8 #include "DataWriter.h"
18 using namespace RdAirplane;
21 namespace fs = boost::filesystem;
22 using namespace DataWriterUtil;
25 const char* DataWriter::stationInfosFileName =
"stationsInfo.dat";
26 const char* DataWriter::generalInfoFileName =
"generalInfo.dat";
29 _outputDirectory_(fs::path(pOutputDirectory)),
30 _globalCoordinateSystem_(pCoordinateSystem) {
33 throw runtime_error(error);
37 for(StationMap::iterator iter =
_stations_.begin();
56 stationInfo=iter->second;
67 ofstream generalStationsInfoFileHandle;
70 generalStationsInfoFileHandle.open(path.c_str());
72 if(!generalStationsInfoFileHandle.is_open()) {
73 ERROR(
"Could not write stations data.");
77 generalStationsInfoFileHandle <<
"Station Id| "
78 <<
"Station Latitude (UTM) (degree)| "
79 <<
"Station Longitude (UTM) (degree)| "
80 <<
"Station Altitude (UTM) (m)| "
81 <<
"Station-CS-Origin-X In Global CS (m)| "
82 <<
"Station-CS-Origin-Y In Global CS (m)| "
83 <<
"Station-CS-Origin-Z In Global CS (m)| "
84 <<
"Station-CS eX In Global CS (m)| "
85 <<
"Station-CS eY In Global CS (m)| "
86 <<
"Station-CS eZ In Global CS (m)| "
92 generalStationsInfoFileHandle << setprecision(numeric_limits<long double>::digits10 + 1)
93 << station.
getId() <<
" ";
96 generalStationsInfoFileHandle << endl;
99 generalStationsInfoFileHandle.close();
103 generalStationsInfoFileHandle.close();
121 eventOutputDirectory+=
"/"+pEventId;
123 if(!fs::create_directory(eventOutputDirectory)) {
127 return eventOutputDirectory;
133 const Point& pReconstructedRadioEventOrigin,
141 Point airplanePosition_manuallyCorrectedPressureAltitude = airplanePosition_manuallyCorrectedPressureAltitude_p==NULL ? Point(0,0,0,
_globalCoordinateSystem_) : *airplanePosition_manuallyCorrectedPressureAltitude_p;
144 Point airplanePosition_CorrectedPressureAltitude = airplanePosition_CorrectedPressureAltitude_p==NULL ? Point(0,0,0,
_globalCoordinateSystem_) : *airplanePosition_CorrectedPressureAltitude_p;
147 Point airplanePosition_GPSAltitude = airplanePosition_GPSAltitude_p==NULL ? Point(0,0,0,
_globalCoordinateSystem_) : *airplanePosition_GPSAltitude_p;
149 Point coreCoordinateSystemOrigin(0,0,0,pCoreCoordinateSystem);
153 fs::path generalInfoFile(eventFolder);
155 generalInfoFile+=
"/";
157 ofstream generalInfoFileHandle;
159 generalInfoFileHandle.open(generalInfoFile.c_str());
161 if(!generalInfoFileHandle.is_open()) {
165 generalInfoFileHandle <<
"Radio Event Id| "
166 <<
"Unix Time Stamp (s)| "
170 <<
"Airplane X-Coordinate (Pressure Altitude) In Global CS (m)| "
171 <<
"Airplane Y-Coordinate (Pressure Altitude) In Global CS (m)| "
172 <<
"Airplane Z-Coordinate (Pressure Altitude) In Global CS (m)| "
174 <<
"Airplane X-Coordinate (Manually Corrected Pressure Altitude) In Global CS (m)| "
175 <<
"Airplane Y-Coordinate (Manually Corrected Pressure Altitude) In Global CS (m)| "
176 <<
"Airplane Z-Coordinate (Manually Corrected Pressure Altitude) In Global CS (m)| "
178 <<
"Airplane X-Coordinate (GDAS Corrected Pressure Altitude) In Global CS (m)| "
179 <<
"Airplane Y-Coordinate (GDAS Corrected Pressure Altitude) In Global CS (m)| "
180 <<
"Airplane Z-Coordinate (GDAS Corrected Pressure Altitude) In Global CS (m)| "
182 <<
"Airplane X-Coordinate (GPS Altitude) In Global CS (m)| "
183 <<
"Airplane Y-Coordinate (GPS Altitude) In Global CS (m)| "
184 <<
"Airplane Z-Coordinate (GPS Altitude) In Global CS (m)| "
186 <<
"Airplane X-Speed In Global CS (m/s)| "
187 <<
"Airplane Y-Speed in Global CS (m/s)| "
188 <<
"Airplane Z-Speed in Global CS (m/s)| "
190 <<
"Reconstructed X-Coordinate In Global CS (m)| "
191 <<
"Reconstructed Y-Coordinate In Global CS (m)| "
192 <<
"Reconstructed Z-Coordinate In Global CS (m)| "
194 <<
"Airplane Latitude (Pressure Altitude) (UTM) (degree)| "
195 <<
"Airplane Longitude (Pressure Altitude) (UTM) (degree)| "
196 <<
"Airplane Altitude (Pressure Altitude) (UTM) (m)| "
198 <<
"Airplane Latitude (Manually Corrected Pressure Altitude) (UTM) (degree)| "
199 <<
"Airplane Longitude (Manually Corrected Pressure Altitude) (UTM) (degree)| "
200 <<
"Airplane Altitude (Manually Corrected Pressure Altitude) (UTM) (m)| "
202 <<
"Airplane Latitude (GDAS Corrected Pressure Altitude) (UTM) (degree)| "
203 <<
"Airplane Longitude (GDAS Corrected Pressure Altitude) (UTM) (degree)| "
204 <<
"Airplane Altitude (GDAS Corrected Pressure Altitude) (UTM) (m)| "
206 <<
"Airplane Latitude (GPS Altitude) (UTM) (degree)| "
207 <<
"Airplane Longitude (GPS Altitude) (UTM) (degree)| "
208 <<
"Airplane Altitude (GPS Altitude) (UTM) (m)| "
210 <<
"Reconstructed Latitude (UTM) (degree)| "
211 <<
"Reconstructed Longitude (UTM) (degree)| "
212 <<
"Reconstructed Altitude (UTM) (m)| "
214 <<
"Core Latitude (UTM) (degree)| "
215 <<
"Core Longitude (UTM) (degree)| "
216 <<
"Core Altitude (UTM) (m)| "
218 <<
"Core-System-Origin-X-Coordinate In Global CS (m)| "
219 <<
"Core-System-Origin-Y-Coordinate In Global CS (m)| "
220 <<
"Core-System-Origin-Z-Coordinate In Global CS (m)| "
222 <<
"Core-System eX_x In Global CS (m)| Core-System eX_y In Global CS (m)| Core-System eX_z In Global CS (m)| "
223 <<
"Core-System eY_x In Global CS (m)| Core-System eY_y In Global CS (m)| Core-System eY_z In Global CS (m)| "
224 <<
"Core-System eZ_x In Global CS (m)| Core-System eZ_y In Global CS (m)| Core-System eZ_z In Global CS (m)| "
226 <<
"Airplane-System-Origin-X-Coordinate In Global CS (m)| "
227 <<
"Airplane-System-Origin-Y-Coordinate In Global CS (m)| "
228 <<
"Airplane-System-Origin-Z-Coordinate In Global CS (m)| "
230 <<
"Airplane-System eX_x In Global CS (m)| Airplane-System eX_y In Global CS (m)| Airplane-System eX_z In Global CS (m)| "
231 <<
"Airplane-System eY_x In Global CS (m)| Airplane-System eY_y In Global CS (m)| Airplane-System eY_z In Global CS (m)| "
232 <<
"Airplane-System eZ_x In Global CS (m)| Airplane-System eZ_y In Global CS (m)| Airplane-System eZ_z In Global CS (m)| "
235 generalInfoFileHandle << setprecision(numeric_limits<long double>::digits10 + 1)
239 << pFlight.
getId() <<
" ";
254 generalInfoFileHandle << endl;
256 generalInfoFileHandle.close();
259 generalInfoFileHandle.close();
265 return pulseInfoWriter;
const StationInfo * registerStationInfo(const rdet::Station &pStation)
unsigned int getId() const
Detector description interface for Station-related data.
evt::Header & GetHeader()
void writeCoordinateSystemToStream(utl::CoordinateSystemPtr pCoordinateSystem, utl::CoordinateSystemPtr pGlobalCoordinateSystem, std::ofstream *pStream)
utl::Point * getPosition(const utl::TimeStamp &pTime, Ads_bEvent::AltitudeType pAltitudeType) const
const Airplane & getAirplane() const
std::string _createOutputFolder() const
A TimeStamp holds GPS second and nanosecond for some event.
utl::Vector * getSpeed(const utl::TimeStamp &pTime, Ads_bEvent::AltitudeType pAltitudeType) const
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
const std::string & getId() const
std::list< PulseInfoWriter * > _pulseInfoWriters_
bool writeStationInfosToFile()
int GetId() const
Station ID.
utl::CoordinateSystemPtr _globalCoordinateSystem_
boost::filesystem::path _createOutputFolderForEvent(const std::string &pEventId) const
void writeVectorToStream_cartesian(const utl::Vector *pVector, utl::CoordinateSystemPtr pCoordinateSystem, std::ofstream *pStream)
PulseInfoWriter * registerEvent(evt::Event &pEvent, const Flight &pFlight, const utl::Point &pReconstructedRadioEventOrigin, utl::CoordinateSystemPtr pCoreCoordinateSystem)
double ApproximatedUnixTimeStampFromTimestamp(const utl::TimeStamp &pTimeStamp)
const utl::CoordinateSystemPtr & getCoordinateSystem() const
void writeCoordinatesToStream_geodetic(const utl::Point *pPoint, std::ofstream *pStream)
const std::string & getId() const
void writeCoordinatesToStream_cartesian(const utl::Point *pPoint, utl::CoordinateSystemPtr pCoordinateSystem, std::ofstream *pStream)
#define ERROR(message)
Macro for logging error messages.
static const char * generalInfoFileName
static const char * stationInfosFileName
boost::filesystem::path _outputDirectory_