Partial test corrections

This commit is contained in:
Guille Gutierrez 2021-09-23 09:17:23 -04:00
parent e40926e74d
commit ba72bd9043
4 changed files with 27 additions and 4 deletions

View File

@ -17,6 +17,7 @@ from city_model_structure.city_object import CityObject
from city_model_structure.city_objects_cluster import CityObjectsCluster from city_model_structure.city_objects_cluster import CityObjectsCluster
from city_model_structure.buildings_cluster import BuildingsCluster from city_model_structure.buildings_cluster import BuildingsCluster
from city_model_structure.parts_consisting_building import PartsConsistingBuilding from city_model_structure.parts_consisting_building import PartsConsistingBuilding
from city_model_structure.subway_entrance import SubwayEntrance
from helpers.geometry_helper import GeometryHelper from helpers.geometry_helper import GeometryHelper
from helpers.location import Location from helpers.location import Location
@ -31,6 +32,7 @@ class City:
self._lower_corner = lower_corner self._lower_corner = lower_corner
self._upper_corner = upper_corner self._upper_corner = upper_corner
self._buildings = None self._buildings = None
self._subway_entrances = None
self._srs_name = srs_name self._srs_name = srs_name
self._geometry = GeometryHelper() self._geometry = GeometryHelper()
# todo: right now extracted at city level, in the future should be extracted also at building level if exist # todo: right now extracted at city level, in the future should be extracted also at building level if exist
@ -124,6 +126,9 @@ class City:
if self.buildings is not None: if self.buildings is not None:
for building in self.buildings: for building in self.buildings:
self._city_objects.append(building) self._city_objects.append(building)
if self.subway_entrances is not None:
for subway_entrance in self.subway_entrances:
self._city_objects.append(subway_entrance)
return self._city_objects return self._city_objects
@property @property
@ -134,6 +139,14 @@ class City:
""" """
return self._buildings return self._buildings
@property
def subway_entrances(self) -> Union[List[SubwayEntrance], None]:
"""
Get the subway entrances belonging to the city
:return: a list of subway entrances objects or none
"""
return self._subway_entrances
@property @property
def lower_corner(self) -> List[float]: def lower_corner(self) -> List[float]:
""" """
@ -171,6 +184,10 @@ class City:
if self._buildings is None: if self._buildings is None:
self._buildings = [] self._buildings = []
self._buildings.append(new_city_object) self._buildings.append(new_city_object)
elif new_city_object.type == 'subway_entrance':
if self._subway_entrances is None:
self._subway_entrances = []
self._subway_entrances.append(new_city_object)
else: else:
raise NotImplementedError(new_city_object.type) raise NotImplementedError(new_city_object.type)

View File

@ -51,4 +51,7 @@ class OsmSubway:
if coordinate[y] < lower_corner[y]: if coordinate[y] < lower_corner[y]:
lower_corner[y] = coordinate[y] lower_corner[y] = coordinate[y]
return City(lower_corner, upper_corner, 'unknown') city = City(lower_corner, upper_corner, 'unknown')
for subway_entrance in self._subway_entrances:
city.add_city_object(subway_entrance)
return city

View File

@ -23,8 +23,9 @@ class TestConstructionFactory(TestCase):
self._city = None self._city = None
self._example_path = (Path(__file__).parent / 'tests_data').resolve() self._example_path = (Path(__file__).parent / 'tests_data').resolve()
def _get_citygml(self): def _get_citygml(self, file=None):
file = 'pluto_building.gml' if file is None:
file = 'pluto_building.gml'
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', file_path).city
self.assertIsNotNone(self._city, 'city is none') self.assertIsNotNone(self._city, 'city is none')

View File

@ -70,7 +70,6 @@ class TestGeometryFactory(TestCase):
self.assertIsNone(building.attic_heated, 'building attic_heated is not none') self.assertIsNone(building.attic_heated, 'building attic_heated is not none')
self.assertIsNotNone(building.terrains, 'building terrains is none') self.assertIsNotNone(building.terrains, 'building terrains is none')
self.assertIsNone(building.average_storey_height, 'building average_storey_height is not none') self.assertIsNone(building.average_storey_height, 'building average_storey_height is not none')
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
self.assertIsNotNone(building.type, 'building type is none') self.assertIsNotNone(building.type, 'building type is none')
self.assertIsNotNone(building.max_height, 'building max_height is none') self.assertIsNotNone(building.max_height, 'building max_height is none')
self.assertIsNotNone(building.floor_area, 'building floor_area is none') self.assertIsNotNone(building.floor_area, 'building floor_area is none')
@ -246,6 +245,9 @@ class TestGeometryFactory(TestCase):
:return: :return:
""" """
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', file_path).city
print(len(city.city_objects))
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')