SLProject 4.0.000
SLDeviceLocation Class Reference

Encapsulation of a mobile device location set by the device's GPS sensor. More...

#include <SLDeviceLocation.h>

Public Member Functions

 SLDeviceLocation ()
 
void init ()
 
void onLocationLatLonAlt (SLdouble latDEG, SLdouble lonDEG, SLdouble altM, SLfloat accuracyM)
 Event handler for mobile device location update. More...
 
SLbool calculateSolarAngles (SLVec3d locationLatLonAlt, std::time_t time)
 Calculates the solar angles at origin at local time. More...
 
SLVec3d convertLatLonAlt2ENU (SLVec3d locLatLonAlt) const
 Converter method: the transferred wgs84 coordinate is converted to ENU frame and returned (does not change SLDeviceLocation) More...
 
void isUsed (SLbool isUsed)
 Setter that turns on the device rotation sensor. More...
 
void useOriginAltitude (SLbool useGLA)
 
void improveOrigin (SLbool impO)
 
void hasOrigin (SLbool hasOL)
 
void originLatLonAlt (int degreesLat, int minutesLat, double secondsLat, int degreesLon, int minutesLon, double secondsLon, double altitudeM)
 Origin coordinate setter in WGS84 Lat-Lon in degrees, minutes and seconds. More...
 
void originLatLonAlt (SLdouble latDEG, SLdouble lonDEG, SLdouble altM)
 Set global origin in latitude, longitude and altitude at the ground level. More...
 
void originLatLonAlt (SLVec3d lla)
 
void defaultLatLonAlt (int degreesLat, int minutesLat, double secondsLat, int degreesLon, int minutesLon, double secondsLon, double altitudeM)
 Default coordinate setter in WGS84 Lat-Lon in degrees, minutes and seconds. More...
 
void defaultLatLonAlt (SLdouble latDEG, SLdouble lonDEG, SLdouble altM)
 Sets the default location in latitude, longitude and altitude. More...
 
void defaultLatLonAlt (SLVec3d lla)
 
void locMaxDistanceM (SLfloat maxDist)
 
void sunLightNode (SLLightDirect *sln)
 
void loadGeoTiff (const SLstring &geoTiffFile)
 Loads a GeoTiff DEM (Digital Elevation Model) Image. More...
 
bool geoTiffIsAvailableAndValid () const
 
bool posIsOnGeoTiff (SLdouble latDEG, SLdouble lonDEG) const
 Return true if the current GPS location is within the GeoTiff boundaries. More...
 
void cameraHeightM (float camHeightM)
 
void offsetMode (SLLocOffsetMode lom)
 
void offsetENU (SLVec3d offsetENU)
 
void activeNamedLocation (SLint locIndex)
 
SLbool isUsed () const
 
SLVec3d locLatLonAlt () const
 
SLVec3d locECEF () const
 
SLVec3d locENU () const
 
SLfloat locAccuracyM () const
 
SLfloat locMaxDistanceM () const
 
SLVec3d defaultENU () const
 
SLVec3d originLatLonAlt () const
 
SLVec3d defaultLatLonAlt () const
 
SLVec3d originENU () const
 
SLVec3d offsetENU () const
 
SLbool hasOrigin () const
 
SLbool useOriginAltitude () const
 
SLMat3d wRecef () const
 
SLfloat improveTime ()
 
SLfloat originSolarZenit () const
 
SLfloat originSolarAzimut () const
 
SLfloat originSolarSunrise () const
 
SLfloat originSolarSunset () const
 
SLNodesunLightNode () const
 
SLfloat altDemM () const
 
SLfloat altGpsM () const
 
SLfloat cameraHeightM () const
 
SLLocOffsetMode offsetMode ()
 
SLstring offsetModeStr () const
 Returns the device location offset mode as string. More...
 
SLVLocationnameLocations ()
 
SLint activeNamedLocation () const
 

Private Attributes

SLbool _isUsed
 Flag if the devices GPS Sensor is used. More...
 
SLbool _isFirstSensorValue
 Flag for the first sensor values. More...
 
SLVec3d _locLatLonAlt
 Earth location in latitudeDEG, longitudeDEG & AltitudeM on WGS84 geoid. More...
 
SLVec3d _locECEF
 Cartesian location in ECEF. More...
 
