Doctrine\MongoDB\Query\Builder::geoNear PHP Method

geoNear() public method

A GeoJSON point may be provided as the first and only argument for 2dsphere queries. This single parameter may be a GeoJSON point object or an array corresponding to the point's JSON representation. If GeoJSON is used, the "spherical" option will default to true. This method sets the "near" option for the geoNear command. The "num" option may be set using {@link Expr::limit()}. The "distanceMultiplier", "maxDistance", "minDistance", and "spherical" options may be set using their respective builder methods. Additional query criteria will be assigned to the "query" option.
See also: http://docs.mongodb.org/manual/reference/command/geoNear/
public geoNear ( float | array | GeoJson\Geometry\Point $x, float $y = null )
$x float | array | GeoJson\Geometry\Point
$y float
    public function geoNear($x, $y = null)
    {
        if ($x instanceof Point) {
            $x = $x->jsonSerialize();
        }
        $this->query['type'] = Query::TYPE_GEO_NEAR;
        $this->query['geoNear'] = ['near' => is_array($x) ? $x : [$x, $y], 'options' => ['spherical' => is_array($x) && isset($x['type'])]];
        return $this;
    }