1 | static double geoDistance_km(double lat1, double long1, double lat2, double long2) { |
2 | double _eQuatorialEarthRadius = 6371; |
3 | double _d2r = (Math.PI / 180D); |
4 | double dlong = (long2 - long1) * _d2r; |
5 | double dlat = (lat2 - lat1) * _d2r; |
6 | double a = Math.pow(Math.sin(dlat / 2D), 2D) + Math.cos(lat1 * _d2r) * Math.cos(lat2 * _d2r) |
7 | * Math.pow(Math.sin(dlong / 2D), 2D); |
8 | double c = 2D * Math.atan2(Math.sqrt(a), Math.sqrt(1D - a)); |
9 | double d = _eQuatorialEarthRadius * c; |
10 | return d; |
11 | } |
Began life as a copy of #1008302
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008304 |
Snippet name: | geoDistance_km |
Eternal ID of this version: | #1008304/5 |
Text MD5: | 3e6f43bea96bb819138ceb8fb808b70c |
Author: | stefan |
Category: | javax / math |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-07 01:38:58 |
Source code size: | 508 bytes / 11 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 620 / 589 |
Version history: | 4 change(s) |
Referenced in: | [show references] |