diff --git a/gml_application_schema_toolbox/core/load_gml_as_xml.py b/gml_application_schema_toolbox/core/load_gml_as_xml.py index 379b6298..577151d5 100644 --- a/gml_application_schema_toolbox/core/load_gml_as_xml.py +++ b/gml_application_schema_toolbox/core/load_gml_as_xml.py @@ -264,21 +264,22 @@ def load_complex_gml(self, xml_uri, is_remote, attributes = {}, geometry_mapping features = [] for id, fid, g, xml, attrs in src.getFeatures(): qgsgeom = None - wkb, srid = g - qgsgeom = QgsGeometry() - qgsgeom.fromWkb(wkb) - if qgsgeom and qgsgeom.type() == QgsWkbTypes.PointGeometry: - if swap_xy: - p = qgsgeom.asPoint() - qgsgeom = QgsGeometry.fromPoint(QgsPointXY(p[1], p[0])) - elif qgsgeom and qgsgeom.type() == QgsWkbTypes.LineGeometry: - if swap_xy: - pl = qgsgeom.asPolyline() - qgsgeom = QgsGeometry.fromPolyline([QgsPointXY(p[1],p[0]) for p in pl]) - elif qgsgeom and qgsgeom.type() == QgsWkbTypes.PolygonGeometry: - if swap_xy: - pl = qgsgeom.asPolygon() - qgsgeom = QgsGeometry.fromPolygon([[QgsPointXY(p[1],p[0]) for p in r] for r in pl]) + if g is not None: + wkb, srid = g + qgsgeom = QgsGeometry() + qgsgeom.fromWkb(wkb) + if qgsgeom and qgsgeom.type() == QgsWkbTypes.PointGeometry: + if swap_xy: + p = qgsgeom.asPoint() + qgsgeom = QgsGeometry.fromPoint(QgsPointXY(p[1], p[0])) + elif qgsgeom and qgsgeom.type() == QgsWkbTypes.LineGeometry: + if swap_xy: + pl = qgsgeom.asPolyline() + qgsgeom = QgsGeometry.fromPolyline([QgsPointXY(p[1],p[0]) for p in pl]) + elif qgsgeom and qgsgeom.type() == QgsWkbTypes.PolygonGeometry: + if swap_xy: + pl = qgsgeom.asPolygon() + qgsgeom = QgsGeometry.fromPolygon([[QgsPointXY(p[1],p[0]) for p in r] for r in pl]) f = QgsFeature(layer.dataProvider().fields(), id) if qgsgeom: