fix: use proj4 +over flag to prevent antimeridian longitude wrapping#353
Closed
yharby wants to merge 1 commit intodevelopmentseed:mainfrom
Closed
fix: use proj4 +over flag to prevent antimeridian longitude wrapping#353yharby wants to merge 1 commit intodevelopmentseed:mainfrom
yharby wants to merge 1 commit intodevelopmentseed:mainfrom
Conversation
proj4's `adjust_lon` normalizes longitude to (-π, π], which causes 360° round-trip errors for coordinates at the antimeridian (±180°): - `forward(-180.001°, lat)` wraps to positive easting (wrong sign) - `inverse(-WM_HALF, northing)` returns +180° instead of -180° These errors make the Delatin mesh refinement unconvergeable for tiles touching the antimeridian on global EPSG:4326 COGs (e.g. a 1.4M×600K pixel DEM spanning ±180° longitude). The round-trip error equals the full image width, producing visibly distorted tile meshes at low zoom. Fix: Add `+over` to the target projection definitions for both the 4326 and 3857 converters. The `+over` flag disables `adjust_lon`, allowing coordinates to pass through unwrapped. This is safe for longlat and Mercator projections where the 180° meridian is a straight line. The `+over` flag is supported since proj4js v2.20.0 (PR proj4js#530). Fixes developmentseed#352
Member
|
This looks very hacky. I think we need a deeper consideration of how to handle images spanning the antimeridian. |
Author
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
+overflag on target projection definitions (EPSG:4326 and EPSG:3857) to disableadjust_lonlongitude normalizationProblem
proj4's
adjust_lonnormalizes longitude to (-π, π], causing:forward(-180.001°, lat)→ positive easting (wrong sign)inverse(-WM_HALF, northing)→ +180° instead of -180°For tiles touching the antimeridian on global EPSG:4326 COGs (e.g. 1.4M×600K pixel DEM), the round-trip error equals the full image width (5625 pixels), producing visibly distorted tile meshes at low zoom levels.
Fix
Add
+overto the target projection definitions:The
+overflag is safe for longlat and Mercator projections where the 180° meridian is a straight line. Supported since proj4js v2.20.0 (proj4js#530).Test plan
Fixes #352