[gdal-dev] SoC Report: GDAL TMS driver

Václav Klusák keo at keo.cz
Fri Jul 11 08:58:58 EDT 2008


Report for week 7.--11..7.2008.

I learned how to use cpl_minixml to parse TMS TileMap file. From this the
first executable read driver for TMS followed. I tried it on datasets
created by gdal2tiles.py using gdal_translate. Found a bug in gdal2tiles
which Klokan promptly fixed. As I mentioned in the previous report, all my
initial attempts to tile caching went out of the window. So for the time
being I implemented the IReadBlock in the most straightforward way possible
-- just read the tile from disk, perform raster IO and destroy the tile
dataset. Turns out GDALRasterBand has its own block cache. I have to
investigate it further to determine how big it is etc. and how it would
interact with my driver.

The code worked, sort of. I found out the hard way the differences between
TMS and GDAL raster abstractions. GDAL has raster with (0,0) coordinates in
the top left corner and can work on them in blocks. TMS has blocks (tiles)
but it has (0,0) in the bottom left corner. So, if raster height is not a
multiple of tile height the GDAL blocks does not map 1:1 to tiles. If the
IReadBlock was implemented the way it was, it would have to read two tiles
and create one block from them. On top of this, some drivers (PNG for
example) doesn't like nonlinear acces which would be necessary in this case.
To solve this I introduced tile cache which holds predefined number of tiles
in MEM datasets. IReadBlock read data from the two according cached tiles.

Again, this worked, sort of. The problem is that IReadBlock has to fill the
buffer using two RasterIO calls and have to calculate appropriate offset in
the buffer for the second call. The code I have written works for BMP
datasets but not for GeoTiff, so there is some bug I will have to fix. I
sent this code to Frank for review as he requested.

What do to next:

Found out how to reliably and portably fill one buffer from two sources.
Additional positive effect of this is that then I could simplify the tile
cache. Now it is a set of MEM GDALDatasets. But that is probably not
necessary. It could just be one giant buffer into which the data would be
loaded during cache fill and from which the IReadBlock would copy the data
to its source buffer. After this works, jump to the writing part of driver.
In terms of raster IO it would be already almost done, but the Create method
has to create a directory structure and generate the XML file basen on
creation options, which I have not investigated much yet.

Václav "Keo" Klusák
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080711/4cd3a01a/attachment.html


More information about the gdal-dev mailing list