Fix data dropping across the antimeridian#70
Open
Shane98c wants to merge 7 commits into
Open
Conversation
Co-authored-by: Eric Gagliano <egagli@uw.edu>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ender on the globe (#58)
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.
Closes #53. Closes #64. Closes #58. This supersedes #65 to point to latest main (sorry for letting that get stale @egagli, I added you as co-author to these commits).
When a viewport straddles 180, MapLibre's
getBounds()reports unwrapped longitudes (e.g. west=104, east=255 at center 180), and two selection paths dropped data on one side until the user panned across:getTilesAtZoomclamped lon to [-180, 180] when computing tile-X, so tiles past the dateline were never requested. (EPSG:4326's path never clamped: whytasmaxworked but the EPSG:3857 pyramids didn't.)getVisibleRegions' overlap test wasn't antimeridian-aware, so far-side regions failed the comparison.map-utils.ts:getTilesAtZoomno longer clamps lon (existingwrappedXfold handles both wrapped and unwrapped bounds; normal views unchanged). NewlonRangeOverlapsdoes an antimeridian-aware overlap that solves for every world-copy offset k·360 (not just ±360), so it's correct for distantrenderWorldCopiespans and 0–360 stores.untiled-mode.ts:getVisibleRegionsuseslonRangeOverlaps;getCandidateRegionswidens to all X columns when crossing (the overlap check trims it back, so no over-fetch).Also ports #65's separate
worldFractionfix (co-authored @egagli): proj4 bbox corners can project out-of-domain (e.g. MODIS sinusoidal) -> NaN worldFraction -> broken level selection; falls back to the equatorial strip and clamps to <= 1.This also covers two more antimeridian rendering paths that the selection fix alone didn't:
zarr-layer.ts: setswrapTileId = trueso Mapbox renders draped tiles into wrapped world copies. Under terrain the drapedrenderToTilepath only drew the canonical world, so one side of the dateline stayed blank even with data loaded (depends on the selection fix above to have data on both sides).mesh-reprojector.ts: culls out-of-domain reprojected vertices and triangles with globe-spanning edges, so source-projected meshes that wrap past 180 (e.g. sinusoidal) no longer draw a flat sheet through the center of the globe on MapLibre / smear across the whole globe on Mapbox.Strip-chunked stores on the globe (#58)
Some virtual stores chunk the data into thin strips: a single row of latitude (or column of longitude) spanning the whole extent. A region maps to one chunk, so these became full-width, near-flat strips that didn't reproject correctly on the globe (mercator was fine): they smeared north on the globe.
mesh-reprojector.ts/untiled-mode.ts: the reprojected mesh now tessellates each axis independently (a non-square uniform grid via separatelonSubdivisions/latSubdivisions) instead of a single square subdivision count. Each axis getsceil(span)(~1 vertex/degree), clamped to[MIN_SUBDIVISIONS, MAX_SUBDIVISIONS]. Two concerns:MIN_SUBDIVISIONSraised 2 → 8 (constants.ts). A single-row strip has a near-zero short span; with only 2 cross-vertices, hard data/nodata edges smeared on the globe (worst on MapLibre globe). The floor guarantees enough cross-vertices regardless of span. Works for row and column chunks alike — whichever axis is thin hits the floor.This replaces an earlier longitude-only heuristic; the per-axis
ceil(span)+ floor subsumes it and also removed the dense-subdivision sliver triangles that flickered when overzoomed.