Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Adjust st-dbscan algorithm to new duration parameter, ch…
…ange default unit to hours
  • Loading branch information
nirvn authored and nyalldawson committed Sep 6, 2021
1 parent 85c5ad6 commit 4d2c24e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Expand Up @@ -884,7 +884,7 @@ tests:
DATETIME_FIELD: date
DBSCAN*: false
EPS: 5.0
EPS2: 1000.0
EPS2: 86400000.0
FIELD_NAME: CLUSTER_ID
INPUT:
name: custom/points_with_date.shp
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmdbscanclustering.cpp
Expand Up @@ -114,7 +114,7 @@ QVariantMap QgsDbscanClusteringAlgorithm::processAlgorithm( const QVariantMap &p

const std::size_t minSize = static_cast< std::size_t>( parameterAsInt( parameters, QStringLiteral( "MIN_SIZE" ), context ) );
const double eps1 = parameterAsDouble( parameters, QStringLiteral( "EPS" ), context );
const double eps2 = parameterAsDouble( parameters, QStringLiteral( "EPS2" ), context ) * 24 * 60 * 60;
const double eps2 = parameterAsDouble( parameters, QStringLiteral( "EPS2" ), context );
const bool borderPointsAreNoise = parameterAsBoolean( parameters, QStringLiteral( "DBSCAN*" ), context );

QgsFields outputFields = source->fields();
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/processing/qgsalgorithmstdbscanclustering.cpp
Expand Up @@ -61,10 +61,10 @@ void QgsStDbscanClusteringAlgorithm::initAlgorithm( const QVariantMap & )
QgsProcessingParameterNumber::Integer, 5, false, 1 ) );
addParameter( new QgsProcessingParameterDistance( QStringLiteral( "EPS" ),
QObject::tr( "Maximum distance between clustered points" ), 1, QStringLiteral( "INPUT" ), false, 0 ) );
QgsProcessingParameterDuration *durationParameter = new QgsProcessingParameterDuration( QStringLiteral( "EPS2" ),
QObject::tr( "Maximum time duration between clustered points" ), 0, false, 0 );
durationParameter->setDefaultUnit( QgsUnitTypes::TemporalDays );
addParameter( durationParameter );
auto durationParameter = std::make_unique<QgsProcessingParameterDuration>( QStringLiteral( "EPS2" ),
QObject::tr( "Maximum time duration between clustered points" ), 0, false, 0 );
durationParameter->setDefaultUnit( QgsUnitTypes::TemporalHours );
addParameter( durationParameter.release() );

auto dbscanStarParam = std::make_unique<QgsProcessingParameterBoolean>( QStringLiteral( "DBSCAN*" ),
QObject::tr( "Treat border points as noise (DBSCAN*)" ), false, true );
Expand Down

0 comments on commit 4d2c24e

Please sign in to comment.