source: ntrip/branches/BNC_2.12/src/t_prn.cpp@ 10434

Last change on this file since 10434 was 8167, checked in by stuerze, 7 years ago

IRNSS support is added in RINEX QC

File size: 2.6 KB
Line 
1#include <sstream>
2#include <iomanip>
3#include <stdlib.h>
4
5#include "t_prn.h"
6
7using namespace std;
8
9//
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 }
18 else if (_system == 'E') {
19 return MAXPRN_GPS + MAXPRN_GLONASS + _number;
20 }
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') {
28 return MAXPRN_GPS + MAXPRN_GLONASS + MAXPRN_GALILEO + MAXPRN_QZSS + MAXPRN_SBAS + _number;
29 }
30 else if (_system == 'I') {
31 return MAXPRN_GPS + MAXPRN_GLONASS + MAXPRN_GALILEO + MAXPRN_QZSS + MAXPRN_SBAS + MAXPRN_BDS + _number;
32 }
33 return 0;
34}
35
36//
37//////////////////////////////////////////////////////////////////////////////
38string t_prn::toString() const {
39 stringstream ss;
40 ss << _system << setfill('0') << setw(2) << _number;
41 return ss.str();
42}
43
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
52// Set from string
53////////////////////////////////////////////////////////////////////////////
54void t_prn::set(const std::string& str) {
55 unsigned prn = 0;
56 char system = '\x0';
57 const char* number = 0;
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') {
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 {
69 throw "t_prn::set: wrong satellite ID: " + str;
70 }
71
72 char* tmpc = 0;
73 prn = strtol(number, &tmpc, 10);
74 if ( tmpc == number || *tmpc != '\x0' ) {
75 throw "t_prn::set: wrong satellite ID: " + str;
76 }
77
78 try {
79 this->set(system, prn);
80 }
81 catch (string exc) {
82 throw "t_prn::set: wrong satellite ID: " + str;
83 }
84}
85
86//
87//////////////////////////////////////////////////////////////////////////////
88t_prn::operator unsigned() const {
89 return toInt();
90}
91
92//
93//////////////////////////////////////////////////////////////////////////////
94istream& operator >> (istream& in, t_prn& prn) {
95 string str;
96 in >> str;
97 if (str.length() == 1 && !isdigit(str[0])) {
98 string str2;
99 in >> str2;
100 str += str2;
101 }
102 prn.set(str);
103 return in;
104}
Note: See TracBrowser for help on using the repository browser.