Skip to content
Permalink
Browse files
Fix data type for feature count in overlay algorithms
  • Loading branch information
nyalldawson committed Jun 8, 2021
1 parent b1f50bb commit fe4544728b3f9bddd1e36bd1f364fea0d2266a83
@@ -106,8 +106,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;
@@ -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 );

@@ -92,8 +92,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() )
@@ -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() )
@@ -82,7 +82,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;
@@ -189,12 +189,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();
@@ -267,14 +267,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

@@ -418,7 +418,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;
@@ -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 );

0 comments on commit fe45447

Please sign in to comment.