Clean mapping test

This commit is contained in:
Guille Gutierrez 2023-02-24 07:19:01 -05:00
parent e070ee5779
commit def1bd221f
2 changed files with 5 additions and 14 deletions

View File

@ -62,7 +62,7 @@ class GeometryHelper:
return MapPoint(((city.upper_corner[0] - coordinate[0]) * 0.5), ((city.upper_corner[1] - coordinate[1]) * 0.5)) return MapPoint(((city.upper_corner[0] - coordinate[0]) * 0.5), ((city.upper_corner[1] - coordinate[1]) * 0.5))
@staticmethod @staticmethod
def city_mapping(city, building_names=None): def city_mapping(city, building_names=None, plot=False):
if building_names is None: if building_names is None:
building_names = [b.name for b in city.buildings] building_names = [b.name for b in city.buildings]
x = int((city.upper_corner[0] - city.lower_corner[0]) * 0.5) + 1 x = int((city.upper_corner[0] - city.lower_corner[0]) * 0.5) + 1
@ -101,6 +101,7 @@ class GeometryHelper:
neighbour.neighbours = [building] neighbour.neighbours = [building]
elif building not in neighbour.neighbours: elif building not in neighbour.neighbours:
neighbour.neighbours.append(building) neighbour.neighbours.append(building)
if plot:
img.show() img.show()
@staticmethod @staticmethod

View File

@ -152,20 +152,10 @@ class TestGeometryFactory(TestCase):
""" """
Test neighbours map creation Test neighbours map creation
""" """
start = datetime.datetime.now()
file = 'concordia.geojson' file = 'concordia.geojson'
city = self._get_city(file, 'geojson', city = self._get_city(file, 'geojson',
height_field='citygml_me',
year_of_construction_field='ANNEE_CONS', year_of_construction_field='ANNEE_CONS',
function_field='LIBELLE_UT') function_field='LIBELLE_UT')
city_end = datetime.datetime.now() GeometryHelper.city_mapping(city, plot=False)
print(f'city load {city_end-start}')
GeometryHelper.city_mapping(city)
end = datetime.datetime.now()
print(f'city map {end-city_end}')
for building in city.buildings:
if building.neighbours is not None:
print(f'{building.name} [{[b.name for b in building.neighbours]}]')
else:
print(f'{building.name} has no neighbours')
self.assertTrue(False) self.assertTrue(False)