forward static method

String forward(
  1. List<double> ll,
  2. int? accuracy
)

Convert lat/lon to MGRS.

@param {number, number} ll Array with longitude and latitude on a WGS84 ellipsoid. @param {number} accuracy=5 Accuracy in digits (5 for 1 m, 4 for 10 m, 3 for 100 m, 2 for 1 km, 1 for 10 km or 0 for 100 km). Optional, default is 5. @return {string} the MGRS string for the given location and accuracy.

Implementation

static String forward(List<double> ll, int? accuracy) {
  accuracy ??= 5;
  if (ll.length != 2) {
    throw Exception(
        'forward received an invalid input: array must contain 2 numbers exactly');
  }
  var lon = ll[0];
  var lat = ll[1];
  if (lon < -180 || lon > 180) {
    throw Exception('forward received an invalid longitude of $lon');
  }
  if (lat < -90 || lat > 90) {
    throw Exception('forward received an invalid latitude of $lat');
  }
  if (lat < -80 || lat > 84) {
    throw Exception(
        'forward received a latitude of $lat, but this library does not support conversions of points in polar regions below 80°S and above 84°N');
  }
  var utm = LLtoUTM(lat, lon);
  return encode(utm, accuracy);
}