From d18190ce4fba6ee3b0b5479275e1337a2a851a3b Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 10 Aug 2023 09:23:34 +0300 Subject: [PATCH] make cppcheck happy --- .../expected/concave_hull_points_03.gml | 1 - .../expected/concave_hull_points_03.xsd | 7 -- ...09.gml => concave_hull_points_03_geos.gml} | 8 +-- ...09.xsd => concave_hull_points_03_geos.xsd} | 4 +- .../expected/concave_hull_points_07.gml | 1 - .../expected/concave_hull_points_07.xsd | 7 -- .../expected/concave_hull_points_07_geos.gml | 16 +++++ .../expected/concave_hull_points_07_geos.xsd | 47 +++++++++++++ .../tests/testdata/qgis_algorithm_tests4.yaml | 66 +++++++++++++------ .../processing/qgsalgorithmconcavehull.cpp | 11 ++-- .../qgsalgorithmvoronoipolygons.cpp | 1 - 11 files changed, 120 insertions(+), 49 deletions(-) rename python/plugins/processing/tests/testdata/expected/{concave_hull_points_09.gml => concave_hull_points_03_geos.gml} (72%) rename python/plugins/processing/tests/testdata/expected/{concave_hull_points_09.xsd => concave_hull_points_03_geos.xsd} (91%) create mode 100644 python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.gml create mode 100644 python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.xsd diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.gml b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.gml index c155287d767..4aca65ec5a6 100644 --- a/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.gml +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.gml @@ -11,7 +11,6 @@ 1 23 5 2 2 3 3 2 5 1 4 2 2 - 1 diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.xsd b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.xsd index ee7f6d9bdfe..754d43b6a49 100644 --- a/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.xsd +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03.xsd @@ -40,13 +40,6 @@ - - - - - - - diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_09.gml b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03_geos.gml similarity index 72% rename from python/plugins/processing/tests/testdata/expected/concave_hull_points_09.gml rename to python/plugins/processing/tests/testdata/expected/concave_hull_points_03_geos.gml index 5939c840ddf..70d0ea51626 100644 --- a/python/plugins/processing/tests/testdata/expected/concave_hull_points_09.gml +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03_geos.gml @@ -2,15 +2,15 @@ -5 03 8 - + -5 03 8 - -1 0 1 1 2 2 3 3 2 5 -1 8 -1 7 -5 0 -1 0 - + -5 0 -1 0 1 1 2 2 3 3 2 5 -1 8 -1 7 1 4 -5 0 + diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_09.xsd b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03_geos.xsd similarity index 91% rename from python/plugins/processing/tests/testdata/expected/concave_hull_points_09.xsd rename to python/plugins/processing/tests/testdata/expected/concave_hull_points_03_geos.xsd index a15928a8663..d1c4e19f5cc 100644 --- a/python/plugins/processing/tests/testdata/expected/concave_hull_points_09.xsd +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_03_geos.xsd @@ -34,8 +34,8 @@ - - + + diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.gml b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.gml index a8a389f31c0..c660eb66978 100644 --- a/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.gml +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.gml @@ -11,7 +11,6 @@ -1 03 8 1 1 2 2 3 3 2 5 -1 8 -1 7 1 4 -1 0 1 1 - 1 diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.xsd b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.xsd index 4ccdf6a95c5..63cfb6bba92 100644 --- a/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.xsd +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07.xsd @@ -40,13 +40,6 @@ - - - - - - - diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.gml b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.gml new file mode 100644 index 00000000000..868cb02e392 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.gml @@ -0,0 +1,16 @@ + + + -5 03 8 + + + + -5 03 8 + -5 0 -1 0 1 1 2 2 3 3 2 5 -1 8 -1 7 1 4 -5 0 + + + diff --git a/python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.xsd b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.xsd new file mode 100644 index 00000000000..b94b03f2d93 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/concave_hull_points_07_geos.xsd @@ -0,0 +1,47 @@ + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml b/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml index 55d10da23e4..98b0d224407 100644 --- a/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml +++ b/python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml @@ -268,6 +268,52 @@ tests: cast: str fid: skip + - algorithm: native:concavehull + name: Concave Hull (GEOS 0.3) + params: + ALPHA: 0.7 + HOLES: true + INPUT: + name: points.gml + type: vector + NO_MULTIGEOMETRY: false + results: + OUTPUT: + name: expected/concave_hull_points_07_geos.gml + type: vector + + - algorithm: native:concavehull + name: Concave Hull (GEOS 0.7) + params: + ALPHA: 0.3 + HOLES: true + INPUT: + name: points.gml + type: vector + NO_MULTIGEOMETRY: false + results: + OUTPUT: + name: expected/concave_hull_points_03_geos.gml + type: vector + + # concave hull tests should be upddated when CI will be using GEOS>=3.11 + # current tests data were generated by Python implementation which produces + # incorrect result by not including all input points in the concave hull + # see https://github.com/qgis/QGIS/issues/54561 + - algorithm: native:concavehull + name: Concave Hull - Points (0.3) + params: + ALPHA: 0.3 + HOLES: true + INPUT: + name: points.gml + type: vector + NO_MULTIGEOMETRY: false + results: + OUTPUT: + name: expected/concave_hull_points_03.gml + type: vector + - algorithm: native:concavehull name: Concave Hull - Points (0.7) params: @@ -281,26 +327,6 @@ tests: OUTPUT: name: expected/concave_hull_points_07.gml type: vector - compare: - geometry: - normalize: True - - - algorithm: native:concavehull - name: Concave Hull - Points (0.9) - params: - ALPHA: 1 - HOLES: true - INPUT: - name: points.gml - type: vector - NO_MULTIGEOMETRY: false - results: - OUTPUT: - name: expected/concave_hull_points_09.gml - type: vector - compare: - geometry: - normalize: True - algorithm: qgis:knearestconcavehull name: K-nearest Neighbor Concave Hull - Points (k=7) diff --git a/src/analysis/processing/qgsalgorithmconcavehull.cpp b/src/analysis/processing/qgsalgorithmconcavehull.cpp index c84e6d87d69..1c659bc83a1 100644 --- a/src/analysis/processing/qgsalgorithmconcavehull.cpp +++ b/src/analysis/processing/qgsalgorithmconcavehull.cpp @@ -90,12 +90,11 @@ QVariantMap QgsConcaveHullAlgorithm::processAlgorithm( const QVariantMap ¶me if ( !sink ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); - QgsGeometry concaveHull; -#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<11 - concaveHullQgis( sink, parameters, context, feedback ); -#else +//~ #if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<11 + //~ concaveHullQgis( sink, parameters, context, feedback ); +//~ #else concaveHullGeos( sink, parameters, feedback ); -#endif +//~ #endif QVariantMap outputs; outputs.insert( QStringLiteral( "OUTPUT" ), dest ); @@ -255,7 +254,7 @@ void QgsConcaveHullAlgorithm::concaveHullQgis( std::unique_ptr< QgsFeatureSink > toDelete << edgesIt.key(); } - edgesIt++; + ++edgesIt; i++; multiStepFeedback.setProgress( i * step ); } diff --git a/src/analysis/processing/qgsalgorithmvoronoipolygons.cpp b/src/analysis/processing/qgsalgorithmvoronoipolygons.cpp index 5bd000c1b22..33009f9ab79 100644 --- a/src/analysis/processing/qgsalgorithmvoronoipolygons.cpp +++ b/src/analysis/processing/qgsalgorithmvoronoipolygons.cpp @@ -209,7 +209,6 @@ QString QgsVoronoiPolygonsAlgorithm::voronoiWithoutAttributes( const QVariantMap QgsFeatureIterator it = mSource->getFeatures( request, QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks ); QgsGeometry allPoints; - QHash< QgsFeatureId, QgsAttributes > attributeCache; double step = mSource->featureCount() > 0 ? 100.0 / mSource->featureCount() : 1;