You are here

function earth_longitude_range in Location 5

Same name and namespace in other branches
  1. 5.3 earth.inc \earth_longitude_range()
  2. 6.3 earth.inc \earth_longitude_range()
  3. 7.5 earth.inc \earth_longitude_range()
  4. 7.3 earth.inc \earth_longitude_range()
  5. 7.4 earth.inc \earth_longitude_range()
3 calls to earth_longitude_range()
location_search_results in ./location.module
location_views_filter_handler_proximity in contrib/location_views/location_views.module
_location_nearby_postalcodes in ./location.inc
This is the main logic-level function for performing proximity postal-code searches. It calls a number of helper functions for finding postal_code results in each country, narrowing down results, formatting the returned array, and sorting the returned…

File

./earth.inc, line 114

Code

function earth_longitude_range($longitude, $latitude, $distance) {

  // Estimate the min and max longitudes within $distance of a given location.
  $long = deg2rad($longitude);
  $lat = deg2rad($latitude);
  $radius = earth_radius($latitude);
  $angle = $distance / $radius;
  $diff = asin(sin($angle) / cos($lat));
  $minlong = $long - $diff;
  $maxlong = $long + $diff;
  if ($minlong < -pi()) {
    $minlong = $minlong + pi() * 2;
  }
  if ($maxlong > pi()) {
    $maxlong = $maxlong - pi() * 2;
  }
  return array(
    rad2deg($minlong),
    rad2deg($maxlong),
  );
}