Bounding Box Queries

Bounding Box Queries

Bounding box queries are implemented via HTTP method and URI.

Note: Use of the bounding box parameter is discouraged. Use the start_range and end_range parameters instead. Every bounding box can be expressed with start_range and end_range parameters.

If a bounding box is not supplied, the full data set is returned. When querying a spatial index, use the bounding box to specify the boundaries of the query lookup on a given value. The specification should be in the form of a comma-separated list of the coordinates to use during the query.

These coordinates are specified as in the GeoJSON specification, so the first two numbers are the lower left coordinates, and the last two numbers are the upper right coordinates.

A bounding box can be expressed as with start_range and end_range parameters. Example:

bbox=0,0,180,90
start_range=[0,0]&end_range[180,90]

Syntax

GET http://[localhost]:8092/places/_design/[design-doc]/_spatial/points?bbox=-180,-90,0,0
Content-Type: application/json
   

Example

HTTP request example:

GET http://127.0.0.1:8092/places/_design/main/_spatial/points?bbox=-180,-90,0,0
Content-Type: application/json

Response

Example response:

{
    "total_rows": 0,
    "rows": [
        {
            "id": "oakland",
            "key": [
                [
                    -122.270833,
                    -122.270833
                ],
                [
                    37.804444,
                    37.804444
                ]
            ],
            "value": [
                "oakland",
                [
                    -122.270833,
                    37.804444
                ]
            ]
        }
    ]
}