Skip to content

Commit

Permalink
Merge pull request #2283 from arnaud-morvan/processing-translate-para…
Browse files Browse the repository at this point in the history
…meterselection-content

[processing] include ParameterSelection dropdown contents in translations
  • Loading branch information
alexbruy committed Sep 27, 2015
2 parents a77e3bf + ea0dc6e commit 5f10b70
Show file tree
Hide file tree
Showing 23 changed files with 140 additions and 95 deletions.
7 changes: 5 additions & 2 deletions python/plugins/processing/algs/qgis/AddTableField.py
Expand Up @@ -45,19 +45,22 @@ class AddTableField(GeoAlgorithm):
FIELD_LENGTH = 'FIELD_LENGTH'
FIELD_PRECISION = 'FIELD_PRECISION'

TYPE_NAMES = ['Integer', 'Float', 'String']
TYPES = [QVariant.Int, QVariant.Double, QVariant.String]

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Add field to attributes table')
self.group, self.i18n_group = self.trAlgorithm('Vector table tools')

self.type_names = [self.tr('Integer'),
self.tr('Float'),
self.tr('String')]

self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.FIELD_NAME,
self.tr('Field name')))
self.addParameter(ParameterSelection(self.FIELD_TYPE,
self.tr('Field type'), self.TYPE_NAMES))
self.tr('Field type'), self.type_names))
self.addParameter(ParameterNumber(self.FIELD_LENGTH,
self.tr('Field length'), 1, 255, 10))
self.addParameter(ParameterNumber(self.FIELD_PRECISION,
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/algs/qgis/CheckValidity.py
Expand Up @@ -44,14 +44,14 @@ class CheckValidity(GeoAlgorithm):
INVALID_OUTPUT = 'INVALID_OUTPUT'
ERROR_OUTPUT = 'ERROR_OUTPUT'

METHODS = ['The one selected in digitizing settings',
'QGIS',
'GEOS']

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Check validity')
self.group, self.i18n_group = self.trAlgorithm('Vector geometry tools')

self.methods = [self.tr('The one selected in digitizing settings'),
'QGIS',
'GEOS']

self.addParameter(ParameterVector(
self.INPUT_LAYER,
self.tr('Input layer'),
Expand All @@ -60,7 +60,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(
self.METHOD,
self.tr('Method'),
self.METHODS))
self.methods))

self.addOutput(OutputVector(
self.VALID_OUTPUT,
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/processing/algs/qgis/ConvexHull.py
Expand Up @@ -43,19 +43,21 @@ class ConvexHull(GeoAlgorithm):
OUTPUT = 'OUTPUT'
FIELD = 'FIELD'
METHOD = 'METHOD'
METHODS = ['Create single minimum convex hull',
'Create convex hulls based on field']

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Convex hull')
self.group, self.i18n_group = self.trAlgorithm('Vector geometry tools')

self.methods = [self.tr('Create single minimum convex hull'),
self.tr('Create convex hulls based on field')]

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterTableField(self.FIELD,
self.tr('Field (optional, only used if creating convex hulls by classes)'),
self.INPUT, optional=True))
self.addParameter(ParameterSelection(self.METHOD,
self.tr('Method'), self.METHODS))
self.tr('Method'), self.methods))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Convex hull')))

def processAlgorithm(self, progress):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/algs/qgis/Eliminate.py
Expand Up @@ -49,14 +49,18 @@ class Eliminate(GeoAlgorithm):
COMPARISONVALUE = 'COMPARISONVALUE'
COMPARISON = 'COMPARISON'

MODES = ['Largest area', 'Smallest Area', 'Largest common boundary']
MODE_LARGEST_AREA = 0
MODE_SMALLEST_AREA = 1
MODE_BOUNDARY = 2

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Eliminate sliver polygons')
self.group, self.i18n_group = self.trAlgorithm('Vector geometry tools')

