fromUsng static method

ArcGISPoint fromUsng(
  1. {required String coordinates,
  2. required SpatialReference? spatialReference}
)

Parses a coordinate in United States National Grid (USNG) notation, and returns a Point representing that location.

The spatial reference provided must have an ellipsoid and datum matching those used by the source of the USNG string. If no spatial reference is provided and the USNG string is suffixed with "(NAD 27)", it is assumed the USNG string is referenced to NAD 27. If no spatial reference is provided and no such suffix exists, it is assumed the USNG string is referenced to WGS 84. The USNG string can contain leading and trailing whitespace and can have whitespace between the grid zone designator, the 100km square identifier and the numerical eastings and northings.

USNG notation examples
13TFJ 23 59
13TFJ2374159574
Returns null on error, including when the given string is not valid USNG notation.

Parameters:

  • coordinates — The USNG notation string for the coordinate.
  • spatialReference — A spatial reference that defines the datum and ellipsoid referenced by the USNG coordinate.

Return Value: A point with the location from the USNG string in the spatial reference provided.

Implementation

static ArcGISPoint fromUsng(
    {required String coordinates,
    required SpatialReference? spatialReference}) {
  _initializeArcGISEnvironmentIfNeeded();
  final coreCoordinates = _CString(coordinates);
  final objectHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_CoordinateFormatter_fromUSNG(coreCoordinates.bytes,
        spatialReference?._handle ?? ffi.nullptr, errorHandler);
  });
  return ArcGISPoint._fromHandle(objectHandle)!;
}