Skip to content
Permalink
Browse files

[processing] drop GEOM_TYPE_MAP in favour of QgsWkbTypes.displayString()

  • Loading branch information
alexbruy committed Oct 5, 2016
1 parent 7a49612 commit eeb8269464f6e411f389400d8c39b261705bc1a8
Showing with 3 additions and 20 deletions.
  1. +3 −20 python/plugins/processing/tools/vector.py
@@ -52,23 +52,6 @@
from processing.tools import dataobjects, spatialite, postgis


GEOM_TYPE_MAP = {
QgsWkbTypes.NullGeometry: 'none',
QgsWkbTypes.Point: 'Point',
QgsWkbTypes.LineString: 'LineString',
QgsWkbTypes.Polygon: 'Polygon',
QgsWkbTypes.MultiPoint: 'MultiPoint',
QgsWkbTypes.MultiLineString: 'MultiLineString',
QgsWkbTypes.MultiPolygon: 'MultiPolygon',
QgsWkbTypes.Point25D: 'Point25D',
QgsWkbTypes.LineString25D: 'LineString25D',
QgsWkbTypes.Polygon25D: 'Polygon25D',
QgsWkbTypes.MultiPoint25D: 'MultiPoint25D',
QgsWkbTypes.MultiLineString25D: 'MultiLineString25D',
QgsWkbTypes.MultiPolygon25D: 'MultiPolygon25D',
}


TYPE_MAP = {
str: QVariant.String,
float: QVariant.Double,
@@ -567,7 +550,7 @@ def __init__(self, destination, encoding, fields, geometryType,
if self.destination.startswith(self.MEMORY_LAYER_PREFIX):
self.isNotFileBased = True

uri = GEOM_TYPE_MAP[geometryType] + "?uuid=" + str(uuid.uuid4())
uri = QgsWkbTypes.displayString(geometryType) + "?uuid=" + str(uuid.uuid4())
if crs.isValid():
uri += '&crs=' + crs.authid()
fieldsdesc = []
@@ -614,7 +597,7 @@ def _runSQL(sql):
if geometryType != QgsWkbTypes.NullGeometry:
_runSQL("SELECT AddGeometryColumn('{schema}', '{table}', 'the_geom', {srid}, '{typmod}', 2)".format(
table=uri.table().lower(), schema=uri.schema(), srid=crs.authid().split(":")[-1],
typmod=GEOM_TYPE_MAP[geometryType].upper()))
typmod=QgsWkbTypes.displayString(geometryType).upper()))

self.layer = QgsVectorLayer(uri.uri(), uri.table(), "postgres")
self.writer = self.layer.dataProvider()
@@ -646,7 +629,7 @@ def _runSQL(sql):
if geometryType != QgsWkbTypes.NullGeometry:
_runSQL("SELECT AddGeometryColumn('{table}', 'the_geom', {srid}, '{typmod}', 2)".format(
table=uri.table().lower(), srid=crs.authid().split(":")[-1],
typmod=GEOM_TYPE_MAP[geometryType].upper()))
typmod=QgsWkbTypes.displayString(geometryType).upper()))

self.layer = QgsVectorLayer(uri.uri(), uri.table(), "spatialite")
self.writer = self.layer.dataProvider()

0 comments on commit eeb8269

Please sign in to comment.
You can’t perform that action at this time.