Last active
December 24, 2015 21:58
-
-
Save sakurabird/6869023 to your computer and use it in GitHub Desktop.
Android 緯度経度から2点間の距離をメートルで返す
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 緯度経度から2点間の距離をメートルで返す | |
| * | |
| * @param lat_a | |
| * @param lng_a | |
| * @param lat_b | |
| * @param lng_b | |
| * @return | |
| */ | |
| public static double getDistance(double lat_a, double lng_a, double lat_b, double lng_b) { | |
| Location locationA = new Location("point A"); | |
| locationA.setLatitude(lat_a); | |
| locationA.setLongitude(lng_a); | |
| Location locationB = new Location("point B"); | |
| locationB.setLatitude(lat_b); | |
| locationB.setLongitude(lng_b); | |
| double distance = locationA.distanceTo(locationB); | |
| return distance; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment