Changeset 11027 in ntrip for trunk/BNC/src/pppCrdFile.cpp
- Timestamp:
- Sep 11, 2026, 3:40:50 PM (42 hours ago)
- File:
-
- 1 edited
-
trunk/BNC/src/pppCrdFile.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/pppCrdFile.cpp
r11022 r11027 40 40 * -----------------------------------------------------------------------*/ 41 41 42 #include <cmath> 42 43 #include <cstdlib> 43 44 #include <fstream> … … 48 49 using namespace std; 49 50 using namespace BNC_PPP; 51 52 // Convert a 'D,M,S' (degrees, minutes, seconds) token into decimal degrees; 53 // the sign of D carries the hemisphere (negative == South/West). 54 ////////////////////////////////////////////////////////////////////////////// 55 static double dmsToDeg(const string& dms) { 56 string str = dms; 57 for (string::iterator it = str.begin(); it != str.end(); ++it) { 58 if (*it == ',') *it = ' '; 59 } 60 istringstream in(str); 61 double d = 0.0, m = 0.0, s = 0.0; 62 in >> d >> m >> s; 63 double sign = (d < 0.0) ? -1.0 : 1.0; 64 return sign * (fabs(d) + m / 60.0 + s / 3600.0); 65 } 50 66 51 67 // … … 81 97 } 82 98 83 in >> staInfo._xyz(1) >> staInfo._xyz(2) >> staInfo._xyz(3); 99 // The a priori coordinate is given either as plain Cartesian 'X Y Z', or, 100 // if the line's first coordinate token is 'LAT:<D,M,S>', as geodetic 101 // 'LAT:<D,M,S> LON:<D,M,S> H:<height>' (converted to XYZ below). 102 streampos posBeforeCoord = in.tellg(); 103 string firstCoordTok; 104 bool geodetic = false; 105 if (in >> firstCoordTok) { 106 geodetic = (firstCoordTok.compare(0, 4, "LAT:") == 0); 107 in.seekg(posBeforeCoord); 108 } 109 if (!geodetic) { 110 in >> staInfo._xyz(1) >> staInfo._xyz(2) >> staInfo._xyz(3); 111 } 84 112 85 // Optional 'EPOCH:<decimalYear>' and 'VEL:<vx>,<vy>,<vz>' keyword tokens 86 // (ITRF reference epoch and velocity in m/year of the coordinate above), 87 // may appear in any order before the antenna eccentricity / name fields. 113 // Optional keyword tokens, may appear in any order before the antenna 114 // eccentricity / name fields: 115 // - 'LAT:<D,M,S>', 'LON:<D,M,S>', 'H:<height>' (geodetic a priori coordinate) 116 // - 'EPOCH:<decimalYear>' (ITRF reference epoch of the coordinate) 117 // - 'VEL:<vx>,<vy>,<vz>' (ITRF velocity [m/year] of the coordinate) 118 double lat = 0.0, lon = 0.0, hgt = 0.0; 119 bool haveLat = false, haveLon = false, haveHgt = false; 88 120 while (!in.eof()) { 89 121 streampos posBeforeToken = in.tellg(); … … 92 124 break; 93 125 } 94 if (token.compare(0, 6, "EPOCH:") == 0) { 126 if (token.compare(0, 4, "LAT:") == 0) { 127 lat = dmsToDeg(token.substr(4)); 128 haveLat = true; 129 } 130 else if (token.compare(0, 4, "LON:") == 0) { 131 lon = dmsToDeg(token.substr(4)); 132 haveLon = true; 133 } 134 else if (token.compare(0, 2, "H:") == 0) { 135 hgt = atof(token.substr(2).c_str()); 136 haveHgt = true; 137 } 138 else if (token.compare(0, 6, "EPOCH:") == 0) { 95 139 staInfo._epoch = atof(token.substr(6).c_str()); 96 140 } … … 107 151 break; 108 152 } 153 } 154 155 if (geodetic && haveLat && haveLon && haveHgt) { 156 double Ell[3] = { lat * M_PI / 180.0, lon * M_PI / 180.0, hgt }; 157 double XYZ[3]; 158 ell2xyz(Ell, XYZ); 159 staInfo._xyz(1) = XYZ[0]; 160 staInfo._xyz(2) = XYZ[1]; 161 staInfo._xyz(3) = XYZ[2]; 109 162 } 110 163
Note:
See TracChangeset
for help on using the changeset viewer.
