Skip to content

Commit

Permalink
Refactor example
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdillah committed May 19, 2021
1 parent eedf43d commit 1780f20
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions examples/mapquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@

from openstreet import Map

map = Map("./resources/madina.osm")
print(map.nodes().by_id(8623725793))
print(map.nodes().by_tag_in("highway", [ "primary" ]).get())
def example_get(map):
print(map.nodes().by_id(8623725793))

ctr = 5
for node in map.nodes().where_tag_in("highway", [ "primary" ]).get():
if ctr == 0:
break;

print("Node id:", node.id)
print("- ", node.tags)

ctr = ctr - 1

def example_iterator(map):
ctr = 5
for node in map.nodes().where_tag_in("highway", [ "primary" ]):
if ctr == 0:
break;

print("Node id:", node.id)

ctr = ctr - 1

if __init__ == "__main__":
map = Map("./resources/madina.osm")
example_get(map)
example_iterator(map)

0 comments on commit 1780f20

Please sign in to comment.