LazMapViewer: Fix floating point error in HaversineAngle. In CalcIntermedPoint, use length units specification in CalcGeoDistance rather than multiplying result by 1000.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9576 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
b361823008
commit
aed26fd17b
@ -76,7 +76,7 @@ end;
|
|||||||
function HaversineAngle(Lat1, Lon1, Lat2, Lon2: Double): Double;
|
function HaversineAngle(Lat1, Lon1, Lat2, Lon2: Double): Double;
|
||||||
var
|
var
|
||||||
latFrom, latTo, lonDiff: Double;
|
latFrom, latTo, lonDiff: Double;
|
||||||
dx, dy, dz: Double;
|
dx, dy, dz, arg: Double;
|
||||||
begin
|
begin
|
||||||
lonDiff := Lon1 - Lon2;
|
lonDiff := Lon1 - Lon2;
|
||||||
latFrom := Lat1;
|
latFrom := Lat1;
|
||||||
@ -86,7 +86,14 @@ begin
|
|||||||
dx := cos(lonDiff) * cos(latFrom) - cos(latTo);
|
dx := cos(lonDiff) * cos(latFrom) - cos(latTo);
|
||||||
dy := sin(lonDiff) * cos(latFrom);
|
dy := sin(lonDiff) * cos(latFrom);
|
||||||
|
|
||||||
Result := arcsin(sqrt(sqr(dx) + sqr(dy) + sqr(dz)) / 2.0) * 2.0;
|
arg := sqrt(sqr(dx) + sqr(dy) + sqr(dz)) / 2.0;
|
||||||
|
if arg >= 1.0 then
|
||||||
|
Result := pi
|
||||||
|
else
|
||||||
|
if arg <= -1.0 then
|
||||||
|
Result := -pi
|
||||||
|
else
|
||||||
|
Result := arcsin(arg) * 2.0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Angles in degrees
|
// Angles in degrees
|
||||||
@ -233,7 +240,7 @@ begin
|
|||||||
Lon := Lon2;
|
Lon := Lon2;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
aD := CalcGeoDistance(Lat1, Lon1, Lat2, Lon2) / EARTH_EQUATORIAL_RADIUS;
|
aD := CalcGeoDistance(Lat1, Lon1, Lat2, Lon2, duMeters) / EARTH_EQUATORIAL_RADIUS;
|
||||||
latFrom := DegToRad(Lat1);
|
latFrom := DegToRad(Lat1);
|
||||||
lonFrom := DegToRad(Lon1);
|
lonFrom := DegToRad(Lon1);
|
||||||
latTo := DegToRad(Lat2);
|
latTo := DegToRad(Lat2);
|
||||||
|
Loading…
Reference in New Issue
Block a user