forked from mvexel/overpass-api-python-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueries.py
44 lines (33 loc) · 1.23 KB
/
queries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
class MapQuery(object):
"""Query to retrieve complete ways and relations in an area."""
_QUERY_TEMPLATE = "(node({south},{west},{north},{east});<;>;);"
def __init__(self, south, west, north, east):
"""
Initialize query with given bounding box.
:param bbox Bounding box with limit values in format west, south,
east, north.
"""
self.west = west
self.south = south
self.east = east
self.north = north
def __str__(self):
return self._QUERY_TEMPLATE.format(
west=self.west,
south=self.south,
east=self.east,
north=self.north
)
class WayQuery(object):
"""Query to retrieve a set of ways and their dependent nodes satisfying
the input parameters"""
_QUERY_TEMPLATE = "(way{query_parameters});(._;>;);"
def __init__(self, query_parameters):
"""Initialize a query for a set of ways satisfying the given parameters.
:param query_parameters Overpass QL query parameters"""
self.query_parameters = query_parameters
def __str__(self):
return self._QUERY_TEMPLATE.format(
query_parameters=self.query_parameters
)