mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-30 00:04:58 -05:00
Merge pull request #3353 from nyalldawson/processing
[Processing] QGIS alg cleanups
This commit is contained in:
commit
45c8a09439
@ -78,11 +78,10 @@ class AddTableField(GeoAlgorithm):
|
|||||||
layer = dataobjects.getObjectFromUri(
|
layer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT_LAYER))
|
self.getParameterValue(self.INPUT_LAYER))
|
||||||
|
|
||||||
provider = layer.dataProvider()
|
fields = layer.fields()
|
||||||
fields = provider.fields()
|
|
||||||
fields.append(QgsField(fieldName, self.TYPES[fieldType], '',
|
fields.append(QgsField(fieldName, self.TYPES[fieldType], '',
|
||||||
fieldLength, fieldPrecision))
|
fieldLength, fieldPrecision))
|
||||||
writer = output.getVectorWriter(fields, provider.wkbType(),
|
writer = output.getVectorWriter(fields, layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
|
|||||||
@ -49,10 +49,9 @@ class AutoincrementalField(GeoAlgorithm):
|
|||||||
output = self.getOutputFromName(self.OUTPUT)
|
output = self.getOutputFromName(self.OUTPUT)
|
||||||
vlayer = \
|
vlayer = \
|
||||||
dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
||||||
vprovider = vlayer.dataProvider()
|
fields = vlayer.fields()
|
||||||
fields = vprovider.fields()
|
|
||||||
fields.append(QgsField('AUTO', QVariant.Int))
|
fields.append(QgsField('AUTO', QVariant.Int))
|
||||||
writer = output.getVectorWriter(fields, vprovider.wkbType(),
|
writer = output.getVectorWriter(fields, vlayer.wkbType(),
|
||||||
vlayer.crs())
|
vlayer.crs())
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
features = vector.features(vlayer)
|
features = vector.features(vlayer)
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class Centroids(GeoAlgorithm):
|
|||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT_LAYER).getVectorWriter(
|
self.OUTPUT_LAYER).getVectorWriter(
|
||||||
layer.pendingFields().toList(),
|
layer.fields(),
|
||||||
QgsWkbTypes.Point,
|
QgsWkbTypes.Point,
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
|
|||||||
@ -97,27 +97,26 @@ class CheckValidity(GeoAlgorithm):
|
|||||||
def doCheck(self, progress):
|
def doCheck(self, progress):
|
||||||
layer = dataobjects.getObjectFromUri(
|
layer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT_LAYER))
|
self.getParameterValue(self.INPUT_LAYER))
|
||||||
provider = layer.dataProvider()
|
|
||||||
|
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
method = int(settings.value(settings_method_key, 1))
|
method = int(settings.value(settings_method_key, 1))
|
||||||
|
|
||||||
valid_ouput = self.getOutputFromName(self.VALID_OUTPUT)
|
valid_ouput = self.getOutputFromName(self.VALID_OUTPUT)
|
||||||
valid_fields = layer.pendingFields().toList()
|
valid_fields = layer.fields()
|
||||||
valid_writer = valid_ouput.getVectorWriter(
|
valid_writer = valid_ouput.getVectorWriter(
|
||||||
valid_fields,
|
valid_fields,
|
||||||
provider.wkbType(),
|
layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
valid_count = 0
|
valid_count = 0
|
||||||
|
|
||||||
invalid_ouput = self.getOutputFromName(self.INVALID_OUTPUT)
|
invalid_ouput = self.getOutputFromName(self.INVALID_OUTPUT)
|
||||||
invalid_fields = layer.pendingFields().toList() + [
|
invalid_fields = layer.fields().toList() + [
|
||||||
QgsField(name='_errors',
|
QgsField(name='_errors',
|
||||||
type=QVariant.String,
|
type=QVariant.String,
|
||||||
len=255)]
|
len=255)]
|
||||||
invalid_writer = invalid_ouput.getVectorWriter(
|
invalid_writer = invalid_ouput.getVectorWriter(
|
||||||
invalid_fields,
|
invalid_fields,
|
||||||
provider.wkbType(),
|
layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
invalid_count = 0
|
invalid_count = 0
|
||||||
|
|
||||||
|
|||||||
@ -111,7 +111,7 @@ class ConcaveHull(GeoAlgorithm):
|
|||||||
feat = QgsFeature()
|
feat = QgsFeature()
|
||||||
dissolved_layer.getFeatures(QgsFeatureRequest().setFilterFid(0)).nextFeature(feat)
|
dissolved_layer.getFeatures(QgsFeatureRequest().setFilterFid(0)).nextFeature(feat)
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), QgsWkbTypes.Polygon, layer.crs())
|
layer.fields().toList(), QgsWkbTypes.Polygon, layer.crs())
|
||||||
geom = feat.geometry()
|
geom = feat.geometry()
|
||||||
if no_multigeom and geom.isMultipart():
|
if no_multigeom and geom.isMultipart():
|
||||||
# Only singlepart geometries are allowed
|
# Only singlepart geometries are allowed
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class ConvexHull(GeoAlgorithm):
|
|||||||
f = QgsField('value', QVariant.String, '', 255)
|
f = QgsField('value', QVariant.String, '', 255)
|
||||||
if useField:
|
if useField:
|
||||||
index = layer.fieldNameIndex(fieldName)
|
index = layer.fieldNameIndex(fieldName)
|
||||||
fType = layer.pendingFields()[index].type()
|
fType = layer.fields()[index].type()
|
||||||
if fType in [QVariant.Int, QVariant.UInt, QVariant.LongLong, QVariant.ULongLong]:
|
if fType in [QVariant.Int, QVariant.UInt, QVariant.LongLong, QVariant.ULongLong]:
|
||||||
f.setType(fType)
|
f.setType(fType)
|
||||||
f.setLength(20)
|
f.setLength(20)
|
||||||
@ -97,7 +97,7 @@ class ConvexHull(GeoAlgorithm):
|
|||||||
]
|
]
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields, QgsWkbTypes.Polygon, layer.dataProvider().crs())
|
fields, QgsWkbTypes.Polygon, layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
inGeom = QgsGeometry()
|
inGeom = QgsGeometry()
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class DeleteColumn(GeoAlgorithm):
|
|||||||
self.getParameterValue(self.INPUT))
|
self.getParameterValue(self.INPUT))
|
||||||
idx = layer.fieldNameIndex(self.getParameterValue(self.COLUMN))
|
idx = layer.fieldNameIndex(self.getParameterValue(self.COLUMN))
|
||||||
|
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
fields.remove(idx)
|
fields.remove(idx)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class DeleteDuplicateGeometries(GeoAlgorithm):
|
|||||||
layer = dataobjects.getObjectFromUri(
|
layer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT))
|
self.getParameterValue(self.INPUT))
|
||||||
|
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
||||||
layer.wkbType(), layer.crs())
|
layer.wkbType(), layer.crs())
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class DeleteHoles(GeoAlgorithm):
|
|||||||
self.getParameterValue(self.INPUT))
|
self.getParameterValue(self.INPUT))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields(),
|
layer.fields(),
|
||||||
layer.wkbType(),
|
layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class DensifyGeometries(GeoAlgorithm):
|
|||||||
isPolygon = layer.geometryType() == QgsWkbTypes.PolygonGeometry
|
isPolygon = layer.geometryType() == QgsWkbTypes.PolygonGeometry
|
||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT).getVectorWriter(layer.pendingFields().toList(),
|
self.OUTPUT).getVectorWriter(layer.fields().toList(),
|
||||||
layer.wkbType(), layer.crs())
|
layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class DensifyGeometriesInterval(GeoAlgorithm):
|
|||||||
isPolygon = layer.geometryType() == QgsWkbTypes.PolygonGeometry
|
isPolygon = layer.geometryType() == QgsWkbTypes.PolygonGeometry
|
||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT).getVectorWriter(layer.pendingFields().toList(),
|
self.OUTPUT).getVectorWriter(layer.fields().toList(),
|
||||||
layer.wkbType(), layer.crs())
|
layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
|
|||||||
@ -68,11 +68,11 @@ class Difference(GeoAlgorithm):
|
|||||||
self.getParameterValue(Difference.OVERLAY))
|
self.getParameterValue(Difference.OVERLAY))
|
||||||
ignoreInvalid = self.getParameterValue(Difference.IGNORE_INVALID)
|
ignoreInvalid = self.getParameterValue(Difference.IGNORE_INVALID)
|
||||||
|
|
||||||
geomType = layerA.dataProvider().wkbType()
|
geomType = layerA.wkbType()
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
Difference.OUTPUT).getVectorWriter(layerA.pendingFields(),
|
Difference.OUTPUT).getVectorWriter(layerA.fields(),
|
||||||
geomType,
|
geomType,
|
||||||
layerA.dataProvider().crs())
|
layerA.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
index = vector.spatialindex(layerB)
|
index = vector.spatialindex(layerB)
|
||||||
|
|||||||
@ -71,12 +71,11 @@ class Dissolve(GeoAlgorithm):
|
|||||||
field_names = self.getParameterValue(Dissolve.FIELD)
|
field_names = self.getParameterValue(Dissolve.FIELD)
|
||||||
vlayerA = dataobjects.getObjectFromUri(
|
vlayerA = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(Dissolve.INPUT))
|
self.getParameterValue(Dissolve.INPUT))
|
||||||
vproviderA = vlayerA.dataProvider()
|
|
||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
Dissolve.OUTPUT).getVectorWriter(
|
Dissolve.OUTPUT).getVectorWriter(
|
||||||
vlayerA.fields().toList(),
|
vlayerA.fields().toList(),
|
||||||
vproviderA.wkbType(),
|
vlayerA.wkbType(),
|
||||||
vlayerA.crs())
|
vlayerA.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|||||||
@ -315,10 +315,9 @@ class Eliminate(GeoAlgorithm):
|
|||||||
# End while
|
# End while
|
||||||
|
|
||||||
# Create output
|
# Create output
|
||||||
provider = processLayer.dataProvider()
|
|
||||||
output = self.getOutputFromName(self.OUTPUT)
|
output = self.getOutputFromName(self.OUTPUT)
|
||||||
writer = output.getVectorWriter(provider.fields(),
|
writer = output.getVectorWriter(processLayer.fields(),
|
||||||
provider.wkbType(), processLayer.crs())
|
processLayer.wkbType(), processLayer.crs())
|
||||||
|
|
||||||
# Write all features that are left over to output layer
|
# Write all features that are left over to output layer
|
||||||
iterator = processLayer.getFeatures()
|
iterator = processLayer.getFeatures()
|
||||||
|
|||||||
@ -54,11 +54,10 @@ class EquivalentNumField(GeoAlgorithm):
|
|||||||
output = self.getOutputFromName(self.OUTPUT)
|
output = self.getOutputFromName(self.OUTPUT)
|
||||||
vlayer = dataobjects.getObjectFromUri(
|
vlayer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT))
|
self.getParameterValue(self.INPUT))
|
||||||
vprovider = vlayer.dataProvider()
|
|
||||||
fieldindex = vlayer.fieldNameIndex(fieldname)
|
fieldindex = vlayer.fieldNameIndex(fieldname)
|
||||||
fields = vprovider.fields()
|
fields = vlayer.fields()
|
||||||
fields.append(QgsField('NUM_FIELD', QVariant.Int))
|
fields.append(QgsField('NUM_FIELD', QVariant.Int))
|
||||||
writer = output.getVectorWriter(fields, vprovider.wkbType(),
|
writer = output.getVectorWriter(fields, vlayer.wkbType(),
|
||||||
vlayer.crs())
|
vlayer.crs())
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
classes = {}
|
classes = {}
|
||||||
|
|||||||
@ -131,7 +131,7 @@ class ExecuteSQL(GeoAlgorithm):
|
|||||||
raise GeoAlgorithmExecutionException(vLayer.dataProvider().error().message())
|
raise GeoAlgorithmExecutionException(vLayer.dataProvider().error().message())
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(
|
||||||
vLayer.pendingFields().toList(),
|
vLayer.fields().toList(),
|
||||||
# Create a point layer (without any points) if 'no geometry' is chosen
|
# Create a point layer (without any points) if 'no geometry' is chosen
|
||||||
vLayer.wkbType() if geometry_type != 1 else 1,
|
vLayer.wkbType() if geometry_type != 1 else 1,
|
||||||
vLayer.crs())
|
vLayer.crs())
|
||||||
|
|||||||
@ -48,8 +48,7 @@ class Explode(GeoAlgorithm):
|
|||||||
vlayer = dataobjects.getObjectFromUri(
|
vlayer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT))
|
self.getParameterValue(self.INPUT))
|
||||||
output = self.getOutputFromName(self.OUTPUT)
|
output = self.getOutputFromName(self.OUTPUT)
|
||||||
vprovider = vlayer.dataProvider()
|
fields = vlayer.fields()
|
||||||
fields = vprovider.fields()
|
|
||||||
writer = output.getVectorWriter(fields, QgsWkbTypes.LineString,
|
writer = output.getVectorWriter(fields, QgsWkbTypes.LineString,
|
||||||
vlayer.crs())
|
vlayer.crs())
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class ExportGeometryInfo(GeoAlgorithm):
|
|||||||
method = self.getParameterValue(self.METHOD)
|
method = self.getParameterValue(self.METHOD)
|
||||||
|
|
||||||
geometryType = layer.geometryType()
|
geometryType = layer.geometryType()
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
|
|
||||||
if geometryType == QgsWkbTypes.PolygonGeometry:
|
if geometryType == QgsWkbTypes.PolygonGeometry:
|
||||||
areaName = vector.createUniqueFieldName('area', fields)
|
areaName = vector.createUniqueFieldName('area', fields)
|
||||||
@ -89,7 +89,7 @@ class ExportGeometryInfo(GeoAlgorithm):
|
|||||||
fields.append(QgsField(yName, QVariant.Double))
|
fields.append(QgsField(yName, QVariant.Double))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields.toList(), layer.dataProvider().wkbType(), layer.crs())
|
fields.toList(), layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
ellips = None
|
ellips = None
|
||||||
crs = None
|
crs = None
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class ExtractByAttribute(GeoAlgorithm):
|
|||||||
operator = self.OPERATORS[self.getParameterValue(self.OPERATOR)]
|
operator = self.OPERATORS[self.getParameterValue(self.OPERATOR)]
|
||||||
value = self.getParameterValue(self.VALUE)
|
value = self.getParameterValue(self.VALUE)
|
||||||
|
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
||||||
layer.wkbType(), layer.crs())
|
layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
|
|||||||
@ -70,8 +70,8 @@ class ExtractByLocation(GeoAlgorithm):
|
|||||||
index = vector.spatialindex(layer)
|
index = vector.spatialindex(layer)
|
||||||
|
|
||||||
output = self.getOutputFromName(self.OUTPUT)
|
output = self.getOutputFromName(self.OUTPUT)
|
||||||
writer = output.getVectorWriter(layer.pendingFields(),
|
writer = output.getVectorWriter(layer.fields(),
|
||||||
layer.dataProvider().wkbType(), layer.crs())
|
layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
if 'disjoint' in predicates:
|
if 'disjoint' in predicates:
|
||||||
disjoinSet = []
|
disjoinSet = []
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class ExtractNodes(GeoAlgorithm):
|
|||||||
self.getParameterValue(self.INPUT))
|
self.getParameterValue(self.INPUT))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), QgsWkbTypes.Point, layer.crs())
|
layer.fields().toList(), QgsWkbTypes.Point, layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
inGeom = QgsGeometry()
|
inGeom = QgsGeometry()
|
||||||
|
|||||||
@ -88,11 +88,10 @@ class FieldsPyculator(GeoAlgorithm):
|
|||||||
|
|
||||||
layer = dataobjects.getObjectFromUri(
|
layer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT_LAYER))
|
self.getParameterValue(self.INPUT_LAYER))
|
||||||
provider = layer.dataProvider()
|
fields = layer.fields()
|
||||||
fields = provider.fields()
|
|
||||||
fields.append(QgsField(fieldName, self.TYPES[fieldType], '',
|
fields.append(QgsField(fieldName, self.TYPES[fieldType], '',
|
||||||
fieldLength, fieldPrecision))
|
fieldLength, fieldPrecision))
|
||||||
writer = output.getVectorWriter(fields, provider.wkbType(),
|
writer = output.getVectorWriter(fields, layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
new_ns = {}
|
new_ns = {}
|
||||||
@ -107,7 +106,7 @@ class FieldsPyculator(GeoAlgorithm):
|
|||||||
self.tr("FieldPyculator code execute error.Global code block can't be executed!\n%s\n%s") % (unicode(sys.exc_info()[0].__name__), unicode(sys.exc_info()[1])))
|
self.tr("FieldPyculator code execute error.Global code block can't be executed!\n%s\n%s") % (unicode(sys.exc_info()[0].__name__), unicode(sys.exc_info()[1])))
|
||||||
|
|
||||||
# Replace all fields tags
|
# Replace all fields tags
|
||||||
fields = provider.fields()
|
fields = layer.fields()
|
||||||
num = 0
|
num = 0
|
||||||
for field in fields:
|
for field in fields:
|
||||||
field_name = unicode(field.name())
|
field_name = unicode(field.name())
|
||||||
|
|||||||
@ -94,12 +94,11 @@ class FieldsCalculator(GeoAlgorithm):
|
|||||||
output.value = system.getTempFilenameInTempFolder(
|
output.value = system.getTempFilenameInTempFolder(
|
||||||
output.name + '.' + ext)
|
output.name + '.' + ext)
|
||||||
|
|
||||||
provider = layer.dataProvider()
|
fields = layer.fields()
|
||||||
fields = layer.pendingFields()
|
|
||||||
if newField:
|
if newField:
|
||||||
fields.append(QgsField(fieldName, fieldType, '', width, precision))
|
fields.append(QgsField(fieldName, fieldType, '', width, precision))
|
||||||
|
|
||||||
writer = output.getVectorWriter(fields, provider.wkbType(),
|
writer = output.getVectorWriter(fields, layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
exp = QgsExpression(formula)
|
exp = QgsExpression(formula)
|
||||||
|
|||||||
@ -68,7 +68,6 @@ class FieldsMapper(GeoAlgorithm):
|
|||||||
output = self.getOutputFromName(self.OUTPUT_LAYER)
|
output = self.getOutputFromName(self.OUTPUT_LAYER)
|
||||||
|
|
||||||
layer = dataobjects.getObjectFromUri(layer)
|
layer = dataobjects.getObjectFromUri(layer)
|
||||||
provider = layer.dataProvider()
|
|
||||||
fields = []
|
fields = []
|
||||||
expressions = []
|
expressions = []
|
||||||
|
|
||||||
@ -109,7 +108,7 @@ class FieldsMapper(GeoAlgorithm):
|
|||||||
expressions.append(expression)
|
expressions.append(expression)
|
||||||
|
|
||||||
writer = output.getVectorWriter(fields,
|
writer = output.getVectorWriter(fields,
|
||||||
provider.wkbType(),
|
layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
# Create output vector layer with new attributes
|
# Create output vector layer with new attributes
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class FixedDistanceBuffer(GeoAlgorithm):
|
|||||||
segments = int(self.getParameterValue(self.SEGMENTS))
|
segments = int(self.getParameterValue(self.SEGMENTS))
|
||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT).getVectorWriter(layer.pendingFields().toList(),
|
self.OUTPUT).getVectorWriter(layer.fields().toList(),
|
||||||
QgsWkbTypes.Polygon, layer.crs())
|
QgsWkbTypes.Polygon, layer.crs())
|
||||||
|
|
||||||
buff.buffering(progress, writer, distance, None, False, layer,
|
buff.buffering(progress, writer, distance, None, False, layer,
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class GeometryConvert(GeoAlgorithm):
|
|||||||
newType = QgsWkbTypes.Point
|
newType = QgsWkbTypes.Point
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields(), newType, layer.crs())
|
layer.fields(), newType, layer.crs())
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
total = 100.0 / len(features)
|
total = 100.0 / len(features)
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class Gridify(GeoAlgorithm):
|
|||||||
self.tr('Invalid grid spacing: %s/%s' % (hSpacing, vSpacing)))
|
self.tr('Invalid grid spacing: %s/%s' % (hSpacing, vSpacing)))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields(), layer.wkbType(), layer.crs())
|
layer.fields(), layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
total = 100.0 / len(features)
|
total = 100.0 / len(features)
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class HubDistance(GeoAlgorithm):
|
|||||||
if addLines:
|
if addLines:
|
||||||
geomType = QgsWkbTypes.LineString
|
geomType = QgsWkbTypes.LineString
|
||||||
|
|
||||||
fields = layerPoints.pendingFields()
|
fields = layerPoints.fields()
|
||||||
fields.append(QgsField('HubName', QVariant.String))
|
fields.append(QgsField('HubName', QVariant.String))
|
||||||
fields.append(QgsField('HubDist', QVariant.Double))
|
fields.append(QgsField('HubDist', QVariant.Double))
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class HubLines(GeoAlgorithm):
|
|||||||
self.tr('Same layer given for both hubs and spokes'))
|
self.tr('Same layer given for both hubs and spokes'))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layerSpoke.pendingFields(), QgsWkbTypes.LineString, layerSpoke.crs())
|
layerSpoke.fields(), QgsWkbTypes.LineString, layerSpoke.crs())
|
||||||
|
|
||||||
spokes = vector.features(layerSpoke)
|
spokes = vector.features(layerSpoke)
|
||||||
hubs = vector.features(layerHub)
|
hubs = vector.features(layerHub)
|
||||||
|
|||||||
@ -73,12 +73,11 @@ class Intersection(GeoAlgorithm):
|
|||||||
self.getParameterValue(self.INPUT))
|
self.getParameterValue(self.INPUT))
|
||||||
vlayerB = dataobjects.getObjectFromUri(
|
vlayerB = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT2))
|
self.getParameterValue(self.INPUT2))
|
||||||
vproviderA = vlayerA.dataProvider()
|
|
||||||
|
|
||||||
geomType = vproviderA.wkbType()
|
geomType = vlayerA.wkbType()
|
||||||
fields = vector.combineVectorFields(vlayerA, vlayerB)
|
fields = vector.combineVectorFields(vlayerA, vlayerB)
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
||||||
geomType, vproviderA.crs())
|
geomType, vlayerA.crs())
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
index = vector.spatialindex(vlayerB)
|
index = vector.spatialindex(vlayerB)
|
||||||
selectionA = vector.features(vlayerA)
|
selectionA = vector.features(vlayerA)
|
||||||
|
|||||||
@ -69,14 +69,13 @@ class JoinAttributes(GeoAlgorithm):
|
|||||||
field2 = self.getParameterValue(self.TABLE_FIELD_2)
|
field2 = self.getParameterValue(self.TABLE_FIELD_2)
|
||||||
|
|
||||||
layer = dataobjects.getObjectFromUri(input)
|
layer = dataobjects.getObjectFromUri(input)
|
||||||
provider = layer.dataProvider()
|
|
||||||
joinField1Index = layer.fieldNameIndex(field)
|
joinField1Index = layer.fieldNameIndex(field)
|
||||||
|
|
||||||
layer2 = dataobjects.getObjectFromUri(input2)
|
layer2 = dataobjects.getObjectFromUri(input2)
|
||||||
joinField2Index = layer2.fieldNameIndex(field2)
|
joinField2Index = layer2.fieldNameIndex(field2)
|
||||||
|
|
||||||
outFields = vector.combineVectorFields(layer, layer2)
|
outFields = vector.combineVectorFields(layer, layer2)
|
||||||
writer = output.getVectorWriter(outFields, provider.wkbType(),
|
writer = output.getVectorWriter(outFields, layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
# Cache attributes of Layer 2
|
# Cache attributes of Layer 2
|
||||||
|
|||||||
@ -82,11 +82,11 @@ class LinesIntersection(GeoAlgorithm):
|
|||||||
idxA = layerA.fieldNameIndex(fieldA)
|
idxA = layerA.fieldNameIndex(fieldA)
|
||||||
idxB = layerB.fieldNameIndex(fieldB)
|
idxB = layerB.fieldNameIndex(fieldB)
|
||||||
|
|
||||||
fieldList = [layerA.pendingFields()[idxA],
|
fieldList = [layerA.fields()[idxA],
|
||||||
layerB.pendingFields()[idxB]]
|
layerB.fields()[idxB]]
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fieldList,
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fieldList,
|
||||||
QgsWkbTypes.Point, layerA.dataProvider().crs())
|
QgsWkbTypes.Point, layerA.crs())
|
||||||
|
|
||||||
spatialIndex = vector.spatialindex(layerB)
|
spatialIndex = vector.spatialindex(layerB)
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class LinesToPolygons(GeoAlgorithm):
|
|||||||
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), QgsWkbTypes.Polygon, layer.crs()
|
layer.fields().toList(), QgsWkbTypes.Polygon, layer.crs()
|
||||||
)
|
)
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|||||||
@ -66,14 +66,14 @@ class Merge(GeoAlgorithm):
|
|||||||
layer = QgsVectorLayer(paths[x], unicode(x), 'ogr')
|
layer = QgsVectorLayer(paths[x], unicode(x), 'ogr')
|
||||||
|
|
||||||
if (len(layers) > 0):
|
if (len(layers) > 0):
|
||||||
if (layer.dataProvider().wkbType() != layers[0].dataProvider().wkbType()):
|
if (layer.wkbType() != layers[0].wkbType()):
|
||||||
raise GeoAlgorithmExecutionException(
|
raise GeoAlgorithmExecutionException(
|
||||||
self.tr('All layers must have same geometry type!'))
|
self.tr('All layers must have same geometry type!'))
|
||||||
|
|
||||||
layers.append(layer)
|
layers.append(layer)
|
||||||
totalFeatureCount += layer.featureCount()
|
totalFeatureCount += layer.featureCount()
|
||||||
|
|
||||||
for sindex, sfield in enumerate(layer.dataProvider().fields()):
|
for sindex, sfield in enumerate(layer.fields()):
|
||||||
found = None
|
found = None
|
||||||
for dfield in fields:
|
for dfield in fields:
|
||||||
if (dfield.name().upper() == sfield.name().upper()):
|
if (dfield.name().upper() == sfield.name().upper()):
|
||||||
@ -88,12 +88,12 @@ class Merge(GeoAlgorithm):
|
|||||||
|
|
||||||
total = 100.0 / totalFeatureCount
|
total = 100.0 / totalFeatureCount
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields.toList(), layers[0].dataProvider().wkbType(),
|
fields.toList(), layers[0].wkbType(),
|
||||||
layers[0].crs())
|
layers[0].crs())
|
||||||
|
|
||||||
featureCount = 0
|
featureCount = 0
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
for feature in layer.dataProvider().getFeatures():
|
for feature in layer.getFeatures():
|
||||||
sattributes = feature.attributes()
|
sattributes = feature.attributes()
|
||||||
dattributes = []
|
dattributes = []
|
||||||
for dindex, dfield in enumerate(fields):
|
for dindex, dfield in enumerate(fields):
|
||||||
@ -104,7 +104,7 @@ class Merge(GeoAlgorithm):
|
|||||||
else:
|
else:
|
||||||
dattribute = ''
|
dattribute = ''
|
||||||
|
|
||||||
for sindex, sfield in enumerate(layer.dataProvider().fields()):
|
for sindex, sfield in enumerate(layer.fields()):
|
||||||
if (sfield.name().upper() == dfield.name().upper()):
|
if (sfield.name().upper() == dfield.name().upper()):
|
||||||
if (sfield.type() != dfield.type()):
|
if (sfield.type() != dfield.type()):
|
||||||
raise GeoAlgorithmExecutionException(
|
raise GeoAlgorithmExecutionException(
|
||||||
|
|||||||
@ -59,12 +59,11 @@ class MergeLines(GeoAlgorithm):
|
|||||||
def processAlgorithm(self, progress):
|
def processAlgorithm(self, progress):
|
||||||
layer = dataobjects.getObjectFromUri(
|
layer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT_LAYER))
|
self.getParameterValue(self.INPUT_LAYER))
|
||||||
provider = layer.dataProvider()
|
|
||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT_LAYER).getVectorWriter(
|
self.OUTPUT_LAYER).getVectorWriter(
|
||||||
layer.fields().toList(),
|
layer.fields().toList(),
|
||||||
provider.wkbType(),
|
layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
|
|||||||
@ -58,10 +58,10 @@ class MultipartToSingleparts(GeoAlgorithm):
|
|||||||
def processAlgorithm(self, progress):
|
def processAlgorithm(self, progress):
|
||||||
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
||||||
|
|
||||||
geomType = self.multiToSingleGeom(layer.dataProvider().wkbType())
|
geomType = self.multiToSingleGeom(layer.wkbType())
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), geomType, layer.crs())
|
layer.fields().toList(), geomType, layer.crs())
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
total = 100.0 / len(features)
|
total = 100.0 / len(features)
|
||||||
@ -87,41 +87,41 @@ class MultipartToSingleparts(GeoAlgorithm):
|
|||||||
|
|
||||||
def multiToSingleGeom(self, wkbType):
|
def multiToSingleGeom(self, wkbType):
|
||||||
try:
|
try:
|
||||||
if wkbType in (QgsWkbTypes.Point, QgsWkbTypes.MultiPoint,
|
if wkbType in (Qgis.WKBPoint, Qgis.WKBMultiPoint,
|
||||||
QgsWkbTypes.Point25D, QgsWkbTypes.MultiPoint25D):
|
Qgis.WKBPoint25D, Qgis.WKBMultiPoint25D):
|
||||||
return QgsWkbTypes.Point
|
return Qgis.WKBPoint
|
||||||
elif wkbType in (QgsWkbTypes.LineString, QgsWkbTypes.MultiLineString,
|
elif wkbType in (Qgis.WKBLineString, Qgis.WKBMultiLineString,
|
||||||
QgsWkbTypes.MultiLineString25D,
|
Qgis.WKBMultiLineString25D,
|
||||||
QgsWkbTypes.LineString25D):
|
Qgis.WKBLineString25D):
|
||||||
|
|
||||||
return QgsWkbTypes.LineString
|
return Qgis.WKBLineString
|
||||||
elif wkbType in (QgsWkbTypes.Polygon, QgsWkbTypes.MultiPolygon,
|
elif wkbType in (Qgis.WKBPolygon, Qgis.WKBMultiPolygon,
|
||||||
QgsWkbTypes.MultiPolygon25D, QgsWkbTypes.Polygon25D):
|
Qgis.WKBMultiPolygon25D, Qgis.WKBPolygon25D):
|
||||||
|
|
||||||
return QgsWkbTypes.Polygon
|
return Qgis.WKBPolygon
|
||||||
else:
|
else:
|
||||||
return QgsWkbTypes.Unknown
|
return Qgis.WKBUnknown
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise GeoAlgorithmExecutionException(unicode(err))
|
raise GeoAlgorithmExecutionException(unicode(err))
|
||||||
|
|
||||||
def extractAsSingle(self, geom):
|
def extractAsSingle(self, geom):
|
||||||
multiGeom = QgsGeometry()
|
multiGeom = QgsGeometry()
|
||||||
geometries = []
|
geometries = []
|
||||||
if geom.type() == QgsWkbTypes.PointGeometry:
|
if geom.type() == Qgis.Point:
|
||||||
if geom.isMultipart():
|
if geom.isMultipart():
|
||||||
multiGeom = geom.asMultiPoint()
|
multiGeom = geom.asMultiPoint()
|
||||||
for i in multiGeom:
|
for i in multiGeom:
|
||||||
geometries.append(QgsGeometry().fromPoint(i))
|
geometries.append(QgsGeometry().fromPoint(i))
|
||||||
else:
|
else:
|
||||||
geometries.append(geom)
|
geometries.append(geom)
|
||||||
elif geom.type() == QgsWkbTypes.LineGeometry:
|
elif geom.type() == Qgis.Line:
|
||||||
if geom.isMultipart():
|
if geom.isMultipart():
|
||||||
multiGeom = geom.asMultiPolyline()
|
multiGeom = geom.asMultiPolyline()
|
||||||
for i in multiGeom:
|
for i in multiGeom:
|
||||||
geometries.append(QgsGeometry().fromPolyline(i))
|
geometries.append(QgsGeometry().fromPolyline(i))
|
||||||
else:
|
else:
|
||||||
geometries.append(geom)
|
geometries.append(geom)
|
||||||
elif geom.type() == QgsWkbTypes.PolygonGeometry:
|
elif geom.type() == Qgis.Polygon:
|
||||||
if geom.isMultipart():
|
if geom.isMultipart():
|
||||||
multiGeom = geom.asMultiPolygon()
|
multiGeom = geom.asMultiPolygon()
|
||||||
for i in multiGeom:
|
for i in multiGeom:
|
||||||
|
|||||||
@ -82,11 +82,10 @@ class OrientedMinimumBoundingBox(GeoAlgorithm):
|
|||||||
|
|
||||||
def layerOmmb(self, layer, writer, progress):
|
def layerOmmb(self, layer, writer, progress):
|
||||||
current = 0
|
current = 0
|
||||||
vprovider = layer.dataProvider()
|
|
||||||
|
|
||||||
fit = vprovider.getFeatures()
|
fit = layer.getFeatures()
|
||||||
inFeat = QgsFeature()
|
inFeat = QgsFeature()
|
||||||
total = 100.0 / vprovider.featureCount()
|
total = 100.0 / layer.featureCount()
|
||||||
newgeometry = QgsGeometry()
|
newgeometry = QgsGeometry()
|
||||||
first = True
|
first = True
|
||||||
while fit.nextFeature(inFeat):
|
while fit.nextFeature(inFeat):
|
||||||
|
|||||||
@ -62,9 +62,8 @@ class PointsDisplacement(GeoAlgorithm):
|
|||||||
|
|
||||||
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
|
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
|
||||||
|
|
||||||
provider = layer.dataProvider()
|
writer = output.getVectorWriter(layer.fields(),
|
||||||
writer = output.getVectorWriter(provider.fields(),
|
layer.wkbType(), layer.crs())
|
||||||
provider.wkbType(), provider.crs())
|
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
|
|
||||||
|
|||||||
@ -68,15 +68,14 @@ class PointsInPolygon(GeoAlgorithm):
|
|||||||
pointLayer = dataobjects.getObjectFromUri(self.getParameterValue(self.POINTS))
|
pointLayer = dataobjects.getObjectFromUri(self.getParameterValue(self.POINTS))
|
||||||
fieldName = self.getParameterValue(self.FIELD)
|
fieldName = self.getParameterValue(self.FIELD)
|
||||||
|
|
||||||
polyProvider = polyLayer.dataProvider()
|
fields = polyLayer.fields()
|
||||||
fields = polyProvider.fields()
|
|
||||||
fields.append(QgsField(fieldName, QVariant.Int))
|
fields.append(QgsField(fieldName, QVariant.Int))
|
||||||
|
|
||||||
(idxCount, fieldList) = vector.findOrCreateField(polyLayer,
|
(idxCount, fieldList) = vector.findOrCreateField(polyLayer,
|
||||||
polyLayer.pendingFields(), fieldName)
|
polyLayer.fields(), fieldName)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields.toList(), polyProvider.geometryType(), polyProvider.crs())
|
fields.toList(), polyLayer.wkbType(), polyLayer.crs())
|
||||||
|
|
||||||
spatialIndex = vector.spatialindex(pointLayer)
|
spatialIndex = vector.spatialindex(pointLayer)
|
||||||
|
|
||||||
|
|||||||
@ -62,16 +62,15 @@ class PointsInPolygonUnique(GeoAlgorithm):
|
|||||||
fieldName = self.getParameterValue(self.FIELD)
|
fieldName = self.getParameterValue(self.FIELD)
|
||||||
classFieldName = self.getParameterValue(self.CLASSFIELD)
|
classFieldName = self.getParameterValue(self.CLASSFIELD)
|
||||||
|
|
||||||
polyProvider = polyLayer.dataProvider()
|
fields = polyLayer.fields()
|
||||||
fields = polyProvider.fields()
|
|
||||||
fields.append(QgsField(fieldName, QVariant.Int))
|
fields.append(QgsField(fieldName, QVariant.Int))
|
||||||
|
|
||||||
classFieldIndex = pointLayer.fieldNameIndex(classFieldName)
|
classFieldIndex = pointLayer.fieldNameIndex(classFieldName)
|
||||||
(idxCount, fieldList) = vector.findOrCreateField(polyLayer,
|
(idxCount, fieldList) = vector.findOrCreateField(polyLayer,
|
||||||
polyLayer.pendingFields(), fieldName)
|
polyLayer.fields(), fieldName)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields.toList(), polyProvider.geometryType(), polyProvider.crs())
|
fields.toList(), polyLayer.wkbType(), polyLayer.crs())
|
||||||
|
|
||||||
spatialIndex = vector.spatialindex(pointLayer)
|
spatialIndex = vector.spatialindex(pointLayer)
|
||||||
|
|
||||||
|
|||||||
@ -69,15 +69,14 @@ class PointsInPolygonWeighted(GeoAlgorithm):
|
|||||||
fieldName = self.getParameterValue(self.FIELD)
|
fieldName = self.getParameterValue(self.FIELD)
|
||||||
fieldIdx = pointLayer.fieldNameIndex(self.getParameterValue(self.WEIGHT))
|
fieldIdx = pointLayer.fieldNameIndex(self.getParameterValue(self.WEIGHT))
|
||||||
|
|
||||||
polyProvider = polyLayer.dataProvider()
|
fields = polyLayer.fields()
|
||||||
fields = polyProvider.fields()
|
|
||||||
fields.append(QgsField(fieldName, QVariant.Int))
|
fields.append(QgsField(fieldName, QVariant.Int))
|
||||||
|
|
||||||
(idxCount, fieldList) = vector.findOrCreateField(polyLayer,
|
(idxCount, fieldList) = vector.findOrCreateField(polyLayer,
|
||||||
polyLayer.pendingFields(), fieldName)
|
polyLayer.fields(), fieldName)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields.toList(), polyProvider.geometryType(), polyProvider.crs())
|
fields.toList(), polyLayer.wkbType(), polyLayer.crs())
|
||||||
|
|
||||||
spatialIndex = vector.spatialindex(pointLayer)
|
spatialIndex = vector.spatialindex(pointLayer)
|
||||||
|
|
||||||
|
|||||||
@ -63,8 +63,7 @@ class PointsLayerFromTable(GeoAlgorithm):
|
|||||||
source = self.getParameterValue(self.INPUT)
|
source = self.getParameterValue(self.INPUT)
|
||||||
vlayer = dataobjects.getObjectFromUri(source)
|
vlayer = dataobjects.getObjectFromUri(source)
|
||||||
output = self.getOutputFromName(self.OUTPUT)
|
output = self.getOutputFromName(self.OUTPUT)
|
||||||
vprovider = vlayer.dataProvider()
|
fields = vlayer.fields()
|
||||||
fields = vprovider.fields()
|
|
||||||
writer = output.getVectorWriter(fields, QgsWkbTypes.Point, self.crs)
|
writer = output.getVectorWriter(fields, QgsWkbTypes.Point, self.crs)
|
||||||
xfieldindex = vlayer.fieldNameIndex(self.getParameterValue(self.XFIELD))
|
xfieldindex = vlayer.fieldNameIndex(self.getParameterValue(self.XFIELD))
|
||||||
yfieldindex = vlayer.fieldNameIndex(self.getParameterValue(self.YFIELD))
|
yfieldindex = vlayer.fieldNameIndex(self.getParameterValue(self.YFIELD))
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class PointsToPaths(GeoAlgorithm):
|
|||||||
fields.append(QgsField('begin', QVariant.String, '', 254, 0))
|
fields.append(QgsField('begin', QVariant.String, '', 254, 0))
|
||||||
fields.append(QgsField('end', QVariant.String, '', 254, 0))
|
fields.append(QgsField('end', QVariant.String, '', 254, 0))
|
||||||
writer = self.getOutputFromName(self.OUTPUT_LINES).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT_LINES).getVectorWriter(
|
||||||
fields, QgsWkbTypes.LineString, layer.dataProvider().crs())
|
fields, QgsWkbTypes.LineString, layer.crs())
|
||||||
|
|
||||||
points = dict()
|
points = dict()
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
|
|||||||
@ -60,9 +60,8 @@ class Polygonize(GeoAlgorithm):
|
|||||||
def processAlgorithm(self, progress):
|
def processAlgorithm(self, progress):
|
||||||
vlayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
vlayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
||||||
output = self.getOutputFromName(self.OUTPUT)
|
output = self.getOutputFromName(self.OUTPUT)
|
||||||
vprovider = vlayer.dataProvider()
|
|
||||||
if self.getParameterValue(self.FIELDS):
|
if self.getParameterValue(self.FIELDS):
|
||||||
fields = vprovider.fields()
|
fields = vlayer.fields()
|
||||||
else:
|
else:
|
||||||
fields = QgsFields()
|
fields = QgsFields()
|
||||||
if self.getParameterValue(self.GEOMETRY):
|
if self.getParameterValue(self.GEOMETRY):
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class PolygonsToLines(GeoAlgorithm):
|
|||||||
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), QgsWkbTypes.LineString, layer.crs())
|
layer.fields().toList(), QgsWkbTypes.LineString, layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
inGeom = QgsGeometry()
|
inGeom = QgsGeometry()
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class RandomExtract(GeoAlgorithm):
|
|||||||
selran = random.sample(xrange(featureCount), value)
|
selran = random.sample(xrange(featureCount), value)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), layer.wkbType(), layer.crs())
|
layer.fields().toList(), layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
total = 100.0 / featureCount
|
total = 100.0 / featureCount
|
||||||
for i, feat in enumerate(features):
|
for i, feat in enumerate(features):
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class RandomExtractWithinSubsets(GeoAlgorithm):
|
|||||||
value = value / 100.0
|
value = value / 100.0
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), layer.wkbType(), layer.crs())
|
layer.fields().toList(), layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
selran = []
|
selran = []
|
||||||
current = 0
|
current = 0
|
||||||
|
|||||||
@ -68,7 +68,7 @@ class RandomPointsAlongLines(GeoAlgorithm):
|
|||||||
fields = QgsFields()
|
fields = QgsFields()
|
||||||
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields, QgsWkbTypes.Point, layer.dataProvider().crs())
|
fields, QgsWkbTypes.Point, layer.crs())
|
||||||
|
|
||||||
nPoints = 0
|
nPoints = 0
|
||||||
nIterations = 0
|
nIterations = 0
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class RandomPointsLayer(GeoAlgorithm):
|
|||||||
fields = QgsFields()
|
fields = QgsFields()
|
||||||
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields, QgsWkbTypes.Point, layer.dataProvider().crs())
|
fields, QgsWkbTypes.Point, layer.crs())
|
||||||
|
|
||||||
nPoints = 0
|
nPoints = 0
|
||||||
nIterations = 0
|
nIterations = 0
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class RandomPointsPolygonsFixed(GeoAlgorithm):
|
|||||||
fields = QgsFields()
|
fields = QgsFields()
|
||||||
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields, QgsWkbTypes.Point, layer.dataProvider().crs())
|
fields, QgsWkbTypes.Point, layer.crs())
|
||||||
|
|
||||||
da = QgsDistanceArea()
|
da = QgsDistanceArea()
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ class RandomPointsPolygonsVariable(GeoAlgorithm):
|
|||||||
fields = QgsFields()
|
fields = QgsFields()
|
||||||
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
fields.append(QgsField('id', QVariant.Int, '', 10, 0))
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields, QgsWkbTypes.Point, layer.dataProvider().crs())
|
fields, QgsWkbTypes.Point, layer.crs())
|
||||||
|
|
||||||
da = QgsDistanceArea()
|
da = QgsDistanceArea()
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import math
|
|||||||
|
|
||||||
from qgis.PyQt.QtGui import QIcon
|
from qgis.PyQt.QtGui import QIcon
|
||||||
|
|
||||||
from qgis.core import Qgis, QgsFeature, QgsGeometry, QgsPoint, QgsWkbTypes, QgsWkbTypes
|
from qgis.core import Qgis, QgsFeature, QgsGeometry, QgsPoint, QgsWkbTypes
|
||||||
|
|
||||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||||
from processing.core.ProcessingLog import ProcessingLog
|
from processing.core.ProcessingLog import ProcessingLog
|
||||||
@ -89,7 +89,7 @@ class RectanglesOvalsDiamondsFixed(GeoAlgorithm):
|
|||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT_LAYER).getVectorWriter(
|
self.OUTPUT_LAYER).getVectorWriter(
|
||||||
layer.pendingFields().toList(),
|
layer.fields().toList(),
|
||||||
QgsWkbTypes.Polygon,
|
QgsWkbTypes.Polygon,
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import math
|
|||||||
|
|
||||||
from qgis.PyQt.QtGui import QIcon
|
from qgis.PyQt.QtGui import QIcon
|
||||||
|
|
||||||
from qgis.core import Qgis, QgsFeature, QgsGeometry, QgsPoint, QgsWkbTypes
|
from qgis.core import Qgis, QgsFeature, QgsGeometry, QgsPoint
|
||||||
|
|
||||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||||
from processing.core.ProcessingLog import ProcessingLog
|
from processing.core.ProcessingLog import ProcessingLog
|
||||||
@ -97,8 +97,8 @@ class RectanglesOvalsDiamondsVariable(GeoAlgorithm):
|
|||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT_LAYER).getVectorWriter(
|
self.OUTPUT_LAYER).getVectorWriter(
|
||||||
layer.pendingFields().toList(),
|
layer.fields().toList(),
|
||||||
QgsWkbTypes.Polygon,
|
Qgis.WKBPolygon,
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|||||||
@ -57,7 +57,7 @@ class ReprojectLayer(GeoAlgorithm):
|
|||||||
targetCrs.createFromUserInput(crsId)
|
targetCrs.createFromUserInput(crsId)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), layer.wkbType(), targetCrs)
|
layer.fields().toList(), layer.wkbType(), targetCrs)
|
||||||
|
|
||||||
layerCrs = layer.crs()
|
layerCrs = layer.crs()
|
||||||
crsTransform = QgsCoordinateTransform(layerCrs, targetCrs)
|
crsTransform = QgsCoordinateTransform(layerCrs, targetCrs)
|
||||||
|
|||||||
@ -49,12 +49,11 @@ class ReverseLineDirection(GeoAlgorithm):
|
|||||||
def processAlgorithm(self, progress):
|
def processAlgorithm(self, progress):
|
||||||
layer = dataobjects.getObjectFromUri(
|
layer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT_LAYER))
|
self.getParameterValue(self.INPUT_LAYER))
|
||||||
provider = layer.dataProvider()
|
|
||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT_LAYER).getVectorWriter(
|
self.OUTPUT_LAYER).getVectorWriter(
|
||||||
layer.fields().toList(),
|
layer.fields().toList(),
|
||||||
provider.wkbType(),
|
layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|||||||
@ -52,9 +52,8 @@ class SaveSelectedFeatures(GeoAlgorithm):
|
|||||||
|
|
||||||
vectorLayer = dataobjects.getObjectFromUri(inputFilename)
|
vectorLayer = dataobjects.getObjectFromUri(inputFilename)
|
||||||
|
|
||||||
provider = vectorLayer.dataProvider()
|
writer = output.getVectorWriter(vectorLayer.fields(),
|
||||||
writer = output.getVectorWriter(provider.fields(),
|
vectorLayer.wkbType(), vectorLayer.crs())
|
||||||
provider.wkbType(), vectorLayer.crs())
|
|
||||||
|
|
||||||
features = vector.features(vectorLayer)
|
features = vector.features(vectorLayer)
|
||||||
total = 100.0 / len(features)
|
total = 100.0 / len(features)
|
||||||
|
|||||||
@ -84,7 +84,7 @@ class SelectByAttribute(GeoAlgorithm):
|
|||||||
operator = self.OPERATORS[self.getParameterValue(self.OPERATOR)]
|
operator = self.OPERATORS[self.getParameterValue(self.OPERATOR)]
|
||||||
value = self.getParameterValue(self.VALUE)
|
value = self.getParameterValue(self.VALUE)
|
||||||
|
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
|
|
||||||
idx = layer.fieldNameIndex(fieldName)
|
idx = layer.fieldNameIndex(fieldName)
|
||||||
fieldType = fields[idx].type()
|
fieldType = fields[idx].type()
|
||||||
|
|||||||
@ -70,7 +70,7 @@ class SimplifyGeometries(GeoAlgorithm):
|
|||||||
pointsAfter = 0
|
pointsAfter = 0
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), layer.wkbType(), layer.crs())
|
layer.fields().toList(), layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
features = vector.features(layer)
|
features = vector.features(layer)
|
||||||
total = 100.0 / len(features)
|
total = 100.0 / len(features)
|
||||||
|
|||||||
@ -64,10 +64,10 @@ class SinglePartsToMultiparts(GeoAlgorithm):
|
|||||||
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
|
||||||
fieldName = self.getParameterValue(self.FIELD)
|
fieldName = self.getParameterValue(self.FIELD)
|
||||||
|
|
||||||
geomType = self.singleToMultiGeom(layer.dataProvider().wkbType())
|
geomType = self.singleToMultiGeom(layer.wkbType())
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), geomType, layer.crs())
|
layer.fields().toList(), geomType, layer.crs())
|
||||||
|
|
||||||
inFeat = QgsFeature()
|
inFeat = QgsFeature()
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|||||||
@ -55,14 +55,13 @@ class Smooth(GeoAlgorithm):
|
|||||||
def processAlgorithm(self, progress):
|
def processAlgorithm(self, progress):
|
||||||
layer = dataobjects.getObjectFromUri(
|
layer = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.INPUT_LAYER))
|
self.getParameterValue(self.INPUT_LAYER))
|
||||||
provider = layer.dataProvider()
|
|
||||||
iterations = self.getParameterValue(self.ITERATIONS)
|
iterations = self.getParameterValue(self.ITERATIONS)
|
||||||
offset = self.getParameterValue(self.OFFSET)
|
offset = self.getParameterValue(self.OFFSET)
|
||||||
|
|
||||||
writer = self.getOutputFromName(
|
writer = self.getOutputFromName(
|
||||||
self.OUTPUT_LAYER).getVectorWriter(
|
self.OUTPUT_LAYER).getVectorWriter(
|
||||||
layer.fields().toList(),
|
layer.fields().toList(),
|
||||||
provider.wkbType(),
|
layer.wkbType(),
|
||||||
layer.crs())
|
layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|||||||
@ -108,11 +108,8 @@ class SpatialJoin(GeoAlgorithm):
|
|||||||
|
|
||||||
sumList = self.getParameterValue(self.STATS).lower().split(',')
|
sumList = self.getParameterValue(self.STATS).lower().split(',')
|
||||||
|
|
||||||
targetProvider = target.dataProvider()
|
targetFields = target.fields()
|
||||||
joinProvider = join.dataProvider()
|
joinFields = join.fields()
|
||||||
|
|
||||||
targetFields = targetProvider.fields()
|
|
||||||
joinFields = joinProvider.fields()
|
|
||||||
|
|
||||||
fieldList = QgsFields()
|
fieldList = QgsFields()
|
||||||
|
|
||||||
@ -141,7 +138,7 @@ class SpatialJoin(GeoAlgorithm):
|
|||||||
fields.append(f)
|
fields.append(f)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields, targetProvider.geometryType(), targetProvider.crs())
|
fields, target.wkbType(), target.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
inFeatB = QgsFeature()
|
inFeatB = QgsFeature()
|
||||||
|
|||||||
@ -57,10 +57,10 @@ class SplitLinesWithLines(GeoAlgorithm):
|
|||||||
layerB = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT_B))
|
layerB = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT_B))
|
||||||
|
|
||||||
sameLayer = self.getParameterValue(self.INPUT_A) == self.getParameterValue(self.INPUT_B)
|
sameLayer = self.getParameterValue(self.INPUT_A) == self.getParameterValue(self.INPUT_B)
|
||||||
fieldList = layerA.pendingFields()
|
fieldList = layerA.fields()
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fieldList,
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fieldList,
|
||||||
QgsWkbTypes.LineString, layerA.dataProvider().crs())
|
QgsWkbTypes.LineString, layerA.crs())
|
||||||
|
|
||||||
spatialIndex = vector.spatialindex(layerB)
|
spatialIndex = vector.spatialindex(layerB)
|
||||||
|
|
||||||
|
|||||||
@ -72,15 +72,13 @@ class SumLines(GeoAlgorithm):
|
|||||||
lengthFieldName = self.getParameterValue(self.LEN_FIELD)
|
lengthFieldName = self.getParameterValue(self.LEN_FIELD)
|
||||||
countFieldName = self.getParameterValue(self.COUNT_FIELD)
|
countFieldName = self.getParameterValue(self.COUNT_FIELD)
|
||||||
|
|
||||||
polyProvider = polyLayer.dataProvider()
|
|
||||||
|
|
||||||
(idxLength, fieldList) = vector.findOrCreateField(polyLayer,
|
(idxLength, fieldList) = vector.findOrCreateField(polyLayer,
|
||||||
polyLayer.pendingFields(), lengthFieldName)
|
polyLayer.fields(), lengthFieldName)
|
||||||
(idxCount, fieldList) = vector.findOrCreateField(polyLayer, fieldList,
|
(idxCount, fieldList) = vector.findOrCreateField(polyLayer, fieldList,
|
||||||
countFieldName)
|
countFieldName)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fieldList.toList(), polyProvider.geometryType(), polyProvider.crs())
|
fieldList.toList(), polyLayer.wkbType(), polyLayer.crs())
|
||||||
|
|
||||||
spatialIndex = vector.spatialindex(lineLayer)
|
spatialIndex = vector.spatialindex(lineLayer)
|
||||||
|
|
||||||
|
|||||||
@ -65,13 +65,10 @@ class SymmetricalDifference(GeoAlgorithm):
|
|||||||
layerB = dataobjects.getObjectFromUri(
|
layerB = dataobjects.getObjectFromUri(
|
||||||
self.getParameterValue(self.OVERLAY))
|
self.getParameterValue(self.OVERLAY))
|
||||||
|
|
||||||
providerA = layerA.dataProvider()
|
geomType = layerA.wkbType()
|
||||||
providerB = layerB.dataProvider()
|
|
||||||
|
|
||||||
geomType = providerA.geometryType()
|
|
||||||
fields = vector.combineVectorFields(layerA, layerB)
|
fields = vector.combineVectorFields(layerA, layerB)
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
fields, geomType, providerA.crs())
|
fields, geomType, layerA.crs())
|
||||||
|
|
||||||
featB = QgsFeature()
|
featB = QgsFeature()
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
@ -92,7 +89,7 @@ class SymmetricalDifference(GeoAlgorithm):
|
|||||||
attrs = featA.attributes()
|
attrs = featA.attributes()
|
||||||
intersects = indexA.intersects(geom.boundingBox())
|
intersects = indexA.intersects(geom.boundingBox())
|
||||||
for i in intersects:
|
for i in intersects:
|
||||||
providerB.getFeatures(QgsFeatureRequest().setFilterFid(i)).nextFeature(featB)
|
layerB.getFeatures(QgsFeatureRequest().setFilterFid(i)).nextFeature(featB)
|
||||||
tmpGeom = featB.geometry()
|
tmpGeom = featB.geometry()
|
||||||
if diffGeom.intersects(tmpGeom):
|
if diffGeom.intersects(tmpGeom):
|
||||||
diffGeom = QgsGeometry(diffGeom.difference(tmpGeom))
|
diffGeom = QgsGeometry(diffGeom.difference(tmpGeom))
|
||||||
@ -117,7 +114,7 @@ class SymmetricalDifference(GeoAlgorithm):
|
|||||||
count += 1
|
count += 1
|
||||||
progress.setPercentage(int(count * total))
|
progress.setPercentage(int(count * total))
|
||||||
|
|
||||||
length = len(providerA.fields())
|
length = len(layerA.fields())
|
||||||
|
|
||||||
for featA in featuresB:
|
for featA in featuresB:
|
||||||
add = True
|
add = True
|
||||||
@ -127,7 +124,7 @@ class SymmetricalDifference(GeoAlgorithm):
|
|||||||
attrs = [NULL] * length + attrs
|
attrs = [NULL] * length + attrs
|
||||||
intersects = indexB.intersects(geom.boundingBox())
|
intersects = indexB.intersects(geom.boundingBox())
|
||||||
for i in intersects:
|
for i in intersects:
|
||||||
providerA.getFeatures(QgsFeatureRequest().setFilterFid(i)).nextFeature(featB)
|
layerA.getFeatures(QgsFeatureRequest().setFilterFid(i)).nextFeature(featB)
|
||||||
tmpGeom = featB.geometry()
|
tmpGeom = featB.geometry()
|
||||||
if diffGeom.intersects(tmpGeom):
|
if diffGeom.intersects(tmpGeom):
|
||||||
diffGeom = QgsGeometry(diffGeom.difference(tmpGeom))
|
diffGeom = QgsGeometry(diffGeom.difference(tmpGeom))
|
||||||
|
|||||||
@ -55,7 +55,7 @@ class TextToFloat(GeoAlgorithm):
|
|||||||
fieldName = self.getParameterValue(self.FIELD)
|
fieldName = self.getParameterValue(self.FIELD)
|
||||||
idx = layer.fieldNameIndex(fieldName)
|
idx = layer.fieldNameIndex(fieldName)
|
||||||
|
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
fields[idx] = QgsField(fieldName, QVariant.Double, '', 24, 15)
|
fields[idx] = QgsField(fieldName, QVariant.Double, '', 24, 15)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
|
||||||
|
|||||||
@ -72,12 +72,10 @@ class Union(GeoAlgorithm):
|
|||||||
vlayerA = dataobjects.getObjectFromUri(self.getParameterValue(Union.INPUT))
|
vlayerA = dataobjects.getObjectFromUri(self.getParameterValue(Union.INPUT))
|
||||||
vlayerB = dataobjects.getObjectFromUri(self.getParameterValue(Union.INPUT2))
|
vlayerB = dataobjects.getObjectFromUri(self.getParameterValue(Union.INPUT2))
|
||||||
|
|
||||||
vproviderA = vlayerA.dataProvider()
|
geomType = vlayerA.wkbType()
|
||||||
|
|
||||||
geomType = vproviderA.wkbType()
|
|
||||||
fields = vector.combineVectorFields(vlayerA, vlayerB)
|
fields = vector.combineVectorFields(vlayerA, vlayerB)
|
||||||
writer = self.getOutputFromName(Union.OUTPUT).getVectorWriter(fields,
|
writer = self.getOutputFromName(Union.OUTPUT).getVectorWriter(fields,
|
||||||
geomType, vproviderA.crs())
|
geomType, vlayerA.crs())
|
||||||
inFeatA = QgsFeature()
|
inFeatA = QgsFeature()
|
||||||
inFeatB = QgsFeature()
|
inFeatB = QgsFeature()
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
@ -175,7 +173,7 @@ class Union(GeoAlgorithm):
|
|||||||
ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
|
ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
|
||||||
self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'))
|
self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'))
|
||||||
|
|
||||||
length = len(vproviderA.fields())
|
length = len(vlayerA.fields())
|
||||||
atMapA = [None] * length
|
atMapA = [None] * length
|
||||||
|
|
||||||
featuresA = vector.features(vlayerB)
|
featuresA = vector.features(vlayerB)
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class VariableDistanceBuffer(GeoAlgorithm):
|
|||||||
segments = int(self.getParameterValue(self.SEGMENTS))
|
segments = int(self.getParameterValue(self.SEGMENTS))
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), QgsWkbTypes.Polygon, layer.crs())
|
layer.fields().toList(), QgsWkbTypes.Polygon, layer.crs())
|
||||||
|
|
||||||
buff.buffering(progress, writer, 0, field, True, layer, dissolve,
|
buff.buffering(progress, writer, 0, field, True, layer, dissolve,
|
||||||
segments)
|
segments)
|
||||||
|
|||||||
@ -70,8 +70,8 @@ class VectorSplit(GeoAlgorithm):
|
|||||||
uniqueValues = vector.uniqueValues(layer, fieldIndex)
|
uniqueValues = vector.uniqueValues(layer, fieldIndex)
|
||||||
baseName = os.path.join(directory, '{0}_{1}'.format(layer.name(), fieldName))
|
baseName = os.path.join(directory, '{0}_{1}'.format(layer.name(), fieldName))
|
||||||
|
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
crs = layer.dataProvider().crs()
|
crs = layer.crs()
|
||||||
geomType = layer.wkbType()
|
geomType = layer.wkbType()
|
||||||
|
|
||||||
total = 100.0 / len(uniqueValues)
|
total = 100.0 / len(uniqueValues)
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class VoronoiPolygons(GeoAlgorithm):
|
|||||||
buf = self.getParameterValue(self.BUFFER)
|
buf = self.getParameterValue(self.BUFFER)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
|
||||||
layer.pendingFields().toList(), QgsWkbTypes.Polygon, layer.crs())
|
layer.fields().toList(), QgsWkbTypes.Polygon, layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
extent = layer.extent()
|
extent = layer.extent()
|
||||||
|
|||||||
@ -132,7 +132,7 @@ class ZonalStatistics(GeoAlgorithm):
|
|||||||
memVectorDriver = ogr.GetDriverByName('Memory')
|
memVectorDriver = ogr.GetDriverByName('Memory')
|
||||||
memRasterDriver = gdal.GetDriverByName('MEM')
|
memRasterDriver = gdal.GetDriverByName('MEM')
|
||||||
|
|
||||||
fields = layer.pendingFields()
|
fields = layer.fields()
|
||||||
(idxMin, fields) = vector.findOrCreateField(layer, fields,
|
(idxMin, fields) = vector.findOrCreateField(layer, fields,
|
||||||
columnPrefix + 'min', 21, 6)
|
columnPrefix + 'min', 21, 6)
|
||||||
(idxMax, fields) = vector.findOrCreateField(layer, fields,
|
(idxMax, fields) = vector.findOrCreateField(layer, fields,
|
||||||
@ -158,7 +158,7 @@ class ZonalStatistics(GeoAlgorithm):
|
|||||||
columnPrefix + 'mode', 21, 6)
|
columnPrefix + 'mode', 21, 6)
|
||||||
|
|
||||||
writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(
|
writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(
|
||||||
fields.toList(), layer.dataProvider().wkbType(), layer.crs())
|
fields.toList(), layer.wkbType(), layer.crs())
|
||||||
|
|
||||||
outFeat = QgsFeature()
|
outFeat = QgsFeature()
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from collections import defaultdict
|
|||||||
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
||||||
|
|
||||||
layer = processing.getObject(Input)
|
layer = processing.getObject(Input)
|
||||||
inputFields = layer.pendingFields()
|
inputFields = layer.fields()
|
||||||
fieldIdxs = []
|
fieldIdxs = []
|
||||||
fields = Fields.split(',')
|
fields = Fields.split(',')
|
||||||
for f in fields:
|
for f in fields:
|
||||||
|
|||||||
@ -172,7 +172,7 @@ class FieldsCalculatorDialog(BASE, WIDGET):
|
|||||||
if self.layer is None:
|
if self.layer is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
fields = self.layer.pendingFields()
|
fields = self.layer.fields()
|
||||||
for f in fields:
|
for f in fields:
|
||||||
self.mExistingFieldComboBox.addItem(f.name())
|
self.mExistingFieldComboBox.addItem(f.name())
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user