CityGML Feeder now auto remove last duplicated point

This commit is contained in:
Guille Gutierrez 2021-03-08 12:05:05 -05:00
parent dbd32e4d20
commit f3443acb30

View File

@ -127,28 +127,28 @@ class CityGml:
@staticmethod @staticmethod
def _lod1_solid(o): def _lod1_solid(o):
try: try:
surfaces = [Surface(s['Polygon']['exterior']['LinearRing']['posList']['#text']) surfaces = [Surface(CityGml._remove_last_point(s['Polygon']['exterior']['LinearRing']['posList']['#text']))
for s in o['Building']['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']] for s in o['Building']['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']]
except TypeError: except TypeError:
surfaces = [Surface(s['Polygon']['exterior']['LinearRing']['posList']) surfaces = [Surface(CityGml._remove_last_point(s['Polygon']['exterior']['LinearRing']['posList']))
for s in o['Building']['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']] for s in o['Building']['lod1Solid']['Solid']['exterior']['CompositeSurface']['surfaceMember']]
return surfaces return surfaces
@staticmethod @staticmethod
def _lod1_multi_surface(o): def _lod1_multi_surface(o):
surfaces = [Surface(s['Polygon']['exterior']['LinearRing']['posList']) surfaces = [Surface(CityGml._remove_last_point((s['Polygon']['exterior']['LinearRing']['posList']))
for s in o['Building']['lod1MultiSurface']['MultiSurface']['surfaceMember']] for s in o['Building']['lod1MultiSurface']['MultiSurface']['surfaceMember']]
return surfaces return surfaces
@staticmethod @staticmethod
def _lod2_solid_multi_surface(o): def _lod2_solid_multi_surface(o):
surfaces = [Surface(s['Polygon']['exterior']['LinearRing']['posList']) surfaces = [Surface(CityGml._remove_last_point(s['Polygon']['exterior']['LinearRing']['posList']))
for s in o['Building']['lod2MultiSurface']['MultiSurface']['surfaceMember']] for s in o['Building']['lod2MultiSurface']['MultiSurface']['surfaceMember']]
return surfaces return surfaces
@staticmethod @staticmethod
def _lod2_composite_surface(s): def _lod2_composite_surface(s):
surfaces = [Surface(sm['Polygon']['exterior']['LinearRing']['posList']) surfaces = [Surface(CityGml._remove_last_point(sm['Polygon']['exterior']['LinearRing']['posList']))
for sm in s['CompositeSurface']['surfaceMember']] for sm in s['CompositeSurface']['surfaceMember']]
return surfaces return surfaces
@ -156,10 +156,10 @@ class CityGml:
def _lod2_multi_surface(s, surface_type): def _lod2_multi_surface(s, surface_type):
# todo: this need to be changed into surface bounded? # todo: this need to be changed into surface bounded?
try: try:
surfaces = [Surface(s['Polygon']['exterior']['LinearRing']['posList']['#text'], surfaces = [Surface(CityGml._remove_last_point(s['Polygon']['exterior']['LinearRing']['posList']['#text']),
surface_type=GeometryHelper.gml_surface_to_libs(surface_type))] surface_type=GeometryHelper.gml_surface_to_libs(surface_type))]
except TypeError: except TypeError:
surfaces = [Surface(s['Polygon']['exterior']['LinearRing']['posList'], surfaces = [Surface(CityGml._remove_last_point(s['Polygon']['exterior']['LinearRing']['posList']),
surface_type=GeometryHelper.gml_surface_to_libs(surface_type))] surface_type=GeometryHelper.gml_surface_to_libs(surface_type))]
return surfaces return surfaces
@ -173,3 +173,9 @@ class CityGml:
else: else:
surfaces = surfaces + CityGml._lod2_multi_surface(s, surface_type) surfaces = surfaces + CityGml._lod2_multi_surface(s, surface_type)
return surfaces return surfaces
@staticmethod
def _remove_last_point(points):
array = points.split(' ')
res = " "
return res.join(array[0:len(array) -3])