openstreet package¶
OpenStreet map with advanced graph functionality built in.
-
class
openstreet.
Map
¶ Bases:
object
Map 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_in
filter 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. SeeMap
documentation 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. SeeMap
documentation for example.
-
-
class
openstreet.
Way
¶ Bases:
object
OpenStreet 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:
object
OpenStreet Map object
-
id
¶ A numeric Id
-
lat
¶ Latitude
-
lon
¶ Longitude
A Dictionary of tag key and value
-
-
class
openstreet.
Bounds
¶ Bases:
object
OpenStreet Bounds object
-
maxlat
¶ Max latitude
-
maxlon
¶ Max longitude
-
minlat
¶ Min latitude
-
minlon
¶ Min longitude
-
-
class
openstreet.
WayQueryBuilder
¶ Bases:
object
Object 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
nodes
See
Map
documentation for usage example.- Parameters
nodes (List[int]) – A list of node ids.
-
-
class
openstreet.
NodeQueryBuilder
¶ Bases:
object
Object 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
key
equalvalue
See
Map
documentation 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
key
that contains one ofvalues
- Parameters
key (str) – Key name of the tags.
values (List[str]) – Possible tag values to include.
- Returns
self
- Return type
-