From c97cb5bdd31e32af07b2d3b641c7a3fd6696aa35 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 19 Jul 2026 02:21:06 +0200 Subject: [PATCH] Center map on selected work area --- CHANGELOG.md | 3 +++ .../test_sprint186_map_first_geographic_explorer.py | 2 ++ docs/CODEX_EXECUTION_LOG.md | 3 +++ frontend/src/components/GeoMap.tsx | 9 +++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 509ddceb..3ec7ea2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,9 @@ the workbench, so national Statbel 2025 population data is no longer mislabeled as a 2019 thematic raster. Selection-bounded SPW/UrbIS results remain available through the exact on-demand acquisition path. +- Made a changed work area take viewport priority over a complete national + layer, so switching between Belgium, Wallonia, Brussels and the North Sea + visibly centers the map on the selected geography. ## Autonomous Belgium and North Sea RC program (2026-07-17) diff --git a/backend/tests/test_sprint186_map_first_geographic_explorer.py b/backend/tests/test_sprint186_map_first_geographic_explorer.py index d77019e4..9132787a 100644 --- a/backend/tests/test_sprint186_map_first_geographic_explorer.py +++ b/backend/tests/test_sprint186_map_first_geographic_explorer.py @@ -48,6 +48,8 @@ def test_map_rectangle_drag_is_wired_to_automatic_analysis() -> None: assert "resizeObserver.observe(containerRef.current)" in geomap assert "fitDataOnChangeRef.current" in geomap assert "map.fitBounds(bounds, { padding: 40, duration: 0 })" in geomap + assert "const areaChanged = lastFittedAreaRef.current !== areaData" in geomap + assert "areaChanged && areaData" in geomap assert "resizeObserver.disconnect()" in geomap assert ".workbench-main .geo-map-canvas .map-container" in styles assert "position: absolute;" in styles diff --git a/docs/CODEX_EXECUTION_LOG.md b/docs/CODEX_EXECUTION_LOG.md index be3ee9f1..05c0bda3 100644 --- a/docs/CODEX_EXECUTION_LOG.md +++ b/docs/CODEX_EXECUTION_LOG.md @@ -44,6 +44,9 @@ on-demand placeholders. National Statbel 2025 population is now presented as the active source, while selection-bounded PICC/UrbIS acquisitions remain available only through an exact bounded request. +- Live browser verification found that a changed work area was fitted together + with the complete active national layer. Area changes now fit the selected + geography first; subsequent layer changes retain the existing fit behavior. - Focused backend and frontend suites passed before full release validation; full local and Tower evidence follows in the final P5 gate. diff --git a/frontend/src/components/GeoMap.tsx b/frontend/src/components/GeoMap.tsx index a31aa7cb..409b45aa 100644 --- a/frontend/src/components/GeoMap.tsx +++ b/frontend/src/components/GeoMap.tsx @@ -500,8 +500,13 @@ function GeoMap({ ) } - const activeCollection = fitDataOnChange ? mergeFeatureCollections([areaData, data]) : areaData - const shouldFitArea = fitDataOnChange || lastFittedAreaRef.current !== areaData + const areaChanged = lastFittedAreaRef.current !== areaData + const activeCollection = areaChanged && areaData + ? areaData + : fitDataOnChange + ? mergeFeatureCollections([areaData, data]) + : areaData + const shouldFitArea = fitDataOnChange || areaChanged if (activeCollection && shouldFitArea) { const bounds = collectCoordinates(activeCollection) if (bounds) {