source: ntrip/trunk/BNC/src/bncsp3.cpp@ 4386

Last change on this file since 4386 was 4382, checked in by mervart, 12 years ago
File size: 4.5 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Server
4 * -------------------------------------------------------------------------
5 *
6 * Class: bncSP3
7 *
8 * Purpose: writes SP3 files
9 *
10 * Author: L. Mervart
11 *
12 * Created: 25-Apr-2008
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iomanip>
19#include <math.h>
20
21#include "bncsp3.h"
22#include "bncutils.h"
23
24using namespace std;
25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
28bncSP3::bncSP3(const QString& sklFileName, const QString& intr, int sampl)
29 : bncoutf(sklFileName, intr, sampl) {
30}
31
32// Destructor
33////////////////////////////////////////////////////////////////////////////
34bncSP3::~bncSP3() {
35}
36
37// Write One Epoch
38////////////////////////////////////////////////////////////////////////////
39t_irc bncSP3::write(int GPSweek, double GPSweeks, const QString& prn,
40 const ColumnVector& xx) {
41
42 if (reopen(GPSweek, GPSweeks) == success) {
43
44 bncTime epoTime(GPSweek, GPSweeks);
45
46 if (epoTime != _lastEpoTime) {
47
48 // Check the sampling interval (print empty epochs)
49 // ------------------------------------------------
50 if (_lastEpoTime.valid() && _sampl > 0) {
51 for (bncTime ep = _lastEpoTime +_sampl; ep < epoTime; ep = ep +_sampl) {
52 _out << "* " << ep.datestr(' ') << ' ' << ep.timestr(8, ' ') << endl;
53 }
54 }
55
56 // Print the new epoch
57 // -------------------
58 _out << "* " << epoTime.datestr(' ') << ' ' << epoTime.timestr(8, ' ') << endl;
59
60 _lastEpoTime = epoTime;
61 }
62
63 _out << "P" << prn.toAscii().data()
64 << setw(14) << setprecision(6) << xx(1) / 1000.0
65 << setw(14) << setprecision(6) << xx(2) / 1000.0
66 << setw(14) << setprecision(6) << xx(3) / 1000.0
67 << setw(14) << setprecision(6) << xx(4) * 1e6 << endl;
68
69 return success;
70 }
71 else {
72 return failure;
73 }
74}
75
76// Close File (write last line)
77////////////////////////////////////////////////////////////////////////////
78void bncSP3::closeFile() {
79 _out << "EOF" << endl;
80 bncoutf::closeFile();
81}
82
83// Write Header
84////////////////////////////////////////////////////////////////////////////
85void bncSP3::writeHeader(const QDateTime& datTim) {
86
87 int GPSWeek;
88 double GPSWeeks;
89 GPSweekFromDateAndTime(datTim, GPSWeek, GPSWeeks);
90
91 double sec = fmod(GPSWeeks, 60.0);
92
93 int mjd;
94 double dayfrac;
95 mjdFromDateAndTime(datTim, mjd, dayfrac);
96
97 int numEpo = _numSec;
98 if (_sampl > 0) {
99 numEpo /= _sampl;
100 }
101
102 _out << "#aP" << datTim.toString("yyyy MM dd hh mm").toAscii().data()
103 << setw(12) << setprecision(8) << sec
104 << " " << setw(7) << numEpo << " ORBIT IGS08 HLM IGS" << endl;
105
106 _out << "## "
107 << setw(4) << GPSWeek
108 << setw(16) << setprecision(8) << GPSWeeks
109 << setw(15) << setprecision(8) << double(_sampl)
110 << setw(6) << mjd
111 << setw(16) << setprecision(13) << dayfrac << endl;
112
113 _out << "+ 56 G01G02G03G04G05G06G07G08G09G10G11G12G13G14G15G16G17\n"
114 << "+ G18G19G20G21G22G23G24G25G26G27G28G29G30G31G32R01R02\n"
115 << "+ R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19\n"
116 << "+ R20R21R22R23R24 0 0 0 0 0 0 0 0 0 0 0 0\n"
117 << "+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
118 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
119 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
120 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
121 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
122 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
123 << "%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc\n"
124 << "%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc\n"
125 << "%f 0.0000000 0.000000000 0.00000000000 0.000000000000000\n"
126 << "%f 0.0000000 0.000000000 0.00000000000 0.000000000000000\n"
127 << "%i 0 0 0 0 0 0 0 0 0\n"
128 << "%i 0 0 0 0 0 0 0 0 0\n"
129 << "/* \n"
130 << "/* \n"
131 << "/* \n"
132 << "/* \n";
133}
134
Note: See TracBrowser for help on using the repository browser.