Skip to content
Permalink
Browse files
Merge pull request #4417 from nyalldawson/processing_writer
Refactor processing writer to use QgsFeatureSink
  • Loading branch information
nyalldawson committed Apr 27, 2017
2 parents d718110 + fd2c18e commit ccb4ac98b48a5b975eb820c27f08ffe13131f94c
Showing with 327 additions and 478 deletions.
  1. +6 −2 python/core/processing/qgsprocessingcontext.sip
  2. +1 −2 python/plugins/processing/algs/qgis/AddTableField.py
  3. +1 −2 python/plugins/processing/algs/qgis/AutoincrementalField.py
  4. +1 −4 python/plugins/processing/algs/qgis/Boundary.py
  5. +1 −4 python/plugins/processing/algs/qgis/BoundingBox.py
  6. +1 −4 python/plugins/processing/algs/qgis/Centroids.py
  7. +3 −12 python/plugins/processing/algs/qgis/CheckValidity.py
  8. +3 −4 python/plugins/processing/algs/qgis/Clip.py
  9. +2 −2 python/plugins/processing/algs/qgis/ConcaveHull.py
  10. +1 −2 python/plugins/processing/algs/qgis/ConvexHull.py
  11. +1 −2 python/plugins/processing/algs/qgis/Delaunay.py
  12. +1 −2 python/plugins/processing/algs/qgis/DeleteColumn.py
  13. +1 −2 python/plugins/processing/algs/qgis/DeleteDuplicateGeometries.py
  14. +2 −4 python/plugins/processing/algs/qgis/DeleteHoles.py
  15. +1 −2 python/plugins/processing/algs/qgis/DensifyGeometries.py
  16. +1 −2 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  17. +1 −3 python/plugins/processing/algs/qgis/Difference.py
  18. +1 −4 python/plugins/processing/algs/qgis/Dissolve.py
  19. +2 −4 python/plugins/processing/algs/qgis/DropGeometry.py
  20. +1 −2 python/plugins/processing/algs/qgis/EliminateSelection.py
  21. +1 −2 python/plugins/processing/algs/qgis/EquivalentNumField.py
  22. +3 −5 python/plugins/processing/algs/qgis/ExecuteSQL.py
  23. +1 −2 python/plugins/processing/algs/qgis/Explode.py
  24. +2 −2 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
  25. +1 −4 python/plugins/processing/algs/qgis/ExtendLines.py
  26. +1 −2 python/plugins/processing/algs/qgis/ExtentFromLayer.py
  27. +1 −2 python/plugins/processing/algs/qgis/ExtractByAttribute.py
  28. +2 −1 python/plugins/processing/algs/qgis/ExtractByExpression.py
  29. +1 −2 python/plugins/processing/algs/qgis/ExtractByLocation.py
  30. +1 −2 python/plugins/processing/algs/qgis/ExtractNodes.py
  31. +1 −4 python/plugins/processing/algs/qgis/ExtractSpecificNodes.py
  32. +1 −2 python/plugins/processing/algs/qgis/FieldPyculator.py
  33. +1 −2 python/plugins/processing/algs/qgis/FieldsCalculator.py
  34. +1 −3 python/plugins/processing/algs/qgis/FieldsMapper.py
  35. +1 −4 python/plugins/processing/algs/qgis/FixGeometry.py
  36. +1 −2 python/plugins/processing/algs/qgis/FixedDistanceBuffer.py
  37. +1 −4 python/plugins/processing/algs/qgis/GeometryByExpression.py
  38. +1 −2 python/plugins/processing/algs/qgis/GeometryConvert.py
  39. +1 −2 python/plugins/processing/algs/qgis/GridLine.py
  40. +1 −2 python/plugins/processing/algs/qgis/GridPolygon.py
  41. +2 −2 python/plugins/processing/algs/qgis/Gridify.py
  42. +2 −2 python/plugins/processing/algs/qgis/HubDistanceLines.py
  43. +2 −2 python/plugins/processing/algs/qgis/HubDistancePoints.py
  44. +2 −2 python/plugins/processing/algs/qgis/HubLines.py
  45. +1 −2 python/plugins/processing/algs/qgis/Intersection.py
  46. +1 −2 python/plugins/processing/algs/qgis/JoinAttributes.py
  47. +2 −2 python/plugins/processing/algs/qgis/LinesIntersection.py
  48. +2 −3 python/plugins/processing/algs/qgis/LinesToPolygons.py
  49. +1 −3 python/plugins/processing/algs/qgis/MeanCoords.py
  50. +2 −3 python/plugins/processing/algs/qgis/Merge.py
  51. +1 −4 python/plugins/processing/algs/qgis/MergeLines.py
  52. +2 −2 python/plugins/processing/algs/qgis/MultipartToSingleparts.py
  53. +1 −4 python/plugins/processing/algs/qgis/OffsetLine.py
  54. +1 −2 python/plugins/processing/algs/qgis/OrientedMinimumBoundingBox.py
  55. +1 −4 python/plugins/processing/algs/qgis/Orthogonalize.py
  56. +1 −4 python/plugins/processing/algs/qgis/PointOnSurface.py
  57. +1 −2 python/plugins/processing/algs/qgis/PointsAlongGeometry.py
  58. +1 −2 python/plugins/processing/algs/qgis/PointsDisplacement.py
  59. +2 −2 python/plugins/processing/algs/qgis/PointsFromLines.py
  60. +2 −2 python/plugins/processing/algs/qgis/PointsFromPolygons.py
  61. +2 −2 python/plugins/processing/algs/qgis/PointsInPolygon.py
  62. +2 −2 python/plugins/processing/algs/qgis/PointsInPolygonUnique.py
  63. +2 −2 python/plugins/processing/algs/qgis/PointsInPolygonWeighted.py
  64. +1 −1 python/plugins/processing/algs/qgis/PointsLayerFromTable.py
  65. +2 −2 python/plugins/processing/algs/qgis/PointsToPaths.py
  66. +1 −4 python/plugins/processing/algs/qgis/PoleOfInaccessibility.py
  67. +1 −4 python/plugins/processing/algs/qgis/PolygonCentroids.py
  68. +1 −1 python/plugins/processing/algs/qgis/Polygonize.py
  69. +2 −2 python/plugins/processing/algs/qgis/PolygonsToLines.py
  70. +2 −2 python/plugins/processing/algs/qgis/RandomExtract.py
  71. +2 −2 python/plugins/processing/algs/qgis/RandomExtractWithinSubsets.py
  72. +1 −2 python/plugins/processing/algs/qgis/RandomPointsAlongLines.py
  73. +1 −2 python/plugins/processing/algs/qgis/RandomPointsExtent.py
  74. +1 −2 python/plugins/processing/algs/qgis/RandomPointsLayer.py
  75. +1 −2 python/plugins/processing/algs/qgis/RandomPointsPolygonsFixed.py
  76. +1 −2 python/plugins/processing/algs/qgis/RandomPointsPolygonsVariable.py
  77. +1 −4 python/plugins/processing/algs/qgis/RectanglesOvalsDiamondsFixed.py
  78. +1 −4 python/plugins/processing/algs/qgis/RectanglesOvalsDiamondsVariable.py
  79. +1 −2 python/plugins/processing/algs/qgis/RegularPoints.py
  80. +1 −4 python/plugins/processing/algs/qgis/RemoveNullGeometry.py
  81. +2 −2 python/plugins/processing/algs/qgis/ReprojectLayer.py
  82. +1 −4 python/plugins/processing/algs/qgis/ReverseLineDirection.py
  83. +1 −2 python/plugins/processing/algs/qgis/SaveSelectedFeatures.py
  84. +2 −8 python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py
  85. +2 −8 python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py
  86. +1 −4 python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py
  87. +1 −4 python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py
  88. +1 −4 python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py
  89. +2 −2 python/plugins/processing/algs/qgis/SimplifyGeometries.py
  90. +2 −2 python/plugins/processing/algs/qgis/SinglePartsToMultiparts.py
  91. +1 −4 python/plugins/processing/algs/qgis/SingleSidedBuffer.py
  92. +1 −4 python/plugins/processing/algs/qgis/Smooth.py
  93. +2 −2 python/plugins/processing/algs/qgis/SnapGeometries.py
  94. +1 −2 python/plugins/processing/algs/qgis/SpatialJoin.py
  95. +2 −2 python/plugins/processing/algs/qgis/SplitLinesWithLines.py
  96. +2 −2 python/plugins/processing/algs/qgis/SplitWithLines.py
  97. +2 −2 python/plugins/processing/algs/qgis/SumLines.py
  98. +1 −2 python/plugins/processing/algs/qgis/SymmetricalDifference.py
  99. +1 −2 python/plugins/processing/algs/qgis/TextToFloat.py
  100. +1 −4 python/plugins/processing/algs/qgis/TopoColors.py
  101. +1 −4 python/plugins/processing/algs/qgis/Translate.py
  102. +1 −2 python/plugins/processing/algs/qgis/Union.py
  103. +2 −2 python/plugins/processing/algs/qgis/VariableDistanceBuffer.py
  104. +1 −2 python/plugins/processing/algs/qgis/VectorGridLines.py
  105. +1 −2 python/plugins/processing/algs/qgis/VectorGridPolygons.py
  106. +1 −1 python/plugins/processing/algs/qgis/VectorSplit.py
  107. +2 −2 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  108. +2 −2 python/plugins/processing/algs/qgis/ZonalStatistics.py
  109. +3 −3 python/plugins/processing/algs/qgis/scripts/Number_of_unique_values_in_classes.py
  110. +3 −1 python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py
  111. +1 −4 python/plugins/processing/core/GeoAlgorithm.py
  112. +1 −1 python/plugins/processing/core/Processing.py
  113. +7 −7 python/plugins/processing/core/outputs.py
  114. +5 −5 python/plugins/processing/gui/AlgorithmDialog.py
  115. +1 −1 python/plugins/processing/gui/AlgorithmDialogBase.py
  116. +1 −1 python/plugins/processing/gui/AlgorithmExecutor.py
  117. +5 −2 python/plugins/processing/gui/BatchAlgorithmDialog.py
  118. +4 −2 python/plugins/processing/gui/Postprocessing.py
  119. +4 −2 python/plugins/processing/gui/ProcessingToolbox.py
  120. +4 −2 python/plugins/processing/gui/menus.py
  121. +3 −2 python/plugins/processing/tests/testdata/scripts/centroids.py
  122. +131 −141 python/plugins/processing/tools/vector.py
  123. +1 −6 src/core/processing/qgsprocessingcontext.h
