From TileCache to WMTS

Geospatial – Actualités

9 mai 2010 camptocamp

I love TileCache ! We have created billions of tiles with it (http://map.geo.admin.ch/,http://plan.epfl.ch/, http://map.veloland.ch/, http://coppet.geocommunes.ch/ etc, etc…). The only issue with TileCache is that it’s not an official standard.
The OGC has just released, on 2010.04.06, the first version of the WMTS (Web Map Tile Service) implementation standard. And the very good thing is that one part of the standard proposes a RESTFul implementation. I can already hear some comments like ‘all this time for that’, but now that it exists, it’s probably a good idea to use it. I still think that the service oriented architecture (KVP and more fantastic SOAP (have a look at the wmts:BinaryContent XML tag…)) is a non sense, so this article will only focus on the resource oriented architecture. The standard contains a nice sentence: « The RESTful pattern provides the ability to set up conformant WMTS servers simply », so let’s have a look if it’s possible to use a TileCache tile sets and serve it as RESTFull WMTS .

Layer
The notion of layer is the same in TileCache and WMTS.

Tile Matrix Set
The notion of Tile Matrix Set doesn’t exist in TileCache. A Tile Matrix Set is a collection of tile matrices defined at different scales. For one layer, you can define several Tile Matrix Sets, typically if you want to create tiles in various coordinate systems.

Tile Matrix
A tile matrix is a collection of tiles for a fixed scale. The tile organization is not the same in TileCache and in WMTS.
For TileCache, the first tile (0,0) is on the bottom left:

For WMTS, the first tile (0,0) is on the top left:

But, it’s quite easy to name the same tile in both coordinate systems. The following conversion functions can be used:
* WMTS.i = TILECACHE.x
* WMTS.j = HeightNumberOfTiles – TILECACHE.y

The notion of scale in TileCache is simply an integer indexing the tile pyramid (from 0 to n). WMTS offers more freedom for the scale and the identifier can be chosen freely. But it’s still possible to convert from WMTS to TileCache:
* WMTS.z (or Tile Matrix identifier) = TILECACHE.scale

Style
In WMTS, the style has been defined as mandatory. Not very clever from my point of view. This should be an optional value. But let’s add « default » everywhere… And I still don’t understand why the style is defined on the layer level.

Redirection from TileCache to WMTS
A TileCache url:

– http://myTileServer/myLayer/15/000/000/000/000/000/002.jpeg

Can be easily redirected to a WMTS url:

– http://myTileServer/myLayer/default/myTileMatrixSet/15/0/0.jpeg

And, in order to use and see the WMTS tiles, OpenLayers, offers, for example, a very convenient class XYZ:

– new OpenLayers.Layer.XYZ(« myLayer »,
« http://myTileServer/myLayer/default/myTileMatrixSet/${z}/${y}/${x}.jpeg »)

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*