VCityTeam / py3dtilers

Tilers accepting various input formats (OBJ, 3DCity databases, GeoJson, IFC) and producing 3DTiles tilesets.
Other
188 stars 51 forks source link

Roof option for geojson-tiler results in an error #175

Closed margrietpalm closed 10 months ago

margrietpalm commented 10 months ago

I'm using geojson-tiler to convert a geojson to a 3D tileset. However, when I try to use the --is_roof option, the following error occurs:

geojson-tiler --is_roof True --paths example.json --output_dir temp/
1 file(s) with supported extensions found
Reading almere/test_triangle/geojsons/test_flip.geojson
Traceback (most recent call last):
  File "/home/margriet/.pyenv/versions/3dtiles/bin/geojson-tiler", line 33, in <module>
    sys.exit(load_entry_point('py3dtilers', 'console_scripts', 'geojson-tiler')())
  File "/home/margriet/src/py3dtilers/py3dtilers/GeojsonTiler/GeojsonTiler.py", line 192, in main
    tileset = geojson_tiler.from_geojson_directory(properties, geojson_tiler.args.is_roof, geojson_tiler.args.add_color, geojson_tiler.args.keep_properties)
  File "/home/margriet/src/py3dtilers/py3dtilers/GeojsonTiler/GeojsonTiler.py", line 168, in from_geojson_directory
    objects = Geojsons.parse_geojsons(features, properties, is_roof, color_attribute)
  File "/home/margriet/src/py3dtilers/py3dtilers/GeojsonTiler/geojson.py", line 187, in parse_geojsons
    if not feature.parse_geojson(properties, is_roof, color_attribute):
  File "/home/margriet/src/py3dtilers/py3dtilers/GeojsonTiler/geojson_polygon.py", line 25, in parse_geojson
    coord[2] -= self.height
IndexError: list index out of range

Some manual testing indicates that indeed coords only contains x and y coordinates, so coord[2] doesn't exist (https://github.com/VCityTeam/py3dtilers/blob/f85ba8661f323e8b17562e663e8ddf0e8dab74a7/py3dtilers/GeojsonTiler/geojson_polygon.py#L25).

Example json file: example.json

margrietpalm commented 10 months ago

I resolved this issue by adding the height as a z-coordinate in the geojson.