1   /* Copyright 2022-2026 Luc Maisonobe
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.propagation.analytical.gnss.data;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.orekit.frames.Frame;
21  import org.orekit.orbits.FieldKeplerianOrbit;
22  import org.orekit.orbits.KeplerianOrbit;
23  import org.orekit.time.FieldGNSSDate;
24  import org.orekit.time.GNSSDate;
25  import org.orekit.time.TimeScales;
26  
27  import java.util.function.DoubleFunction;
28  
29  /**
30   * Container for data contained in a GPS navigation message.
31   * @author Luc Maisonobe
32   * @since 12.0
33   */
34  public class GPSCivilianNavigationMessage extends CivilianNavigationMessage<GPSCivilianNavigationMessage> {
35  
36      /** Message type.
37       * @since 14.0
38       */
39      public static final String CNAV = "CNAV";
40  
41      /** Message type.
42       * @since 14.0
43       */
44      public static final String CNV2 = "CNV2";
45  
46      /** Constructor.
47       * @param cnv2             indicator for CNV2 messages
48       * @param timeScales       known time scales
49       * @param type             message type
50       * @param prn              PRN number of the satellite
51       * @param toe              time of ephemeris (<em>must</em> be consistent with {@code orbit})
52       * @param orbit            Keplerian orbit in Earth-frozen frame
53       * @param aDot             change rate in semi-major axis (m/s)
54       * @param deltaN0          delta of satellite mean motion
55       * @param deltaN0Dot       change rate in Δn₀
56       * @param iDot             inclination rate (rad/s)
57       * @param omegaDot         rate of right ascension (rad/s)
58       * @param cuc              amplitude of the cosine harmonic correction term to the argument of latitude
59       * @param cus              amplitude of the sine harmonic correction term to the argument of latitude
60       * @param crc              amplitude of the cosine harmonic correction term to the orbit radius
61       * @param crs              amplitude of the sine harmonic correction term to the orbit radius
62       * @param cic              amplitude of the cosine harmonic correction term to the inclination
63       * @param cis              amplitude of the sine harmonic correction term to the inclination
64       * @param af0              zero-th order clock correction (s)
65       * @param af1              first order clock correction (s/s)
66       * @param af2              second order clock correction (s/s²)
67       * @param tgd              group delay differential TGD for L1-L2 correction
68       * @param toc              time of clock
69       * @param transmissionTime transmission time
70       * @param svAccuracy       user SV accuracy (m)
71       * @param svHealth         satellite health status
72       * @param iscL1CA          inter signal delay for L1 C/A
73       * @param iscL1CD          inter signal delay for L1 CD
74       * @param iscL1CP          inter signal delay for L1 CP
75       * @param iscL2C           inter signal delay for L2 C
76       * @param iscL5I5          inter signal delay for L5I
77       * @param iscL5Q5          inter signal delay for L5Q
78       * @param uraiEd           elevation-dependent user range accuracy
79       * @param uraiNed0         term 0 of non-elevation-dependent user range accuracy
80       * @param uraiNed1         term 1 of non-elevation-dependent user range accuracy
81       * @param uraiNed2         term 2 of non-elevation-dependent user range accuracy
82       * @param flags            flags
83       */
84      public GPSCivilianNavigationMessage(final boolean cnv2,
85                                          final TimeScales timeScales, final String type,
86                                          final int prn, final GNSSDate toe, final KeplerianOrbit orbit,
87                                          final double aDot, final double deltaN0, final double deltaN0Dot,
88                                          final double iDot, final double omegaDot,
89                                          final double cuc, final double cus,
90                                          final double crc, final double crs,
91                                          final double cic, final double cis,
92                                          final double af0, final double af1, final double af2,
93                                          final double tgd, final GNSSDate toc, final GNSSDate  transmissionTime,
94                                          final double svAccuracy, final int svHealth,
95                                          final double iscL1CA, final double iscL1CD, final double iscL1CP,
96                                          final double iscL2C, final double iscL5I5, final double iscL5Q5,
97                                          final int uraiEd, final int uraiNed0, final int uraiNed1, final int uraiNed2,
98                                          final int flags) {
99          super(cnv2, GNSSConstants.GPS_AV, GNSSConstants.GPS_WEEK_NB,
100               timeScales, type, prn, toe, orbit,
101               aDot, deltaN0, deltaN0Dot, iDot, omegaDot, cuc, cus, crc, crs, cic, cis,
102               af0, af1, af2, tgd, toc, transmissionTime,
103               svAccuracy, svHealth, iscL1CA, iscL1CD, iscL1CP, iscL2C, iscL5I5, iscL5Q5,
104               uraiEd, uraiNed0, uraiNed1, uraiNed2, flags);
105     }
106 
107     /** Constructor from field instance.
108      * @param <T> type of the field elements
109      * @param original regular field instance
110      */
111     public <T extends CalculusFieldElement<T>> GPSCivilianNavigationMessage(final FieldGPSCivilianNavigationMessage<T> original) {
112         super(original);
113     }
114 
115     /** {@inheritDoc} */
116     @Override
117     public <T extends CalculusFieldElement<T>>
118         FieldGPSCivilianNavigationMessage<T> toField(final FieldKeplerianOrbit<T> orbit,
119                                                      final T[] nonKeplerian,
120                                                      final DoubleFunction<T> converter) {
121         return new FieldGPSCivilianNavigationMessage<>(isCnv2(),
122                                                        getAngularVelocity(), getWeeksInCycle(), getTimeScales(),
123                                                        getType(), getPrn(),
124                                                        new FieldGNSSDate<>(orbit.getDate().getField(), getTimeOfEphemeris()),
125                                                        orbit, nonKeplerian,
126                                                        converter.apply(getTgd()),
127                                                        new FieldGNSSDate<>(orbit.getDate().getField(), getTimeOfClock()),
128                                                        new FieldGNSSDate<>(orbit.getDate().getField(), getTransmissionTime()),
129                                                        converter.apply(getSvAccuracy()),
130                                                        getSvHealth(),
131                                                        converter.apply(getIscL1CA()),
132                                                        converter.apply(getIscL1CD()),
133                                                        converter.apply(getIscL1CP()),
134                                                        converter.apply(getIscL2C()),
135                                                        converter.apply(getIscL5I5()),
136                                                        converter.apply(getIscL5Q5()),
137                                                        getUraiEd(), getUraiNed0(), getUraiNed1(), getUraiNed2(),
138                                                        getFlags());
139     }
140 
141     /** {@inheritDoc} */
142     @Override
143     public GPSCivilianNavigationMessageFactory baseFactory(final Frame inertial, final Frame bodyFixed) {
144         return new GPSCivilianNavigationMessageFactory(getTimeScales(), getTimeOfEphemeris().getSystem(), getType(),
145                                                        inertial, bodyFixed, isCnv2());
146     }
147 
148 }