2021-06-03 11:27:48 -04:00
|
|
|
"""
|
2021-08-27 12:51:30 -04:00
|
|
|
CityGmlLod1 module parses citygml_classes files with level of detail 1 and import the geometry into the city model
|
|
|
|
structure
|
2021-06-03 11:27:48 -04:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2021-06-03 11:27:48 -04:00
|
|
|
"""
|
|
|
|
|
2022-11-24 17:58:45 -05:00
|
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
2021-06-04 09:22:06 -04:00
|
|
|
from imports.geometry.citygml_classes.citygml_base import CityGmlBase
|
2021-08-06 12:28:20 -04:00
|
|
|
from city_model_structure.building_demand.surface import Surface
|
2021-06-02 11:16:00 -04:00
|
|
|
from city_model_structure.attributes.polygon import Polygon
|
|
|
|
|
|
|
|
|
2021-06-03 10:12:06 -04:00
|
|
|
class CityGmlLod1(CityGmlBase):
|
2021-06-03 11:27:48 -04:00
|
|
|
"""
|
|
|
|
CityGmlLod1 class to parse level of detail 1 city gml files
|
|
|
|
"""
|
2021-06-03 10:12:06 -04:00
|
|
|
|
|
|
|
@classmethod
|
2021-08-30 11:38:28 -04:00
|
|
|
def _multi_curve(cls, city_object_member):
|
2021-06-03 10:12:06 -04:00
|
|
|
pass
|
|
|
|
|
2021-08-30 11:38:28 -04:00
|
|
|
def __init__(self, city_object_member):
|
2021-06-03 10:12:06 -04:00
|
|
|
super().__init__()
|
2021-08-30 11:38:28 -04:00
|
|
|
self._city_object_member = city_object_member
|
|
|
|
self._surfaces = self._identify(self._city_object_member)
|
2021-08-11 10:29:54 -04:00
|
|
|
|
|
|
|
@classmethod
|
2021-08-30 11:38:28 -04:00
|
|
|
def _identify(cls, city_object_member):
|
|
|
|
if 'lod1Solid' in city_object_member:
|
|
|
|
return cls._solid(city_object_member)
|
|
|
|
if 'lod1MultiSurface' in city_object_member:
|
|
|
|
return cls._multi_surface(city_object_member)
|
|
|
|
raise NotImplementedError(city_object_member)
|
2021-06-02 11:16:00 -04:00
|
|
|
|
2021-08-27 12:51:30 -04:00
|
|
|
@classmethod
|
2021-08-30 11:38:28 -04:00
|
|
|
def _solid(cls, city_object_member):
|
2021-06-02 11:16:00 -04:00
|
|
|
try:
|
|
|
|
solid_points = [
|
2022-11-24 17:58:45 -05:00
|
|
|
GeometryHelper.points_from_string(GeometryHelper.remove_last_point_from_string(
|
|
|
|
s['Polygon']['exterior']['LinearRing']['posList']['#text']))
|
2021-08-30 11:38:28 -04:00
|
|
|
for s in city_object_member['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']]
|
2021-06-02 11:16:00 -04:00
|
|
|
except TypeError:
|
|
|
|
solid_points = [
|
2022-11-24 17:58:45 -05:00
|
|
|
GeometryHelper.points_from_string(GeometryHelper.remove_last_point_from_string(
|
|
|
|
s['Polygon']['exterior']['LinearRing']['posList']))
|
2021-08-30 11:38:28 -04:00
|
|
|
for s in city_object_member['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']]
|
2021-06-02 11:16:00 -04:00
|
|
|
|
|
|
|
return [Surface(Polygon(sp), Polygon(sp)) for sp in solid_points]
|
|
|
|
|
2021-08-27 12:51:30 -04:00
|
|
|
@classmethod
|
2021-08-30 11:38:28 -04:00
|
|
|
def _multi_surface(cls, city_object_member):
|
2022-11-24 17:58:45 -05:00
|
|
|
solid_points = [GeometryHelper.points_from_string(GeometryHelper.remove_last_point_from_string(
|
|
|
|
s['Polygon']['exterior']['LinearRing']['posList']))
|
2021-08-30 11:38:28 -04:00
|
|
|
for s in city_object_member['Building']['lod1MultiSurface']['MultiSurface']['surfaceMember']]
|
2021-08-27 12:51:30 -04:00
|
|
|
return [Surface(Polygon(sp), Polygon(sp)) for sp in solid_points]
|