Skip to content
Permalink
Browse files
Promote Qgis::DataType to enum class
  • Loading branch information
nyalldawson committed May 27, 2021
1 parent d80ebab commit b4fea529f1679c9a497573c99cc3f6a83a925748
Showing with 743 additions and 676 deletions.
  1. +31 −0 python/core/auto_additions/qgis.py
  2. +3 −3 python/core/auto_generated/qgis.sip.in
  3. +4 −1 python/core/auto_generated/raster/qgscontrastenhancement.sip.in
  4. +1 −1 python/core/auto_generated/raster/qgsrasterblock.sip.in
  5. +1 −0 python/core/auto_generated/raster/qgsrasterchecker.sip.in
  6. +3 −1 scripts/sipify.pl
  7. +3 −3 src/3d/symbols/qgspointcloud3dsymbol.cpp
  8. +2 −2 src/3d/terrain/qgsdemterraintileloader_p.cpp
  9. +4 −4 src/analysis/processing/qgsalgorithmcellstatistics.cpp
  10. +16 −16 src/analysis/processing/qgsalgorithmconstantraster.cpp
  11. +1 −1 src/analysis/processing/qgsalgorithmexportmesh.cpp
  12. +1 −1 src/analysis/processing/qgsalgorithmfuzzifyraster.h
  13. +2 −2 src/analysis/processing/qgsalgorithmlinedensity.cpp
  14. +66 −66 src/analysis/processing/qgsalgorithmrandomraster.cpp
  15. +2 −2 src/analysis/processing/qgsalgorithmrasterfrequencybycomparisonoperator.cpp
  16. +1 −1 src/analysis/processing/qgsalgorithmrasterlogicalop.cpp
  17. +1 −1 src/analysis/processing/qgsalgorithmrasterlogicalop.h
  18. +2 −2 src/analysis/processing/qgsalgorithmrastersampling.cpp
  19. +1 −1 src/analysis/processing/qgsalgorithmrasterstackposition.cpp
  20. +1 −1 src/analysis/processing/qgsalgorithmreclassifybylayer.cpp
  21. +1 −1 src/analysis/processing/qgsalgorithmreclassifybylayer.h
  22. +1 −1 src/analysis/processing/qgsalgorithmrescaleraster.cpp
  23. +5 −5 src/analysis/processing/qgsalgorithmroundrastervalues.cpp
  24. +1 −1 src/analysis/processing/qgsalgorithmvectorize.h
  25. +12 −12 src/analysis/processing/qgsrasteranalysisutils.cpp
  26. +1 −1 src/analysis/processing/qgsrasteranalysisutils.h
  27. +3 −3 src/app/3d/qgspointcloud3dsymbolwidget.cpp
  28. +2 −2 src/app/qgisapp.cpp
  29. +2 −2 src/core/mesh/qgsmeshlayerinterpolator.cpp
  30. +1 −1 src/core/pointcloud/qgspointcloudrendererregistry.cpp
  31. +3 −3 src/core/pointcloud/qgspointcloudrgbrenderer.cpp
  32. +23 −23 src/core/providers/gdal/qgsgdalprovider.cpp
  33. +13 −13 src/core/providers/gdal/qgsgdalproviderbase.cpp
  34. +8 −8 src/core/qgis.h
  35. +6 −6 src/core/raster/qgsbrightnesscontrastfilter.cpp
  36. +1 −1 src/core/raster/qgscliptominmaxenhancement.cpp
  37. +1 −1 src/core/raster/qgscontrastenhancement.cpp
  38. +32 −29 src/core/raster/qgscontrastenhancement.h
  39. +1 −1 src/core/raster/qgscontrastenhancementfunction.cpp
  40. +1 −1 src/core/raster/qgshillshaderenderer.cpp
  41. +6 −6 src/core/raster/qgshuesaturationfilter.cpp
  42. +2 −2 src/core/raster/qgsmultibandcolorrenderer.cpp
  43. +1 −1 src/core/raster/qgspalettedrasterrenderer.cpp
  44. +12 −12 src/core/raster/qgsraster.cpp
  45. +59 −59 src/core/raster/qgsrasterblock.cpp
  46. +34 −34 src/core/raster/qgsrasterblock.h
  47. +8 −0 src/core/raster/qgsrasterchecker.cpp
  48. +13 −0 src/core/raster/qgsrasterchecker.h
  49. +1 −1 src/core/raster/qgsrastercontourrenderer.cpp
  50. +17 −17 src/core/raster/qgsrasterfilewriter.cpp
  51. +11 −11 src/core/raster/qgsrasterinterface.cpp
  52. +5 −2 src/core/raster/qgsrasterinterface.h
  53. +14 −14 src/core/raster/qgsrasterlayer.cpp
  54. +1 −1 src/core/raster/qgsrasternuller.cpp
  55. +1 −1 src/core/raster/qgsrasterprojector.cpp
  56. +3 −3 src/core/raster/qgsrasterrenderer.cpp
  57. +5 −5 src/core/raster/qgsrasterresamplefilter.cpp
  58. +5 −5 src/core/raster/qgssinglebandcolordatarenderer.cpp
  59. +1 −1 src/core/raster/qgssinglebandgrayrenderer.cpp
  60. +1 −1 src/core/raster/qgssinglebandpseudocolorrenderer.cpp
  61. +3 −3 src/gui/pointcloud/qgspointcloudrgbrendererwidget.cpp
  62. +2 −2 src/gui/qgsrasterlayersaveasdialog.cpp
  63. +11 −11 src/gui/raster/qgsrasterhistogramwidget.cpp
  64. +4 −4 src/gui/raster/qgsrasterlayerproperties.cpp
  65. +4 −4 src/gui/raster/qgsrastertransparencywidget.cpp
  66. +2 −2 src/providers/arcgisrest/qgsamsprovider.h
  67. +7 −4 src/providers/grass/qgis.r.in.cpp
  68. +17 −17 src/providers/grass/qgsgrassgislib.cpp
  69. +24 −24 src/providers/grass/qgsgrassimport.cpp
  70. +4 −4 src/providers/grass/qgsgrassrasterprovider.cpp
  71. +7 −7 src/providers/wcs/qgswcsprovider.cpp
  72. +1 −1 src/providers/wms/qgswmsprovider.cpp
  73. +103 −103 tests/src/analysis/testqgsprocessingalgs.cpp
  74. +3 −3 tests/src/analysis/testqgsrastercalculator.cpp
  75. +10 −10 tests/src/analysis/testqgsreclassifyutils.cpp
  76. +3 −3 tests/src/core/testcontrastenhancements.cpp
  77. +60 −60 tests/src/core/testqgsgdalprovider.cpp
  78. +1 −1 tests/src/core/testqgsmeshlayerinterpolator.cpp
  79. +3 −3 tests/src/core/testqgsrasterblock.cpp
  80. +9 −9 tests/src/core/testqgsrasterfilewriter.cpp
  81. +1 −1 tests/src/providers/testqgswcspublicservers.cpp
