Querying on the East

Querying on the East

This query retrieves data based on the GeoJSON polygons example and associated with the eastern hemisphere.

Description

In this example, all documents that are on the eastern hemisphere are queried. In addition, since the area is also emitted as third dimension, queries need to contain that as well. As we don't care what the area is, we'll query it with the wildcard, null. So the final query is:

This means the following coordinates are specified:

  • longitude (first dimension) greater than 0 and smaller than 180
  • latitude (second dimension) between -90 and 90.
  • null (third dimension) as a wildcard since, in this case, the third dimension doesn't matter.

The longitude and latitude are represented by the query parameters are start_range=[0,-90]&end_range=[180,90]. If just those two query parameters are specified, an error message displays indicating that the dimensionality doesn't match. That's why the null wildcard is used to represent the third dimension.

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://10.5.2.54:8092/default/_design/areas/_spatial/locAndArea?start_range=[0,-90,null]&end_range=[180,90,null]

Response

The results contain only the Flemish Diamond:

{"total_rows":0,"rows":[
    {"id": "flemish_diamond",
     "key":[[3.55,4.84],[50.73,51.3],[2947,2947]],
     "value":"Flemish Diamond",
     "geometry":{"type":"Polygon","coordinates":[[[3.55,51.08],[4.36,50.73],[4.84,50.85],[4.45,51.3],[3.55,51.08]]]}}]}