зеркало из https://github.com/mozilla/gecko-dev.git
Bug 515335. Distance calculation between 2 geocoordinates incorrect for points not on the equator. r=dougt.
--HG-- extra : rebase_source : 7f73773d16fb2ecee1f57e0c106b014c2f424de9
This commit is contained in:
Родитель
e44e74289c
Коммит
fdb442917d
|
@ -540,11 +540,17 @@ nsGeolocationService::IsBetterPosition(nsIDOMGeoPosition *aSomewhere)
|
|||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
// check to see if there has been a large movement
|
||||
double delta = fabs(newLat - oldLat) + fabs(newLon + oldLon);
|
||||
// Use spherical law of cosines to calculate difference
|
||||
// Not quite as correct as the Haversine but simpler and cheaper
|
||||
double radsInDeg = 3.14159265 / 180.0;
|
||||
|
||||
// Convert to meters. 1 second of arc of latitude (or longitude at the
|
||||
// equator) is 1 nautical mile or 1852m.
|
||||
delta *= 60 * 1852;
|
||||
double rNewLat = newLat * radsInDeg;
|
||||
double rNewLon = newLon * radsInDeg;
|
||||
double rOldLat = oldLat * radsInDeg;
|
||||
double rOldLon = oldLon * radsInDeg;
|
||||
|
||||
// WGS84 equatorial radius of earth = 6378137m
|
||||
double delta = acos( (sin(rNewLat) * sin(rOldLat)) + (cos(rNewLat) * cos(rOldLat) * cos(rOldLon - rNewLon)) ) * 6378137;
|
||||
|
||||
// The threshold is when the distance between the two positions exceeds the
|
||||
// worse (larger value) of the two accuracies.
|
||||
|
|
Загрузка…
Ссылка в новой задаче