Merge remote-tracking branch 'origin/master'

This commit is contained in:
pilar 2021-01-07 17:34:08 -05:00
commit f3a0a7c942
5 changed files with 25 additions and 4 deletions

View File

@ -30,7 +30,7 @@ class Polyhedron:
self._min_z = None self._min_z = None
self._min_y = None self._min_y = None
self._min_x = 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): def _position_of(self, point, face):
vertices = self.vertices vertices = self.vertices

View File

@ -19,7 +19,6 @@ class CityObject:
self._lod = lod self._lod = lod
self._surfaces = surfaces self._surfaces = surfaces
self._polyhedron = None self._polyhedron = None
self._geometry = GeometryHelper()
@property @property
def lod(self): def lod(self):

View File

@ -17,10 +17,15 @@ class GeometryHelper:
""" """
Geometry helper class Geometry helper class
""" """
def __init__(self, delta=0.5, area_delta=0.5): def __init__(self, delta=0.5, area_delta=0.5):
self._delta = delta self._delta = delta
self._area_delta = area_delta self._area_delta = area_delta
@property
def config(self):
print(f'delta {self._delta} area {self._area_delta}')
@staticmethod @staticmethod
def adjacent_locations(location1, location2): def adjacent_locations(location1, location2):
""" """
@ -46,7 +51,7 @@ class GeometryHelper:
delta = math.fabs(a1 - a2) delta = math.fabs(a1 - a2)
return delta <= self._area_delta 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) Compare two points and decides if they are almost equal (quadratic error under delta)
:param v1: [x,y,z] :param v1: [x,y,z]

View File

@ -9,6 +9,7 @@ from unittest import TestCase
from city_model_structure.city import City from city_model_structure.city import City
from factories.geometry_factory import GeometryFactory from factories.geometry_factory import GeometryFactory
from helpers.geometry_helper import GeometryHelper
class TestGeometryFactory(TestCase): class TestGeometryFactory(TestCase):
@ -23,7 +24,8 @@ class TestGeometryFactory(TestCase):
self._city_gml = None self._city_gml = None
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve() self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
self._pickle_file = (self._example_path / 'city.pickle').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): def _get_citygml(self):
if self._city_gml is None: if self._city_gml is None:
@ -69,6 +71,21 @@ class TestGeometryFactory(TestCase):
self.assertIsNotNone(city.country_code, 'country code is none') self.assertIsNotNone(city.country_code, 'country code is none')
os.remove(self._pickle_file.resolve()) 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): def test_citygml_buildings(self):
""" """
Test city objects in the city Test city objects in the city

Binary file not shown.