You are here

public function IpGeoLocAPI::earthRadius in IP Geolocation Views & Maps 8

Get radius of the Earth at a given latitude.

Parameters

float $latitude: The latitude for which to calculate Earth's radius.

Return value

float The radius of Earth at the given latitude

File

src/Services/IpGeoLocAPI.php, line 767

Class

IpGeoLocAPI
Class IpGeoAPI to interact with other modules.

Namespace

Drupal\ip_geoloc\Services

Code

public function earthRadius($latitude) {
  $lat = deg2rad($latitude);
  $x = cos($lat) / $this
    ->earthRadiusSemimajor();
  $y = sin($lat) / $this
    ->earthRadiusSemiminor();
  return 1.0 / sqrt($x * $x + $y * $y);
}