debug: add /api/eterra/debug-tile-sample for Martin tile diagnostics
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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<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);
|
||||
}
|
||||
Reference in New Issue
Block a user