aspectumapp / osm2geojson

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

Failed to convert MultiPolygon relation 'with more than one hole' to shape #39

Closed AdrianKriger closed 1 year ago

AdrianKriger commented 1 year ago

Hello. Thank you for this library. Its wonderful.

This might be related to #38

Have you changed something? I was forced to recreate an environment over the Festive break and 0.1.33 on longer handles MultiPolygons as it did. This call / conversion worked perfectly before. Now MultiPolygons with more than one hole fails?

query = """
    [out:json][timeout:25];
    (area[name='{0}'] ->.b;
    // -- target area ~ can be way or relation
    {1}(area.b)[name='{2}'];
    map_to_area -> .a;
        // I want all buildings ~ with levels tagged
        way['building'](area.a);
        // and relation type=multipolygon ~ to removed courtyards from buildings
        relation['building']["type"="multipolygon"](area.a);
    );
    out body;
    >;
    out skel qt;
    """.format("Western Cape", "way", "Cape Peninsula University of Technology (Bellville Campus)"])

url = "http://overpass-api.de/api/interpreter"
r = requests.get(url, params={'data': query})
    #rr = r.read()
gj = osm2geojson.json2geojson(r.json())

Failed to convert relation to shape {'id': 12213843,
 'members': [{'ref': 897589024,
              'role': 'inner',
              'type': 'way',
              'used': 12213843},
             {'ref': 897589023,
              'role': 'outer',
              'type': 'way',
              'used': 12213843},
             {'ref': 921756023,
              'role': 'inner',
              'type': 'way',
              'used': 12213843}],
 'tags': {'addr:city': 'Cape Town',
          'addr:housename': 'Old Science Building',
          'addr:postcode': '7530',
          'addr:suburb': 'Bellville',
          'building': 'university',
          'building:levels': '2',
          'type': 'multipolygon'},
 'type': 'relation'}
Failed to convert relation to shape {'id': 12279396,
 'members': [{'ref': 904215650,
              'role': 'inner',
              'type': 'way',
              'used': 12279396},
             {'ref': 904215653,
              'role': 'inner',
              'type': 'way',
              'used': 12279396},
             {'ref': 904215651,
              'role': 'inner',
              'type': 'way',
              'used': 12279396},
             {'ref': 904215652,
              'role': 'inner',
              'type': 'way',
              'used': 12279396},
             {'ref': 897473411,
              'role': 'outer',
              'type': 'way',
              'used': 12279396},
             {'ref': 906758868,
              'role': 'inner',
              'type': 'way',
              'used': 12279396}],
 'tags': {'addr:city': 'Cape Town',
          'addr:housename': 'Richard Sacco Residence',
          'addr:postcode': '7530',
          'addr:suburb': 'Bellville',
          'building': 'dormitory',
          'building:levels': '2',
          'residential': 'university',
          'type': 'multipolygon'},
 'type': 'relation'}
Failed to convert relation to shape {'id': 12295766,
 'members': [{'ref': 905545986,
              'role': 'inner',
              'type': 'way',
              'used': 12295766},
             {'ref': 905545985,
              'role': 'inner',
              'type': 'way',
              'used': 12295766},
             {'ref': 905545983,
              'role': 'inner',
              'type': 'way',
              'used': 12295766},
             {'ref': 905545984,
              'role': 'inner',
              'type': 'way',
              'used': 12295766},
             {'ref': 905545982,
              'role': 'outer',
              'type': 'way',
              'used': 12295766}],
 'tags': {'addr:city': 'Cape Town',
          'addr:housename': 'Mechanical and Industrial Engineering - '
                            'Mechatronics',
          'addr:postcode': '7530',
          'addr:suburb': 'Bellville',
          'building': 'university',
          'building:levels': '2',
          'type': 'multipolygon'},
 'type': 'relation'}
Failed to convert relation to shape {'id': 12303540,
 'members': [{'ref': 906239600,
              'role': 'inner',
              'type': 'way',
              'used': 12303540},
             {'ref': 906239599,
              'role': 'inner',
              'type': 'way',
              'used': 12303540},
             {'ref': 906239598,
              'role': 'outer',
              'type': 'way',
              'used': 12303540}],
 'tags': {'addr:city': 'Cape Town',
          'addr:housename': 'Horticulture',
          'addr:postcode': '7530',
          'addr:suburb': 'Bellville',
          'building': 'university',
          'building:levels': '2',
          'type': 'multipolygon'},
 'type': 'relation'}
Failed to convert relation to shape {'id': 12405081,
 'members': [{'ref': 897625900,
              'role': 'inner',
              'type': 'way',
              'used': 12405081},
             {'ref': 897625899,
              'role': 'inner',
              'type': 'way',
              'used': 12405081},
             {'ref': 897625898,
              'role': 'outer',
              'type': 'way',
              'used': 12405081}],
 'tags': {'addr:city': 'Cape Town',
          'addr:housename': 'Freedom Square Residence',
          'addr:postcode': '7530',
          'addr:suburb': 'Bellville',
          'building': 'dormitory',
          'building:levels': '4',
          'residential': 'university',
          'type': 'multipolygon'},
 'type': 'relation'}

Do I need to update?

rapkin commented 1 year ago

Hello! Yes, you can try to use version 0.2.3

AdrianKriger commented 1 year ago

Thank you.