@@ -75,8 +75,12 @@ class QgsProcessingContext
Sets the expression ``context``.
%End



QgsProject &temporaryLayerStore();
%Docstring
Returns a reference to the project used for storing temporary layers during
algorithm execution.
:rtype: QgsProject
%End

QgsFeatureRequest::InvalidGeometryCheck invalidGeometryCheck() const;
%Docstring
@@ -97,8 +97,7 @@ def processAlgorithm(self, context, feedback):
fields = layer.fields()
fields.append(QgsField(fieldName, self.TYPES[fieldType], '',
fieldLength, fieldPrecision))
writer = output.getVectorWriter(fields, layer.wkbType(),
layer.crs())
writer = output.getVectorWriter(fields, layer.wkbType(), layer.crs(), context)
outFeat = QgsFeature()
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -67,8 +67,7 @@ def processAlgorithm(self, context, feedback):
dataobjects.getLayerFromString(self.getParameterValue(self.INPUT))
fields = vlayer.fields()
fields.append(QgsField('AUTO', QVariant.Int))
writer = output.getVectorWriter(fields, vlayer.wkbType(),
vlayer.crs())
writer = output.getVectorWriter(fields, vlayer.wkbType(), vlayer.crs(), context)
outFeat = QgsFeature()
features = QgsProcessingUtils.getFeatures(vlayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayer, context)
@@ -78,10 +78,7 @@ def processAlgorithm(self, context, feedback):
output_wkb = QgsWkbTypes.addM(output_wkb)

