Creating a Spatial View Function

Creating a Spatial View Function

A spatial view function is created to create a multidimensional view file for GeoJSON polygons.

To query based on the location and the area, create a multidimensional view function with three dimensions. Based on the GeoJSON polygon data information, the first two dimensions are the location and the third dimension is the area.

In the following example, a development view is created with the design document name of _design/areas and a spatial view named locAndArea.

function(doc, meta) {
  if (doc.geometry && doc.properties
      && doc.properties.area && doc.properties.name) {
    emit([doc.geometry, doc.properties.area], doc.properties.name);
  }
}