Skip to content

fix(raster-reproject): measure output mode's pixel size away from a center that has none - #717

Merged
kylebarron merged 1 commit into
mainfrom
kyle/output-pixel-size-fallback
Oct 16, 2026
Merged

kylebarron merged 1 commit into
mainfrom
kyle/output-pixel-size-fallback

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Note that this can increase the number of forward projection calls done to infer the pixel size (up to 100 total forward projection calls), but this is only for tiles whose center is +-85 deg on a web mercator map.

As described by Claude:

Only when the center has no size (its center is past 85.05° on Web Mercator) does it measure the 5x5 grid. That's 25 × 4 = 100 projections, once per tile, not per triangle.


Note

This PR was written by Claude (Claude Code), not by @kylebarron.

Output mode (_errorSpace: "output") measures its unit, one input pixel's size on the map, at the center of the meshed area. Where the pixel there has no size, the reprojector threw, so RasterLayer drew nothing for that tile.

That happens to polar tiles on a Web Mercator map. Web Mercator clamps latitudes past 85.05° onto the map's top edge, so a tile whose center is past that limit, such as an overview tile of an EPSG:3413 or EPSG:3031 COG around the pole, measures a pixel size of 0. Input mode doesn't converge on those tiles either, but it meshes them. So this blocks making output mode the only mode in the layers.

What changes. When the pixel at the center has no size, the reprojector measures across a 5x5 grid over the meshed area, edges and corners included, and uses the median of the sizes that are finite and positive. It throws only if none are. The edges matter: of a 1000 km tile around the pole, only the corners are inside the latitude limit. Tiles whose center pixel has a size keep exactly the meshes they had.

On EPSG:3413 tiles of 256 px, in output mode:

Polar tile Before After
Pole at the center, 1000 km throws stops at the iteration cap, as input mode does
Pole at the center, 4000 km throws stops at the iteration cap, as input mode does
Center at 86°N throws converges in 3,167 triangles (input mode stops at 10,003)
Center at 81°N 475 triangles unchanged

Tests. A map that's flat in a band around the center row gets its pixel size from the grid. A 1000 km polar tile around the pole gets a finite, positive pixel size; this one fails without the grid's edges. A map that's flat everywhere still throws.

🤖 Written by Claude Code

…enter that has none

Output mode measures its unit, one input pixel's size on the map, at the
center of the meshed area. A polar tile whose center is past Web Mercator's
latitude limit has no size there, because the clamp collapses it onto the
map's top edge, so the reprojector threw and the tile wasn't drawn.

When the pixel at the center has no size, the pixel size is now the median of
the finite, positive sizes on a 5x5 grid across the meshed area, edges
included. Tiles whose center pixel has a size keep their meshes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the fix label Oct 15, 2026

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kylebarron
kylebarron merged commit ded7611 into main Oct 16, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/output-pixel-size-fallback branch October 16, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant