Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,18 @@ function sampleReferencePointsInEPSG3857(
const geoY = minY + relY * (maxY - minY);

// Reproject to Web Mercator (EPSG 3857)
const projected = projectTo3857([geoX, geoY]);
refPointPositions.push(projected);
const [projectedX, projectedY] = projectTo3857([geoX, geoY]);

// Handle invalid projections (e.g., latitudes beyond ±85.05° produce NaN/Infinity)
// Clamp Y to valid Web Mercator bounds in EPSG:3857 meters
//
// Note that whenever a NaN is created from a positive geoY, that this must
// be the north pole. And vice versa for negative geoY.
const clampedY = Number.isFinite(projectedY)
? projectedY
: Math.sign(geoY) * EPSG_3857_HALF_CIRCUMFERENCE;

refPointPositions.push([projectedX, clampedY]);
}

return refPointPositions;
Expand Down