SLVec3d _locENU
 Cartesian location in ENU frame. More...
 
SLfloat _locAccuracyM
 Horizontal accuracy radius in m with 68% probability. More...
 
SLfloat _locMaxDistanceM
 Max. allowed distance from origin. If higher it is ignored. More...
 
SLVec3d _defaultLatLonAlt
 Default location of scene in LatLonAlt. More...
 
SLVec3d _defaultENU
 Default location in ENU frame used if real location is too far away from origin. More...
 
SLVec3d _originLatLonAlt
 Global origin location of scene in LatLonAlt. More...
 
SLVec3d _originENU
 Origin location in ENU frame. More...
 
SLVec3d _offsetENU
 Offset vector in ENU frame. More...
 
SLfloat _originAccuracyM
 Accuracy radius of origin point. More...
 
SLfloat _originSolarZenith
 Zenith angle of the sun in deg. (from up dir.) at origin at local time. More...
 
SLfloat _originSolarAzimuth
 Azimuth angle of the sun in deg. (eastward from north) at origin at local time. More...
 
SLfloat _originSolarSunrise
 Sunrise local time at origin. More...
 
SLfloat _originSolarSunset
 Sunset local time at origin. More...
 
SLbool _hasOrigin
 Flag if this scene has a global reference location. More...
 
SLbool _useOriginAltitude
 Flag if global reference altitude should be used. More...
 
SLfloat _altDemM
 Altitude in m from Digital Elevation Model. More...
 
SLfloat _altGpsM
 Altitude in m from GPS. More...
 
SLfloat _cameraHeightM
 Height from ground to the mobile camera in m. More...
 
SLbool _improveOrigin
 Flag if origin should be improved over time & accuracy. More...
 
SLfloat _improveTimeSEC
 Max. time in seconds for the origin improvement. More...
 
HighResTimer _improveTimer
 Timer to measure the improve time. More...
 
SLMat3d _wRecef
 ECEF frame to world frame rotation: rotates a point defined in ecef. More...
 
SLNode_sunLightNode
 Pointer to directional light node to be changed if solar angles are calculated. More...
 
CVImageGeoTiff _demGeoTiff
 Digital Elevation Model from a Geo Tiff image. More...
 
SLLocOffsetMode _offsetMode
 Location offset mode. More...
 
SLVLocation _nameLocations
 Vector of fix locations for default view points. More...
 
SLint _activeNamedLocation
 Index of the active named location as defaultENU;. More...
 

Detailed Description

Encapsulation of a mobile device location set by the device's GPS sensor.

This class is only used if SLProject runs on a mobile device. Check out the app-Demo-SLProject/android and app_demo_slproject/ios how the sensor data is generated and passed to this object hold by AppDemo. The class stores the devices location that it gets from its GPS (global positioning system) sensor. The device location can be used in the active camera to apply it to the scene camera (s. SLCamera::setView).

  • LatLonAlt: The device location from GPS comes as a latitude (deg. north-south), longitude (deg. east-west) and altitude (m) LatLonAlt-tripple. These two angles are a position and height on the WGS84 ellipsoid (World Geodetic System 1984).
  • ECEF (Earth Centered Earth Fixed) are right-handed cartesian world coordinates with the z-axis at the north pole the x-axis at the prime meridian (0 deg. longitude) and the y-axis at 90 deg. longitude. x- and y-axis form the equator plane.
  • ENU (East North Up) is the local frame (= right-handed coordinate system) on the surface of the ellipsoid with the E=East tangential vector, the N=North tangential vector and U=Up as the ellipsoid's normal vector. Be aware that the up vector is normal to the ellipsoid and not to the terrain above. This normal does not point the center of the ellipsoid.
    If we want to show a local scene on the earth, we do this always in the ENU frame because in the ECEF frame with have not enough precision for float coordinates. Therefore we have define a local origin in the ENU frame and convert all locations from LatLonAlt to ECEF and the with the wRecef rotation matrix to the ENU frame.

Constructor & Destructor Documentation

◆ SLDeviceLocation()

SLDeviceLocation::SLDeviceLocation ( )
inline

Member Function Documentation

◆ activeNamedLocation() [1/2]

SLint SLDeviceLocation::activeNamedLocation ( ) const
inline

◆ activeNamedLocation() [2/2]