writer = self.getOutputFromName(
self.OUTPUT_LAYER).getVectorWriter(
layer.fields(),
output_wkb,
layer.crs())
self.OUTPUT_LAYER).getVectorWriter(layer.fields(), output_wkb, layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -67,10 +67,7 @@ def processAlgorithm(self, context, feedback):
self.getParameterValue(self.INPUT_LAYER))

writer = self.getOutputFromName(
self.OUTPUT_LAYER).getVectorWriter(
layer.fields().toList(),
QgsWkbTypes.Polygon,
layer.crs())
self.OUTPUT_LAYER).getVectorWriter(layer.fields().toList(), QgsWkbTypes.Polygon, layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -69,10 +69,7 @@ def processAlgorithm(self, context, feedback):
self.getParameterValue(self.INPUT_LAYER))

writer = self.getOutputFromName(
self.OUTPUT_LAYER).getVectorWriter(
layer.fields(),
QgsWkbTypes.Point,
layer.crs())
self.OUTPUT_LAYER).getVectorWriter(layer.fields(), QgsWkbTypes.Point, layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -108,32 +108,23 @@ def doCheck(self, context, feedback):

valid_output = self.getOutputFromName(self.VALID_OUTPUT)
valid_fields = layer.fields()
valid_writer = valid_output.getVectorWriter(
valid_fields,
layer.wkbType(),
layer.crs())
valid_writer = valid_output.getVectorWriter(valid_fields, layer.wkbType(), layer.crs(), context)
valid_count = 0

invalid_output = self.getOutputFromName(self.INVALID_OUTPUT)
invalid_fields = layer.fields().toList() + [
QgsField(name='_errors',
type=QVariant.String,
len=255)]
invalid_writer = invalid_output.getVectorWriter(
invalid_fields,
layer.wkbType(),
layer.crs())
invalid_writer = invalid_output.getVectorWriter(invalid_fields, layer.wkbType(), layer.crs(), context)
invalid_count = 0

error_output = self.getOutputFromName(self.ERROR_OUTPUT)
error_fields = [
QgsField(name='message',
type=QVariant.String,
len=255)]
error_writer = error_output.getVectorWriter(
error_fields,
QgsWkbTypes.Point,
layer.crs())
error_writer = error_output.getVectorWriter(error_fields, QgsWkbTypes.Point, layer.crs(), context)
error_count = 0

features = QgsProcessingUtils.getFeatures(layer, context)
@@ -75,10 +75,9 @@ def processAlgorithm(self, context, feedback):
mask_layer = dataobjects.getLayerFromString(
self.getParameterValue(Clip.OVERLAY))

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
source_layer.fields(),
QgsWkbTypes.multiType(source_layer.wkbType()),
source_layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(source_layer.fields(),
QgsWkbTypes.multiType(source_layer.wkbType()),
source_layer.crs(), context)

# first build up a list of clip geometries
clip_geoms = []
@@ -133,8 +133,8 @@ def processAlgorithm(self, context, feedback):
feedback.setProgressText(self.tr('Saving data...'))
feat = QgsFeature()
dissolved_layer.getFeatures(QgsFeatureRequest().setFilterFid(0)).nextFeature(feat)
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
layer.fields().toList(), QgsWkbTypes.Polygon, layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.fields().toList(), QgsWkbTypes.Polygon,
layer.crs(), context)
geom = feat.geometry()
if no_multigeom and geom.isMultipart():
# Only singlepart geometries are allowed
@@ -103,8 +103,7 @@ def processAlgorithm(self, context, feedback):
QgsField('perim', QVariant.Double, '', 20, 6)
]

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
fields, QgsWkbTypes.Polygon, layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, QgsWkbTypes.Polygon, layer.crs(), context)

