Crs.FormatMgrs Methods
Formats a LongLat point to an MGRS reference (Military Grid Reference System).
Overload List
Name | Description | |
---|---|---|
FormatMgrs(GeodeticDatum geodeticDatum, MgrsLetteringScheme letteringScheme, System.Boolean insertSpaces, System.Int32 evenNumberOfDigits, Point longLat) | Formats a LongLat point to an MGRS reference, using the standard zone for the point. | |
FormatMgrs(GeodeticDatum geodeticDatum, MgrsLetteringScheme letteringScheme, System.Boolean insertSpaces, System.Int32 evenNumberOfDigits, Point longLat, System.Int32 zone) | Formats a LongLat point to an MGRS reference, using a user-selected zone. |
FormatMgrs(GeodeticDatum geodeticDatum, MgrsLetteringScheme letteringScheme, System.Boolean insertSpaces, System.Int32 evenNumberOfDigits, Point longLat)
Formats a LongLat point to an MGRS reference, using the standard zone for the point.Syntax
public static System.String FormatMgrs (
GeodeticDatum geodeticDatum,
MgrsLetteringScheme letteringScheme,
System.Boolean insertSpaces,
System.Int32 evenNumberOfDigits,
Point longLat
)
Parameters
The geodetic datum used, for both input and output.
The MGRS lettering scheme to use: 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).
Controls whether spaces should be inserted, to make the output easier to read for humans (but harder for computers).
The number of digits to use for the numerical location, an even number in the range -2 to 16.
The input position expressed in LongLat.
Return Value
The MGRS reference.
Remarks
Note that the method does not transform between geodetic datums: For example, if the geodeticDatum parameter represents ED50 (European Datum 1950), then the method formats ED50 LongLat into ED50 MGRS.
The method will return an empty string if the input latitude is not in the range -90° to 90°, or if the input longitude is not in the range -999.5° to 999.5°.
The evenNumberOfDigits parameter must be -2, 0, 2, 4, 6, 8, 10, 12, 14 or 16 and determines the resolution used. If some other value is specified, 10 will be 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 |
The values 12, 14 and 16 are not allowed in military MGRS, but they are allowed in the civilian version USNG (US National Grid).
FormatMgrs(GeodeticDatum geodeticDatum, MgrsLetteringScheme letteringScheme, System.Boolean insertSpaces, System.Int32 evenNumberOfDigits, Point longLat, System.Int32 zone)
Formats a LongLat point to an MGRS reference, using a user-selected zone.Syntax
public static System.String FormatMgrs (
GeodeticDatum geodeticDatum,
MgrsLetteringScheme letteringScheme,
System.Boolean insertSpaces,
System.Int32 evenNumberOfDigits,
Point longLat,
System.Int32 zone
)
Parameters
The geodetic datum used, for both input and output.
The MGRS lettering scheme to use: 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).
Controls whether spaces should be inserted, to make the output easier to read for humans (but harder for computers).
The number of digits to use for the numerical location, an even number in the range -2 to 16.
The input position expressed in LongLat.
The user-selected zone.
Return Value
The MGRS reference.
Remarks
In the more basic variant of this method, FormatMgrs(geodeticDatum, letteringScheme, insertSpaces, evenNumberOfDigits, longLat), the zone for the output is selected automatically, based on the longLat parameter.
But in this variant, the user can select the zone for the output. Use 1 to 60 to select a UTM zone, or 90 to select UPS North, or -90 to select UPS South. An exception will be thrown for other values.
This can be useful for a small area that crosses the boundary between two UTM zones. To avoid problems at the zone boundary, one can agree to use only one zone for the entire area of interest. In other words, the UTM grid of the selected zone is extended a bit.
According to the UTM specifications, a UTM grid may be extended at least 40 km into the neighboring zone. This method tries to be as generous as possible, but there are inherent limitations in the MGRS lettering scheme (see bullet list below). So, if the user-selected zone cannot be extended to cover the given longLat position, the method will throw an exception.
This method will also throw an exception if the input latitude is not in the range -90° to 90°, or if the input longitude is not in the range -999.5° to 999.5°. (This differs from the basic variant FormatMgrs(geodeticDatum, letteringScheme, insertSpaces, evenNumberOfDigits, longLat), which just returns an empty string in this case.)
In other respects, this method behaves like the basic variant.
Limits for an extended UTM zone: the position must be at most 400 km from the central meridian, and at most 9500 km north of the equator (about 85.5°N), and at most 9000 km south of the equator (about 81°S).
Limits for extended UPS North: when the position is expressed in UPS North, both easting and northing must be between 1300 km and 2700 km.
Limits for extended UPS South: when the position is expressed in UPS South, both easting and northing must be between 800 km and 3200 km.
Platforms
Windows, Linux, Android
See Also
Reference
Crs Class
Core Module
ParseMgrs
TryParseMgrs
ParseMgrsAsArea
UtmGridGenerator