source: ntrip/trunk/BNC/src/t_prn.cpp@ 10033

Last change on this file since 10033 was 8168, checked in by stuerze, 7 years ago

IRNSS support is added in RINEX QC

File size: 2.6 KB
RevLine 
[5741]1#include <sstream>
2#include <iomanip>
3#include <stdlib.h>
4
5#include "t_prn.h"
6
7using namespace std;
8
[8148]9//
[5741]10//////////////////////////////////////////////////////////////////////////////
11int t_prn::toInt() const {
12 if (_system == 'G') {
13 return _number;
14 }
15 else if (_system == 'R') {
16 return MAXPRN_GPS + _number;
17 }
[6014]18 else if (_system == 'E') {
19 return MAXPRN_GPS + MAXPRN_GLONASS + _number;
20 }
[6321]21 else if (_system == 'J') {
22 return MAXPRN_GPS + MAXPRN_GLONASS + MAXPRN_GALILEO + _number;
23 }
24 else if (_system == 'S') {
25 return MAXPRN_GPS + MAXPRN_GLONASS + MAXPRN_GALILEO + MAXPRN_QZSS + _number;
26 }
27 else if (_system == 'C') {
[8168]28 return MAXPRN_GPS + MAXPRN_GLONASS + MAXPRN_GALILEO + MAXPRN_QZSS + MAXPRN_SBAS + _number;
[6321]29 }
[8168]30 else if (_system == 'I') {
31 return MAXPRN_GPS + MAXPRN_GLONASS + MAXPRN_GALILEO + MAXPRN_QZSS + MAXPRN_SBAS + MAXPRN_BDS + _number;
32 }
[5741]33 return 0;
34}
35
[8148]36//
[5741]37//////////////////////////////////////////////////////////////////////////////
38string t_prn::toString() const {
39 stringstream ss;
40 ss << _system << setfill('0') << setw(2) << _number;
41 return ss.str();
42}
43
[6809]44//
45//////////////////////////////////////////////////////////////////////////////
46string t_prn::toInternalString() const {
47 stringstream ss;
48 ss << _system << setfill('0') << setw(2) << _number << '_' << _flags;
49 return ss.str();
50}
51
[5741]52// Set from string
53////////////////////////////////////////////////////////////////////////////
[5838]54void t_prn::set(const std::string& str) {
[5741]55 unsigned prn = 0;
56 char system = '\x0';
57 const char* number = 0;
[8168]58 if ( str[0] == 'G' || str[0] == 'R' || str[0] == 'E' ||
59 str[0] == 'J' || str[0] == 'S' || str[0] == 'C' ||
60 str[0] == 'I') {
[5741]61 system = str[0];
62 number = str.c_str() + 1;
63 }
64 else if ( isdigit(str[0]) ) {
65 system = 'G';
66 number = str.c_str();
67 }
68 else {
[5838]69 throw "t_prn::set: wrong satellite ID: " + str;
[5741]70 }
71
72 char* tmpc = 0;
73 prn = strtol(number, &tmpc, 10);
74 if ( tmpc == number || *tmpc != '\x0' ) {
[5838]75 throw "t_prn::set: wrong satellite ID: " + str;
[5741]76 }
77
78 try {
[5838]79 this->set(system, prn);
[5741]80 }
81 catch (string exc) {
[5838]82 throw "t_prn::set: wrong satellite ID: " + str;
[5741]83 }
84}
85
[8148]86//
[5741]87//////////////////////////////////////////////////////////////////////////////
88t_prn::operator unsigned() const {
89 return toInt();
90}
91
[8148]92//
[5741]93//////////////////////////////////////////////////////////////////////////////
[5745]94istream& operator >> (istream& in, t_prn& prn) {
[5741]95 string str;
96 in >> str;
97 if (str.length() == 1 && !isdigit(str[0])) {
98 string str2;
99 in >> str2;
100 str += str2;
101 }
[5838]102 prn.set(str);
[5741]103 return in;
104}
Note: See TracBrowser for help on using the repository browser.