outFeat = QgsFeature()
inGeom = QgsGeometry()
@@ -77,8 +77,7 @@ def processAlgorithm(self, context, feedback):
QgsField('POINTB', QVariant.Double, '', 24, 15),
QgsField('POINTC', QVariant.Double, '', 24, 15)]

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
QgsWkbTypes.Polygon, layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, QgsWkbTypes.Polygon, layer.crs(), context)

pts = []
ptDict = {}
@@ -83,8 +83,7 @@ def processAlgorithm(self, context, feedback):
for index in field_indices:
fields.remove(index)

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, layer.wkbType(), layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -65,8 +65,7 @@ def processAlgorithm(self, context, feedback):

fields = layer.fields()

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, layer.wkbType(), layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)

@@ -77,10 +77,8 @@ def processAlgorithm(self, context, feedback):
if min_area == 0.0:
min_area = -1.0

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
layer.fields(),
layer.wkbType(),
layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.fields(), layer.wkbType(), layer.crs(),
context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -85,8 +85,7 @@ def processAlgorithm(self, context, feedback):
isPolygon = layer.geometryType() == QgsWkbTypes.PolygonGeometry

writer = self.getOutputFromName(
self.OUTPUT).getVectorWriter(layer.fields().toList(),
layer.wkbType(), layer.crs())
self.OUTPUT).getVectorWriter(layer.fields().toList(), layer.wkbType(), layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -79,8 +79,7 @@ def processAlgorithm(self, context, feedback):
isPolygon = layer.geometryType() == QgsWkbTypes.PolygonGeometry

writer = self.getOutputFromName(
self.OUTPUT).getVectorWriter(layer.fields().toList(),
layer.wkbType(), layer.crs())
self.OUTPUT).getVectorWriter(layer.fields().toList(), layer.wkbType(), layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -77,9 +77,7 @@ def processAlgorithm(self, context, feedback):

geomType = QgsWkbTypes.multiType(layerA.wkbType())
writer = self.getOutputFromName(
Difference.OUTPUT).getVectorWriter(layerA.fields(),
geomType,
layerA.crs())
Difference.OUTPUT).getVectorWriter(layerA.fields(), geomType, layerA.crs(), context)

