hub/imports/geometry/citygml_classes/citygml_lod1.py
2021-08-27 12:51:30 -04:00

56 lines
2.0 KiB
Python

"""
CityGmlLod1 module parses citygml_classes files with level of detail 1 and import the geometry into the city model
structure
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2021 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from imports.geometry.citygml_classes.citygml_base import CityGmlBase
from city_model_structure.building_demand.surface import Surface
from city_model_structure.attributes.polygon import Polygon
class CityGmlLod1(CityGmlBase):
"""
CityGmlLod1 class to parse level of detail 1 city gml files
"""
@classmethod
def _multi_curve(cls, o):
pass
def __init__(self, o):
super().__init__()
self._o = o
self._surfaces = self._identify(self._o)
@classmethod
def _identify(cls, o):
if 'lod1Solid' in o:
return cls._solid(o)
if 'lod1MultiSurface' in o:
return cls._multi_surface(o)
raise NotImplementedError(o)
@classmethod
def _solid(cls, o):
try:
solid_points = [
CityGmlBase._solid_points(CityGmlBase._remove_last_point(s['Polygon']['exterior']['LinearRing']['posList']
['#text']))
for s in o['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']]
except TypeError:
solid_points = [
CityGmlBase._solid_points(CityGmlBase._remove_last_point(s['Polygon']['exterior']['LinearRing']['posList']))
for s in o['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']]
return [Surface(Polygon(sp), Polygon(sp)) for sp in solid_points]
@classmethod
def _multi_surface(cls, o):
print("lod1_multi")
solid_points = [CityGmlBase._solid_points(CityGmlBase._remove_last_point(s['Polygon']['exterior']['LinearRing']
['posList']))
for s in o['Building']['lod1MultiSurface']['MultiSurface']['surfaceMember']]
return [Surface(Polygon(sp), Polygon(sp)) for sp in solid_points]