fromGars static method

ArcGISPoint fromGars({
  1. required String coordinates,
  2. SpatialReference? spatialReference,
  3. required GarsConversionMode garsConversionMode,
})

Parses a coordinate in Global Area Reference System (GARS) 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 GARS string. If no spatial reference is provided, it is assumed the GARS string is referenced to WGS 84. The GARS string must not contain any whitespace.

GARS notation examples
354ND
354ND22
Returns null on error, including when the given string is not valid GARS notation.

Parameters:

  • coordinates — The GARS notation string for the coordinate.
  • spatialReference — A spatial reference that defines the datum and ellipsoid referenced by the GARS coordinate.
  • garsConversionMode — Select whether the returned point's location represents the south-west corner of the GARS cell the coordinate lies within, or its center.

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

Implementation

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