@@ -20,27 +20,44 @@ def get_filters(network_type='drive'):
2020 'elevator|escalator|footway|path|pedestrian|planned|platform|proposed|raceway|steps|track"]'
2121 '["service"!~"emergency_access|parking|parking_aisle|private"]' )
2222
23+ osm_filters ['bicycle' ] = ('["highway"]["area"!~"yes"]["access"!~"private"]'
24+ '["highway"!~"abandoned|bridleway|footway|bus_guideway|construction|corridor|elevator|'
25+ 'escalator|planned|platform|proposed|raceway|steps|footway"]'
26+ '["service"!~"private"]["bicycle"!~"no"])' )
27+
28+ osm_filters ['service' ] = ('["highway"]["area"!~"yes"]["access"!~"private"]["highway"!~"abandoned|bridleway|'
29+ 'construction|corridor|platform|cycleway|elevator|escalator|footway|path|planned|'
30+ 'proposed|raceway|steps|track"]["service"!~"emergency_access|parking|'
31+ 'parking_aisle|private"]["psv"!~"no"]["footway"!~"yes"]' )
32+
2333 return osm_filters [network_type ]
2434
2535
26- def osm_download (bbox , network_type = None ):
36+ def osm_download (bbox , network_type = 'drive' , custom_filter = None ):
2737 """ Get the OpenStreetMap response.
2838
2939 Parameters
3040 ----------
3141 bbox: tuple
3242 bounding box within N, S, E, W coordinates.
33- network_type: str or None , optional, default: None
43+ network_type: str, optional, default: 'drive'
3444 Type of street network to obtain.
45+ custom_filter: str or None, optional, default: None
46+ Custom filter to be used instead of the predefined ones to query the Overpass API.
47+ An example of a custom filter is the following '[highway][!"footway"]'.
48+ For more information visit https://overpass-turbo.eu and https://taginfo.openstreetmap.org.
49+
3550 Returns
3651 -------
3752 response: json
3853 Response of the OpenStreetMao API service.
3954 """
40- # TODO: add network_type statement
4155 north , south , west , east = bbox
4256
43- osm_filters = get_filters (network_type = 'drive' )
57+ if custom_filter is not None :
58+ osm_filter = custom_filter
59+ else :
60+ osm_filter = get_filters (network_type = network_type )
4461
4562 url_endpoint = 'https://maps.mail.ru/osm/tools/overpass/api/interpreter'
4663
@@ -49,7 +66,7 @@ def osm_download(bbox, network_type=None):
4966
5067 overpass_settings = f'[out:{ out_resp } ][timeout:{ timeout } ]'
5168
52- query_str = f'{ overpass_settings } ;(way{ osm_filters } ({ south } , { west } , { north } , { east } );>;);out;'
69+ query_str = f'{ overpass_settings } ;(way{ osm_filter } ({ south } , { west } , { north } , { east } );>;);out;'
5370
5471 response_json = requests .post (url_endpoint , data = {'data' : query_str })
5572
0 commit comments