Skip to content

Commit

Permalink
XML mode: Allow non-spatial layers
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Mercier committed Jul 17, 2017
1 parent 3520161 commit 8c034cd
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions gml_application_schema_toolbox/core/load_gml_as_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8c034cd

Please sign in to comment.