[processing] Adjust st-dbscan algorithm to new duration parameter, change default unit to hours

This commit is contained in:
Mathieu Pellerin 2021-09-04 22:15:34 +07:00 committed by Nyall Dawson
parent 85c5ad6c2a
commit 4d2c24e850
3 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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();

View File

@ -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 );