Converts between points and formatted coordinate notation strings. More...
| Header | #include <Coordinate |
| Since | Esri |
| Inherits | Esri |
This class was introduced in Esri::ArcGISRuntime 100.1.
Public Functions
| virtual | ~ |
Static Public Members
| Esri | from |
| Esri | from |
| Esri | from |
| Esri | from |
| Esri | from |
| Esri | from |
| Esri | instance() |
| QString | to |
| QString | to |
| QString | to |
| QString | to |
| QString | to |
| QString | to |
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).
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.
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 |
|---|
| 354 |
| 354 |
[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 |
|---|
| MKM |
| MKM |
[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+002 | * |
| ^ | Circumflex Accent | U+005 | ^ | |
| ~ | Tilde | U+007 | ~ | |
| ° | Degree Sign | U+00 | ° | |
| º | Masculine Ordinal Indicator | U+00 | º | |
| ˚ | Ring Above | U+02 | ˚ | |
| ⁰ | 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+02 | ˝ | |
| ” | Right Double Quotation Mark | U+201 | ” | |
| ″ | Double Prime | U+2033 | ″ |
| Latitude-longitude notation examples |
|---|
| 55 56 39.123 |
| 55°56′39″ |
| 55~56.65205', -003~09.71723' |
| 55.9442008* | -3.1619539* |
[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 |
|---|
| 30 |
| 30 |
[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 |
|---|
| 13 |
| 13 |
[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 |
|---|
| 30 |
| 30 |
| 30 |
| 489885.32,6199877.36,30 |
[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 | MKM | 1min | 2km |
| 1 | MKM | 1min | 2km |
| 2 | MKM | 1min | 2km |
| 3 | MKM | 0.1min | 200m |
| 4 | MKM | 0.01min | 20m |
| 5 | MKM | 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 nullptr 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 | Decimal | 056 | 1deg | 100km |
| 1 | Decimal | 55.9 | 0.1deg | 10km |
| 2 | Decimal | 55.94 | 0.01deg | 1km |
| 3 | Decimal | 55.944 | 0.001deg | 100m |
| 0 | Degrees | 55 057 | 1min | 2km |
| 1 | Degrees | 55 56.7 | 0.1min | 200m |
| 2 | Degrees | 55 56.65 | 0.01min | 20m |
| 3 | Degrees | 55 56.650 | 0.001min | 2m |
| 0 | Degrees | 55 56 039 | 1sec | 30m |
| 1 | Degrees | 55 56 39.1 | 0.1sec | 3m |
| 2 | Degrees | 55 56 39.12 | 0.01sec | 300mm |
| 3 | Degrees | 55 56 39.123 | 0.001sec | 30mm |
* At the equator to 1 significant figure. The 'decimal_places' should be in the interval [0, 16].
[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 180deg.
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 | 30 | 100km |
| 1 | false | 30 | 10km |
| 2 | false | 30 | 1km |
| 3 | false | 30 | 100m |
| 4 | false | 30 | 10m |
| 5 | false | 30 | 1m |
| 0 | true | 30 | 100km |
| 1 | true | 30 | 10km |
| 2 | true | 30 | 1km |
| 3 | true | 30 | 100m |
| 4 | true | 30 | 10m |
| 5 | true | 30 | 1m |
[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 | 13 | 100km |
| 1 | false | 13 | 10km |
| 2 | false | 13 | 1km |
| 3 | false | 13 | 100m |
| 4 | false | 13 | 10m |
| 5 | false | 13 | 1m |
| 0 | true | 13 | 100km |
| 1 | true | 13 | 10km |
| 2 | true | 13 | 1km |
| 3 | true | 13 | 100m |
| 4 | true | 13 | 10m |
| 5 | true | 13 | 1m |
| *4 | false | 13 | 10m |
| *2 | true | 13 | 1km |
* When the point's spatial reference is based on NAD 27.
[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 |
|---|---|---|
Latitude | false | 30 |
Latitude | true | 30 |
North | false | 30 |
North | true | 30 |