Skip to content
Permalink
Browse files

make parameter descriptions translatable

  • Loading branch information
alexbruy committed Feb 24, 2015
1 parent a2f686a commit b4f25684ae9c2caa8643d17b677c10b6d57f51f4
@@ -42,30 +42,34 @@ class Ogr2OgrBuffer(OgrAlgorithm):
OUTPUT_LAYER = 'OUTPUT_LAYER'
INPUT_LAYER = 'INPUT_LAYER'
GEOMETRY = 'GEOMETRY'
DISTANCE = 'DISTANCE'
DISTANCE = 'DISTANCE'
DISSOLVEALL = 'DISSOLVEALL'
FIELD = 'FIELD'
MULTI = 'MULTI'
MULTI = 'MULTI'
OPTIONS = 'OPTIONS'

def defineCharacteristics(self):
self.name = 'Buffer vectors'
self.group = '[OGR] Geoprocessing'

self.addParameter(ParameterVector(self.INPUT_LAYER, 'Input layer',
[ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.GEOMETRY, 'Geometry column name ("geometry" for Shapefiles, may be different for other formats)',
'geometry', optional=False))
self.addParameter(ParameterString(self.DISTANCE,'Buffer distance', '1000', optional=False))
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.GEOMETRY,
self.tr('Geometry column name ("geometry" for Shapefiles, may be different for other formats)'),
'geometry', optional=False))
self.addParameter(ParameterString(self.DISTANCE,
self.tr('Buffer distance'), '1000', optional=False))
self.addParameter(ParameterBoolean(self.DISSOLVEALL,
'Dissolve all results?', False))
self.addParameter(ParameterTableField(self.FIELD, 'Dissolve by attribute',
self.INPUT_LAYER, optional=True))
self.tr('Dissolve all results'), False))
self.addParameter(ParameterTableField(self.FIELD,
self.tr('Dissolve by attribute'), self.INPUT_LAYER, optional=True))
self.addParameter(ParameterBoolean(self.MULTI,
'Output as singlepart geometries (only used when dissolving by attribute)?', False))
self.addParameter(ParameterString(self.OPTIONS, 'Additional creation options (see ogr2ogr manual)',
'', optional=True))
self.addOutput(OutputVector(self.OUTPUT_LAYER, 'Output layer'))
self.tr('Output as singlepart geometries (only used when dissolving by attribute)'), False))
self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options (see ogr2ogr manual)'),
'', optional=True))

self.addOutput(OutputVector(self.OUTPUT_LAYER, self.tr('Output layer')))

def processAlgorithm(self, progress):
inLayer = self.getParameterValue(self.INPUT_LAYER)
@@ -74,9 +78,9 @@ def processAlgorithm(self, progress):
geometry = unicode(self.getParameterValue(self.GEOMETRY))
distance = unicode(self.getParameterValue(self.DISTANCE))
dissolveall = self.getParameterValue(self.DISSOLVEALL)
field = unicode(self.getParameterValue(self.FIELD))
field = unicode(self.getParameterValue(self.FIELD))
multi = self.getParameterValue(self.MULTI)

output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value

@@ -90,27 +94,27 @@ def processAlgorithm(self, progress):
if dissolveall or field != 'None':
arguments.append('-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(')
else:
arguments.append('-dialect sqlite -sql "SELECT ST_Buffer(')
arguments.append('-dialect sqlite -sql "SELECT ST_Buffer(')
arguments.append(geometry)
arguments.append(',')
arguments.append(distance)
if dissolveall or field != 'None':
arguments.append(')),*')
arguments.append(')),*')
else:
arguments.append('),*')
arguments.append('),*')
arguments.append('FROM')
arguments.append(layername)
if field != 'None':
arguments.append('GROUP')
arguments.append('BY')
arguments.append(field)
arguments.append('"')
arguments.append('BY')
arguments.append(field)
arguments.append('"')
if field != 'None' and multi:
arguments.append('-explodecollections')

if len(options) > 0:
arguments.append(options)

commands = []
if isWindows():
commands = ['cmd.exe', '/C ', 'ogr2ogr.exe',
@@ -119,4 +123,3 @@ def processAlgorithm(self, progress):
commands = ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]

