forked from s_ranjbar/city_retrofit
Correct unittests
This commit is contained in:
parent
08f44fc935
commit
d650a713c4
|
@ -24,8 +24,8 @@ class Geojson:
|
|||
"""
|
||||
Geojson class
|
||||
"""
|
||||
X = 0
|
||||
Y = 1
|
||||
_X = 0
|
||||
_Y = 1
|
||||
|
||||
def __init__(self,
|
||||
path,
|
||||
|
@ -128,14 +128,17 @@ class Geojson:
|
|||
function = self._function_to_hub[function]
|
||||
geometry = feature['geometry']
|
||||
building_name = ''
|
||||
building_alias = building_name
|
||||
if 'id' in feature:
|
||||
building_name = feature['id']
|
||||
building_alias = building_name
|
||||
if self._name_field is not None:
|
||||
building_name = feature['properties'][self._name_field]
|
||||
building_alias = feature['properties'][self._name_field]
|
||||
|
||||
if str(geometry['type']).lower() == 'polygon':
|
||||
buildings.append(self._parse_polygon(geometry['coordinates'],
|
||||
building_name,
|
||||
building_alias,
|
||||
function,
|
||||
year_of_construction,
|
||||
extrusion_height))
|
||||
|
@ -143,6 +146,7 @@ class Geojson:
|
|||
elif str(geometry['type']).lower() == 'multipolygon':
|
||||
buildings.append(self._parse_multi_polygon(geometry['coordinates'],
|
||||
building_name,
|
||||
building_alias,
|
||||
function,
|
||||
year_of_construction,
|
||||
extrusion_height))
|
||||
|
@ -165,12 +169,12 @@ class Geojson:
|
|||
def _polygon_coordinates_to_3d(self, polygon_coordinates):
|
||||
transformed_coordinates = ''
|
||||
for coordinate in polygon_coordinates:
|
||||
transformed = self._transformer.transform(coordinate[self.Y], coordinate[self.X])
|
||||
self._save_bounds(transformed[self.X], transformed[self.Y])
|
||||
transformed_coordinates = f'{transformed_coordinates} {transformed[self.X]} {transformed[self.Y]} 0.0'
|
||||
transformed = self._transformer.transform(coordinate[self._Y], coordinate[self._X])
|
||||
self._save_bounds(transformed[self._X], transformed[self._Y])
|
||||
transformed_coordinates = f'{transformed_coordinates} {transformed[self._X]} {transformed[self._Y]} 0.0'
|
||||
return transformed_coordinates.lstrip(' ')
|
||||
|
||||
def _parse_polygon(self, coordinates, building_name, function, year_of_construction, extrusion_height):
|
||||
def _parse_polygon(self, coordinates, building_name, building_alias, function, year_of_construction, extrusion_height):
|
||||
surfaces = []
|
||||
for polygon_coordinates in coordinates:
|
||||
points = igh.points_from_string(
|
||||
|
@ -206,6 +210,7 @@ class Geojson:
|
|||
if len(surfaces) > 1:
|
||||
raise ValueError('too many surfaces!!!!')
|
||||
building = Building(f'{building_name}', surfaces, year_of_construction, function)
|
||||
building.alias = building_alias
|
||||
if extrusion_height == 0:
|
||||
return building
|
||||
else:
|
||||
|
@ -239,10 +244,11 @@ class Geojson:
|
|||
wall = Surface(polygon, polygon)
|
||||
surfaces.append(wall)
|
||||
building = Building(f'{building_name}', surfaces, year_of_construction, function)
|
||||
building.alias = building_alias
|
||||
building.volume = volume
|
||||
return building
|
||||
|
||||
def _parse_multi_polygon(self, polygons_coordinates, building_name, function, year_of_construction, extrusion_height):
|
||||
def _parse_multi_polygon(self, polygons_coordinates, building_name, building_alias, function, year_of_construction, extrusion_height):
|
||||
surfaces = []
|
||||
for coordinates in polygons_coordinates:
|
||||
for polygon_coordinates in coordinates:
|
||||
|
@ -276,6 +282,7 @@ class Geojson:
|
|||
polygon.area = igh.ground_area(coordinates)
|
||||
surfaces[-1] = Surface(polygon, polygon)
|
||||
building = Building(f'{building_name}', surfaces, year_of_construction, function)
|
||||
building.alias = building_alias
|
||||
if extrusion_height == 0:
|
||||
return building
|
||||
else:
|
||||
|
@ -309,5 +316,6 @@ class Geojson:
|
|||
wall = Surface(polygon, polygon)
|
||||
surfaces.append(wall)
|
||||
building = Building(f'{building_name}', surfaces, year_of_construction, function)
|
||||
building.alias = building_alias
|
||||
building.volume = volume
|
||||
return building
|
||||
|
|
|
@ -90,22 +90,22 @@ class TestResultsImport(TestCase):
|
|||
self.assertIsNotNone(building.heating_peak_load)
|
||||
self.assertIsNotNone(building.cooling_peak_load)
|
||||
pd.testing.assert_series_equal(
|
||||
building.heating_peak_load[cte.YEAR]['heating peak loads'],
|
||||
building.heating_peak_load[cte.YEAR][cte.HEATING_PEAK_LOAD],
|
||||
expected_yearly['expected'],
|
||||
check_names=False
|
||||
)
|
||||
pd.testing.assert_series_equal(
|
||||
building.cooling_peak_load[cte.YEAR]['cooling peak loads'],
|
||||
building.cooling_peak_load[cte.YEAR][cte.COOLING_PEAK_LOAD],
|
||||
expected_yearly['expected'],
|
||||
check_names=False
|
||||
)
|
||||
pd.testing.assert_series_equal(
|
||||
building.heating_peak_load[cte.MONTH]['heating peak loads'],
|
||||
building.heating_peak_load[cte.MONTH][cte.HEATING_PEAK_LOAD],
|
||||
expected_monthly['expected'],
|
||||
check_names=False
|
||||
)
|
||||
pd.testing.assert_series_equal(
|
||||
building.cooling_peak_load[cte.MONTH]['cooling peak loads'],
|
||||
building.cooling_peak_load[cte.MONTH][cte.COOLING_PEAK_LOAD],
|
||||
expected_monthly['expected'],
|
||||
check_names=False
|
||||
)
|
||||
|
|
|
@ -98,9 +98,9 @@ class TestSystemsFactory(TestCase):
|
|||
copy.deepcopy(_generic_building_energy_system.generation_system)
|
||||
)
|
||||
if cte.HEATING in _building_energy_equipment.demand_types:
|
||||
_building_generation_system.heat_power = building.heating_peak_load[cte.YEAR]['heating peak loads'][0]
|
||||
_building_generation_system.heat_power = building.heating_peak_load[cte.YEAR][cte.HEATING_PEAK_LOAD][0]
|
||||
if cte.COOLING in _building_energy_equipment.demand_types:
|
||||
_building_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR]['cooling peak loads'][0]
|
||||
_building_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][cte.COOLING_PEAK_LOAD][0]
|
||||
_building_energy_equipment.generation_system = _building_generation_system
|
||||
_building_energy_equipment.distribution_system = _building_distribution_system
|
||||
_building_energy_equipment.emission_system = _building_emission_system
|
||||
|
|
Loading…
Reference in New Issue
Block a user