Skip to content

Commit 3d819a9

Browse files
author
wilhel1812
committed
fix: use Math.round for tile latStart/lonStart to handle GeoTIFF FP precision
Copernicus DEM GeoTIFF files for latitude bands N03, N15, and N63 have ModelTiepoint Y coordinates slightly below the expected integer (e.g., 63.99999999999999 instead of 64.0). Math.floor(minLat) then rounded down to the wrong tile index, causing entire latitude bands of terrain data to be unfindable. Fixes #817
1 parent 1b1af00 commit 3d819a9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/lib/copernicusTerrainClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ const parseCopernicusTileInMain = async (
307307
}
308308
return {
309309
key: tileKey,
310-
latStart: Math.floor(minLat),
311-
lonStart: Math.floor(minLon),
310+
latStart: Math.round(minLat),
311+
lonStart: Math.round(minLon),
312312
size: Math.max(width, height),
313313
width,
314314
height,

src/workers/copernicusTileParser.worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ const parse = async (message: TileParserRequestMessage): Promise<TileParserRespo
5959
key: message.key,
6060
dataset: message.dataset,
6161
path: message.path,
62-
latStart: Math.floor(minLat),
63-
lonStart: Math.floor(minLon),
62+
latStart: Math.round(minLat),
63+
lonStart: Math.round(minLon),
6464
width,
6565
height,
6666
elevations: out,

0 commit comments

Comments
 (0)