LazMapViewer: Fix TMapViewerEngine.CrossesDateLine. Based on patch by Ekkehard Domning. Less hints and warnings.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9352 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
5d277d115f
commit
744fe8c3a3
@ -156,11 +156,11 @@ type
|
||||
procedure WriteProvidersToXML(AFileName: String);
|
||||
|
||||
procedure DblClick(Sender: TObject);
|
||||
procedure MouseDown(Sender: TObject; Button: TMouseButton;
|
||||
procedure MouseDown(Sender: TObject; {%H-}Button: TMouseButton;
|
||||
{%H-}Shift: TShiftState; X, Y: Integer);
|
||||
procedure MouseMove(Sender: TObject; {%H-}Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
procedure MouseUp(Sender: TObject; Button: TMouseButton;
|
||||
procedure MouseUp(Sender: TObject; {%H-}Button: TMouseButton;
|
||||
{%H-}Shift: TShiftState; X, Y: Integer);
|
||||
procedure MouseWheel(Sender: TObject; {%H-}Shift: TShiftState;
|
||||
WheelDelta: Integer; {%H-}MousePos: TPoint; var Handled: Boolean);
|
||||
@ -415,21 +415,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Returns true when the visible window crosses the date line, i.e. the longitudes
|
||||
at the left of the window are > 0, and those at the right are < 0. }
|
||||
{ Returns true when the visible window crosses the date line, i.e. the
|
||||
longitudes at the left of the window are greater than those at the right. }
|
||||
function TMapViewerEngine.CrossesDateline: Boolean;
|
||||
var
|
||||
visArea: TRealArea;
|
||||
mapWidth: Int64;
|
||||
begin
|
||||
// A non-cyclic map cannot cross the date line.
|
||||
if not FCyclic then
|
||||
exit(false);
|
||||
|
||||
// Catch the case, that the screen is wider than the whole world
|
||||
mapWidth := ZoomFactor(MapWin.Zoom) * TILE_SIZE;
|
||||
mapWidth := mvGeoMath.ZoomFactor(MapWin.Zoom) * TILE_SIZE;
|
||||
Result := (MapWin.Width > mapWidth);
|
||||
if not Result then
|
||||
begin
|
||||
// Or: date line is visible when the longitude of the map's left side is
|
||||
// larger than the longitude of the right side.
|
||||
visArea.TopLeft := ScreenToLatLon(Point(0, 0));
|
||||
visArea.BottomRight := ScreenToLatLon(Point(Width, Height));
|
||||
Result := (visArea.TopLeft.Lon > 0) and (visArea.BottomRight.Lon < 0);
|
||||
Result := visArea.TopLeft.Lon > visArea.BottomRight.Lon;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -734,7 +740,7 @@ var
|
||||
mPoint : TPoint;
|
||||
PType: TProjectionType;
|
||||
begin
|
||||
mapWidth := round(ZoomFactor(AWin.Zoom)) * TILE_SIZE;
|
||||
mapWidth := round(mvGeoMath.ZoomFactor(AWin.Zoom)) * TILE_SIZE;
|
||||
|
||||
if FCyclic then
|
||||
begin
|
||||
@ -770,7 +776,7 @@ begin
|
||||
// note: coth: ** for better readability, but breaking OmniPascal in VSCode
|
||||
// Result.LonRad := ( APoints.X / (( TILE_SIZE / (2*pi)) * 2**Zoom) ) - pi;
|
||||
// Result.LatRad := arctan( sinh(pi - (APoints.Y/TILE_SIZE) / 2**Zoom * pi*2) );
|
||||
zoomFac := ZoomFactor(Zoom);
|
||||
zoomFac := mvGeoMath.ZoomFactor(Zoom);
|
||||
Result.LonRad := ( APoint.X / (( TILE_SIZE / (2*pi)) * zoomFac) ) - pi;
|
||||
Result.LatRad := arctan( sinh(pi - (APoint.Y/TILE_SIZE) / zoomFac * pi*2) );
|
||||
|
||||
@ -812,8 +818,8 @@ begin
|
||||
// https://pubs.usgs.gov/pp/1395/report.pdf, page 44
|
||||
|
||||
Z := 23 - Zoom;
|
||||
zoomFac := ZoomFactor(Z);
|
||||
WorldSize := ZoomFactor(31);
|
||||
zoomFac := mvGeoMath.ZoomFactor(Z);
|
||||
WorldSize := mvGeoMath.ZoomFactor(31);
|
||||
Cpm := WorldSize / EARTH_CIRCUMFERENCE;
|
||||
|
||||
LonRad := (APoint.x / (Cpm/zoomFac) - EARTH_CIRCUMFERENCE/2) / EARTH_EQUATORIAL_RADIUS;
|
||||
|
Loading…
Reference in New Issue
Block a user