revert: disable building labels + remove debug endpoints

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) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-27 08:43:20 +02:00
parent 946723197e
commit 9d45799900
4 changed files with 3 additions and 147 deletions
@@ -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<string, unknown>,
),
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.",
});
}
@@ -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<string, unknown> = { 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<string, unknown>) => e.id === "gis_cladiri")
: (index as Record<string, unknown>).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);
}
@@ -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<MapViewerHandle, MapViewerProps>(
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,
@@ -46,7 +46,6 @@ const BASE_LAYERS = [
"l-terenuri-label",
"l-cladiri-fill",
"l-cladiri-line",
"l-cladiri-label",
];
/* ------------------------------------------------------------------ */