Qt Virtual Chart Table (QVCT)
CDataPositionValidity.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QDateTime>
21 
22 // QVCT
23 #include "QVCTRuntime.hpp"
25 
26 
27 //------------------------------------------------------------------------------
28 // CONSTRUCTORS / DESTRUCTOR
29 //------------------------------------------------------------------------------
30 
32  : fdTimeLastPosition( UNDEFINED_VALUE )
33  , fdErrorPosition( UNDEFINED_VALUE )
34  , bInvalidPosition( false )
35  , fdTimeLastElevation( UNDEFINED_VALUE )
36  , fdErrorElevation( UNDEFINED_VALUE )
37  , bInvalidElevation( false )
38 {}
39 
40 
41 //------------------------------------------------------------------------------
42 // METHODS
43 //------------------------------------------------------------------------------
44 
45 //
46 // GETTERS
47 //
48 
50 {
51  if( bInvalidPosition ) return false;
52  if( fdErrorPosition != UNDEFINED_VALUE && fdErrorPosition > QVCTRuntime::useSettings()->getMaxErrorPosition() ) return false;
53  if( fdTimeLastPosition != UNDEFINED_VALUE && microtime() - fdTimeLastPosition > QVCTRuntime::useSettings()->getMaxAgePosition() ) return false;
54  return true;
55 }
56 
58 {
59  if( bInvalidElevation ) return false;
60  if( fdErrorElevation != UNDEFINED_VALUE && fdErrorElevation > QVCTRuntime::useSettings()->getMaxErrorElevation() ) return false;
61  if( fdTimeLastElevation != UNDEFINED_VALUE && microtime() - fdTimeLastElevation > QVCTRuntime::useSettings()->getMaxAgeElevation() ) return false;
62  return true;
63 }
double fdTimeLastPosition
Position last-set time, in seconds from Unix epoch.
bool isValidPosition() const
Returns the position's (global) validity status.
double fdTimeLastElevation
Elevation last-set time, in seconds from Unix epoch.
double fdErrorPosition
Position error, in meters.
bool isValidElevation() const
Returns the elevation's (global) validity status.
bool bInvalidPosition
Position (forced) invalidity status.
bool bInvalidElevation
Elevation (forced) invalidity status.
double fdErrorElevation
Elevation error, in meters.
static constexpr double UNDEFINED_VALUE
static CSettings * useSettings()
double microtime()
Returns the system time with microseconds resolution, in seconds.
Definition: main.cpp:30