fix: handle antimeridian-crossing tiles in Web Mercator reprojection#374
Open
james-willis wants to merge 1 commit intodevelopmentseed:mainfrom
Open
fix: handle antimeridian-crossing tiles in Web Mercator reprojection#374james-willis wants to merge 1 commit intodevelopmentseed:mainfrom
james-willis wants to merge 1 commit intodevelopmentseed:mainfrom
Conversation
Tiles near ±180° longitude cause RasterReprojector mesh refinement to diverge because forwardTo3857 maps nearby source coordinates on opposite sides of the antimeridian to EPSG:3857 x-values ~40M meters apart. Detect these tiles by checking if corner x-values in EPSG:3857 span more than half the world circumference, then wrap the projection functions to make the coordinate space continuous. Extract the wrapping logic into wrapAntimeridianProjections() in proj.ts with unit tests covering no-op passthrough, wrapping detection, coordinate continuity, and forward/inverse round-tripping. Closes developmentseed#366
39cf0d5 to
7280242
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #366 — COG tiles near ±180° longitude cause
RasterReprojectormesh refinement to diverge in Web Mercator mode.Problem
When rendering an EPSG:4326 COG that spans the antimeridian,
forwardTo3857maps nearby source coordinates on opposite sides of ±180° to EPSG:3857 x-values ~40 million meters apart (+20M vs -20M). The mesh triangles connecting these vertices span the entire map, and the reprojection error never converges (currentError=43200after 10001 iterations).Solution
In
COGLayer._renderSubLayers, for the Web Mercator code path:+circumferenceso the tile's coordinate space is continuous (all positive), and unwrap in the inverse directionThis makes the mesh subdivision see a smooth, continuous coordinate space instead of a discontinuity, allowing
RasterReprojectorto converge normally.Changes
packages/deck.gl-geotiff/src/cog-layer.ts:HALF_CIRCUMFERENCEconstant_renderSubLayersTesting
pnpm build)pnpm lint)