From 1919155d412859ed05f81f0607a34b9cd5b1ddfc Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Wed, 25 Mar 2026 01:15:00 +0200 Subject: [PATCH] perf: hide basemap boundaries, remove UAT layers, optimize Martin minzoom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Basemap cleanup (after map load): - Hide OpenFreeMap boundary/admin layers (redundant with our UATs) - Keep city/town place labels, remove village-level - Hide our Martin UAT layers (not needed in ParcelSync — filtered by siruta) Martin tile optimization: - gis_terenuri_status minzoom: 10 → 13 (parcels not visible below 13) - gis_cladiri_status minzoom: 12 → 14 (buildings not visible below 14) - Prevents unnecessary tile fetches at low zoom levels Applied to both ParcelSync Harta tab and Portal map. Requires docker restart martin. Co-Authored-By: Claude Opus 4.6 (1M context) --- martin.yaml | 4 +- src/app/(portal)/portal/page.tsx | 30 +++++++++++++ .../parcel-sync/components/tabs/map-tab.tsx | 42 +++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/martin.yaml b/martin.yaml index 86191fa..dd536e8 100644 --- a/martin.yaml +++ b/martin.yaml @@ -100,7 +100,7 @@ postgres: geometry_column: geom srid: 3844 bounds: [20.2, 43.5, 30.0, 48.3] - minzoom: 10 + minzoom: 13 maxzoom: 18 properties: object_id: text @@ -120,7 +120,7 @@ postgres: geometry_column: geom srid: 3844 bounds: [20.2, 43.5, 30.0, 48.3] - minzoom: 12 + minzoom: 14 maxzoom: 18 properties: object_id: text diff --git a/src/app/(portal)/portal/page.tsx b/src/app/(portal)/portal/page.tsx index e6349fb..dae2fb8 100644 --- a/src/app/(portal)/portal/page.tsx +++ b/src/app/(portal)/portal/page.tsx @@ -1242,6 +1242,36 @@ function HartaContent() { .catch(() => {}); }, [selectedSiruta]); + // Hide basemap admin boundaries + our UAT layers + const cleanedBasemapRef = useRef(false); + useEffect(() => { + if (!mapReady) { cleanedBasemapRef.current = false; return; } + if (cleanedBasemapRef.current) return; + const map = asMap(mapHandleRef.current); + if (!map) return; + cleanedBasemapRef.current = true; + try { + const style = (map as unknown as { getStyle(): { layers?: { id: string }[] } }).getStyle(); + if (style?.layers) { + for (const layer of style.layers) { + const id = layer.id.toLowerCase(); + if (id.includes("boundary") || id.includes("admin") || + (id.includes("place") && !id.includes("place-city") && !id.includes("place-town"))) { + map.setLayoutProperty(layer.id, "visibility", "none"); + } + } + } + } catch { /* noop */ } + const uatLayers = [ + "l-uats-z0-line", "l-uats-z5-fill", "l-uats-z5-line", + "l-uats-z8-fill", "l-uats-z8-line", "l-uats-z8-label", + "l-uats-z12-fill", "l-uats-z12-line", "l-uats-z12-label", + ]; + for (const lid of uatLayers) { + try { if (map.getLayer(lid)) map.setLayoutProperty(lid, "visibility", "none"); } catch { /* noop */ } + } + }, [mapReady]); + // When map becomes ready, fitBounds ONCE per siruta useEffect(() => { if (!mapReady || !boundsRef.current || !selectedSiruta) return; diff --git a/src/modules/parcel-sync/components/tabs/map-tab.tsx b/src/modules/parcel-sync/components/tabs/map-tab.tsx index 1656f1d..e378190 100644 --- a/src/modules/parcel-sync/components/tabs/map-tab.tsx +++ b/src/modules/parcel-sync/components/tabs/map-tab.tsx @@ -150,6 +150,48 @@ export function MapTab({ siruta, sirutaValid, sessionConnected, syncLocalCount, return () => clearInterval(check); }, [sirutaValid, mapReady]); + /* ── Hide basemap admin boundaries + our UAT layers (we use siruta filter) */ + const cleanedBasemapRef = useRef(false); + useEffect(() => { + if (!mapReady) { + cleanedBasemapRef.current = false; + return; + } + if (cleanedBasemapRef.current) return; + const map = asMap(mapHandleRef.current); + if (!map) return; + cleanedBasemapRef.current = true; + + // Hide OpenFreeMap admin boundary and place layers (redundant — we have our own UATs) + try { + const style = (map as unknown as { getStyle(): { layers?: { id: string }[] } }).getStyle(); + if (style?.layers) { + for (const layer of style.layers) { + const id = layer.id.toLowerCase(); + if ( + id.includes("boundary") || + id.includes("admin") || + (id.includes("place") && !id.includes("place-city") && !id.includes("place-town")) + ) { + map.setLayoutProperty(layer.id, "visibility", "none"); + } + } + } + } catch { + /* noop */ + } + + // Hide our Martin UAT layers (not needed when filtering by siruta) + const uatLayers = [ + "l-uats-z0-line", "l-uats-z5-fill", "l-uats-z5-line", + "l-uats-z8-fill", "l-uats-z8-line", "l-uats-z8-label", + "l-uats-z12-fill", "l-uats-z12-line", "l-uats-z12-label", + ]; + for (const lid of uatLayers) { + try { if (map.getLayer(lid)) map.setLayoutProperty(lid, "visibility", "none"); } catch { /* noop */ } + } + }, [mapReady]); + /* ── Fetch UAT bounds ──────────────────────────────────────── */ const prevBoundsSirutaRef = useRef(""); useEffect(() => {