Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Simplify algorithm should not run validity checks on geo…
…metries

Simplify (by its intrinsic nature) can output invalid geometries,
and its processing is not affected by the presence of input
geometry validity.

Also tag a few other algorithms which aren't sensitive to input
geometry validity.
  • Loading branch information
nyalldawson committed Feb 8, 2019
1 parent 061882d commit 9b6367f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/analysis/processing/qgsalgorithmsimplify.cpp
Expand Up @@ -132,6 +132,11 @@ QgsFeatureList QgsSimplifyAlgorithm::processFeature( const QgsFeature &feature,
return QgsFeatureList() << f;
}

QgsProcessingFeatureSource::Flag QgsSimplifyAlgorithm::sourceFlags() const
{
return QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks;
}

///@endcond


2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmsimplify.h
Expand Up @@ -52,7 +52,7 @@ class QgsSimplifyAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString outputName() const override;
bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback *feedback ) override;

QgsProcessingFeatureSource::Flag sourceFlags() const override;
private:

double mTolerance = 1.0;
Expand Down
5 changes: 5 additions & 0 deletions src/analysis/processing/qgsalgorithmsmooth.cpp
Expand Up @@ -156,6 +156,11 @@ QgsFeatureList QgsSmoothAlgorithm::processFeature( const QgsFeature &feature, Qg
return QgsFeatureList() << f;
}

QgsProcessingFeatureSource::Flag QgsSmoothAlgorithm::sourceFlags() const
{
return QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks;
}

///@endcond


1 change: 1 addition & 0 deletions src/analysis/processing/qgsalgorithmsmooth.h
Expand Up @@ -49,6 +49,7 @@ class QgsSmoothAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QgsProcessing::SourceType outputLayerType() const override;
bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsProcessingFeatureSource::Flag sourceFlags() const override;

private:
int mIterations = 1;
Expand Down
5 changes: 5 additions & 0 deletions src/analysis/processing/qgsalgorithmsnaptogrid.cpp
Expand Up @@ -154,6 +154,11 @@ QgsFeatureList QgsSnapToGridAlgorithm::processFeature( const QgsFeature &feature
return QgsFeatureList() << f;
}

QgsProcessingFeatureSource::Flag QgsSnapToGridAlgorithm::sourceFlags() const
{
return QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks;
}

///@endcond


1 change: 1 addition & 0 deletions src/analysis/processing/qgsalgorithmsnaptogrid.h
Expand Up @@ -47,6 +47,7 @@ class QgsSnapToGridAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString outputName() const override;
bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsProcessingFeatureSource::Flag sourceFlags() const override;

private:
double mIntervalX = 0.0;
Expand Down
5 changes: 5 additions & 0 deletions src/analysis/processing/qgsalgorithmsplitlinesbylength.cpp
Expand Up @@ -144,6 +144,11 @@ QgsFeatureList QgsSplitLinesByLengthAlgorithm::processFeature( const QgsFeature
}
}

QgsProcessingFeatureSource::Flag QgsSplitLinesByLengthAlgorithm::sourceFlags() const
{
return QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks;
}


///@endcond

Expand Down
1 change: 1 addition & 0 deletions src/analysis/processing/qgsalgorithmsplitlinesbylength.h
Expand Up @@ -51,6 +51,7 @@ class QgsSplitLinesByLengthAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString outputName() const override;
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type inputWkbType ) const override;
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsProcessingFeatureSource::Flag sourceFlags() const override;

private:

Expand Down

0 comments on commit 9b6367f

Please sign in to comment.