From 32a01d1d32eea447b254c720d374a9057159166a Mon Sep 17 00:00:00 2001 From: root676 Date: Fri, 25 Oct 2019 20:20:42 +0200 Subject: [PATCH] optimize handling of missing geometries and zero count densification --- .../qgsalgorithmdensifygeometriesbycount.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/analysis/processing/qgsalgorithmdensifygeometriesbycount.cpp b/src/analysis/processing/qgsalgorithmdensifygeometriesbycount.cpp index 6e429dee4d3..d342ec8b4e2 100644 --- a/src/analysis/processing/qgsalgorithmdensifygeometriesbycount.cpp +++ b/src/analysis/processing/qgsalgorithmdensifygeometriesbycount.cpp @@ -81,7 +81,7 @@ void QgsDensifyGeometriesByCountAlgorithm::initParameters( const QVariantMap &co QgsProcessingParameterNumber::Integer, 1, false, 1, 10000000 ); verticesCnt->setIsDynamic( true ); - verticesCnt->setDynamicPropertyDefinition( QgsPropertyDefinition( QStringLiteral( "VerticesCount" ), QObject::tr( "Vertices count" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) ); + verticesCnt->setDynamicPropertyDefinition( QgsPropertyDefinition( QStringLiteral( "VerticesCount" ), QObject::tr( "Vertices count" ), QgsPropertyDefinition::IntegerPositive ) ); verticesCnt->setDynamicLayerParameterName( QStringLiteral( "INPUT" ) ); addParameter( verticesCnt.release() ); } @@ -107,14 +107,18 @@ QgsFeatureList QgsDensifyGeometriesByCountAlgorithm::processFeature( const QgsFe { Q_UNUSED( context ) Q_UNUSED( feedback ) + QgsFeature densifiedFeature = feature; - int verticesCnt = mVerticesCnt; - if ( mDynamicVerticesCnt ) - verticesCnt = mVerticesCntProperty.valueAsInt( context.expressionContext(), verticesCnt ); - if ( feature.hasGeometry() ) - densifiedFeature.setGeometry( feature.geometry().densifyByCount( verticesCnt ) ); + { + int verticesCnt = mVerticesCnt; + if ( mDynamicVerticesCnt ) + verticesCnt = mVerticesCntProperty.valueAsInt( context.expressionContext(), verticesCnt ); + + if ( verticesCnt > 0 ) + densifiedFeature.setGeometry( feature.geometry().densifyByCount( verticesCnt ) ); + } return QgsFeatureList() << densifiedFeature; }