Repository navigation
refactor(examples): move the custom projection example to deck.gl v10's crs-based API - #882
Merged
Merged
Conversation
…example deck.gl 10.0.0-alpha.1 changed the experimental custom projection API that the example's deck.gl 9.4 stand-in copied in October: views now take a `crs` that math.gl resolves into a descriptor, and `fromBounds`, `projection`, `fromCrs` and `toCrs` are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h.gl 5, as in deck.gl v10 deck.gl 10.0.0-alpha.1's `_CustomProjectionView` takes a `crs` (an EPSG code, PROJ string, WKT or PROJJSON) and resolves it asynchronously with math.gl's projection engine; the `projection`, `fromCrs`, `toCrs` and `fromBounds` props are gone. The example's deck.gl 9.4 stand-in now does the same with `@math.gl/geospatial` 5.0.0-beta.8, the version alpha.1 pins, and `ProjectedCOGLayer` converts through `viewport.crs.converter`. Presets still pass their `fromBounds`, so the maps look as before. `examples/_shared` now declares the `@math.gl/web-mercator` peer of `@deck.gl/mapbox` itself: otherwise pnpm resolved that peer to the new 5.0 beta for every example with a MapLibre overlay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… CRS deck.gl 10.0.0-alpha.1 drops `fromBounds`: a math.gl CRS descriptor's `normalize` clamps positions into the projection's rendering extent instead. `ProjectedCOGLayer` now derives its lng/lat domain from that clamp, so it no longer takes a `fromBounds` prop, and the presets no longer carry one. The polar presets now reach math.gl's extent, 60° past the equator, instead of the example's 20°. Co-Authored-By: Claude Opus 5.5 <[email protected]>
….0.0-alpha.1 Explains how the stand-in follows v10's API, how to move the example to deck.gl v10, and what the domain is now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Beside the Equal Earth and Web Mercator maps, math.gl's inverse returns a wrapped longitude instead of throwing, so the cursor readout showed a wrong coordinate where it used to show "—". The stand-in's inverse now projects the result back and rejects it unless it lands where it came from, as the October stand-in did. This also covers the camera's world center, and a new test pins the same check in `ProjectedCOGLayer`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…as built The README's steps for moving to deck.gl v10 keep `pixelToWorld`, which the app imports from the stand-in. The spec now records the meters-only scale, the app's wait on `resolveCRS`, and the round-trip check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
commented
Nov 13, 2026
kylebarron
left a comment
Member
Author
There was a problem hiding this comment.
There will still be a lot of changes and review before this gets merged into primary project code when v10 is released, but this looks like a good update to align with upstream v10 alphas.
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.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
deck.gl published
10.0.0-alpha.1. Its experimental_CustomProjectionViewAPI has changed since the custom projection example copied it in October (#694). This moves the example's deck.gl 9.4 stand-in to the alpha.1 API, so the example shows how upstream works now. The example stays on deck.gl 9.4, and nothing underpackages/changes.Ref #695
What changed upstream
10.0.0-alpha.1projection: {forward, inverse},fromCrs,toCrscrs: an EPSG code, PROJ string, WKT or PROJJSON, resolved by math.gl'sprojectionEngine.getCRSview.initialize(), whichDeckawaitsfromCrsfromBoundscrs.converter.WGS84.normalizeviewport.preproject/postUnprojectviewport.crs.converter.WGS84.from/toWhat changes in the example
src/custom-projection/) takes acrsand resolves it with@math.gl/geospatial5.0.0-beta.8, the version alpha.1 pins, through a cachedresolveCRS. The viewport exposescrs, andprojectionSignatureis[crs.signature, resolution]. It still differs from upstream in three ways:Viewportconstructor callsprojectFlatbefore a subclass can store a per-CRS scale;projectandunprojectstay in map meters.ProjectedCOGLayerconverts throughviewport.crs.converter.WGS84, and takes its lng/lat domain from the CRS'snormalizeclamp. It no longer has afromBoundsprop, and the presets no longer carry one.DeckGL, because deck.gl 9.4 doesn't awaitinitialize(). Until the new CRS resolves, the previous projection stays on screen, soDeckGLnever remounts.examples/_sharednow declares@math.gl/web-mercator: ^4.1.0. Without it, pnpm resolved@deck.gl/mapbox's@math.gl/web-mercatorpeer (range^4.1.0) to the new 5.0 beta for every example with a MapLibre overlay.Visible change
The polar maps now reach math.gl's extent, 60° past the equator, instead of the example's 20°. The default views look the same.
Checks
math.gl's conversions match proj4's to within a micrometer at sample points inside each preset's extent, for all four presets.
COG range requests per view, in headed Chrome:
mainEvery view finished loading in under 8 seconds, with no new console messages.
Deckinstance and only custom projection viewports.The example's main bundle chunk grows from 1,592 KB to 1,801 KB, +67 KB gzipped, all of it math.gl's projection engine. Apache Arrow isn't bundled.
The example's 56 tests pass, and so do
pnpm -r --filter=!docs typecheckandpnpm check.🤖 Written by Claude Code