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

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

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. TileStache: More Then You’re
    Granddad’s TileCache Server
    Matt Kenny, Tableau Software
    @mattmakesmaps
    http://mattmakesmaps.com

    View full-size slide

  2. Our Lightening-Fast Agenda
    • What is TileStache?
    • What does it Cache/Render?
    • How can it be extended?

    View full-size slide

  3. What is it?
    “TileStache is a Python-based server application that
    can serve up map tiles based on rendered geographic
    data.” - http://tilestache.org

    View full-size slide

  4. 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.

    View full-size slide

  5. Providers
    • Supported Raster-Based:
    • mapnik
    • MBTiles
    • Remote WMS Services

    View full-size slide

  6. Providers
    • Supported Non-Raster Based:
    • TopoJSON
    • GeoJSON/BSON
    • Arc GeoServices JSON/BSON (ESRI)
    • UTF Grids

    View full-size slide

  7. TopoJSON - Requirements
    • PostGIS DB
    • Spherical Mercator (EPSG:900913) / WGS84 <-- Out of the Box

    View full-size slide

  8. 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: }}}}

    View full-size slide

  9. 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

    View full-size slide

  10. 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

    View full-size slide

  11. 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:        }

    View full-size slide

  12. Demo Time
    http://mattmakesmaps.github.io/TileStache-GiphyAPI-Demo/

    View full-size slide

  13. Thanks!
    Slides/Links: http://mattmakesmaps.com
    twitter: @mattmakesmaps
    e-mail: [email protected]

    View full-size slide