Skip to content
Permalink
Browse files

Early resampling: fix requests typical of pixel identification

  • Loading branch information
rouault authored and nyalldawson committed Jun 10, 2020
1 parent 47da98c commit d2497c82128b3bc29093e9b2c560126407299e38
Showing with 22 additions and 4 deletions.
  1. +4 −4 src/core/providers/gdal/qgsgdalprovider.cpp
  2. +18 −0 tests/src/python/test_qgsrasterresampler.py
@@ -958,10 +958,10 @@ bool QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &reqExtent, int
sExtraArg.dfXSize = tgtWidth * reqXRes / srcXRes;
sExtraArg.dfYSize = tgtHeight * reqYRes / -srcYRes;
return GDALRasterIOEx( gdalBand, GF_Read,
std::floor( sExtraArg.dfXOff ),
std::floor( sExtraArg.dfYOff ),
std::floor( sExtraArg.dfXSize ),
std::floor( sExtraArg.dfYSize ),
static_cast<int>( std::floor( sExtraArg.dfXOff ) ),
static_cast<int>( std::floor( sExtraArg.dfYOff ) ),
std::max( 1, static_cast<int>( std::floor( sExtraArg.dfXSize ) ) ),
std::max( 1, static_cast<int>( std::floor( sExtraArg.dfYSize ) ) ),
static_cast<char *>( data ) +
( tgtTop * bufferWidthPix + tgtLeft ) * dataSize,
tgtWidth,
@@ -564,6 +564,24 @@ def testGDALResampling_nominal_resolution_slightly_overlapping_bottom_edge(self)
# The values in the bottom line are not subject to resampling currently
self.checkRawBlockContents(block, [[65, 100], [70, 190]])

def testGDALResampling_less_than_one_pixel(self):

xmin = 100
ymax = 1000
xres = 5
yres = 5

# Extent is less than one pixel. Simulates pixel identification
extent = QgsRectangle(xmin + 2.25 * xres,
ymax - 4.25 * yres,
xmin + 2.5 * xres,
ymax - 4.5 * yres)

with self.setupGDALResampling() as provider:
provider.setZoomedInResamplingMethod(QgsRasterDataProvider.ResamplingMethod.Bilinear)
block = provider.block(1, extent, 1, 1)
self.checkRawBlockContents(block, [[68]])


if __name__ == '__main__':
unittest.main()

0 comments on commit d2497c8

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