@@ -17,6 +17,37 @@
QgsMapLayer.PointCloudLayer.__doc__ = "Added in 3.18"
QgsMapLayerType.__doc__ = 'Types of layers that can be added to a map\n\n.. versionadded:: 3.8\n\n' + '* ``VectorLayer``: ' + QgsMapLayerType.VectorLayer.__doc__ + '\n' + '* ``RasterLayer``: ' + QgsMapLayerType.RasterLayer.__doc__ + '\n' + '* ``PluginLayer``: ' + QgsMapLayerType.PluginLayer.__doc__ + '\n' + '* ``MeshLayer``: ' + QgsMapLayerType.MeshLayer.__doc__ + '\n' + '* ``VectorTileLayer``: ' + QgsMapLayerType.VectorTileLayer.__doc__ + '\n' + '* ``AnnotationLayer``: ' + QgsMapLayerType.AnnotationLayer.__doc__ + '\n' + '* ``PointCloudLayer``: ' + QgsMapLayerType.PointCloudLayer.__doc__
# --
# monkey patching scoped based enum
Qgis.UnknownDataType = Qgis.DataType.UnknownDataType
Qgis.UnknownDataType.__doc__ = "Unknown or unspecified type"
Qgis.Byte = Qgis.DataType.Byte
Qgis.Byte.__doc__ = "Eight bit unsigned integer (quint8)"
Qgis.UInt16 = Qgis.DataType.UInt16
Qgis.UInt16.__doc__ = "Sixteen bit unsigned integer (quint16)"
Qgis.Int16 = Qgis.DataType.Int16
Qgis.Int16.__doc__ = "Sixteen bit signed integer (qint16)"
Qgis.UInt32 = Qgis.DataType.UInt32
Qgis.UInt32.__doc__ = "Thirty two bit unsigned integer (quint32)"
Qgis.Int32 = Qgis.DataType.Int32
Qgis.Int32.__doc__ = "Thirty two bit signed integer (qint32)"
Qgis.Float32 = Qgis.DataType.Float32
Qgis.Float32.__doc__ = "Thirty two bit floating point (float)"
Qgis.Float64 = Qgis.DataType.Float64
Qgis.Float64.__doc__ = "Sixty four bit floating point (double)"
Qgis.CInt16 = Qgis.DataType.CInt16
Qgis.CInt16.__doc__ = "Complex Int16"
Qgis.CInt32 = Qgis.DataType.CInt32
Qgis.CInt32.__doc__ = "Complex Int32"
Qgis.CFloat32 = Qgis.DataType.CFloat32
Qgis.CFloat32.__doc__ = "Complex Float32"
Qgis.CFloat64 = Qgis.DataType.CFloat64
Qgis.CFloat64.__doc__ = "Complex Float64"
Qgis.ARGB32 = Qgis.DataType.ARGB32
Qgis.ARGB32.__doc__ = "Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32"
Qgis.ARGB32_Premultiplied = Qgis.DataType.ARGB32_Premultiplied
Qgis.ARGB32_Premultiplied.__doc__ = "Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied"
Qgis.DataType.__doc__ = 'Raster data types.\nThis is modified and extended copy of GDALDataType.\n\n' + '* ``UnknownDataType``: ' + Qgis.DataType.UnknownDataType.__doc__ + '\n' + '* ``Byte``: ' + Qgis.DataType.Byte.__doc__ + '\n' + '* ``UInt16``: ' + Qgis.DataType.UInt16.__doc__ + '\n' + '* ``Int16``: ' + Qgis.DataType.Int16.__doc__ + '\n' + '* ``UInt32``: ' + Qgis.DataType.UInt32.__doc__ + '\n' + '* ``Int32``: ' + Qgis.DataType.Int32.__doc__ + '\n' + '* ``Float32``: ' + Qgis.DataType.Float32.__doc__ + '\n' + '* ``Float64``: ' + Qgis.DataType.Float64.__doc__ + '\n' + '* ``CInt16``: ' + Qgis.DataType.CInt16.__doc__ + '\n' + '* ``CInt32``: ' + Qgis.DataType.CInt32.__doc__ + '\n' + '* ``CFloat32``: ' + Qgis.DataType.CFloat32.__doc__ + '\n' + '* ``CFloat64``: ' + Qgis.DataType.CFloat64.__doc__ + '\n' + '* ``ARGB32``: ' + Qgis.DataType.ARGB32.__doc__ + '\n' + '* ``ARGB32_Premultiplied``: ' + Qgis.DataType.ARGB32_Premultiplied.__doc__
# --
Qgis.DataType.baseClass = Qgis
Qgis.PythonMacroMode.baseClass = Qgis
QgsVectorDataProvider.FeatureCountState = Qgis.FeatureCountState
@@ -81,11 +81,11 @@ The development version
Warning,
Critical,
Success,
None
None,
};

