AirplaneUtil.h
Go to the documentation of this file.
1 /*
2  * AirplaneUtil.h
3  *
4  * Created on: Apr 19, 2015
5  * Author: leven
6  */
7 
8 #ifndef AIRPLANEUTIL_H_
9 #define AIRPLANEUTIL_H_
10 
11 #include "utl/PhysicalConstants.h"
12 #include "utl/UTCDateTime.h"
13 #include <string>
14 
15 namespace RdAirplane {
16 namespace Util {
17 std::string inline TimestampHumanReadAble(const double& pUnixTimeStampInS) {
18  char timeHumanReadable[20];
19  time_t time = pUnixTimeStampInS;
20  tm* timeStruct = gmtime(&time);
21  strftime(timeHumanReadable, sizeof(timeHumanReadable), "%d.%m.%Y %H:%M:%S", timeStruct);
22  return timeHumanReadable;
23 }
24 /*
25  * Returns the gps time as a double.
26  * This is an approximation because the double data type is not large enough to store all the decimals.
27  */
28 double inline ApproximatedGPSTimeStampFromTimestamp(const utl::TimeStamp& pTimeStamp) {
29  return (pTimeStamp.GetGPSSecond())+((double)pTimeStamp.GetGPSNanoSecond()*pow(10.0,-9));
30 }
31 /*
32  * Returns the unix time as a double.
33  * This is an approximation because the double data type is not large enough to store all the decimals.
34  */
35 double inline ApproximatedUnixTimeStampFromTimestamp(const utl::TimeStamp& pTimeStamp) {
36  utl::UTCDateTime time(pTimeStamp);
37  return (double)time.GetUnixSecond()+(double)time.GetNanosecond()*pow(10.0,-9);
38 }
39 
40 template<typename ContainerType>
41 void inline deleteAllPointersInContainer(ContainerType& pContainer) {
42  for(typename ContainerType::iterator iter = pContainer.begin(); iter!=pContainer.end(); ++iter) {
43  delete *iter;
44  }
45 }
46 
47 }
48 }
49 #endif /* AIRPLANEUTIL_H_ */
std::time_t GetUnixSecond() const
seconds after Unix epoch (1 Jan 1970) without any leap corrections
Definition: UTCDateTime.h:63
double GetNanosecond() const
Definition: UTCDateTime.h:60
double pow(const double x, const unsigned int i)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
unsigned long GetGPSSecond() const
GPS second.
Definition: TimeStamp.h:124
void deleteAllPointersInContainer(ContainerType &pContainer)
Definition: AirplaneUtil.h:41
double GetGPSNanoSecond() const
GPS nanosecond.
Definition: TimeStamp.h:127
double ApproximatedGPSTimeStampFromTimestamp(const utl::TimeStamp &pTimeStamp)
Definition: AirplaneUtil.h:28
double ApproximatedUnixTimeStampFromTimestamp(const utl::TimeStamp &pTimeStamp)
Definition: AirplaneUtil.h:35
std::string TimestampHumanReadAble(const double &pUnixTimeStampInS)
Definition: AirplaneUtil.h:17

, generated on Tue Sep 26 2023.