public static function boundingBox($latitude, $longitude, $mileRange) {
      $maxLatitude = $latitude + $mileRange / self::EQUATOR_LAT_DEGREE_IN_MILES;
      $minLatitude = $latitude - ($maxLatitude - $latitude);

      $maxLongitude = $longitude + $mileRange / (cos($minLatitude * M_PI / 180) * self::EQUATOR_LAT_DEGREE_IN_MILES);
      $minLongitude = $longitude - ($maxLongitude - $longitude);

      return array('lat' => array('max' => $maxLatitude,
                                  'min' => $minLatitude),
                   'lon' => array('max' => $maxLongitude,
                                  'min' => $minLongitude));
    }
public static function boundingBox($latitude, $longitude, $mileRange) {
      $maxLatitude = $latitude + $mileRange / self::EQUATOR_LAT_DEGREE_IN_MILES;
      $minLatitude = $latitude - ($maxLatitude - $latitude);

      $maxLongitude = $longitude + $mileRange / (cos($minLatitude * M_PI / 180) * self::EQUATOR_LAT_DEGREE_IN_MILES);
      $minLongitude = $longitude - ($maxLongitude - $longitude);

      return array('lat' => array('max' => $maxLatitude,
                                  'min' => $minLatitude),
                   'lon' => array('max' => $maxLongitude,
                                  'min' => $minLongitude));
    }
public static function boundingBox ( $ latitude , $ longitude , $ mileRange ) { $ maxLatitude = $ latitude + $ mileRange / self :: EQUATOR_LAT_DEGREE_IN_MILES ; $ minLatitude = $ latitude - ( $ maxLatitude - $ latitude ) ; $ maxLongitude = $ longitude + $ mileRange / ( cos ( $ minLatitude * M_PI / 180 ) * self :: EQUATOR_LAT_DEGREE_IN_MILES ) ; $ minLongitude = $ longitude - ( $ maxLongitude - $ longitude ) ; return array ( 'lat' => array ( 'max' => $ maxLatitude , 'min' => $ minLatitude ) , 'lon' => array ( 'max' => $ maxLongitude , 'min' => $ minLongitude ) ) ; }
Computes a four point bounding box around the specified location. This
can then be used to find all locations within an X-mile range of a central
location. A bounding box is much easier and faster to compute than a
bounding radius.

The returned array contains two keys: 'lat' and 'lon'. Each of these
contains another array with two keys: 'max' and 'min'. Four points are
returned in total.

@param  float|string $latitude to draw the bounding box around
@param  float|string $longitude to draw the bounding box around
@param  int|float|string $mileRange mile range around point
@return array 'lat' and 'lon' 'min' and 'max' points
Computes a four point bounding box around the specified location . This can then be used to find all locations within an X - mile range of a central location . A bounding box is much easier and faster to compute than a bounding radius .