Merge pull request #552 from berkenbu/master

Fix great circle formula in distance calculation
pull/554/head
Gordon Williams 2020-08-26 07:46:35 +01:00 committed by GitHub
commit 9675565550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View File

@ -361,7 +361,7 @@
{ "id": "gpsnav",
"name": "GPS Navigation",
"icon": "icon.png",
"version":"0.03",
"version":"0.04",
"description": "Displays GPS Course and Speed, + Directions to waypoint and waypoint recording, now with waypoint editor",
"tags": "tool,outdoors,gps",
"readme": "README.md",

View File

@ -1,4 +1,4 @@
0.01: New App!
0.02: Add SCREENACCESS interface
0.03: Add Waypoint Editor
0.04: Fix great circle formula

View File

@ -93,9 +93,8 @@ function bearing(a,b){
}
function distance(a,b){
var x = radians(a.lon-b.lon) * Math.cos(radians((a.lat+b.lat)/2));
var y = radians(b.lat-a.lat);
return Math.round(Math.sqrt(x*x + y*y) * 6371000);
var dsigma = Math.acos(Math.sin(radians(a.lat))*Math.sin(radians(b.lat))+Math.cos(radians(a.lat))*Math.cos(radians(b.lat))*Math.cos(radians(a.lon-b.lon)));
return Math.round(dsigma*6371000);
}
var selected = false;