toUsng static method

String toUsng(
  1. {required ArcGISPoint point,
  2. required int precision,
  3. required bool addSpaces}
)

Returns a formatted coordinate in United States National Grid (USNG) notation representing the given point's location.

The precision value controls the number of digits used to represent each numerical easting and northing value within the USNG string. For example:

precision add_spaces Example output Approx precision
0 false 13TFJ 100km
1 false 13TFJ25 10km
2 false 13TFJ2359 1km
3 false 13TFJ237595 100m
4 false 13TFJ23745951 10m
5 false 13TFJ2374359512 1m
0 true 13T FJ 100km
1 true 13T FJ 2 5 10km
2 true 13T FJ 23 59 1km
3 true 13T FJ 237 595 100m
4 true 13T FJ 2374 5951 10m
5 true 13T FJ 23743 59512 1m

If the point's SpatialReference is NAD 27, then a suffix is added to the end of the formatted string. For example:

precision add_spaces Example output Approx precision
4 false 13TFJ23795929 (NAD 27) 10m
2 true 13T FJ 23 59 (NAD 27) 1km

When the point's spatial reference is based on NAD 27. The 'precision' should be in the interval [0, 8]. The point must have a spatial reference. Returns null on error.

Parameters:

  • point — The coordinate to be represented in MGRS notation.
  • precision — The precision with which to represent the coordinate.
  • addSpaces — If false, the generated string contains no spaces. If true, a space separates the grid zone designator, the 100km square identifier, and the numerical easting and northing values.

Return Value: A USNG notation string representing the position of the given point.

Implementation

static String toUsng(
    {required ArcGISPoint point,
    required int precision,
    required bool addSpaces}) {
  _initializeArcGISEnvironmentIfNeeded();
  final stringHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_CoordinateFormatter_toUSNG(
        point._handle, precision, addSpaces, errorHandler);
  });
  return stringHandle.toDartString();
}