1 //==============================================================================
2 //
3 //  This file is part of GPSTk, the GPS Toolkit.
4 //
5 //  The GPSTk 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 GPSTk 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 GPSTk; 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-2020, 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 
39 /**
40  * @file EphemerisRange.hpp
41  * Computation of range and associated quantities from XvtStore
42  */
43 
44 #ifndef NEW_EPHEMERIS_RANGE_HPP
45 #define NEW_EPHEMERIS_RANGE_HPP
46 
47 #include "CommonTime.hpp"
48 #include "SatID.hpp"
49 #include "Position.hpp"
50 #include "XvtStore.hpp"
51 
52 namespace gpstk
53 {
54       /// @ingroup GNSSEph
55       //@{
56 
57       /** Compute the corrected range from receiver at position Rx, to
58        * the GPS satellite given by SatID sat, as well as azimuth,
59        * elevation, etc., given a nominal timetag (either received or
60        * transmitted time) and an XvtStore.
61        */
62    class CorrectedEphemerisRange
63    {
64    public:
65          /// Default constructor.
CorrectedEphemerisRange()66       CorrectedEphemerisRange() {}
67 
68          /// Compute the corrected range at RECEIVE time, from
69          /// receiver at position Rx, to the GPS satellite given by
70          /// SatID sat, as well as all the CER quantities, given the
71          /// nominal receive time tr_nom and an XvtStore.
72       double ComputeAtReceiveTime(
73          const CommonTime& tr_nom,
74          const Position& Rx,
75          const SatID sat,
76          const XvtStore<SatID>& Eph);
77 
78          /// Compute the corrected range at TRANSMIT time, from
79          /// receiver at position Rx, to the GPS satellite given by
80          /// SatID sat, as well as all the CER quantities, given the
81          /// nominal receive time tr_nom, the measured pseudorange,
82          /// and an XvtStore.
83       double ComputeAtTransmitTime(
84          const CommonTime& tr_nom,
85          const double& pr,
86          const Position& Rx,
87          const SatID sat,
88          const XvtStore<SatID>& Eph);
89 
90          /// Compute the corrected range at TRANSMIT time, from
91          /// receiver at position Rx, to the GPS satellite given by
92          /// SatID sat, as well as all the CER quantities, given the
93          /// nominal receive time tr_nom and an XvtStore.
94          /// This doesn't use a pseudorange to initialize the
95          /// time-of-flight computation; however note that this could
96          /// be problematic since the measured pseudorange includes
97          /// the Rx clock bias while this does not; prefer the version
98          /// with measured pseudorange input.
99       double ComputeAtTransmitTime(
100          const CommonTime& tr_nom,
101          const Position& Rx,
102          const SatID sat,
103          const XvtStore<SatID>& Eph);
104 
105          /// Compute the corrected range at TRANSMIT time, from
106          /// receiver at position Rx, to the GPS satellite given by
107          /// SatID sat, as well as all the CER quantities, given the
108          /// nominal transmit time tt_nom and an XvtStore. This is
109          /// used for data smoothed to transmit time.
110       double ComputeAtTransmitSvTime(
111          const CommonTime& tt_nom,
112          const double& pr,
113          const Position& Rx,
114          const SatID sat,
115          const XvtStore<SatID>& Eph);
116 
117          /// The computed raw (geometric) range in meters.
118       double rawrange;
119          /// The satellite clock bias in meters.
120       double svclkbias;
121          /// The satellite clock drift in m/s.
122       double svclkdrift;
123          /// The relativity correction in meters.
124       double relativity;
125          /// The satellite elevation (spheroidal), as seen at the
126          /// receiver, in degrees.
127       double elevation;
128          /// The satellite azimuth (spheroidal), as seen at the
129          /// receiver, in degrees.
130       double azimuth;
131          /// The satellite elevation (geodetic), as seen at the
132          /// receiver, in degrees.
133       double elevationGeodetic;
134          /// The satellite azimuth (geodetic), as seen at the
135          /// receiver, in degrees.
136       double azimuthGeodetic;
137          /// The computed transmit time of the signal.
138       CommonTime transmit;
139          /// The direction cosines of the satellite, as seen at the
140          /// receiver (XYZ).
141       Triple cosines;
142          /// The satellite position (m) and velocity (m/s) in ECEF coordinates.
143       Xvt svPosVel;
144 
145    private:
146          // These are just helper functions to keep from repeating code
147       void updateCER(const Position& Rx);
148       void rotateEarth(const Position& Rx);
149 
150    }; // end class CorrectedEphemerisRange
151 
152       /// Compute relativity correction (sec.s) from the satellite
153       /// position and velocity
154    double RelativityCorrection(const Xvt& svPosVel);
155 
156       //@}
157 
158 }  // namespace gpstk
159 
160 #endif
161