From 311f63e81255930b50cd5448cf58f6e6e231415a Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Fri, 27 Mar 2026 08:22:26 +0200 Subject: [PATCH] debug: add /api/eterra/debug-tile-sample for Martin tile diagnostics Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/api/eterra/debug-tile-sample/route.ts | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/app/api/eterra/debug-tile-sample/route.ts diff --git a/src/app/api/eterra/debug-tile-sample/route.ts b/src/app/api/eterra/debug-tile-sample/route.ts new file mode 100644 index 0000000..38987fe --- /dev/null +++ b/src/app/api/eterra/debug-tile-sample/route.ts @@ -0,0 +1,64 @@ +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); +}