src/Lootils/Geo/Location.php
public function latitudeRange($distance) {
    $long = deg2rad($this->longitude());
    $lat = deg2rad($this->latitude());

    $radius = $this->earthRadius($this->latitude());
    $angle = $distance / $radius;
    $rightangle = pi() / 2;

    $minlat = $lat - $angle;
    if ($minlat < -$rightangle) { // wrapped around the south pole
      $overshoot = -$minlat - $rightangle;
      $minlat = -$rightangle + $overshoot;
      if ($minlat > $maxlat) { $maxlat = $minlat; }
      $minlat = -$rightangle;
    }

    $maxlat = $lat + $angle;
    if ($maxlat > $rightangle) { // wrapped around the north pole
      $overshoot = $maxlat - $rightangle;
      $maxlat = $rightangle - $overshoot;
      if ($maxlat < $minlat) { $minlat = $maxlat; }
      $maxlat = $rightangle;
    }

    return array(
      'min' => rad2deg($minlat),
      'max' => rad2deg($maxlat),
    );
  }
public function latitudeRange($distance) {
    $long = deg2rad($this->longitude());
    $lat = deg2rad($this->latitude());

    $radius = $this->earthRadius($this->latitude());
    $angle = $distance / $radius;
    $rightangle = pi() / 2;

    $minlat = $lat - $angle;
    if ($minlat < -$rightangle) { // wrapped around the south pole
      $overshoot = -$minlat - $rightangle;
      $minlat = -$rightangle + $overshoot;
      if ($minlat > $maxlat) { $maxlat = $minlat; }
      $minlat = -$rightangle;
    }

    $maxlat = $lat + $angle;
    if ($maxlat > $rightangle) { // wrapped around the north pole
      $overshoot = $maxlat - $rightangle;
      $maxlat = $rightangle - $overshoot;
      if ($maxlat < $minlat) { $minlat = $maxlat; }
      $maxlat = $rightangle;
    }

    return array(
      'min' => rad2deg($minlat),
      'max' => rad2deg($maxlat),
    );
  }
Find a range of latitudes given a center point.

This is useful when you have a center point and want to find a range to
query against a set. For example, you want to find all the businesses to
display on the glowing rectangle (mobile device) given a center point and
radius.

Note, this are just quickly calculated estimates.

@param float $distance
The distance in meters from the center point to calculate.

@return array
An array with the two bounding values (floats) for the range.