public function nearPointSpherical($field, $longitude, $latitude, $distance)
    {
        $point = new Point(array(
            (float) $longitude,
            (float) $latitude
        ));

        $near = array(
            '$geometry' => $point->jsonSerialize(),
        );

        if (is_array($distance)) {
            if (!empty($distance[0])) {
                $near['$minDistance'] = (int) $distance[0];
            }
            if (!empty($distance[1])) {
                $near['$maxDistance'] = (int) $distance[1];
            }
        } else {
            $near['$maxDistance'] = (int) $distance;
        }

        $this->where($field, array('$nearSphere' => $near));

        return $this;
    }
public function nearPointSpherical($field, $longitude, $latitude, $distance)
    {
        $point = new Point(array(
            (float) $longitude,
            (float) $latitude
        ));

        $near = array(
            '$geometry' => $point->jsonSerialize(),
        );

        if (is_array($distance)) {
            if (!empty($distance[0])) {
                $near['$minDistance'] = (int) $distance[0];
            }
            if (!empty($distance[1])) {
                $near['$maxDistance'] = (int) $distance[1];
            }
        } else {
            $near['$maxDistance'] = (int) $distance;
        }

        $this->where($field, array('$nearSphere' => $near));

        return $this;
    }
public function nearPointSpherical ( $ field , $ longitude , $ latitude , $ distance ) { $ point = new Point ( array ( ( float ) $ longitude , ( float ) $ latitude ) ) ; $ near = array ( '$geometry' => $ point -> jsonSerialize ( ) , ) ; if ( is_array ( $ distance ) ) { if ( ! empty ( $ distance [ 0 ] ) ) { $ near [ '$minDistance' ] = ( int ) $ distance [ 0 ] ; } if ( ! empty ( $ distance [ 1 ] ) ) { $ near [ '$maxDistance' ] = ( int ) $ distance [ 1 ] ; } } else { $ near [ '$maxDistance' ] = ( int ) $ distance ; } $ this -> where ( $ field , array ( '$nearSphere' => $ near ) ) ; return $ this ; }
Find document near points in spherical surface

@param string $field
@param float $longitude
@param float $latitude
@param int|array $distance distance from point in meters. Array distance
allowed only in MongoDB 2.6
@return Expression
Find document near points in spherical surface