TileStache.Goodies.Providers.PostGeoJSON | index /home/migurski/public_html/TileStache/TileStache/Goodies/Providers/PostGeoJSON.py |
Provider that returns GeoJSON data responses from PostGIS queries.
This is an example of a provider that does not return an image, but rather
queries a database for raw data and replies with a string of GeoJSON. For
example, it's possible to retrieve data for locations of OpenStreetMap points
of interest based on a query with a bounding box intersection.
Read more about the GeoJSON spec at: http://geojson.org/geojson-spec.html
Caveats:
Currently only databases in the 900913 (google) projection are usable, though
this is the default setting for imports from osm2pgsql. The "!bbox!" query
placeholder (see example below) must be lowercase, and expands to:
ST_SetSRID(ST_MakeBox2D(ST_MakePoint(ulx, uly), ST_MakePoint(lrx, lry)), 900913)
You must support the "900913" SRID in your PostGIS database for now. I'll make
this more flexible if this provider proves useful.
Example TileStache provider configuration:
"pois":
{
"provider": {"class": "TileStache.Goodies.Providers.PostGeoJSON.Provider",
"kwargs": {
"dsn": "dbname=geodata user=postgres",
"query": "SELECT osm_id, name, way FROM planet_osm_point WHERE way && !bbox! AND name IS NOT NULL",
"id_column": "osm_id", "geometry_column": "way"
}}
}
Classes | ||||||||||||||||
|
Functions | ||
|