You are here

function earth_radius in Location 7.3

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.4 earth.inc \earth_radius()

Earth redius.

Latitudes in all of U. S.: from -7.2 (American Samoa) to 70.5 (Alaska). Latitudes in continental U. S.: from 24.6 (Florida) to 49.0 (Washington). Average latitude of all U. S. zipcodes: 37.9.

5 calls to earth_radius()
earth_arclength in ./earth.inc
Earth arclength.
earth_distance in ./earth.inc
Earth distance.
earth_distance_sql in ./earth.inc
Returns the SQL fragment needed to add a column called 'distance' to a query that includes the location table.
earth_latitude_range in ./earth.inc
Earth latitude range.
earth_longitude_range in ./earth.inc
Earth longitude range.

File

./earth.inc, line 68
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) {

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