Class to format points as MGRS or UTM/UPS coordinates.

This class offers methods to format coordinates into either UTM MGRS, UPS MGRS, UTM or UPS notation. The UTM MGRS and UTM notations are used for coordinates within the UTM latitude bounds. For points in the polar regions, outside the UTM latitude bounds, the UPS MGRS and UPS notations are used.

Example use

  const format = new MGRSFormat({
formatType: MGRSFormatType.UTM_UPS,
precision: MGRSFormatPrecision.PRECISION_1M,
zoneSeparator: " ",
coordinateSeparator: " "
});
const lonLatPoint = createPoint(getReference("CRS:84"), [10, 10]);
const mgrsString = format.format(lonLatPoint);
console.log(mgrsString); // 32P 0609600 1105578
const parsedPoint = format.parse(mgrsString);
console.log(parsedPoint);

Since

2015.1

Hierarchy

  • MGRSFormat

Constructors

Methods

Constructors

Methods

  • Formats the given point or the given (lon,lat) pair as an MGRS coordinate String. The point must be an instance of Point.

    Parameters

    • pointOrLon: number | Point

      point to be formatted or the longitude. When a point is used the reference of the point must be WGS84.

    • Optional lat: number

      the latitude, expressed in degrees (between -90 and 90), only required when the first argument is a longitude value.

    Returns string

    the formatted String.

    Throws

    ProgrammingError if the provided arguments don't correspond to either a Point or a lon/lat pair, or when a Point with a non-geodetic reference is provided.

  • Parses the given MGRS coordinate string into a Point with WGS84 lon lat coordinates.

    Parameters

    • stringVal: string

      expects a MGRS coordinate string as an argument

    Returns Point

    the Point instance. The point uses WGS84 as its reference.

    Since

    2021.0

    Throws

    ProgrammingError if an invalid MGRS coordinate string is provided