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 WriteProvidersToXML(AFileName: String);
|
||||||
|
|
||||||
procedure DblClick(Sender: TObject);
|
procedure DblClick(Sender: TObject);
|
||||||
procedure MouseDown(Sender: TObject; Button: TMouseButton;
|
procedure MouseDown(Sender: TObject; {%H-}Button: TMouseButton;
|
||||||
{%H-}Shift: TShiftState; X, Y: Integer);
|
{%H-}Shift: TShiftState; X, Y: Integer);
|
||||||
procedure MouseMove(Sender: TObject; {%H-}Shift: TShiftState;
|
procedure MouseMove(Sender: TObject; {%H-}Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
procedure MouseUp(Sender: TObject; Button: TMouseButton;
|
procedure MouseUp(Sender: TObject; {%H-}Button: TMouseButton;
|
||||||
{%H-}Shift: TShiftState; X, Y: Integer);
|
{%H-}Shift: TShiftState; X, Y: Integer);
|
||||||
procedure MouseWheel(Sender: TObject; {%H-}Shift: TShiftState;
|
procedure MouseWheel(Sender: TObject; {%H-}Shift: TShiftState;
|
||||||
WheelDelta: Integer; {%H-}MousePos: TPoint; var Handled: Boolean);
|
WheelDelta: Integer; {%H-}MousePos: TPoint; var Handled: Boolean);
|
||||||
@ -415,21 +415,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Returns true when the visible window crosses the date line, i.e. the longitudes
|
{ Returns true when the visible window crosses the date line, i.e. the
|
||||||
at the left of the window are > 0, and those at the right are < 0. }
|
longitudes at the left of the window are greater than those at the right. }
|
||||||
function TMapViewerEngine.CrossesDateline: Boolean;
|
function TMapViewerEngine.CrossesDateline: Boolean;
|
||||||
var
|
var
|
||||||
visArea: TRealArea;
|
visArea: TRealArea;
|
||||||
mapWidth: Int64;
|
mapWidth: Int64;
|
||||||
begin
|
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
|
// 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);
|
Result := (MapWin.Width > mapWidth);
|
||||||
if not Result then
|
if not Result then
|
||||||
begin
|
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.TopLeft := ScreenToLatLon(Point(0, 0));
|
||||||
visArea.BottomRight := ScreenToLatLon(Point(Width, Height));
|
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;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -734,7 +740,7 @@ var
|
|||||||
mPoint : TPoint;
|
mPoint : TPoint;
|
||||||
PType: TProjectionType;
|
PType: TProjectionType;
|
||||||
begin
|
begin
|
||||||
mapWidth := round(ZoomFactor(AWin.Zoom)) * TILE_SIZE;
|
mapWidth := round(mvGeoMath.ZoomFactor(AWin.Zoom)) * TILE_SIZE;
|
||||||
|
|
||||||
if FCyclic then
|
if FCyclic then
|
||||||
begin
|
begin
|
||||||
@ -770,7 +776,7 @@ begin
|
|||||||
// note: coth: ** for better readability, but breaking OmniPascal in VSCode
|
// note: coth: ** for better readability, but breaking OmniPascal in VSCode
|
||||||
// Result.LonRad := ( APoints.X / (( TILE_SIZE / (2*pi)) * 2**Zoom) ) - pi;
|
// Result.LonRad := ( APoints.X / (( TILE_SIZE / (2*pi)) * 2**Zoom) ) - pi;
|
||||||
// Result.LatRad := arctan( sinh(pi - (APoints.Y/TILE_SIZE) / 2**Zoom * pi*2) );
|
// 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.LonRad := ( APoint.X / (( TILE_SIZE / (2*pi)) * zoomFac) ) - pi;
|
||||||
Result.LatRad := arctan( sinh(pi - (APoint.Y/TILE_SIZE) / zoomFac * pi*2) );
|
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
|
// https://pubs.usgs.gov/pp/1395/report.pdf, page 44
|
||||||
|
|
||||||
Z := 23 - Zoom;
|
Z := 23 - Zoom;
|
||||||
zoomFac := ZoomFactor(Z);
|
zoomFac := mvGeoMath.ZoomFactor(Z);
|
||||||
WorldSize := ZoomFactor(31);
|
WorldSize := mvGeoMath.ZoomFactor(31);
|
||||||
Cpm := WorldSize / EARTH_CIRCUMFERENCE;
|
Cpm := WorldSize / EARTH_CIRCUMFERENCE;
|
||||||
|
|
||||||
LonRad := (APoint.x / (Cpm/zoomFac) - EARTH_CIRCUMFERENCE/2) / EARTH_EQUATORIAL_RADIUS;
|
LonRad := (APoint.x / (Cpm/zoomFac) - EARTH_CIRCUMFERENCE/2) / EARTH_EQUATORIAL_RADIUS;
|
||||||
|
Loading…
Reference in New Issue
Block a user