1 /* Copyright 2022-2025 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.hipparchus.Field;
21
22 import java.util.function.Function;
23
24 /** Container for common GNSS data contained in almanac and navigation messages.
25 * @param <T> type of the field elements
26 * @param <O> type of the orbital elements (non-field version)
27 * @author Luc Maisonobe
28 * @since 13.0
29 */
30 public abstract class FieldCommonGnssData<T extends CalculusFieldElement<T>,
31 O extends CommonGnssData<O>>
32 extends FieldGnssOrbitalElements<T, O>
33 implements FieldGNSSClockElements<T> {
34
35 /** SV zero-th order clock correction (s). */
36 private T af0;
37
38 /** SV first order clock correction (s/s). */
39 private T af1;
40
41 /** SV second order clock correction (s/s²). */
42 private T af2;
43
44 /** Group delay differential TGD for L1-L2 correction. */
45 private T tgd;
46
47 /** Time Of Clock. */
48 private T toc;
49
50 /** Constructor from non-field instance.
51 * @param field field to which elements belong
52 * @param original regular non-field instance
53 */
54 protected FieldCommonGnssData(final Field<T> field, final O original) {
55 super(field, original);
56 setAf0(field.getZero().newInstance(original.getAf0()));
57 setAf1(field.getZero().newInstance(original.getAf1()));
58 setAf2(field.getZero().newInstance(original.getAf2()));
59 setTGD(field.getZero().newInstance(original.getTGD()));
60 setToc(field.getZero().newInstance(original.getToc()));
61 }
62
63 /** Constructor from different field instance.
64 * @param <V> type of the old field elements
65 * @param original regular non-field instance
66 * @param converter for field elements
67 */
68 protected <V extends CalculusFieldElement<V>> FieldCommonGnssData(final Function<V, T> converter,
69 final FieldCommonGnssData<V, O> original) {
70 super(converter, original);
71 setAf0(converter.apply(original.getAf0()));
72 setAf1(converter.apply(original.getAf1()));
73 setAf2(converter.apply(original.getAf2()));
74 setTGD(converter.apply(original.getTGD()));
75 setToc(converter.apply(original.getToc()));
76 }
77
78 /** {@inheritDoc} */
79 @Override
80 public T getAf0() {
81 return af0;
82 }
83
84 /**
85 * Setter for the SV Clock Bias Correction Coefficient (s).
86 * @param af0 the SV Clock Bias Correction Coefficient to set
87 */
88 public void setAf0(final T af0) {
89 this.af0 = af0;
90 }
91
92 /** {@inheritDoc} */
93 @Override
94 public T getAf1() {
95 return af1;
96 }
97
98 /**
99 * Setter for the SV Clock Drift Correction Coefficient (s/s).
100 * @param af1 the SV Clock Drift Correction Coefficient to set
101 */
102 public void setAf1(final T af1) {
103 this.af1 = af1;
104 }
105
106 /** {@inheritDoc} */
107 @Override
108 public T getAf2() {
109 return af2;
110 }
111
112 /**
113 * Setter for the Drift Rate Correction Coefficient (s/s²).
114 * @param af2 the Drift Rate Correction Coefficient to set
115 */
116 public void setAf2(final T af2) {
117 this.af2 = af2;
118 }
119
120 /**
121 * Set the estimated group delay differential TGD for L1-L2 correction.
122 * @param groupDelayDifferential the estimated group delay differential TGD for L1-L2 correction (s)
123 */
124 public void setTGD(final T groupDelayDifferential) {
125 this.tgd = groupDelayDifferential;
126 }
127
128 /** {@inheritDoc} */
129 @Override
130 public T getTGD() {
131 return tgd;
132 }
133
134 /**
135 * Set the time of clock.
136 * @param toc the time of clock (s)
137 * @see #getAf0()
138 * @see #getAf1()
139 * @see #getAf2()
140 */
141 public void setToc(final T toc) {
142 this.toc = toc;
143 }
144
145 /** {@inheritDoc} */
146 @Override
147 public T getToc() {
148 return toc;
149 }
150
151 }