GeoUnit
The unit a distance is given or asked for in.
The same stretch of the globe is one number in kilometres and another in miles.
Nothing in a bare double says which one you mean — so the distance methods on
CkGeo ask you, with a GeoUnit parameter. Leave it out and everything is
kilometres.
Members
| Member | Meaning |
|---|---|
Kilometers |
Kilometres. This is the default. |
Miles |
Statute miles — the ordinary mile used on US roads. |
NauticalMiles |
Nautical miles — one minute of latitude (a sixtieth of a degree). |
Meters |
Metres. |
Where it is used
Two methods on CkGeo take a unit parameter. On
Distance it sets the unit of the answer; on IsWithin it sets the unit of
the radius you pass in. Both default to GeoUnit.Kilometers.
Quick look
using SafeCoder.CommonKit;
using SafeCoder.CommonKit.Enums;
// New York to London, along the surface of the globe
CkGeo.Distance(
latitude1: 40.7128,
longitude1: -74.0060,
latitude2: 51.5074,
longitude2: -0.1278
); // -> 5570.229873656523 (kilometres, the default)
CkGeo.Distance(
latitude1: 40.7128,
longitude1: -74.0060,
latitude2: 51.5074,
longitude2: -0.1278,
unit: GeoUnit.Miles
); // -> 3461.1803776299676