Temporary fix sensor test
This commit is contained in:
parent
eb249f84d3
commit
de471ee88a
|
@ -171,6 +171,7 @@ class City:
|
|||
else:
|
||||
raise NotImplementedError(new_city_object.type)
|
||||
|
||||
|
||||
def remove_city_object(self, city_object):
|
||||
"""
|
||||
Remove a CityObject from the city
|
||||
|
@ -320,6 +321,7 @@ class City:
|
|||
:param new_city_objects_cluster:CityObjectsCluster
|
||||
:return: None
|
||||
"""
|
||||
print(new_city_objects_cluster.type)
|
||||
if new_city_objects_cluster.type == 'buildings':
|
||||
if self._buildings_clusters is None:
|
||||
self._buildings_clusters = []
|
||||
|
|
|
@ -11,6 +11,7 @@ from city_model_structure.building import Building
|
|||
from helpers.geometry_helper import GeometryHelper
|
||||
from imports.geometry.citygml_lod2 import CityGmlLod2
|
||||
from imports.geometry.citygml_lod1 import CityGmlLod1
|
||||
from city_model_structure.parts_consisting_building import PartsConsistingBuilding
|
||||
|
||||
|
||||
class CityGml:
|
||||
|
@ -23,7 +24,7 @@ class CityGml:
|
|||
self._lod2_tags = ['lod2Solid', 'lod2MultiSurface', 'lod2MultiCurve']
|
||||
with open(path) as gml:
|
||||
# Clean the namespaces is an important task to prevent wrong ns:field due poor citygml implementations
|
||||
|
||||
fl = ('cityObjectMember', 'curveMember', 'boundedBy', 'surfaceMember', 'consistsOfBuildingPart')
|
||||
self._gml = xmltodict.parse(gml.read(), process_namespaces=True, xml_attribs=True, namespaces={
|
||||
'http://www.opengis.net/gml': None,
|
||||
'http://www.opengis.net/citygml/1.0': None,
|
||||
|
@ -43,7 +44,8 @@ class CityGml:
|
|||
'http://www.opengis.net/citygml/relief/2.0 http://schemas.opengis.net/citygml/relief/2.0/relief.xsd" '
|
||||
'xmlns="http://www.opengis.net/citygml/2.0': None,
|
||||
'http://www.opengis.net/citygml/2.0': None
|
||||
}, force_list=('cityObjectMember', 'curveMember', 'boundedBy', 'surfaceMember'))
|
||||
}, force_list=fl)
|
||||
|
||||
self._city_objects = None
|
||||
self._geometry = GeometryHelper()
|
||||
for bound in self._gml['CityModel']['boundedBy']:
|
||||
|
@ -83,8 +85,16 @@ class CityGml:
|
|||
raise NotImplementedError("Not supported level of detail")
|
||||
return Building(name, lod, surfaces, year_of_construction, function, self._lower_corner, [])
|
||||
|
||||
def _create_parts_consisting_building(self):
|
||||
raise NotImplementedError
|
||||
def _create_parts_consisting_building(self, city_object):
|
||||
name = city_object['@id']
|
||||
building_parts = []
|
||||
for part in city_object['consistsOfBuildingPart']:
|
||||
building = self._create_building(part['BuildingPart'])
|
||||
print(f'add city building part {building.name}')
|
||||
self._city.add_city_object(building)
|
||||
building_parts.append(building)
|
||||
print(f'add building cluster {name}')
|
||||
return PartsConsistingBuilding(name, building_parts)
|
||||
|
||||
@property
|
||||
def city(self) -> City:
|
||||
|
@ -98,7 +108,8 @@ class CityGml:
|
|||
for o in self._gml['CityModel']['cityObjectMember']:
|
||||
city_object = o['Building']
|
||||
if 'consistsOfBuildingPart' in city_object:
|
||||
raise NotImplementedError("Building cluster")
|
||||
print('create building parts')
|
||||
self._city.add_city_objects_cluster(self._create_parts_consisting_building(city_object))
|
||||
else:
|
||||
self._city.add_city_object(self._create_building(city_object))
|
||||
return self._city
|
||||
|
|
|
@ -41,7 +41,11 @@ class CityGmlLod2(CityGmlBase):
|
|||
surface_type = next(iter(b))
|
||||
surface_encoding, surface_subtype = cls._surface_encoding(b[surface_type])
|
||||
for member in b[surface_type][surface_encoding][surface_subtype]['surfaceMember']:
|
||||
sp = cls._solid_points(cls._remove_last_point(member['Polygon']['exterior']['LinearRing']['posList']))
|
||||
if '@srsDimension' in member['Polygon']['exterior']['LinearRing']['posList']:
|
||||
gml_points = member['Polygon']['exterior']['LinearRing']['posList']["#text"]
|
||||
else:
|
||||
gml_points = member['Polygon']['exterior']['LinearRing']['posList']
|
||||
sp = cls._solid_points(cls._remove_last_point(gml_points))
|
||||
p = Polygon(sp)
|
||||
surface = Surface(p, p, surface_type=GeometryHelper.gml_surface_to_libs(surface_type))
|
||||
surfaces.append(surface)
|
||||
|
@ -49,8 +53,8 @@ class CityGmlLod2(CityGmlBase):
|
|||
|
||||
@classmethod
|
||||
def _multi_curve(cls, o):
|
||||
raise NotImplementedError
|
||||
raise NotImplementedError('multi curve')
|
||||
|
||||
@classmethod
|
||||
def _multi_surface(cls, o):
|
||||
raise NotImplementedError
|
||||
raise NotImplementedError('multi surface')
|
||||
|
|
|
@ -51,10 +51,11 @@ class TestGeometryFactory(TestCase):
|
|||
def test_stuttgart_gml(self):
|
||||
file = '20190815_mitte_out_MC_FloursurfaceADD.gml'
|
||||
city = self._get_citygml(file)
|
||||
print(f'city name: {city}')
|
||||
for building in city.buildings:
|
||||
print(f'building {building.name} has {len(building.surfaces)} surfaces {building.volume}')
|
||||
self.assertFalse(building.volume is 'inf', 'building volume is inf')
|
||||
print(f'Found {len(city.buildings)} buildings' )
|
||||
print(f'Found {len(city.buildings)} buildings')
|
||||
|
||||
def test_citygml_buildings(self):
|
||||
"""
|
||||
|
|
|
@ -36,16 +36,15 @@ class TestSensorsFactory(TestCase):
|
|||
surfaces = []
|
||||
year_of_construction = 2021
|
||||
function = "office"
|
||||
city = City(lower_corner, upper_corner, srs_name)
|
||||
buildings.append(Building("EV", lod, surfaces, year_of_construction, function, lower_corner))
|
||||
buildings.append(Building("GM", lod, surfaces, year_of_construction, function, lower_corner))
|
||||
city = City(lower_corner, upper_corner, srs_name)
|
||||
#virtual_building = CityObject("GM_MB_EV", lod, surfaces, lower_corner)
|
||||
#virtual_building.type = 'Virtual'
|
||||
#city.add_city_object(virtual_building)
|
||||
|
||||
for building in buildings:
|
||||
city.add_city_object(building)
|
||||
return city
|
||||
#virtual_building = CityObject("GM_MB_EV", lod, surfaces, lower_corner)
|
||||
#virtual_building.type = 'Virtual'
|
||||
#city.add_city_object(virtual_building)
|
||||
|
||||
def test_city_with_sensors(self):
|
||||
SensorsFactory('cec', self._city, self._end_point).enrich()
|
||||
|
|
Loading…
Reference in New Issue
Block a user