Compare commits

...

2 Commits

Author SHA1 Message Date
1f6b3e2d8a Correct unit tests 2023-03-17 12:56:47 -04:00
81e7d580cf partial optimization 2023-03-17 12:54:52 -04:00
4 changed files with 12 additions and 2 deletions

View File

@ -152,6 +152,10 @@ class Polygon:
self._area += np.linalg.norm(np.cross(ab, ac)) / 2
return self._area
@area.setter
def area(self, value):
self._area = value
@property
def normal(self) -> np.ndarray:
"""

View File

@ -68,6 +68,7 @@ class Geojson:
# geojson provides the roofs, need to be transform into grounds
points = igh.invert_points(points)
polygon = Polygon(points)
polygon.area = igh.ground_area(points)
surfaces.append(Surface(polygon, polygon))
buildings.append(Building(f'{name}_zone_{zone}', surfaces, year_of_construction, function))
return buildings

View File

@ -134,7 +134,7 @@ class TestGeometryFactory(TestCase):
"""
Test geojson import
"""
file = '10000_buildings.geojson'
file = '2000_buildings.geojson'
start = datetime.datetime.now()
city = self._get_city(file, 'geojson',
height_field='building_height',
@ -146,7 +146,7 @@ class TestGeometryFactory(TestCase):
hub.exports.exports_factory.ExportsFactory('obj', city, self._output_path).export()
end = datetime.datetime.now()
print(f'geometry export in {end - start} s')
self.assertEqual(195, len(city.buildings), 'wrong number of buildings')
self.assertEqual(2356, len(city.buildings), 'wrong number of buildings')
self._check_buildings(city)
def test_map_neighbours(self):
@ -159,6 +159,10 @@ class TestGeometryFactory(TestCase):
year_of_construction_field='ANNEE_CONS',
function_field='LIBELLE_UT')
info_lod1 = GeometryHelper.city_mapping(city, plot=False)
city = self._get_city(file, 'geojson',
year_of_construction_field='ANNEE_CONS',
function_field='LIBELLE_UT')
info_lod0 = GeometryHelper.city_mapping(city, plot=False)
hub.exports.exports_factory.ExportsFactory('obj', city, self._output_path).export()
self.assertEqual(info_lod0, info_lod1)
for building in city.buildings:

File diff suppressed because one or more lines are too long