Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TileStache: More Then You’re Granddad’s TileCac...

TileStache: More Then You’re Granddad’s TileCache Server

An overview of the TileStache tiled web mapping server. Presented at the CUGOS Fall Fling Bling, October 2013.

Matthew Kenny

October 16, 2013
Tweet

More Decks by Matthew Kenny

Other Decks in Programming

Transcript

  1. Our Lightening-Fast Agenda • What is TileStache? • What does

    it Cache/Render? • How can it be extended?
  2. What is it? “TileStache is a Python-based server application that

    can serve up map tiles based on rendered geographic data.” - http://tilestache.org
  3. Distinct Functionality • Caches: Instructions for storing tiles generated via

    a Provider class instance. • Providers: Instructions for rendering a tile in a specifc format (raster/vector) from a specific data source (postgis/shp). • Configuration File: Links providers with caches.
  4. TopoJSON - Config Example 01: "layers": { 02: "osm-processed_p10": {

    03: "allowed origin": "*", 04: "provider": { 05: "class": "TileStache.Goodies.VecTiles:Provider", 06: "kwargs": { 07: "dbinfo": { 08: "host": "localhost", 09: "user": "matt", 10: "database": "ts_data" 11: }, 12: "simplify": 10.0, 13: "queries": [ 14: "SELECT gid, geom AS __geometry__ FROM 15: osm.land_polygons_split" 16: ] 17: }}}}
  5. Extending “It should be quick and easy to understand what

    the library is doing and why... Where possible, dynamic programming “magic” is to be avoided, in favor of basic, procedural and copiously-documented Python.” - Project Docs
  6. Extending class ProviderStub: def __init__(self, layer): # create a new

    provider for a layer raise NotImplementedError def renderTile(self, width, height, srs, coord): # return an object with a PIL-like save() method for a tile raise NotImplementedError def renderArea(self, width, height, srs, xmin, ymin, xmax, ymax, zoom): # return an object with a PIL-like save() method for an area raise NotImplementedError
  7. +

  8. GIF Layer - Config File 01:        "gif_layer":

     { 02:            "provider":  { 03:                "class":  "TileStache.Goodies.Providers.GiphyAPI:Provider", 04:                "kwargs":  { 05:                        "api_key":  "dc6zaTOxFJmzC", 06:                        "search_term":  "pizza-­‐cat", 07:                        "num_gifs":  16, 08:                        "num_threads":  4 09:                        } 10:            } 11:        }