outFeat = QgsFeature()
index = vector.spatialindex(layerB)
@@ -82,10 +82,7 @@ def processAlgorithm(self, context, feedback):
self.getParameterValue(Dissolve.INPUT))

writer = self.getOutputFromName(
Dissolve.OUTPUT).getVectorWriter(
vlayerA.fields().toList(),
vlayerA.wkbType(),
vlayerA.crs())
Dissolve.OUTPUT).getVectorWriter(vlayerA.fields().toList(), vlayerA.wkbType(), vlayerA.crs(), context)

outFeat = QgsFeature()
features = QgsProcessingUtils.getFeatures(vlayerA, context)
@@ -70,10 +70,8 @@ def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT_LAYER))
writer = self.getOutputFromName(
self.OUTPUT_TABLE).getVectorWriter(
layer.fields(),
QgsWkbTypes.NoGeometry,
QgsCoordinateReferenceSystem())
self.OUTPUT_TABLE).getVectorWriter(layer.fields(), QgsWkbTypes.NoGeometry, QgsCoordinateReferenceSystem(),
context)

request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)
features = QgsProcessingUtils.getFeatures(layer, context, request)
@@ -92,8 +92,7 @@ def processAlgorithm(self, context, feedback):
featToEliminate = []
selFeatIds = inLayer.selectedFeatureIds()
output = self.getOutputFromName(self.OUTPUT)
writer = output.getVectorWriter(inLayer.fields(),
inLayer.wkbType(), inLayer.crs())
writer = output.getVectorWriter(inLayer.fields(), inLayer.wkbType(), inLayer.crs(), context)

for aFeat in inLayer.getFeatures():
if aFeat.id() in selFeatIds:
@@ -73,8 +73,7 @@ def processAlgorithm(self, context, feedback):
fieldindex = vlayer.fields().lookupField(fieldname)
fields = vlayer.fields()
fields.append(QgsField('NUM_FIELD', QVariant.Int))
writer = output.getVectorWriter(fields, vlayer.wkbType(),
vlayer.crs())
writer = output.getVectorWriter(fields, vlayer.wkbType(), vlayer.crs(), context)
outFeat = QgsFeature()
classes = {}

@@ -146,11 +146,9 @@ def processAlgorithm(self, context, feedback):
if not vLayer.isValid():
raise GeoAlgorithmExecutionException(vLayer.dataProvider().error().message())

writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(
vLayer.fields().toList(),
# Create a point layer (without any points) if 'no geometry' is chosen
vLayer.wkbType() if geometry_type != 1 else 1,
vLayer.crs())
writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(vLayer.fields().toList(),
vLayer.wkbType() if geometry_type != 1 else 1,
vLayer.crs(), context)

