[Fdo-trac] [fdo-trac] #1021: GDAL provider: upsampled rasters come out with blank horizontal stripes

FDO trac_fdo at osgeo.org
Sat Oct 24 00:21:15 PDT 2026


#1021: GDAL provider: upsampled rasters come out with blank horizontal stripes
-----------------------------+----------------------
   Reporter:  jng            |      Owner:  jng
       Type:  defect         |     Status:  assigned
   Priority:  major          |  Milestone:  4.2.0
  Component:  GDAL Provider  |    Version:
   Severity:  3              |   Keywords:
External ID:                 |
-----------------------------+----------------------
 === Summary ===

 A raster feature source read through the GDAL (GRFP) provider renders with
 horizontal stripes when the requested image is larger than the source
 raster: a
 large fraction of the output rows come back entirely blank.

 === Environment ===

 FDO 4.2 (branches/4.2, r8420), Linux x86-64, Debug and Release, provider
 OSGeo.Gdal.4.2.

 Not a new defect. The rounding that causes it dates from r892 (2006-06-14)
 and
 the edge trip that completes it from r928 (2006-09-08).

 Observed through MapGuide Open Source 4.0, which renders rasters through
 this
 provider: a 1350x675 GeoTIFF rendered into a 4000x2000 raster image (with
 MaxRasterImageWidth/MaxRasterImageHeight raised to 4001, which is what
 allows a
 request that size to reach the provider) came out with 653 of its 2000
 rows
 uniformly white.

 === Steps to reproduce (provider alone, no rendering involved) ===

 Using Providers/GDAL/TestData/DEM/dem.xml - 337x469, Int16, class "Photo",
 raster property "Image":

 1. Open the connection, Select from "Photo", GetRaster(L"Image").
 2. SetImageXSize(2048); SetImageYSize(2048).
    (An upsample in both directions, and 4,194,304 pixels - over the
 threshold.)
 3. GetDataModel() reports TileSizeX = 2048, TileSizeY = 1.
 4. GetStreamReader() and read all 2048 * 2048 * 2 bytes.

 Expected: no output row consists entirely of 0xFF.

 Actual: 1579 of the 2048 rows are entirely 0xFF. The DEM's samples are
 943..3178, so a genuine row can never be all 0xFF.

 Reading the same source at 3001x1400 leaves 931 of 1400 rows blank.

 === Analysis ===

 FdoRfpBandRaster::GetDataModel() (FdoRfpBandRaster.cpp:244) reads a raster
 of
 more than 4,000,000 pixels one scanline per tile - TileSizeY is set to 1 -
 so
 every output row rounds its own source window in
 FdoRfpStreamReaderByTile::_getTile():

     fileWinYOff  = (int) floor( fileWinULY + 0.5 );
     fileWinYSize = (int) floor( fileWinLRY + 0.5 ) - fileWinYOff;

 When the requested image is larger than the source, each window is less
 than one
 source pixel tall, so both of its edges round to the same integer and
 fileWinYSize comes out as 0. The rounded offset can likewise land at
 fileYSize,
 one past the last source row.

 GDAL treats a zero-size window as a no-op: RasterIO() returns CE_None in
 that
 case without writing anything into the buffer
 (gdal/gcore/gdalrasterband.cpp).
 The tile buffer was prefilled with 0xFF by

     memset( m_tileData, 255, m_numTileBytes );

 earlier in the same function, so the row is emitted exactly as prefilled -
 blank.

 The right/bottom edge trip that follows narrows a window straddling the
 image
 edge and scales the working block by the fraction of a source pixel that
 remains:

     yRatio = (fileYSize - fileWinYOff) / (double) fileWinYSize;
     m_wrkBlockYSize = (int) (m_wrkBlockYSize * yRatio + 0.5);

 With only a fraction of a source pixel left, that rounds to 0 as well, and
 the
 zero-size buffer is skipped in the same way.

 Downsampling is unaffected (a window is always at least one source pixel
 wide or
 tall), and so is the single-tile path at or below 4,000,000 pixels, where
 the
 window is the whole source image.

 === Workaround ===

 None from the client side. Holding the requested raster at or below
 4,000,000
 pixels avoids the scanline-tiled path - which is what MapGuide does by
 default
 via MaxRasterImageWidth/MaxRasterImageHeight.

 === Fix ===

 FdoRfpStreamReaderByTile::_getTile() clamps the read window: fileWinXOff
 and
 fileWinYOff are held to the last source pixel, fileWinXSize and
 fileWinYSize to
 at least one pixel, and m_wrkBlockXSize/m_wrkBlockYSize to at least one
 after
 the edge trip.

 Covered by two tests in Providers/GDAL/Src/UnitTest/RfpTestDem.cpp -
 testUpsampledTileStream and testUpsampledTileStreamEdgeRows - which report
 the
 blank-row counts above when the provider change is removed, and 0 with it.
-- 
Ticket URL: <https://trac.osgeo.org/fdo/ticket/1021>
FDO <http://fdo.osgeo.org/>
Feature Data Objects


More information about the fdo-trac mailing list