C

LocationScriptInterface Class

The LocationScriptInterface class enables you to emulate the position of a device and the speed at which it is moving. More...

Header: #include <LocationScriptInterface>

Properties

Public Functions

double altitude() const
qreal azimuth(int satellite) const
qreal direction() const
qreal elevation(int satellite) const
qreal groundSpeed() const
qreal horizontalAccuracy() const
bool inUse(int satellite) const
double latitude() const
QObject *loadGPX(const QString &fileName)
QObject *loadNMEA(const QString &fileName)
double longitude() const
qreal magneticVariation() const
QList<int> satellites() const
void setAltitude(double )
void setDirection(qreal )
void setGroundSpeed(qreal )
void setHorizontalAccuracy(qreal )
void setLatitude(double )
void setLongitude(double )
void setMagneticVariation(qreal )
void setTimestamp(const QDateTime &dt)
void setUseCurrentTimestamp(bool )
void setVerticalAccuracy(qreal )
void setVerticalSpeed(qreal )
int signalStrength(int satellite) const
QDateTime timestamp() const
bool useCurrentTimestamp() const
qreal verticalAccuracy() const
qreal verticalSpeed() const

Public Slots

bool addSatellite(int satelliteIdentifier)
bool addSatellite(int satelliteIdentifier, qreal elevation, qreal azimuth, int signalStrength, bool inUse)
bool removeSatellite(int satelliteIdentifier)
bool setAzimuth(int satelliteIdentifier, qreal azimuth)
bool setElevation(int satelliteIdentifier, qreal elevation)
bool setIdentifier(int oldPrn, int newPrn)
bool setInUse(int satelliteIdentifier, bool inUse)
bool setSignalStrength(int satelliteIdentifier, int signalStrength)
bool setSystem(int satelliteIdentifier, int system)

Detailed Description

The LocationScriptInterface class enables you to emulate the position of a device and the speed at which it is moving.

Applications can use the Location module to access basic geographical information about the location of the device. The information is obtained from satellites and it includes latitude, longitude, altitude, direction, and speed.

The LocationScriptInterface class is exposed as location.

For example, the following script uses the latitude, longitude, and altitude properties to change the current location of the device every few seconds.

var i = 0;
while (i < 10)
{
    location.latitude += 0.0001;
    location.longitude -= 0.0001;
    location.altitude += 0.000001;
    location.useCurrentTimestamp = true;

    print ("Updated position:" + i);
    i = i + 1;

    yield(2000);
}

Property Documentation

altitude : double

This property holds the elevation from sea level of the reported position in meters.

The return value is undefined if the altitude has not been set.

Access functions:

double altitude() const
void setAltitude(double )

direction : qreal

This property holds the bearing of the reported position in degrees, relative to true north.

Access functions:

qreal direction() const
void setDirection(qreal )

groundSpeed : qreal

This property holds the velocity of the device in meters per second.

Access functions:

qreal groundSpeed() const
void setGroundSpeed(qreal )

horizontalAccuracy : qreal

This property holds the accuracy of the provided latitude-longitude value in meters.

Access functions:

qreal horizontalAccuracy() const
void setHorizontalAccuracy(qreal )

latitude : double

This property holds the latitude of the reported position in decimal degrees.

To be valid, the latitude value must be between -90 and 90. A positive value indicates the Northern Hemisphere, whereas a negative value indicates the Southern Hemisphere.

The return value is undefined if the latitude has not been set.

Access functions:

double latitude() const
void setLatitude(double )

longitude : double

This property holds the longitude of the reported position in decimal degrees.

To be valid, the longitude value must be between -180 and 180. A positive value indicates the Northern Hemisphere, whereas a negative value indicates the Southern Hemisphere.

The return value is undefined if the longitude has not been set.

Access functions:

double longitude() const
void setLongitude(double )

magneticVariation : qreal

This property holds the angle in degrees between the horizontal component of the magnetic field and true north.

A positive value indicates a clockwise direction from true north and a negative value indicates a counter-clockwise direction.

Access functions:

qreal magneticVariation() const
void setMagneticVariation(qreal )

timestamp : QDateTime

This property holds the date and time when the position was reported.

Access functions:

QDateTime timestamp() const
void setTimestamp(const QDateTime &dt)

useCurrentTimestamp : bool

This property holds whether the current time stamp is used.

Returns whether the Current radio button is selected in the Location view.

