If an unnecessary Polygon FeatureCollection was provided (i.e. a Collection with a single Polygon) the code broke with the following error:
Traceback (most recent call last):
File "/usr/local/bin/ogr2osm", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/ogr2osm/ogr2osm.py", line 271, in main
osmdata.process(datasource)
File "/usr/local/lib/python3.10/dist-packages/ogr2osm/osm_data.py", line 422, in process
self.add_feature(ogrfeature, layer_fields, datasource.source_encoding, reproject)
File "/usr/local/lib/python3.10/dist-packages/ogr2osm/osm_data.py", line 370, in add_feature
osmgeometries = self.__parse_geometry(ogrgeometry, feature_tags)
File "/usr/local/lib/python3.10/dist-packages/ogr2osm/osm_data.py", line 345, in __parse_geometry
osmgeometries.append(self.__parse_collection(ogrgeometry, tags))
File "/usr/local/lib/python3.10/dist-packages/ogr2osm/osm_data.py", line 313, in __parse_collection
if len(members) == 1 and len(members[0].nodes) <= self.max_points_in_way:
I therefore chose to handle unnecessary Collections earlier pretending they are just normal geometries.
Context
This has nothing to do with the MR directly but I stumbled up on the issue while exporting some data from ohsome.org and then trying to convert the geojson back to the OSM data format just as I had done here: https://heigit.org/2022-30daymapchallenge-round-up-part-2-deleted-maps/ . The offender was identified as this relation https://www.openstreetmap.org/relation/3088804 (a relation with a child relation). Ohsome chooses to ignore the child relation and provide an unnecessary Collection:
If an unnecessary Polygon FeatureCollection was provided (i.e. a Collection with a single Polygon) the code broke with the following error:
Fixing the tuple reference in https://github.com/roelderickx/ogr2osm/blob/2a0c8b22311aea1dfc63577f986febc493321b61/ogr2osm/osm_data.py#L318-L320 would fix the error but the tags would get distorted, as a list-value is expected but a simple string-value is given to the tags dict in https://github.com/roelderickx/ogr2osm/blob/2a0c8b22311aea1dfc63577f986febc493321b61/ogr2osm/osm_data.py#L320.
I therefore chose to handle unnecessary Collections earlier pretending they are just normal geometries.
Context
This has nothing to do with the MR directly but I stumbled up on the issue while exporting some data from ohsome.org and then trying to convert the geojson back to the OSM data format just as I had done here: https://heigit.org/2022-30daymapchallenge-round-up-part-2-deleted-maps/ . The offender was identified as this relation https://www.openstreetmap.org/relation/3088804 (a relation with a child relation). Ohsome chooses to ignore the child relation and provide an unnecessary Collection: