static func metersToDegreesForLat(atLongitude longitude: CLLocationDegrees) -> CLLocationDistance {
let a = cos(2 * Math.degreesToRadians(longitude))
let b = cos(4 * Math.degreesToRadians(longitude))
let c = cos(6 * Math.degreesToRadians(longitude))
return 1.0 / fabs(111132.95255 - 559.84957 * a + 1.17514 * b - 0.00230 * c)
}
static func metersToDegreesForLon(atLatitude latitude: CLLocationDegrees) -> CLLocationDistance {
let a = cos(Math.degreesToRadians(latitude))
let b = cos(3 * Math.degreesToRadians(latitude))
let c = cos(5 * Math.degreesToRadians(latitude))
return 1.0 / fabs(111412.87733 * a - 93.50412 * b + 0.11774 * c)
}
On the WGS 84 spheroid, the length in meters of a degree of latitude at latitude ϕ (that is, the number of meters you would have to travel along a north–south line to move 1 degree in latitude, when at latitude ϕ), is about:
The returned measure of meters per degree latitude varies continuously with latitude.
Similarly, the length in meters of a degree of longitude can be calculated as
(Those coefficients can be improved, but as they stand the distance they give is correct within a centimeter.)
The formulae both return units of meters per degree.
Compare this from Understanding terms in Length of Degree formula?:
with this:
You can also look at the Geographic coordinate system wiki article:
$
111132.92 - 559.82\, \cos 2\phi + 1.175\, \cos 4\phi - 0.0023\, \cos 6\phi
$$
111412.84\, \cos \phi - 93.5\, \cos 3\phi + 0.118\, \cos 5\phi
$