Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'filename:fname piece:py': 0.07; 'json': 0.07; 'mouse': 0.07; 'referring': 0.07; 'string': 0.09; 'cursor': 0.09; 'except:': 0.09; 'grid': 0.09; 'try:': 0.09; 'wrapped': 0.09; 'python': 0.11; 'def': 0.12; 'stored': 0.12; '(also': 0.16; '(x,': 0.16; '39,': 0.16; 'appear.': 0.16; 'coordinates': 0.16; 'empty.': 0.16; 'file).': 0.16; 'formatted': 0.16; 'normally,': 0.16; 'other,': 0.16; 'permits': 0.16; 'res': 0.16; 'res:': 0.16; 'sqlite': 0.16; 'url:json': 0.16; '(you': 0.16; 'url:)': 0.16; '(not': 0.18; 'command': 0.22; 'appears': 0.22; 'example': 0.22; 'import': 0.22; 'previously': 0.22; 'to:name:python-list@python.org': 0.22; 'print': 0.22; 'error': 0.23; 'format,': 0.24; 'headers': 0.24; 'string,': 0.24; 'file.': 0.24; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'database,': 0.30; 'code': 0.31; 'getting': 0.31; "skip:' 10": 0.31; 'extract': 0.31; 'keys': 0.31; 'file': 0.32; 'compatible': 0.32; 'url:python': 0.33; 'skip:# 10': 0.33; 'table': 0.34; 'subject:from': 0.34; 'info': 0.35; 'display': 0.35; 'connection': 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'there': 0.35; 'returning': 0.36; 'skip:j 20': 0.36; 'done': 0.36; 'shows': 0.36; 'url:org': 0.36; 'two': 0.37; 'server': 0.38; 'url:library': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'is.': 0.60; 'skip:z 20': 0.60; 'information,': 0.61; 'show': 0.63; 'information': 0.63; 'map': 0.64; 'taking': 0.65; 'charset:windows-1252': 0.65; 'url:png': 0.68; 'url:17': 0.68; 'containing': 0.69; 'url:4': 0.69; 'apart': 0.72; 'url:a': 0.72; 'url:page': 0.74; 'comment.': 0.84; 'tiles': 0.84; 'together,': 0.84; 'url:74': 0.84; 'url:14': 0.95 X-TMN: [gBMttloaQnpmcCOra7i+s92i0XUmRrAzriHC4FA8HjQ=] X-Originating-Email: [embrujada_w@hotmail.com] Content-Type: multipart/mixed; boundary="_fe499687-3f2b-47b6-aa9c-1452143f2d0c_" From: Carmen Campos Bordons To: "python-list@python.org" Subject: Extract UTFGrid from MBTiles database Date: Mon, 3 Jun 2013 12:02:37 +0000 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 03 Jun 2013 12:02:37.0957 (UTC) FILETIME=[3DBAF350:01CE6052] X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 248 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370261027 news.xs4all.nl 15883 [2001:888:2000:d::a6]:47662 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46786 --_fe499687-3f2b-47b6-aa9c-1452143f2d0c_ Content-Type: multipart/alternative; boundary="_4f937173-8ee5-41d3-9478-f124a755e263_" --_4f937173-8ee5-41d3-9478-f124a755e263_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable I would appreciate any help or comment. The idea is=0A= to create a server in python that serves maps on the internet. The maps hav= e to=0A= be in MBTiles format=2C which is a SQLite database that store all the map t= iles=0A= in a single file. Taking this as an example http://a.tiles.mapbox.com/v3/ma= pbox.geography-class/page.html#4.00/36.74/28.30 The tiles are images of the= =0A= map in png=2C like this one http://a.tiles.mapbox.com/v3/mapbox.geography-c= lass/4/7/7.png and apart from the tiles=2C in the=0A= database is stored the UTFGrid information=2C 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 yo= u hover in the=0A= map=2C some extra information appears referring to the point where the mous= e is.=0A= As you can see in this example http://a.tiles.mapbox.com/v3/mapbox.geograph= y-class/page.html#4.00/36.74/28.30 a infobox appears with the=0A= flag of every country(which is the information stored in the UTFGrid file).= =0A= =0A= In the=0A= MBTiles database there are two table (also other=2C but not important in th= is case):=0A= =93tiles=94=2C where are stored the tiles=3B and =93grids=94=2C where is st= ored the UTFGrid=0A= associated to every tile.=0A= =0A= >From the=0A= MBTiles I can extract the tiles and display a normal map=2C and I can also= =0A= extract the UTFGrid file individually (not all together=2C like the tiles t= hat I=0A= can see the whole map=3B with the UTFGrid I just get one file). When I show= the=0A= map normally=2C the infoboxes do not appear. But I do not get any error in= =0A= command line or in the website. It just like the UTFGrid is empty.=0A= =0A= Attached is=0A= the code I am using to access the MBtiles file.=0A= =0A= I am using=0A= this SQL to access the MBTiles file=0A= =0A= =93select=0A= grid from grids where tile_column=3D? and tile_row=3D? and zoom_level=3D?"= =2C (x=2C=0A= y=2C z)=0A= =0A= And if I=0A= change it for this=0A= =0A= "select=0A= grid from grids where tile_column=3D? and tile_row=3D? and zoom_level=3D?"= =2C (67=2C=0A= 84=2C 7)=0A= =0A= I am=0A= getting always the same UTFGrid=2C but in this case it shows the infoboxes = on the=0A= map=2C that one for all the tiles.=0A= =0A= It is like=0A= if I have this part of the map http://a.tiles.mapbox.com/v3/mapbox.geograph= y-class/page.html#4.00/10.14/17.31 but I always get the=0A= infoboxes of this tile http://a.tiles.mapbox.com/v3/mapbox.geography-class/= 4/7/7.png I get the infoboxes in all the=0A= tiles=2C but all of them are showing the flag of that tile. Thanks=2CCarmen = --_4f937173-8ee5-41d3-9478-f124a755e263_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

