LuciadRIA can format point locations as strings in a variety of output formats. This can be useful to display the map position of the mouse cursor in the view, for example. The LuciadRIA samples all show mouse locations on the map.

Longitude-latitude coordinate formatting

The shape/format module offers the class LonLatPointFormat, which allows you to format points from and to longitude-latitude coordinates.

The formatting of the coordinates is determined by a pattern string in EBNF notation:

const format = new LonLatPointFormat({pattern: "lat(+D),lon(+D)"});
console.log(format.format(10, 10));

MGRS coordinate formatting

The shape/format/MGRSPointFormat class allows you to format points as MGRS or UTM/UPS coordinates.

The UTM and UTM MGRS notations are used for coordinates within the UTM latitude bounds. For points in the polar regions, outside the UTM latitude bounds, the UPS and UPS MGRS notations are used.

const format = new MGRSPointFormat({
  formatType: MGRSPointFormat.Type.UTM_UPS,
  precision: MGRSPointFormat.Precision.PRECISION_1M
});
console.log(format.format(10, 10));