Crs.ParseMgrs Method
Parses an MGRS reference to a LongLat point.
ParseMgrs(GeodeticDatum geodeticDatum, MgrsLetteringScheme letteringScheme, System.String mgrs)
Parses an MGRS reference to a LongLat point.Syntax
public static Point ParseMgrs (
GeodeticDatum geodeticDatum,
MgrsLetteringScheme letteringScheme,
System.String mgrs
)
Parameters
The geodetic datum used, for both input and output.
The MGRS lettering scheme used: new or old. The old one may be used only if the datum ellipsoid is Bessel 1841, Bessel Namibia, Clarke 1866, Clarke 1880 or Clarke 1880 (IGN).
The MGRS reference.
Return Value
The center of the area that the MGRS reference denotes, in LongLat.
Remarks
If the MGRS reference cannot be parsed, the method will throw an exception, whose message explains why the parsing failed.
Note that the method does not transform between geodetic datums: For example, if the geodeticDatum parameter represents ED50 (European Datum 1950), then the method parses ED50 MGRS into ED50 LongLat.
In strict usage, an MGRS reference must have no spaces, dashes or other separators. Example:
32VPK7664100252
In more informal usage, spaces or tabs may separate the four main parts. Example:
32V PK 76641 00252
This method can parse the informal usage, too, as long as the whitespace consists of only space characters and/or tab characters, and occurs only between the four main parts (the grid zone designator like 32V above, the 100 000 m square identifier like PK above, and the two halves of the numerical location like 76641 and 00252 above).
The parsing method will accept an MGRS string even if it refers to a location outside the standard boundaries for the UTM zone, since it is permitted to extend a UTM grid beyond its standard zone. See ParseMgrsAsArea for some examples.
The number of digits used for the numerical location (which must be 0, 2, 4, 6, 8, 10, 12, 14 or 16) is noted and stored as the z coordinate of the result, where the application can inspect it. (Using 12, 14 or 16 digits is allowed only in US National Grid, the civilian version of MGRS, so a military application may want to complain if the z is larger than 10.)
The method can also accept an MGRS reference that consists only of a grid zone designation, like 30U. In this case, the number of digits in the numerical location is considered to be -2 (by extrapolation).
The number of digits gives the resolution used:
number of digits | example (with spaces) | resolution |
---|---|---|
-2 | 30U | 6° * 8° (usually) |
0 | 30U XC | 100 km |
2 | 30U XC 9 1 | 10 km |
4 | 30U XC 99 10 | 1 km |
6 | 30U XC 992 102 | 100 m |
8 | 30U XC 9923 1023 | 10 m |
10 | 30U XC 99237 10233 | 1 m |
12 | 30U XC 992379 102338 | 1 dm |
14 | 30U XC 9923796 1023387 | 1 cm |
16 | 30U XC 99237963 10233872 | 1 mm |
Platforms
Windows, Linux, Android
See Also
Reference
Crs Class
Core Module
TryParseMgrs
ParseMgrsAsArea
FormatMgrs
FormatUtmUps
UtmGridGenerator