Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tiler): Ensure rendered tiles does not exceed bounds #1036

Merged
merged 2 commits into from
Aug 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/tiler/src/tiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ export class Tiler {
// Determine the pixels that are needed from the source tiff to render the XYZ Tile
const requiredTifPixels = rasterBounds.intersection.subtract(rasterBounds.tiff);

const { tileSize } = img;
const startX = Math.floor((requiredTifPixels.x / tileSize.width) * pixelScale);
const endX = Math.ceil((requiredTifPixels.right / tileSize.width) * pixelScale);
const startY = Math.floor((requiredTifPixels.y / tileSize.height) * pixelScale);
const endY = Math.ceil((requiredTifPixels.bottom / tileSize.height) * pixelScale);
const { tileSize, tileCount } = img;
const startX = Math.max(Math.floor((requiredTifPixels.x / tileSize.width) * pixelScale), 0);
const endX = Math.min(Math.ceil((requiredTifPixels.right / tileSize.width) * pixelScale), tileCount.x);
const startY = Math.max(Math.floor((requiredTifPixels.y / tileSize.height) * pixelScale), 0);
const endY = Math.min(Math.ceil((requiredTifPixels.bottom / tileSize.height) * pixelScale), tileCount.y);

const composites = [];
const pixelScaleInv = 1 / pixelScale;
Expand Down