You are here

function earth_radius in Location 7.4

Same name and namespace in other branches
  1. 5.3 earth.inc \earth_radius()
  2. 5 earth.inc \earth_radius()
  3. 6.3 earth.inc \earth_radius()
  4. 7.5 earth.inc \earth_radius()
  5. 7.3 earth.inc \earth_radius()
5 calls to earth_radius()
earth_arclength in ./earth.inc
earth_distance in ./earth.inc
earth_distance_sql in ./earth.inc
earth_latitude_range in ./earth.inc
earth_longitude_range in ./earth.inc
@todo 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…

File

./earth.inc, line 51
Trigonometry for calculating geographical distances. All function arguments and return values measure distances in metres and angles in degrees. The ellipsoid model is from the WGS-84 datum. Ka-Ping Yee, 2003-08-11

Code

function earth_radius($latitude = 37.9) {

  //global $earth_radius_semimajor, $earth_radius_semiminor;

  // Estimate the Earth's radius at a given latitude.
  // Default to an approximate average radius for the United States.
  $lat = deg2rad($latitude);
  $x = cos($lat) / earth_radius_semimajor();
  $y = sin($lat) / earth_radius_semiminor();
  return 1 / sqrt($x * $x + $y * $y);
}