You are here

function getlocations_earth_radius in Get Locations 7.2

Same name and namespace in other branches
  1. 7 getlocations.module \getlocations_earth_radius()
7 calls to getlocations_earth_radius()
getlocations_earth_arclength in ./getlocations.module
getlocations_earth_distance in ./getlocations.module
getlocations_earth_distance_sql in ./getlocations.module
Returns the SQL fragment needed to add a column called 'distance' to a query. For use in Views distance/proximity calculations
getlocations_earth_latitude_range in ./getlocations.module
getlocations_earth_longitude_range in ./getlocations.module
This function uses earth_asin_safe so is not accurate for all possible parameter combinations. This means this function doesn't work properly for high distance values. This function needs to be re-written to work properly for larger distance…

... See full list

File

./getlocations.module, line 5808
getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_earth_radius($latitude = 45) {

  // Estimate the Earth's radius at a given latitude.
  $lat = deg2rad($latitude);
  $x = cos($lat) / GETLOCATIONS_EARTH_RADIUS_SEMIMAJOR;
  $y = sin($lat) / GETLOCATIONS_EARTH_RADIUS_SEMIMINOR;
  $return = 1 / sqrt($x * $x + $y * $y);
  return $return;
}