enum DataType
{
enum class DataType
{
UnknownDataType,
Byte,
UInt16,
@@ -33,7 +33,10 @@ ContrastEnhancementAlgorithm.
UserDefinedEnhancement
};

QgsContrastEnhancement( Qgis::DataType datatype = Qgis::Byte );
QgsContrastEnhancement( Qgis::DataType datatype = Qgis::DataType::Byte );
%Docstring
Constructor for QgsContrastEnhancement, for the specified data type.
%End
QgsContrastEnhancement( const QgsContrastEnhancement &ce );
~QgsContrastEnhancement();

@@ -64,7 +64,7 @@ This method does not return ``True`` if size is not zero and all values are
'no data' (null).
%End

static int typeSize( int dataType ) /HoldGIL/;
static int typeSize( Qgis::DataType dataType ) /HoldGIL/;
%Docstring
Returns the size in bytes for the specified ``dataType``.
%End
@@ -8,6 +8,7 @@




class QgsRasterChecker
{
%Docstring(signature="appended")
@@ -1049,7 +1049,9 @@ sub detect_non_method_member{
$enum_mk_base = $+{emkb} if defined $+{emkb};
if (defined $+{emkf} and $monkeypatch eq "1"){
if ( $ACTUAL_CLASS ne "" ) {
push @OUTPUT_PYTHON, "$enum_mk_base.$+{emkf} = $ACTUAL_CLASS.$enum_qualname\n";
if ($enum_mk_base.$+{emkf} ne $ACTUAL_CLASS.$enum_qualname) {
push @OUTPUT_PYTHON, "$enum_mk_base.$+{emkf} = $ACTUAL_CLASS.$enum_qualname\n";
}
} else {
push @OUTPUT_PYTHON, "$enum_mk_base.$+{emkf} = $enum_qualname\n";
}
@@ -274,7 +274,7 @@ void QgsRgbPointCloud3DSymbol::readXml( const QDomElement &elem, const QgsReadWr
QDomElement redContrastElem = elem.firstChildElement( QStringLiteral( "redContrastEnhancement" ) );
if ( !redContrastElem.isNull() )
{
redContrastEnhancement = new QgsContrastEnhancement( Qgis::UnknownDataType );
redContrastEnhancement = new QgsContrastEnhancement( Qgis::DataType::UnknownDataType );
redContrastEnhancement->readXml( redContrastElem );
setRedContrastEnhancement( redContrastEnhancement );
}
@@ -283,7 +283,7 @@ void QgsRgbPointCloud3DSymbol::readXml( const QDomElement &elem, const QgsReadWr
QDomElement greenContrastElem = elem.firstChildElement( QStringLiteral( "greenContrastEnhancement" ) );
if ( !greenContrastElem.isNull() )
{
greenContrastEnhancement = new QgsContrastEnhancement( Qgis::UnknownDataType );
greenContrastEnhancement = new QgsContrastEnhancement( Qgis::DataType::UnknownDataType );
greenContrastEnhancement->readXml( greenContrastElem );
setGreenContrastEnhancement( greenContrastEnhancement );
}
@@ -292,7 +292,7 @@ void QgsRgbPointCloud3DSymbol::readXml( const QDomElement &elem, const QgsReadWr
QDomElement blueContrastElem = elem.firstChildElement( QStringLiteral( "blueContrastEnhancement" ) );
if ( !blueContrastElem.isNull() )
{
blueContrastEnhancement = new QgsContrastEnhancement( Qgis::UnknownDataType );
blueContrastEnhancement = new QgsContrastEnhancement( Qgis::DataType::UnknownDataType );
blueContrastEnhancement->readXml( blueContrastElem );
setBlueContrastEnhancement( blueContrastEnhancement );
}
@@ -186,7 +186,7 @@ static QByteArray _readDtmData( QgsRasterDataProvider *provider, const QgsRectan
QByteArray data;
if ( block )
{
block->convert( Qgis::Float32 ); // currently we expect just floats
block->convert( Qgis::DataType::Float32 ); // currently we expect just floats
data = block->data();
data.detach(); // this should make a deep copy

@@ -275,7 +275,7 @@ void QgsDemHeightMapGenerator::lazyLoadDtmCoarseData( int res, const QgsRectangl
if ( mDtmCoarseData.isEmpty() )
{
std::unique_ptr< QgsRasterBlock > block( mDtm->dataProvider()->block( 1, rect, res, res ) );
block->convert( Qgis::Float32 );
block->convert( Qgis::DataType::Float32 );
mDtmCoarseData = block->data();
mDtmCoarseData.detach(); // make a deep copy
}
@@ -103,7 +103,7 @@ bool QgsCellStatisticsAlgorithmBase::prepareAlgorithm( const QVariantMap &parame

//determine output raster data type
//initially raster data type to most primitive data type that is possible
mDataType = Qgis::Byte;
mDataType = Qgis::DataType::Byte;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
for ( int band : i.bands )
@@ -245,12 +245,12 @@ bool QgsCellStatisticsAlgorithm::prepareSpecificAlgorithmParameters( const QVari
)
{
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
mDataType = Qgis::DataType::Float32; //force float on mean, stddev and median with equal number of input layers if all inputs are integer
}
else if ( mMethod == QgsRasterAnalysisUtils::Count || mMethod == QgsRasterAnalysisUtils::Variety ) //count, variety
{
if ( static_cast<int>( mDataType ) > 5 ) //if is floating point type
mDataType = Qgis::Int32; //force integer on variety if all inputs are float or complex
mDataType = Qgis::DataType::Int32; //force integer on variety if all inputs are float or complex
}
return true;
}
@@ -425,7 +425,7 @@ bool QgsCellStatisticsPercentileAlgorithm::prepareSpecificAlgorithmParameters( c

//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 && static_cast< int >( mDataType ) < 6 )
mDataType = Qgis::DataType::Float32;

return true;
@@ -100,49 +100,49 @@ QVariantMap QgsConstantRasterAlgorithm::processAlgorithm( const QVariantMap &par
double intpart;
fractpart = abs( std::modf( value, &intpart ) ); //@abs: negative values may be entered

Qgis::DataType rasterDataType = Qgis::Float32; //standard output type
Qgis::DataType rasterDataType = Qgis::DataType::Float32; //standard output type
switch ( typeId )
{
case 0:
rasterDataType = Qgis::Byte;
rasterDataType = Qgis::DataType::Byte;
if ( value < std::numeric_limits<quint8>::min() || value > std::numeric_limits<quint8>::max() )
throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept positive values between %1 and %2" ).arg( std::numeric_limits<quint8>::min() ).arg( std::numeric_limits<quint8>::max() ).arg( QLatin1String( "Byte" ) ) );
if ( fractpart > 0 )
feedback->reportError( QObject::tr( "The entered constant value has decimals but will be written to a raster dataset of type %1. The decimals of the constant value will be omitted." ).arg( QLatin1String( "Byte" ) ) );
break;
case 1:
rasterDataType = Qgis::Int16;
rasterDataType = Qgis::DataType::Int16;
if ( value < std::numeric_limits<qint16>::min() || value > std::numeric_limits<qint16>::max() )
throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept values between %1 and %2" ).arg( std::numeric_limits<qint16>::min() ).arg( std::numeric_limits<qint16>::max() ).arg( QLatin1String( "Integer16" ) ) );
if ( fractpart > 0 )
feedback->reportError( QObject::tr( "The entered constant value has decimals but will be written to a raster dataset of type %1. The decimals of the constant value will be omitted." ).arg( QLatin1String( "Integer16" ) ) );
break;
case 2:
rasterDataType = Qgis::UInt16;
rasterDataType = Qgis::DataType::UInt16;
if ( value < std::numeric_limits<quint16>::min() || value > std::numeric_limits<quint16>::max() )
throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept positive values between %1 and %2" ).arg( std::numeric_limits<quint16>::min() ).arg( std::numeric_limits<quint16>::max() ).arg( "Unsigned Integer16" ) );
if ( fractpart > 0 )
feedback->reportError( QObject::tr( "The entered constant value has decimals but will be written to a raster dataset of type %1. The decimals of the constant value will be omitted." ).arg( QLatin1String( "Unsigned Integer16" ) ) );
break;
case 3:
rasterDataType = Qgis::Int32;
rasterDataType = Qgis::DataType::Int32;
if ( value < std::numeric_limits<qint32>::min() || value > std::numeric_limits<qint32>::max() )
throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept values between %1 and %2" ).arg( std::numeric_limits<qint32>::min() ).arg( std::numeric_limits<qint32>::max() ).arg( QLatin1String( "Integer32" ) ) );
if ( fractpart > 0 )
feedback->reportError( QObject::tr( "The entered constant value has decimals but will be written to a raster dataset of type %1. The decimals of the constant value will be omitted." ).arg( QLatin1String( "Integer32" ) ) );
break;
case 4:
rasterDataType = Qgis::UInt32;
rasterDataType = Qgis::DataType::UInt32;
if ( value < std::numeric_limits<quint32>::min() || value > std::numeric_limits<quint32>::max() )
throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept positive values between %1 and %2" ).arg( std::numeric_limits<quint32>::min() ).arg( std::numeric_limits<quint32>::max() ).arg( QLatin1String( "Unsigned Integer32" ) ) );
if ( fractpart > 0 )
feedback->reportError( QObject::tr( "The entered constant value has decimals but will be written to a raster dataset of type %1. The decimals of the constant value will be omitted." ).arg( QLatin1String( "Unsigned Integer32" ) ) );
break;
case 5:
rasterDataType = Qgis::Float32;
rasterDataType = Qgis::DataType::Float32;
break;
case 6:
rasterDataType = Qgis::Float64;
rasterDataType = Qgis::DataType::Float64;
break;
default:
break;
@@ -179,56 +179,56 @@ QVariantMap QgsConstantRasterAlgorithm::processAlgorithm( const QVariantMap &par
{
std::vector<quint8> byteRow( cols );
std::fill( byteRow.begin(), byteRow.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&byteRow[0], QgsRasterBlock::typeSize( Qgis::Byte ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&byteRow[0], QgsRasterBlock::typeSize( Qgis::DataType::Byte ) * cols ) );
break;
}
case 1:
{
std::vector<qint16> int16Row( cols );
std::fill( int16Row.begin(), int16Row.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&int16Row[0], QgsRasterBlock::typeSize( Qgis::Int16 ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&int16Row[0], QgsRasterBlock::typeSize( Qgis::DataType::Int16 ) * cols ) );
break;
}
case 2:
{
std::vector<quint16> uInt16Row( cols );
std::fill( uInt16Row.begin(), uInt16Row.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&uInt16Row[0], QgsRasterBlock::typeSize( Qgis::UInt16 ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&uInt16Row[0], QgsRasterBlock::typeSize( Qgis::DataType::UInt16 ) * cols ) );
break;
}
case 3:
{
std::vector<qint32> int32Row( cols );
std::fill( int32Row.begin(), int32Row.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&int32Row[0], QgsRasterBlock::typeSize( Qgis::Int32 ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&int32Row[0], QgsRasterBlock::typeSize( Qgis::DataType::Int32 ) * cols ) );
break;
}
case 4:
{
std::vector<quint32> uInt32Row( cols );
std::fill( uInt32Row.begin(), uInt32Row.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&uInt32Row[0], QgsRasterBlock::typeSize( Qgis::UInt32 ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&uInt32Row[0], QgsRasterBlock::typeSize( Qgis::DataType::UInt32 ) * cols ) );
break;
}
case 5:
{
std::vector<float> float32Row( cols );
std::fill( float32Row.begin(), float32Row.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&float32Row[0], QgsRasterBlock::typeSize( Qgis::Float32 ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&float32Row[0], QgsRasterBlock::typeSize( Qgis::DataType::Float32 ) * cols ) );
break;
}
case 6:
{
std::vector<double> float64Row( cols );
std::fill( float64Row.begin(), float64Row.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&float64Row[0], QgsRasterBlock::typeSize( Qgis::Float64 ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&float64Row[0], QgsRasterBlock::typeSize( Qgis::DataType::Float64 ) * cols ) );
break;
}
default:
{
std::vector<float> float32Row( cols );
std::fill( float32Row.begin(), float32Row.end(), value );
block.setData( QByteArray::fromRawData( ( char * )&float32Row[0], QgsRasterBlock::typeSize( Qgis::Float32 ) * cols ) );
block.setData( QByteArray::fromRawData( ( char * )&float32Row[0], QgsRasterBlock::typeSize( Qgis::DataType::Float32 ) * cols ) );
break;
}
}
@@ -825,7 +825,7 @@ QVariantMap QgsMeshRasterizeAlgorithm::processAlgorithm( const QVariantMap &para
rasterFileWriter.setOutputFormat( outputFormat );

std::unique_ptr<QgsRasterDataProvider> rasterDataProvider(
rasterFileWriter.createMultiBandRaster( Qgis::Float64, width, height, extent, mTransform.destinationCrs(), mDataPerGroup.count() ) );
rasterFileWriter.createMultiBandRaster( Qgis::DataType::Float64, width, height, extent, mTransform.destinationCrs(), mDataPerGroup.count() ) );
rasterDataProvider->setEditable( true );

for ( int i = 0; i < mDataPerGroup.count(); ++i )
@@ -71,7 +71,7 @@ class QgsFuzzifyRasterAlgorithmBase : public QgsProcessingAlgorithm
int mNbCellsXProvider = 0;
int mNbCellsYProvider = 0;

Qgis::DataType mDataType = Qgis::Float32;
Qgis::DataType mDataType = Qgis::DataType::Float32;
const double mNoDataValue = -9999;
QgsRasterDataProvider *mDestinationRasterProvider;
};
@@ -140,7 +140,7 @@ QVariantMap QgsLineDensityAlgorithm::processAlgorithm( const QVariantMap &parame
QgsRasterFileWriter writer = QgsRasterFileWriter( outputFile );
writer.setOutputProviderKey( QStringLiteral( "gdal" ) );
writer.setOutputFormat( outputFormat );
std::unique_ptr<QgsRasterDataProvider > provider( writer.createOneBandRaster( Qgis::Float32, cols, rows, rasterExtent, mCrs ) );
std::unique_ptr<QgsRasterDataProvider > provider( writer.createOneBandRaster( Qgis::DataType::Float32, cols, rows, rasterExtent, mCrs ) );
if ( !provider )
throw QgsProcessingException( QObject::tr( "Could not create raster output: %1" ).arg( outputFile ) );
if ( !provider->isValid() )
@@ -151,7 +151,7 @@ QVariantMap QgsLineDensityAlgorithm::processAlgorithm( const QVariantMap &parame
qgssize totalCellcnt = static_cast<qgssize>( rows ) * cols;
int cellcnt = 0;

std::unique_ptr< QgsRasterBlock > rasterDataLine = std::make_unique< QgsRasterBlock >( Qgis::Float32, cols, 1 );
std::unique_ptr< QgsRasterBlock > rasterDataLine = std::make_unique< QgsRasterBlock >( Qgis::DataType::Float32, cols, 1 );

for ( int row = 0; row < rows; row++ )
{

0 comments on commit b4fea52

Please sign in to comment.