toMgrs static method
- {required ArcGISPoint point,
- required MgrsConversionMode mgrsConversionMode,
- required int precision,
- required bool addSpaces}
Returns a formatted coordinate in Military Grid Reference System (MGRS) notation representing the given point's location.
For an explanation of the different modes for interpreting an MGRS notation string, please see MgrsConversionMode. Note that the choice between zone 01 and 60 has an impact only when generating the MGRS notation string for a point with longitude of exactly 180deg. The precision value controls the number of digits used to represent each numerical easting and northing value within the MGRS string. For example:
precision | add_spaces | Example output | Approx precision ---------- | ---------- | ------------------ | ---------------- 0 | false | 30UVG | 100km 1 | false | 30UVG89 | 10km 2 | false | 30UVG8999 | 1km 3 | false | 30UVG898998 | 100m 4 | false | 30UVG89889988 | 10m 5 | false | 30UVG8988499881 | 1m 0 | true | 30U VG | 100km 1 | true | 30U VG 8 9 | 10km 2 | true | 30U VG 89 99 | 1km 3 | true | 30U VG 898 998 | 100m 4 | true | 30U VG 8988 9988 | 10m 5 | true | 30U VG 89884 99881 | 1m
The 'precision' should be in the interval [0, 8]. The point must have a spatial reference. Returns null on error.
Parameters:
point
— The location to be represented in MGRS notation.mgrsConversionMode
— The mode to use for the returned MGRS notation string.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: An MGRS notation string representing the position of the given point.
Implementation
static String toMgrs(
{required ArcGISPoint point,
required MgrsConversionMode mgrsConversionMode,
required int precision,
required bool addSpaces}) {
_initializeArcGISEnvironmentIfNeeded();
final stringHandle = _withThrowingErrorHandler((errorHandler) {
return runtimecore.RT_CoordinateFormatter_toMGRS(point._handle,
mgrsConversionMode.coreValue, precision, addSpaces, errorHandler);
});
return stringHandle.toDartString();
}