get_traffic_nearby
Find nearby traffic counting stations in Switzerland with current volume data. Input coordinates to get traffic monitoring points within a specified radius.
Instructions
Find ASTRA traffic counting stations near a geographic coordinate in Switzerland. Returns nearby stations with traffic volume data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | Latitude in WGS84 (e.g. 47.3769 for Zürich) | |
| lon | Yes | Longitude in WGS84 (e.g. 8.5417 for Zürich) | |
| radius | No | Search radius in meters (default: 5000) |
Implementation Reference
- src/modules/traffic.ts:183-213 (handler)The handler logic for 'get_traffic_nearby' which converts coordinates to LV95 and queries the ASTRA API.
case "get_traffic_nearby": { const lat = args.lat as number; const lon = args.lon as number; const radius = (args.radius as number | undefined) ?? 5000; const [e, n] = wgs84ToLv95(lat, lon); // Build a map extent around the point using the radius const extentPadding = radius * 3; const mapExtent = `${e - extentPadding},${n - extentPadding},${e + extentPadding},${n + extentPadding}`; const url = buildUrl(`${GEO_ADMIN}/identify`, { geometry: `${e},${n}`, geometryType: "esriGeometryPoint", tolerance: radius, mapExtent, imageDisplay: "1,1,96", layers: `all:${TRAFFIC_LAYER}`, returnGeometry: false, }); const data = await fetchJSON<IdentifyResponse>(url); const stations = data.results.map(slimTrafficStation); return JSON.stringify({ count: stations.length, lat, lon, radius_m: radius, stations, source: "ASTRA — Federal Roads Office (Bundesamt für Strassen)", }); } - src/modules/traffic.ts:118-139 (schema)The MCP tool definition and input schema for 'get_traffic_nearby'.
name: "get_traffic_nearby", description: "Find ASTRA traffic counting stations near a geographic coordinate in Switzerland. Returns nearby stations with traffic volume data.", inputSchema: { type: "object", required: ["lat", "lon"], properties: { lat: { type: "number", description: "Latitude in WGS84 (e.g. 47.3769 for Zürich)", }, lon: { type: "number", description: "Longitude in WGS84 (e.g. 8.5417 for Zürich)", }, radius: { type: "number", description: "Search radius in meters (default: 5000)", }, }, }, },