Querying on the Area

Querying on the Area

This query retrieves data based on the GeoJSON polygon example and associated with a large square footage.

Description

In this example, all documents queried are associated with any really large area. For example, the criteria could be any areas bigger than 10,000 square kilometers without caring about a specific location or query for areas bigger than 10,000 square kilometers without caring where they are.

In this case, the existing view can be queried with wildcards on the location (the first two dimensions) and an open range for the area.

HTTP method and URI

GET [bucket-name]/_design/[design-doc]/_spatial/[spatial-name]

Syntax

Curl syntax:

curl http://[localhost]:8092/[bucket-name]/_design/[design-doc]/_spatial/[spatial-name]?start_range=[]&end_range=[]

Example

The following example is based on the GeoJSON polygon data and the associated spatial view function.

Curl example:

curl http://localhost:8092/default/_design/areas/_spatial/locAndArea?start_range=[null,null,10000]&end_range=[null,null,null]

Alternatively, the query could have used start_range=[-180,-90,10000]&end_range=[180,90,null] because the longitudes and latitudes have those bounds.

Response

The results contain only the Bermuda Triangle:

{"total_rows":0,"rows":[
    {"id": "bermuda_triangle",
     "key": [[-80.19,-64.73],[18.43,32.31],[1150180,1150180]],
     "value": "Bermuda Triangle",
     "geometry": {"type":"Polygon","coordinates":[[[-64.73,32.31],[-80.19,25.76],[-66.09,18.43],[-64.73,32.31]]]}}]}