debug: add /api/eterra/debug-tile-props to check Martin tile columns
Temporary diagnostic to verify what columns gis_cladiri view exposes for Martin vector tiles. Needed to debug missing C1/C2 labels. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
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.",
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user