self.modes = [self.tr('Largest area'),
self.tr('Smallest Area'),
self.tr('Largest common boundary')]

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_POLYGON]))
self.addParameter(ParameterBoolean(self.KEEPSELECTION,
Expand All @@ -79,7 +83,7 @@ def defineCharacteristics(self):
self.tr('Value'), default='0'))
self.addParameter(ParameterSelection(self.MODE,
self.tr('Merge selection with the neighbouring polygon with the'),
self.MODES))
self.modes))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Cleaned')))

def processAlgorithm(self, progress):
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/processing/algs/qgis/ExportGeometryInfo.py
Expand Up @@ -41,16 +41,18 @@ class ExportGeometryInfo(GeoAlgorithm):
METHOD = 'CALC_METHOD'
OUTPUT = 'OUTPUT'

CALC_METHODS = ['Layer CRS', 'Project CRS', 'Ellipsoidal']

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Export/Add geometry columns')
self.group, self.i18n_group = self.trAlgorithm('Vector table tools')

self.calc_methods = [self.tr('Layer CRS'),
self.tr('Project CRS'),
self.tr('Ellipsoidal')]

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterSelection(self.METHOD,
self.tr('Calculate using'), self.CALC_METHODS, 0))
self.tr('Calculate using'), self.calc_methods, 0))

self.addOutput(OutputVector(self.OUTPUT, self.tr('Added geom info')))

Expand Down
11 changes: 10 additions & 1 deletion python/plugins/processing/algs/qgis/ExtractByAttribute.py
Expand Up @@ -58,12 +58,21 @@ def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Extract by attribute')
self.group, self.i18n_group = self.trAlgorithm('Vector selection tools')

self.i18n_operators = ['=',
'!=',
'>',
'>=',
'<',
'<=',
self.tr('begins with'),
self.tr('contains')]

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input Layer'), [ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterTableField(self.FIELD,
self.tr('Selection attribute'), self.INPUT))
self.addParameter(ParameterSelection(self.OPERATOR,
self.tr('Operator'), self.OPERATORS))
self.tr('Operator'), self.i18n_operators))
self.addParameter(ParameterString(self.VALUE, self.tr('Value')))

self.addOutput(OutputVector(self.OUTPUT, self.tr('Extracted (attribute)')))
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/algs/qgis/FieldPyculator.py
Expand Up @@ -51,18 +51,22 @@ class FieldsPyculator(GeoAlgorithm):
OUTPUT_LAYER = 'OUTPUT_LAYER'
RESULT_VAR_NAME = 'value'

TYPE_NAMES = ['Integer', 'Float', 'String']
TYPES = [QVariant.Int, QVariant.Double, QVariant.String]

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Advanced Python field calculator')
self.group, self.i18n_group = self.trAlgorithm('Vector table tools')

self.type_names = [self.tr('Integer'),
self.tr('Float'),
self.tr('String')]

