Repository navigation
feat(core): add experimental CustomProjectionView - #10741
Conversation
|
1434d86 to
3a7069c
Compare
3a7069c to
6b03ef2
Compare
08fb03a to
81a94a1
Compare
81a94a1 to
57b81c9
Compare
fa8a169 to
d5f7aca
Compare
ibgreen
left a comment
There was a problem hiding this comment.
API and fundamental functionality review of the current revision. Two points to address below: source-unit handling in meter-size estimation, and explicit invalidation when the conversion configuration changes.
| metersPerDegree, | ||
| 1 | ||
| ] | ||
| : [1, 1, 1]; |
There was a problem hiding this comment.
[P2] Recognized feet units are treated as meters here. isSphericalCrs classifies both +units=ft and +units=us-ft as linear, but this branch assigns one meter to each source unit. For an otherwise undistorted converter with forward([x, y, z]) => [0.3048 * x, 0.3048 * y, z], the estimator returns a scale of 0.3048 instead of 1, so meter-based sizes render at 30.48% of their intended size unless getDistanceScale is supplied. Could we use the actual source-unit-to-meter factor, or require an explicit scale callback for unsupported units? Please include a feet-to-meters regression case; the current recognized-linear-units test expects the same scale for feet and meters.
There was a problem hiding this comment.
units=ft is not a supported scenario. getDistanceScale is the wrong surface for that correction, because it does not apply to position projection, only size projections. The viewport currently documents preprojected value as "map coordinate in meters" and no unit conversion mechanism is exposed.
We can revisit when we integrate the new math.gl projection module.
| this.isGeospatial = true; | ||
| this.bearing = bearing; | ||
| this.resolution = resolution; | ||
| this.signature = JSON.stringify([fromCrs, toCrs, resolution]); |
There was a problem hiding this comment.
[P2] Could we give applications an explicit way to invalidate preprojected geometry when conversion semantics change? I agree with keeping converter object identity out of this signature because React can recreate equivalent converters. However, changing fromBounds changes preproject output while this signature remains unchanged, allowing prepared layer positions to retain the old bounds while viewport projection/picking uses the new bounds. A converter can also change behavior with the same CRS identifiers. Including the bounds values and adding a projectionRevision (or equivalent explicit trigger) would cover both cases without unnecessary updates on callback recreation. Applications should be able to refresh geometry while keeping accurate CRS identifiers and the same subdivision resolution.
There was a problem hiding this comment.
fromBounds is intended to be an inherited property of the fromCrs and/or projection method (e.g. the latitude range of [-85.051129, 85.051129] of Web Mercator projection), not the bounding box of a layer's data. It is used to inform the viewport that the project function cannot produce a valid output if the input is outside of the bounds. Therefore it should never change on its own without the identity of the projection changing.
|
Thanks Xiaoji — this is a useful step toward making deck.gl work with a broader range of coordinate datasets and map projections. The application-supplied converter and a separate planar view give us a practical foundation while keeping the projection engine outside core. Supporting a non-Mercator rendering plane is especially valuable. A few directional ideas as we shape the API:
These are direction-setting ideas, not a request to implement all of them in this PR. I would like us to address the two inline points on source-unit scaling and conversion invalidation, and keep this experimental API moving forward. |
d5f7aca to
6f2fd7e
Compare
bdbbce5 to
adcb376
Compare
adcb376 to
bf605e1
Compare
…reographic COGs (#694) * ci: build examples under examples/experimental Add `examples/experimental/*` to the pnpm workspace and to the docs workflow's example build loop. The loop skips directories without a package.json: `examples/experimental/` itself matches `examples/*/`, and a failed `node -p` would abort the step under `bash -e`. Both hunks are byte-identical to the ones in #647, so the two branches merge cleanly in either order. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(examples): add experimental custom projection example Render COGs in arbitrary planar map projections (Arctic and Antarctic polar stereographic, Equal Earth, Web Mercator), with no basemap. Polar data can't be shown in Web Mercator at all, and choosing a projection is routine in GIS workflows. deck.gl merged experimental support for this as `_CustomProjectionView` (visgl/deck.gl#10741), but it ships with deck.gl v10. The example uses a stand-in on deck.gl 9.4's `OrthographicView` with the same options and `{center, zoom}` view state, so moving to the official view is an import swap in the example plus a globe-detection fix in deck.gl-raster (see the README). - `src/custom-projection/`: the view, viewport and controller stand-in. Common space and zoom match upstream, and so do `preproject`, `postUnproject`, `projectFlat` and `projectionSignature`. - `src/projected-cog-layer/`: `ProjectedCOGLayer`, a `COGLayer` that selects tiles in the map CRS and has `RasterLayer` mesh each tile in map meters (`coordinateSystem: "cartesian"`). Domain-aware culling and trimming, pole and antimeridian handling, and LOD measured on screen. - Vector context (coastlines, graticule, domain outline) is projected on the CPU. - Data: GEBCO 2026, the NASA Explorer Base Map (native EPSG:3031), EOxCloudless, and ITS_LIVE ice velocity (EPSG:3031 and EPSG:3413). No library code changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * add app experimental box * clean up app wording * cleaner labels * perf(examples): cut pole mesh cost in custom projection example Zooming in over a pole was slow: a view at zoom 8 meshed 1.15M triangles and spent ~26 s in proj4. The reprojector measures error in source pixels as if they were square, but lng/lat pixels near a pole are only cos(lat) as wide as they are tall on a polar map, so it kept splitting triangles to fix sub-screen-pixel column errors. - Stretch each geographic tile's pixel grid horizontally by the pixels' aspect ratio on the map before meshing (columnErrorScale). RasterLayer only uses `width` to size the mesh grid, so passing width * scale with matching transforms reweighs column error without changing UVs. The ratio is measured in the output map, so it also holds for Equal Earth. - Stop meshing geographic tiles at 89.5° instead of one row from the pole, which halves the remaining pole triangles. Over the pole at zoom 8: 1.15M -> 31k triangles, ~26 s -> 0.7 s of meshing. Visible map-space error is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * cleaner label * update README * add experimental section to docs --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…'s crs-based API (#882) > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. deck.gl published [`10.0.0-alpha.1`](https://github.com/visgl/deck.gl/releases/tag/v10.0.0-alpha.1). Its experimental `_CustomProjectionView` API 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 under `packages/` changes. Ref #695 ### What changed upstream | | October (visgl/deck.gl#10741) | `10.0.0-alpha.1` | | --- | --- | --- | | Projection input | `projection: {forward, inverse}`, `fromCrs`, `toCrs` | **`crs`**: an EPSG code, PROJ string, WKT or PROJJSON, resolved by math.gl's `projectionEngine.getCRS` | | Resolution | synchronous | **asynchronous**: `view.initialize()`, which `Deck` awaits | | World coordinates | `fromCrs` | **always WGS84** | | Domain | `fromBounds` | **set by the projection**: `crs.converter.WGS84.normalize` | | Conversions | `viewport.preproject` / `postUnproject` | `viewport.crs.converter.WGS84.from` / `to` | ### What changes in the example - **The stand-in** (`src/custom-projection/`) takes a `crs` and resolves it with `@math.gl/geospatial` `5.0.0-beta.8`, the version alpha.1 pins, through a cached `resolveCRS`. The viewport exposes `crs`, and `projectionSignature` is `[crs.signature, resolution]`. It still differs from upstream in three ways: - top-down camera only; - meter-based CRSs only, because deck.gl 9.4's `Viewport` constructor calls `projectFlat` before a subclass can store a per-CRS scale; - `project` and `unproject` stay in map meters. - **`ProjectedCOGLayer`** converts through `viewport.crs.converter.WGS84`, and takes its lng/lat domain from the CRS's `normalize` clamp. It no longer has a `fromBounds` prop, and the presets no longer carry one. - **The app** resolves the selected preset's CRS before handing the view to `DeckGL`, because deck.gl 9.4 doesn't await `initialize()`. Until the new CRS resolves, the previous projection stays on screen, so `DeckGL` never remounts. - **The README** says how to move the example to deck.gl v10. - **`examples/_shared`** now declares `@math.gl/web-mercator: ^4.1.0`. Without it, pnpm resolved `@deck.gl/mapbox`'s `@math.gl/web-mercator` peer (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. <!-- before/after screenshots --> ### 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: | View | `main` | This PR | | --- | --- | --- | | Arctic, default | 10 | 10 | | Antarctic, default | 10 | 10 | | Equal Earth, default | 4 | 4 | | Web Mercator, default | 8 | 8 | | Antarctic, NASA basemap and ITS_LIVE | 13 | 13 | | Arctic, zoom 0.6 | 3 | **13** | | Antarctic, zoom 0.6 | 4 | **14** | Every view finished loading in under 8 seconds, with no new console messages. - **Switching projections:** switching five times, 40 ms apart, kept one `Deck` instance and only custom projection viewports. - **Cursor:** off the map (above, below or beside it) it reads "—". Beside the Equal Earth and Web Mercator maps, math.gl's inverse returns a wrapped longitude instead of throwing, so the stand-in keeps the October stand-in's round-trip check. 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 typecheck` and `pnpm check`. 🤖 Written by [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
For #10739 (PR 2 of 6)
Introduce a planar map view backed by application-supplied coordinate converters.
Changed list
Note
Medium Risk
Touches core viewports, controllers, layer preprojection, and shader uniforms—wide rendering impact though gated behind experimental exports and documented layer limits.
Overview
Adds an experimental planar map stack (
_CustomProjectionView,_CustomProjectionViewport,_CustomProjectionController) so apps can supplyforward/inverseconverters (e.g. proj4) and render with MapView-stylecenter/zoom/pitch/bearing. Positions are CPU-preprojected to map meters, with optionalfromBoundsclamping,resolutionfor curved geometry, CRS metadata (fromCrs/toCrs) driving layer refresh viaprojectionSignature, and meter-size distortion handling throughgetDistanceScaleor CRS heuristics.CustomProjectionControlleranchors pan/zoom on the common ground plane, supports world-coordinatemaxBounds, and is exported from@deck.gl/coreanddeck.glonly under_-prefixed names. Documentation, TOC, and What's New are updated; tests cover Web Mercator camera parity, controller gestures, layer preprojection/cartesian behavior, and shader altitude/precision.Reviewed by Cursor Bugbot for commit bf605e1. Bugbot is set up for automated code reviews on this repo. Configure here.