Skip to content
Permalink
Browse files

[processing] Use bulk spatial index loader in Delete Duplicates algor…

…ithm

Cuts processing time to 70% of original for a 3 million point input file
(debug build)
  • Loading branch information
nyalldawson committed Jan 1, 2020
1 parent fe6abba commit c46e89f7de121d015a3baf99a1050d4835779b38
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/analysis/processing/qgsalgorithmdeleteduplicategeometries.cpp
@@ -93,13 +93,11 @@ QVariantMap QgsDeleteDuplicateGeometriesAlgorithm::processAlgorithm( const QVari
double step = mSource->featureCount() > 0 ? 100.0 / mSource->featureCount() : 0;
QHash< QgsFeatureId, QgsGeometry > geometries;
QSet< QgsFeatureId > nullGeometryFeatures;
QgsSpatialIndex index;
QgsFeature f;
long current = 0;
while ( it.nextFeature( f ) )
QgsSpatialIndex index( it, [&]( const QgsFeature & f ) ->bool
{
if ( feedback->isCanceled() )
break;
return false;

if ( !f.hasGeometry() )
{
@@ -108,13 +106,15 @@ QVariantMap QgsDeleteDuplicateGeometriesAlgorithm::processAlgorithm( const QVari
else
{
geometries.insert( f.id(), f.geometry() );
index.addFeature( f );
}

// overall this loop takes about 10% of time
current++;
feedback->setProgress( 0.10 * current * step );
}
return true;
} );

QgsFeature f;

// start by assuming everything is unique, and chop away at this list
QHash< QgsFeatureId, QgsGeometry > uniqueFeatures = geometries;

0 comments on commit c46e89f

Please sign in to comment.
You can’t perform that action at this time.