Skip to content
Permalink
Browse files

Merge pull request #5237 from nyalldawson/port_algs

[processing] Port line intersection and split with lines to c++
  • Loading branch information
nyalldawson committed Sep 22, 2017
2 parents 5d6c178 + 57b7692 commit a6b1c3ee9f78d7900448ed68041432b2b505b185
Showing with 1,056 additions and 610 deletions.
  1. +15 −0 python/core/processing/qgsprocessingutils.sip
  2. +3 −2 python/plugins/processing/algs/qgis/HubLines.py
  3. +1 −1 python/plugins/processing/algs/qgis/JoinAttributes.py
  4. +0 −181 python/plugins/processing/algs/qgis/LinesIntersection.py
  5. +0 −4 python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
  6. +2 −1 python/plugins/processing/algs/qgis/SpatialJoin.py
  7. +2 −1 python/plugins/processing/algs/qgis/SpatialJoinSummary.py
  8. +0 −209 python/plugins/processing/algs/qgis/SplitWithLines.py
  9. +2 −1 python/plugins/processing/algs/qgis/SymmetricalDifference.py
  10. +2 −2 python/plugins/processing/algs/qgis/Union.py
  11. +55 −0 python/plugins/processing/tests/testdata/custom/line_intersection1.gml
  12. +4 −4 ...lugins/processing/tests/testdata/{expected/line_intersection.xsd → custom/line_intersection1.xsd}
  13. +41 −0 python/plugins/processing/tests/testdata/custom/line_intersection2.gml
  14. +37 −0 python/plugins/processing/tests/testdata/custom/line_intersection2.xsd
  15. +50 −0 python/plugins/processing/tests/testdata/expected/line_intersection_all_fields.gml
  16. +51 −0 python/plugins/processing/tests/testdata/expected/line_intersection_all_fields.xsd
  17. +19 −15 ...processing/tests/testdata/expected/{line_intersection.gml → line_intersection_partial_fields.gml}
  18. +37 −0 python/plugins/processing/tests/testdata/expected/line_intersection_partial_fields.xsd
  19. +0 −15 python/plugins/processing/tests/testdata/expected/lines_split_with_lines.gfs
  20. +8 −24 python/plugins/processing/tests/testdata/expected/lines_split_with_lines.gml
  21. +23 −0 python/plugins/processing/tests/testdata/expected/lines_split_with_lines.xsd
  22. +0 −15 python/plugins/processing/tests/testdata/expected/lines_split_with_same_lines.gfs
  23. +3 −13 python/plugins/processing/tests/testdata/expected/lines_split_with_same_lines.gml
  24. +23 −0 python/plugins/processing/tests/testdata/expected/lines_split_with_same_lines.xsd
  25. +0 −32 python/plugins/processing/tests/testdata/expected/split_polys_with_lines.gfs
  26. +2 −2 python/plugins/processing/tests/testdata/expected/split_polys_with_lines.gml
  27. +43 −0 python/plugins/processing/tests/testdata/expected/split_polys_with_lines.xsd
  28. +31 −0 python/plugins/processing/tests/testdata/expected/variable_buffer_points.gfs
  29. +58 −65 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
  30. +0 −23 python/plugins/processing/tools/vector.py
  31. +413 −0 src/core/processing/qgsnativealgorithms.cpp
  32. +48 −0 src/core/processing/qgsnativealgorithms.h
  33. +35 −0 src/core/processing/qgsprocessingutils.cpp
  34. +12 −0 src/core/processing/qgsprocessingutils.h
  35. +36 −0 tests/src/core/testqgsprocessing.cpp
@@ -193,6 +193,21 @@ class QgsProcessingUtils
:rtype: str
%End

static QgsFields combineFields( const QgsFields &fieldsA, const QgsFields &fieldsB );
%Docstring
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).

Duplicate field names will be altered to "name_2", "name_3", etc, finding the first
non-duplicate name.

.. note::

Some output file formats (e.g. shapefiles) have restrictions on the maximum
length of field names, so be aware that the results of calling this method may
be truncated when saving to these formats.
:rtype: QgsFields
%End

};

class QgsProcessingFeatureSource : QgsFeatureSource
@@ -37,7 +37,8 @@
QgsProcessingParameterField,
QgsProcessingParameterFeatureSink,
QgsProcessingException,
QgsExpression)
QgsExpression,
QgsProcessingUtils)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import vector

@@ -89,7 +90,7 @@ def processAlgorithm(self, parameters, context, feedback):
field_spoke = self.parameterAsString(parameters, self.SPOKE_FIELD, context)
field_spoke_index = hub_source.fields().lookupField(field_spoke)

fields = vector.combineFields(hub_source.fields(), spoke_source.fields())
fields = QgsProcessingUtils.combineFields(hub_source.fields(), spoke_source.fields())

(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
fields, QgsWkbTypes.LineString, hub_source.sourceCrs())
@@ -82,7 +82,7 @@ def processAlgorithm(self, parameters, context, feedback):
joinField1Index = input.fields().lookupField(field)
joinField2Index = input2.fields().lookupField(field2)

outFields = vector.combineFields(input.fields(), input2.fields())
outFields = QgsProcessingUtils.combineFields(input.fields(), input2.fields())

(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
outFields, input.wkbType(), input.sourceCrs())

This file was deleted.

@@ -91,7 +91,6 @@
from .ImportIntoSpatialite import ImportIntoSpatialite
from .Intersection import Intersection
from .JoinAttributes import JoinAttributes
from .LinesIntersection import LinesIntersection
from .LinesToPolygons import LinesToPolygons
from .MeanCoords import MeanCoords
from .Merge import Merge
@@ -147,7 +146,6 @@
from .SpatialIndex import SpatialIndex
from .SpatialJoin import SpatialJoin
from .SpatialJoinSummary import SpatialJoinSummary
from .SplitWithLines import SplitWithLines
from .StatisticsByCategories import StatisticsByCategories
from .SumLines import SumLines
from .SymmetricalDifference import SymmetricalDifference
@@ -227,7 +225,6 @@ def getAlgs(self):
ImportIntoSpatialite(),
Intersection(),
JoinAttributes(),
LinesIntersection(),
LinesToPolygons(),
MeanCoords(),
Merge(),
@@ -283,7 +280,6 @@ def getAlgs(self):
SpatialIndex(),
SpatialJoin(),
SpatialJoinSummary(),
SplitWithLines(),
StatisticsByCategories(),
SumLines(),
SymmetricalDifference(),
@@ -37,6 +37,7 @@
QgsFeatureRequest,
QgsGeometry,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterBoolean,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
@@ -148,7 +149,7 @@ def processAlgorithm(self, parameters, context, feedback):
if idx >= 0:
fields_to_join.append(join_source.fields().at(idx))

out_fields = vector.combineFields(source_fields, fields_to_join)
out_fields = QgsProcessingUtils.combineFields(source_fields, fields_to_join)

(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
out_fields, source.wkbType(), source.sourceCrs())
@@ -43,6 +43,7 @@
QgsDateTimeStatisticalSummary,
QgsStringStatisticalSummary,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterBoolean,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
@@ -247,7 +248,7 @@ def addField(original, stat, type):
else:
addFieldKeepType(join_field, f[0])

out_fields = vector.combineFields(source_fields, fields_to_join)
out_fields = QgsProcessingUtils.combineFields(source_fields, fields_to_join)

(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
out_fields, source.wkbType(), source.sourceCrs())

0 comments on commit a6b1c3e

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