Skip to content

Commit

Permalink
[processing] drop GEOM_TYPE_MAP in favour of QgsWkbTypes.displayString()
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 5, 2016
1 parent 7a49612 commit eeb8269
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions python/plugins/processing/tools/vector.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit eeb8269

Please sign in to comment.