Skip to content

Add grid selector with projection-aware map extent - #3489

Merged
sbrunner merged 2 commits into
masterfrom
feature/admin-test-grid-selector
Apr 23, 2026
Merged

Add grid selector with projection-aware map extent#3489
sbrunner merged 2 commits into
masterfrom
feature/admin-test-grid-selector

Conversation

@sbrunner

Copy link
Copy Markdown
Member

Summary

  • add a grid selector in the admin test layers panel and persist the selected grid in the permalink for the active layer only
  • rebuild WMTS sources when grid or dimension changes, and keep tile debug aligned with the active layer grid
  • preserve the displayed extent when switching projection by transforming the current extent/center to the newly selected grid projection

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +385 to +401
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;

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +460 to +465
const initialProjection = projectionFromCode(initialProjectionCode);
const initialCenter =
initialProjectionCode === defaultProjectionCode
? defaultCenter
: ol.proj.transform(defaultCenter, defaultProjectionCode, initialProjectionCode);

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@sbrunner
sbrunner force-pushed the feature/admin-test-grid-selector branch from 83a56f8 to 68ad808 Compare April 23, 2026 10:29
@sbrunner
sbrunner merged commit 0e2e7bc into master Apr 23, 2026
14 checks passed
@sbrunner
sbrunner deleted the feature/admin-test-grid-selector branch April 23, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants