From 8c034cdf7982f093df1bbca13745ed9aff31f687 Mon Sep 17 00:00:00 2001 From: Hugo Mercier Date: Mon, 17 Jul 2017 21:30:41 +0200 Subject: [PATCH] XML mode: Allow non-spatial layers --- .../core/load_gml_as_xml.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) 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: