Testing kelowna test case to debug triangulation and volume calculations
This commit is contained in:
parent
592afe929d
commit
1aa17575bf
|
@ -30,7 +30,7 @@ class Polyhedron:
|
|||
self._min_z = None
|
||||
self._min_y = None
|
||||
self._min_x = None
|
||||
self._geometry = GeometryHelper(delta=5.0, area_delta=0.01)
|
||||
self._geometry = GeometryHelper(delta=0.5, area_delta=0.001)
|
||||
|
||||
def _position_of(self, point, face):
|
||||
vertices = self.vertices
|
||||
|
|
|
@ -19,7 +19,6 @@ class CityObject:
|
|||
self._lod = lod
|
||||
self._surfaces = surfaces
|
||||
self._polyhedron = None
|
||||
self._geometry = GeometryHelper()
|
||||
|
||||
@property
|
||||
def lod(self):
|
||||
|
|
|
@ -17,10 +17,15 @@ class GeometryHelper:
|
|||
"""
|
||||
Geometry helper class
|
||||
"""
|
||||
|
||||
def __init__(self, delta=0.5, area_delta=0.5):
|
||||
self._delta = delta
|
||||
self._area_delta = area_delta
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
print(f'delta {self._delta} area {self._area_delta}')
|
||||
|
||||
@staticmethod
|
||||
def adjacent_locations(location1, location2):
|
||||
"""
|
||||
|
@ -46,7 +51,7 @@ class GeometryHelper:
|
|||
delta = math.fabs(a1 - a2)
|
||||
return delta <= self._area_delta
|
||||
|
||||
def almost_equal(self, v1, v2, debug=False):
|
||||
def almost_equal(self, v1, v2):
|
||||
"""
|
||||
Compare two points and decides if they are almost equal (quadratic error under delta)
|
||||
:param v1: [x,y,z]
|
||||
|
|
|
@ -9,6 +9,7 @@ from unittest import TestCase
|
|||
|
||||
from city_model_structure.city import City
|
||||
from factories.geometry_factory import GeometryFactory
|
||||
from helpers.geometry_helper import GeometryHelper
|
||||
|
||||
|
||||
class TestGeometryFactory(TestCase):
|
||||
|
@ -23,7 +24,8 @@ class TestGeometryFactory(TestCase):
|
|||
self._city_gml = None
|
||||
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
||||
self._pickle_file = (self._example_path / 'city.pickle').resolve()
|
||||
self._big_pickle_file = (self._example_path / 'big.pickle').resolve()
|
||||
self._kelowna_pickle_file = (self._example_path / 'kelowna_test_case.pickle').resolve()
|
||||
self._output_path = (Path(__file__).parent / 'surface_outputs').resolve()
|
||||
|
||||
def _get_citygml(self):
|
||||
if self._city_gml is None:
|
||||
|
@ -69,6 +71,21 @@ class TestGeometryFactory(TestCase):
|
|||
self.assertIsNotNone(city.country_code, 'country code is none')
|
||||
os.remove(self._pickle_file.resolve())
|
||||
|
||||
def test_surfaces_triangulation(self):
|
||||
"""
|
||||
Test city surfaces triangulation and polygon creation
|
||||
:return:
|
||||
"""
|
||||
city = City.load(self._kelowna_pickle_file)
|
||||
helper = GeometryHelper(delta=0.0, area_delta=0.5)
|
||||
errors = 0
|
||||
for building in city.buildings:
|
||||
building._polyhedron._geometry = helper
|
||||
if str(building.volume) == 'inf':
|
||||
building.obj_export(self._output_path)
|
||||
errors += 1
|
||||
print(f'{errors} buildings aren\'t closed volumes')
|
||||
|
||||
def test_citygml_buildings(self):
|
||||
"""
|
||||
Test city objects in the city
|
||||
|
|
BIN
tests_data/kelowna_test_case.pickle
Normal file
BIN
tests_data/kelowna_test_case.pickle
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user