protected function getBoundingCoordinates(MapLocationValue $location, $distance)
    {
        $radiansLatitude = deg2rad($location->latitude);
        $radiansLongitude = deg2rad($location->longitude);
        $angularDistance = $distance / self::EARTH_RADIUS;
        $deltaLongitude = asin(sin($angularDistance) / cos($radiansLatitude));

        $lowLatitudeRadians = $radiansLatitude - $angularDistance;
        $highLatitudeRadians = $radiansLatitude + $angularDistance;

        // Check that bounding box does not include poles.
        if ($lowLatitudeRadians > -M_PI_2 && $highLatitudeRadians < M_PI_2) {
            $boundingCoordinates = array(
                'lowLatitude' => rad2deg($lowLatitudeRadians),
                'lowLongitude' => rad2deg($radiansLongitude - $deltaLongitude),
                'highLatitude' => rad2deg($highLatitudeRadians),
                'highLongitude' => rad2deg($radiansLongitude + $deltaLongitude),
            );
        } else {
            // Handle the pole(s) being inside a bounding box, in this case we MUST cover
            // full circle of Earth's longitude and one or both poles.
            // Note that calculation for distances over the polar regions with flat Earth formula
            // will be VERY imprecise.
            $boundingCoordinates = array(
                'lowLatitude' => rad2deg(max($lowLatitudeRadians, -M_PI_2)),
                'lowLongitude' => rad2deg(-M_PI),
                'highLatitude' => rad2deg(min($highLatitudeRadians, M_PI_2)),
                'highLongitude' => rad2deg(M_PI),
            );
        }

        return $boundingCoordinates;
    }
protected function getBoundingCoordinates(MapLocationValue $location, $distance)
    {
        $radiansLatitude = deg2rad($location->latitude);
        $radiansLongitude = deg2rad($location->longitude);
        $angularDistance = $distance / self::EARTH_RADIUS;
        $deltaLongitude = asin(sin($angularDistance) / cos($radiansLatitude));

        $lowLatitudeRadians = $radiansLatitude - $angularDistance;
        $highLatitudeRadians = $radiansLatitude + $angularDistance;

        // Check that bounding box does not include poles.
        if ($lowLatitudeRadians > -M_PI_2 && $highLatitudeRadians < M_PI_2) {
            $boundingCoordinates = array(
                'lowLatitude' => rad2deg($lowLatitudeRadians),
                'lowLongitude' => rad2deg($radiansLongitude - $deltaLongitude),
                'highLatitude' => rad2deg($highLatitudeRadians),
                'highLongitude' => rad2deg($radiansLongitude + $deltaLongitude),
            );
        } else {
            // Handle the pole(s) being inside a bounding box, in this case we MUST cover
            // full circle of Earth's longitude and one or both poles.
            // Note that calculation for distances over the polar regions with flat Earth formula
            // will be VERY imprecise.
            $boundingCoordinates = array(
                'lowLatitude' => rad2deg(max($lowLatitudeRadians, -M_PI_2)),
                'lowLongitude' => rad2deg(-M_PI),
                'highLatitude' => rad2deg(min($highLatitudeRadians, M_PI_2)),
                'highLongitude' => rad2deg(M_PI),
            );
        }

        return $boundingCoordinates;
    }
protected function getBoundingCoordinates ( MapLocationValue $ location , $ distance ) { $ radiansLatitude = deg2rad ( $ location -> latitude ) ; $ radiansLongitude = deg2rad ( $ location -> longitude ) ; $ angularDistance = $ distance / self :: EARTH_RADIUS ; $ deltaLongitude = asin ( sin ( $ angularDistance ) / cos ( $ radiansLatitude ) ) ; $ lowLatitudeRadians = $ radiansLatitude - $ angularDistance ; $ highLatitudeRadians = $ radiansLatitude + $ angularDistance ; // Check that bounding box does not include poles. if ( $ lowLatitudeRadians > - M_PI_2 && $ highLatitudeRadians < M_PI_2 ) { $ boundingCoordinates = array ( 'lowLatitude' => rad2deg ( $ lowLatitudeRadians ) , 'lowLongitude' => rad2deg ( $ radiansLongitude - $ deltaLongitude ) , 'highLatitude' => rad2deg ( $ highLatitudeRadians ) , 'highLongitude' => rad2deg ( $ radiansLongitude + $ deltaLongitude ) , ) ; } else { // Handle the pole(s) being inside a bounding box, in this case we MUST cover // full circle of Earth's longitude and one or both poles. // Note that calculation for distances over the polar regions with flat Earth formula // will be VERY imprecise. $ boundingCoordinates = array ( 'lowLatitude' => rad2deg ( max ( $ lowLatitudeRadians , - M_PI_2 ) ) , 'lowLongitude' => rad2deg ( - M_PI ) , 'highLatitude' => rad2deg ( min ( $ highLatitudeRadians , M_PI_2 ) ) , 'highLongitude' => rad2deg ( M_PI ) , ) ; } return $ boundingCoordinates ; }
Calculates and returns bounding box coordinates.

Credits: http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates

@todo it should also be possible to calculate inner bounding box, which could be applied for the
operators GT, GTE and lower distance of the BETWEEN operator.

@param \eZ\Publish\API\Repository\Values\Content\Query\Criterion\Value\MapLocationValue $location
@param float $distance

@return array
Calculates and returns bounding box coordinates .