Skip to content

Commit bbc97b3

Browse files
committed
adding example
1 parent 3ea6db1 commit bbc97b3

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

examples/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Examples
2+
3+
Please contribute your examples, submit a pull request!
4+
5+
## Turn restrictions as a list
6+
7+
File: `turn_restriction_relations_as_list.py`
8+
9+
This example requests a CSV response from an Overpass query for turn restrictions within the Toronto city limits.
10+
11+
The result is then converted to a Python list and printed to stdout.
12+
13+
Sample output:
14+
15+
```python
16+
['6809605', 'hoream_telenav', '2016-12-21T15:05:42Z', '', 'no_left_turn'],
17+
...
18+
```
19+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python3
2+
3+
import overpass
4+
5+
api = overpass.API()
6+
7+
# Turn restrictions in Toronto
8+
turn_restrictions_query = "relation[type=restriction](area:3600324211)"
9+
10+
turn_restrictions_list = []
11+
12+
overpass_response = api.Get(
13+
turn_restrictions_query,
14+
responseformat='csv(::"id",::"user",::"timestamp",restriction,"restriction:conditional")',
15+
verbosity='meta')
16+
17+
print(overpass_response)
18+
#reader = csv.reader(response)
19+
#turn_restrictions_list = list(reader)
20+
21+
for row in overpass_response.split('\n'):
22+
turn_restrictions_list.append([elem for elem in row.split('\t')])
23+
24+
print(turn_restrictions_list)

0 commit comments

Comments
 (0)