aspectumapp / osm2geojson

Convert OSM and Overpass XML/JSON to GeoJSON
MIT License
97 stars 15 forks source link

osm_busRoute_2geojson #24

Closed AdrianKriger closed 2 years ago

AdrianKriger commented 2 years ago

I am attempting to harvest a number of bus routes with this query:

query = """
[out:json][timeout:30];
area[name='Western Cape'];
// gather results
(
  // query part for: “"bus route"”
  relation["type"="route"]["route"="bus"]['operator'="MyCiTi"](area);
);
// print results
out body;
>;
out skel qt;
"""
url = "http://overpass-api.de/api/interpreter"
r = requests.get(url, params={'data': query})
#rr = r.read()
r_lines = osm2geojson.json2geojson(r.json())

and getting these:

multiline member not handled {'type': 'way', 'ref': 8103781, 'role': ''}
multiline member not handled {'type': 'way', 'ref': 261692637, 'role': ''}
multiline member not handled {'type': 'way', 'ref': 620499486, 'role': ''}

with these:

Element not converted {'type': 'relation', 'id': 947075, 'members': [{'type': 'node', 'ref': 1477393569, 'role': 'platform'}, {'type': 'node', 'ref': 1477393546, 'role': 'platform'}, {'type': 'node', 'ref': 613240265, 'role': 'platform'}, {'type': 'node', 'ref': 461745758, 'role': 'platform'},
...
{'type': 'way', 'ref': 738013878, 'role': ''}], 'tags': {'from': 'Airport', 'name': 'Airport – Civic Centre – Waterfront', 'network': 'Cape Town IRT', 'operator': 'MyCiTi', 'public_transport:version': '2', 'ref': 'A01', 'route': 'bus', 'to': 'Waterfront', 'type': 'route'}}

The query does not fail. nodeand LineStringare returned. An example:

{'type': 'Feature',
  'properties': {'type': 'node', 'id': 8440156895},
  'geometry': {'type': 'Point', 'coordinates': [18.4786065, -33.5100461]}},
 {'type': 'Feature',
  'properties': {'type': 'way', 'id': 13856290},
  'geometry': {'type': 'LineString',
   'coordinates': [[18.3492245, -34.0287179],
    [18.3490569, -34.0290828],
    [18.3490375, -34.0291378],
    [18.3490281, -34.0291862],
    [18.3490273, -34.0292753],
    [18.3490368, -34.0293418],
    [18.3490562, -34.0294102],
    [18.3491039, -34.0295013],
    [18.3492029, -34.0296483],
    [18.3492755, -34.0297541],
    [18.3493278, -34.0298328],
    [18.3493909, -34.0299227]]}},

The relationis lost. What have I done wrong?

rapkin commented 2 years ago

I don't think that something done wrong. It's ok to see messages like this - not all information can be converted because the server produces incomplete geometry, but the lib produces warning messages for debug purpose. I checked your example and compared with overpass visualization. And looks like all geometry converted successfully. If you think that some geometry missed - please, provide small informative example, so I can debug easily.

rapkin commented 2 years ago

I found that old version of osm2geojson used in your project here https://github.com/AdrianKriger/osm_LoD1_3DCityModel/blob/50b9df10f4a97ae65e0edef976e36ced3ba473bd/requirements.txt - so maybe update to last version will help.

AdrianKriger commented 2 years ago

update ~ 0.1.29 => :rocket:

Thank you.