GdalUtils.runGdal(commands, progress)

@@ -42,11 +42,11 @@ class Ogr2OgrDissolve(OgrAlgorithm):
OUTPUT_LAYER = 'OUTPUT_LAYER'
INPUT_LAYER = 'INPUT_LAYER'
GEOMETRY = 'GEOMETRY'
FIELD = 'FIELD'
MULTI = 'MULTI'
COUNT = 'COUNT'
STATS = 'STATS'
STATSATT = 'STATSATT'
FIELD = 'FIELD'
MULTI = 'MULTI'
COUNT = 'COUNT'
STATS = 'STATS'
STATSATT = 'STATSATT'
AREA = 'AREA'
FIELDS = 'FIELDS'
OPTIONS = 'OPTIONS'
@@ -55,43 +55,43 @@ def defineCharacteristics(self):
self.name = 'Dissolve polygons'
self.group = '[OGR] Geoprocessing'

self.addParameter(ParameterVector(self.INPUT_LAYER, 'Input layer',
[ParameterVector.VECTOR_TYPE_POLYGON], False))
self.addParameter(ParameterString(self.GEOMETRY, 'Geometry column name ("geometry" for Shapefiles, may be different for other formats)',
'geometry', optional=False))
self.addParameter(ParameterTableField(self.FIELD, 'Dissolve field',
self.INPUT_LAYER))
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_POLYGON], False))
self.addParameter(ParameterString(self.GEOMETRY,
self.tr('Geometry column name ("geometry" for Shapefiles, may be different for other formats)'),
'geometry', optional=False))
self.addParameter(ParameterTableField(self.FIELD,
self.tr('Dissolve field'), self.INPUT_LAYER))
self.addParameter(ParameterBoolean(self.MULTI,
'Output as multipart geometries?', True))
self.tr('Output as multipart geometries'), True))
self.addParameter(ParameterBoolean(self.FIELDS,
'Keep input attributes?', False))
self.tr('Keep input attributes'), False))
self.addParameter(ParameterBoolean(self.COUNT,
'Count dissolved features?', False))
self.tr('Count dissolved features'), False))
self.addParameter(ParameterBoolean(self.AREA,
'Compute area and perimeter of dissolved features?', False))
self.tr('Compute area and perimeter of dissolved features'), False))
self.addParameter(ParameterBoolean(self.STATS,
'Compute min/max/sum/mean for the following numeric attribute?', False))
self.addParameter(ParameterTableField(self.STATSATT, 'Numeric attribute to compute dissolved features stats',
self.INPUT_LAYER))
self.addParameter(ParameterString(self.OPTIONS, 'Additional creation options (see ogr2ogr manual)',
'', optional=True))
self.addOutput(OutputVector(self.OUTPUT_LAYER, 'Output layer'))
self.tr('Compute min/max/sum/mean for the following numeric attribute'), False))
self.addParameter(ParameterTableField(self.STATSATT,
self.tr('Numeric attribute to compute dissolved features stats'), self.INPUT_LAYER))
self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options (see ogr2ogr manual)'),
'', optional=True))

self.addOutput(OutputVector(self.OUTPUT_LAYER, self.tr('Output layer')))

def processAlgorithm(self, progress):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = self.ogrConnectionString(inLayer)[1:-1]
layername = "'" + self.ogrLayerName(inLayer) + "'"
geometry = unicode(self.getParameterValue(self.GEOMETRY))
field = unicode(self.getParameterValue(self.FIELD))
field = unicode(self.getParameterValue(self.FIELD))
statsatt = unicode(self.getParameterValue(self.STATSATT))
stats = self.getParameterValue(self.STATS)
area = self.getParameterValue(self.AREA)
multi = self.getParameterValue(self.MULTI)
count = self.getParameterValue(self.COUNT)
fields = self.getParameterValue(self.FIELDS)
#dsUri = QgsDataSourceURI(self.getParameterValue(self.INPUT_LAYER))
#geomColumn = dsUri.geometryColumn()
querystart = '-dialect sqlite -sql "SELECT ST_Union(' + geometry + ')'
queryend = ' FROM ' + layername + ' GROUP BY ' + field + '"'
if fields:
@@ -109,8 +109,8 @@ def processAlgorithm(self, progress):
if area:
queryarea = ", SUM(ST_area(" + geometry + ")) AS area_diss, ST_perimeter(ST_union(" + geometry + ")) AS peri_diss"
else:
queryarea = ""
queryarea = ""

