source: ntrip/trunk/BNC/bncrinex.cpp@ 79

Last change on this file since 79 was 79, checked in by mervart, 18 years ago

* empty log message *

File size: 5.4 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * Bernese NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: bncRinex
7 *
8 * Purpose: writes RINEX files
9 *
10 * Author: L. Mervart
11 *
12 * Created: 27-Aug-2006
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iomanip>
19
20#include "bncrinex.h"
21
22#include "RTCM3/rtcm3torinex.h"
23
24using namespace std;
25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
28bncRinex::bncRinex(const char* StatID) {
29 _statID = StatID;
30 _headerWritten = false;
31}
32
33// Destructor
34////////////////////////////////////////////////////////////////////////////
35bncRinex::~bncRinex() {
36 _out.close();
37}
38
39// Write RINEX Header
40////////////////////////////////////////////////////////////////////////////
41void bncRinex::writeHeader(struct converttimeinfo& cti, double second) {
42
43 // Open the Output File
44 // --------------------
45 QByteArray fname = _statID + ".RXO";
46 _out.open(fname.data());
47
48 // Write mandatory Records
49 // -----------------------
50 _out.setf(ios::fixed);
51 _out.setf(ios::left);
52
53 double approxPos[3]; approxPos[0] = approxPos[1] = approxPos[2] = 0.0;
54 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
55
56 _out << " 2.10 OBSERVATION DATA G (GPS) RINEX VERSION / TYPE" << endl;
57 _out << "BNC LM 27-Aug-2006 PGM / RUN BY / DATE" << endl;
58 _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
59 _out << setw(60) << "BKG" << "OBSERVER / AGENCY" << endl;
60 _out << setw(20) << "unknown"
61 << setw(20) << "unknown"
62 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl;
63 _out << setw(20) << "unknown"
64 << setw(20) << "unknown"
65 << setw(20) << " " << "ANT # / TYPE" << endl;
66 _out.unsetf(ios::left);
67 _out << setw(14) << setprecision(4) << approxPos[0]
68 << setw(14) << setprecision(4) << approxPos[1]
69 << setw(14) << setprecision(4) << approxPos[2]
70 << " " << "APPROX POSITION XYZ" << endl;
71 _out << setw(14) << setprecision(4) << antennaNEU[0]
72 << setw(14) << setprecision(4) << antennaNEU[1]
73 << setw(14) << setprecision(4) << antennaNEU[2]
74 << " " << "ANTENNA: DELTA H/E/N" << endl;
75 _out << " 1 1 WAVELENGTH FACT L1/2" << endl;
76 _out << " 4 P1 P2 L1 L2 # / TYPES OF OBSERV" << endl;
77 _out << setw(6) << cti.year
78 << setw(6) << cti.month
79 << setw(6) << cti.day
80 << setw(6) << cti.hour
81 << setw(6) << cti.minute
82 << setw(13) << setprecision(7) << second
83 << " " << "TIME OF FIRST OBS" << endl;
84 _out << " END OF HEADER" << endl;
85
86 _headerWritten = true;
87}
88
89// Stores Observation into Internal Array
90////////////////////////////////////////////////////////////////////////////
91void bncRinex::deepCopy(const Observation* obs) {
92 Observation* newObs = new Observation();
93 memcpy(newObs, obs, sizeof(*obs));
94 _obs.push_back(newObs);
95}
96
97// Write One Epoch into the RINEX File
98////////////////////////////////////////////////////////////////////////////
99void bncRinex::dumpEpoch() {
100
101 // Easy Return
102 // -----------
103 if (_obs.isEmpty()) {
104 return;
105 }
106
107 // Time of Epoch
108 // -------------
109 struct converttimeinfo cti;
110 Observation* firstObs = *_obs.begin();
111 converttime(&cti, firstObs->GPSWeek, firstObs->GPSWeeks);
112
113 // Write RINEX Header
114 // ------------------
115 if (!_headerWritten) {
116 writeHeader(cti, cti.second + fmod(firstObs->sec, 1.0));
117 }
118
119 _out.setf(std::ios::fixed);
120
121 _out << setw(3) << cti.year%100
122 << setw(3) << cti.month
123 << setw(3) << cti.day
124 << setw(3) << cti.hour
125 << setw(3) << cti.minute
126 << setw(11) << setprecision(7)
127 << cti.second + fmod(firstObs->sec, 1.0)
128 << " " << 0 << setw(3) << _obs.size();
129
130 QListIterator<Observation*> it(_obs); int iSat = 0;
131 while (it.hasNext()) {
132 iSat++;
133 Observation* ob = it.next();
134 _out << " " << setw(2) << int(ob->SVPRN);
135 if (iSat == 12 && it.hasNext()) {
136 _out << endl << " ";
137 iSat = 0;
138 }
139 }
140 _out << endl;
141
142 static const double const_c = 299792458.0;
143 static const double const_freq1 = 1575420000.0;
144 static const double const_freq2 = 1227600000.0;
145 static const double const_lambda1 = const_c / const_freq1;
146 static const double const_lambda2 = const_c / const_freq2;
147
148 it.toFront();
149 while (it.hasNext()) {
150 Observation* ob = it.next();
151
152 char lli = ' ';
153 char snr = ' ';
154 _out << setw(14) << setprecision(3) << ob->C1 << lli << snr;
155 _out << setw(14) << setprecision(3) << ob->P2 << lli << snr;
156 _out << setw(14) << setprecision(3) << ob->L1 / const_lambda1 << lli << snr;
157 _out << setw(14) << setprecision(3) << ob->L2 / const_lambda2 << lli << snr;
158 _out << endl;
159
160 delete ob;
161 }
162
163 _out.flush();
164 _obs.clear();
165}
166
Note: See TracBrowser for help on using the repository browser.