Skip to content
Permalink
Browse files

Fix single band gray with alpha raster type not recognized (fix #4159)

- Add band color interpretation for WCS provider (from GDAL provider)

Backported to 2.8.3
  • Loading branch information
dakcarto committed Jun 4, 2015
1 parent 06af43d commit 1f74cf08de0a9190eec8349526202e6edaa9d982
Showing with 21 additions and 1 deletion.
  1. +13 −1 src/core/raster/qgsrasterlayer.cpp
  2. +6 −0 src/providers/wcs/qgswcsprovider.cpp
  3. +2 −0 src/providers/wcs/qgswcsprovider.h
@@ -708,7 +708,19 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
QgsDebugMsg( "dataType = " + QString::number( mDataProvider->dataType( 1 ) ) );
if (( mDataProvider->bandCount() > 1 ) )
{
mRasterType = Multiband;
// handle singleband gray with alpha
if ( mDataProvider->bandCount() == 2
&& (( mDataProvider->colorInterpretation( 1 ) == QgsRaster::GrayIndex
&& mDataProvider->colorInterpretation( 2 ) == QgsRaster::AlphaBand )
|| ( mDataProvider->colorInterpretation( 1 ) == QgsRaster::AlphaBand
&& mDataProvider->colorInterpretation( 2 ) == QgsRaster::GrayIndex ) ) )
{
mRasterType = GrayOrUndefined;
}
else
{
mRasterType = Multiband;
}
}
else if ( mDataProvider->dataType( 1 ) == QGis::ARGB32
|| mDataProvider->dataType( 1 ) == QGis::ARGB32_Premultiplied )
@@ -913,6 +913,12 @@ QList<QgsColorRampShader::ColorRampItem> QgsWcsProvider::colorTable( int theBand
return mColorTables.value( theBandNumber - 1 );
}

int QgsWcsProvider::colorInterpretation( int bandNo ) const
{
GDALRasterBandH myGdalBand = GDALGetRasterBand( mCachedGdalDataset, bandNo );
return colorInterpretationFromGdal( GDALGetRasterColorInterpretation( myGdalBand ) );
}


bool QgsWcsProvider::parseServiceExceptionReportDom( QByteArray const & xml, const QString& wcsVersion, QString& errorTitle, QString& errorText )
{
@@ -178,6 +178,8 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase
void reloadData() override;
QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const override;

int colorInterpretation( int bandNo ) const override;

static QMap<QString, QString> supportedMimes();

/**

0 comments on commit 1f74cf0

Please sign in to comment.
You can’t perform that action at this time.