-
Notifications
You must be signed in to change notification settings - Fork 93
Description
It is expected the following codes should produce the same output, but it turns out they didn't.
Code 1
import overpass
api = overpass.API()
result = api.get('[out:json];rel(3676782);out;', build=False)
print(result)
Output:
{"features": [], "type": "FeatureCollection"}
Code 2
import requests
resp = requests.get(
'http://overpass-api.de/api/interpreter',
params={'data': '[out:json];rel(3676782);out;'})
print(resp.json())
Output:
{'version': 0.6, 'generator': 'Overpass API 0.7.54.13 ff15392f', 'osm3s': {'timestamp_osm_base': '2018-04-10T07:39:02Z', 'copyright': 'The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.'}, 'elements': [{'type': 'relation', 'id': 3676782, 'members': [{'type': 'way', 'ref': 45161703, 'role': 'outer'}, {'type': 'way', 'ref': 9768812, 'role': 'outer'}, {'type': 'way', 'ref': 9770315, 'role': 'outer'}, {'type': 'way', 'ref': 45161682, 'role': 'outer'}, {'type': 'way', 'ref': 10041616, 'role': 'outer'}, {'type': 'way', 'ref': 9767801, 'role': 'outer'}, {'type': 'way', 'ref': 262802435, 'role': 'outer'}, {'type': 'way', 'ref': 9560555, 'role': 'outer'}, {'type': 'way', 'ref': 246658002, 'role': 'outer'}, {'type': 'way', 'ref': 9562448, 'role': 'outer'}, {'type': 'way', 'ref': 9560531, 'role': 'outer'}, {'type': 'way', 'ref': 9763360, 'role': 'outer'}, {'type': 'way', 'ref': 9761979, 'role': 'outer'}, {'type': 'way', 'ref': 9768478, 'role': 'outer'}, {'type': 'way', 'ref': 9770660, 'role': 'outer'}, {'type': 'way', 'ref': 271093834, 'role': 'outer'}], 'tags': {'name': '大嶼山 Lantau Island', 'name:en': 'Lantau Island', 'name:zh': '大嶼山', 'place': 'island', 'type': 'multipolygon', 'wikidata': 'Q502379', 'wikipedia': 'en:Lantau Island'}}]}
The reason should be the default value of responseformat (geojson). Although my query said I want a json, the .get() method still convert it to geojson (default responseformat). To obtain the desired output, I have to add responseformat='json'.
api.get('[out:json];rel(3676782);out;', build=False, responseformat='json')
This looks redundant. Not sure if it is what you desired.