Extract UTFGrid from MBTiles database

Carmen Campos Bordons embrujada_w at hotmail.com
Mon Jun 3 08:02:37 EDT 2013


I would appreciate any help or comment.
The idea is
to create a server in python that serves maps on the internet. The maps have to
be in MBTiles format, which is a SQLite database that store all the map tiles
in a single file. Taking this as an example http://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html#4.00/36.74/28.30 The tiles are images of the
map in png, like this one http://a.tiles.mapbox.com/v3/mapbox.geography-class/4/7/7.png and apart from the tiles, in the
database is stored the UTFGrid information, like this file http://a.tiles.mapbox.com/v3/mapbox.geography-class/4/7/7.grid.json. The UTFGrid (you can consult in http://www.mapbox.com/developers/utfgrid/) permits than when you hover in the
map, some extra information appears referring to the point where the mouse is.
As you can see in this example http://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html#4.00/36.74/28.30 a infobox appears with the
flag of every country(which is the information stored in the UTFGrid file).

In the
MBTiles database there are two table (also other, but not important in this case):
“tiles”, where are stored the tiles; and “grids”, where is stored the UTFGrid
associated to every tile.

>From the
MBTiles I can extract the tiles and display a normal map, and I can also
extract the UTFGrid file individually (not all together, like the tiles that I
can see the whole map; with the UTFGrid I just get one file). When I show the
map normally, the infoboxes do not appear. But I do not get any error in
command line or in the website. It just like the UTFGrid is empty.

Attached is
the code I am using to access the MBtiles file.

I am using
this SQL to access the MBTiles file

“select
grid from grids where tile_column=? and tile_row=? and zoom_level=?", (x,
y, z)

And if I
change it for this

"select
grid from grids where tile_column=? and tile_row=? and zoom_level=?", (67,
84, 7)

I am
getting always the same UTFGrid, but in this case it shows the infoboxes on the
map, that one for all the tiles.

It is like
if I have this part of the map http://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html#4.00/10.14/17.31 but I always get the
infoboxes of this tile http://a.tiles.mapbox.com/v3/mapbox.geography-class/4/7/7.png I get the infoboxes in all the
tiles, but all of them are showing the flag of that tile.
Thanks,Carmen 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130603/972e16f9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python_code.py
Type: text/x-script.phyton
Size: 2807 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20130603/972e16f9/attachment.bin>


More information about the Python-list mailing list