Method ToMgrs
ToMgrs(MapPoint, MgrsConversionMode, Int32, Boolean)
Returns a formatted coordinate string in Military Grid Reference System (MGRS) notation representing the given MapPoint's location.
Declaration
public static string ToMgrs(MapPoint point, MgrsConversionMode mgrsConversionMode, int precision, bool addSpaces)
Parameters
Type | Name | Description |
---|---|---|
MapPoint | point | The location to be represented in MGRS notation. It must have a SpatialReference set. |
MgrsConversionMode | mgrsConversionMode | The MgrsConversionMode to use for the returned MGRS notation string. |
Int32 | precision | The precision with which to represent the coordinate. Value is expected to be between 0 to 8 (inclusive), and will be clamped if necessary. |
Boolean | addSpaces | If |
Returns
Type | Description |
---|---|
System.String | An MGRS notation string representing the position of the given MapPoint. |
Remarks
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
a longitude of exactly 180 degrees. The precision
parameter controls the number of digits used
to represent each numerical easting and northing value within the returned MGRS string. For example:
precision parameter value |
addSpaces parameter value |
Example output | Approximate precision (to 1 significant figure) |
---|---|---|---|
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 |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
ArgumentException |
|
Applies to
Platforms and versions
Target | Versions |
---|---|
.NET Standard 2.0 | 100.3 - 100.15 |
.NET 6.0 | 100.13 - 100.15 |
.NET 6.0 Windows | 100.13 - 100.15 |
.NET Framework | 100.1 - 100.15 |
.NET 5 | 100.10 - 100.12 |
.NET Core 3.1 | 100.7 - 100.12 |
Xamarin.Android | 100.1 - 100.15 |
Xamarin.iOS | 100.1 - 100.15 |
UWP | 100.1 - 100.15 |