@@ -1598,13 +1598,20 @@ QString QgsGdalProvider::buildPyramids( const QList<QgsRasterPyramid> & theRaste
1598
1598
Q_FOREACH ( const QString& option, theConfigOptions )
1599
1599
{
1600
1600
QStringList opt = option.split ( ' =' );
1601
- QByteArray key = opt[0 ].toLocal8Bit ();
1602
- QByteArray value = opt[1 ].toLocal8Bit ();
1603
- // save previous value
1604
- myConfigOptionsOld[ opt[0 ] ] = QString ( CPLGetConfigOption ( key.data (), nullptr ) );
1605
- // set temp. value
1606
- CPLSetConfigOption ( key.data (), value.data () );
1607
- QgsDebugMsg ( QString ( " set option %1=%2" ).arg ( key.data (), value.data () ) );
1601
+ if ( opt.size () == 2 )
1602
+ {
1603
+ QByteArray key = opt[0 ].toLocal8Bit ();
1604
+ QByteArray value = opt[1 ].toLocal8Bit ();
1605
+ // save previous value
1606
+ myConfigOptionsOld[ opt[0 ] ] = QString ( CPLGetConfigOption ( key.data (), nullptr ) );
1607
+ // set temp. value
1608
+ CPLSetConfigOption ( key.data (), value.data () );
1609
+ QgsDebugMsg ( QString ( " set option %1=%2" ).arg ( key.data (), value.data () ) );
1610
+ }
1611
+ else
1612
+ {
1613
+ QgsDebugMsg ( QString ( " invalid pyramid option: %1" ).arg ( option ) );
1614
+ }
1608
1615
}
1609
1616
}
1610
1617
@@ -1634,7 +1641,8 @@ QString QgsGdalProvider::buildPyramids( const QList<QgsRasterPyramid> & theRaste
1634
1641
}
1635
1642
}
1636
1643
/* From : http://www.gdal.org/classGDALDataset.html#a2aa6f88b3bbc840a5696236af11dde15
1637
- * pszResampling : one of "NEAREST", "GAUSS", "CUBIC", "AVERAGE", "MODE", "AVERAGE_MAGPHASE" or "NONE" controlling the downsampling method applied.
1644
+ * pszResampling : one of "NEAREST", "GAUSS", "CUBIC", "CUBICSPLINE" (GDAL >= 2.0),
1645
+ * "LANCZOS" ( GDAL >= 2.0), "AVERAGE", "MODE" or "NONE" controlling the downsampling method applied.
1638
1646
* nOverviews : number of overviews to build.
1639
1647
* panOverviewList : the list of overview decimation factors to build.
1640
1648
* nListBands : number of bands to build overviews for in panBandList. Build for all bands if this is 0.
@@ -2962,7 +2970,7 @@ QString QgsGdalProvider::validateCreationOptions( const QStringList& createOptio
2962
2970
return message;
2963
2971
}
2964
2972
2965
- QString QgsGdalProvider::validatePyramidsCreationOptions ( QgsRaster::RasterPyramidsFormat pyramidsFormat,
2973
+ QString QgsGdalProvider::validatePyramidsConfigOptions ( QgsRaster::RasterPyramidsFormat pyramidsFormat,
2966
2974
const QStringList & theConfigOptions, const QString & fileFormat )
2967
2975
{
2968
2976
// Erdas Imagine format does not support config options
@@ -2977,21 +2985,19 @@ QString QgsGdalProvider::validatePyramidsCreationOptions( QgsRaster::RasterPyram
2977
2985
else if ( pyramidsFormat == QgsRaster::PyramidsInternal )
2978
2986
{
2979
2987
QStringList supportedFormats;
2980
- supportedFormats << " gtiff" << " georaster" << " hfa" << " jp2kak " << " mrsid " << " nitf" ;
2988
+ supportedFormats << " gtiff" << " georaster" << " hfa" << " gpkg " << " rasterlite " << " nitf" ;
2981
2989
if ( ! supportedFormats.contains ( fileFormat.toLower () ) )
2982
- return QString ( " Internal pyramids format only supported for gtiff/georaster/hfa/jp2kak/mrsid/nitf files (using %1)" ).arg ( fileFormat );
2983
- // TODO - check arguments for georaster hfa jp2kak mrsid nitf
2984
- // for now, only test gtiff
2985
- else if ( fileFormat.toLower () != " gtiff" )
2986
- return QString ();
2990
+ return QString ( " Internal pyramids format only supported for gtiff/georaster/gpkg/rasterlite/nitf files (using %1)" ).arg ( fileFormat );
2987
2991
}
2988
-
2989
- // for gtiff external or internal pyramids, validate gtiff-specific values
2990
- // PHOTOMETRIC_OVERVIEW=YCBCR requires a source raster with only 3 bands (RGB)
2991
- if ( theConfigOptions.contains ( " PHOTOMETRIC_OVERVIEW=YCBCR" ) )
2992
+ else
2992
2993
{
2993
- if ( GDALGetRasterCount ( mGdalDataset ) != 3 )
2994
- return " PHOTOMETRIC_OVERVIEW=YCBCR requires a source raster with only 3 bands (RGB)" ;
2994
+ // for gtiff external pyramids, validate gtiff-specific values
2995
+ // PHOTOMETRIC_OVERVIEW=YCBCR requires a source raster with only 3 bands (RGB)
2996
+ if ( theConfigOptions.contains ( " PHOTOMETRIC_OVERVIEW=YCBCR" ) )
2997
+ {
2998
+ if ( GDALGetRasterCount ( mGdalDataset ) != 3 )
2999
+ return " PHOTOMETRIC_OVERVIEW=YCBCR requires a source raster with only 3 bands (RGB)" ;
3000
+ }
2995
3001
}
2996
3002
2997
3003
return QString ();
@@ -3022,6 +3028,10 @@ QGISEXTERN QList<QPair<QString, QString> > *pyramidResamplingMethods()
3022
3028
methods.append ( QPair<QString, QString>( " AVERAGE" , QObject::tr ( " Average" ) ) );
3023
3029
methods.append ( QPair<QString, QString>( " GAUSS" , QObject::tr ( " Gauss" ) ) );
3024
3030
methods.append ( QPair<QString, QString>( " CUBIC" , QObject::tr ( " Cubic" ) ) );
3031
+ #if GDAL_VERSION_MAJOR >= 2
3032
+ methods.append ( QPair<QString, QString>( " CUBICSPLINE" , QObject::tr ( " Cubic Spline" ) ) );
3033
+ methods.append ( QPair<QString, QString>( " LANCZOS" , QObject::tr ( " Lanczos" ) ) );
3034
+ #endif
3025
3035
methods.append ( QPair<QString, QString>( " MODE" , QObject::tr ( " Mode" ) ) );
3026
3036
methods.append ( QPair<QString, QString>( " NONE" , QObject::tr ( " None" ) ) );
3027
3037
}
0 commit comments