lazmapviewer: Allow to scroll beyond the date limit. Patch by Ekkehard Domning (https://www.lazarusforum.de/viewtopic.php?p=135037).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8789 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-04-15 09:44:43 +00:00
parent 6d9dd703f0
commit a530b02b06

View File

@ -403,7 +403,7 @@ begin
MaxY := (Int64(aWin.Height) div TILE_SIZE) + 1;
startX := -aWin.X div TILE_SIZE;
startY := -aWin.Y div TILE_SIZE;
Result.Left := startX;
Result.Left := startX - 1;
Result.Right := startX + MaxX;
Result.Top := startY;
Result.Bottom := startY + MaxY;
@ -683,10 +683,13 @@ var
iMapWidth: Int64;
mPoint : TPoint;
begin
// review: coth: respective projection check. move to subfunctions? figure out what did i mean here...
iMapWidth := Round(IntPower(2, AWin.Zoom)) * TILE_SIZE;
mPoint.X := EnsureRange(APoint.X - AWin.X, 0, iMapWidth);
mPoint.X := (APoint.X - AWin.X) mod iMapWidth;
while mPoint.X < 0 do
mPoint.X := mPoint.X + iMapWidth;
while mPoint.X >= iMapWidth do
mPoint.X := mPoint.X - iMapWidth;
mPoint.Y := EnsureRange(APoint.Y - AWin.Y, 0, iMapWidth);
case aWin.MapProvider.ProjectionType of
@ -967,17 +970,22 @@ var
x, y : Integer; //int64;
Tiles: TTileIdArray = nil;
iTile: Integer;
numTiles: Integer;
begin
if not(Active) then
Exit;
Queue.CancelAllJob(self);
TilesVis := CalculateVisibleTiles(aWin);
numTiles := 1 shl aWin.Zoom;
SetLength(Tiles, (TilesVis.Bottom - TilesVis.Top + 1) * (TilesVis.Right - TilesVis.Left + 1));
iTile := Low(Tiles);
for y := TilesVis.Top to TilesVis.Bottom do
for X := TilesVis.Left to TilesVis.Right do
begin
Tiles[iTile].X := X;
//Tiles[iTile].X := X;
Tiles[iTile].X := X mod numTiles;
if Tiles[iTile].X < 0 then
Tiles[iTile].X := Tiles[iTile].X + numTiles;
Tiles[iTile].Y := Y;
Tiles[iTile].Z := aWin.Zoom;
if IsValidTile(aWin, Tiles[iTile]) then
@ -1213,15 +1221,36 @@ var
EnvTile: TEnvTile;
img: TLazIntfImage;
X, Y: integer;
worldWidth: Integer;
numTiles: Integer;
baseX: Integer;
begin
EnvTile := TEnvTile(Data);
try
if IsCurrentWin(EnvTile.Win)then
begin
Cache.GetFromCache(EnvTile.Win.MapProvider, EnvTile.Tile, img);
X := EnvTile.Win.X + EnvTile.Tile.X * TILE_SIZE; // begin of X
Y := EnvTile.Win.Y + EnvTile.Tile.Y * TILE_SIZE; // begin of Y
DrawTile(EnvTile.Tile, X, Y, img);
Y := EnvTile.Win.Y + EnvTile.Tile.Y * TILE_SIZE; // begin of Y
baseX := EnvTile.Win.X + EnvTile.Tile.X * TILE_SIZE; // begin of X
numTiles := 1 shl EnvTile.Win.Zoom;
worldWidth := numTiles * TILE_SIZE;
// From the center to the left (western) hemisphere
X := baseX;
while (X+TILE_SIZE >= 0) do
begin
DrawTile(EnvTile.Tile, X, Y, img);
X := X - worldWidth;
end;
// From the center to the right (eastern) hemisphere
X := baseX + worldWidth;
while ((X-TILE_SIZE) <= EnvTile.Win.Width) do
begin
DrawTile(EnvTile.Tile, X, Y, img);
X := X + worldWidth;
end;
end;
finally
FreeAndNil(EnvTile);