iduedu.PbfSource¶
- class iduedu.PbfSource(path)[source]¶
A local OpenStreetMap
.osm.pbffile answering the queries IduEdu otherwise sends to Overpass.For a city, pass a compact per-city file cut with
iduedu.osm_pbf.split_by_polygons(); reading a whole country extract works too, but the first query then scans the whole file. Later queries on the same source read only the blocks of the file they need.- Parameters:
- Raises:
FileNotFoundError – When
pathdoes not exist.ValueError – When the file is not an OSM
.pbffile.
Methods
The relation
osm_idasrelation(<osm_id>); out geom;returns it (empty list when absent).out centerelements of the given members (dicts withtypeandref), sorted by type and id.Tags and coordinates of members, keyed by
(type, id), asfetch_member_tagsreturns them.Public-transport route elements in a polygon, shaped as
get_routes_by_polyreturns them.The replication timestamp from the file header, see
snapshot_time().Ways matching an Overpass tag filter inside a polygon.
The ways of
ways_by_filter()as a table, without the per-point dictionaries.- snapshot_time()[source]¶
The replication timestamp from the file header, see
snapshot_time().
- ways_by_filter(polygon, way_filter)[source]¶
Ways matching an Overpass tag filter inside a polygon.
Equivalent to
way<way_filter>(poly:"..."); out geom;. Returns Overpassout geomway elements{"type": "way", "id", "bounds", "nodes", "geometry": [{"lat", "lon"}], "tags"}.
- ways_table(polygon, way_filter)[source]¶
The ways of
ways_by_filter()as a table, without the per-point dictionaries.Columns
type("way"),id,nodes(list of node ids),geometry((k, 2)array of lon/lat) andtags. The street builders read this; it holds the same data as the Overpass elements.
- routes_by_poly(polygon, public_transport_types)[source]¶
Public-transport route elements in a polygon, shaped as
get_routes_by_polyreturns them.Reproduces, statement by statement and in the same order, the Overpass query of
iduedu.overpass.downloaders.get_routes_by_poly(): tags of the member ways and then of the member nodes of ground routes (out tags), the ground route relations (out geom) and theirroute_masterrelations (out body) and, forsubway, the relations sharing a node with a subway route (out geom), their stop-area groups (out body), the stations among their members (out tags), the route masters of the subway routes (out body), thestop_area_memberssection marker and all their members (out center).One difference in shape: a way member of a ground route relation carries its
geometryas a read-only(k, 2)lon/lat array, shared by all the routes along the way, not as a list of{"lat", "lon"}dicts; the route parser reads both.
- member_elements(members)[source]¶
out centerelements of the given members (dicts withtypeandref), sorted by type and id.