Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Raster] Add a Qgis::DataType::Int8 signed data type #51587

Merged
merged 1 commit into from
Jan 29, 2023

Conversation

rouault
Copy link
Contributor

@rouault rouault commented Jan 25, 2023

Continuation of #51586

Probably 3.32 material at that point?

@github-actions github-actions bot added this to the 3.30.0 milestone Jan 25, 2023
@nyalldawson
Copy link
Collaborator

Probably 3.32 material at that point

Is there anything in particular you're worried about here? From a look over the changes it's all additions to handling int8 only, so even buggy support for that is better then the current no support IMO.

@rouault
Copy link
Contributor Author

rouault commented Jan 25, 2023

Is there anything in particular you're worried about here?

no, not really. That could be fine in 3.30 as well.

Copy link
Collaborator

@nyalldawson nyalldawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in 3.30 👍

python/core/auto_additions/qgis.py Outdated Show resolved Hide resolved
src/core/qgis.h Outdated Show resolved Hide resolved
@rouault
Copy link
Contributor Author

rouault commented Jan 26, 2023

It might still be useful to merge #51586 and have it backported to 3.28 so that the next LTR gets a minimal GDAL support for Int8 rasters when/if GDAL 3.7 is used at some point with QGIS 3.28

@nyalldawson
Copy link
Collaborator

@rouault good point!

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jan 27, 2023

@rouault souldn't the Int8 / GDT_Int8 value be added to the QgsGdalUtils::gdalDataTypeFromQgisDataType function?

GDALDataType QgsGdalUtils::gdalDataTypeFromQgisDataType( Qgis::DataType dataType )
{
switch ( dataType )
{
case Qgis::DataType::UnknownDataType:
return GDALDataType::GDT_Unknown;
break;
case Qgis::DataType::Byte:
return GDALDataType::GDT_Byte;
break;
case Qgis::DataType::UInt16:
return GDALDataType::GDT_UInt16;
break;
case Qgis::DataType::Int16:
return GDALDataType::GDT_Int16;
break;
case Qgis::DataType::UInt32:
return GDALDataType::GDT_UInt32;
break;
case Qgis::DataType::Int32:
return GDALDataType::GDT_Int32;
break;
case Qgis::DataType::Float32:
return GDALDataType::GDT_Float32;
break;
case Qgis::DataType::Float64:
return GDALDataType::GDT_Float64;
break;
case Qgis::DataType::CInt16:
return GDALDataType::GDT_CInt16;
break;
case Qgis::DataType::CInt32:
return GDALDataType::GDT_CInt32;
break;
case Qgis::DataType::CFloat32:
return GDALDataType::GDT_CFloat32;
break;
case Qgis::DataType::CFloat64:
return GDALDataType::GDT_CFloat64;
break;
case Qgis::DataType::ARGB32:
case Qgis::DataType::ARGB32_Premultiplied:
return GDALDataType::GDT_Unknown;
break;
};

@rouault
Copy link
Contributor Author

rouault commented Jan 27, 2023

souldn't the Int8 / GDT_Int8 value be added to the QgsGdalUtils::gdalDataTypeFromQgisDataType function?

good catch. added (weird that the compiler didn't emit a warning about the missing case)

@rouault rouault closed this Jan 28, 2023
@rouault rouault reopened this Jan 28, 2023
@rouault rouault merged commit 133a4f4 into qgis:master Jan 29, 2023
@DelazJ
Copy link
Contributor

DelazJ commented Jan 31, 2023

@rouault Do I correctly understand that with this PR, the "output data types" parameter of the algs will get one more item (for those running gdal 3.7)?

@agiudiceandrea
Copy link
Contributor

@DelazJ, the output data types for following GDAL algorithms should be updated:

ClipRasterByExtent.py
ClipRasterByMask.py
gdalcalc.py
GridAverage.py
GridDataMetrics.py
GridInverseDistance.py
GridInverseDistanceNearestNeighbor.py
GridLinear.py
GridNearestNeighbor.py
merge.py
proximity.py
rasterize.py
rearrange_bands.py
retile.py
translate.py
warp.py

Since it is an enum value, maybe it would be better to insert the new value at the end, in order to maintain compatibility with previous versions.

@DelazJ
Copy link
Contributor

DelazJ commented Jan 31, 2023

the output data types for following GDAL algorithms should be updated:

Plus a few QGIS ones (qgis/QGIS-Documentation@master...DelazJ:QGIS-Documentation:rasterTypesInclude), isn't it?

Since it is an enum value, maybe it would be better to insert the new value at the end, in order to maintain compatibility with previous versions.

That was my next question after the first one is confirmed. Considering that we have enum, where is that new value put ? (doesn't seem to be at the end in the code, so would it not break existing scripts?)

@rouault
Copy link
Contributor Author

rouault commented Jan 31, 2023

Re processing algorithms , I'm not familiar with them, so hard to comment for sure. But at first sight it seems that it is a drop down of strings, and that the index is stored (at least that's what I see in files like python/plugins/processing/tests/testdata/qgis_algorithm_tests4.yaml), which is a bit unfortunate. So yes, "Int8" if it was added should likely be put at the end to avoid breaking existing code/scripts. But perhaps I'm wrong

@agiudiceandrea
Copy link
Contributor

Exactly.
For example:

self.TYPES = [self.tr('Use Input Layer Data Type'), 'Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64', 'CInt16', 'CInt32', 'CFloat32', 'CFloat64']

or:
TYPES = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64', 'CInt16', 'CInt32', 'CFloat32', 'CFloat64']

@agiudiceandrea
Copy link
Contributor

Plus a few QGIS ones

For those ones (native:rasterbooleanand, native:rasterbooleanor, native:reclassifybylayer, native:reclassifybytable) the following code should be updated:

void populateDataTypes()
{
if ( sDataTypes.empty() )
{
sDataTypes.append( qMakePair( QStringLiteral( "Byte" ), Qgis::DataType::Byte ) );
sDataTypes.append( qMakePair( QStringLiteral( "Int16" ), Qgis::DataType::Int16 ) );
sDataTypes.append( qMakePair( QStringLiteral( "UInt16" ), Qgis::DataType::UInt16 ) );
sDataTypes.append( qMakePair( QStringLiteral( "Int32" ), Qgis::DataType::Int32 ) );
sDataTypes.append( qMakePair( QStringLiteral( "UInt32" ), Qgis::DataType::UInt32 ) );
sDataTypes.append( qMakePair( QStringLiteral( "Float32" ), Qgis::DataType::Float32 ) );
sDataTypes.append( qMakePair( QStringLiteral( "Float64" ), Qgis::DataType::Float64 ) );
sDataTypes.append( qMakePair( QStringLiteral( "CInt16" ), Qgis::DataType::CInt16 ) );
sDataTypes.append( qMakePair( QStringLiteral( "CInt32" ), Qgis::DataType::CInt32 ) );
sDataTypes.append( qMakePair( QStringLiteral( "CFloat32" ), Qgis::DataType::CFloat32 ) );
sDataTypes.append( qMakePair( QStringLiteral( "CFloat64" ), Qgis::DataType::CFloat64 ) );
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants