LazMapviewer: Partial fix of gps points created near E/W border not showing.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8798 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-04-21 10:36:50 +00:00
parent 7461eaa8fc
commit 7b8cf5cf0b
2 changed files with 34 additions and 5 deletions

View File

@ -793,8 +793,7 @@ var
begin
Area.TopLeft := Engine.ScreenToLonLat(Point(aLeft, aTop));
Area.BottomRight := Engine.ScreenToLonLat(Point(aRight, aBottom));
while Area.BottomRight.Lon < Area.TopLeft.Lon do
Area.BottomRight.Lon := Area.BottomRight.Lon + 360.0;
Area.Normalize;
if GPSItems.Count > 0 then
begin
@ -1016,13 +1015,25 @@ end;
function TMapView.GetVisibleArea: TRealArea;
var
aPt: TPoint;
w, mapWidth: Int64;
begin
aPt.X := 0;
aPt.Y := 0;
Result.TopLeft := Engine.ScreenToLonLat(aPt);
aPt.X := Width;
aPt.Y := Height;
Result.BottomRight := Engine.ScreenToLonLat(aPt);;
mapWidth := ZoomFactor(Engine.Zoom) * TILE_SIZE;
w := Width;
if w >= mapWidth then
begin
Result.TopLeft.Lon := -180;
Result.BottomRight.Lon := 180;
end else
begin
aPt.X := w;
aPt.Y := Height;
Result.BottomRight := Engine.ScreenToLonLat(aPt);
Result.Normalize;
end;
end;
procedure TMapView.ClearBuffer;

View File

@ -47,11 +47,15 @@ Type
TRealArea = Record
TopLeft : TRealPoint;
BottomRight : TRealPoint;
procedure Normalize;
function Normalized: TRealArea;
end;
implementation
{ TRealPoint }
function TRealPoint.GetLonRad: Extended;
begin
Result := DegToRad(Self.Lon);
@ -72,5 +76,19 @@ begin
Self.Lat := RadToDeg(AValue);
end;
{ TRealArea }
procedure TRealArea.Normalize;
begin
while BottomRight.Lon < TopLeft.Lon do
BottomRight.Lon := BottomRight.Lon + 360.0;
end;
function TRealArea.Normalized: TRealArea;
begin
Result := Self;
Result.Normalize;
end;
end.