ObsID.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
41 
42 #include <iomanip>
43 #include <math.h>
44 #include "ObsID.hpp"
45 
46 namespace gnsstk
47 {
48  bool ObsID::verbose = false;
49 
50  // Convenience output method
51  std::ostream& ObsID::dump(std::ostream& s) const
52  {
53  s << ObsID::cbDesc[band] << " "
54  << ObsID::tcDesc[code] << " "
55  << ObsID::otDesc[type];
56  if (ObsID::verbose)
57  {
58  std::ios::fmtflags oldFlags = s.flags();
59  s << " "
60  << std::boolalpha << freqOffs << "/" << freqOffsWild << " "
61  << std::hex << mcode << "/" << mcodeMask
63  s.flags(oldFlags);
64  }
65  return s;
66  } // ObsID::dump()
67 
68 
69 
70  // Equality requires all fields to be the same unless the field is unknown
71  bool ObsID::operator==(const ObsID& right) const
72  {
73  // std::cerr << __PRETTY_FUNCTION__ << std::endl;
74  // combined mask, which basically means that a 0 in either
75  // mask is a wildcard.
76  uint32_t cmask = mcodeMask & right.mcodeMask;
77  return ((type == ObservationType::Any ||
78  right.type == ObservationType::Any || type == right.type) &&
79  (band == CarrierBand::Any || right.band == CarrierBand::Any ||
80  band == right.band) &&
81  (code == TrackingCode::Any || right.code == TrackingCode::Any ||
82  code == right.code) &&
83  (xmitAnt == XmitAnt::Any || right.xmitAnt == XmitAnt::Any ||
84  xmitAnt == right.xmitAnt) &&
85  (freqOffsWild == true || right.freqOffsWild == true ||
86  freqOffs == right.freqOffs) &&
87  ((mcode & cmask) == (right.mcode & cmask)));
88  }
89 
90 
91 // Use this macro in operator<< to figure out why things fail
92 #if 0
93 #define ORDERRET(RV) { \
94  std::cerr << "operator<() returning " << RV << " @ " << __LINE__ \
95  << std::endl; \
96  return RV; \
97  }
98 #else
99 #define ORDERRET(RV) return RV;
100 #endif
101 
102  // This ordering is somewhat arbitrary but is required to be able
103  // to use an ObsID as an index to a std::map. If an application needs
104  // some other ordering, inherit and override this function.
105  bool ObsID::operator<(const ObsID& right) const
106  {
107  //std::cerr << __PRETTY_FUNCTION__ << std::endl;
108  if ((band != CarrierBand::Any) && (right.band != CarrierBand::Any))
109  {
110  if (band < right.band) ORDERRET(true);
111  if (right.band < band) ORDERRET(false);
112  }
113  if ((code != TrackingCode::Any) && (right.code != TrackingCode::Any))
114  {
115  if (code < right.code) ORDERRET(true);
116  if (right.code < code) ORDERRET(false);
117  }
118  if ((type != ObservationType::Any) &&
119  (right.type != ObservationType::Any))
120  {
121  if (type < right.type) ORDERRET(true);
122  if (right.type < type) ORDERRET(false);
123  }
124  if ((xmitAnt != XmitAnt::Any) && (right.xmitAnt != XmitAnt::Any))
125  {
126  if (xmitAnt < right.xmitAnt) ORDERRET(true);
127  if (right.xmitAnt < xmitAnt) ORDERRET(false);
128  }
129  if (!freqOffsWild && !right.freqOffsWild)
130  {
131  if (freqOffs < right.freqOffs) ORDERRET(true);
132  if (right.freqOffs < freqOffs) ORDERRET(false);
133  }
134  // combined mask, which basically means that a 0 in either
135  // mask is a wildcard.
136  int64_t cmask = mcodeMask & right.mcodeMask;
137  // std::cerr << "cmask=" << std::hex << cmask << " mcodeMask="
138  // << mcodeMask << " right.mcodeMask=" << right.mcodeMask
139  // << std::endl
140  // << " mcode=" << mcode << " right.mcode=" << right.mcode
141  // << std::dec << std::endl;
142  ORDERRET(((mcode & cmask) < (right.mcode & cmask)));
143  }
144 
145 
146  void ObsID ::
148  {
153  freqOffsWild = true;
154  mcodeMask = 0;
155  }
156 
157 
158  bool ObsID ::
159  isWild() const
160  {
161  return ((type == ObservationType::Any) ||
162  (band == CarrierBand::Any) ||
163  (code == TrackingCode::Any) ||
164  (xmitAnt == XmitAnt::Any) ||
165  (mcodeMask != -1) ||
166  freqOffsWild);
167  }
168 
169 
170  namespace StringUtils
171  {
172  // convert this object to a string representation
173  std::string asString(const ObsID& p)
174  {
175  std::ostringstream oss;
176  p.dump(oss);
177  return oss.str();
178  }
179  }
180 
181 
182  // stream output for ObsID
183  std::ostream& operator<<(std::ostream& s, const ObsID& p)
184  {
185  p.dump(s);
186  return s;
187  }
188 }
gnsstk::ObsID::xmitAnt
XmitAnt xmitAnt
Identify the transmitting antenna.
Definition: ObsID.hpp:202
gnsstk::ObsID::isWild
bool isWild() const
Return true if any of the data are wildcard values.
Definition: ObsID.cpp:159
gnsstk::ObsID::operator<
virtual bool operator<(const ObsID &right) const
Definition: ObsID.cpp:105
gnsstk::CarrierBand::Any
@ Any
Used to match any carrier band.
gnsstk::ObsID::tcDesc
static GNSSTK_EXPORT std::map< TrackingCode, std::string > tcDesc
These strings are for forming a somewhat verbose description.
Definition: ObsID.hpp:216
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::ObsID::band
CarrierBand band
Definition: ObsID.hpp:200
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::ObservationType::Any
@ Any
Used to match any observation type.
gnsstk::ObsID
Definition: ObsID.hpp:82
gnsstk::operator<<
std::ostream & operator<<(std::ostream &s, const ObsEpoch &oe) noexcept
Definition: ObsEpochMap.cpp:54
gnsstk::ObsID::operator==
virtual bool operator==(const ObsID &right) const
Equality requires all fields to be the same.
Definition: ObsID.cpp:71
gnsstk::ObsID::code
TrackingCode code
Definition: ObsID.hpp:201
gnsstk::ObsID::otDesc
static GNSSTK_EXPORT std::map< ObservationType, std::string > otDesc
Definition: ObsID.hpp:218
ObsID.hpp
gnsstk::ObsID::freqOffsWild
bool freqOffsWild
True=Treat freqOffs as a wildcard when matching.
Definition: ObsID.hpp:204
gnsstk::ObsID::mcodeMask
uint32_t mcodeMask
Bitmask for matching mcode.
Definition: ObsID.hpp:227
gnsstk::ObsID::type
ObservationType type
Definition: ObsID.hpp:199
gnsstk::ObsID::freqOffs
int freqOffs
GLONASS frequency offset.
Definition: ObsID.hpp:203
gnsstk::ObsID::mcode
uint32_t mcode
Data to uniquely identify M-code signal.
Definition: ObsID.hpp:226
ORDERRET
#define ORDERRET(RV)
Definition: ObsID.cpp:99
gnsstk::ObsID::dump
virtual std::ostream & dump(std::ostream &s) const
Convenience output method.
Definition: ObsID.cpp:51
gnsstk::ObsID::makeWild
void makeWild()
Set all data to wildcard values.
Definition: ObsID.cpp:147
gnsstk::ObsID::cbDesc
static GNSSTK_EXPORT std::map< CarrierBand, std::string > cbDesc
Definition: ObsID.hpp:217
gnsstk::XmitAnt::Any
@ Any
When making comparisons in ObsID, matches any enumeration.
gnsstk::ObsID::verbose
static GNSSTK_EXPORT bool verbose
Definition: ObsID.hpp:223
gnsstk::TrackingCode::Any
@ Any
Used to match any tracking code.


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:40