maxDistance() публичный Метод

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