forked from s_ranjbar/city_retrofit
Fixt test and implement lod2 with multiparts
This commit is contained in:
parent
d37f8bc68c
commit
5e65b09665
|
@ -48,6 +48,7 @@ class CityGml:
|
|||
|
||||
self._city_objects = None
|
||||
self._geometry = GeometryHelper()
|
||||
|
||||
for bound in self._gml['CityModel']['boundedBy']:
|
||||
envelope = bound['Envelope']
|
||||
if '#text' in envelope['lowerCorner']:
|
||||
|
@ -58,6 +59,7 @@ class CityGml:
|
|||
self._upper_corner = np.fromstring(envelope['upperCorner'], dtype=float, sep=' ')
|
||||
if '@srsName' in envelope:
|
||||
self._srs_name = envelope['@srsName']
|
||||
print(f'gmlread {path}')
|
||||
|
||||
@property
|
||||
def content(self):
|
||||
|
|
|
@ -32,14 +32,22 @@ class CityGmlLod2(CityGmlBase):
|
|||
def _surface_encoding(surfaces):
|
||||
if 'lod2MultiSurface' in surfaces:
|
||||
return 'lod2MultiSurface', 'MultiSurface'
|
||||
print(surfaces)
|
||||
raise NotImplementedError('unknown surface type')
|
||||
|
||||
@classmethod
|
||||
def _solid(cls, o):
|
||||
surfaces = []
|
||||
for b in o["boundedBy"]:
|
||||
surface_type = next(iter(b))
|
||||
surface_encoding, surface_subtype = cls._surface_encoding(b[surface_type])
|
||||
try:
|
||||
surface_type = next(iter(b))
|
||||
except TypeError:
|
||||
continue
|
||||
try:
|
||||
surface_encoding, surface_subtype = cls._surface_encoding(b[surface_type])
|
||||
except NotImplementedError:
|
||||
print("Ignore bounded")
|
||||
continue
|
||||
for member in b[surface_type][surface_encoding][surface_subtype]['surfaceMember']:
|
||||
if '@srsDimension' in member['Polygon']['exterior']['LinearRing']['posList']:
|
||||
gml_points = member['Polygon']['exterior']['LinearRing']['posList']["#text"]
|
||||
|
@ -57,20 +65,4 @@ class CityGmlLod2(CityGmlBase):
|
|||
|
||||
@classmethod
|
||||
def _multi_surface(cls, o):
|
||||
surfaces = []
|
||||
for b in o["boundedBy"]:
|
||||
try:
|
||||
surface_type = next(iter(b))
|
||||
except TypeError:
|
||||
continue
|
||||
surface_encoding, surface_subtype = cls._surface_encoding(b[surface_type])
|
||||
for member in b[surface_type][surface_encoding][surface_subtype]['surfaceMember']:
|
||||
if '@srsDimension' in member['Polygon']['exterior']['LinearRing']['posList']:
|
||||
gml_points = member['Polygon']['exterior']['LinearRing']['posList']["#text"]
|
||||
else:
|
||||
gml_points = member['Polygon']['exterior']['LinearRing']['posList']
|
||||
sp = cls._solid_points(cls._remove_last_point(gml_points))
|
||||
p = Polygon(sp)
|
||||
surface = Surface(p, p, surface_type=GeometryHelper.gml_surface_to_libs(surface_type))
|
||||
surfaces.append(surface)
|
||||
return surfaces
|
||||
return cls._solid(o)
|
||||
|
|
|
@ -49,13 +49,13 @@ class TestGeometryFactory(TestCase):
|
|||
|
||||
# citygml
|
||||
def test_stuttgart_gml(self):
|
||||
file = '20190815_mitte_out_MC_FloursurfaceADD.gml'
|
||||
file = 'ConcordiaSWGcampus.gml'
|
||||
city = self._get_citygml(file)
|
||||
print(f'city name: {city}')
|
||||
for building in city.buildings:
|
||||
print(f'building {building.name} has {len(building.surfaces)} surfaces {building.volume}')
|
||||
self.assertFalse(building.volume is 'inf', 'building volume is inf')
|
||||
print(f'Found {len(city.buildings)} buildings')
|
||||
self.assertTrue(True)
|
||||
|
||||
def test_citygml_buildings(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user