TileStache.Goodies.Providers.SolrGeoJSON module

Provider that returns GeoJSON data responses from Solr spatial queries.

This is an example of a provider that does not return an image, but rather queries a Solr instance for raw data and replies with a string of GeoJSON.

Read more about the GeoJSON spec at: http://geojson.org/geojson-spec.html

Caveats:

Example TileStache provider configuration:

“solr”: {
“provider”: {“class”: “TileStache.Goodies.Providers.SolrGeoJSON.Provider”,
“kwargs”: {
“solr_endpoint”: “http://localhost:8983/solr/example”, “solr_query”: “:”,

}}

}

The following optional parameters are also supported:

latitude_field: The name of the latitude field associated with your query parser; the default is ‘latitude’

longitude_field: The name of the longitude field associated with your query parser, default is ‘longitude

response_fields: A comma-separated list of fields with which to filter the Solr response; the default is ‘’ (or: include all fields)

id_field: The name name of your Solr instance’s unique ID field; the default is ‘’.

By default queries are scoped to the bounding box of a given tile. Radial queries are also supported if you supply a ‘radius’ kwarg to your provider and have installed the JTeam spatial plugin: http://www.jteam.nl/news/spatialsolr.html.

For example:

“solr”: {
“provider”: {“class”: “TileStache.Goodies.Providers.SolrGeoJSON.Provider”,
“kwargs”: {
“solr_endpoint”: “http://localhost:8983/solr/example”, “solr_query”: ‘foo:bar’, “radius”: “1”,

}}

}

Radial queries are begin at the center of the tile being rendered and distances are measured in kilometers.

The following optional parameters are also supported for radial queries:

query_parser: The name of the Solr query parser associated with your spatial plugin; the default is ‘spatial’.

class TileStache.Goodies.Providers.SolrGeoJSON.Provider(layer, solr_endpoint, solr_query, **kwargs)
getTypeByExtension(extension)

Get mime-type and format by file extension.

This only accepts “json”.

renderTile(width, height, srs, coord)

Render a single tile, return a SaveableResponse instance.

unproject(x, y)
class TileStache.Goodies.Providers.SolrGeoJSON.SaveableResponse(content)

Wrapper class for JSON response that makes it behave like a PIL.Image object.

TileStache.getTile() expects to be able to save one of these to a buffer.

save(out, format)