From 9d457999008af22d290e4f8526902be385e90450 Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Fri, 27 Mar 2026 08:43:20 +0200 Subject: [PATCH] revert: disable building labels + remove debug endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building labels (C1/C2/C3) disabled — Martin MVT tiles don't include cadastral_ref as a property despite the PostgreSQL view exposing it. Root cause needs investigation (Martin config or alternative tile server). Removed temporary debug endpoints: - /api/eterra/debug-tile-props - /api/eterra/debug-tile-sample Kept /api/eterra/debug-fields (useful long-term diagnostic). Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/api/eterra/debug-tile-props/route.ts | 72 ------------------- src/app/api/eterra/debug-tile-sample/route.ts | 64 ----------------- .../geoportal/components/map-viewer.tsx | 13 +--- .../parcel-sync/components/tabs/map-tab.tsx | 1 - 4 files changed, 3 insertions(+), 147 deletions(-) delete mode 100644 src/app/api/eterra/debug-tile-props/route.ts delete mode 100644 src/app/api/eterra/debug-tile-sample/route.ts diff --git a/src/app/api/eterra/debug-tile-props/route.ts b/src/app/api/eterra/debug-tile-props/route.ts deleted file mode 100644 index 48beaa8..0000000 --- a/src/app/api/eterra/debug-tile-props/route.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { NextResponse } from "next/server"; -import { PrismaClient } from "@prisma/client"; - -const prisma = new PrismaClient(); - -/** - * GET /api/eterra/debug-tile-props?siruta=161829 - * - * Shows what columns the gis_cladiri view exposes (Martin tile properties). - * Also shows a sample building's raw DB data for comparison. - */ -export async function GET(request: Request) { - const url = new URL(request.url); - const siruta = url.searchParams.get("siruta") ?? "161829"; - - // Sample building from DB - const sample = await prisma.gisFeature.findFirst({ - where: { layerId: "CLADIRI_ACTIVE", siruta }, - }); - - // Check what the gis_features view would expose - let viewColumns: string[] = []; - try { - const cols = await prisma.$queryRaw<{ column_name: string }[]>` - SELECT column_name - FROM information_schema.columns - WHERE table_name = 'GisFeature' - ORDER BY ordinal_position - `; - viewColumns = cols.map((c) => c.column_name); - } catch { - viewColumns = ["query failed"]; - } - - // Check gis_cladiri view columns - let viewCladiriColumns: string[] = []; - try { - const cols = await prisma.$queryRaw<{ column_name: string }[]>` - SELECT column_name - FROM information_schema.columns - WHERE table_name = 'gis_cladiri' - ORDER BY ordinal_position - `; - viewCladiriColumns = cols.map((c) => c.column_name); - } catch (e) { - viewCladiriColumns = [ - `query failed: ${e instanceof Error ? e.message : String(e)}`, - ]; - } - - return NextResponse.json({ - gisFeature_columns: viewColumns, - gis_cladiri_view_columns: viewCladiriColumns, - sample_building: sample - ? { - id: sample.id, - layerId: sample.layerId, - siruta: sample.siruta, - objectId: sample.objectId, - cadastralRef: sample.cadastralRef, - areaValue: sample.areaValue, - isActive: sample.isActive, - attributes_keys: Object.keys( - sample.attributes as Record, - ), - has_geom: sample.geometry != null, - enrichment: sample.enrichment, - } - : null, - note: "Martin tiles gis_cladiri expune coloanele din view-ul gis_cladiri. cadastral_ref trebuie sa fie prezent.", - }); -} diff --git a/src/app/api/eterra/debug-tile-sample/route.ts b/src/app/api/eterra/debug-tile-sample/route.ts deleted file mode 100644 index 38987fe..0000000 --- a/src/app/api/eterra/debug-tile-sample/route.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { NextResponse } from "next/server"; - -/** - * GET /api/eterra/debug-tile-sample?siruta=161829 - * - * Fetches an actual vector tile from Martin and decodes the property names. - * This tells us exactly what fields are available in tiles. - */ -export async function GET(request: Request) { - const url = new URL(request.url); - const siruta = url.searchParams.get("siruta") ?? "161829"; - - // Husi coordinates roughly: lat 46.67, lon 28.06 - // At zoom 16: x=38400, y=23200 (approximate) - // Use the Martin catalog to find exact tiles - - const martinUrl = process.env.MARTIN_URL || "http://martin:3000"; - - const result: Record = { siruta }; - - // Check Martin catalog for gis_cladiri - try { - const catRes = await fetch(`${martinUrl}/gis_cladiri`); - const catalog = await catRes.json(); - result.martin_catalog = catalog; - } catch (e) { - result.martin_catalog_error = e instanceof Error ? e.message : String(e); - } - - // Try to get a tile and check its content type / size - // For Husi at zoom 15, approximate tile coords - const testTiles = [ - { z: 15, x: 19043, y: 11680 }, // approximate Husi area - { z: 16, x: 38086, y: 23360 }, - ]; - - for (const t of testTiles) { - try { - const tileRes = await fetch(`${martinUrl}/gis_cladiri/${t.z}/${t.x}/${t.y}`); - result[`tile_${t.z}_${t.x}_${t.y}`] = { - status: tileRes.status, - contentType: tileRes.headers.get("content-type"), - size: tileRes.headers.get("content-length") ?? "unknown", - }; - } catch (e) { - result[`tile_${t.z}_${t.x}_${t.y}`] = { error: e instanceof Error ? e.message : String(e) }; - } - } - - // Check Martin source config - try { - const indexRes = await fetch(`${martinUrl}/catalog`); - const index = await indexRes.json(); - // Find gis_cladiri in the catalog - const cladiriEntry = Array.isArray(index) - ? index.find((e: Record) => e.id === "gis_cladiri") - : (index as Record).gis_cladiri; - result.martin_source_config = cladiriEntry ?? "not found in catalog"; - } catch (e) { - result.martin_index_error = e instanceof Error ? e.message : String(e); - } - - return NextResponse.json(result); -} diff --git a/src/modules/geoportal/components/map-viewer.tsx b/src/modules/geoportal/components/map-viewer.tsx index fa90550..98c7e8f 100644 --- a/src/modules/geoportal/components/map-viewer.tsx +++ b/src/modules/geoportal/components/map-viewer.tsx @@ -58,7 +58,6 @@ 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", @@ -439,15 +438,9 @@ 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 — use SAME source as terenuri to test rendering - // If this works with terenuri source, problem is with gis_cladiri tiles - map.addLayer({ id: LAYER_IDS.cladiriLabel, type: "symbol", source: SOURCES.cladiri, "source-layer": SOURCES.cladiri, minzoom: 15, - layout: { - "text-field": "{cadastral_ref}", - "text-font": ["Noto Sans Regular"], - "text-size": 9, "text-anchor": "top", "text-offset": [0, 1], - }, - paint: { "text-color": "#dc2626", "text-halo-color": "#fff", "text-halo-width": 2 } }); + // TODO: Building body labels (C1, C2...) — disabled pending Martin tile investigation + // Martin MVT tiles don't include cadastral_ref as a property despite the view exposing it. + // Next step: evaluate alternatives (pg_tileserv, GeoJSON source, Martin config). // === 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 1703a4b..1c72065 100644 --- a/src/modules/parcel-sync/components/tabs/map-tab.tsx +++ b/src/modules/parcel-sync/components/tabs/map-tab.tsx @@ -46,7 +46,6 @@ const BASE_LAYERS = [ "l-terenuri-label", "l-cladiri-fill", "l-cladiri-line", - "l-cladiri-label", ]; /* ------------------------------------------------------------------ */