[gdal-dev] GDAL WKT Raster cache: Problem, options to solve and doubts

Jorge Arévalo jorge.arevalo at gmail.com
Fri Aug 14 08:47:30 EDT 2009


Hello,

I've asked several concepts related with RasterIO-related methods in
Dataset and RasterBand. Thanks to your responses, I've a better
understanding of the GDAL drivers' I/O method. But I've a couple of
doubts I need to solve to finish the GSoC, although I'd like to
continue developing the driver after it.

Problem: In basic GDAL WKT Raster driver, each row of a raster table
(one block, in regularly blocked rasters) means one server round. This
is slow, and "sub-optimal".

How to solve it?: IReadBlock executes an spatial query to get all the
rows of a table that fits in a natural block, defined by nXOff, nYOff
and the values fetched by GetBlockSize. In many raster formats, one
natural block is a scanline, of size (nXRasterSize, 1). In WKT Raster
format, if we have a regularly blocked raster,  "natural" block size
will be equal to RASTER_COLUMNS-defined block size, and the query will
return one block. To avoid one spatial query for each block petition,
we should "force" the driver to get all the blocks covering the area
requested in a IRasterIO call.

How to implement it? My approach is based on implementing
WKTRasterDataset::IRasterIO method (overriding GDALDataset::IRasterIO
method). This method executes a spatial query that returns all the
raster rows covering the area requested. Now, I have all the data of
an image region. If the requested region dimensions match the buffer
dimensions, I can copy all the pixels fetched in this way:

pImage = {b1b1b1b1b1b1b1b1b1b1...|b2b2b2b2b2b2b2b2b2...|...|bnbnbnbnbnbnbnbnbn}

Where bi are the bytes of the band i. A WKT Raster image has a
non-interleaved format, all the band are consecutive. Is it correct? I
mean, copy the data in pImage with this format.

And if the region dimensions don't match the buffer dimensiones,
should I raise an error and finish or delegate in base
GDALDataset::IRasterIO implementation?

Another question: After copying the data from fetched rows in pImage
buffer, should I do anything more?

Other part of my implementation is overriding
GDALRasterBand::IRasterIO method. My method will simply call the
WKTRasterDataset::IRasterIO method with only one band to read. Is it
correct?

Thanks in advance.

Best regards,
Jorge


More information about the gdal-dev mailing list