VCityTeam / py3dtilers

Tilers accepting various input formats (OBJ, 3DCity databases, GeoJson, IFC) and producing 3DTiles tilesets.
GNU Lesser General Public License v2.1
192 stars 52 forks source link

[CityTiler] Error when using textures together with LOD1 #51

Open jailln opened 2 years ago

jailln commented 2 years ago

When using textures together with LOD1 I hit the following error:

Traceback (most recent call last):
  File "/home/vincent/Documents/dev/py3dtilers/venv/bin/citygml-tiler", line 33, in <module>
    sys.exit(load_entry_point('py3dtilers', 'console_scripts', 'citygml-tiler')())
  File "/home/vincent/Documents/dev/py3dtilers/py3dtilers/CityTiler/CityTiler.py", line 183, in main
    tileset = city_tiler.from_3dcitydb(cursor, objects_type, split_surfaces)
  File "/home/vincent/Documents/dev/py3dtilers/py3dtilers/CityTiler/CityTiler.py", line 148, in from_3dcitydb
    return self.create_tileset_from_geometries(objects_to_tile, extension_name=extension_name)
  File "/home/vincent/Documents/dev/py3dtilers/py3dtilers/Common/tiler.py", line 100, in create_tileset_from_geometries
    return create_tileset(objects_to_tile, self.args.lod1, create_loa, self.args.loa, extension_name, self.args.with_texture)
  File "/home/vincent/Documents/dev/py3dtilers/py3dtilers/Common/tileset_creation.py", line 13, in create_tileset
    lod_tree = LodTree(objects_to_tile, create_lod1, create_loa, polygons_path, with_texture)
  File "/home/vincent/Documents/dev/py3dtilers/py3dtilers/Common/lod_tree.py", line 24, in __init__
    lod1_node = Lod1Node(group.objects_to_tile, 5)
  File "/home/vincent/Documents/dev/py3dtilers/py3dtilers/Common/lod_node.py", line 40, in __init__
    extruded_polygon = ExtrudedPolygon(object_to_tile)
  File "/home/vincent/Documents/dev/py3dtilers/py3dtilers/Common/polygon_extrusion.py", line 38, in __init__
    points = hull.exterior.coords[:-1]
AttributeError: 'LineString' object has no attribute 'exterior'
LorenzoMarnat commented 2 years ago

Its because, when creating textured 3DTiles, we split the surfaces of each cityObject. It means that we have one instance of ObjectToTile (or child classes) for each surface. So, when creating LOD1, the tiler tries to create a LOD1 for each surface and this error occurs because it cant find the footprint of a single triangle.

We split the surfaces when adding the textures because it's easier to match a surface with its UVs/image than to match a cityObject with UVs/images of all the surfaces. But it would be usefull to keep the cityObjects of the GML, even when adding textures, to be able to create LODs (or for other use cases). It will be a future developpement.