[GIS] How to serve MBTiles with TileStache

mbtilestilemilltilestache

I'm am looking for a way to serve tiles while offline. I'm using Windows 7. Here's what I've done so far:

-Uploaded a portion of OSM data into TileMill
-Converted the OSM data into a file called osm.mbtiles
-Installed Python and Mapnik
-Installed TileStache (to C:\TileStache-1.49.10) and its dependencies (Pillow,   ModestMaps,SimpleJSON, Werkzeug)
-Placed osm.mbtiles into the TileStache folder (to C:\TileStache-1.49.10\osm.mbtiles)
-Written test.cfg to look like this:

{
  "cache":
  {
    "name": "Test"
  },
  "layers": 
  {
    "osm":
    {
        "provider": {"name": "mbtiles", "tileset": "osm.mbtiles"}

    }
  }
}

-Place the config file here: C:\TileStache-1.49.10\test.cfg

Then, after all of that is done, I run:

C:\TileStache-1.49.10>tilestache-server.py -c test.cfg

After I run that command, I see:

 * Running on http:<IP_ADDR>:8080

So, I open up my web browser and go to:

localhost:8080/osm/preview.html

which is then routed to:

http://localhost:8080/roads/preview.html#10/37.8000/-122.2600

I see nothing on this page, but the server in the terminal is spitting out this:

enter image description here

Also, I've tried all the steps above using world map converted to .mbtiles using zoom level 0-8 and then manually changing the URL of the tilestache server page to be:

http://localhost:8080/roads/preview.html#3/50/50

But, I still get the same errors and nothing shows up. What should I try to fix this?

Best Answer

As it turns out, TileStache ends up taking the file name from the configuration file and prepending it with a "/". So, for Windows, this means that you have to place your .mbtiles file at the root of your drive if you want the server to be able to find it.

Or, if you're feeling "hacky", you can go into the MBTiles.py file and hardcode a "." in front of the filename variable that was giving the database connection error (line 153). This makes the path look like ./ instead of /. Of course, this means your code breaks if you need to update to a newer version of TileStache, thus making this a "hacky" solution.

Related Question