6 #include "det/Detector.h"
8 #include "atm/Atmosphere.h"
9 #include "atm/USStdADBProfileModel.h"
10 #include "utl/AugerUnits.h"
19 using namespace RdAirplane;
24 using namespace boost;
29 _captureTime_(pCaptureTime),
30 _coordinatesFromAds_b_(pCoordinates),
31 _pressureAltitude_(-1.0),
32 _manuallyCorrectedPressureAltitude_(-1.0),
33 _GDAScorrectedPressureAltitude_(-1.0),
35 _ads_bMessageBinary_(_binaryFromHexString(pAds_bMessageAsHex)),
38 _altitudeType_(ePressureAltitude) {
41 double altitudeOffset=0.0;
55 Detector& detector = Detector::GetInstance();
67 double latitude = geodeticCoordinates.get<0>();
68 double longitude = geodeticCoordinates.get<1>();
88 switch(pAltitudeType) {
98 throw runtime_error(
"Encountered an unknown altitude type.");
103 switch(pAltitudeType) {
106 throw runtime_error(
"Tried to read the gps altitude from ADS-B data that does not contain gps informations.");
110 throw runtime_error(
"Tried to read the corrected pressure altitude from ADS-B data for which the altitude was either from gps or could not be corrected.");
114 throw runtime_error(
"Tried to read the pressure altitude from ADS-B data only holding the gps altitude.");
118 throw runtime_error(
"Tried to read the pressure altitude from ADS-B data only holding the gps altitude.");
121 throw runtime_error(
"Encountered an unknown altitude type.");
127 if(pRecursionDepth>=pMaxRecursionDepth)
129 double middleAltitude = (pLowerAltitude+pUpperAltitude)/2;
130 double middlePressure = pProfileResult.
Y(middleAltitude);
131 if(
abs(middlePressure-pPressure)<pPressureTreshold)
132 return middleAltitude;
133 if(middlePressure >= pPressure)
134 return _getAltitudeFromPressure(pProfileResult, pPressure, middleAltitude, pUpperAltitude, pPressureTreshold, ++pRecursionDepth, pMaxRecursionDepth);
136 return _getAltitudeFromPressure(pProfileResult, pPressure, pLowerAltitude, middleAltitude, pPressureTreshold, ++pRecursionDepth, pMaxRecursionDepth);
140 static double lowestAltitude = 7000*
m;
141 static double highestAltitude = 13000*
m;
142 static double pressureThreshold = 1*
milli*
bar;
143 static unsigned int maxRecursionDepth = 100;
144 return _getAltitudeFromPressure(pProfileResult, pPressure, lowestAltitude, highestAltitude, pressureThreshold, 0, maxRecursionDepth);
148 static bool alphabet[16][4] = {
167 switch(toupper(pHexChar)) {
168 case '0': index = 0;
break;
169 case '1': index = 1;
break;
170 case '2': index = 2;
break;
171 case '3': index = 3;
break;
172 case '4': index = 4;
break;
173 case '5': index = 5;
break;
174 case '6': index = 6;
break;
175 case '7': index = 7;
break;
176 case '8': index = 8;
break;
177 case '9': index = 9;
break;
178 case 'A': index = 10;
break;
179 case 'B': index = 11;
break;
180 case 'C': index = 12;
break;
181 case 'D': index = 13;
break;
182 case 'E': index = 14;
break;
183 case 'F': index = 15;
break;
185 throw runtime_error(
"Encountered invalid hex character " + pHexChar);
188 bool* res = alphabet[index];
189 return vector<bool>(res, res+4);
194 for(
size_t i = 0; i<pHexString.length();++i) {
196 for(vector<bool>::const_iterator iter = charToBinary.begin(); iter!=charToBinary.end(); ++iter)
197 res.push_back(*iter);
213 unsigned short i = pVector.size()-1;
214 for(vector<bool>::const_iterator it = pVector.begin(); it != pVector.end(); ++it,--i){
224 vector<bool> tc(first, last);
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
Top of the interface to Atmosphere information.
constexpr double atmosphere
const double & getAltitudeOffset() const
AltitudeType _altitudeType_
static std::vector< bool > _binaryFromHexString(const std::string &pHexString)
std::vector< bool > _ads_bMessageBinary_
bool ShouldBeFilteredOut() const
utl::TimeStamp GetTime() const
Get time pertaining to the detector description.
Class to hold and convert a point in geodetic coordinates.
bool HasGPSAltitude() const
static const unsigned int ADS_B_DATA_BIT_OFFSET
const atm::ProfileResult & EvaluatePressureVsHeight() const
Tabulated function giving Y=air pressure as a function of X=height.
double _manuallyCorrectedPressureAltitude_
static int _intFromBoolVector(const std::vector< bool > &pVector)
Ads_bEvent(const utl::TimeStamp &pCaptureTime, const utl::UTMPoint &pCoordinates, const std::string &pAds_bMessageAsHex, Flight *pFlight)
utl::UTMPoint * _coordinatesGPSAltitude_
utl::UTMPoint * _coordinatesManuallyCorrectedPressureAltitude_
utl::UTMPoint * _coordinatesGDASCorrectedPressureAltitude_
utl::TimeStamp _captureTime_
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
A TimeStamp holds GPS second and nanosecond for some event.
const atm::Atmosphere & GetAtmosphere() const
Extracts profile info from US Standard Atmosphere.
Reference ellipsoids for UTM transformations.
double GetHeight() const
Get the height.
Class describing the Atmospheric profile.
const utl::UTMPoint & getCoordinates() const
double abs(const SVector< n, T > &v)
double _GDAScorrectedPressureAltitude_
Top of the hierarchy of the detector description interface.
static double _getAltitudeFromPressure(const atm::ProfileResult &pProfileResult, double pPressure, double pLowerHeight, double pUpperHeight, double pPressureTreshold, unsigned int pRecursionDepth, unsigned int pMaxRecursionDepth)
bool _decodeAds_bMessage()
A TimeInterval is used to represent time elapsed between two events.
const ReferenceEllipsoid & GetEllipsoid() const
Get the reference ellipsoid.
double getAltitude(AltitudeType pAltitudeType) const
double _pressureAltitude_
static utl::TimeInterval MAX_TIME_SPAN_BETWEEN_ADS_B_EVENT_AND_DETECTOR_TIME
const AirplaneOffset * getOffset() const
static std::vector< bool > _binaryFromHexChar(const char &pHexChar)
utl::UTMPoint * _coordinatesPressureAltitude_
const atm::ProfileResult & EvaluatePressureVsHeight() const override
Table of air pressure as a function of height.
boost::tuple< double, double, double > GetGeodeticCoordinates() const
Get geodetic latitude, longitude, height.
const utl::TimeInterval & getTimeOffset() const
utl::UTMPoint _coordinatesFromAds_b_