I would appreciate any help or comment.


The idea is=0A= to create a server in python that serves maps on the internet. The maps hav= e to=0A= be in MBTiles format=2C which is a SQLite database that store all the map t= iles=0A= 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 th= e=0A= map in png=2C like this one http://a.tiles.mapbo= x.com/v3/mapbox.geography-class/4/7/7.png a= nd apart from the tiles=2C in the=0A= database is stored the UTFGrid information=2C like this file http://a.tiles.mapbox.com/v3/mapbox.geography-class/4/7/= 7.grid.json. The UTFGrid (you can consult i= n http://www.mapbox.com/developers/utfgrid/) permits than when you hover in the=0A= map=2C some extra information appears referring to the point where the mous= e is.=0A= 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=0A= flag of every country(which is the information stored in the UTFGrid file).=

=0A= =0A=

In the=0A= MBTiles database there are two table (also other=2C but not important in th= is case):=0A= =93tiles=94=2C where are stored the tiles=3B and =93grids=94=2C where is st= ored the UTFGrid=0A= associated to every tile.

=0A= =0A=

From the=0A= MBTiles I can extract the tiles and display a normal map=2C and I can also= =0A= extract the UTFGrid file individually (not all together=2C like the tiles t= hat I=0A= can see the whole map=3B with the UTFGrid I just get one file). When I show= the=0A= map normally=2C the infoboxes do not appear. But I do not get any error in= =0A= command line or in the website. It just like the UTFGrid is empty.

=0A= =0A=

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

=0A= =0A=

I am using=0A= this SQL to access the MBTiles file

=0A= =0A=

=93select=0A= grid from grids where tile_column=3D? and tile_row=3D? and zoom_level=3D?"= =2C (x=2C=0A= y=2C z)

=0A= =0A=

And if I=0A= change it for this

=0A= =0A=

"select=0A= grid from grids where tile_column=3D? and tile_row=3D? and zoom_level=3D?"= =2C (67=2C=0A= 84=2C 7)

=0A= =0A=

I am=0A= getting always the same UTFGrid=2C but in this case it shows the infoboxes = on the=0A= map=2C that one for all the tiles.

=0A= =0A=

It is like=0A= 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=0A= infoboxes of this tile http://a.tiles.mapbox.com= /v3/mapbox.geography-class/4/7/7.png I get = the infoboxes in all the=0A= tiles=2C but all of them are showing the flag of that tile.


Thanks=2C

Carmen

= --_4f937173-8ee5-41d3-9478-f124a755e263_-- --_fe499687-3f2b-47b6-aa9c-1452143f2d0c_ Content-Type: text/x-script.phyton Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="python_code.py" DQppbXBvcnQgc3FsaXRlMw0KaW1wb3J0IGpzb24NCmltcG9ydCB6bGliDQoNCmRlZiBnZXRfdGls ZShsYXllciwgeCwgeSwgeiwgZXh0KToNCgl0cnk6DQoJCSMgQ29ubmVjdCB0byB0aGUgZGF0YWJh c2UgYW5kIGdldCB0aGUgY3Vyc29yDQoJCWRiID0gc3FsaXRlMy5jb25uZWN0KCJkYXRhLyVzLm1i dGlsZXMiICUgbGF5ZXIpDQoJCWMgPSBkYi5jdXJzb3IoKQ0KCQkjY2xvc2luZyhkYi5jdXJzb3Ip DQoJZXhjZXB0Og0KCQkjIHJldHVybiBOb25lDQoJCSMgSW4gY2FzZSB0aGUgY29ubmVjdGlvbiBj YW4gbm90IGJlIGRvbmUNCgkJc3RhcnRfcmVzcG9uc2UoJzQwNCBOb3QgZm91bmQnLCBbKCdDb250 ZW50LVR5cGUnLCAndGV4dC9wbGFpbicpXSkNCgkJcmV0dXJuIFsiTm90IGZvdW5kOiAlcy5tYnRp bGVzIiAlIChsYXllciwpXQ0KCSMgR2V0IHRoZSB0aWxlcyBmcm9tIHRoZSBkYXRhYmFzZSwgdXNp bmcgdGhlIHpvb20gYW5kIHRoZSBjb29yZGluYXRlcyB3ZSBnb3QgcHJldmlvdXNseQ0KCWMuZXhl Y3V0ZSgic2VsZWN0IHRpbGVfZGF0YSBmcm9tIHRpbGVzIHdoZXJlIHRpbGVf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