Access functions:

bool useCurrentTimestamp() const
void setUseCurrentTimestamp(bool )

verticalAccuracy : qreal

This property holds the accuracy of the reported altitude value in meters.

Access functions:

qreal verticalAccuracy() const
void setVerticalAccuracy(qreal )

verticalSpeed : qreal

This property holds the velocity of the device in meters per second.

Access functions:

qreal verticalSpeed() const
void setVerticalSpeed(qreal )

Member Function Documentation

[slot] bool LocationScriptInterface::addSatellite(int satelliteIdentifier)

Adds a new satellite with the identifier satelliteIdentifier. Returns true on success.

[slot] bool LocationScriptInterface::addSatellite(int satelliteIdentifier, qreal elevation, qreal azimuth, int signalStrength, bool inUse)

Adds a new satellite with the identifier satelliteIdentifier. Sets the reported elevation of the satellite to elevation, azimuth to azimuth, signal strength to signalStrength, and state to inUse.

qreal LocationScriptInterface::azimuth(int satellite) const

Returns the azimuth in degrees reported by satellite.

Returns -1 if the satellite does not exist.

See also setAzimuth().

qreal LocationScriptInterface::elevation(int satellite) const

Returns the elevation reported by satellite.

Returns -1 if the satellite does not exist.

See also setElevation().

bool LocationScriptInterface::inUse(int satellite) const

Returns whether the satellite is reported to be used to determine the current position.

A GPS receiver tracks a number of satellites to calculate the actual position of a device on earth. However, even if a satellite is in the reception range, the receiver might not be able to use its current position for calculations or its signal might be too weak.

See also setInUse().

QObject *LocationScriptInterface::loadGPX(const QString &fileName)

Loads the file specified by fileName to emulate latitude, longitude, elevation, and time. The file must be in the GPS exchange (GPX) format. A GPX file contains a collection of trackpoints that take location, elevation, and time as attributes, and can be used to exchange data between GPS devices and applications.

QObject *LocationScriptInterface::loadNMEA(const QString &fileName)

Loads the file specified by fileName to emulate position. The file must be in the NMEA format. NMEA is a communications standard used for connecting marine sensors and display units within ships and boats.

[slot] bool LocationScriptInterface::removeSatellite(int satelliteIdentifier)

Removes the satellite specified by satelliteIdentifier.

Returns true if the satellite can be removed successfully; otherwise returns false.

QList<int> LocationScriptInterface::satellites() const

Returns the satellite identifiers of the satellites that can be used for positioning.

[slot] bool LocationScriptInterface::setAzimuth(int satelliteIdentifier, qreal azimuth)

Sets the azimuth of the satellite identified by satelliteIdentifier as the value of azimuth.

Returns true if the satellite is found and its azimuth can be set. Otherwise, returns false.

See also azimuth().

[slot] bool LocationScriptInterface::setElevation(int satelliteIdentifier, qreal elevation)

Sets the angle (in degrees) to see the satellite satelliteIdentifier from the current position as elevation.

Returns true if the satellite is found and the elevation can be set. Otherwise, returns false.

See also elevation().

[slot] bool LocationScriptInterface::setIdentifier(int oldPrn, int newPrn)

Changes the satellite identifier from oldPrn to newPrn.

Returns true if the satellite identifier can be changed successfully; otherwise returns false.

[slot] bool LocationScriptInterface::setInUse(int satelliteIdentifier, bool inUse)

Sets the reported state of the satellite specified by satelliteIdentifier to inUse.

Returns true if the satellite is found and its reported state can be set. Otherwise, returns false.

See also inUse().

[slot] bool LocationScriptInterface::setSignalStrength(int satelliteIdentifier, int signalStrength)

Sets the signal strength of the satellite specified by satelliteIdentifier to signalStrength.

Returns true if the satellite is found and its signal strength can be set. Otherwise, returns false.

See also signalStrength().

[slot] bool LocationScriptInterface::setSystem(int satelliteIdentifier, int system)

Sets the satellite specified by satelliteIdentifier to emulate the positioning system system.

Returns true if the satellite is found and the system can be set. Otherwise, returns false.

int LocationScriptInterface::signalStrength(int satellite) const

Returns the signal strength of satellite in decibels.

Returns -1 if the satellite does not exist.

See also setSignalStrength().

Available under certain Qt licenses.
Find out more.