Skip to content
Permalink
Browse files

Optimise unordered set differencing

  • Loading branch information
nyalldawson committed Jul 16, 2018
1 parent e46b00d commit 9e03a7e1d3254fbee0268611ff014967050877de
Showing with 7 additions and 14 deletions.
  1. +7 −14 src/analysis/processing/qgsalgorithmdbscanclustering.cpp
@@ -102,16 +102,6 @@ struct KDBushDataHashById
}
};

bool operator <( const QgsSpatialIndexKDBushData &data, const QgsFeatureId id )
{
return data.id < id;
};

bool operator <( const QgsFeatureId id, const QgsSpatialIndexKDBushData &data )
{
return id < data.id;
};

QVariantMap QgsDbscanClusteringAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
@@ -287,10 +277,13 @@ void QgsDbscanClusteringAlgorithm::dbscan( const std::size_t minSize,
if ( within2.size() >= minSize )
{
// expand neighbourhood
std::set_difference( within2.begin(),
within2.end(),
visited.begin(), visited.end(),
std::inserter( within, within.end() ) );
std::copy_if( within2.begin(),
within2.end(),
std::inserter( within, within.end() ),
[&visited]( const QgsSpatialIndexKDBushData & needle )
{
return visited.find( needle.id ) == visited.end();
} );
}
if ( !borderPointsAreNoise || within2.size() >= minSize )
{

0 comments on commit 9e03a7e

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