forked from s_ranjbar/city_retrofit
assign lod at city level and correct unit tests
This commit is contained in:
parent
5dc471dd2a
commit
a0445200a5
|
@ -20,8 +20,7 @@ class CityObjectsCluster(ABC, CityObject):
|
||||||
self._cluster_type = cluster_type
|
self._cluster_type = cluster_type
|
||||||
self._city_objects = city_objects
|
self._city_objects = city_objects
|
||||||
self._sensors = []
|
self._sensors = []
|
||||||
self._lod = ''
|
super().__init__(name, None, None)
|
||||||
super().__init__(name, self._lod, None, None)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -24,6 +24,7 @@ class ConstructionFactory:
|
||||||
Enrich the city by using NREL information
|
Enrich the city by using NREL information
|
||||||
"""
|
"""
|
||||||
UsPhysicsParameters(self._city, self._base_path).enrich_buildings()
|
UsPhysicsParameters(self._city, self._base_path).enrich_buildings()
|
||||||
|
self._city.level_of_detail.construction = 2
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -82,7 +82,7 @@ class AirSourceHeatPumpParameters:
|
||||||
heat_pump.heating_comp_power = h_data[1]
|
heat_pump.heating_comp_power = h_data[1]
|
||||||
heat_pump.heating_capacity_coff = self._compute_coefficients(h_data)
|
heat_pump.heating_capacity_coff = self._compute_coefficients(h_data)
|
||||||
|
|
||||||
energy_system = EnergySystem('{} capacity heat pump'.format(heat_pump.model), 0, [], None)
|
energy_system = EnergySystem('{} capacity heat pump'.format(heat_pump.model), [], None)
|
||||||
energy_system.air_source_hp = heat_pump
|
energy_system.air_source_hp = heat_pump
|
||||||
self._city.add_city_object(energy_system)
|
self._city.add_city_object(energy_system)
|
||||||
return self._city
|
return self._city
|
||||||
|
|
|
@ -129,7 +129,7 @@ class WaterToWaterHPParameters:
|
||||||
heat_pump.entering_water_temp = data['ewt']
|
heat_pump.entering_water_temp = data['ewt']
|
||||||
heat_pump.leaving_water_temp = data['lwt']
|
heat_pump.leaving_water_temp = data['lwt']
|
||||||
heat_pump.power_demand_coff = self._compute_coefficients(data)
|
heat_pump.power_demand_coff = self._compute_coefficients(data)
|
||||||
energy_system = EnergySystem(heat_pump.model, 0, [], None)
|
energy_system = EnergySystem(heat_pump.model, [], None)
|
||||||
energy_system.water_to_water_hp = heat_pump
|
energy_system.water_to_water_hp = heat_pump
|
||||||
self._city.add_city_object(energy_system)
|
self._city.add_city_object(energy_system)
|
||||||
return self._city
|
return self._city
|
||||||
|
|
|
@ -23,6 +23,7 @@ class CityGml:
|
||||||
"""
|
"""
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self._city = None
|
self._city = None
|
||||||
|
self._lod = 0
|
||||||
self._lod1_tags = ['lod1Solid', 'lod1MultiSurface']
|
self._lod1_tags = ['lod1Solid', 'lod1MultiSurface']
|
||||||
self._lod2_tags = ['lod2Solid', 'lod2MultiSurface', 'lod2MultiCurve']
|
self._lod2_tags = ['lod2Solid', 'lod2MultiSurface', 'lod2MultiCurve']
|
||||||
self._lower_corner = None
|
self._lower_corner = None
|
||||||
|
@ -74,8 +75,6 @@ class CityGml:
|
||||||
continue
|
continue
|
||||||
envelope = bound['Envelope']
|
envelope = bound['Envelope']
|
||||||
self._srs_name = envelope['@srsName']
|
self._srs_name = envelope['@srsName']
|
||||||
lower_corner = None
|
|
||||||
upper_corner = None
|
|
||||||
if '#text' in envelope['lowerCorner']:
|
if '#text' in envelope['lowerCorner']:
|
||||||
lower_corner = np.fromstring(envelope['lowerCorner']['#text'], dtype=float, sep=' ')
|
lower_corner = np.fromstring(envelope['lowerCorner']['#text'], dtype=float, sep=' ')
|
||||||
upper_corner = np.fromstring(envelope['upperCorner']['#text'], dtype=float, sep=' ')
|
upper_corner = np.fromstring(envelope['upperCorner']['#text'], dtype=float, sep=' ')
|
||||||
|
@ -110,14 +109,16 @@ class CityGml:
|
||||||
if 'function' in city_object:
|
if 'function' in city_object:
|
||||||
function = city_object['function']
|
function = city_object['function']
|
||||||
if any(key in city_object for key in self._lod1_tags):
|
if any(key in city_object for key in self._lod1_tags):
|
||||||
lod = 1
|
if self._lod is None or self._lod > 1:
|
||||||
|
self._lod = 1
|
||||||
surfaces = CityGmlLod1(city_object).surfaces
|
surfaces = CityGmlLod1(city_object).surfaces
|
||||||
elif any(key in city_object for key in self._lod2_tags):
|
elif any(key in city_object for key in self._lod2_tags):
|
||||||
lod = 2
|
if self._lod is None or self._lod > 2:
|
||||||
|
self._lod = 2
|
||||||
surfaces = CityGmlLod2(city_object).surfaces
|
surfaces = CityGmlLod2(city_object).surfaces
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Not supported level of detail")
|
raise NotImplementedError("Not supported level of detail")
|
||||||
return Building(name, lod, surfaces, year_of_construction, function, self._lower_corner, terrains=None)
|
return Building(name, surfaces, year_of_construction, function, self._lower_corner, terrains=None)
|
||||||
|
|
||||||
def _create_parts_consisting_building(self, city_object):
|
def _create_parts_consisting_building(self, city_object):
|
||||||
name = city_object['@id']
|
name = city_object['@id']
|
||||||
|
@ -143,4 +144,5 @@ class CityGml:
|
||||||
self._city.add_city_objects_cluster(self._create_parts_consisting_building(city_object))
|
self._city.add_city_objects_cluster(self._create_parts_consisting_building(city_object))
|
||||||
else:
|
else:
|
||||||
self._city.add_city_object(self._create_building(city_object))
|
self._city.add_city_object(self._create_building(city_object))
|
||||||
|
self._city.level_of_detail.geometry = self._lod
|
||||||
return self._city
|
return self._city
|
||||||
|
|
|
@ -57,6 +57,7 @@ class GPandas:
|
||||||
Get city out of a GeoPandas Table
|
Get city out of a GeoPandas Table
|
||||||
"""
|
"""
|
||||||
if self._city is None:
|
if self._city is None:
|
||||||
|
lod = 1
|
||||||
self._city = City(self._lower_corner, self._upper_corner, self._srs_name)
|
self._city = City(self._lower_corner, self._upper_corner, self._srs_name)
|
||||||
for scene_index, bldg in self._scene.iterrows():
|
for scene_index, bldg in self._scene.iterrows():
|
||||||
geometry = bldg.geom
|
geometry = bldg.geom
|
||||||
|
@ -67,7 +68,7 @@ class GPandas:
|
||||||
trimesh.repair.fix_winding(building_mesh)
|
trimesh.repair.fix_winding(building_mesh)
|
||||||
year_of_construction = int(bldg['year_built'])
|
year_of_construction = int(bldg['year_built'])
|
||||||
name = str(scene_index)
|
name = str(scene_index)
|
||||||
lod = 1
|
|
||||||
if year_of_construction > 2000:
|
if year_of_construction > 2000:
|
||||||
function = cte.RESIDENTIAL
|
function = cte.RESIDENTIAL
|
||||||
else:
|
else:
|
||||||
|
@ -82,8 +83,9 @@ class GPandas:
|
||||||
perimeter_polygon = solid_polygon
|
perimeter_polygon = solid_polygon
|
||||||
surface = Surface(solid_polygon, perimeter_polygon)
|
surface = Surface(solid_polygon, perimeter_polygon)
|
||||||
surfaces.append(surface)
|
surfaces.append(surface)
|
||||||
building = Building(name, lod, surfaces, year_of_construction, function, self._lower_corner, terrains=None)
|
building = Building(name, surfaces, year_of_construction, function, self._lower_corner, terrains=None)
|
||||||
self._city.add_city_object(building)
|
self._city.add_city_object(building)
|
||||||
|
self._city.level_of_detail.geometry = lod
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -59,10 +59,11 @@ class Obj:
|
||||||
self._city = City(self._lower_corner, self._upper_corner, srs_name)
|
self._city = City(self._lower_corner, self._upper_corner, srs_name)
|
||||||
scene = self.scene.geometry
|
scene = self.scene.geometry
|
||||||
keys = scene.keys()
|
keys = scene.keys()
|
||||||
|
lod = 1
|
||||||
for key in keys:
|
for key in keys:
|
||||||
name = key
|
name = key
|
||||||
# todo: where do we get this information from?
|
# todo: where do we get this information from?
|
||||||
lod = 1
|
|
||||||
year_of_construction = 0
|
year_of_construction = 0
|
||||||
function = ''
|
function = ''
|
||||||
|
|
||||||
|
@ -77,6 +78,7 @@ class Obj:
|
||||||
perimeter_polygon = solid_polygon
|
perimeter_polygon = solid_polygon
|
||||||
surface = Surface(solid_polygon, perimeter_polygon)
|
surface = Surface(solid_polygon, perimeter_polygon)
|
||||||
surfaces.append(surface)
|
surfaces.append(surface)
|
||||||
building = Building(name, lod, surfaces, year_of_construction, function, self._lower_corner, terrains=None)
|
building = Building(name, surfaces, year_of_construction, function, self._lower_corner, terrains=None)
|
||||||
self._city.add_city_object(building)
|
self._city.add_city_object(building)
|
||||||
|
self._city.level_of_detail.geometry = lod
|
||||||
return self._city
|
return self._city
|
||||||
|
|
|
@ -101,7 +101,7 @@ class Rhino:
|
||||||
if face is None:
|
if face is None:
|
||||||
break
|
break
|
||||||
hub_surfaces = hub_surfaces + self._add_face(face)
|
hub_surfaces = hub_surfaces + self._add_face(face)
|
||||||
building = Building(name, 3, hub_surfaces, 'unknown', 'unknown', (self._min_x, self._min_y, self._min_z), [])
|
building = Building(name, hub_surfaces, 'unknown', 'unknown', (self._min_x, self._min_y, self._min_z), [])
|
||||||
city_objects.append(building)
|
city_objects.append(building)
|
||||||
lower_corner = (self._min_x, self._min_y, self._min_z)
|
lower_corner = (self._min_x, self._min_y, self._min_z)
|
||||||
upper_corner = (self._max_x, self._max_y, self._max_z)
|
upper_corner = (self._max_x, self._max_y, self._max_z)
|
||||||
|
@ -133,4 +133,5 @@ class Rhino:
|
||||||
|
|
||||||
for building in buildings:
|
for building in buildings:
|
||||||
city.add_city_object(building)
|
city.add_city_object(building)
|
||||||
|
city.level_of_detail.geometry = 3
|
||||||
return city
|
return city
|
||||||
|
|
|
@ -78,4 +78,4 @@ class GeometryFactory:
|
||||||
Enrich the city given to the class using the class given handler
|
Enrich the city given to the class using the class given handler
|
||||||
:return: City
|
:return: City
|
||||||
"""
|
"""
|
||||||
return GPandas(geopandas.read_file(self._path)).city
|
return CityGml(self._path).city
|
||||||
|
|
|
@ -26,12 +26,14 @@ class UsageFactory:
|
||||||
"""
|
"""
|
||||||
Enrich the city with HFT usage library
|
Enrich the city with HFT usage library
|
||||||
"""
|
"""
|
||||||
|
self._city.level_of_detail.usage = 2
|
||||||
return HftUsageParameters(self._city, self._base_path).enrich_buildings()
|
return HftUsageParameters(self._city, self._base_path).enrich_buildings()
|
||||||
|
|
||||||
def _comnet(self):
|
def _comnet(self):
|
||||||
"""
|
"""
|
||||||
Enrich the city with COMNET usage library
|
Enrich the city with COMNET usage library
|
||||||
"""
|
"""
|
||||||
|
self._city.level_of_detail.usage = 2
|
||||||
return ComnetUsageParameters(self._city, self._base_path).enrich_buildings()
|
return ComnetUsageParameters(self._city, self._base_path).enrich_buildings()
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
|
|
|
@ -70,7 +70,6 @@ class TestConstructionFactory(TestCase):
|
||||||
def _check_buildings(self, city):
|
def _check_buildings(self, city):
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
self.assertIsNotNone(building.name, 'building name is none')
|
self.assertIsNotNone(building.name, 'building name is none')
|
||||||
self.assertIsNotNone(building.lod, 'building lod is none')
|
|
||||||
self.assertIsNotNone(building.type, 'building type is none')
|
self.assertIsNotNone(building.type, 'building type is none')
|
||||||
self.assertIsNotNone(building.volume, 'building volume is none')
|
self.assertIsNotNone(building.volume, 'building volume is none')
|
||||||
self.assertIsNotNone(building.detailed_polyhedron, 'building detailed polyhedron is none')
|
self.assertIsNotNone(building.detailed_polyhedron, 'building detailed polyhedron is none')
|
||||||
|
|
|
@ -54,7 +54,6 @@ class TestGeometryFactory(TestCase):
|
||||||
def _check_buildings(self, city):
|
def _check_buildings(self, city):
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
self.assertIsNotNone(building.name, 'building name is none')
|
self.assertIsNotNone(building.name, 'building name is none')
|
||||||
self.assertIsNotNone(building.lod, 'building lod is none')
|
|
||||||
self.assertIsNotNone(building.type, 'building type is none')
|
self.assertIsNotNone(building.type, 'building type is none')
|
||||||
self.assertIsNotNone(building.volume, 'building volume is none')
|
self.assertIsNotNone(building.volume, 'building volume is none')
|
||||||
self.assertIsNotNone(building.detailed_polyhedron, 'building detailed polyhedron is none')
|
self.assertIsNotNone(building.detailed_polyhedron, 'building detailed polyhedron is none')
|
||||||
|
|
|
@ -33,7 +33,6 @@ class TestUsageFactory(TestCase):
|
||||||
def _check_buildings(self, city):
|
def _check_buildings(self, city):
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
self.assertIsNotNone(building.name, 'building name is none')
|
self.assertIsNotNone(building.name, 'building name is none')
|
||||||
self.assertIsNotNone(building.lod, 'building lod is none')
|
|
||||||
self.assertIsNotNone(building.type, 'building type is none')
|
self.assertIsNotNone(building.type, 'building type is none')
|
||||||
self.assertIsNotNone(building.volume, 'building volume is none')
|
self.assertIsNotNone(building.volume, 'building volume is none')
|
||||||
self.assertIsNotNone(building.detailed_polyhedron, 'building detailed polyhedron is none')
|
self.assertIsNotNone(building.detailed_polyhedron, 'building detailed polyhedron is none')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user