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