forked from s_ranjbar/city_retrofit
Correct unit tests due latest changes in gpandas handler.
Partial rollback of some changes
This commit is contained in:
parent
e68830a16b
commit
6be5325f75
|
@ -164,7 +164,7 @@ When all the dependencies are satisfied, you are all set to start importing your
|
||||||
Add the following code to your main.py
|
Add the following code to your main.py
|
||||||
from imports.geometry_factory import GeometryFactory
|
from imports.geometry_factory import GeometryFactory
|
||||||
|
|
||||||
city = GeometryFactory('citygml', 'myfile.gml').city
|
city = GeometryFactory('citygml', path='myfile.gml').city
|
||||||
|
|
||||||
Always remember to push your own project changes as the last thing you do before ending your working day!
|
Always remember to push your own project changes as the last thing you do before ending your working day!
|
||||||
First, commit your changes by clicking on the green check in the top-right corner of Pycharm. Add a comment
|
First, commit your changes by clicking on the green check in the top-right corner of Pycharm. Add a comment
|
||||||
|
|
|
@ -237,7 +237,7 @@ Add the following code to your main.py
|
||||||
|
|
||||||
from imports.geometry_factory import GeometryFactory
|
from imports.geometry_factory import GeometryFactory
|
||||||
|
|
||||||
city = GeometryFactory('citygml', 'myfile.gml').city
|
city = GeometryFactory('citygml', path='myfile.gml').city
|
||||||
```
|
```
|
||||||
|
|
||||||
9. Always remember to push your own project changes as the last thing you do before ending your working day!
|
9. Always remember to push your own project changes as the last thing you do before ending your working day!
|
||||||
|
|
|
@ -12,7 +12,7 @@ Catalog = TypeVar('Catalog')
|
||||||
|
|
||||||
class GreeneryCatalogFactory:
|
class GreeneryCatalogFactory:
|
||||||
"""
|
"""
|
||||||
GeometryFactory class
|
GreeneryCatalogFactory class
|
||||||
"""
|
"""
|
||||||
def __init__(self, file_type, base_path=None):
|
def __init__(self, file_type, base_path=None):
|
||||||
if base_path is None:
|
if base_path is None:
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Obj(Triangular):
|
||||||
file_name_out = self._city.name + '_ground.' + self._triangular_format
|
file_name_out = self._city.name + '_ground.' + self._triangular_format
|
||||||
file_path_in = (Path(self._path).resolve() / file_name_in).resolve()
|
file_path_in = (Path(self._path).resolve() / file_name_in).resolve()
|
||||||
file_path_out = (Path(self._path).resolve() / file_name_out).resolve()
|
file_path_out = (Path(self._path).resolve() / file_name_out).resolve()
|
||||||
scene = GeometryFactory('obj', file_path_in).scene
|
scene = GeometryFactory('obj', path=file_path_in).scene
|
||||||
scene.rezero()
|
scene.rezero()
|
||||||
obj_file = trimesh.exchange.obj.export_obj(scene)
|
obj_file = trimesh.exchange.obj.export_obj(scene)
|
||||||
with open(file_path_out, 'w') as file:
|
with open(file_path_out, 'w') as file:
|
||||||
|
|
|
@ -40,6 +40,7 @@ class GPandas:
|
||||||
self._scene = dataframe
|
self._scene = dataframe
|
||||||
self._scene = self._scene.to_crs(self._srs_name)
|
self._scene = self._scene.to_crs(self._srs_name)
|
||||||
min_x, min_y, max_x, max_y = self._scene.total_bounds
|
min_x, min_y, max_x, max_y = self._scene.total_bounds
|
||||||
|
print(min_x)
|
||||||
self._lower_corner = [min_x, min_y, 0]
|
self._lower_corner = [min_x, min_y, 0]
|
||||||
self._upper_corner = [max_x, max_y, 0]
|
self._upper_corner = [max_x, max_y, 0]
|
||||||
|
|
||||||
|
@ -58,10 +59,10 @@ class GPandas:
|
||||||
if self._city is None:
|
if self._city is None:
|
||||||
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.geometry
|
geometry = bldg.geom
|
||||||
# polygon = ShapelyPoly(geometry['coordinates'][0])
|
polygon = ShapelyPoly(geometry['coordinates'][0])
|
||||||
height = float(bldg['height'])
|
height = float(bldg['height'])
|
||||||
building_mesh = trimesh.creation.extrude_polygon(geometry, height)
|
building_mesh = trimesh.creation.extrude_polygon(polygon, height)
|
||||||
trimesh.repair.fill_holes(building_mesh)
|
trimesh.repair.fill_holes(building_mesh)
|
||||||
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'])
|
||||||
|
|
|
@ -17,7 +17,7 @@ class GeometryFactory:
|
||||||
"""
|
"""
|
||||||
GeometryFactory class
|
GeometryFactory class
|
||||||
"""
|
"""
|
||||||
def __init__(self, file_type, path, data_frame=None):
|
def __init__(self, file_type, path=None, data_frame=None):
|
||||||
self._file_type = '_' + file_type.lower()
|
self._file_type = '_' + file_type.lower()
|
||||||
self._path = path
|
self._path = path
|
||||||
self._data_frame = data_frame
|
self._data_frame = data_frame
|
||||||
|
@ -46,7 +46,6 @@ class GeometryFactory:
|
||||||
"""
|
"""
|
||||||
if self._data_frame is None:
|
if self._data_frame is None:
|
||||||
self._data_frame = geopandas.read_file(self._path)
|
self._data_frame = geopandas.read_file(self._path)
|
||||||
print( self._data_frame )
|
|
||||||
return GPandas(self._data_frame).city
|
return GPandas(self._data_frame).city
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -23,7 +23,7 @@ class TestCityMerge(TestCase):
|
||||||
|
|
||||||
def _get_citygml(self, file):
|
def _get_citygml(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
city = GeometryFactory('citygml', file_path).city
|
city = GeometryFactory('citygml', path=file_path).city
|
||||||
self.assertIsNotNone(city, 'city is none')
|
self.assertIsNotNone(city, 'city is none')
|
||||||
return city
|
return city
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TestConstructionFactory(TestCase):
|
||||||
|
|
||||||
def _get_citygml(self, file):
|
def _get_citygml(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
self._city = GeometryFactory('citygml', file_path).city
|
self._city = GeometryFactory('citygml', path=file_path).city
|
||||||
self.assertIsNotNone(self._city, 'city is none')
|
self.assertIsNotNone(self._city, 'city is none')
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TestBuildings(TestCase):
|
||||||
def test_doe_idf(self):
|
def test_doe_idf(self):
|
||||||
city_file = "../unittests/tests_data/one_building_in_kelowna.gml"
|
city_file = "../unittests/tests_data/one_building_in_kelowna.gml"
|
||||||
output_path = Path('../unittests/tests_outputs/').resolve()
|
output_path = Path('../unittests/tests_outputs/').resolve()
|
||||||
city = GeometryFactory('citygml', city_file).city
|
city = GeometryFactory('citygml', path=city_file).city
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
building.year_of_construction = 2006
|
building.year_of_construction = 2006
|
||||||
ConstructionFactory('nrel', city).enrich()
|
ConstructionFactory('nrel', city).enrich()
|
||||||
|
|
|
@ -25,7 +25,7 @@ class TestEnergySystemsFactory(TestCase):
|
||||||
"""
|
"""
|
||||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||||
self._output_path = "../unittests/tests_data/as_user_output.csv"
|
self._output_path = "../unittests/tests_data/as_user_output.csv"
|
||||||
self._city = GeometryFactory('citygml', city_file).city
|
self._city = GeometryFactory('citygml', path=city_file).city
|
||||||
EnergySystemsFactory('air source hp', self._city).enrich()
|
EnergySystemsFactory('air source hp', self._city).enrich()
|
||||||
|
|
||||||
def test_air_source_heat_pump_import(self):
|
def test_air_source_heat_pump_import(self):
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TestEnergySystemsFactory(TestCase):
|
||||||
"""
|
"""
|
||||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||||
self._output_path = "../unittests/tests_data/w2w_user_output.csv"
|
self._output_path = "../unittests/tests_data/w2w_user_output.csv"
|
||||||
self._city = GeometryFactory('citygml', city_file).city
|
self._city = GeometryFactory('citygml', path=city_file).city
|
||||||
EnergySystemsFactory('water to water hp', self._city).enrich()
|
EnergySystemsFactory('water to water hp', self._city).enrich()
|
||||||
|
|
||||||
def test_water_to_water_heat_pump_import(self):
|
def test_water_to_water_heat_pump_import(self):
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TestGeometryFactory(TestCase):
|
||||||
|
|
||||||
def _get_citygml(self, file):
|
def _get_citygml(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
self._city = GeometryFactory('citygml', file_path).city
|
self._city = GeometryFactory('citygml', path=file_path).city
|
||||||
self.assertIsNotNone(self._city, 'city is none')
|
self.assertIsNotNone(self._city, 'city is none')
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class TestExports(TestCase):
|
||||||
|
|
||||||
def _get_citygml(self, file):
|
def _get_citygml(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
self._city = GeometryFactory('citygml', file_path).city
|
self._city = GeometryFactory('citygml', path=file_path).city
|
||||||
self.assertIsNotNone(self._city, 'city is none')
|
self.assertIsNotNone(self._city, 'city is none')
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class TestGeometryFactory(TestCase):
|
||||||
|
|
||||||
def _get_citygml(self, file):
|
def _get_citygml(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
self._city = GeometryFactory('citygml', file_path).city
|
self._city = GeometryFactory('citygml', path=file_path).city
|
||||||
self.assertIsNotNone(self._city, 'city is none')
|
self.assertIsNotNone(self._city, 'city is none')
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ class TestGeometryFactory(TestCase):
|
||||||
def _get_obj(self, file):
|
def _get_obj(self, file):
|
||||||
# todo: solve the incongruities between city and city_debug
|
# todo: solve the incongruities between city and city_debug
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
self._city = GeometryFactory('obj', file_path).city
|
self._city = GeometryFactory('obj', path=file_path).city
|
||||||
self.assertIsNotNone(self._city, 'city is none')
|
self.assertIsNotNone(self._city, 'city is none')
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
def _get_rhino(self, file):
|
def _get_rhino(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
self._city = GeometryFactory('rhino', file_path).city
|
self._city = GeometryFactory('rhino', path=file_path).city
|
||||||
self.assertIsNotNone(self._city, 'city is none')
|
self.assertIsNotNone(self._city, 'city is none')
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class TestGeometryFactory(TestCase):
|
||||||
"""
|
"""
|
||||||
file_path = (self._example_path / 'subway.osm').resolve()
|
file_path = (self._example_path / 'subway.osm').resolve()
|
||||||
|
|
||||||
city = GeometryFactory('osm_subway', file_path).city
|
city = GeometryFactory('osm_subway', path=file_path).city
|
||||||
|
|
||||||
self.assertIsNotNone(city, 'subway entrances is none')
|
self.assertIsNotNone(city, 'subway entrances is none')
|
||||||
self.assertEqual(len(city.city_objects), 20, 'Wrong number of subway entrances')
|
self.assertEqual(len(city.city_objects), 20, 'Wrong number of subway entrances')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
TestGeometryFactory test and validate the city model structure geometric parameters
|
Test greenery factory test and validate the greenery construction
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2022 Concordia CERC group
|
Copyright © 2022 Concordia CERC group
|
||||||
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
|
|
|
@ -27,7 +27,7 @@ class GreeneryInIdf(TestCase):
|
||||||
city_file = "../unittests/tests_data/one_building_in_kelowna.gml"
|
city_file = "../unittests/tests_data/one_building_in_kelowna.gml"
|
||||||
output_path = Path('../unittests/tests_outputs/').resolve()
|
output_path = Path('../unittests/tests_outputs/').resolve()
|
||||||
|
|
||||||
city = GeometryFactory('citygml', city_file).city
|
city = GeometryFactory('citygml', path=city_file).city
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
building.year_of_construction = 2006
|
building.year_of_construction = 2006
|
||||||
ConstructionFactory('nrel', city).enrich()
|
ConstructionFactory('nrel', city).enrich()
|
||||||
|
@ -80,7 +80,7 @@ class GreeneryInIdf(TestCase):
|
||||||
print('With greenery')
|
print('With greenery')
|
||||||
print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr')
|
print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr')
|
||||||
|
|
||||||
city = GeometryFactory('citygml', city_file).city
|
city = GeometryFactory('citygml', path=city_file).city
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
building.year_of_construction = 2006
|
building.year_of_construction = 2006
|
||||||
ConstructionFactory('nrel', city).enrich()
|
ConstructionFactory('nrel', city).enrich()
|
||||||
|
|
|
@ -24,28 +24,28 @@ class TestLifeCycleAssessment(TestCase):
|
||||||
|
|
||||||
def test_fuel(self):
|
def test_fuel(self):
|
||||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||||
city = GeometryFactory('citygml', city_file).city
|
city = GeometryFactory('citygml', path=city_file).city
|
||||||
LifeCycleAssessment('fuel', city).enrich()
|
LifeCycleAssessment('fuel', city).enrich()
|
||||||
for fuel in city.fuels:
|
for fuel in city.fuels:
|
||||||
self.assertTrue(len(city.fuels) > 0)
|
self.assertTrue(len(city.fuels) > 0)
|
||||||
|
|
||||||
def test_vehicle(self):
|
def test_vehicle(self):
|
||||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||||
city = GeometryFactory('citygml', city_file).city
|
city = GeometryFactory('citygml', path=city_file).city
|
||||||
LifeCycleAssessment('vehicle', city).enrich()
|
LifeCycleAssessment('vehicle', city).enrich()
|
||||||
for vehicle in city.vehicles:
|
for vehicle in city.vehicles:
|
||||||
self.assertTrue(len(city.vehicles) > 0)
|
self.assertTrue(len(city.vehicles) > 0)
|
||||||
|
|
||||||
def test_machine(self):
|
def test_machine(self):
|
||||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||||
city = GeometryFactory('citygml', city_file).city
|
city = GeometryFactory('citygml', path=city_file).city
|
||||||
LifeCycleAssessment('machine', city).enrich()
|
LifeCycleAssessment('machine', city).enrich()
|
||||||
for machine in city.machines:
|
for machine in city.machines:
|
||||||
self.assertTrue(len(city.machines) > 0)
|
self.assertTrue(len(city.machines) > 0)
|
||||||
|
|
||||||
def test_material(self):
|
def test_material(self):
|
||||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||||
city = GeometryFactory('citygml', city_file).city
|
city = GeometryFactory('citygml', path=city_file).city
|
||||||
LifeCycleAssessment('material', city).enrich()
|
LifeCycleAssessment('material', city).enrich()
|
||||||
for material in city.lca_materials:
|
for material in city.lca_materials:
|
||||||
self.assertTrue(len(city.lca_materials) > 0)
|
self.assertTrue(len(city.lca_materials) > 0)
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TestSchedulesFactory(TestCase):
|
||||||
|
|
||||||
def _get_citygml(self, file):
|
def _get_citygml(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
_city = GeometryFactory('citygml', file_path).city
|
_city = GeometryFactory('citygml', path=file_path).city
|
||||||
for building in _city.buildings:
|
for building in _city.buildings:
|
||||||
building.year_of_construction = 2006
|
building.year_of_construction = 2006
|
||||||
ConstructionFactory('nrel', _city).enrich()
|
ConstructionFactory('nrel', _city).enrich()
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TestUsageFactory(TestCase):
|
||||||
|
|
||||||
def _get_citygml(self, file):
|
def _get_citygml(self, file):
|
||||||
file_path = (self._example_path / file).resolve()
|
file_path = (self._example_path / file).resolve()
|
||||||
self._city = GeometryFactory('citygml', file_path).city
|
self._city = GeometryFactory('citygml', path=file_path).city
|
||||||
self.assertIsNotNone(self._city, 'city is none')
|
self.assertIsNotNone(self._city, 'city is none')
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user