mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Expose choice of how to handle out-of-class values
This commit is contained in:
parent
18ddc4ec72
commit
dafa384317
@ -60,6 +60,11 @@ void QgsReclassifyAlgorithmBase::initAlgorithm( const QVariantMap &configuration
|
||||
boundsHandling->setFlags( QgsProcessingParameterDefinition::FlagAdvanced );
|
||||
addParameter( boundsHandling.release() );
|
||||
|
||||
std::unique_ptr< QgsProcessingParameterBoolean > missingValuesParam = qgis::make_unique< QgsProcessingParameterBoolean >( QStringLiteral( "NODATA_FOR_MISSING" ),
|
||||
QObject::tr( "Use no data when no range matches value" ), false, false );
|
||||
missingValuesParam->setFlags( QgsProcessingParameterDefinition::FlagAdvanced );
|
||||
addParameter( missingValuesParam.release() );
|
||||
|
||||
addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Reclassified raster" ) ) );
|
||||
}
|
||||
|
||||
@ -80,7 +85,7 @@ bool QgsReclassifyAlgorithmBase::prepareAlgorithm( const QVariantMap ¶meters
|
||||
mNbCellsYProvider = mInterface->ySize();
|
||||
|
||||
mNoDataValue = parameterAsDouble( parameters, QStringLiteral( "NO_DATA" ), context );
|
||||
|
||||
mUseNoDataForMissingValues = parameterAsBool( parameters, QStringLiteral( "NODATA_FOR_MISSING" ), context );
|
||||
|
||||
int boundsType = parameterAsEnum( parameters, QStringLiteral( "RANGE_BOUNDARIES" ), context );
|
||||
switch ( boundsType )
|
||||
@ -107,7 +112,7 @@ bool QgsReclassifyAlgorithmBase::prepareAlgorithm( const QVariantMap ¶meters
|
||||
|
||||
QVariantMap QgsReclassifyAlgorithmBase::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
|
||||
{
|
||||
QVector< QgsReclassifyUtils::RasterClass > classes = createClasses( parameters, context, feedback );
|
||||
QVector< QgsReclassifyUtils::RasterClass > classes = createClasses( mBoundsType, parameters, context, feedback );
|
||||
|
||||
const QString outputFile = parameterAsOutputLayer( parameters, QStringLiteral( "OUTPUT" ), context );
|
||||
QFileInfo fi( outputFile );
|
||||
@ -122,7 +127,8 @@ QVariantMap QgsReclassifyAlgorithmBase::processAlgorithm( const QVariantMap &par
|
||||
|
||||
provider->setNoDataValue( 1, mNoDataValue );
|
||||
|
||||
QgsReclassifyUtils::reclassify( classes, mInterface.get(), mBand, mExtent, mNbCellsXProvider, mNbCellsYProvider, provider.get(), mNoDataValue, feedback );
|
||||
QgsReclassifyUtils::reclassify( classes, mInterface.get(), mBand, mExtent, mNbCellsXProvider, mNbCellsYProvider, provider.get(), mNoDataValue, mUseNoDataForMissingValues,
|
||||
feedback );
|
||||
|
||||
QVariantMap outputs;
|
||||
outputs.insert( QStringLiteral( "OUTPUT" ), outputFile );
|
||||
|
@ -73,6 +73,7 @@ class QgsReclassifyAlgorithmBase : public QgsProcessingAlgorithm
|
||||
int mNbCellsXProvider = 0;
|
||||
int mNbCellsYProvider = 0;
|
||||
QgsReclassifyUtils::RasterClass::BoundsType mBoundsType = QgsReclassifyUtils::RasterClass::IncludeMax;
|
||||
bool mUseNoDataForMissingValues = false;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -124,7 +125,8 @@ class QgsReclassifyByTableAlgorithm : public QgsReclassifyAlgorithmBase
|
||||
|
||||
void addAlgorithmParams() override;
|
||||
bool _prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
|
||||
QVector< QgsReclassifyUtils::RasterClass > createClasses( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
|
||||
QVector< QgsReclassifyUtils::RasterClass > createClasses( QgsReclassifyUtils::RasterClass::BoundsType boundsType,
|
||||
const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user