[Gdal-dev] Driver Implementation API - IReadBlock or IRasterIO
Frank Warmerdam
fwarmerdam at gmail.com
Wed Feb 2 14:28:49 EST 2005
On Wed, 2 Feb 2005 13:36:20 -0500, Robert J Farmer <r-farmer at jtboyd.com> wrote:
> Hello!
>
> I am trying to develop a driver implementation for a propritary raster
> format. Unfortunately, I am struggling with a few key concepts with the
> GDAL API.
>
> The raster format contains a header followed by two bands of data which are
> pixel-interleaved (i.e.. B1P1, B2P1, B1P2, etc) Band 1 contains float
> values, band 2 contains unsigned short values -- so both are 4 bytes long.
Rob,
I'm not sure why you say both are 4 bytes long. A float is 4 bytes, but an
unsigned short is 2 bytes. The overall pixel group is 6 bytes.
> I believe that I should implement the IRasterIO interface (actually override
> it with BlockBasedRasterIO) to efficiently read the raster. But what about
> the IReadBlock interface, do I need this?
>
> I am unsure, when to implement IReadBlock and/or IRasterIO. Any guidance
> would be greatly appreciated.
First, I would encourage you to implement this as a "raw format".
That is derive
your dataset class from RawDataset and either use RawRasterBand directly
or derive your band class from it if you need to add special
capabilities. Then
all you would have to do for the IO is create the raw raster bands with the
correct layout information.
However, setting that aside the only method for image reading you *need*
to implement is IReadBlock() on your raster band class. All other entry points
are essentially an effort to optimize special cases, and to some reasonable
extent this has already been done for the Raw classes.
In answer to some of your specific questions, you *always* need to
implement the GDALRasterBand::IReadBlock() method. I believe it is
the only pure virtual method in the core gdal format classes.
You should implement IRasterIO() if you have special ways of implementing
subsetting or overviews efficiently. But for the obvious cases the Raw
raster code already handles this for you. I would add that it is *very*
easy to make mistakes implementing IRasterIO() since it does a great deal
of processing.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list