get_trail_closures_nearby
Find hiking trail closures and detours near your location in Switzerland using GPS coordinates. Check for disruptions within a specified radius to plan safe routes.
Instructions
Find Swiss hiking trail closures and detours near a given GPS coordinate. Converts WGS84 coordinates to Swiss LV95 and queries the swisstopo identify endpoint. Returns closures within the specified radius.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | Latitude in WGS84 (e.g. 46.9480 for Bern). | |
| lon | Yes | Longitude in WGS84 (e.g. 7.4474 for Bern). | |
| radius | No | Search radius in metres. Default: 10000 (10 km). Max: 50000. |
Implementation Reference
- src/modules/hiking.ts:264-321 (handler)The handler function for 'get_trail_closures_nearby', which converts WGS84 coordinates to LV95 and queries the swisstopo identify endpoint.
async function handleGetTrailClosuresNearby( args: Record<string, unknown> ): Promise<string> { const lat = Number(args.lat); const lon = Number(args.lon); if (isNaN(lat) || isNaN(lon)) { throw new Error("lat and lon must be valid numbers"); } if (lat < 45.0 || lat > 48.0 || lon < 5.5 || lon > 11.0) { throw new Error("Coordinates appear to be outside Switzerland (lat 45–48, lon 5.5–11)"); } const radius = Math.min(50000, Math.max(1, Number(args.radius) || 10000)); // Convert WGS84 → LV95 const [e, n] = wgs84ToLv95(lat, lon); // Build map extent based on radius (approx 1 metre = 1 LV95 unit) const extent = `${e - radius},${n - radius},${e + radius},${n + radius}`; const url = buildUrl(`${BASE}/identify`, { layers: `all:${LAYER}`, geometry: `${e},${n}`, geometryType: "esriGeometryPoint", sr: 2056, tolerance: radius, imageDisplay: "1,1,100", mapExtent: extent, returnGeometry: false, }); const data = await fetchJSON<FindResponse>(url); const closures = deduplicate((data.results ?? []).map(slimClosure)); const result = { count: closures.length, query: { lat, lon, radius_m: radius, lv95_e: Math.round(e), lv95_n: Math.round(n), }, source: "ASTRA / Schweizer Wanderwege (swisstopo ch.astra.wanderland-sperrungen_umleitungen)", closures, }; const json = JSON.stringify(result); if (json.length > 49000) { const trimmed = { ...result, closures: closures.map((c) => ({ ...c, description: c.description.slice(0, 100) })), }; return JSON.stringify(trimmed); } return json; } - src/modules/hiking.ts:147-171 (registration)The definition and registration of the 'get_trail_closures_nearby' tool including its schema.
{ name: "get_trail_closures_nearby", description: "Find Swiss hiking trail closures and detours near a given GPS coordinate. " + "Converts WGS84 coordinates to Swiss LV95 and queries the swisstopo identify endpoint. " + "Returns closures within the specified radius.", inputSchema: { type: "object", properties: { lat: { type: "number", description: "Latitude in WGS84 (e.g. 46.9480 for Bern).", }, lon: { type: "number", description: "Longitude in WGS84 (e.g. 7.4474 for Bern).", }, radius: { type: "number", description: "Search radius in metres. Default: 10000 (10 km). Max: 50000.", }, }, required: ["lat", "lon"], }, },