openstreet package¶
OpenStreet map with advanced graph functionality built in.
-
class
openstreet.Map¶ Bases:
objectMap provide parsing and storage for OSM format
Map contains three main information: nodes, ways, and bounds. For ways and nodes, both must be accessed using query style or fluent interface.
1 2
map = Map("/path/to/map.osm") streets = map.ways().where_tag_in("highstreet", [ "primary", "secondary" ]).get()
Tag is an element in OSM format looked like these:
<tag key="akeyhere" value="somevalue" />. So using theby_tag_infilter would means looping over all the ways in the OSM with the matching tag “highstreet” and value of “primary” or “secondary”.-
bounds()¶ Return Bounds object of the map
-
nodes()¶ Return query builder to filter ways collection
Refer to NodeQueryBuilder methods for available filters. Call
NodeQueryBuilder.get()when done to retrieve the result. SeeMapdocumentation for example.
-
ways()¶ Return query builder to filter ways collection
Refer to WayQueryBuilder methods for available filters. Call
WayQueryBuilder.get()when done to retrieve the result. SeeMapdocumentation for example.
-
-
class
openstreet.Way¶ Bases:
objectOpenStreet Way object
-
id¶ A numeric Id
-
is_area()¶ Determine whether it is a closed polygon (area) or not
-
nodes¶ A List of Node IDs
A Dictionary of tag key and value
-
-
class
openstreet.Node¶ Bases:
objectOpenStreet Map object
-
id¶ A numeric Id
-
lat¶ Latitude
-
lon¶ Longitude
A Dictionary of tag key and value
-
-
class
openstreet.Bounds¶ Bases:
objectOpenStreet Bounds object
-
maxlat¶ Max latitude
-
maxlon¶ Max longitude
-
minlat¶ Min latitude
-
minlon¶ Min longitude
-
-
class
openstreet.WayQueryBuilder¶ Bases:
objectObject that save filtering operations
-
by_id()¶ Returns Node with given
id
-
get()¶ Returns the filtered Way list
-
where_contain_nodes()¶ Filter Way that contains nodes
nodesSee
Mapdocumentation for usage example.- Parameters
nodes (List[int]) – A list of node ids.
-
-
class
openstreet.NodeQueryBuilder¶ Bases:
objectObject that save filtering operations
-
by_id()¶ Returns Node with given
id
-
get()¶ Returns the filtered Node list
-
where_tag_eq()¶ Filter Node with tag of key
keyequalvalueSee
Mapdocumentation for usage example.- Parameters
key (str) – Key name of the tags.
value (str) – A tag value to filter.
- Returns
self
- Return type
-
where_tag_in()¶ Filter Node with tag of key
keythat contains one ofvalues- Parameters
key (str) – Key name of the tags.
values (List[str]) – Possible tag values to include.
- Returns
self
- Return type
-