[OSM-dev] [GSoC] Data tile example site
Michael Daines
michael at mdaines.com
Wed Aug 22 16:20:31 BST 2012
Ander,
You'll have to store the coordinates yourself. Because you needed the coordinates to request the tile in the first place, you already have them -- you just need some way of associating the coordinates with the tile.
When caching I don't think you need to store the coordinates explicitly -- you would probably use the coordinates as a key and the tile's JSON contents as a value.
One thing you can do if you want to cache tiles on disk is store them as individual files in directories. Conceptually, you would store the tile with coordinates z=16 x=32744 y=21792 in "/path/to/cache/16/32744/21792.js".
This won't work well as you cache more and more tiles, because there will be a lot of files in these directories. mod_tile uses a hashing scheme to avoid this problem:
https://github.com/openstreetmap/mod_tile/blob/a39905d1957fd37cba0aa3a4ec7302ba4865b34c/dir_utils.c#L68
Another approach is to use a hash (like SHA1) of the tile's contents as a cache key, and maintain a mapping between coordinates and hashes. This avoids storing tiles twice which have the same content. There's a brief description of this approach here:
http://mapbox.com/developers/mbtiles/#using_views_to_reference_redundant_images
-- Michael
On 2012-08-20, at 3:09 AM, Ander Pijoan <ander.pijoan at deusto.es> wrote:
> Hi! I have a big question:
>
> Imagine I download one of the tiles and keep it in my hard drive or in
> a cache or send it to a client to open it in a program. The tiles
> bounding box or X,Y,Zoom values are not in it so it won't be able to
> know where to place that tile.
>
> I know that when asking for the tile I have those X,Y and Zoom values
> so I can calculate its position but if it is not written anywhere in
> the tile. I made some tests with Kothic's tiles allocated at
> Osmonimski.ru and those tiles at least have their bounding box and
> also their X,Y and Zoom values explicit in them.
>
>
>
> 2012/8/17, Michael Daines <michael at mdaines.com>:
>> Hi everyone,
>>
>> An example data tile server covering the British Isles is now online:
>>
>> http://data-tiles.mdaines.com/
>>
>> The library I have been working on is rendering tiles as a Tirex backend
>> using OpenStreetMap data. The map is drawn using Kothic JS over top of image
>> tiles rendered with Mapnik which show land polygons (basically the contents
>> of the layer-shapefiles.xml.inc file in OSM's Mapnik stylesheet).
>>
>> Here is an example data tile:
>>
>> http://data-tiles.mdaines.com/render/16/32744/21792.js
>>
>> The data in the tileset is defined by this configuration file which uses a
>> DSL that works sort of like CSS selectors:
>>
>> https://github.com/mdaines/cover/blob/master/config/render.rb
>>
>>
>> -- Michael
>>
>>
>> _______________________________________________
>> dev mailing list
>> dev at openstreetmap.org
>> http://lists.openstreetmap.org/listinfo/dev
>>
>
>
> --
> Ander Pijoan Lamas
> Ingeniero Técnico en Informática de Gestión
> Universidad de Deusto
>
> Contacto:
> Email: ander.pijoan at deusto.es
> Móvil: +34 664471228
More information about the dev
mailing list