| 1 | = Read/Write driver for TMS tiles = |
| 2 | |
| 3 | This work is continuation of the SoC 2007 project [http://trac.osgeo.org/gdal/wiki/SoCTileDriver GDAL2Tiles]. |
| 4 | The goal is to create a new driver for reading and writing maps in TMS tiled format. |
| 5 | |
| 6 | == Data format == |
| 7 | |
| 8 | === TMS tiled maps === |
| 9 | |
| 10 | The driver will operate on data in |
| 11 | the [http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#TileMap_Resource OSGeo TMS TileMap Resource] format |
| 12 | used already by GDAL2Tiles. In short, the map is described in one XML file. Image data is divided into |
| 13 | several zooming levels represented by directories containing tiles as individual files. |
| 14 | |
| 15 | === Tiles === |
| 16 | |
| 17 | The TMS specification doesn't prescribe the format of tiles but PNG and JPEG are |
| 18 | the only useable formats in web setting. Both have existing drivers in GDAL. |
| 19 | The TMS driver will use only PNG tiles at first. Extending the support to |
| 20 | JPEG tiles as well is possible next step after implementing both reading and writing |
| 21 | functionality for PNG. |
| 22 | |
| 23 | == Work plan == |
| 24 | |
| 25 | The work is divided into several steps. First two are essential, all others |
| 26 | are optional. |
| 27 | |
| 28 | === Read driver === |
| 29 | |
| 30 | First step is to create a read-only driver. The `Open` method will be called on |
| 31 | the main XML file describing the map. The `<TileSet>` URLs will be expected to be |
| 32 | paths relative to the main file. This is the case with data produced by GDAL2Tiles. |
| 33 | When this expectation is not met, the driver could try to guess the names of directories |
| 34 | using the last part of the URL and the base directory of the file being opened. |
| 35 | Another approach is to use auxiliary file describing the layout, this is similar |
| 36 | to the way the WMS driver works. |
| 37 | |
| 38 | Although the tiled map has several zooming levels, only the lowest one will be used. |
| 39 | `IReadBlock` requests will be handled by loading data from the files representing |
| 40 | the selected area using existing PNG driver. |
| 41 | |
| 42 | === Write driver === |
| 43 | |
| 44 | Next on plan is the writing part. The driver will support the |
| 45 | `CreateCopy` method returning the created dataset as `ReadOnly` (implemented in previous step). |
| 46 | This will allow to export existing datasets in tiled format. Creation options will include |
| 47 | the dimensions of tiles, number of zooming levels and the zooming ratio between them. |
| 48 | |
| 49 | Implementing `Create` method and `Update` mode dataset is questionable. |
| 50 | The PNG driver has this mode controlled by compile time option, so the |
| 51 | TMS driver would have to do the same. Even then, the PNG driver imposes some |
| 52 | restrictions on the calling side: ''"Note: callers must provide blocks in increasing Y order."'', |
| 53 | from `pngdataset.cpp`. This would translate to the TMS driver itself and its users too. |
| 54 | JPEG drivers have `CreateCopy` method only. |
| 55 | |
| 56 | === Performance tuning === |
| 57 | |
| 58 | The reading strategy at this point will be probably quite simple -- creating new |
| 59 | datasets for appropriate tiles in the `IReadBlock` method and getting data from them. |
| 60 | This could prove to be inefficient. There are several ways to solve this issue: |
| 61 | |
| 62 | * Holding all tiles opened -- could be wasting too much memory. |
| 63 | * Managing a cache of recently used tiles. |
| 64 | * Prefetching adjacent tiles into the cache. |
| 65 | |
| 66 | These and other should be explored and the final solution selected based on measured performance. |
| 67 | |
| 68 | === HTTP Read driver === |
| 69 | |
| 70 | The TMS tiled maps are mostly used on web, so the ability to read the map from |
| 71 | http connection could be quite useful. This step is somewhat related to the |
| 72 | preceding one because without intelligent caching, the performance could |
| 73 | very well become unacceptable. |
| 74 | |
| 75 | == Student info == |
| 76 | |
| 77 | My name is Václav Klusák and I am a graduate student of Applied Informatics at |
| 78 | [http://www.muni.cz Masaryk University] in Brno, Czech Republic. I can be |
| 79 | reached by email (`keo@keo.cz`) or ICQ (247 160 335). |