Coordinate QML Type

Tools to convert and parse GPS coordinates. More...

Import Statement: import ArcGIS.AppFramework.Sql 1.0

Properties

Methods

  • object convert(qgeocoordinate coordinate, string format)
  • object convert(qgeocoordinate coordinate, string format, object options)
  • object parse(string text)
  • object parse(string text, object options)

Detailed Description

The Coordinate component provides methods to either parse a text representation of geographic coordinates into a valid location format, as well as methods to convert a location value between different coordinate formats. This component is a singleton, and as such does not need to be instantiated.

The following code sample demonstrates a potential usage of the Coordinate component. The center of the map provides a value that is converted into the coordinate output below, while the text field above the map can be used to enter a coordinate in text, that will be parsed as a valid coordinate value that the map will zoom to.

Map {
    id: map
    plugin: Plugin { preferred: [ "esri" ] }
    center: QtPositioning.coordinate(  34.057252, -117.194581 )
    zoomLevel: 17
    copyrightsVisible: false

    TextField {
        width: parent.width
        text: "34°03.4351'N 117°11.6749'W" // geographic (dd, dms, ddm), geouri, srs, utm and mgrs
        placeholderText: qsTr( "Enter coordinate" )
        validator: InputValidator {
            validate: function ( input ) {
                let info = Coordinate.parse( input );
                return info.coordinateValid ? InputValidator.Acceptable : InputValidator.Intermediate;
            }
        }
        onAccepted: {
            let info = Coordinate.parse( text );
            map.center = QtPositioning.coordinate( info.coordinate.latitude, info.coordinate.longitude );
        }
    }

    Text {
        anchors.bottom: parent.bottom
        width: parent.width
        text: coordinateToDMS( map.center )
    }

    function coordinateToDMS( coordinate ) {
        let format = "dms"; // mgrs, utm, ups, universalGrid, srs, dd, ddm, dms
        let options = { precision: 4 };
        let info = Coordinate.convert( coordinate, format, options );
        return info.dms.latitudeText + " " + info.dms.longitudeText;
    }
}

Property Documentation

[read-only] availableConvertFormats : QStringList

A list of available formats to convert GPS values into. The following formats are supported by the AppFramework:

OutputDescription
mgrsMilitary Grade Reference System
utmUniversal Tranverse Mercator
upsUniversal Polar Stereographic
universalGridUniversal Grid (returns either UTM or UPS depending on which is applicable)
srsSpatial Reference System
ddDecimal degrees
ddmDegrees decimal minutes
dmsDegrees minutes seconds

[read-only] availableParseFormats : QStringList

A list of available formats to convert a string interpretation of a GPS coordinate as. The following formats are supported by the AppFramework:

OutputDescription
mgrsMilitary Grade Reference System
utmUniversal Tranverse Mercator
srsSpatial Reference System
geographicGeographic coordinate system
geouriGeo URI scheme

Method Documentation

object convert(qgeocoordinate coordinate, string format)

Converts the provided GPS coordinate into the given format.

The coordinate parameter

The GPS coordinate to convert into a new format.

The format parameter

The output format for the GPS coordinate to convert.


object convert(qgeocoordinate coordinate, string format, object options)

Converts the provided GPS coordinate into the given format. Certain output formats can also accept other properties that can be set in the options parameter.

The coordinate parameter

The GPS coordinate to convert into a new format.

The format parameter

The output format for the GPS coordinate to convert.

The options parameter

If there are options available for the output format you are using, provide them here.

For SRS, you can provide an SRID to declare if your coordinate is to be output in geographic coordinates or web mercator. For DD, DDM or DMS, you can provide a precision value to determine the amount of decimal places that the values will be rounded to.


object parse(string text)

Parses a text string as a GPS coordinate.

The text parameter

The text string to parse as a GPS coordinate.


object parse(string text, object options)

Parses a text string as a GPS coordinate, adhering to the provided options.

The text parameter

The text string to parse as a GPS coordinate.

The options parameter


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.