Skip to content
Permalink
Browse files
[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 4d2c24e850580a9647d224d69ec32a5721bfa531
@@ -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
@@ -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();
@@ -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 );

0 comments on commit 4d2c24e

Please sign in to comment.