Query.prototype.geometry()

Parameters
  • object «Object» Must contain a type property which is a String and a coordinates property which is an Array. See the examples.
Returns:
  • «Query» this

Specifies a $geometry condition

Example

  1. const polyA = [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]]
  2. query.where('loc').within().geometry({ type: 'Polygon', coordinates: polyA })
  3. // or
  4. const polyB = [[ 0, 0 ], [ 1, 1 ]]
  5. query.where('loc').within().geometry({ type: 'LineString', coordinates: polyB })
  6. // or
  7. const polyC = [ 0, 0 ]
  8. query.where('loc').within().geometry({ type: 'Point', coordinates: polyC })
  9. // or
  10. query.where('loc').intersects().geometry({ type: 'Point', coordinates: polyC })

The argument is assigned to the most recent path passed to where().

NOTE:

geometry() must come after either intersects() or within().

The object argument must contain type and coordinates properties. - type {String} - coordinates {Array}