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 Slide

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

    View 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 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 Slide

  5. Caches

    View Slide

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

    View Slide

  7. Providers

    View Slide

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

    View Slide

  9. TopoJSON - Requirements
    • PostGIS DB
    • Spherical Mercator (EPSG:900913) / WGS84

    View Slide

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

  11. View Slide

  12. View Slide

  13. 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 Slide

  14. 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 Slide

  15. +

    View Slide

  16. 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 Slide

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

    View Slide

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

    View Slide