Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
qgsgdalprovider.cpp: add getGDALResamplingAlg() function
  • Loading branch information
rouault authored and nyalldawson committed Jun 19, 2020
1 parent 93bc7c2 commit c6f3650
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/core/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -780,6 +780,26 @@ bool QgsGdalProvider::canDoResampling(
return false;
}

static GDALRIOResampleAlg getGDALResamplingAlg( QgsGdalProvider::ResamplingMethod method )
{
GDALRIOResampleAlg eResampleAlg = GRIORA_NearestNeighbour;
switch ( method )
{
case QgsGdalProvider::ResamplingMethod::Nearest:
eResampleAlg = GRIORA_NearestNeighbour;
break;

case QgsGdalProvider::ResamplingMethod::Bilinear:
eResampleAlg = GRIORA_Bilinear;
break;

case QgsGdalProvider::ResamplingMethod::Cubic:
eResampleAlg = GRIORA_Cubic;
break;
}

return eResampleAlg;
}

bool QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &reqExtent, int bufferWidthPix, int bufferHeightPix, void *data, QgsRasterBlockFeedback *feedback )
{
Expand Down Expand Up @@ -943,13 +963,7 @@ bool QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &reqExtent, int
{
method = mZoomedOutResamplingMethod;
}
if ( method == ResamplingMethod::Bilinear )
sExtraArg.eResampleAlg = GRIORA_Bilinear;
else if ( method == ResamplingMethod::Cubic )
sExtraArg.eResampleAlg = GRIORA_Cubic;
else
sExtraArg.eResampleAlg = GRIORA_NearestNeighbour;

sExtraArg.eResampleAlg = getGDALResamplingAlg( method );
sExtraArg.bFloatingPointWindowValidity = true;
sExtraArg.dfXOff = ( reqExtent.xMinimum() + tgtLeft * reqXRes - mExtent.xMinimum() ) / srcXRes;
sExtraArg.dfYOff = ( mExtent.yMaximum() - ( reqExtent.yMaximum() - tgtTop * reqYRes ) ) / -srcYRes;
Expand Down Expand Up @@ -1042,12 +1056,8 @@ bool QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &reqExtent, int
GDALRasterIOExtraArg sExtraArg;
INIT_RASTERIO_EXTRA_ARG( sExtraArg );

if ( mZoomedOutResamplingMethod == ResamplingMethod::Bilinear )
sExtraArg.eResampleAlg = GRIORA_Bilinear;
else if ( mZoomedOutResamplingMethod == ResamplingMethod::Cubic )
sExtraArg.eResampleAlg = GRIORA_Cubic;
else
sExtraArg.eResampleAlg = GRIORA_NearestNeighbour;
sExtraArg.eResampleAlg = getGDALResamplingAlg( mZoomedOutResamplingMethod );

CPLErr eErr = GDALRasterIOEx( GDALGetRasterBand( hSrcDS.get(), 1 ),
GF_Read,
0, 0, tmpWidth, tmpHeight,
Expand Down

0 comments on commit c6f3650

Please sign in to comment.