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),
    );
  }