features = QgsProcessingUtils.getFeatures(vLayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vLayer, context)
@@ -68,8 +68,7 @@ def processAlgorithm(self, context, feedback):
self.getParameterValue(self.INPUT))
output = self.getOutputFromName(self.OUTPUT)
fields = vlayer.fields()
writer = output.getVectorWriter(fields, QgsWkbTypes.LineString,
vlayer.crs())
writer = output.getVectorWriter(fields, QgsWkbTypes.LineString, vlayer.crs(), context)
outFeat = QgsFeature()
features = QgsProcessingUtils.getFeatures(vlayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayer, context)
@@ -107,8 +107,8 @@ def processAlgorithm(self, context, feedback):
zName = vector.createUniqueFieldName('mvalue', fields)
fields.append(QgsField(zName, QVariant.Double))

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
fields.toList(), layer.wkbType(), layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields.toList(), layer.wkbType(), layer.crs(),
context)

ellips = None
crs = None
@@ -71,10 +71,7 @@ def processAlgorithm(self, context, feedback):
self.getParameterValue(self.INPUT_LAYER))

writer = self.getOutputFromName(
self.OUTPUT_LAYER).getVectorWriter(
layer.fields(),
layer.wkbType(),
layer.crs())
self.OUTPUT_LAYER).getVectorWriter(layer.fields(), layer.wkbType(), layer.crs(), context)

start_distance = self.getParameterValue(self.START_DISTANCE)
end_distance = self.getParameterValue(self.END_DISTANCE)
@@ -89,8 +89,7 @@ def processAlgorithm(self, context, feedback):
QgsField('WIDTH', QVariant.Double),
]

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
QgsWkbTypes.Polygon, layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, QgsWkbTypes.Polygon, layer.crs(), context)

if byFeature:
self.featureExtent(layer, context, writer, feedback)
@@ -111,8 +111,7 @@ def processAlgorithm(self, context, feedback):
value = self.getParameterValue(self.VALUE)

fields = layer.fields()
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, layer.wkbType(), layer.crs(), context)

idx = layer.fields().lookupField(fieldName)
fieldType = fields[idx].type()
@@ -70,7 +70,8 @@ def defineCharacteristics(self):
def processAlgorithm(self, context, feedback):
layer = dataobjects.getLayerFromString(self.getParameterValue(self.INPUT))
expression_string = self.getParameterValue(self.EXPRESSION)
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.fields(), layer.wkbType(), layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.fields(), layer.wkbType(), layer.crs(),
context)

expression = QgsExpression(expression_string)
if not expression.hasParserError():
@@ -97,8 +97,7 @@ def processAlgorithm(self, context, feedback):
index = vector.spatialindex(layer)

output = self.getOutputFromName(self.OUTPUT)
writer = output.getVectorWriter(layer.fields(),
layer.wkbType(), layer.crs())
writer = output.getVectorWriter(layer.fields(), layer.wkbType(), layer.crs(), context)

if 'disjoint' in predicates:
disjoinSet = []
@@ -75,8 +75,7 @@ def processAlgorithm(self, context, feedback):
fields.append(QgsField('distance', QVariant.Double))
fields.append(QgsField('angle', QVariant.Double))

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
fields, QgsWkbTypes.Point, layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, QgsWkbTypes.Point, layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
@@ -80,10 +80,7 @@ def processAlgorithm(self, context, feedback):
fields.append(QgsField('angle', QVariant.Double))

writer = self.getOutputFromName(
self.OUTPUT_LAYER).getVectorWriter(
fields,
QgsWkbTypes.Point,
layer.crs())
self.OUTPUT_LAYER).getVectorWriter(fields, QgsWkbTypes.Point, layer.crs(), context)

node_indices_string = self.getParameterValue(self.NODES)
indices = []
@@ -107,8 +107,7 @@ def processAlgorithm(self, context, feedback):
fields = layer.fields()
fields.append(QgsField(fieldName, self.TYPES[fieldType], '',
fieldLength, fieldPrecision))
writer = output.getVectorWriter(fields, layer.wkbType(),
layer.crs())
writer = output.getVectorWriter(fields, layer.wkbType(), layer.crs(), context)
outFeat = QgsFeature()
new_ns = {}

@@ -113,8 +113,7 @@ def processAlgorithm(self, context, feedback):
if newField:
fields.append(QgsField(fieldName, fieldType, '', width, precision))

writer = output.getVectorWriter(fields, layer.wkbType(),
layer.crs())
writer = output.getVectorWriter(fields, layer.wkbType(), layer.crs(), context)

exp = QgsExpression(formula)

Loading

0 comments on commit ccb4ac9

Please sign in to comment.