2021-03-25 09:11:42 -04:00
|
|
|
"""
|
|
|
|
Building test
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2021-04-07 11:47:39 -04:00
|
|
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-03-25 09:11:42 -04:00
|
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest import TestCase
|
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
|
|
|
|
|
|
|
2021-08-27 12:51:30 -04:00
|
|
|
class TestBuildings(TestCase):
|
2021-03-25 09:11:42 -04:00
|
|
|
"""
|
|
|
|
TestBuilding TestCase 1
|
|
|
|
"""
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Test setup
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
self._city_gml = None
|
|
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
|
|
|
|
|
|
|
def _get_citygml(self, file):
|
|
|
|
if self._city_gml is None:
|
|
|
|
file_path = (self._example_path / file).resolve()
|
2021-04-08 11:47:58 -04:00
|
|
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
2021-03-25 09:11:42 -04:00
|
|
|
self.assertIsNotNone(self._city_gml, 'city is none')
|
|
|
|
return self._city_gml
|
|
|
|
|
|
|
|
def test_storeys_division(self):
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
|
|
|
Test storeys division
|
|
|
|
"""
|
2021-03-25 09:11:42 -04:00
|
|
|
file = 'kelowna.gml'
|
|
|
|
city = self._get_citygml(file)
|
2021-03-31 14:17:53 -04:00
|
|
|
i = 0
|
2021-03-25 09:11:42 -04:00
|
|
|
for building in city.buildings:
|
2021-03-31 14:17:53 -04:00
|
|
|
if i < 5:
|
2021-03-25 09:11:42 -04:00
|
|
|
building.average_storey_height = 1.5
|
|
|
|
print(building.name)
|
|
|
|
print(building.volume)
|
|
|
|
print(building.floor_area)
|
|
|
|
print(building.max_height)
|
|
|
|
print(building.centroid)
|
|
|
|
print(len(building.storeys))
|
2021-03-31 14:17:53 -04:00
|
|
|
i += 1
|