TileStache.Goodies.VecTiles.server | index

`Provider that returns PostGIS vector tiles in GeoJSON or MVT format.
VecTiles is intended for rendering, and returns tiles with contents simplified,
precision reduced and often clipped. The MVT format in particular is designed
for use in Mapnik with the VecTiles Datasource, which can read binary MVT tiles.
For a more general implementation, try the Vector provider:
http://tilestache.org/doc/#vector-provider`

Modules

``

TileStache.Goodies.VecTiles.geojson | TileStache.Goodies.VecTiles.mvt | TileStache.Goodies.VecTiles.topojson |

Classes

``

Connection
EmptyResponse
MultiProvider
MultiResponse
Provider
Response

class Connection
`` | `Context manager for Postgres connections. See http://www.python.org/dev/peps/pep-0343/ and http://effbot.org/zone/python-with-statement.htm`

Methods defined here:

__enter__(self)

__exit__(self, type, value, traceback)

__init__(self, dbinfo)

class EmptyResponse
`` | `Simple empty response renders valid MVT or GeoJSON with no features.`

Methods defined here:

__init__(self, bounds)

save(self, out, format)

class MultiProvider

``

`VecTiles provider to gather PostGIS tiles into a single multi-response.
Returns a MultiResponse object for GeoJSON or TopoJSON requests.
names:
List of names of vector-generating layers from elsewhere in config.
Sample configuration, for a layer with combined data from water
and land areas, both assumed to be vector-returning layers:
"provider":
{
"class": "TileStache.Goodies.VecTiles:MultiProvider",
"kwargs":
{
"names": ["water-areas", "land-areas"]
}
}
`

Methods defined here:

__init__(self, layer, names)

getTypeByExtension(self, extension)
  `Get mime-type and format by file extension, "json" or "topojson" only.`

renderTile(self, width, height, srs, coord)
  `Render a single tile, return a Response instance.`

class MultiResponse

``

Methods defined here:

__init__(self, config, names, coord)
  `Create a new response object with TileStache config and layer names.`

save(self, out, format)

class Provider

``

`VecTiles provider for PostGIS data sources.
Parameters:
dbinfo:
Required dictionary of Postgres connection parameters. Should
include some combination of 'host', 'user', 'password', and 'database'.
queries:
Required list of Postgres queries, one for each zoom level. The
last query in the list is repeated for higher zoom levels, and null
queries indicate an empty response.
Query must use "__geometry__" for a column name, and must be in
spherical mercator (900913) projection. A query may include an
"__id__" column, which will be used as a feature ID in GeoJSON
instead of a dynamically-generated hash of the geometry. A query
can additionally be a file name or URL, interpreted relative to
the location of the TileStache config file.
If the query contains the token "!bbox!", it will be replaced with
a constant bounding box geomtry like this:
"ST_SetSRID(ST_MakeBox2D(ST_MakePoint(x, y), ST_MakePoint(x, y)), <srid>)"
This behavior is modeled on Mapnik's similar bbox token feature:
https://github.com/mapnik/mapnik/wiki/PostGIS#bbox-token
clip:
Optional boolean flag determines whether geometries are clipped to
tile boundaries or returned in full. Default true: clip geometries.
srid:
Optional numeric SRID used by PostGIS for spherical mercator.
Default 900913.
simplify:
Optional floating point number of pixels to simplify all geometries.
Useful for creating double resolution (retina) tiles set to 0.5, or
set to 0.0 to prevent any simplification. Default 1.0.
simplify_until:
Optional integer specifying a zoom level where no more geometry
simplification should occur. Default 16.
Sample configuration, for a layer with no results at zooms 0-9, basic
selection of lines with names and highway tags for zoom 10, a remote
URL containing a query for zoom 11, and a local file for zooms 12+:
"provider":
{
"class": "TileStache.Goodies.VecTiles:Provider",
"kwargs":
{
"dbinfo":
{
"host": "localhost",
"user": "gis",
"password": "gis",
"database": "gis"
},
"queries":
[
null, null, null, null, null,
null, null, null, null, null,
"SELECT way AS __geometry__, highway, name FROM planet_osm_line -- zoom 10+ ",
"http://example.com/query-z11.pgsql",
"query-z12-plus.pgsql"
]
}
}
`

Methods defined here:

__init__(self, layer, dbinfo, queries, clip=True, srid=900913, simplify=1.0, simplify_until=16)

getTypeByExtension(self, extension)
  `Get mime-type and format by file extension, one of "mvt", "json" or "topojson".`

renderTile(self, width, height, srs, coord)
  `Render a single tile, return a Response instance.`

class Response

``

Methods defined here:

__init__(self, dbinfo, srid, subquery, columns, bounds, tolerance, zoom, clip)
  `Create a new response object with Postgres connection info and a query.
  bounds argument is a 4-tuple with (xmin, ymin, xmax, ymax).`

save(self, out, format)

Functions

``

build_query(srid, subquery, subcolumns, bbox, tolerance, is_geo, is_clipped)
  `Build and return an PostGIS query.`

connect(*args, **kwargs)

query_columns(dbinfo, srid, subquery, bounds)
  `Get information about the columns returned for a subquery.`

Data

``

err = ImportError('No module named psycopg2.extras',)
pi = 3.1415926535897931
tolerances = [156543.03392804097, 78271.516964020484, 39135.758482010242, 19567.879241005121, 9783.9396205025605, 4891.9698102512803, 2445.9849051256401, 1222.9924525628201, 611.49622628141003, 305.74811314070502, 152.87405657035251, 76.437028285176254, 38.218514142588127, 19.109257071294063, 9.5546285356470317, 4.7773142678235159, 2.3886571339117579, 1.194328566955879, 0.59716428347793948, 0.29858214173896974]
zoom = 19