self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.FIELD_NAME,
self.tr('Result field name'), 'NewField'))
self.addParameter(ParameterSelection(self.FIELD_TYPE,
self.tr('Field type'), self.TYPE_NAMES))
self.tr('Field type'), self.type_names))
self.addParameter(ParameterNumber(self.FIELD_LENGTH,
self.tr('Field length'), 1, 255, 10))
self.addParameter(ParameterNumber(self.FIELD_PRECISION,
Expand Down
9 changes: 7 additions & 2 deletions python/plugins/processing/algs/qgis/FieldsCalculator.py
Expand Up @@ -52,18 +52,23 @@ class FieldsCalculator(GeoAlgorithm):
FORMULA = 'FORMULA'
OUTPUT_LAYER = 'OUTPUT_LAYER'

TYPE_NAMES = ['Float', 'Integer', 'String', 'Date']
TYPES = [QVariant.Double, QVariant.Int, QVariant.String, QVariant.Date]

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Field calculator')
self.group, self.i18n_group = self.trAlgorithm('Vector table tools')

self.type_names = [self.tr('Float'),
self.tr('Integer'),
self.tr('String'),
self.tr('Date')]

self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY], False))
self.addParameter(ParameterString(self.FIELD_NAME,
self.tr('Result field name')))
self.addParameter(ParameterSelection(self.FIELD_TYPE,
self.tr('Field type'), self.TYPE_NAMES))
self.tr('Field type'), self.type_names))
self.addParameter(ParameterNumber(self.FIELD_LENGTH,
self.tr('Field length'), 1, 255, 10))
self.addParameter(ParameterNumber(self.FIELD_PRECISION,
Expand Down
15 changes: 7 additions & 8 deletions python/plugins/processing/algs/qgis/GeometryConvert.py
Expand Up @@ -40,21 +40,20 @@ class GeometryConvert(GeoAlgorithm):
TYPE = 'TYPE'
OUTPUT = 'OUTPUT'

TYPES = ['Centroids',
'Nodes',
'Linestrings',
'Multilinestrings',
'Polygons'
]

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Convert geometry type')
self.group, self.i18n_group = self.trAlgorithm('Vector geometry tools')

self.types = [self.tr('Centroids'),
self.tr('Nodes'),
self.tr('Linestrings'),
self.tr('Multilinestrings'),
self.tr('Polygons')]

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterSelection(self.TYPE,
self.tr('New geometry type'), self.TYPES))
self.tr('New geometry type'), self.types))

self.addOutput(OutputVector(self.OUTPUT, self.tr('Converted')))

Expand Down
13 changes: 6 additions & 7 deletions python/plugins/processing/algs/qgis/Grid.py
Expand Up @@ -46,18 +46,17 @@ class Grid(GeoAlgorithm):
CRS = 'CRS'
OUTPUT = 'OUTPUT'

TYPES = ['Rectangle (line)',
'Rectangle (polygon)',
'Diamond (polygon)',
'Hexagon (polygon)'
]

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Create grid')
self.group, self.i18n_group = self.trAlgorithm('Vector creation tools')

self.types = [self.tr('Rectangle (line)'),
self.tr('Rectangle (polygon)'),
self.tr('Diamond (polygon)'),
self.tr('Hexagon (polygon)')]

self.addParameter(ParameterSelection(self.TYPE,
self.tr('Grid type'), self.TYPES))
self.tr('Grid type'), self.types))
self.addParameter(ParameterExtent(self.EXTENT,
self.tr('Grid extent')))
self.addParameter(ParameterNumber(self.HSPACING,
Expand Down
8 changes: 7 additions & 1 deletion python/plugins/processing/algs/qgis/HubDistance.py
Expand Up @@ -62,6 +62,12 @@ def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Distance to nearest hub')
self.group, self.i18n_group = self.trAlgorithm('Vector analysis tools')

self.units = [self.tr('Meters'),
self.tr('Feet'),
self.tr('Miles'),
self.tr('Kilometers'),
self.tr('Layer units')]

self.addParameter(ParameterVector(self.POINTS,
self.tr('Source points layer'), [ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterVector(self.HUBS,
Expand All @@ -71,7 +77,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.GEOMETRY,
self.tr('Output shape type'), self.GEOMETRIES))
self.addParameter(ParameterSelection(self.UNIT,
self.tr('Measurement unit'), self.UNITS))
self.tr('Measurement unit'), self.units))

self.addOutput(OutputVector(self.OUTPUT, self.tr('Hub distance')))

Expand Down
12 changes: 6 additions & 6 deletions python/plugins/processing/algs/qgis/PointDistance.py
Expand Up @@ -46,14 +46,14 @@ class PointDistance(GeoAlgorithm):
NEAREST_POINTS = 'NEAREST_POINTS'
DISTANCE_MATRIX = 'DISTANCE_MATRIX'

MAT_TYPES = ['Linear (N*k x 3) distance matrix',
'Standard (N x T) distance matrix',
'Summary distance matrix (mean, std. dev., min, max)']

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Distance matrix')
self.group, self.i18n_group = self.trAlgorithm('Vector analysis tools')

self.mat_types = [self.tr('Linear (N*k x 3) distance matrix'),
self.tr('Standard (N x T) distance matrix'),
self.tr('Summary distance matrix (mean, std. dev., min, max)')]

self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input point layer'), [ParameterVector.VECTOR_TYPE_POINT]))
self.addParameter(ParameterTableField(self.INPUT_FIELD,
Expand All @@ -65,7 +65,7 @@ def defineCharacteristics(self):
self.tr('Target unique ID field'), self.TARGET_LAYER,
ParameterTableField.DATA_TYPE_ANY))
self.addParameter(ParameterSelection(self.MATRIX_TYPE,
self.tr('Output matrix type'), self.MAT_TYPES, 0))
self.tr('Output matrix type'), self.mat_types, 0))
self.addParameter(ParameterNumber(self.NEAREST_POINTS,
self.tr('Use only the nearest (k) target points'), 0, 9999, 0))