query = querystart + queryfields + querycount + querystats + queryarea + queryend
output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value
@@ -122,11 +122,11 @@ def processAlgorithm(self, progress):
arguments.append(output)
arguments.append(ogrLayer)
arguments.append(self.ogrLayerName(inLayer))
arguments.append(query)
arguments.append(query)

if not multi:
arguments.append('-explodecollections')
arguments.append('-explodecollections')

if len(options) > 0:
arguments.append(options)

@@ -138,4 +138,3 @@ def processAlgorithm(self, progress):
commands = ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]

GdalUtils.runGdal(commands, progress)

@@ -50,31 +50,35 @@ class Ogr2OgrOneSideBuffer(OgrAlgorithm):
LEFTRIGHTLIST = ['Right','Left']
DISSOLVEALL = 'DISSOLVEALL'
FIELD = 'FIELD'
MULTI = 'MULTI'
MULTI = 'MULTI'
OPTIONS = 'OPTIONS'

def defineCharacteristics(self):
self.name = 'Single sided buffers (and offset lines) for lines'
self.group = '[OGR] Geoprocessing'

self.addParameter(ParameterVector(self.INPUT_LAYER, 'Input layer',
[ParameterVector.VECTOR_TYPE_LINE], False))
self.addParameter(ParameterSelection(self.OPERATION, 'Buffer or Offset Curve?',self.OPERATIONLIST, 0))
self.addParameter(ParameterString(self.GEOMETRY, 'Geometry column name ("geometry" for Shapefiles, may be different for other formats)',
'geometry', optional=False))
self.addParameter(ParameterString(self.RADIUS,'Buffer distance', '1000', optional=False))
self.addParameter(ParameterSelection(self.LEFTRIGHT, 'Left or Right buffer',self.LEFTRIGHTLIST, 0))
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_LINE], False))
self.addParameter(ParameterSelection(self.OPERATION,
self.tr('Operation'),self.OPERATIONLIST, 0))
self.addParameter(ParameterString(self.GEOMETRY,
self.tr('Geometry column name ("geometry" for Shapefiles, may be different for other formats)'),
'geometry', optional=False))
self.addParameter(ParameterString(self.RADIUS,
self.tr('Buffer distance'), '1000', optional=False))
self.addParameter(ParameterSelection(self.LEFTRIGHT,
self.tr('Buffer side'),self.LEFTRIGHTLIST, 0))
self.addParameter(ParameterBoolean(self.DISSOLVEALL,
'Dissolve all results?', False))
self.addParameter(ParameterTableField(self.FIELD, 'Dissolve by attribute',
self.INPUT_LAYER, optional=True))
self.tr('Dissolve all results'), False))
self.addParameter(ParameterTableField(self.FIELD,
self.tr('Dissolve by attribute'), self.INPUT_LAYER, optional=True))
self.addParameter(ParameterBoolean(self.MULTI,
'Output as singlepart geometries (only used when dissolving by attribute)?', False))
self.addParameter(ParameterString(self.OPTIONS, 'Additional creation options (see ogr2ogr manual)',
'', optional=True))
self.addOutput(OutputVector(self.OUTPUT_LAYER, 'Output layer'))

self.tr('Output as singlepart geometries (only used when dissolving by attribute)'), False))
self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options (see ogr2ogr manual)'),
'', optional=True))

self.addOutput(OutputVector(self.OUTPUT_LAYER, self.tr('Output layer')))

def processAlgorithm(self, progress):
inLayer = self.getParameterValue(self.INPUT_LAYER)
@@ -85,9 +89,9 @@ def processAlgorithm(self, progress):
distance = unicode(self.getParameterValue(self.RADIUS))
leftright = self.LEFTRIGHTLIST[self.getParameterValue(self.LEFTRIGHT)]
dissolveall = self.getParameterValue(self.DISSOLVEALL)
field = unicode(self.getParameterValue(self.FIELD))
field = unicode(self.getParameterValue(self.FIELD))
multi = self.getParameterValue(self.MULTI)

