LuciadCPillar 2023.1.04
luciad::MgrsFormat Class Reference

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

#include <luciad/grids/mgrs/MgrsFormat.h>

Classes

class  Builder
 Builder for creating luciad::MgrsFormat. More...
 

Public Member Functions

 MgrsFormat (const MgrsFormat &other)
 
 MgrsFormat (MgrsFormat &&other) noexcept
 
 ~MgrsFormat ()
 
Builder asBuilder () const
 Creates a new builder initialized with all the properties of this style. More...
 
luciad::expected< std::string, ErrorInfoformat (const Point &lonLatPoint) const
 Formats the given point or the given (lon,lat) pair as an MGRS or UTM/UPS coordinate string. More...
 
std::string getCoordinateSeparator () const
 Gets the string to separate the zone/grid letters and the coordinates. More...
 
MgrsFormatType getFormatType () const
 Gets the luciad::MgrsFormatType used to format an MGRS or UTM/UPS string. More...
 
MgrsFormatPrecision getPrecision () const
 Gets the luciad::MgrsFormatPrecision used to format an MGRS or UTM/UPS string. More...
 
std::string getZoneSeparator () const
 Gets the string to separate the zone/grid letters and the coordinates. More...
 
MgrsFormatoperator= (const MgrsFormat &other) noexcept
 
MgrsFormatoperator= (MgrsFormat &&other) noexcept
 
luciad::expected< Point, ErrorInfoparse (const std::string &coordinateString) const
 Parses the given MGRS or UTM/UPS coordinate string into a point with WGS84 lon lat coordinates. More...
 

Static Public Member Functions

static Builder newBuilder ()
 Creates a new builder with the default values. More...
 

Detailed Description

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.

Construction of this class is done through the Builder design pattern mechanism.

Example usage:

.build();
auto wgs84 = CoordinateReferenceProvider::create("EPSG:4326");
auto point = Point(wgs84.value(), {5, 45, 0});
auto stringResult = mgrsFormat.format(point);
auto parsed = mgrsFormat.parse(stringResult.value());
static luciad::expected< std::shared_ptr< CoordinateReference >, ErrorInfo > create(const std::string &identifier)
Creates the coordinate reference from a given EPSG, WKT (version 1) or OGC identifier.
Builder & coordinateSeparator(std::string coordinateSeparator)
Sets the string to separate the zone/grid letters and the coordinates.
Builder & zoneSeparator(std::string zoneSeparator)
Sets the string to use as zoneSeparator between the grid zone and the 100km squares when formatting M...
MgrsFormat build() const
Creates the MGRS format, based on the properties set on this builder.
Builder & formatType(MgrsFormatType formatType)
Sets the luciad::MgrsFormatType.
Builder & precision(MgrsFormatPrecision precision)
Sets the luciad::MgrsFormatPrecision used to format an MGRS or UTM/UPS string.
Class to format points as MGRS or UTM/UPS coordinates.
Definition: MgrsFormat.h:146
static Builder newBuilder()
Creates a new builder with the default values.
luciad::expected< std::string, ErrorInfo > format(const Point &lonLatPoint) const
Formats the given point or the given (lon,lat) pair as an MGRS or UTM/UPS coordinate string.
luciad::expected< Point, ErrorInfo > parse(const std::string &coordinateString) const
Parses the given MGRS or UTM/UPS coordinate string into a point with WGS84 lon lat coordinates.
Represents a point.
Definition: Point.h:17
@ Mgrs
MGRS format type.
@ Precision1M
Precision of 1 meter.
Since
2023.1

Constructor & Destructor Documentation

◆ MgrsFormat() [1/2]

luciad::MgrsFormat::MgrsFormat ( const MgrsFormat other)

◆ MgrsFormat() [2/2]

luciad::MgrsFormat::MgrsFormat ( MgrsFormat &&  other)
noexcept

◆ ~MgrsFormat()

luciad::MgrsFormat::~MgrsFormat ( )

Member Function Documentation

◆ asBuilder()

Builder luciad::MgrsFormat::asBuilder ( ) const

Creates a new builder initialized with all the properties of this style.

Returns
the new builder.

◆ format()

luciad::expected< std::string, ErrorInfo > luciad::MgrsFormat::format ( const Point lonLatPoint) const

Formats the given point or the given (lon,lat) pair as an MGRS or UTM/UPS coordinate string.

Parameters
lonLatPointthe point to be formatted. The reference of the point must be WGS84.
Returns
an expected containing the formatted string. If the point cannot be formatted, the expected contains an informational message.

◆ getCoordinateSeparator()

std::string luciad::MgrsFormat::getCoordinateSeparator ( ) const

Gets the string to separate the zone/grid letters and the coordinates.

Returns
the coordinate separator.

◆ getFormatType()

MgrsFormatType luciad::MgrsFormat::getFormatType ( ) const

Gets the luciad::MgrsFormatType used to format an MGRS or UTM/UPS string.

Returns
the format type.

◆ getPrecision()

MgrsFormatPrecision luciad::MgrsFormat::getPrecision ( ) const

Gets the luciad::MgrsFormatPrecision used to format an MGRS or UTM/UPS string.

Returns
the precision.

◆ getZoneSeparator()

std::string luciad::MgrsFormat::getZoneSeparator ( ) const

Gets the string to separate the zone/grid letters and the coordinates.

Returns
the zone separator.

◆ newBuilder()

static Builder luciad::MgrsFormat::newBuilder ( )
static

Creates a new builder with the default values.

Returns
the new builder.

◆ operator=() [1/2]

MgrsFormat & luciad::MgrsFormat::operator= ( const MgrsFormat other)
noexcept

◆ operator=() [2/2]

MgrsFormat & luciad::MgrsFormat::operator= ( MgrsFormat &&  other)
noexcept

◆ parse()

luciad::expected< Point, ErrorInfo > luciad::MgrsFormat::parse ( const std::string &  coordinateString) const

Parses the given MGRS or UTM/UPS coordinate string into a point with WGS84 lon lat coordinates.

Parameters
coordinateStringa MGRS coordinate string
Returns
an expected containing the parsed point. If the coordinate string cannot be parsed, the expected contains an informational message.