void SLDeviceLocation::activeNamedLocation ( SLint  locIndex)
inline

◆ altDemM()

SLfloat SLDeviceLocation::altDemM ( ) const
inline

◆ altGpsM()

SLfloat SLDeviceLocation::altGpsM ( ) const
inline

◆ calculateSolarAngles()

SLbool SLDeviceLocation::calculateSolarAngles ( SLVec3d  locationLatLonAlt,
std::time_t  time 
)

Calculates the solar angles at origin at local time.

Calculates the zenith and azimuth angle in deg. of the sun at the origin at the local time using the Solar Position Algorithm from: https://midcdmz.nrel.gov/spa/ that is part of libsl_external.

◆ cameraHeightM() [1/2]

SLfloat SLDeviceLocation::cameraHeightM ( ) const
inline

◆ cameraHeightM() [2/2]

void SLDeviceLocation::cameraHeightM ( float  camHeightM)
inline

◆ convertLatLonAlt2ENU()

SLVec3d SLDeviceLocation::convertLatLonAlt2ENU ( SLVec3d  locLatLonAlt) const

Converter method: the transferred wgs84 coordinate is converted to ENU frame and returned (does not change SLDeviceLocation)

◆ defaultENU()

SLVec3d SLDeviceLocation::defaultENU ( ) const
inline

◆ defaultLatLonAlt() [1/4]

SLVec3d SLDeviceLocation::defaultLatLonAlt ( ) const
inline

◆ defaultLatLonAlt() [2/4]

void SLDeviceLocation::defaultLatLonAlt ( int  degreesLat,
int  minutesLat,
double  secondsLat,
int  degreesLon,
int  minutesLon,
double  secondsLon,
double  altitudeM 
)

Default coordinate setter in WGS84 Lat-Lon in degrees, minutes and seconds.

◆ defaultLatLonAlt() [3/4]

void SLDeviceLocation::defaultLatLonAlt ( SLdouble  latDEG,
SLdouble  lonDEG,
SLdouble  altM 
)

Sets the default location in latitude, longitude and altitude.

It must be called after setting the origin. If no origin is set with it will be automatically set in onLocationLatLonAlt. The default location is used by the camera in SLCamera::setView if the current distance between _locENU and _originENU is greater than _locMaxDistanceM. Witch means that you are in real not near the location. /param latDEG Latitude (vertical) on WGS84 geoid in degrees /param lonDEG Longitude (horizontal) on WGS84 geoid in degrees /param altM Altitude over WGS84 geoid in meters

◆ defaultLatLonAlt() [4/4]

void SLDeviceLocation::defaultLatLonAlt ( SLVec3d  lla)
inline

◆ geoTiffIsAvailableAndValid()

bool SLDeviceLocation::geoTiffIsAvailableAndValid ( ) const

◆ hasOrigin() [1/2]

SLbool SLDeviceLocation::hasOrigin ( ) const
inline

◆ hasOrigin() [2/2]

void SLDeviceLocation::hasOrigin ( SLbool  hasOL)

◆ improveOrigin()

void SLDeviceLocation::improveOrigin ( SLbool  impO)
inline

◆ improveTime()

SLfloat SLDeviceLocation::improveTime ( )
inline

◆ init()

void SLDeviceLocation::init ( )

◆ isUsed() [1/2]

SLbool SLDeviceLocation::isUsed ( ) const
inline

◆ isUsed() [2/2]

void SLDeviceLocation::isUsed ( SLbool  isUsed)

Setter that turns on the device rotation sensor.

◆ loadGeoTiff()

void SLDeviceLocation::loadGeoTiff ( const SLstring geoTiffFile)

Loads a GeoTiff DEM (Digital Elevation Model) Image.

◆ locAccuracyM()

SLfloat SLDeviceLocation::locAccuracyM ( ) const
inline

◆ locECEF()

SLVec3d SLDeviceLocation::locECEF ( ) const
inline

◆ locENU()

SLVec3d SLDeviceLocation::locENU ( ) const
inline

◆ locLatLonAlt()

SLVec3d SLDeviceLocation::locLatLonAlt ( ) const
inline

◆ locMaxDistanceM() [1/2]

SLfloat SLDeviceLocation::locMaxDistanceM ( ) const
inline

◆ locMaxDistanceM() [2/2]

