lengthToRadians function

num lengthToRadians(
  1. num distance, [
  2. Unit unit = Unit.kilometers
])

Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet

Implementation

num lengthToRadians(num distance, [Unit unit = Unit.kilometers]) {
  num? factor = factors[unit];
  if (factor == null) {
    throw Exception("$unit units is invalid");
  }
  return distance / factor;
}