Querying GeoCouch
Once you've setup GeoCouch it’s time to query it. This is done through CouchDB’s _external interface. A requests looks like that:
http://localhost:5984/<db-name>/_external/geo/<design-doc>?name=<geometry-name>'
- db-name:
The database you geo-enabled
- design-doc:
The design document that contains the geo property
- geometry-name:
The arbitrary string used in the geo property that defines a geometry
All responses are an array (JSON notation) of document IDs that were valid for the spatial request.
Query parameters
The query parameters follow the OpenSearch-Geo extension draft. Currently supported arguments are listed below.
bbox
A bounding box search. It returns all document IDs that are with the specified bounding box.
bbox=west,south,east,north
Example request:
http://localhost:5984/geodata/_external/geo/default?name=streets&bbox=-10.1,30.424,131.987,73.83
p
A polygon search. It returns all document IDs that are with the specified polygon. In contrast to the OpenSearch-Geo extension draft the order of the coordinates dosn’t matter (they don’t need to be in clockwise order) and the polygon will be closed automatically.
p=x1,y1,x2,y2,x3,y3,…
Example request:
http://localhost:5984/geodata/_external/geo/default?name=streets&p=10,20,10,30,15,60,50,30,50,20
radius
New in version 0.10.1
Return all geometries of the given name within a certain radius (in metre) around a coordinate.
radius=distance_in_metre,lat=latitude,lon=longitude
Example request:
http://localhost:5984/geodata/_external/geo/default?name=streets&radius=107.374,lat=32.425,lon=121.5872

