Add grid selector with projection-aware map extent - #3489
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a grid selector to the admin OpenLayers test page and makes map view/debug behavior grid- and projection-aware, while also exposing --grid in the default allowed-arguments configuration.
Changes:
- Add per-layer WMTS grid selection UI and persist active grid in the permalink for the active layer.
- Rebuild WMTS sources when grid/dimension changes and keep the TileDebug layer aligned with the active grid’s tile grid/projection.
- Preserve displayed extent/center when switching grid projections by transforming the current view state.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tilecloud_chain/tests/test_ui.py |
Extends UI template-string assertions to cover new grid selector + projection-change behavior. |
tilecloud_chain/templates/openlayers.html |
Implements grid selection, source rebuilds, debug-layer syncing, and projection-aware view updates. |
tilecloud_chain/schema.json |
Adds --grid to the default server.allowed_arguments list in the schema. |
tilecloud_chain/configuration.py |
Updates generated defaults/docs to include --grid in ALLOWED_ARGUMENTS_DEFAULT and Server docstring. |
tilecloud_chain/CONFIG.md |
Updates documented default allowed_arguments to include --grid. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const currentExtent = currentView.calculateExtent(size); | ||
| if (currentProjectionCode !== nextProjectionCode) { | ||
| transformedExtent = ol.proj.transformExtent( | ||
| currentExtent, | ||
| currentProjectionCode, | ||
| nextProjectionCode | ||
| ); | ||
| } else { | ||
| transformedExtent = currentExtent; | ||
| } | ||
| } | ||
|
|
||
| if (currentCenter) { | ||
| if (currentProjectionCode && currentProjectionCode !== nextProjectionCode) { | ||
| nextCenter = ol.proj.transform(currentCenter, currentProjectionCode, nextProjectionCode); | ||
| } else { | ||
| nextCenter = currentCenter; |
There was a problem hiding this comment.
updateViewForLayer unconditionally calls ol.proj.transformExtent / ol.proj.transform when switching between different grid projection codes. If the target projection isn’t registered in proj4/OpenLayers (only {{ srs }} is defined above), these calls can throw at runtime (“No transform for …”), breaking the test page when a layer exposes multiple grids with different EPSG codes. Consider checking that a transform exists (e.g., via ol.proj.getTransform(...)) or wrapping the transform in try/catch and falling back to default center/zoom/extent when transforms are unavailable (and/or registering proj4 definitions for all grid projections).
| const initialProjection = projectionFromCode(initialProjectionCode); | ||
| const initialCenter = | ||
| initialProjectionCode === defaultProjectionCode | ||
| ? defaultCenter | ||
| : ol.proj.transform(defaultCenter, defaultProjectionCode, initialProjectionCode); | ||
|
|
There was a problem hiding this comment.
Initial view setup transforms defaultCenter into initialProjectionCode when it differs from {{ srs }}. As with the projection-change logic later, this can throw if the grid’s projection isn’t registered / doesn’t have a transform from the default projection. Guard this transform (or ensure all grid projections are registered with proj4) so the page still loads when capabilities expose a grid in another EPSG.
83a56f8 to
68ad808
Compare
Summary