API Documentation
Documentation for developing SailfishOS applicationsLocationInfo Class
(Sailfish::Mdm::LocationInfo)The LocationInfo class provides device location data. More...
Header: | #include <mdm-location.h> |
Public Types
class | Position |
Properties
|
Public Functions
LocationInfo(QObject *parent = Q_NULLPTR) | |
~LocationInfo() | |
double | altitude() const |
double | latitude() const |
double | longitude() const |
Position | position() const |
void | requestUpdate() |
int | satellitesInUse() const |
int | satellitesInView() const |
void | startUpdates() |
void | stopUpdates() |
QDateTime | timestamp() const |
Signals
void | positionChanged() |
void | satellitesChanged() |
Detailed Description
The LocationInfo class provides device location data.
Clients can use this to retrieve the current location of the device, assuming that some positioning method is enabled.
To use this class, clients must add the following to their qmake project:
CONFIG += link_pkgconfig PKGCONFIG += sailfishmdm
and then #include <mdm-location.h>
.
Example of usage:
#include <mdm-location.h> void listenForLocationChange(QObject *parent) { Sailfish::Mdm::LocationInfo *info = new Sailfish::Mdm::LocationInfo(parent); QObject::connect(info, &Sailfish::Mdm::LocationInfo::positionChanged, [info] { qInfo() << "GPS: Coordinates:" << info->latitude() << "," << info->longitude(); }); info->requestUpdate(); }
Property Documentation
altitude : const double
This property holds the altitude of the device as reported in the most recent position update.
This method will return a Not-A-Number double if no altitude is currently known for the device (for example if no position updates have yet been provided by any position providers).
The positionChanged() signal will be emitted when a position update is received.
Access functions:
double | altitude() const |
Notifier signal:
void | positionChanged() |
latitude : const double
This property holds the latitude of the device as reported in the most recent position update.
This method will return a Not-A-Number double if no latitude is currently known for the device (for example if no position updates have yet been provided by any position providers).
The positionChanged() signal will be emitted when a position update is received.
Access functions:
double | latitude() const |
Notifier signal:
void | positionChanged() |
longitude : const double
This property holds the longitude of the device as reported in the most recent position update.
This method will return a Not-A-Number double if no longitude is currently known for the device (for example if no position updates have yet been provided by any position providers).
The positionChanged() signal will be emitted when a position update is received.
Access functions:
double | longitude() const |
Notifier signal:
void | positionChanged() |
position : const Position
This property holds the most recent position update received.
This value is updated whenever a position update is received from one of the enabled position providers.
Note that if the client has not called requestUpdate() recently and has not requested continual updates via startUpdates() then the position returned may be stale!
Access functions:
Position | position() const |
Notifier signal:
void | positionChanged() |
satellitesInUse : const int
This property holds the number of GPS satellites currently in use.
Note that the GPS provider may not be able to provide an accurate position update until at least 4 satellites are in use.
The satellitesChanged() signal will be emitted when the number of satellites in use or in view have changed.
Access functions:
int | satellitesInUse() const |
Notifier signal:
void | satellitesChanged() |
satellitesInView : const int
This property holds the number of GPS satellites currently in view.
This number is based on the almanac data.
The satellitesChanged() signal will be emitted when the number of satellites in use or in view have changed.
Access functions:
int | satellitesInView() const |
Notifier signal:
void | satellitesChanged() |
timestamp : const QDateTime
This property holds the timestamp of the most recent position update.
This method will return an invalid date-time if no position updates have yet been provided by any position providers.
The positionChanged() signal will be emitted when a position update is received.
Access functions:
QDateTime | timestamp() const |
Notifier signal:
void | positionChanged() |
Member Function Documentation
LocationInfo::LocationInfo(QObject *parent = Q_NULLPTR)
Default constructs an instance of LocationInfo.
LocationInfo::~LocationInfo()
Destroys the instance of LocationInfo.
[signal]
void LocationInfo::positionChanged()
This signal is emitted whenever a position update is received from one of the enabled position providers. Clients will only receive this signal if they have previously called requestUpdate() or startUpdates().
Note: Notifier signal for property altitude. Notifier signal for property latitude. Notifier signal for property longitude. Notifier signal for property position. Notifier signal for property timestamp.
void LocationInfo::requestUpdate()
Requests a single position and satellite update from the enabled positioning providers.
[signal]
void LocationInfo::satellitesChanged()
This signal is emitted whenever the number of satellites in view or in use changes, according to the GPS position provider. Clients will only receive this signal if they have previously called requestUpdate() or startUpdates().
Note: Notifier signal for property satellitesInUse. Notifier signal for property satellitesInView.
void LocationInfo::startUpdates()
Subscribes the client to position updates from any enabled position providers (including GPS and aGPS).
void LocationInfo::stopUpdates()
Unsubscribes the client from position updates from position providers (including GPS and aGPS).
If the client was the last active subscriber, the GPS provider will power down the GPS hardware, and any aGPS provider processes will exit.