- class QGeoCoordinate¶
The
QGeoCoordinate
class defines a geographical position on the surface of the Earth. More…Synopsis¶
Properties¶
altitudeᅟ
- This property holds the altitude in meters above sea levelisValidᅟ
- This property holds the validity of this geo coordinatelatitudeᅟ
- This property holds the latitude in decimal degreeslongitudeᅟ
- This property holds the longitude in decimal degrees
Methods¶
def
__init__()
def
altitude()
def
azimuthTo()
def
distanceTo()
def
isValid()
def
latitude()
def
longitude()
def
__ne__()
def
__eq__()
def
setAltitude()
def
setLatitude()
def
setLongitude()
def
swap()
def
toString()
def
type()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
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). UsedistanceTo()
andazimuthTo()
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 .
- class CoordinateType¶
Defines the types of a coordinate.
Constant
Description
QGeoCoordinate.InvalidCoordinate
An invalid coordinate. A coordinate is invalid if its latitude or longitude values are invalid.
QGeoCoordinate.Coordinate2D
A coordinate with valid latitude and longitude values.
QGeoCoordinate.Coordinate3D
A coordinate with valid latitude and longitude values, and also an altitude value.
- class CoordinateFormat¶
Defines the possible formatting options for
toString()
.Constant
Description
QGeoCoordinate.Degrees
Returns a string representation of the coordinates in decimal degrees format.
QGeoCoordinate.DegreesWithHemisphere
Returns a string representation of the coordinates in decimal degrees format, using ‘N’, ‘S’, ‘E’ or ‘W’ to indicate the hemispheres of the coordinates.
QGeoCoordinate.DegreesMinutes
Returns a string representation of the coordinates in degrees-minutes format.
QGeoCoordinate.DegreesMinutesWithHemisphere
Returns a string representation of the coordinates in degrees-minutes format, using ‘N’, ‘S’, ‘E’ or ‘W’ to indicate the hemispheres of the coordinates.
QGeoCoordinate.DegreesMinutesSeconds
Returns a string representation of the coordinates in degrees-minutes-seconds format.
QGeoCoordinate.DegreesMinutesSecondsWithHemisphere
Returns 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
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property altitudeᅟ: float¶
This property holds 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.
- Access functions:
- property isValidᅟ: bool¶
This property holds This property holds the validity of this geo coordinate..
The geo coordinate is valid if the
longitude
andlatitude
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.
- Access functions:
- property latitudeᅟ: float¶
This property holds 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.
- Access functions:
- property longitudeᅟ: float¶
This property holds 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.
- Access functions:
- __init__()¶
Constructs a coordinate. The coordinate will be invalid until
setLatitude()
andsetLongitude()
have been called.- __init__(other)
- Parameters:
other –
QGeoCoordinate
Constructs a coordinate from the contents of
other
.- __init__(latitude, longitude)
- Parameters:
latitude – float
longitude – float
Constructs a coordinate with the given
latitude
andlongitude
.If the latitude is not between -90 to 90 inclusive, or the longitude is not between -180 to 180 inclusive, none of the values are set and the
type()
will beInvalidCoordinate
.See also
- __init__(latitude, longitude, altitude)
- Parameters:
latitude – float
longitude – float
altitude – float
Constructs a coordinate with the given
latitude
,longitude
andaltitude
.If the latitude is not between -90 to 90 inclusive, or the longitude is not between -180 to 180 inclusive, none of the values are set and the
type()
will beInvalidCoordinate
.Note that
altitude
specifies the meters above sea level.See also
- altitude()¶
- Return type:
float
Returns the altitude (meters above sea level).
The return value is undefined if the altitude has not been set.
See also
Getter of property
altitudeᅟ
.- atDistanceAndAzimuth(distance, azimuth[, distanceUp=0.0])¶
- Parameters:
distance – float
azimuth – float
distanceUp – float
- Return type:
Returns the coordinate that is reached by traveling
distance
meters from the current coordinate atazimuth
(or bearing) along a great-circle. There is an assumption that the Earth is spherical for the purpose of this calculation.The altitude will have
distanceUp
added to it.Returns an invalid coordinate if this coordinate is invalid.
- azimuthTo(other)¶
- Parameters:
other –
QGeoCoordinate
- Return type:
float
Returns the azimuth (or bearing) in degrees from this coordinate to the coordinate specified by
other
. Altitude is not used in the calculation.The bearing returned is the bearing from the origin to
other
along the great-circle between the two coordinates. There is an assumption that the Earth is spherical for the purpose of this calculation.Returns 0 if the type of this coordinate or the type of
other
isInvalidCoordinate
.- distanceTo(other)¶
- Parameters:
other –
QGeoCoordinate
- Return type:
float
Returns the distance (in meters) from this coordinate to the coordinate specified by
other
. Altitude is not used in the calculation.This calculation returns the great-circle distance between the two coordinates, with an assumption that the Earth is spherical for the purpose of this calculation.
Returns 0 if the type of this coordinate or the type of
other
isInvalidCoordinate
.- isValid()¶
- Return type:
bool
Returns
true
if thelongitude
andlatitude
are valid.Getter of property
isValidᅟ
.- latitude()¶
- Return type:
float
Returns the latitude, in decimal degrees. The return value is undefined if the latitude has not been set.
A positive latitude indicates the Northern Hemisphere, and a negative latitude indicates the Southern Hemisphere.
See also
Getter of property
latitudeᅟ
.- longitude()¶
- Return type:
float
Returns the longitude, in decimal degrees. The return value is undefined if the longitude has not been set.
A positive longitude indicates the Eastern Hemisphere, and a negative longitude indicates the Western Hemisphere.
See also
Getter of property
longitudeᅟ
.- __ne__(rhs)¶
- Parameters:
rhs –
QGeoCoordinate
- Return type:
bool
Returns
true
if latitude, longitude, or altitude of thelhs
coordinate are not identical to those of therhs
coordinate. Otherwise returnsfalse
.- __eq__(rhs)¶
- Parameters:
rhs –
QGeoCoordinate
- Return type:
bool
Returns
true
if the latitude, longitude and altitude of thelhs
coordinate are the same as those of therhs
coordinate. Otherwise returnsfalse
.The longitude will be ignored if the latitude is +/- 90 degrees.
- setAltitude(altitude)¶
- Parameters:
altitude – float
Sets the altitude (meters above sea level) to
altitude
.See also
Setter of property
altitudeᅟ
.- setLatitude(latitude)¶
- Parameters:
latitude – float
Sets the latitude (in decimal degrees) to
latitude
. The value should be in the WGS84 datum.To be valid, the latitude must be between -90 to 90 inclusive.
See also
Setter of property
latitudeᅟ
.- setLongitude(longitude)¶
- Parameters:
longitude – float
Sets the longitude (in decimal degrees) to
longitude
. The value should be in the WGS84 datum.To be valid, the longitude must be between -180 to 180 inclusive.
See also
Setter of property
longitudeᅟ
.- swap(other)¶
- Parameters:
other –
QGeoCoordinate
- toString([format=QGeoCoordinate.CoordinateFormat.DegreesMinutesSecondsWithHemisphere])¶
- Parameters:
format –
CoordinateFormat
- Return type:
str
Returns this coordinate as a string in the specified
format
.For example, if this coordinate has a latitude of -27.46758, a longitude of 153.027892 and an altitude of 28.1, these are the strings returned depending on
format
:format
valueReturned string
-27.46758°, 153.02789°, 28.1m
27.46758° S, 153.02789° E, 28.1m
-27° 28.054’, 153° 1.673’, 28.1m
27° 28.054 S’, 153° 1.673’ E, 28.1m
-27° 28’ 3.2”, 153° 1’ 40.4”, 28.1m
27° 28’ 3.2” S, 153° 1’ 40.4” E, 28.1m
The altitude field is omitted if no altitude is set.
If the coordinate is invalid, an empty string is returned.
- type()¶
- Return type:
Returns the type of this coordinate.