void SLDeviceLocation::locMaxDistanceM ( SLfloat  maxDist)
inline

◆ nameLocations()

SLVLocation & SLDeviceLocation::nameLocations ( )
inline

◆ offsetENU() [1/2]

SLVec3d SLDeviceLocation::offsetENU ( ) const
inline

◆ offsetENU() [2/2]

void SLDeviceLocation::offsetENU ( SLVec3d  offsetENU)
inline

◆ offsetMode() [1/2]

SLLocOffsetMode SLDeviceLocation::offsetMode ( )
inline

◆ offsetMode() [2/2]

void SLDeviceLocation::offsetMode ( SLLocOffsetMode  lom)
inline

◆ offsetModeStr()

SLstring SLDeviceLocation::offsetModeStr ( ) const

Returns the device location offset mode as string.

◆ onLocationLatLonAlt()

void SLDeviceLocation::onLocationLatLonAlt ( SLdouble  latDEG,
SLdouble  lonDEG,
SLdouble  altM,
SLfloat  accuracyM 
)

Event handler for mobile device location update.

Global event handler for device GPS location with longitude and latitude in degrees and altitude in meters. This location uses the World Geodetic System 1984 (WGS84). The accuracy in meters is a radius in which the location is with a probability of 68% (2 sigma). The altitude in m is the most inaccurate information. The option _useOriginAltitude allows to overwrite the current altitude with the origins altitude. If a geoTiff is available the altitude is is take from it. /param latDEG Latitude (vertical) on WGS84 geoid in degrees /param lonDEG Longitude (horizontal) on WGS84 geoid in degrees /param altM Altitude over WGS84 geoid in meters /param accuracyM Accuracy in meters is a radius

◆ originENU()

SLVec3d SLDeviceLocation::originENU ( ) const
inline

◆ originLatLonAlt() [1/4]

SLVec3d SLDeviceLocation::originLatLonAlt ( ) const
inline

◆ originLatLonAlt() [2/4]

void SLDeviceLocation::originLatLonAlt ( int  degreesLat,
int  minutesLat,
double  secondsLat,
int  degreesLon,
int  minutesLon,
double  secondsLon,
double  altitudeM 
)

Origin coordinate setter in WGS84 Lat-Lon in degrees, minutes and seconds.

◆ originLatLonAlt() [3/4]

void SLDeviceLocation::originLatLonAlt ( SLdouble  latDEG,
SLdouble  lonDEG,
SLdouble  altM 
)

Set global origin in latitude, longitude and altitude at the ground level.

The calculated values can be used for global camera positioning via GPS sensor. The origin is the zero point of the model. The origin should be defined in the model on the ground. /param latDEG Latitude (vertical) on WGS84 geoid in decimal degrees /param lonDEG Longitude (horizontal) on WGS84 geoid in decimal degrees /param altM Altitude over WGS84 geoid in meters

◆ originLatLonAlt() [4/4]

void SLDeviceLocation::originLatLonAlt ( SLVec3d  lla)
inline

◆ originSolarAzimut()

SLfloat SLDeviceLocation::originSolarAzimut ( ) const
inline

◆ originSolarSunrise()

SLfloat SLDeviceLocation::originSolarSunrise ( ) const
inline

◆ originSolarSunset()

SLfloat SLDeviceLocation::originSolarSunset ( ) const
inline

◆ originSolarZenit()

SLfloat SLDeviceLocation::originSolarZenit ( ) const
inline

◆ posIsOnGeoTiff()

bool SLDeviceLocation::posIsOnGeoTiff ( SLdouble  latDEG,
SLdouble  lonDEG 
) const

Return true if the current GPS location is within the GeoTiff boundaries.

◆ sunLightNode() [1/2]

SLNode * SLDeviceLocation::sunLightNode ( ) const
inline

◆ sunLightNode() [2/2]

void SLDeviceLocation::sunLightNode ( SLLightDirect sln)
inline

◆ useOriginAltitude() [1/2]

SLbool SLDeviceLocation::useOriginAltitude ( ) const
inline

◆ useOriginAltitude() [2/2]

void SLDeviceLocation::useOriginAltitude ( SLbool  useGLA)
inline

◆ wRecef()

SLMat3d SLDeviceLocation::wRecef ( ) const
inline

Member Data Documentation

◆ _activeNamedLocation

