Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix data type for feature count in overlay algorithms
  • Loading branch information
nyalldawson committed Jun 8, 2021
1 parent 1f25ba5 commit 839afe9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmdifference.cpp
Expand Up @@ -101,8 +101,8 @@ QVariantMap QgsDifferenceAlgorithm::processAlgorithm( const QVariantMap &paramet
QVariantMap outputs;
outputs.insert( QStringLiteral( "OUTPUT" ), dest );

int count = 0;
int total = sourceA->featureCount();
long count = 0;
const long total = sourceA->featureCount();
QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputA );

return outputs;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmintersection.cpp
Expand Up @@ -109,8 +109,8 @@ QVariantMap QgsIntersectionAlgorithm::processAlgorithm( const QVariantMap &param
QVariantMap outputs;
outputs.insert( QStringLiteral( "OUTPUT" ), dest );

int count = 0;
int total = sourceA->featureCount();
long count = 0;
const long total = sourceA->featureCount();

QgsOverlayUtils::intersection( *sourceA, *sourceB, *sink, context, feedback, count, total, fieldIndicesA, fieldIndicesB );

Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmsymmetricaldifference.cpp
Expand Up @@ -87,8 +87,8 @@ QVariantMap QgsSymmetricalDifferenceAlgorithm::processAlgorithm( const QVariantM
QVariantMap outputs;
outputs.insert( QStringLiteral( "OUTPUT" ), dest );

int count = 0;
int total = sourceA->featureCount() + sourceB->featureCount();
long count = 0;
const long total = sourceA->featureCount() + sourceB->featureCount();

QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputAB );
if ( feedback->isCanceled() )
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmunion.cpp
Expand Up @@ -102,8 +102,8 @@ QVariantMap QgsUnionAlgorithm::processAlgorithm( const QVariantMap &parameters,
QList<int> fieldIndicesA = QgsProcessingUtils::fieldNamesToIndices( QStringList(), sourceA->fields() );
QList<int> fieldIndicesB = QgsProcessingUtils::fieldNamesToIndices( QStringList(), sourceB->fields() );

int count = 0;
int total = sourceA->featureCount() * 2 + sourceB->featureCount();
long count = 0;
const long total = sourceA->featureCount() * 2 + sourceB->featureCount();

QgsOverlayUtils::intersection( *sourceA, *sourceB, *sink, context, feedback, count, total, fieldIndicesA, fieldIndicesB );
if ( feedback->isCanceled() )
Expand Down
14 changes: 7 additions & 7 deletions src/analysis/processing/qgsoverlayutils.cpp
Expand Up @@ -81,7 +81,7 @@ static bool sanitizeDifferenceResult( QgsGeometry &geom, QgsWkbTypes::GeometryTy
}


void QgsOverlayUtils::difference( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, int &count, int totalCount, QgsOverlayUtils::DifferenceOutput outputAttrs )
void QgsOverlayUtils::difference( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long &count, long totalCount, QgsOverlayUtils::DifferenceOutput outputAttrs )
{
QgsWkbTypes::GeometryType geometryType = QgsWkbTypes::geometryType( QgsWkbTypes::multiType( sourceA.wkbType() ) );
QgsFeatureRequest requestB;
Expand Down Expand Up @@ -188,12 +188,12 @@ void QgsOverlayUtils::difference( const QgsFeatureSource &sourceA, const QgsFeat
}

++count;
feedback->setProgress( count / ( double ) totalCount * 100. );
feedback->setProgress( count / static_cast< double >( totalCount ) * 100. );
}
}


void QgsOverlayUtils::intersection( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, int &count, int totalCount, const QList<int> &fieldIndicesA, const QList<int> &fieldIndicesB )
void QgsOverlayUtils::intersection( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long &count, long totalCount, const QList<int> &fieldIndicesA, const QList<int> &fieldIndicesB )
{
QgsWkbTypes::GeometryType geometryType = QgsWkbTypes::geometryType( QgsWkbTypes::multiType( sourceA.wkbType() ) );
int attrCount = fieldIndicesA.count() + fieldIndicesB.count();
Expand Down Expand Up @@ -266,14 +266,14 @@ void QgsOverlayUtils::intersection( const QgsFeatureSource &sourceA, const QgsFe
}

++count;
feedback->setProgress( count / ( double ) totalCount * 100. );
feedback->setProgress( count / static_cast<double >( totalCount ) * 100. );
}
}

void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatureSink &sink, QgsProcessingFeedback *feedback )
{
int count = 0;
int totalCount = source.featureCount();
long count = 0;
const long totalCount = source.featureCount();
if ( totalCount == 0 )
return; // nothing to do here

Expand Down Expand Up @@ -417,7 +417,7 @@ void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatur
}

++count;
feedback->setProgress( count / ( double ) totalCount * 100. );
feedback->setProgress( count / static_cast< double >( totalCount ) * 100. );
}
if ( feedback->isCanceled() )
return;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsoverlayutils.h
Expand Up @@ -41,9 +41,9 @@ namespace QgsOverlayUtils
OutputBA, //!< Write attributes of both layers, inverted (first attributes of B, then attributes of A)
};

void difference( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, int &count, int totalCount, DifferenceOutput outputAttrs );
void difference( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long &count, long totalCount, DifferenceOutput outputAttrs );

void intersection( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, int &count, int totalCount, const QList<int> &fieldIndicesA, const QList<int> &fieldIndicesB );
void intersection( const QgsFeatureSource &sourceA, const QgsFeatureSource &sourceB, QgsFeatureSink &sink, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long &count, long totalCount, const QList<int> &fieldIndicesA, const QList<int> &fieldIndicesB );

//! Makes sure that what came out from intersection of two geometries is good to be used in the output
bool sanitizeIntersectionResult( QgsGeometry &geom, QgsWkbTypes::GeometryType geometryType );
Expand Down

0 comments on commit 839afe9

Please sign in to comment.