Expand Down Expand Up @@ -93,7 +93,7 @@ def processAlgorithm(self, progress):
self.linearMatrix(inLayer, inField, targetLayer, targetField,
matType, nPoints, progress)
elif matType == 1:
# Standard distance matrix
# Standard distance matrix
self.regularMatrix(inLayer, inField, targetLayer, targetField,
nPoints, progress)
elif matType == 2:
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/algs/qgis/RandomExtract.py
Expand Up @@ -43,17 +43,17 @@ class RandomExtract(GeoAlgorithm):
METHOD = 'METHOD'
NUMBER = 'NUMBER'

METHODS = ['Number of selected features',
'Percentage of selected features']

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Random extract')
self.group, self.i18n_group = self.trAlgorithm('Vector selection tools')

self.methods = [self.tr('Number of selected features'),
self.tr('Percentage of selected features')]

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterSelection(self.METHOD,
self.tr('Method'), self.METHODS, 0))
self.tr('Method'), self.methods, 0))
self.addParameter(ParameterNumber(self.NUMBER,
self.tr('Number/percentage of selected features'), 0, None, 10))

Expand Down
Expand Up @@ -45,19 +45,19 @@ class RandomExtractWithinSubsets(GeoAlgorithm):
FIELD = 'FIELD'
OUTPUT = 'OUTPUT'

METHODS = ['Number of selected features',
'Percentage of selected features']

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Random extract within subsets')
self.group, self.i18n_group = self.trAlgorithm('Vector selection tools')

self.methods = [self.tr('Number of selected features'),
self.tr('Percentage of selected features')]

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterTableField(self.FIELD,
self.tr('ID field'), self.INPUT))
self.addParameter(ParameterSelection(self.METHOD,
self.tr('Method'), self.METHODS, 0))
self.tr('Method'), self.methods, 0))
self.addParameter(ParameterNumber(self.NUMBER,
self.tr('Number/percentage of selected features'), 1, None, 10))

Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/algs/qgis/RandomPointsPolygonsFixed.py
Expand Up @@ -47,17 +47,17 @@ class RandomPointsPolygonsFixed(GeoAlgorithm):
STRATEGY = 'STRATEGY'
OUTPUT = 'OUTPUT'

STRATEGIES = ['Points count',
'Points density'
]

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Random points inside polygons (fixed)')
self.group, self.i18n_group = self.trAlgorithm('Vector creation tools')

self.strategies = [self.tr('Points count'),
self.tr('Points density')]

self.addParameter(ParameterVector(self.VECTOR,
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_POLYGON]))
self.addParameter(ParameterSelection(self.STRATEGY,
self.tr('Sampling strategy'), self.STRATEGIES, 0))
self.tr('Sampling strategy'), self.strategies, 0))
self.addParameter(ParameterNumber(self.VALUE,
self.tr('Number or density of points'), 0.0001, 9999999.0, 1.0))
self.addParameter(ParameterNumber(self.MIN_DISTANCE,
Expand Down

0 comments on commit 5f10b70

Please sign in to comment.