83 rv += quote + bitsAsString((
validBits)b) + quote;
100 unsigned long allValid;
101 if (
version == 2.0 ) allValid = allValid20;
102 else if (
version == 2.1 ) allValid = allValid21;
103 else if (
version == 2.11) allValid = allValid211;
104 else if (
version >= 3.0 ) allValid = allValid211;
108 err.addText(
"Make sure to set the version correctly.");
112 if ((
valid & allValid) != allValid)
114 string errstr(
"Incomplete or invalid header: missing: ");
115 errstr += bitString(allValid & ~
valid);
116 FFStreamError
err(errstr);
117 err.addText(
"Make sure you set all header valid bits for all of the available data.");
123 if (
valid & validVersion)
126 line += string(11,
' ');
128 line += stringVersion;
129 strm << line << endl;
132 if (
valid & validRunBy)
140 curDate = (
static_cast<CivilTime>(sysTime)).
printf(
"%02m/%02d/%04Y %02H:%02M:%02S");
144 curDate = (
static_cast<CivilTime>(sysTime)).printf(
"%04Y%02m%02d %02H%02M%02S %P");
148 strm << line << endl;
151 if (
valid & validComment)
153 vector<string>::const_iterator itr = commentList.begin();
154 while (itr != commentList.end())
157 line += stringComment;
158 strm << line << endl;
163 if (
valid & validMarkerName)
166 line += stringMarkerName;
167 strm << line << endl;
170 if (
valid & validMarkerNumber)
173 line += stringMarkerNumber;
174 strm << line << endl;
177 if (
valid & validObsType)
180 vector<RinexMetType>::const_iterator itr = obsTypeList.begin();
181 size_t numWritten = 0;
182 while (itr != obsTypeList.end())
186 if ((numWritten % (maxObsPerLine+1)) == 0)
188 line += stringObsType;
189 strm << line << endl;
191 line = string(6,
' ');
197 line += string(60 - line.size(),
' ');
198 line += stringObsType;
199 strm << line << endl;
202 if (
valid & validSensorType)
205 vector<sensorType>::const_iterator itr = sensorTypeList.begin();
206 while (itr != sensorTypeList.end())
208 if (std::find(obsTypeList.begin(), obsTypeList.end(),
209 (*itr).obsType) != obsTypeList.end())
213 line += string(6,
' ');
215 line += string(4,
' ');
216 line += convertObsType((*itr).obsType);
217 line += string(1,
' ');
218 line += stringSensorType;
219 strm << line << endl;
225 if (
valid & validSensorPos)
228 vector<sensorPosType>::const_iterator itr = sensorPosList.begin();
229 while (itr != sensorPosList.end())
231 if (std::find(obsTypeList.begin(), obsTypeList.end(),
232 (*itr).obsType) != obsTypeList.end())
238 line += string(1,
' ');
239 line += convertObsType((*itr).obsType);
240 line += string(1,
' ');
241 line += stringSensorPos;
242 strm << line << endl;
250 line = string(60,
' ');
252 strm << line << endl;
270 sensorTypeList.clear();
271 sensorPosList.clear();
280 if (line.length()<60 || line.length()>81)
282 FFStreamError e(
"Bad line length");
286 string thisLabel =
strip(line.substr(60,20));
288 if (thisLabel == stringVersion)
290 std::string verstr(
strip(line.substr(0,20)));
291 if ((verstr !=
"2.0") && (verstr !=
"2.1") && (verstr !=
"2.00") &&
292 (verstr !=
"2.10") && (verstr !=
"2.11") && (verstr !=
"3.0") &&
293 (verstr !=
"3.01") && (verstr!=
"3.02"))
295 FFStreamError e(
"Unknown or unsupported RINEX version " +
303 FFStreamError e(
"This isn't a Rinex Met file");
306 valid |= validVersion;
308 else if (thisLabel == stringRunBy)
315 else if (thisLabel == stringComment)
317 commentList.push_back(
strip(line.substr(0,60)));
318 valid |= validComment;
320 else if (thisLabel == stringMarkerName)
323 valid |= validMarkerName;
325 else if (thisLabel == stringMarkerNumber)
328 valid |= validMarkerNumber;
330 else if (thisLabel == stringObsType)
333 if (!(
valid & validObsType))
336 for (
int i = 0; (i < numObs) && (i < maxObsPerLine); i++)
338 int currPos = i * 6 + 6;
339 if (line.substr(currPos, 4) != string(4,
' '))
341 FFStreamError e(
"Format error for line type " + stringObsType);
344 obsTypeList.push_back(convertObsType(line.substr(currPos + 4, 2)));
346 valid |= validObsType;
351 int currentObsTypes = obsTypeList.size();
352 for (
int i = currentObsTypes;
353 (i < numObs) && (i < (maxObsPerLine + currentObsTypes));
356 int currPos = (i % maxObsPerLine) * 6 + 6;
357 if (line.substr(currPos, 4) != string(4,
' '))
359 FFStreamError e(
"Format error for line type " + stringObsType);
362 obsTypeList.push_back(convertObsType(line.substr(currPos + 4, 2)));
366 else if (thisLabel == stringSensorType)
368 if (line.substr(40,6) !=
string(6,
' '))
370 FFStreamError e(
"Format error for line type " + stringSensorType);
377 st.
obsType = convertObsType(line.substr(57,2));
379 sensorTypeList.push_back(st);
383 if (sensorTypeList.size() == obsTypeList.size())
385 valid |= validSensorType;
389 valid &= ~(long)validSensorType;
392 else if (thisLabel == stringSensorPos)
397 sp.position[1] =
asDouble(line.substr(14,14));
398 sp.position[2] =
asDouble(line.substr(28,14));
401 sp.obsType = convertObsType(line.substr(57,2));
403 sensorPosList.push_back(
sp);
406 if (
sp.obsType == PR)
408 valid |= validSensorPos;
411 else if (thisLabel == stringEoH)
417 FFStreamError e(
"Unknown header label " + thisLabel);
422 unsigned long allValid;
423 if (
version == 2.0 ) allValid = allValid20;
424 else if (
version == 2.1 ) allValid = allValid21;
425 else if (
version == 2.11) allValid = allValid21;
426 else if (
version >= 3.0 ) allValid = allValid21;
429 FFStreamError e(
"Unknown or unsupported RINEX version " +
434 if ( (allValid &
valid) != allValid)
436 string errstr(
"Incomplete or invalid header: missing: ");
437 errstr += bitString(allValid & ~
valid);
438 FFStreamError
err(errstr);
450 if (!obsTypeList.empty())
452 s <<
"Obs types:" << endl;
453 vector<RinexMetType>::const_iterator itr = obsTypeList.begin();
454 while (itr != obsTypeList.end())
456 s << convertObsType(*itr) <<
" ";
466 if (oneObs ==
"PR")
return PR;
467 else if (oneObs ==
"TD")
return TD;
468 else if (oneObs ==
"HR")
return HR;
469 else if (oneObs ==
"ZW")
return ZW;
470 else if (oneObs ==
"ZD")
return ZD;
471 else if (oneObs ==
"ZT")
return ZT;
472 else if (oneObs ==
"WD")
return WD;
473 else if (oneObs ==
"WS")
return WS;
474 else if (oneObs ==
"RI")
return RI;
475 else if (oneObs ==
"HI")
return HI;
478 FFStreamError e(
"Bad obs type:" + oneObs);
485 if (oneObs == PR)
return "PR";
486 else if (oneObs == TD)
return "TD";
487 else if (oneObs == HR)
return "HR";
488 else if (oneObs ==
ZW)
return "ZW";
489 else if (oneObs == ZD)
return "ZD";
490 else if (oneObs ==
ZT)
return "ZT";
491 else if (oneObs == WD)
return "WD";
492 else if (oneObs == WS)
return "WS";
493 else if (oneObs == RI)
return "RI";
494 else if (oneObs == HI)
return "HI";
497 FFStreamError e(
"Bad obs type:" +
asString(oneObs));
504 std::vector<std::string>& diffs,
505 const std::vector<std::string>& inclExclList,
509 std::map<std::string,bool> lineMap;
510 std::map<std::string,bool>::const_iterator lmi;
513 std::set<std::string>
514 lcomments(commentList.begin(), commentList.end()),
516 std::set<RinexMetType>
517 lobs(obsTypeList.begin(), obsTypeList.end()),
520 ltype(sensorTypeList.begin(), sensorTypeList.end()),
522 std::set<sensorPosType>
523 lpos(sensorPosList.begin(), sensorPosList.end()),
530 lineMap[stringVersion] =
533 lineMap[stringRunBy] =
537 lineMap[stringComment] = (lcomments == rcomments);
540 lineMap[stringObsType] = (lobs == robs);
541 lineMap[stringSensorType] = (ltype == rtype);
542 lineMap[stringSensorPos] = (lpos == rpos);
546 std::map<std::string,bool> oldLineMap(lineMap);
547 std::map<std::string,bool>::const_iterator olmi;
549 for (
unsigned i = 0; i < inclExclList.size(); i++)
551 if ((olmi = oldLineMap.find(inclExclList[i])) != oldLineMap.end())
553 lineMap[olmi->first] = olmi->second;
560 for (
unsigned i = 0; i < inclExclList.size(); i++)
562 lineMap.erase(inclExclList[i]);
567 for (lmi = lineMap.begin(); lmi != lineMap.end(); lmi++)
571 diffs.push_back(lmi->first);
582 return ((obsType == r.
obsType) &&
583 (model == r.
model) &&
585 (fabs(accuracy - r.
accuracy) < 0.001));
592 if (obsType < r.
obsType)
return true;
593 if (obsType > r.
obsType)
return false;
594 if (model < r.
model)
return true;
595 if (model > r.
model)
return false;
596 if (type < r.
type)
return true;
597 if (type > r.
type)
return false;
598 if (accuracy < r.
accuracy)
return true;
607 return ((obsType == r.
obsType) &&
609 (fabs(height - r.
height) < 0.001));
617 if (obsType < r.
obsType)
return true;
618 if (obsType > r.
obsType)
return false;
619 if (position[0] < r.
position[0])
return true;
620 if (position[0] > r.
position[0])
return false;
621 if (position[1] < r.
position[1])
return true;
622 if (position[1] > r.
position[1])
return false;
623 if (position[2] < r.
position[2])
return true;
624 if (position[2] > r.
position[2])
return false;
625 if (height < r.
height)
return true;