fetch_road_network
Fetch OpenStreetMap road and optional waterway data for a bounding box, returning geometry and attributes to support EPANET network generation, with class filtering and paging.
Instructions
Fetch the road network for a geographic bounding box from OpenStreetMap (fixed public Overpass endpoint only — never Nominatim, never a caller-supplied URL) and return structured road geometry and attributes for future EPANET network generation: OSM way id, name, highway classification, full WGS84 geometry, length (m), and lanes/maxspeed/surface/oneway/bridge/tunnel where OSM has them (missing tags come back null). When waterwayTypes is set, matching linear waterway ways (river/stream/brook/canal/drain/ditch — for river-intake placement) are fetched in the same request and returned under waterways with way id, name, waterway class, geometry, length (m), and width/intermittent/tunnel. The bounding box is validated (ranges, min < max, per-axis span and total area caps) and the results are capped (maxResults, default 500, hard cap 5000) and pageable (offset; roads and waterways are paged independently with the same offset/maxResults). The Overpass query requests only the requested highway/waterway classes (roadTypes/waterwayTypes whitelists; roadTypes defaults to the standard drivable set, waterwayTypes is off unless given), carries a descriptive User-Agent, has a 30 s timeout and a 25 MB response cap, and fails closed on any Overpass error/timeout. Identical (bbox, roadTypes, waterwayTypes) requests are served from a short-lived in-memory cache. PURE READ: no network session, model, or file is touched — nothing is generated or optimized yet. Data © OpenStreetMap contributors, licensed ODbL (https://www.openstreetmap.org/copyright).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxLat | Yes | North latitude (WGS84 degrees) of the bounding box. | |
| maxLon | Yes | East longitude (WGS84 degrees) of the bounding box. | |
| minLat | Yes | South latitude (WGS84 degrees) of the bounding box. | |
| minLon | Yes | West longitude (WGS84 degrees) of the bounding box. | |
| offset | No | Zero-based page offset; combine with maxResults to page through large areas (roads are ordered by OSM way id). | |
| roadTypes | No | Highway classes to fetch, e.g. ["residential", "tertiary"]. Defaults to the standard drivable set (motorway/trunk/primary/secondary/tertiary/unclassified/residential/living_street/road/service/track). Unknown values are rejected, never silently dropped. | |
| maxResults | No | Page size (default 500, hard cap 5000); combine with offset to page through large areas. | |
| waterwayTypes | No | Waterway classes to fetch alongside the roads, e.g. ["river", "stream", "canal"] for river-intake placement. Linear channels only: river/stream/brook/canal/drain/ditch. When set, matching waterway ways are returned under `waterways` (way id, name, waterway class, geometry, length, width/intermittent/tunnel) in the same request. Unknown values are rejected, never silently dropped. When omitted, only roads are fetched. |