QGeoCoordinate Class

The QGeoCoordinate class defines a geographical position on the surface of the Earth. More...

Header: #include <QGeoCoordinate>
qmake: QT += positioning
Since: Qt 5.2

This class was introduced in Qt 5.2.

Public Types

enum CoordinateFormat { Degrees, DegreesWithHemisphere, DegreesMinutes, DegreesMinutesWithHemisphere, DegreesMinutesSeconds, DegreesMinutesSecondsWithHemisphere }
enum CoordinateType { InvalidCoordinate, Coordinate2D, Coordinate3D }

Properties

Public Functions

double altitude() const
bool isValid() const
double latitude() const
double longitude() const
void setAltitude(double altitude)
void setLatitude(double latitude)
void setLongitude(double longitude)

Detailed Description

A QGeoCoordinate is defined by latitude, longitude, and optionally, altitude.

Use type() to determine whether a coordinate is a 2D coordinate (has latitude and longitude only) or 3D coordinate (has latitude, longitude and altitude). Use distanceTo() and azimuthTo() to calculate the distance and bearing between coordinates.

The coordinate values should be specified using the WGS84 datum. For more information on geographical terms see this article on coordinates and another on geodetic systems including WGS84.

Azimuth in this context is equivalent to a compass bearing based on true north.

This class is a Q_GADGET since Qt 5.5. It can be directly used from C++ and QML.

Member Type Documentation

enum QGeoCoordinate::CoordinateFormat

Defines the possible formatting options for toString().

ConstantValueDescription
QGeoCoordinate::Degrees0Returns a string representation of the coordinates in decimal degrees format.
QGeoCoordinate::DegreesWithHemisphere1Returns a string representation of the coordinates in decimal degrees format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
QGeoCoordinate::DegreesMinutes2Returns a string representation of the coordinates in degrees-minutes format.
QGeoCoordinate::DegreesMinutesWithHemisphere3Returns a string representation of the coordinates in degrees-minutes format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
QGeoCoordinate::DegreesMinutesSeconds4Returns a string representation of the coordinates in degrees-minutes-seconds format.
QGeoCoordinate::DegreesMinutesSecondsWithHemisphere5Returns a string representation of the coordinates in degrees-minutes-seconds format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.

See also toString().

enum QGeoCoordinate::CoordinateType

Defines the types of a coordinate.

ConstantValueDescription
QGeoCoordinate::InvalidCoordinate0An invalid coordinate. A coordinate is invalid if its latitude or longitude values are invalid.
QGeoCoordinate::Coordinate2D1A coordinate with valid latitude and longitude values.
QGeoCoordinate::Coordinate3D2A coordinate with valid latitude and longitude values, and also an altitude value.

Property Documentation

altitude : double

This property holds the altitude in meters above sea level.

The property is undefined (qQNaN()) if the altitude has not been set.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

This property was introduced in Qt 5.5.

Access functions:

double altitude() const
void setAltitude(double altitude)

isValid : const bool

This property holds the validity of this geo coordinate.

The geo coordinate is valid if the longitude and latitude properties have been set to valid values.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

This property was introduced in Qt 5.5.

Access functions:

bool isValid() const

latitude : double

This property holds the latitude in decimal degrees.

The property is undefined (qQNaN()) if the latitude has not been set. A positive latitude indicates the Northern Hemisphere, and a negative latitude indicates the Southern Hemisphere. When setting the latitude the new value should be in the WGS84 datum format.

To be valid, the latitude must be between -90 to 90 inclusive.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

This property was introduced in Qt 5.5.

Access functions:

double latitude() const
void setLatitude(double latitude)

longitude : double

This property holds the longitude in decimal degrees.

The property is undefined (qQNaN()) if the longitude has not been set. A positive longitude indicates the Eastern Hemisphere, and a negative longitude indicates the Western Hemisphere. When setting the longitude the new value should be in the WGS84 datum format.

To be valid, the longitude must be between -180 to 180 inclusive.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

This property was introduced in Qt 5.5.

Access functions:

double longitude() const
void setLongitude(double longitude)