From acb9be83450be6d0c40d82dadbf4c831e130489d Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Fri, 27 Mar 2026 06:53:45 +0200 Subject: [PATCH] feat(geoportal): building body labels (C1, C2, C3...) on map at zoom 17+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extracts body suffix from cadastral_ref (e.g. "77102-C1" → "C1") and displays as centered label on each building polygon. Only visible at zoom 17+ to avoid clutter at lower zooms. Applied to both geoportal map-viewer and parcel-sync map tab. Uses siruta filter in parcel-sync tab. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../geoportal/components/map-viewer.tsx | 26 +++++++++++++++++++ .../parcel-sync/components/tabs/map-tab.tsx | 1 + 2 files changed, 27 insertions(+) diff --git a/src/modules/geoportal/components/map-viewer.tsx b/src/modules/geoportal/components/map-viewer.tsx index 96cd423..0abee83 100644 --- a/src/modules/geoportal/components/map-viewer.tsx +++ b/src/modules/geoportal/components/map-viewer.tsx @@ -58,6 +58,7 @@ const LAYER_IDS = { terenuriLabel: "l-terenuri-label", cladiriFill: "l-cladiri-fill", cladiriLine: "l-cladiri-line", + cladiriLabel: "l-cladiri-label", selectionFill: "l-selection-fill", selectionLine: "l-selection-line", drawPolygonFill: "l-draw-polygon-fill", @@ -438,6 +439,31 @@ export const MapViewer = forwardRef( paint: { "fill-color": "#3b82f6", "fill-opacity": 0.5 } }); map.addLayer({ id: LAYER_IDS.cladiriLine, type: "line", source: SOURCES.cladiri, "source-layer": SOURCES.cladiri, minzoom: 14, paint: { "line-color": "#1e3a5f", "line-width": 0.6 } }); + // Building body labels (C1, C2...) — only at high zoom to avoid clutter + map.addLayer({ id: LAYER_IDS.cladiriLabel, type: "symbol", source: SOURCES.cladiri, "source-layer": SOURCES.cladiri, minzoom: 17, + layout: { + "text-field": [ + "case", + // Extract body suffix: "77102-C1" → "C1", "77102-C2" → "C2" + ["has", "cadastral_ref"], + ["case", + ["!=", ["index-of", "-C", ["get", "cadastral_ref"]], -1], + ["slice", ["get", "cadastral_ref"], ["+", ["index-of", "-C", ["get", "cadastral_ref"]], 1]], + "" // no "-C" suffix → no label + ], + "" + ], + "text-font": ["Noto Sans Regular"], + "text-size": 10, + "text-anchor": "center", + "text-allow-overlap": false, + }, + paint: { + "text-color": "#1e40af", + "text-halo-color": "#ffffff", + "text-halo-width": 1.2, + }, + }); // === Selection highlight === map.addLayer({ id: LAYER_IDS.selectionFill, type: "fill", source: SOURCES.terenuri, "source-layer": SOURCES.terenuri, minzoom: 13, diff --git a/src/modules/parcel-sync/components/tabs/map-tab.tsx b/src/modules/parcel-sync/components/tabs/map-tab.tsx index 1c72065..1703a4b 100644 --- a/src/modules/parcel-sync/components/tabs/map-tab.tsx +++ b/src/modules/parcel-sync/components/tabs/map-tab.tsx @@ -46,6 +46,7 @@ const BASE_LAYERS = [ "l-terenuri-label", "l-cladiri-fill", "l-cladiri-line", + "l-cladiri-label", ]; /* ------------------------------------------------------------------ */