minDistance() public method

This method must be called after near() or nearSphere(), since placement of the $minDistance option depends on whether a GeoJSON point or legacy coordinates were provided for $near/$nearSphere.
See also: http://docs.mongodb.org/manual/reference/operator/minDistance/
public minDistance ( float $minDistance )
$minDistance float
Beispiel #1
0
 /**
  * Set the "minDistance" option for a geoNear command query or add
  * $minDistance criteria to the query.
  *
  * If the query is a geoNear command ({@link Expr::geoNear()} was called),
  * the "minDistance" command option will be set; otherwise, $minDistance
  * will be added to the current expression.
  *
  * If the query uses GeoJSON points, $minDistance will be interpreted in
  * meters. If legacy point coordinates are used, $minDistance will be
  * interpreted in radians.
  *
  * @see Expr::minDistance()
  * @see http://docs.mongodb.org/manual/reference/command/geoNear/
  * @see http://docs.mongodb.org/manual/reference/operator/minDistance/
  * @see http://docs.mongodb.org/manual/reference/operator/near/
  * @see http://docs.mongodb.org/manual/reference/operator/nearSphere/
  * @param float $minDistance
  * @return self
  */
 public function minDistance($minDistance)
 {
     if ($this->query['type'] === Query::TYPE_GEO_NEAR) {
         $this->query['geoNear']['options']['minDistance'] = $minDistance;
     } else {
         $this->expr->minDistance($minDistance);
     }
     return $this;
 }
Beispiel #2
0
 /**
  * Add $minDistance criteria to the query.
  *
  * If the query uses GeoJSON points, $minDistance will be interpreted in
  * meters. If legacy point coordinates are used, $minDistance will be
  * interpreted in radians.
  *
  * @see Expr::minDistance()
  * @see http://docs.mongodb.org/manual/reference/command/geoNear/
  * @see http://docs.mongodb.org/manual/reference/operator/minDistance/
  * @see http://docs.mongodb.org/manual/reference/operator/near/
  * @see http://docs.mongodb.org/manual/reference/operator/nearSphere/
  * @param float $minDistance
  * @return $this
  */
 public function minDistance($minDistance)
 {
     $this->query->minDistance($minDistance);
     return $this;
 }
Beispiel #3
0
 /**
  * @expectedException BadMethodCallException
  */
 public function testMinDistanceRequiresNearOrNearSphereOperator()
 {
     $expr = new Expr();
     $expr->minDistance(1);
 }