Skip to content
Permalink
Browse files

[processing] add option to force singlepart geometry type to postgis …

…import (fix #14889)
  • Loading branch information
alexbruy committed May 27, 2016
1 parent 5fc17dd commit 33977d16dd7f0df5371613cf5033bad1ef6910cd
Showing with 6 additions and 0 deletions.
  1. +6 −0 python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
@@ -50,6 +50,7 @@ class ImportIntoPostGIS(GeoAlgorithm):
GEOMETRY_COLUMN = 'GEOMETRY_COLUMN'
LOWERCASE_NAMES = 'LOWERCASE_NAMES'
DROP_STRING_LENGTH = 'DROP_STRING_LENGTH'
FORCE_SINGLEPART = 'FORCE_SINGLEPART'
PRIMARY_KEY = 'PRIMARY_KEY'
ENCODING = 'ENCODING'

@@ -81,6 +82,8 @@ def defineCharacteristics(self):
self.tr('Convert field names to lowercase'), True))
self.addParameter(ParameterBoolean(self.DROP_STRING_LENGTH,
self.tr('Drop length constraints on character fields'), False))
self.addParameter(ParameterBoolean(self.FORCE_SINGLEPART,
self.tr('Create single-part geometries instead of multi-part'), False))

def processAlgorithm(self, progress):
connection = self.DB_CONNECTIONS[self.getParameterValue(self.DATABASE)]
@@ -89,6 +92,7 @@ def processAlgorithm(self, progress):
createIndex = self.getParameterValue(self.CREATEINDEX)
convertLowerCase = self.getParameterValue(self.LOWERCASE_NAMES)
dropStringLength = self.getParameterValue(self.DROP_STRING_LENGTH)
forceSinglePart = self.getParameterValue(self.FORCE_SINGLEPART)
primaryKeyField = self.getParameterValue(self.PRIMARY_KEY)
encoding = self.getParameterValue(self.ENCODING)
settings = QSettings()
@@ -131,6 +135,8 @@ def processAlgorithm(self, progress):
geomColumn = geomColumn.lower()
if dropStringLength:
options['dropStringConstraints'] = True
if forceSinglePart:
options['forceSinglePartGeometryType'] = True

# Clear geometry column for non-geometry tables
if not layer.hasGeometryType():

0 comments on commit 33977d1

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