From cc42df15d51e1aeda330bf20450779d607d067e1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:35:44 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../qgsalgorithmcheckgeometryangle.cpp | 10 +- .../qgsalgorithmcheckgeometryangle.h | 5 +- .../qgsalgorithmcheckgeometryarea.cpp | 12 +- .../qgsalgorithmcheckgeometryarea.h | 5 +- .../qgsalgorithmcheckgeometryhole.cpp | 10 +- .../qgsalgorithmcheckgeometryhole.h | 4 +- ...qgsalgorithmcheckgeometrymissingvertex.cpp | 10 +- .../qgsalgorithmcheckgeometrymissingvertex.h | 4 +- .../qgsalgorithmfixgeometryangle.cpp | 74 ++++---- .../processing/qgsalgorithmfixgeometryangle.h | 9 +- .../qgsalgorithmfixgeometryarea.cpp | 86 ++++----- .../processing/qgsalgorithmfixgeometryarea.h | 9 +- .../qgsalgorithmfixgeometryhole.cpp | 74 ++++---- .../processing/qgsalgorithmfixgeometryhole.h | 9 +- .../qgsalgorithmfixgeometrymissingvertex.cpp | 74 ++++---- .../qgsalgorithmfixgeometrymissingvertex.h | 9 +- .../testqgsprocessingcheckgeometry.cpp | 44 ++--- .../analysis/testqgsprocessingfixgeometry.cpp | 163 +++++++++--------- 18 files changed, 288 insertions(+), 323 deletions(-) diff --git a/src/analysis/processing/qgsalgorithmcheckgeometryangle.cpp b/src/analysis/processing/qgsalgorithmcheckgeometryangle.cpp index e0e930fa29c8..506a0adb5164 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometryangle.cpp +++ b/src/analysis/processing/qgsalgorithmcheckgeometryangle.cpp @@ -83,8 +83,7 @@ void QgsGeometryCheckAngleAlgorithm::initAlgorithm( const QVariantMap &configura addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorAnyGeometry ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } @@ -128,11 +127,11 @@ auto QgsGeometryCheckAngleAlgorithm::processAlgorithm( const QVariantMap ¶me QgsFields fields = outputFields(); fields.append( uniqueIdField ); - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); - const std::unique_ptr< QgsFeatureSink > sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); + const std::unique_ptr sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); if ( !sink_errors ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -165,13 +164,12 @@ auto QgsGeometryCheckAngleAlgorithm::processAlgorithm( const QVariantMap ¶me multiStepFeedback.setCurrentStep( 3 ); feedback->setProgressText( QObject::tr( "Exporting errors…" ) ); - const double step{checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1}; + const double step { checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1 }; long i = 0; feedback->setProgress( 0.0 ); for ( const QgsGeometryCheckError *error : checkErrors ) { - if ( feedback->isCanceled() ) { break; diff --git a/src/analysis/processing/qgsalgorithmcheckgeometryangle.h b/src/analysis/processing/qgsalgorithmcheckgeometryangle.h index 4477a386b73e..a5ef674b047b 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometryangle.h +++ b/src/analysis/processing/qgsalgorithmcheckgeometryangle.h @@ -29,7 +29,6 @@ class QgsGeometryCheckAngleAlgorithm : public QgsProcessingAlgorithm { public: - QgsGeometryCheckAngleAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -42,10 +41,8 @@ class QgsGeometryCheckAngleAlgorithm : public QgsProcessingAlgorithm QgsGeometryCheckAngleAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - QVariantMap processAlgorithm( const QVariantMap ¶meters, - QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; + QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; private: QgsFeaturePool *createFeaturePool( QgsVectorLayer *layer ) const; diff --git a/src/analysis/processing/qgsalgorithmcheckgeometryarea.cpp b/src/analysis/processing/qgsalgorithmcheckgeometryarea.cpp index 2ea83118ace9..7358a18e7adc 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometryarea.cpp +++ b/src/analysis/processing/qgsalgorithmcheckgeometryarea.cpp @@ -55,7 +55,7 @@ auto QgsGeometryCheckAreaAlgorithm::shortHelpString() const -> QString return QObject::tr( "This algorithm check the area of geometry (polygon)." ); } -auto QgsGeometryCheckAreaAlgorithm::flags() const -> Qgis::ProcessingAlgorithmFlags +auto QgsGeometryCheckAreaAlgorithm::flags() const -> Qgis::ProcessingAlgorithmFlags { return QgsProcessingAlgorithm::flags() | Qgis::ProcessingAlgorithmFlag::NoThreading; } @@ -83,8 +83,7 @@ void QgsGeometryCheckAreaAlgorithm::initAlgorithm( const QVariantMap &configurat addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorPolygon ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } @@ -126,11 +125,11 @@ auto QgsGeometryCheckAreaAlgorithm::processAlgorithm( const QVariantMap ¶met QgsFields fields = outputFields(); fields.append( uniqueIdField ); - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); - const std::unique_ptr< QgsFeatureSink > sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); + const std::unique_ptr sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); if ( !sink_errors ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -163,13 +162,12 @@ auto QgsGeometryCheckAreaAlgorithm::processAlgorithm( const QVariantMap ¶met multiStepFeedback.setCurrentStep( 3 ); feedback->setProgressText( QObject::tr( "Exporting errors…" ) ); - const double step{checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1}; + const double step { checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1 }; long i = 0; feedback->setProgress( 0.0 ); for ( QgsGeometryCheckError *error : checkErrors ) { - if ( feedback->isCanceled() ) { break; diff --git a/src/analysis/processing/qgsalgorithmcheckgeometryarea.h b/src/analysis/processing/qgsalgorithmcheckgeometryarea.h index bb35a8d00593..70cd6ee6c663 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometryarea.h +++ b/src/analysis/processing/qgsalgorithmcheckgeometryarea.h @@ -28,7 +28,6 @@ class QgsGeometryCheckAreaAlgorithm : public QgsProcessingAlgorithm { public: - QgsGeometryCheckAreaAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -41,10 +40,8 @@ class QgsGeometryCheckAreaAlgorithm : public QgsProcessingAlgorithm QgsGeometryCheckAreaAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - QVariantMap processAlgorithm( const QVariantMap ¶meters, - QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; + QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; private: int mTolerance { 8 }; diff --git a/src/analysis/processing/qgsalgorithmcheckgeometryhole.cpp b/src/analysis/processing/qgsalgorithmcheckgeometryhole.cpp index 42e6a4145044..6be2e9f8addb 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometryhole.cpp +++ b/src/analysis/processing/qgsalgorithmcheckgeometryhole.cpp @@ -82,8 +82,7 @@ void QgsGeometryCheckHoleAlgorithm::initAlgorithm( const QVariantMap &configurat addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorPolygon ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } @@ -126,11 +125,11 @@ auto QgsGeometryCheckHoleAlgorithm::processAlgorithm( const QVariantMap ¶met QgsFields fields = outputFields(); fields.append( uniqueIdField ); - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); - const std::unique_ptr< QgsFeatureSink > sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); + const std::unique_ptr sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); if ( !sink_errors ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -159,13 +158,12 @@ auto QgsGeometryCheckHoleAlgorithm::processAlgorithm( const QVariantMap ¶met multiStepFeedback.setCurrentStep( 3 ); feedback->setProgressText( QObject::tr( "Exporting errors…" ) ); - const double step{checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1}; + const double step { checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1 }; long i = 0; feedback->setProgress( 0.0 ); for ( QgsGeometryCheckError *error : checkErrors ) { - if ( feedback->isCanceled() ) { break; diff --git a/src/analysis/processing/qgsalgorithmcheckgeometryhole.h b/src/analysis/processing/qgsalgorithmcheckgeometryhole.h index eb2a6bafbfa6..1399e8c0c73e 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometryhole.h +++ b/src/analysis/processing/qgsalgorithmcheckgeometryhole.h @@ -28,7 +28,6 @@ class QgsGeometryCheckHoleAlgorithm : public QgsProcessingAlgorithm { public: - QgsGeometryCheckHoleAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -41,13 +40,12 @@ class QgsGeometryCheckHoleAlgorithm : public QgsProcessingAlgorithm QgsGeometryCheckHoleAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; static QgsFields outputFields(); private: - int mTolerance{8}; + int mTolerance { 8 }; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.cpp b/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.cpp index fa9a2843e490..2f4e0d59dd1c 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.cpp +++ b/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.cpp @@ -82,8 +82,7 @@ void QgsGeometryCheckMissingVertexAlgorithm::initAlgorithm( const QVariantMap &c addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorPolygon ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } @@ -126,11 +125,11 @@ auto QgsGeometryCheckMissingVertexAlgorithm::processAlgorithm( const QVariantMap QgsFields fields = outputFields(); fields.append( uniqueIdField ); - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, fields, input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); - const std::unique_ptr< QgsFeatureSink > sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); + const std::unique_ptr sink_errors( parameterAsSink( parameters, QStringLiteral( "ERRORS" ), context, dest_errors, fields, Qgis::WkbType::Point, input->sourceCrs() ) ); if ( !sink_errors ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -158,13 +157,12 @@ auto QgsGeometryCheckMissingVertexAlgorithm::processAlgorithm( const QVariantMap multiStepFeedback.setCurrentStep( 3 ); feedback->setProgressText( QObject::tr( "Exporting errors…" ) ); - const double step{checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1}; + const double step { checkErrors.size() > 0 ? 100.0 / checkErrors.size() : 1 }; long i = 0; feedback->setProgress( 0.0 ); for ( QgsGeometryCheckError *error : checkErrors ) { - if ( feedback->isCanceled() ) { break; diff --git a/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.h b/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.h index 7139e09dd11d..7df6526cf6a2 100644 --- a/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.h +++ b/src/analysis/processing/qgsalgorithmcheckgeometrymissingvertex.h @@ -28,7 +28,6 @@ class QgsGeometryCheckMissingVertexAlgorithm : public QgsProcessingAlgorithm { public: - QgsGeometryCheckMissingVertexAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -41,13 +40,12 @@ class QgsGeometryCheckMissingVertexAlgorithm : public QgsProcessingAlgorithm QgsGeometryCheckMissingVertexAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; static QgsFields outputFields(); private: - int mTolerance{8}; + int mTolerance { 8 }; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmfixgeometryangle.cpp b/src/analysis/processing/qgsalgorithmfixgeometryangle.cpp index 370b487c4034..f49dbee60304 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometryangle.cpp +++ b/src/analysis/processing/qgsalgorithmfixgeometryangle.cpp @@ -68,49 +68,50 @@ void QgsFixGeometryAngleAlgorithm::initAlgorithm( const QVariantMap &configurati Q_UNUSED( configuration ) // Inputs - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ) - ); - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) - ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ) + ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), - QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) ) - ); + QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), + QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), - QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), + QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), - QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), + QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), - QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), + QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); // Outputs addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorAnyGeometry ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "REPORT" ), QObject::tr( "Report layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } auto QgsFixGeometryAngleAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) -> QVariantMap { - const std::unique_ptr< QgsProcessingFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); + const std::unique_ptr input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); if ( !input ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) ); - const std::unique_ptr< QgsProcessingFeatureSource > errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); + const std::unique_ptr errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); if ( !errors ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -139,7 +140,7 @@ auto QgsFixGeometryAngleAlgorithm::processAlgorithm( const QVariantMap ¶mete throw QgsProcessingException( QObject::tr( "Field %1 does not have the same type than in errors layer." ).arg( featIdFieldName ) ); QString dest_output; - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); @@ -147,7 +148,7 @@ auto QgsFixGeometryAngleAlgorithm::processAlgorithm( const QVariantMap ¶mete QgsFields reportFields = errors->fields(); reportFields.append( QgsField( QStringLiteral( "report" ), QMetaType::QString ) ); reportFields.append( QgsField( QStringLiteral( "error_fixed" ), QMetaType::Bool ) ); - const std::unique_ptr< QgsFeatureSink > sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); + const std::unique_ptr sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); if ( !sink_report ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "REPORT" ) ) ); @@ -200,15 +201,15 @@ auto QgsFixGeometryAngleAlgorithm::processAlgorithm( const QVariantMap ¶mete else { QgsGeometryCheckError checkError = QgsGeometryCheckError( - &check, - QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), - errorFeature.geometry().asPoint(), - QgsVertexId( - errorFeature.attribute( partIdxFieldName ).toInt(), - errorFeature.attribute( ringIdxFieldName ).toInt(), - errorFeature.attribute( vertexIdxFieldName ).toInt() - ) - ); + &check, + QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), + errorFeature.geometry().asPoint(), + QgsVertexId( + errorFeature.attribute( partIdxFieldName ).toInt(), + errorFeature.attribute( ringIdxFieldName ).toInt(), + errorFeature.attribute( vertexIdxFieldName ).toInt() + ) + ); for ( auto changes : changesList ) checkError.handleChanges( changes ); @@ -220,7 +221,6 @@ auto QgsFixGeometryAngleAlgorithm::processAlgorithm( const QVariantMap ¶mete if ( !sink_report->addFeature( reportFeature, QgsFeatureSink::FastInsert ) ) throw QgsProcessingException( writeFeatureError( sink_report.get(), parameters, QStringLiteral( "REPORT" ) ) ); - } multiStepFeedback.setProgress( 100 ); diff --git a/src/analysis/processing/qgsalgorithmfixgeometryangle.h b/src/analysis/processing/qgsalgorithmfixgeometryangle.h index 24938648d8f4..75c77077af82 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometryangle.h +++ b/src/analysis/processing/qgsalgorithmfixgeometryangle.h @@ -28,7 +28,6 @@ class QgsFixGeometryAngleAlgorithm : public QgsProcessingAlgorithm { public: - QgsFixGeometryAngleAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -41,13 +40,11 @@ class QgsFixGeometryAngleAlgorithm : public QgsProcessingAlgorithm QgsFixGeometryAngleAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - QVariantMap processAlgorithm( const QVariantMap ¶meters, - QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - private: + QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - int mTolerance{8}; + private: + int mTolerance { 8 }; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmfixgeometryarea.cpp b/src/analysis/processing/qgsalgorithmfixgeometryarea.cpp index 1f8c1d56159c..e45406796d2e 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometryarea.cpp +++ b/src/analysis/processing/qgsalgorithmfixgeometryarea.cpp @@ -64,12 +64,10 @@ void QgsFixGeometryAreaAlgorithm::initAlgorithm( const QVariantMap &configuratio Q_UNUSED( configuration ) // Inputs - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) ) - ); - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) - ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) ) + ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) + ); // Specific inputs for this check QStringList methods; @@ -77,53 +75,56 @@ void QgsFixGeometryAreaAlgorithm::initAlgorithm( const QVariantMap &configuratio // const QVariantMap config; // QgsGeometryCheckContext *context; //!\ uninitialized context to retrieve resolution methods ontly (which should perhaps be a static method?) QList checkMethods = QgsGeometryAreaCheck( nullptr, QVariantMap() ).availableResolutionMethods(); - std::transform( checkMethods.cbegin(), checkMethods.cend() - 2, std::inserter( methods, methods.begin() ), - []( const QgsGeometryCheckResolutionMethod & checkMethod ) { return checkMethod.name(); } ); + std::transform( checkMethods.cbegin(), checkMethods.cend() - 2, std::inserter( methods, methods.begin() ), []( const QgsGeometryCheckResolutionMethod &checkMethod ) { return checkMethod.name(); } ); } addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ), QObject::tr( "Method" ), methods ) ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "MERGE_ATTRIBUTE" ), QObject::tr( "Field to consider when merging polygons with the identical attribue method" ), - QString(), QStringLiteral( "INPUT" ), - Qgis::ProcessingFieldParameterDataType::Any, false, true ) - ); + QStringLiteral( "MERGE_ATTRIBUTE" ), QObject::tr( "Field to consider when merging polygons with the identical attribue method" ), + QString(), QStringLiteral( "INPUT" ), + Qgis::ProcessingFieldParameterDataType::Any, false, true + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), - QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) ) - ); + QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), + QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), - QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), + QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), - QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), + QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), - QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), + QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); // Outputs addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorPolygon ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "REPORT" ), QObject::tr( "Report layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } auto QgsFixGeometryAreaAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) -> QVariantMap { - const std::unique_ptr< QgsProcessingFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); + const std::unique_ptr input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); if ( !input ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) ); - const std::unique_ptr< QgsProcessingFeatureSource > errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); + const std::unique_ptr errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); if ( !errors ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -156,7 +157,7 @@ auto QgsFixGeometryAreaAlgorithm::processAlgorithm( const QVariantMap ¶meter throw QgsProcessingException( QObject::tr( "Field %1 does not have the same type than in errors layer." ).arg( featIdFieldName ) ); QString dest_output; - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); @@ -164,7 +165,7 @@ auto QgsFixGeometryAreaAlgorithm::processAlgorithm( const QVariantMap ¶meter QgsFields reportFields = errors->fields(); reportFields.append( QgsField( QStringLiteral( "report" ), QMetaType::QString ) ); reportFields.append( QgsField( QStringLiteral( "error_fixed" ), QMetaType::Bool ) ); - const std::unique_ptr< QgsFeatureSink > sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); + const std::unique_ptr sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); if ( !sink_report ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "REPORT" ) ) ); @@ -231,15 +232,15 @@ auto QgsFixGeometryAreaAlgorithm::processAlgorithm( const QVariantMap ¶meter else { QgsGeometryCheckError checkError = QgsGeometryCheckError( - &check, - QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), - errorFeature.geometry().asPoint(), - QgsVertexId( - errorFeature.attribute( partIdxFieldName ).toInt(), - errorFeature.attribute( ringIdxFieldName ).toInt(), - errorFeature.attribute( vertexIdxFieldName ).toInt() - ) - ); + &check, + QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), + errorFeature.geometry().asPoint(), + QgsVertexId( + errorFeature.attribute( partIdxFieldName ).toInt(), + errorFeature.attribute( ringIdxFieldName ).toInt(), + errorFeature.attribute( vertexIdxFieldName ).toInt() + ) + ); for ( auto changes : changesList ) checkError.handleChanges( changes ); @@ -251,7 +252,6 @@ auto QgsFixGeometryAreaAlgorithm::processAlgorithm( const QVariantMap ¶meter if ( !sink_report->addFeature( reportFeature, QgsFeatureSink::FastInsert ) ) throw QgsProcessingException( writeFeatureError( sink_report.get(), parameters, QStringLiteral( "REPORT" ) ) ); - } multiStepFeedback.setProgress( 100 ); diff --git a/src/analysis/processing/qgsalgorithmfixgeometryarea.h b/src/analysis/processing/qgsalgorithmfixgeometryarea.h index 0247c39be13d..24332e781e64 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometryarea.h +++ b/src/analysis/processing/qgsalgorithmfixgeometryarea.h @@ -28,7 +28,6 @@ class QgsFixGeometryAreaAlgorithm : public QgsProcessingAlgorithm { public: - QgsFixGeometryAreaAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -41,13 +40,11 @@ class QgsFixGeometryAreaAlgorithm : public QgsProcessingAlgorithm QgsFixGeometryAreaAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - QVariantMap processAlgorithm( const QVariantMap ¶meters, - QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - private: + QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - int mTolerance{8}; + private: + int mTolerance { 8 }; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmfixgeometryhole.cpp b/src/analysis/processing/qgsalgorithmfixgeometryhole.cpp index 60cccb938669..be7345c1e83d 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometryhole.cpp +++ b/src/analysis/processing/qgsalgorithmfixgeometryhole.cpp @@ -66,49 +66,50 @@ void QgsFixGeometryHoleAlgorithm::initAlgorithm( const QVariantMap &configuratio Q_UNUSED( configuration ) // Inputs - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ) - ); - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) - ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ) + ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), - QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) ) - ); + QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), + QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), - QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), + QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), - QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), + QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), - QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), + QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); // Outputs addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorAnyGeometry ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "REPORT" ), QObject::tr( "Report layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } auto QgsFixGeometryHoleAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) -> QVariantMap { - const std::unique_ptr< QgsProcessingFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); + const std::unique_ptr input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); if ( !input ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) ); - const std::unique_ptr< QgsProcessingFeatureSource > errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); + const std::unique_ptr errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); if ( !errors ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -137,7 +138,7 @@ auto QgsFixGeometryHoleAlgorithm::processAlgorithm( const QVariantMap ¶meter throw QgsProcessingException( QObject::tr( "Field %1 does not have the same type than in errors layer." ).arg( featIdFieldName ) ); QString dest_output; - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); @@ -145,7 +146,7 @@ auto QgsFixGeometryHoleAlgorithm::processAlgorithm( const QVariantMap ¶meter QgsFields reportFields = errors->fields(); reportFields.append( QgsField( QStringLiteral( "report" ), QMetaType::QString ) ); reportFields.append( QgsField( QStringLiteral( "error_fixed" ), QMetaType::Bool ) ); - const std::unique_ptr< QgsFeatureSink > sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); + const std::unique_ptr sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); if ( !sink_report ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "REPORT" ) ) ); @@ -195,15 +196,15 @@ auto QgsFixGeometryHoleAlgorithm::processAlgorithm( const QVariantMap ¶meter else { QgsGeometryCheckError checkError = QgsGeometryCheckError( - &check, - QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), - errorFeature.geometry().asPoint(), - QgsVertexId( - errorFeature.attribute( partIdxFieldName ).toInt(), - errorFeature.attribute( ringIdxFieldName ).toInt(), - errorFeature.attribute( vertexIdxFieldName ).toInt() - ) - ); + &check, + QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), + errorFeature.geometry().asPoint(), + QgsVertexId( + errorFeature.attribute( partIdxFieldName ).toInt(), + errorFeature.attribute( ringIdxFieldName ).toInt(), + errorFeature.attribute( vertexIdxFieldName ).toInt() + ) + ); for ( auto changes : changesList ) checkError.handleChanges( changes ); @@ -215,7 +216,6 @@ auto QgsFixGeometryHoleAlgorithm::processAlgorithm( const QVariantMap ¶meter if ( !sink_report->addFeature( reportFeature, QgsFeatureSink::FastInsert ) ) throw QgsProcessingException( writeFeatureError( sink_report.get(), parameters, QStringLiteral( "REPORT" ) ) ); - } multiStepFeedback.setProgress( 100 ); diff --git a/src/analysis/processing/qgsalgorithmfixgeometryhole.h b/src/analysis/processing/qgsalgorithmfixgeometryhole.h index 8cba99e0a52b..4239590931b7 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometryhole.h +++ b/src/analysis/processing/qgsalgorithmfixgeometryhole.h @@ -28,7 +28,6 @@ class QgsFixGeometryHoleAlgorithm : public QgsProcessingAlgorithm { public: - QgsFixGeometryHoleAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -41,13 +40,11 @@ class QgsFixGeometryHoleAlgorithm : public QgsProcessingAlgorithm QgsFixGeometryHoleAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - QVariantMap processAlgorithm( const QVariantMap ¶meters, - QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - private: + QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - int mTolerance{8}; + private: + int mTolerance { 8 }; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.cpp b/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.cpp index aab3444a6cf0..a07df8c369ce 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.cpp +++ b/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.cpp @@ -64,50 +64,51 @@ void QgsFixGeometryMissingVertexAlgorithm::initAlgorithm( const QVariantMap &con Q_UNUSED( configuration ) // Inputs - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) ) - ); - addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), - QList< int >() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) - ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) ) + ); + addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "ERRORS" ), QObject::tr( "Errors layer" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), - QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) ) - ); + QStringLiteral( "UNIQUE_ID" ), QObject::tr( "Field of original feature unique identifier" ), + QStringLiteral( "id" ), QStringLiteral( "ERRORS" ) + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), - QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "PART_IDX" ), QObject::tr( "Field of part index" ), + QStringLiteral( "gc_partidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), - QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "RING_IDX" ), QObject::tr( "Field of ring index" ), + QStringLiteral( "gc_ringidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); addParameter( new QgsProcessingParameterField( - QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), - QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), - Qgis::ProcessingFieldParameterDataType::Numeric ) - ); + QStringLiteral( "VERTEX_IDX" ), QObject::tr( "Field of vertex index" ), + QStringLiteral( "gc_vertidx" ), QStringLiteral( "ERRORS" ), + Qgis::ProcessingFieldParameterDataType::Numeric + ) + ); // Outputs addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ), Qgis::ProcessingSourceType::VectorPolygon ) ); addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "REPORT" ), QObject::tr( "Report layer" ), Qgis::ProcessingSourceType::VectorPoint ) ); - std::unique_ptr< QgsProcessingParameterNumber > tolerance = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "TOLERANCE" ), - QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); + std::unique_ptr tolerance = std::make_unique( QStringLiteral( "TOLERANCE" ), QObject::tr( "Tolerance" ), Qgis::ProcessingNumberParameterType::Integer, 8, false, 1, 13 ); tolerance->setFlags( tolerance->flags() | Qgis::ProcessingParameterFlag::Advanced ); addParameter( tolerance.release() ); } auto QgsFixGeometryMissingVertexAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) -> QVariantMap { - const std::unique_ptr< QgsProcessingFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); + const std::unique_ptr input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); if ( !input ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) ); - const std::unique_ptr< QgsProcessingFeatureSource > errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); + const std::unique_ptr errors( parameterAsSource( parameters, QStringLiteral( "ERRORS" ), context ) ); if ( !errors ) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "ERRORS" ) ) ); @@ -136,7 +137,7 @@ auto QgsFixGeometryMissingVertexAlgorithm::processAlgorithm( const QVariantMap & throw QgsProcessingException( QObject::tr( "Field %1 does not have the same type than in errors layer." ).arg( featIdFieldName ) ); QString dest_output; - const std::unique_ptr< QgsFeatureSink > sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); + const std::unique_ptr sink_output( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest_output, input->fields(), input->wkbType(), input->sourceCrs() ) ); if ( !sink_output ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) ); @@ -144,7 +145,7 @@ auto QgsFixGeometryMissingVertexAlgorithm::processAlgorithm( const QVariantMap & QgsFields reportFields = errors->fields(); reportFields.append( QgsField( QStringLiteral( "report" ), QMetaType::QString ) ); reportFields.append( QgsField( QStringLiteral( "error_fixed" ), QMetaType::Bool ) ); - const std::unique_ptr< QgsFeatureSink > sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); + const std::unique_ptr sink_report( parameterAsSink( parameters, QStringLiteral( "REPORT" ), context, dest_report, reportFields, errors->wkbType(), errors->sourceCrs() ) ); if ( !sink_report ) throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "REPORT" ) ) ); @@ -195,15 +196,15 @@ auto QgsFixGeometryMissingVertexAlgorithm::processAlgorithm( const QVariantMap & else { QgsGeometryCheckError checkError = QgsGeometryCheckError( - &check, - QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), - errorFeature.geometry().asPoint(), - QgsVertexId( - errorFeature.attribute( partIdxFieldName ).toInt(), - errorFeature.attribute( ringIdxFieldName ).toInt(), - errorFeature.attribute( vertexIdxFieldName ).toInt() - ) - ); + &check, + QgsGeometryCheckerUtils::LayerFeature( featurePool.get(), inputFeature, checkContext.get(), false ), + errorFeature.geometry().asPoint(), + QgsVertexId( + errorFeature.attribute( partIdxFieldName ).toInt(), + errorFeature.attribute( ringIdxFieldName ).toInt(), + errorFeature.attribute( vertexIdxFieldName ).toInt() + ) + ); for ( auto changes : changesList ) checkError.handleChanges( changes ); @@ -215,7 +216,6 @@ auto QgsFixGeometryMissingVertexAlgorithm::processAlgorithm( const QVariantMap & if ( !sink_report->addFeature( reportFeature, QgsFeatureSink::FastInsert ) ) throw QgsProcessingException( writeFeatureError( sink_report.get(), parameters, QStringLiteral( "REPORT" ) ) ); - } multiStepFeedback.setProgress( 100 ); diff --git a/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.h b/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.h index ac9a44176315..b239b3492717 100644 --- a/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.h +++ b/src/analysis/processing/qgsalgorithmfixgeometrymissingvertex.h @@ -28,7 +28,6 @@ class QgsFixGeometryMissingVertexAlgorithm : public QgsProcessingAlgorithm { public: - QgsFixGeometryMissingVertexAlgorithm() = default; void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; QString name() const override; @@ -41,13 +40,11 @@ class QgsFixGeometryMissingVertexAlgorithm : public QgsProcessingAlgorithm QgsFixGeometryMissingVertexAlgorithm *createInstance() const override SIP_FACTORY; protected: - bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - QVariantMap processAlgorithm( const QVariantMap ¶meters, - QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - private: + QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - int mTolerance{8}; + private: + int mTolerance { 8 }; }; ///@endcond PRIVATE diff --git a/tests/src/analysis/testqgsprocessingcheckgeometry.cpp b/tests/src/analysis/testqgsprocessingcheckgeometry.cpp index 8882aab20c2c..c521dc932811 100644 --- a/tests/src/analysis/testqgsprocessingcheckgeometry.cpp +++ b/tests/src/analysis/testqgsprocessingcheckgeometry.cpp @@ -20,18 +20,19 @@ #include "qgstest.h" #include "qgsvectorlayer.h" -class TestQgsProcessingCheckGeometry: public QgsTest +class TestQgsProcessingCheckGeometry : public QgsTest { Q_OBJECT public: - TestQgsProcessingCheckGeometry() : QgsTest( QStringLiteral( "Processing Algorithms Check Geometry" ) ) {} + TestQgsProcessingCheckGeometry() + : QgsTest( QStringLiteral( "Processing Algorithms Check Geometry" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void angleAlg_data(); void angleAlg(); @@ -41,7 +42,6 @@ class TestQgsProcessingCheckGeometry: public QgsTest void missingVertexAlg(); private: - QgsVectorLayer *mLineLayer = nullptr; QgsVectorLayer *mPolygonLayer = nullptr; }; @@ -99,7 +99,7 @@ void TestQgsProcessingCheckGeometry::angleAlg() layerToTest->selectByIds( QgsFeatureIds() << 0 << 1 ); - std::unique_ptr< QgsProcessingAlgorithm > alg( + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:checkgeometryangle" ) ) ); QVERIFY( alg != nullptr ); @@ -113,15 +113,15 @@ void TestQgsProcessingCheckGeometry::angleAlg() bool ok = false; QgsProcessingFeedback feedback; - const std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + const std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - const std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - const std::unique_ptr errorsLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); + const std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + const std::unique_ptr errorsLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); QVERIFY( outputLayer->isValid() ); QVERIFY( errorsLayer->isValid() ); QCOMPARE( outputLayer->featureCount(), expectedErrorCount ); @@ -130,7 +130,7 @@ void TestQgsProcessingCheckGeometry::angleAlg() void TestQgsProcessingCheckGeometry::areaAlg() { - std::unique_ptr< QgsProcessingAlgorithm > alg( + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:checkgeometryarea" ) ) ); QVERIFY( alg != nullptr ); @@ -144,14 +144,14 @@ void TestQgsProcessingCheckGeometry::areaAlg() bool ok = false; QgsProcessingFeedback feedback; - const std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + const std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - const std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - const std::unique_ptr errorsLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); + const std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + const std::unique_ptr errorsLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); QVERIFY( outputLayer->isValid() ); QVERIFY( errorsLayer->isValid() ); QCOMPARE( outputLayer->featureCount(), 8 ); @@ -160,7 +160,7 @@ void TestQgsProcessingCheckGeometry::areaAlg() void TestQgsProcessingCheckGeometry::holeAlg() { - const std::unique_ptr< QgsProcessingAlgorithm > alg( + const std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:checkgeometryhole" ) ) ); QVERIFY( alg != nullptr ); @@ -173,14 +173,14 @@ void TestQgsProcessingCheckGeometry::holeAlg() bool ok = false; QgsProcessingFeedback feedback; - const std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + const std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - std::unique_ptr errorsLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); + std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + std::unique_ptr errorsLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); QVERIFY( outputLayer->isValid() ); QVERIFY( errorsLayer->isValid() ); QCOMPARE( outputLayer->featureCount(), 1 ); @@ -189,7 +189,7 @@ void TestQgsProcessingCheckGeometry::holeAlg() void TestQgsProcessingCheckGeometry::missingVertexAlg() { - const std::unique_ptr< QgsProcessingAlgorithm > alg( + const std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:checkgeometrymissingvertex" ) ) ); QVERIFY( alg != nullptr ); @@ -205,14 +205,14 @@ void TestQgsProcessingCheckGeometry::missingVertexAlg() bool ok = false; QgsProcessingFeedback feedback; - const std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + const std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - const std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - const std::unique_ptr errorsLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); + const std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + const std::unique_ptr errorsLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "ERRORS" ) ).toString() ) ) ); QVERIFY( outputLayer->isValid() ); QVERIFY( errorsLayer->isValid() ); QCOMPARE( outputLayer->featureCount(), 5 ); diff --git a/tests/src/analysis/testqgsprocessingfixgeometry.cpp b/tests/src/analysis/testqgsprocessingfixgeometry.cpp index 005223d6b941..08df893cc12f 100644 --- a/tests/src/analysis/testqgsprocessingfixgeometry.cpp +++ b/tests/src/analysis/testqgsprocessingfixgeometry.cpp @@ -19,18 +19,19 @@ #include "qgstest.h" #include "qgsvectorlayer.h" -class TestQgsProcessingFixGeometry: public QgsTest +class TestQgsProcessingFixGeometry : public QgsTest { Q_OBJECT public: - TestQgsProcessingFixGeometry() : QgsTest( QStringLiteral( "Processing Algorithms Fix Geometry" ) ) {} + TestQgsProcessingFixGeometry() + : QgsTest( QStringLiteral( "Processing Algorithms Fix Geometry" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void fixAngleAlg_data(); void fixAngleAlg(); @@ -42,8 +43,7 @@ class TestQgsProcessingFixGeometry: public QgsTest void fixMissingVertexAlg(); private: - const QDir mDataDir{ QDir( TEST_DATA_DIR ).absoluteFilePath( QStringLiteral( "geometry_fix" ) ) }; - + const QDir mDataDir { QDir( TEST_DATA_DIR ).absoluteFilePath( QStringLiteral( "geometry_fix" ) ) }; }; void TestQgsProcessingFixGeometry::initTestCase() @@ -86,37 +86,33 @@ void TestQgsProcessingFixGeometry::fixAngleAlg_data() polygonsFinalVertexCount.insert( "5", 5 ); QTest::newRow( "Lines" ) - << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=lines" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) - << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=lines_vertex_to_delete" ), - QStringLiteral( "lines vertex to delete" ), QStringLiteral( "ogr" ) ) - << ( QStringList() - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) ) - << linesFinalVertexCount; + << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=lines" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) + << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=lines_vertex_to_delete" ), QStringLiteral( "lines vertex to delete" ), QStringLiteral( "ogr" ) ) + << ( QStringList() + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) ) + << linesFinalVertexCount; QTest::newRow( "Polygon" ) - << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=polygons" ), - QStringLiteral( "polygons" ), QStringLiteral( "ogr" ) ) - << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=polygons_vertex_to_delete" ), - QStringLiteral( "polygons vertex to delete" ), QStringLiteral( "ogr" ) ) - << ( QStringList() - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Resulting geometry is degenerate" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) - << QStringLiteral( "Delete node with small angle" ) ) - << polygonsFinalVertexCount; + << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=polygons" ), QStringLiteral( "polygons" ), QStringLiteral( "ogr" ) ) + << new QgsVectorLayer( mDataDir.absoluteFilePath( "delete_vertex.gpkg|layername=polygons_vertex_to_delete" ), QStringLiteral( "polygons vertex to delete" ), QStringLiteral( "ogr" ) ) + << ( QStringList() + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Resulting geometry is degenerate" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) + << QStringLiteral( "Delete node with small angle" ) ) + << polygonsFinalVertexCount; } void TestQgsProcessingFixGeometry::fixAngleAlg() @@ -130,7 +126,7 @@ void TestQgsProcessingFixGeometry::fixAngleAlg() QVERIFY( sourceLayer->isValid() ); QVERIFY( errorsLayer->isValid() ); - const std::unique_ptr< QgsProcessingAlgorithm > alg( + const std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:fixgeometryangle" ) ) ); QVERIFY( alg != nullptr ); @@ -144,14 +140,14 @@ void TestQgsProcessingFixGeometry::fixAngleAlg() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - std::unique_ptr reportLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); + std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + std::unique_ptr reportLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); QVERIFY( reportLayer->isValid() ); QVERIFY( outputLayer->isValid() ); @@ -171,7 +167,7 @@ void TestQgsProcessingFixGeometry::fixAngleAlg() int nbVertices = 0; QgsFeature feat; outputLayer->getFeatures( QgsFeatureRequest( QString( "\"fid\" = %1" ).arg( it.key() ) ) ).nextFeature( feat ); - QgsVertexIterator vit = feat.geometry().vertices(); + QgsVertexIterator vit = feat.geometry().vertices(); while ( vit.hasNext() ) { vit.next(); @@ -188,45 +184,44 @@ void TestQgsProcessingFixGeometry::fixAreaAlg_data() QTest::addColumn( "method" ); QTest::newRow( "Merge with longest shared edge" ) - << ( QStringList() - << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) - << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) ) - << 0; + << ( QStringList() + << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) + << QStringLiteral( "Merge with neighboring polygon with longest shared edge" ) ) + << 0; QTest::newRow( "Merge with largest area" ) - << ( QStringList() - << QStringLiteral( "Merge with neighboring polygon with largest area" ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Merge with neighboring polygon with largest area" ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Failed to merge with neighbor: " ) - << QStringLiteral( "Merge with neighboring polygon with largest area" ) - << QStringLiteral( "Merge with neighboring polygon with largest area" ) ) - << 1; + << ( QStringList() + << QStringLiteral( "Merge with neighboring polygon with largest area" ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Merge with neighboring polygon with largest area" ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Failed to merge with neighbor: " ) + << QStringLiteral( "Merge with neighboring polygon with largest area" ) + << QStringLiteral( "Merge with neighboring polygon with largest area" ) ) + << 1; QTest::newRow( "Merge with identical attribute value" ) - << ( QStringList() - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) - << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) ) - << 2; + << ( QStringList() + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) + << QStringLiteral( "Merge with neighboring polygon with identical attribute value, if any, or leave as is" ) ) + << 2; } void TestQgsProcessingFixGeometry::fixAreaAlg() { - const QDir testDataDir( QDir( TEST_DATA_DIR ).absoluteFilePath( "geometry_checker" ) ); QgsVectorLayer sourceLayer = QgsVectorLayer( testDataDir.absoluteFilePath( "polygon_layer.shp" ), QStringLiteral( "polygons" ), QStringLiteral( "ogr" ) ); QgsVectorLayer errorsLayer = QgsVectorLayer( mDataDir.absoluteFilePath( "merge_polygons.gpkg|layername=errors_layer" ), QString(), QStringLiteral( "ogr" ) ); @@ -236,7 +231,7 @@ void TestQgsProcessingFixGeometry::fixAreaAlg() QVERIFY( sourceLayer.isValid() ); QVERIFY( errorsLayer.isValid() ); - const std::unique_ptr< QgsProcessingAlgorithm > alg( + const std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:fixgeometryarea" ) ) ); QVERIFY( alg != nullptr ); @@ -253,14 +248,14 @@ void TestQgsProcessingFixGeometry::fixAreaAlg() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - const std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - const std::unique_ptr reportLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); + const std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + const std::unique_ptr reportLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); QVERIFY( reportLayer->isValid() ); QVERIFY( outputLayer->isValid() ); @@ -284,7 +279,7 @@ void TestQgsProcessingFixGeometry::fixHoleAlg() QVERIFY( errorsLayer.isValid() ); const QStringList reportList = QStringList() << QStringLiteral( "Remove hole" ); - const std::unique_ptr< QgsProcessingAlgorithm > alg( + const std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:fixgeometryhole" ) ) ); QVERIFY( alg != nullptr ); @@ -298,14 +293,14 @@ void TestQgsProcessingFixGeometry::fixHoleAlg() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - const std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - const std::unique_ptr reportLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); + const std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + const std::unique_ptr reportLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); QVERIFY( reportLayer->isValid() ); QVERIFY( outputLayer->isValid() ); @@ -334,7 +329,7 @@ void TestQgsProcessingFixGeometry::fixMissingVertexAlg() << QStringLiteral( "Add missing vertex" ) << QStringLiteral( "Add missing vertex" ); - const std::unique_ptr< QgsProcessingAlgorithm > alg( + const std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:fixgeometrymissingvertex" ) ) ); QVERIFY( alg != nullptr ); @@ -348,14 +343,14 @@ void TestQgsProcessingFixGeometry::fixMissingVertexAlg() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - const std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); - const std::unique_ptr reportLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); + const std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + const std::unique_ptr reportLayer( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "REPORT" ) ).toString() ) ) ); QVERIFY( reportLayer->isValid() ); QVERIFY( outputLayer->isValid() );