SLint SLDeviceLocation::_activeNamedLocation
private

Index of the active named location as defaultENU;.

◆ _altDemM

SLfloat SLDeviceLocation::_altDemM
private

Altitude in m from Digital Elevation Model.

◆ _altGpsM

SLfloat SLDeviceLocation::_altGpsM
private

Altitude in m from GPS.

◆ _cameraHeightM

SLfloat SLDeviceLocation::_cameraHeightM
private

Height from ground to the mobile camera in m.

◆ _defaultENU

SLVec3d SLDeviceLocation::_defaultENU
private

Default location in ENU frame used if real location is too far away from origin.

◆ _defaultLatLonAlt

SLVec3d SLDeviceLocation::_defaultLatLonAlt
private

Default location of scene in LatLonAlt.

◆ _demGeoTiff

CVImageGeoTiff SLDeviceLocation::_demGeoTiff
private

Digital Elevation Model from a Geo Tiff image.

◆ _hasOrigin

SLbool SLDeviceLocation::_hasOrigin
private

Flag if this scene has a global reference location.

◆ _improveOrigin

SLbool SLDeviceLocation::_improveOrigin
private

Flag if origin should be improved over time & accuracy.

◆ _improveTimer

HighResTimer SLDeviceLocation::_improveTimer
private

Timer to measure the improve time.

◆ _improveTimeSEC

SLfloat SLDeviceLocation::_improveTimeSEC
private

Max. time in seconds for the origin improvement.

◆ _isFirstSensorValue

SLbool SLDeviceLocation::_isFirstSensorValue
private

Flag for the first sensor values.

◆ _isUsed

SLbool SLDeviceLocation::_isUsed
private

Flag if the devices GPS Sensor is used.

◆ _locAccuracyM

SLfloat SLDeviceLocation::_locAccuracyM
private

Horizontal accuracy radius in m with 68% probability.

◆ _locECEF

SLVec3d SLDeviceLocation::_locECEF
private

Cartesian location in ECEF.

◆ _locENU

SLVec3d SLDeviceLocation::_locENU
private

Cartesian location in ENU frame.

◆ _locLatLonAlt

SLVec3d SLDeviceLocation::_locLatLonAlt
private

Earth location in latitudeDEG, longitudeDEG & AltitudeM on WGS84 geoid.

◆ _locMaxDistanceM

SLfloat SLDeviceLocation::_locMaxDistanceM
private

Max. allowed distance from origin. If higher it is ignored.

◆ _nameLocations

SLVLocation SLDeviceLocation::_nameLocations
private

Vector of fix locations for default view points.

◆ _offsetENU

SLVec3d SLDeviceLocation::_offsetENU
private

Offset vector in ENU frame.

◆ _offsetMode

SLLocOffsetMode SLDeviceLocation::_offsetMode
private

Location offset mode.

◆ _originAccuracyM

SLfloat SLDeviceLocation::_originAccuracyM
private

Accuracy radius of origin point.

◆ _originENU

SLVec3d SLDeviceLocation::_originENU
private

Origin location in ENU frame.

◆ _originLatLonAlt

SLVec3d SLDeviceLocation::_originLatLonAlt
private

Global origin location of scene in LatLonAlt.

◆ _originSolarAzimuth

SLfloat SLDeviceLocation::_originSolarAzimuth
private

Azimuth angle of the sun in deg. (eastward from north) at origin at local time.

◆ _originSolarSunrise

SLfloat SLDeviceLocation::_originSolarSunrise
private

Sunrise local time at origin.

◆ _originSolarSunset

SLfloat SLDeviceLocation::_originSolarSunset
private

Sunset local time at origin.

◆ _originSolarZenith

SLfloat SLDeviceLocation::_originSolarZenith
private

Zenith angle of the sun in deg. (from up dir.) at origin at local time.

◆ _sunLightNode

SLNode* SLDeviceLocation::_sunLightNode
private

Pointer to directional light node to be changed if solar angles are calculated.

◆ _useOriginAltitude

SLbool SLDeviceLocation::_useOriginAltitude
private

Flag if global reference altitude should be used.

◆ _wRecef

SLMat3d SLDeviceLocation::_wRecef
private

ECEF frame to world frame rotation: rotates a point defined in ecef.


The documentation for this class was generated from the following files: