Skip to content

Commit

Permalink
[processing] add option to force singlepart geometry type to postgis …
Browse files Browse the repository at this point in the history
…import (fix #14889)
  • Loading branch information
alexbruy committed May 27, 2016
1 parent 5fc17dd commit 33977d1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
Expand Up @@ -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'

Expand Down Expand Up @@ -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)]
Expand All @@ -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()
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 33977d1

Please sign in to comment.