fix styling

This commit is contained in:
root676 2021-01-02 23:42:21 +01:00 committed by Nyall Dawson
parent d254d06eb1
commit 1dda44c526
3 changed files with 98 additions and 98 deletions

View File

@ -230,19 +230,19 @@ void QgsCellStatisticsAlgorithm::addSpecificAlgorithmParams()
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "STATISTIC" ), QObject::tr( "Statistic" ), statistics, false, 0, false ) );
}
bool QgsCellStatisticsAlgorithm::prepareSpecificAlgorithmParameters(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
bool QgsCellStatisticsAlgorithm::prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
Q_UNUSED(feedback)
Q_UNUSED( feedback )
//obtain statistic method
mMethod = static_cast<QgsRasterAnalysisUtils::CellValueStatisticMethods>( parameterAsEnum( parameters, QStringLiteral( "STATISTIC" ), context ) );
//force data types on specific functions in the cellstatistics alg if input data types don't match
if (
mMethod == QgsRasterAnalysisUtils::Mean ||
mMethod == QgsRasterAnalysisUtils::StandardDeviation ||
mMethod == QgsRasterAnalysisUtils::Variance ||
(mMethod == QgsRasterAnalysisUtils::Median && (mInputs.size() % 2 == 0) )
)
mMethod == QgsRasterAnalysisUtils::Mean ||
mMethod == QgsRasterAnalysisUtils::StandardDeviation ||
mMethod == QgsRasterAnalysisUtils::Variance ||
( mMethod == QgsRasterAnalysisUtils::Median && ( mInputs.size() % 2 == 0 ) )
)
{
if ( static_cast<int>( mDataType ) < 6 )
mDataType = Qgis::Float32; //force float on mean, stddev and median with equal number of input layers if all inputs are integer
@ -255,7 +255,7 @@ bool QgsCellStatisticsAlgorithm::prepareSpecificAlgorithmParameters(const QVaria
return true;
}
void QgsCellStatisticsAlgorithm::processRasterStack(QgsProcessingFeedback *feedback)
void QgsCellStatisticsAlgorithm::processRasterStack( QgsProcessingFeedback *feedback )
{
int maxWidth = QgsRasterIterator::DEFAULT_MAXIMUM_TILE_WIDTH;
int maxHeight = QgsRasterIterator::DEFAULT_MAXIMUM_TILE_HEIGHT;
@ -413,25 +413,25 @@ QgsCellStatisticsPercentileAlgorithm *QgsCellStatisticsPercentileAlgorithm::crea
void QgsCellStatisticsPercentileAlgorithm::addSpecificAlgorithmParams()
{
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ), QObject::tr( "Method"), QStringList() << "Nearest rank" << "Inclusive linear interpolation (PERCENTILE.INC)" << "Exclusive linear interpolation (PERCENTILE.EXC)", false, 0, false) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "PERCENTILE" ), QObject::tr( "Percentile" ), QgsProcessingParameterNumber::Double, 10, false, 0.0, 1.0) );
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ), QObject::tr( "Method" ), QStringList() << "Nearest rank" << "Inclusive linear interpolation (PERCENTILE.INC)" << "Exclusive linear interpolation (PERCENTILE.EXC)", false, 0, false ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "PERCENTILE" ), QObject::tr( "Percentile" ), QgsProcessingParameterNumber::Double, 10, false, 0.0, 1.0 ) );
}
bool QgsCellStatisticsPercentileAlgorithm::prepareSpecificAlgorithmParameters(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
bool QgsCellStatisticsPercentileAlgorithm::prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
Q_UNUSED(feedback)
mMethod = static_cast< QgsRasterAnalysisUtils::CellValuePercentileMethods >( parameterAsEnum( parameters, QStringLiteral("METHOD"), context) );
Q_UNUSED( feedback )
mMethod = static_cast< QgsRasterAnalysisUtils::CellValuePercentileMethods >( parameterAsEnum( parameters, QStringLiteral( "METHOD" ), context ) );
mPercentile = parameterAsDouble( parameters, QStringLiteral( "PERCENTILE" ), context );
//default percentile output data type to float32 raster if interpolation method is chosen
//otherwise use the most potent data type in the intput raster stack (see prepareAlgorithm() in base class)
if( mMethod != QgsRasterAnalysisUtils::CellValuePercentileMethods::NearestRankPercentile && mDataType < 6)
if ( mMethod != QgsRasterAnalysisUtils::CellValuePercentileMethods::NearestRankPercentile && mDataType < 6 )
mDataType = Qgis::DataType::Float32;
return true;
}
void QgsCellStatisticsPercentileAlgorithm::processRasterStack(QgsProcessingFeedback *feedback)
void QgsCellStatisticsPercentileAlgorithm::processRasterStack( QgsProcessingFeedback *feedback )
{
int maxWidth = QgsRasterIterator::DEFAULT_MAXIMUM_TILE_WIDTH;
@ -554,14 +554,14 @@ QgsCellStatisticsPercentRankFromValueAlgorithm *QgsCellStatisticsPercentRankFrom
void QgsCellStatisticsPercentRankFromValueAlgorithm::addSpecificAlgorithmParams()
{
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ), QObject::tr( "Method"), QStringList() << "Inclusive linear interpolation (PERCENTRANK.INC)" << "Exclusive linear interpolation (PERCENTRANK.EXC)", false, 0, false) );
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ), QObject::tr( "Method" ), QStringList() << "Inclusive linear interpolation (PERCENTRANK.INC)" << "Exclusive linear interpolation (PERCENTRANK.EXC)", false, 0, false ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "VALUE" ), QObject::tr( "Value" ), QgsProcessingParameterNumber::Double, 10, false ) );
}
bool QgsCellStatisticsPercentRankFromValueAlgorithm::prepareSpecificAlgorithmParameters(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
bool QgsCellStatisticsPercentRankFromValueAlgorithm::prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
Q_UNUSED(feedback)
mMethod = static_cast< QgsRasterAnalysisUtils::CellValuePercentRankMethods >( parameterAsEnum( parameters, QStringLiteral("METHOD"), context) );
Q_UNUSED( feedback )
mMethod = static_cast< QgsRasterAnalysisUtils::CellValuePercentRankMethods >( parameterAsEnum( parameters, QStringLiteral( "METHOD" ), context ) );
mValue = parameterAsDouble( parameters, QStringLiteral( "VALUE" ), context );
//output data type always defaults to Float32 because result only ranges between 0 and 1
@ -569,7 +569,7 @@ bool QgsCellStatisticsPercentRankFromValueAlgorithm::prepareSpecificAlgorithmPar
return true;
}
void QgsCellStatisticsPercentRankFromValueAlgorithm::processRasterStack(QgsProcessingFeedback *feedback)
void QgsCellStatisticsPercentRankFromValueAlgorithm::processRasterStack( QgsProcessingFeedback *feedback )
{
int maxWidth = QgsRasterIterator::DEFAULT_MAXIMUM_TILE_WIDTH;
@ -680,7 +680,7 @@ QString QgsCellStatisticsPercentRankFromRasterAlgorithm::shortHelpString() const
"The output raster's extent and resolution is defined by a reference "
"raster. If the input raster layers that do not match the cell size of the reference raster layer will be "
"resampled using nearest neighbor resampling. NoData values in any of the input layers will result in a NoData cell output if the Ignore NoData parameter is not set. "
"The output raster data type will always be Float32." );
"The output raster data type will always be Float32." );
}
QgsCellStatisticsPercentRankFromRasterAlgorithm *QgsCellStatisticsPercentRankFromRasterAlgorithm::createInstance() const
@ -690,15 +690,15 @@ QgsCellStatisticsPercentRankFromRasterAlgorithm *QgsCellStatisticsPercentRankFro
void QgsCellStatisticsPercentRankFromRasterAlgorithm::addSpecificAlgorithmParams()
{
addParameter( new QgsProcessingParameterRasterLayer( QStringLiteral( "INPUT_VALUE_RASTER"), QObject::tr( "Value raster layer") ) );
addParameter( new QgsProcessingParameterBand( QStringLiteral( "VALUE_RASTER_BAND"), QObject::tr( "Value raster band"), 1, QStringLiteral( "VALUE_LAYER" ) ) );
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ), QObject::tr( "Method"), QStringList() << "Inclusive linear interpolation (PERCENTRANK.INC)" << "Exclusive linear interpolation (PERCENTRANK.EXC)", false, 0, false) );
addParameter( new QgsProcessingParameterRasterLayer( QStringLiteral( "INPUT_VALUE_RASTER" ), QObject::tr( "Value raster layer" ) ) );
addParameter( new QgsProcessingParameterBand( QStringLiteral( "VALUE_RASTER_BAND" ), QObject::tr( "Value raster band" ), 1, QStringLiteral( "VALUE_LAYER" ) ) );
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "METHOD" ), QObject::tr( "Method" ), QStringList() << "Inclusive linear interpolation (PERCENTRANK.INC)" << "Exclusive linear interpolation (PERCENTRANK.EXC)", false, 0, false ) );
}
bool QgsCellStatisticsPercentRankFromRasterAlgorithm::prepareSpecificAlgorithmParameters(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
bool QgsCellStatisticsPercentRankFromRasterAlgorithm::prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
Q_UNUSED(feedback)
mMethod = static_cast< QgsRasterAnalysisUtils::CellValuePercentRankMethods >( parameterAsEnum( parameters, QStringLiteral("METHOD"), context) );
Q_UNUSED( feedback )
mMethod = static_cast< QgsRasterAnalysisUtils::CellValuePercentRankMethods >( parameterAsEnum( parameters, QStringLiteral( "METHOD" ), context ) );
QgsRasterLayer *inputValueRaster = parameterAsRasterLayer( parameters, QStringLiteral( "INPUT_VALUE_RASTER" ), context );
if ( !inputValueRaster )
@ -713,7 +713,7 @@ bool QgsCellStatisticsPercentRankFromRasterAlgorithm::prepareSpecificAlgorithmPa
return true;
}
void QgsCellStatisticsPercentRankFromRasterAlgorithm::processRasterStack(QgsProcessingFeedback *feedback)
void QgsCellStatisticsPercentRankFromRasterAlgorithm::processRasterStack( QgsProcessingFeedback *feedback )
{
int maxWidth = QgsRasterIterator::DEFAULT_MAXIMUM_TILE_WIDTH;
int maxHeight = QgsRasterIterator::DEFAULT_MAXIMUM_TILE_HEIGHT;
@ -732,7 +732,7 @@ void QgsCellStatisticsPercentRankFromRasterAlgorithm::processRasterStack(QgsProc
std::unique_ptr< QgsRasterBlock > outputBlock;
while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
{
std::unique_ptr< QgsRasterBlock > valueBlock ( mValueRasterInterface->block( mValueRasterBand, blockExtent, iterCols, iterRows ) );
std::unique_ptr< QgsRasterBlock > valueBlock( mValueRasterInterface->block( mValueRasterBand, blockExtent, iterCols, iterRows ) );
std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : mInputs )
@ -764,7 +764,7 @@ void QgsCellStatisticsPercentRankFromRasterAlgorithm::processRasterStack(QgsProc
std::vector<double> cellValues = QgsRasterAnalysisUtils::getCellValuesFromBlockStack( inputBlocks, row, col, noDataInStack );
int cellValueStackSize = cellValues.size();
if ( noDataInStack && !mIgnoreNoData && !percentRankValueIsNoData)
if ( noDataInStack && !mIgnoreNoData && !percentRankValueIsNoData )
{
outputBlock->setValue( row, col, mNoDataValue );
}

View File

@ -485,9 +485,9 @@ double QgsRasterAnalysisUtils::nearestRankPercentile( std::vector<double> cellVa
std::sort( cellValues.begin(), cellValues.end() );
int i = 0;
if( percentile > 0 )
if ( percentile > 0 )
{
i = static_cast<int>( std::ceil( percentile * static_cast<double>(stackSize) ) - 1 );
i = static_cast<int>( std::ceil( percentile * static_cast<double>( stackSize ) ) - 1 );
}
return cellValues[i];
@ -495,43 +495,43 @@ double QgsRasterAnalysisUtils::nearestRankPercentile( std::vector<double> cellVa
double QgsRasterAnalysisUtils::interpolatedPercentileInc( std::vector<double> cellValues, int stackSize, double percentile )
{
std::sort(cellValues.begin(), cellValues.end() );
double x = ( percentile * (stackSize - 1) );
std::sort( cellValues.begin(), cellValues.end() );
double x = ( percentile * ( stackSize - 1 ) );
int i = static_cast<int>( std::floor( x ) );
double xFraction = std::fmod(x, 1);
double xFraction = std::fmod( x, 1 );
if(stackSize == 1)
if ( stackSize == 1 )
{
return cellValues[0];
}
else if ( stackSize == 2)
else if ( stackSize == 2 )
{
return cellValues[0] + (cellValues[1] - cellValues[0]) * percentile;
return cellValues[0] + ( cellValues[1] - cellValues[0] ) * percentile;
}
else
{
return cellValues[i] + (cellValues[i+1] - cellValues[i]) * xFraction;
return cellValues[i] + ( cellValues[i + 1] - cellValues[i] ) * xFraction;
}
}
double QgsRasterAnalysisUtils::interpolatedPercentileExc( std::vector<double> cellValues, int stackSize, double percentile, double noDataValue )
{
std::sort(cellValues.begin(), cellValues.end() );
double x = ( percentile * (stackSize + 1) );
std::sort( cellValues.begin(), cellValues.end() );
double x = ( percentile * ( stackSize + 1 ) );
int i = static_cast<int>( std::floor( x ) ) - 1;
double xFraction = std::fmod(x, 1);
double lowerExcValue = 1.0 / (static_cast<double>(stackSize) + 1.0);
double upperExcValue = static_cast<double>(stackSize) / (static_cast<double>(stackSize) + 1.0);
double xFraction = std::fmod( x, 1 );
double lowerExcValue = 1.0 / ( static_cast<double>( stackSize ) + 1.0 );
double upperExcValue = static_cast<double>( stackSize ) / ( static_cast<double>( stackSize ) + 1.0 );
if(stackSize < 2 || ( (percentile < lowerExcValue || percentile > upperExcValue)) )
if ( stackSize < 2 || ( ( percentile < lowerExcValue || percentile > upperExcValue ) ) )
{
return noDataValue;
}
else
{
return cellValues[i] + (cellValues[i+1] - cellValues[i]) * xFraction;
return cellValues[i] + ( cellValues[i + 1] - cellValues[i] ) * xFraction;
}
}
@ -539,23 +539,23 @@ double QgsRasterAnalysisUtils::interpolatedPercentRankInc( std::vector<double> c
{
std::sort( cellValues.begin(), cellValues.end() );
if( value < cellValues[0] || value > cellValues[stackSize - 1] )
if ( value < cellValues[0] || value > cellValues[stackSize - 1] )
{
return noDataValue;
}
else
{
for(int i = 0; i < stackSize - 1; i++)
for ( int i = 0; i < stackSize - 1; i++ )
{
if(cellValues[i] <= value && cellValues[i+1] >= value)
if ( cellValues[i] <= value && cellValues[i + 1] >= value )
{
double fraction = 0.0;
//make sure that next number in the distribution is not the same to prevent NaN fractions
if( !qgsDoubleNear( cellValues[i], cellValues[i+1] ) )
fraction = ( value - cellValues[i] ) / ( cellValues[i+1] - cellValues[i] );
if ( !qgsDoubleNear( cellValues[i], cellValues[i + 1] ) )
fraction = ( value - cellValues[i] ) / ( cellValues[i + 1] - cellValues[i] );
return ( fraction + i ) / (stackSize - 1);
return ( fraction + i ) / ( stackSize - 1 );
}
}
return noDataValue;
@ -566,23 +566,23 @@ double QgsRasterAnalysisUtils::interpolatedPercentRankExc( std::vector<double> c
{
std::sort( cellValues.begin(), cellValues.end() );
if( value < cellValues[0] || value > cellValues[stackSize - 1] )
if ( value < cellValues[0] || value > cellValues[stackSize - 1] )
{
return noDataValue;
}
else
{
for (int i = 0; i < stackSize - 1; i++)
for ( int i = 0; i < stackSize - 1; i++ )
{
if(cellValues[i] <= value && cellValues[i+1] >= value)
if ( cellValues[i] <= value && cellValues[i + 1] >= value )
{
double fraction = 0.0;
//make sure that next number in the distribution is not the same to prevent NaN fractions
if( !qgsDoubleNear(cellValues[i], cellValues[i+1]) )
fraction = (value - cellValues[i]) / (cellValues[i+1] - cellValues[i]);
if ( !qgsDoubleNear( cellValues[i], cellValues[i + 1] ) )
fraction = ( value - cellValues[i] ) / ( cellValues[i + 1] - cellValues[i] );
return ( (i + 1) + fraction) / (stackSize + 1);
return ( ( i + 1 ) + fraction ) / ( stackSize + 1 );
}
}
return noDataValue;

View File

@ -2704,21 +2704,21 @@ void TestQgsProcessingAlgs::percentileFunctions_data()
QTest::newRow( "testcase_1" )
<< QgsRasterAnalysisUtils::NearestRankPercentile
<< std::vector<double>({100, 24, 49, 36, 2, 18, 98, 64, 20, 20})
<< std::vector<double>({0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1})
<< std::vector<double>({2, 2, 18, 20, 20, 24, 36, 49, 64, 98, 100});
<< std::vector<double>( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} )
<< std::vector<double>( {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1} )
<< std::vector<double>( {2, 2, 18, 20, 20, 24, 36, 49, 64, 98, 100} );
QTest::newRow( "testcase_2" )
<< QgsRasterAnalysisUtils::InterpolatedPercentileInc
<< std::vector<double>({100, 24, 49, 36, 2, 18, 98, 64, 20, 20})
<< std::vector<double>({0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1})
<< std::vector<double>({2.0,16.4,19.6,20.0,22.4,30.0, 41.2,53.5,70.8,98.2,100});
<< std::vector<double>( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} )
<< std::vector<double>( {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1} )
<< std::vector<double>( {2.0, 16.4, 19.6, 20.0, 22.4, 30.0, 41.2, 53.5, 70.8, 98.2, 100} );
QTest::newRow( "testcase_3" )
<< QgsRasterAnalysisUtils::InterpolatedPercentileExc
<< std::vector<double>({100, 24, 49, 36, 2, 18, 98, 64, 20, 20})
<< std::vector<double>({0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1})
<< std::vector<double>({-9999,3.6,18.4,20,21.6,30, 43.8,59.5,91.2,99.8,-9999});
<< std::vector<double>( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} )
<< std::vector<double>( {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1} )
<< std::vector<double>( {-9999, 3.6, 18.4, 20, 21.6, 30, 43.8, 59.5, 91.2, 99.8, -9999} );
}
void TestQgsProcessingAlgs::percentileFunctions()
@ -2728,33 +2728,33 @@ void TestQgsProcessingAlgs::percentileFunctions()
QFETCH( std::vector<double>, inputPercentiles );
QFETCH( std::vector<double>, expectedValues );
int inputValuesSize = static_cast<int>(inputValues.size());
int percentileSize = static_cast<int>(inputPercentiles.size());
int inputValuesSize = static_cast<int>( inputValues.size() );
int percentileSize = static_cast<int>( inputPercentiles.size() );
double result;
for(int i = 0; i < percentileSize; i++)
for ( int i = 0; i < percentileSize; i++ )
{
double percentile = inputPercentiles[i];
double expectedValue = expectedValues[i];
switch ( function )
{
case( QgsRasterAnalysisUtils::NearestRankPercentile ):
case ( QgsRasterAnalysisUtils::NearestRankPercentile ):
{
result = QgsRasterAnalysisUtils::nearestRankPercentile(inputValues, inputValuesSize, percentile);
QCOMPARE( result , expectedValue );
result = QgsRasterAnalysisUtils::nearestRankPercentile( inputValues, inputValuesSize, percentile );
QCOMPARE( result, expectedValue );
break;
}
case( QgsRasterAnalysisUtils::InterpolatedPercentileInc ):
case ( QgsRasterAnalysisUtils::InterpolatedPercentileInc ):
{
result = QgsRasterAnalysisUtils::interpolatedPercentileInc(inputValues, inputValuesSize, percentile);
QCOMPARE( result, expectedValue);
result = QgsRasterAnalysisUtils::interpolatedPercentileInc( inputValues, inputValuesSize, percentile );
QCOMPARE( result, expectedValue );
break;
}
case( QgsRasterAnalysisUtils::InterpolatedPercentileExc ):
case ( QgsRasterAnalysisUtils::InterpolatedPercentileExc ):
{
result = QgsRasterAnalysisUtils::interpolatedPercentileExc(inputValues, inputValuesSize, percentile, -9999);
QCOMPARE( result, expectedValue);
result = QgsRasterAnalysisUtils::interpolatedPercentileExc( inputValues, inputValuesSize, percentile, -9999 );
QCOMPARE( result, expectedValue );
break;
}
}
@ -2999,15 +2999,15 @@ void TestQgsProcessingAlgs::percentrankFunctions_data()
QTest::newRow( "testcase_1" )
<< QgsRasterAnalysisUtils::InterpolatedPercentRankInc
<< std::vector<double>({100, 24, 49, 36, 2, 18, 98, 64, 20, 20})
<< std::vector<double>({-8,2,18,20,33,47,29,39.5,57,39,12,100,150})
<< std::vector<double>({-9999,0,0.111111111111,0.222222222222,0.527777777778,0.649572649573,0.490740740741,0.58547008547,0.725925925926,0.581196581197,0.0694444444444,1,-9999});
<< std::vector<double>( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} )
<< std::vector<double>( {-8, 2, 18, 20, 33, 47, 29, 39.5, 57, 39, 12, 100, 150} )
<< std::vector<double>( {-9999, 0, 0.111111111111, 0.222222222222, 0.527777777778, 0.649572649573, 0.490740740741, 0.58547008547, 0.725925925926, 0.581196581197, 0.0694444444444, 1, -9999} );
QTest::newRow( "testcase_2" )
<< QgsRasterAnalysisUtils::InterpolatedPercentRankExc
<< std::vector<double>({100, 24, 49, 36, 2, 18, 98, 64, 20, 20})
<< std::vector<double>({-8,2,18,20,33,47,29,39.5,57,39,12,100,150})
<< std::vector<double>({-9999,0.0909090909091,0.1818181818181,0.272727272727,0.522727272727,0.622377622378,0.492424242424,0.56993006993,0.684848484848,0.566433566434,0.1477272727272,0.909090909091,-9999});
<< std::vector<double>( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} )
<< std::vector<double>( {-8, 2, 18, 20, 33, 47, 29, 39.5, 57, 39, 12, 100, 150} )
<< std::vector<double>( {-9999, 0.0909090909091, 0.1818181818181, 0.272727272727, 0.522727272727, 0.622377622378, 0.492424242424, 0.56993006993, 0.684848484848, 0.566433566434, 0.1477272727272, 0.909090909091, -9999} );
}
void TestQgsProcessingAlgs::percentrankFunctions()
@ -3017,37 +3017,37 @@ void TestQgsProcessingAlgs::percentrankFunctions()
QFETCH( std::vector<double>, inputPercentrank );
QFETCH( std::vector<double>, expectedValues );
int inputValuesSize = static_cast<int>(inputValues.size());
int percentrankSize = static_cast<int>(inputPercentrank.size());
int inputValuesSize = static_cast<int>( inputValues.size() );
int percentrankSize = static_cast<int>( inputPercentrank.size() );
double result;
for(int i = 0; i < percentrankSize; i++)
for ( int i = 0; i < percentrankSize; i++ )
{
double percentrank = inputPercentrank[i];
double expectedValue = expectedValues[i];
switch ( function )
{
case( QgsRasterAnalysisUtils::InterpolatedPercentRankInc ):
case ( QgsRasterAnalysisUtils::InterpolatedPercentRankInc ):
{
result = QgsRasterAnalysisUtils::interpolatedPercentRankInc(inputValues, inputValuesSize, percentrank, -9999);
QCOMPARE( result, expectedValue);
result = QgsRasterAnalysisUtils::interpolatedPercentRankInc( inputValues, inputValuesSize, percentrank, -9999 );
QCOMPARE( result, expectedValue );
break;
}
case( QgsRasterAnalysisUtils::InterpolatedPercentRankExc ):
case ( QgsRasterAnalysisUtils::InterpolatedPercentRankExc ):
{
result = QgsRasterAnalysisUtils::interpolatedPercentRankExc(inputValues, inputValuesSize, percentrank, -9999);
QCOMPARE( result, expectedValue);
result = QgsRasterAnalysisUtils::interpolatedPercentRankExc( inputValues, inputValuesSize, percentrank, -9999 );
QCOMPARE( result, expectedValue );
break;
}
}
}
std::vector<double> cellVal = std::vector<double>( {13,36,13,44,60} );
std::vector<double> cellVal = std::vector<double>( {13, 36, 13, 44, 60} );
qDebug() << QgsRasterAnalysisUtils::interpolatedPercentRankInc( cellVal, 5, 13, 200 );
QVERIFY(true);
QVERIFY( true );
}
void TestQgsProcessingAlgs::percentrankByRaster_data()
@ -3204,7 +3204,7 @@ void TestQgsProcessingAlgs::percentrankByRaster()
parameters.insert( QStringLiteral( "VALUE_RASTER_BAND" ), valueLayerBand );
parameters.insert( QStringLiteral( "METHOD" ), method );
parameters.insert( QStringLiteral( "IGNORE_NODATA" ), ignoreNoData );
parameters.insert( QStringLiteral( "OUTPUT_NODATA_VALUE"), noDataValue);
parameters.insert( QStringLiteral( "OUTPUT_NODATA_VALUE" ), noDataValue );
parameters.insert( QStringLiteral( "REFERENCE_LAYER" ), QString( myDataPath + referenceLayer ) );
parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT );
@ -3405,7 +3405,7 @@ void TestQgsProcessingAlgs::percentrankByValue()
parameters.insert( QStringLiteral( "VALUE" ), value );
parameters.insert( QStringLiteral( "METHOD" ), method );
parameters.insert( QStringLiteral( "IGNORE_NODATA" ), ignoreNoData );
parameters.insert( QStringLiteral( "OUTPUT_NODATA_VALUE"), noDataValue);
parameters.insert( QStringLiteral( "OUTPUT_NODATA_VALUE" ), noDataValue );
parameters.insert( QStringLiteral( "REFERENCE_LAYER" ), QString( myDataPath + referenceLayer ) );
parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT );