Converts between points and formatted coordinate notation strings. More...
Header: | #include <CoordinateFormatter.h> |
Since: | Esri::ArcGISRuntime 100.1 |
Inherits: | Esri::ArcGISRuntime::Object |
Public Functions
virtual | ~CoordinateFormatter() override |
Static Public Members
Esri::ArcGISRuntime::Point | fromGars(const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference, Esri::ArcGISRuntime::GarsConversionMode garsConversionMode) |
Esri::ArcGISRuntime::Point | fromGeoRef(const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference) |
Esri::ArcGISRuntime::Point | fromLatitudeLongitude(const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference) |
Esri::ArcGISRuntime::Point | fromMgrs(const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference, Esri::ArcGISRuntime::MgrsConversionMode mgrsConversionMode) |
Esri::ArcGISRuntime::Point | fromUsng(const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference) |
Esri::ArcGISRuntime::Point | fromUtm(const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference, Esri::ArcGISRuntime::UtmConversionMode utmConversionMode) |
Esri::ArcGISRuntime::CoordinateFormatter * | instance() |
QString | toGars(const Esri::ArcGISRuntime::Point &point) |
QString | toGeoRef(const Esri::ArcGISRuntime::Point &point, int precision) |
QString | toLatitudeLongitude(const Esri::ArcGISRuntime::Point &point, Esri::ArcGISRuntime::LatitudeLongitudeFormat format, int decimalPlaces) |
QString | toMgrs(const Esri::ArcGISRuntime::Point &point, Esri::ArcGISRuntime::MgrsConversionMode mgrsConversionMode, int precision, bool addSpaces) |
QString | toUsng(const Esri::ArcGISRuntime::Point &point, int precision, bool addSpaces) |
QString | toUtm(const Esri::ArcGISRuntime::Point &point, Esri::ArcGISRuntime::UtmConversionMode utmConversionMode, bool addSpaces) |
Detailed Description
Supported notations are:
- Latitude-longitude in degrees.
- Global Area Reference System (GARS).
- World Geographic Reference System (GEOREF).
- Military Grid Reference System (MGRS).
- United States National Grid (USNG).
- Universal Transverse Mercator (UTM).
Relevant samples:
- Format coordinates: Format coordinates in a variety of common notations.
Member Function Documentation
[override virtual]
CoordinateFormatter::~CoordinateFormatter ()
Destructor.
[static]
Esri::ArcGISRuntime::Point CoordinateFormatter::fromGars (const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference , Esri::ArcGISRuntime::GarsConversionMode garsConversionMode )
Parses a coordinate in Global Area Reference System (GARS) notation, and returns a Point representing that location.
- coordinates - The GARS notation string for the coordinate.
- spatialReference - A spatial reference that defines the datum and ellipsoid referenced by the GARS coordinate.
- garsConversionMode - Select whether the returned point's location represents the south-west corner of the GARS cell the coordinate lies within, or its center.
The spatial reference provided must have an ellipsoid and datum matching those used by the source of the GARS string. If no spatial reference is provided, it is assumed the GARS string is referenced to WGS 84. The GARS string must not contain any whitespace. Returns an empty Point on error, including when the given string is not valid GARS notation.
Returns a point with the location from the GEOREF string in the spatial reference provided. Returns an empty Point if the input text could not be parsed.
GARS notation examples |
---|
354ND |
354ND22 |
[static]
Esri::ArcGISRuntime::Point CoordinateFormatter::fromGeoRef (const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference )
Parses a coordinate in World Geographic Reference System (GEOREF) notation, and returns a Point representing that location.
- coordinates - The GEOREF notation string for the coordinate.
- spatialReference - A spatial reference that defines the datum and ellipsoid referenced by the GEOREF coordinate.
Returns a point with the location from the GEOREF string in the spatial reference provided. Returns an empty Point if the input text could not be parsed.
The spatial reference provided must have an ellipsoid and datum matching those used by the source of the GEOREF string. If no spatial reference is provided, it is assumed the GEOREF string is referenced to WGS 84
. The GEOREF string may contain leading and trailing whitespace.
GEOREF notation examples |
---|
MKML5056 |
MKML50285665 |
Returns an empty Point on error, including when the given string is not valid GEOREF notation.
[static]
Esri::ArcGISRuntime::Point CoordinateFormatter::fromLatitudeLongitude (const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference )
Parses a coordinate in latitude-longitude notation, and returns a Point representing that location.
- coordinates - The latitude-longitude notation string for the coordinate. The coordinate may use decimal degrees, degrees and decimal minutes, or degrees-minutes-seconds format.
- spatialReference - A spatial reference that defines the datum and ellipsoid referenced by the latitude-longitude coordinate.
Returns a point with the location from the latitude/longitude string in the spatial reference provided. Returns an empty Point if the input text could not be parsed.
The spatial reference provided must have an ellipsoid and datum matching those used by the source of the latitude-longitude string. If no spatial reference is provided, it is assumed the latitude-longitude coordinates are referenced to WGS 84
.
Supported characters
Symbol | Character | Name | Unicode number | HTML code |
---|---|---|---|---|
Degree | * | Asterisk | U+002A | * |
^ | Circumflex Accent | U+005E | ^ | |
~ | Tilde | U+007E | ~ | |
° | Degree Sign | U+00B0 | ° | |
º | Masculine Ordinal Indicator | U+00BA | º | |
˚ | Ring Above | U+02DA | ˚ | |
⁰ | Superscript Zero | U+2070 | ⁰ | |
Minute | ' | Apostrophe | U+0027 | ' |
᾿ | Right Single Quotation Mark | U+2019 | ᾿ | |
′ | Prime | U+2032 | ′ | |
Second | " | Quotation Mark | U+0022 | " |
˝ | Double Acute Accent | U+02DD | ˝ | |
” | Right Double Quotation Mark | U+201D | ” | |
″ | Double Prime | U+2033 | ″ |
The latitude-longitude string may contain leading and trailing whitespace, and may also contain a space, comma, or vertical bar symbol to separate the latitude from the longitude. It may also contain the characters 'N', 'S', 'E' and 'W', or use a minus (-) symbol to indicate the hemisphere of each value.
Latitude-longitude notation examples |
---|
55 56 39.123N 003 09 43.034W |
55°56′39″N 3°09′43″W |
55~56.65205', -003~09.71723' |
55.9442008* | -3.1619539* |
Returns an empty Point on error, including when the given string cannot be interpreted.
[static]
Esri::ArcGISRuntime::Point CoordinateFormatter::fromMgrs (const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference , Esri::ArcGISRuntime::MgrsConversionMode mgrsConversionMode )
Parses a coordinate in Military Grid Reference System (MGRS) notation, and returns a Point representing that location.
- coordinates - The MGRS notation string for the coordinate.
- spatialReference - A spatial reference that defines the datum and ellipsoid referenced by the MGRS coordinate.
- mgrsConversionMode - The mode used by the given MGRS coordinates.
Returns a point with the location from the MGRS string in the spatial reference provided. The spatial reference provided must have an ellipsoid and datum matching those used by the source of the MGRS string. If no spatial reference is provided, it is assumed the MGRS string is referenced to WGS 84
. Returns an empty Point if the input text could not be parsed.
For an explanation of the different modes for interpreting an MGRS notation string, please see MgrsConversionMode. Note that the choice between zone 01
and 60 has no impact when reading from an MGRS notation string.
The MGRS string can contain leading and trailing whitespace and can have whitespace between the grid zone designator, the 100km square identifier, and the numerical eastings and northings.
MGRS notation examples |
---|
30UVG898998 |
30UVG 89885 99877 |
Returns an empty Point on error, including when the given string is not valid MGRS notation.
See also MgrsConversionMode.
[static]
Esri::ArcGISRuntime::Point CoordinateFormatter::fromUsng (const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference )
Parses a coordinate in United States National Grid (USNG) notation, and returns a Point representing that location.
- coordinates - The USNG notation string for the coordinate.
- spatialReference - A spatial reference that defines the datum and ellipsoid referenced by the USNG coordinate.
Return a point with the location from the USNG string in the spatial reference provided. Returns an empty Point if the input text could not be parsed.
The spatial reference provided must have an ellipsoid and datum matching those used by the source of the USNG string. If no spatial reference is provided and the USNG string is suffixed with "(NAD 27)"
, it is assumed the USNG string is referenced to NAD
27. If no spatial reference is provided and no such suffix exists, it is assumed the USNG string is referenced to WGS 84
.
The USNG string can contain leading and trailing whitespace and can have whitespace between the grid zone designator, the 100km square identifier and the numerical eastings and northings.
USNG notation examples |
---|
13TFJ 23 59 |
13TFJ2374159574 |
Returns an empty Point on error, including when the given string is not valid USNG notation.
See also MgrsConversionMode.
[static]
Esri::ArcGISRuntime::Point CoordinateFormatter::fromUtm (const QString &coordinates, const Esri::ArcGISRuntime::SpatialReference &spatialReference , Esri::ArcGISRuntime::UtmConversionMode utmConversionMode )
Parses a coordinate in Universal Transverse Mercator (UTM) notation, and returns a Point representing that location.
- coordinates - The UTM notation string for the coordinate.
- spatialReference - A spatial reference that defines the datum and ellipsoid referenced by the UTM coordinate.
- utmConversionMode - The latitude notation scheme used by the given UTM coordinate, either a latitudinal band, or a hemisphere designator.
Returns a point with the location from the UTM string in the spatial reference provided. Returns an empty Point on error, including when the given string is not valid UTM notation.
The spatial reference provided must have an ellipsoid and datum matching those used by the source of the UTM string. If no spatial reference is provided, it is assumed the UTM string is referenced to WGS 84
.
The UTM string can contain leading and trailing whitespace and can have whitespace between the zone and latitude designator and the numerical eastings and northings.
UTM notation examples |
---|
30U 489885 6199877 |
30U4898856199877 |
30N 489885 6199877 (using N/S indicator) |
489885.32,6199877.36,30U (this form supports sub-meter precision) |
Returns an empty Point on error, including when the given string is not valid UTM notation.
See also MgrsConversionMode.
[static]
Esri::ArcGISRuntime::CoordinateFormatter *CoordinateFormatter::instance()
The instance getter for CoordinateFormatter.
This can be used to check for errors.
See also Object::errorOccurred.
[static]
QString CoordinateFormatter::toGars (const Esri::ArcGISRuntime::Point &point)
Returns a formatted coordinate in Global Area Reference System (GARS) notation representing the given point's location.
- point - The location to be represented in GARS notation. The point must have a spatial reference.
Returns a GARS notation string representing the GARS cell containing the given point. Returns an empty QString on error.
[static]
QString CoordinateFormatter::toGeoRef (const Esri::ArcGISRuntime::Point &point, int precision)
Returns a formatted coordinate in World Geographic Reference System (GEOREF) notation representing the given point's location.
- point - The location to be represented in GEOREF notation. The point must have a spatial reference.
- precision - The precision with which to represent the coordinate. The 'precision' should be in the interval [0, 9].
Returns A GEOREF notation string representing the position of the given point. Returns an empty QString on error.
The precision value controls the number of digits used to represent the fractional part of the coordinate's latitude and longitude, expressed in minutes. For example:
Precision | Example output | Angular precision | Approx precision* |
---|---|---|---|
0 | MKML5056 | 1min | 2km |
1 | MKML5056 | 1min | 2km |
2 | MKML5056 | 1min | 2km |
3 | MKML502566 | 0.1min | 200m |
4 | MKML50285665 | 0.01min | 20m |
5 | MKML5028256652 | 0.001min | 2m |
At the equator to 1 significant figure. The 'precision' should be in the interval [0, 9]. The point must have a spatial reference. Returns an empty QString on error.
[static]
QString CoordinateFormatter::toLatitudeLongitude (const Esri::ArcGISRuntime::Point &point, Esri::ArcGISRuntime::LatitudeLongitudeFormat format, int decimalPlaces )
Returns a formatted coordinate in latitude-longitude notation representing the given point's location.
- point - The location to be represented as a formatted latitude-longitude string. The point must have a spatial reference.
- format - The mode to use when formatting the latitude-longitude string.
- decimalPlaces - The number of decimal places to use.
Returns a string representing the latitude-longitude of the given point. Returns an empty QString on error.
The latitude-longitude string contains a space separating the latitude from the longitude value, and the characters 'N' or 'S', and 'E' and 'W', to indicate the hemisphere of each value. The string will also contain spaces separating the components (degrees, minutes, seconds) of each value. The precision of the output is controlled by both the 'format' and 'decimal_places' parameters. For example:
decimalPlaces | LatitudeLongitudeFormat | Example output | Angular precision | Approx precision* |
---|---|---|---|---|
0 | DecimalDegrees | 056N 0003W | 1deg | 100km |
1 | DecimalDegrees | 55.9N 003.2W | 0.1deg | 10km |
2 | DecimalDegrees | 55.94N 003.16W | 0.01deg | 1km |
3 | DecimalDegrees | 55.944N 003.162W | 0.001deg | 100m |
0 | DegreesDecimalMinutes | 55 057N 003 010W | 1min | 2km |
1 | DegreesDecimalMinutes | 55 56.7N 003 09.7W | 0.1min | 200m |
2 | DegreesDecimalMinutes | 55 56.65N 003 09.72W | 0.01min | 20m |
3 | DegreesDecimalMinutes | 55 56.650N 003 09.717W | 0.001min | 2m |
0 | DegreesMinutesSeconds | 55 56 039N 003 09 043W | 1sec | 30m |
1 | DegreesMinutesSeconds | 55 56 39.1N 003 09 43.0W | 0.1sec | 3m |
2 | DegreesMinutesSeconds | 55 56 39.12N 003 09 43.03W | 0.01sec | 300mm |
3 | DegreesMinutesSeconds | 55 56 39.123N 003 09 43.034W | 0.001sec | 30mm |
* At the equator to 1 significant figure. The 'decimal_places' should be in the interval [0, 16]. The point must have a spatial reference. Returns nullptr
on error.
See also LatitudeLongitudeFormat.
[static]
QString CoordinateFormatter::toMgrs (const Esri::ArcGISRuntime::Point &point, Esri::ArcGISRuntime::MgrsConversionMode mgrsConversionMode , int precision, bool addSpaces )
Returns a formatted coordinate in Military Grid Reference System (MGRS) notation representing the given point's location.
- point - The location to be represented in MGRS notation. The point must have a spatial reference.
- mgrsConversionMode - The mode to use for the returned MGRS notation string.
- precision - The precision with which to represent the coordinate. The 'precision' should be in the interval [0, 8].
- addSpaces - If
false
, the generated string contains no spaces. Iftrue
, a space separates the grid zone designator, the 100km square identifier, and the numerical easting and northing values.
Returns an MGRS notation string representing the position of the given point. Returns an empty QString on error.
For an explanation of the different modes for interpreting an MGRS notation string, please see MgrsConversionMode. Note that the choice between zone 01
and 60 has an impact only when generating the MGRS notation string for a point with longitude of exactly 180 degrees.
The precision value controls the number of digits used to represent each numerical easting and northing value within the MGRS string. For example:
precision | addSpaces | Example output | Approx precision |
---|---|---|---|
0 | false | 30UVG | 100km |
1 | false | 30UVG89 | 10km |
2 | false | 30UVG8999 | 1km |
3 | false | 30UVG898998 | 100m |
4 | false | 30UVG89889988 | 10m |
5 | false | 30UVG8988499881 | 1m |
0 | true | 30U VG | 100km |
1 | true | 30U VG 8 9 | 10km |
2 | true | 30U VG 89 99 | 1km |
3 | true | 30U VG 898 998 | 100m |
4 | true | 30U VG 8988 9988 | 10m |
5 | true | 30U VG 89884 99881 | 1m |
The 'precision' should be in the interval [0, 8]. The point must have a spatial reference. Returns an empty QString on error.
[static]
QString CoordinateFormatter::toUsng (const Esri::ArcGISRuntime::Point &point, int precision, bool addSpaces )
Returns a formatted coordinate in United States National Grid (USNG) notation representing the given point's location.
- point - The coordinate to be represented in MGRS notation. The point must have a spatial reference.
- precision - The precision with which to represent the coordinate. The 'precision' should be in the interval [0, 8].
- addSpaces - If
false
, the generated string contains no spaces. Iftrue
, a space separates the grid zone designator, the 100km square identifier, and the numerical easting and northing values.
Returns a USNG notation string representing the position of the given point. Returns an empty QString on error.
The precision value controls the number of digits used to represent each numerical easting and northing value within the USNG string. For example:
precision | addSpaces | Example output | Approx precision |
---|---|---|---|
0 | false | 13TFJ | 100km |
1 | false | 13TFJ25 | 10km |
2 | false | 13TFJ2359 | 1km |
3 | false | 13TFJ237595 | 100m |
4 | false | 13TFJ23745951 | 10m |
5 | false | 13TFJ2374359512 | 1m |
0 | true | 13T FJ | 100km |
1 | true | 13T FJ 2 5 | 10km |
2 | true | 13T FJ 23 59 | 1km |
3 | true | 13T FJ 237 595 | 100m |
4 | true | 13T FJ 2374 5951 | 10m |
5 | true | 13T FJ 23743 59512 | 1m |
If the point's SpatialReference is NAD 27, then a suffix is added to the end of the formatted string. For example:
precision | addSpaces | Example output | Approx precision |
---|---|---|---|
4 | false | 13TFJ23795929 (NAD 27) | 10m |
2 | true | 13T FJ 23 59 (NAD 27) | 1km |
When the point's spatial reference is based on NAD 27. The 'precision' should be in the interval [0, 8]. The point must have a spatial reference. Returns an empty QString on error.
[static]
QString CoordinateFormatter::toUtm (const Esri::ArcGISRuntime::Point &point, Esri::ArcGISRuntime::UtmConversionMode utmConversionMode , bool addSpaces )
Returns a formatted coordinate in Universal Transverse Mercator (UTM) notation representing the given point's location.
- point - The coordinate to be represented in UTM notation. The point must have a spatial reference.
- utmConversionMode - The latitude notation scheme to use in the returned UTM notation string, either a latitudinal band, or a hemisphere designator.
- addSpaces - If
false
, the generated string contains no spaces. Iftrue
, a space separates the UTM zone and latitude designator, and each numerical easting and northing value.
Returns a UTM notation string representing the position of the given point. Returns and empty QString on error.
Example output for a point in the southern hemisphere:
UtmConversionMode | addSpaces | Example output |
---|---|---|
LatitudeBandIndicators | false | 30U4898846199881 |
LatitudeBandIndicators | true | 30U 489884 6199881 |
NorthSouthIndicators | false | 30N4898846199881 |
NorthSouthIndicators | true | 30N 489884 6199881 |
The point must have a spatial reference. Returns an empty QString on error.