Skip to content
Permalink
Browse files

Merge pull request #3130 from arnaud-morvan/processing_gdal_shapeenco…

…ding

[processing] Add SHAPE_ENCODING parameter in GDAL "to postgis" algorithms
  • Loading branch information
alexbruy committed Jun 14, 2016
2 parents 834ab1c + 5d37cc3 commit 4b7fc98e332d4507a3a1497a93ab1d0bdc3b29ea
@@ -44,6 +44,7 @@ class Ogr2OgrTableToPostGisList(GdalAlgorithm):

DATABASE = 'DATABASE'
INPUT_LAYER = 'INPUT_LAYER'
SHAPE_ENCODING = 'SHAPE_ENCODING'
HOST = 'HOST'
PORT = 'PORT'
USER = 'USER'
@@ -76,6 +77,8 @@ def defineCharacteristics(self):
self.tr('Database (connection name)'), self.DB_CONNECTIONS))
self.addParameter(ParameterTable(self.INPUT_LAYER,
self.tr('Input layer')))
self.addParameter(ParameterString(self.SHAPE_ENCODING,
self.tr('Shape encoding'), "", optional=True))
self.addParameter(ParameterString(self.SCHEMA,
self.tr('Schema name'), 'public', optional=True))
self.addParameter(ParameterString(self.TABLE,
@@ -120,6 +123,7 @@ def getConsoleCommands(self):
password = settings.value(mySettings + '/password')
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = ogrConnectionString(inLayer)[1:-1]
shapeEncoding = self.getParameterValue(self.SHAPE_ENCODING)
schema = unicode(self.getParameterValue(self.SCHEMA))
table = unicode(self.getParameterValue(self.TABLE))
pk = unicode(self.getParameterValue(self.PK))
@@ -140,6 +144,10 @@ def getConsoleCommands(self):
arguments = []
arguments.append('-progress')
arguments.append('--config PG_USE_COPY YES')
if len(shapeEncoding) > 0:
arguments.append('--config')
arguments.append('SHAPE_ENCODING')
arguments.append('"' + shapeEncoding + '"')
arguments.append('-f')
arguments.append('PostgreSQL')
arguments.append('PG:"host=')
@@ -43,6 +43,7 @@
class Ogr2OgrToPostGis(GdalAlgorithm):

INPUT_LAYER = 'INPUT_LAYER'
SHAPE_ENCODING = 'SHAPE_ENCODING'
GTYPE = 'GTYPE'
GEOMTYPE = ['', 'NONE', 'GEOMETRY', 'POINT', 'LINESTRING', 'POLYGON', 'GEOMETRYCOLLECTION', 'MULTIPOINT', 'MULTIPOLYGON', 'MULTILINESTRING']
S_SRS = 'S_SRS'
@@ -81,6 +82,8 @@ def defineCharacteristics(self):
self.group, self.i18n_group = self.trAlgorithm('[OGR] Miscellaneous')
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.SHAPE_ENCODING,
self.tr('Shape encoding'), "", optional=True))
self.addParameter(ParameterSelection(self.GTYPE,
self.tr('Output geometry type'), self.GEOMTYPE, 0))
self.addParameter(ParameterCrs(self.A_SRS,
@@ -153,6 +156,7 @@ def defineCharacteristics(self):
def getConsoleCommands(self):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = ogrConnectionString(inLayer)[1:-1]
shapeEncoding = self.getParameterValue(self.SHAPE_ENCODING)
ssrs = unicode(self.getParameterValue(self.S_SRS))
tsrs = unicode(self.getParameterValue(self.T_SRS))
asrs = unicode(self.getParameterValue(self.A_SRS))
@@ -192,6 +196,10 @@ def getConsoleCommands(self):
arguments = []
arguments.append('-progress')
arguments.append('--config PG_USE_COPY YES')
if len(shapeEncoding) > 0:
arguments.append('--config')
arguments.append('SHAPE_ENCODING')
arguments.append('"' + shapeEncoding + '"')
arguments.append('-f')
arguments.append('PostgreSQL')
arguments.append('PG:"host=' + host)
@@ -47,6 +47,7 @@ class Ogr2OgrToPostGisList(GdalAlgorithm):

DATABASE = 'DATABASE'
INPUT_LAYER = 'INPUT_LAYER'
SHAPE_ENCODING = 'SHAPE_ENCODING'
GTYPE = 'GTYPE'
GEOMTYPE = ['', 'NONE', 'GEOMETRY', 'POINT', 'LINESTRING', 'POLYGON', 'GEOMETRYCOLLECTION', 'MULTIPOINT', 'MULTIPOLYGON', 'MULTILINESTRING']
S_SRS = 'S_SRS'
@@ -93,6 +94,8 @@ def defineCharacteristics(self):
self.tr('Database (connection name)'), self.DB_CONNECTIONS))
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.SHAPE_ENCODING,
self.tr('Shape encoding'), "", optional=True))
self.addParameter(ParameterSelection(self.GTYPE,
self.tr('Output geometry type'), self.GEOMTYPE, 0))
self.addParameter(ParameterCrs(self.A_SRS,
@@ -164,6 +167,7 @@ def getConsoleCommands(self):
password = settings.value(mySettings + '/password')
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = ogrConnectionString(inLayer)[1:-1]
shapeEncoding = self.getParameterValue(self.SHAPE_ENCODING)
ssrs = unicode(self.getParameterValue(self.S_SRS))
tsrs = unicode(self.getParameterValue(self.T_SRS))
asrs = unicode(self.getParameterValue(self.A_SRS))
@@ -198,6 +202,10 @@ def getConsoleCommands(self):
arguments = []
arguments.append('-progress')
arguments.append('--config PG_USE_COPY YES')
if len(shapeEncoding) > 0:
arguments.append('--config')
arguments.append('SHAPE_ENCODING')
arguments.append('"' + shapeEncoding + '"')
arguments.append('-f')
arguments.append('PostgreSQL')
arguments.append('PG:"host=' + host)

0 comments on commit 4b7fc98

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