Changeset 82 in ntrip for trunk/BNC/bncrinex.cpp
- Timestamp:
- Aug 30, 2006, 5:35:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncrinex.cpp
r79 r82 16 16 * -----------------------------------------------------------------------*/ 17 17 18 #include <QSettings> 19 #include <QDir> 20 #include <QDate> 21 #include <QFile> 22 #include <QTextStream> 18 23 #include <iomanip> 19 24 20 25 #include "bncrinex.h" 21 26 #include "bncutils.h" 22 27 #include "RTCM3/rtcm3torinex.h" 23 28 … … 29 34 _statID = StatID; 30 35 _headerWritten = false; 36 readSkeleton(); 31 37 } 32 38 … … 37 43 } 38 44 45 // Read Skeleton Header File 46 //////////////////////////////////////////////////////////////////////////// 47 void bncRinex::readSkeleton() { 48 49 // Resolve Skeleton File Name 50 // -------------------------- 51 QSettings settings; 52 QString sklName = settings.value("rnxPath").toString(); 53 expandEnvVar(sklName); 54 if ( sklName[sklName.length()-1] != QDir::separator() ) { 55 sklName += QDir::separator(); 56 } 57 sklName += _statID.left(4) + "." + settings.value("rnxSkel").toString(); 58 59 // Read the File 60 // ------------- 61 QFile skl(sklName); 62 if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) { 63 QTextStream in(&skl); 64 while ( !in.atEnd() ) { 65 _headerLines.append( in.readLine() ); 66 if (_headerLines.last().indexOf("END OF HEADER") != -1) { 67 break; 68 } 69 } 70 } 71 } 72 73 // File Name according to RINEX Standards 74 //////////////////////////////////////////////////////////////////////////// 75 void bncRinex::resolveFileName(struct converttimeinfo& cti) { 76 77 QSettings settings; 78 QString path = settings.value("rnxPath").toString(); 79 expandEnvVar(path); 80 81 if ( path[path.length()-1] != QDir::separator() ) { 82 path += QDir::separator(); 83 } 84 85 QDate date(cti.year, cti.month, cti.day); 86 87 QChar ch = '0'; 88 89 path += _statID.left(4) + 90 QString("%1%2.%3O").arg(date.dayOfYear(), 3, 10, QChar('0')) 91 .arg(ch) 92 .arg(date.year() % 100, 2, 10, QChar('0')); 93 94 _fName = path.toAscii(); 95 } 96 39 97 // Write RINEX Header 40 98 //////////////////////////////////////////////////////////////////////////// … … 43 101 // Open the Output File 44 102 // -------------------- 45 QByteArray fname = _statID + ".RXO"; 46 _out.open(fname.data()); 47 48 // Write mandatory Records 49 // ----------------------- 103 resolveFileName(cti); 104 _out.open(_fName.data()); 50 105 _out.setf(ios::fixed); 51 106 _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; 107 108 109 // Copy Skeleton Header 110 // -------------------- 111 if (_headerLines.size() > 0) { 112 QStringListIterator it(_headerLines); 113 while (it.hasNext()) { 114 QString line = it.next(); 115 if (line.indexOf("# / TYPES OF OBSERV") != -1) { 116 _out << " 4 P1 P2 L1 L2" 117 " # / TYPES OF OBSERV" << endl; 118 } 119 else if (line.indexOf("TIME OF FIRST OBS") != -1) { 120 _out << setw(6) << cti.year 121 << setw(6) << cti.month 122 << setw(6) << cti.day 123 << setw(6) << cti.hour 124 << setw(6) << cti.minute 125 << setw(13) << setprecision(7) << second 126 << " TIME OF FIRST OBS" << endl; 127 } 128 else { 129 _out << line.toAscii().data() << endl; 130 } 131 } 132 } 133 134 // Write Dummy Header 135 // ------------------ 136 else { 137 double approxPos[3]; approxPos[0] = approxPos[1] = approxPos[2] = 0.0; 138 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0; 139 140 _out << " 2.10 OBSERVATION DATA G (GPS) RINEX VERSION / TYPE" << endl; 141 _out << "BNC LM 27-Aug-2006 PGM / RUN BY / DATE" << endl; 142 _out << setw(60) << _statID.data() << "MARKER NAME" << endl; 143 _out << setw(60) << "BKG" << "OBSERVER / AGENCY" << endl; 144 _out << setw(20) << "unknown" 145 << setw(20) << "unknown" 146 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl; 147 _out << setw(20) << "unknown" 148 << setw(20) << "unknown" 149 << setw(20) << " " << "ANT # / TYPE" << endl; 150 _out.unsetf(ios::left); 151 _out << setw(14) << setprecision(4) << approxPos[0] 152 << setw(14) << setprecision(4) << approxPos[1] 153 << setw(14) << setprecision(4) << approxPos[2] 154 << " " << "APPROX POSITION XYZ" << endl; 155 _out << setw(14) << setprecision(4) << antennaNEU[0] 156 << setw(14) << setprecision(4) << antennaNEU[1] 157 << setw(14) << setprecision(4) << antennaNEU[2] 158 << " " << "ANTENNA: DELTA H/E/N" << endl; 159 _out << " 1 1 WAVELENGTH FACT L1/2" << endl; 160 _out << " 4 P1 P2 L1 L2 # / TYPES OF OBSERV" << endl; 161 _out << setw(6) << cti.year 162 << setw(6) << cti.month 163 << setw(6) << cti.day 164 << setw(6) << cti.hour 165 << setw(6) << cti.minute 166 << setw(13) << setprecision(7) << second 167 << " " << "TIME OF FIRST OBS" << endl; 168 _out << " END OF HEADER" << endl; 169 } 85 170 86 171 _headerWritten = true;
Note:
See TracChangeset
for help on using the changeset viewer.