output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value

@@ -105,35 +109,35 @@ def processAlgorithm(self, progress):
arguments.append('-dialect sqlite -sql "SELECT ST_Union(ST_OffsetCurve(')
else:
if operation == 'Single Side Buffer':
arguments.append('-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(')
arguments.append('-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(')
else:
arguments.append('-dialect sqlite -sql "SELECT ST_OffsetCurve(')
arguments.append('-dialect sqlite -sql "SELECT ST_OffsetCurve(')
arguments.append(geometry)
arguments.append(',')
arguments.append(distance)
if dissolveall or field != 'None':
if leftright == 'Left':
arguments.append(',0)),*')
arguments.append(',0)),*')
else:
arguments.append(',1)),*')
arguments.append(',1)),*')
else:
if leftright == 'Left':
arguments.append(',0),*')
arguments.append(',0),*')
else:
arguments.append(',1),*')
arguments.append(',1),*')
arguments.append('FROM')
arguments.append(layername)
if field != 'None':
arguments.append('GROUP')
arguments.append('BY')
arguments.append(field)
arguments.append('"')
arguments.append('BY')
arguments.append(field)
arguments.append('"')
if field != 'None' and multi:
arguments.append('-explodecollections')

if len(options) > 0:
arguments.append(options)

commands = []
if isWindows():
commands = ['cmd.exe', '/C ', 'ogr2ogr.exe',
@@ -142,4 +146,3 @@ def processAlgorithm(self, progress):
commands = ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]

GdalUtils.runGdal(commands, progress)

@@ -48,22 +48,26 @@ def defineCharacteristics(self):
self.name = 'Create points along lines'
self.group = '[OGR] Geoprocessing'

self.addParameter(ParameterVector(self.INPUT_LAYER, 'Input layer',
[ParameterVector.VECTOR_TYPE_LINE], False))
self.addParameter(ParameterString(self.GEOMETRY, 'Geometry column name ("geometry" for Shapefiles, may be different for other formats)',
'geometry', optional=False))
self.addParameter(ParameterNumber(self.DISTANCE, 'Distance from line start represented as fraction of line length', 0, 1, 0.5))
self.addParameter(ParameterString(self.OPTIONS, 'Additional creation options (see ogr2ogr manual)',
'', optional=True))
self.addOutput(OutputVector(self.OUTPUT_LAYER, 'Output layer'))
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_LINE], False))
self.addParameter(ParameterString(self.GEOMETRY,
self.tr('Geometry column name ("geometry" for Shapefiles, may be different for other formats)'),
'geometry', optional=False))
self.addParameter(ParameterNumber(self.DISTANCE,
self.tr('Distance from line start represented as fraction of line length'), 0, 1, 0.5))
self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options (see ogr2ogr manual)'),
'', optional=True))

self.addOutput(OutputVector(self.OUTPUT_LAYER, self.tr('Output layer')))

def processAlgorithm(self, progress):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = self.ogrConnectionString(inLayer)[1:-1]
layername = "'" + self.ogrLayerName(inLayer) + "'"
distance = unicode(self.getParameterValue(self.DISTANCE))
geometry = unicode(self.getParameterValue(self.GEOMETRY))

output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value

@@ -74,7 +78,7 @@ def processAlgorithm(self, progress):
arguments.append(output)
arguments.append(ogrLayer)
arguments.append(self.ogrLayerName(inLayer))

arguments.append('-dialect sqlite -sql "SELECT ST_Line_Interpolate_Point(')
arguments.append(geometry)
arguments.append(',')
@@ -83,10 +87,10 @@ def processAlgorithm(self, progress):
arguments.append('FROM')
arguments.append(layername)
arguments.append('"')

if len(options) > 0:
arguments.append(options)

commands = []
if isWindows():
commands = ['cmd.exe', '/C ', 'ogr2ogr.exe',
@@ -95,4 +99,3 @@ def processAlgorithm(self, progress):
commands = ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]

GdalUtils.runGdal(commands, progress)

0 comments on commit b4f2568

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