Skip to content

Instantly share code, notes, and snippets.

@yuba
Last active December 1, 2017 14:13
Show Gist options
  • Save yuba/eb7a84fe9bc3fcd4d52b32a45f0e7b89 to your computer and use it in GitHub Desktop.
Save yuba/eb7a84fe9bc3fcd4d52b32a45f0e7b89 to your computer and use it in GitHub Desktop.
地球を真球と仮定して2地点間の距離を算出する ref: https://qiita.com/yuba/items/4372944ce0f6a0bf6cb5
distance_km = 6371 * acos(
cos(latA/180*pi) * cos((lonB - lonA)/180*pi) * cos(latB/180*pi) +
sin(latA/180*pi) * sin(latB/180*pi)
);
distance_km = 6371 * acos(
cos(lonA/180*pi) * cos(latA/180*pi) * cos(lonB/180*pi) * cos(latB/180*pi) +
sin(lonA/180*pi) * cos(latA/180*pi) * sin(lonB/180*pi) * cos(latB/180*pi) +
sin(latA/180*pi) * sin(latB/180*pi)
);
distance_km = 6371 * acos(
cos(latA/180*pi) * cos((lonB - lonA)/180*pi) * cos(latB/180*pi) +
sin(latA/180*pi) * sin(latB/180*pi)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment