/**
* 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;
}