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 /**
25 * This class holds a GPS almanac as read from SEM or YUMA files.
26 *
27 * <p>Depending on the source (SEM or YUMA), some fields may be filled in or not.
28 * An almanac read from a YUMA file doesn't hold SVN number, average URA and satellite
29 * configuration.</p>
30 *
31 * @param <T> type of the field elements
32 * @author Luc Maisonobe
33 * @since 13.0
34 *
35 */
36 public class FieldGPSAlmanac<T extends CalculusFieldElement<T>>
37 extends FieldAbstractAlmanac<T, GPSAlmanac> {
38
39 /** Source of the almanac. */
40 private String src;
41
42 /** SVN number. */
43 private int svn;
44
45 /** Health status. */
46 private int health;
47
48 /** Average URA. */
49 private int ura;
50
51 /** Satellite configuration. */
52 private int config;
53
54 /** Constructor from non-field instance.
55 * @param field field to which elements belong
56 * @param original regular non-field instance
57 */
58 public FieldGPSAlmanac(final Field<T> field, final GPSAlmanac original) {
59 super(field, original);
60 setSource(original.getSource());
61 setSVN(original.getSVN());
62 setHealth(original.getHealth());
63 setURA(original.getURA());
64 setSatConfiguration(original.getSatConfiguration());
65 }
66
67 /** Constructor from different field instance.
68 * @param <V> type of the old field elements
69 * @param original regular non-field instance
70 * @param converter for field elements
71 */
72 public <V extends CalculusFieldElement<V>> FieldGPSAlmanac(final Function<V, T> converter,
73 final FieldGPSAlmanac<V> original) {
74 super(converter, original);
75 setSource(original.getSource());
76 setSVN(original.getSVN());
77 setHealth(original.getHealth());
78 setURA(original.getURA());
79 setSatConfiguration(original.getSatConfiguration());
80 }
81
82 /** {@inheritDoc} */
83 @Override
84 public GPSAlmanac toNonField() {
85 return new GPSAlmanac(this);
86 }
87
88 /** {@inheritDoc} */
89 @SuppressWarnings("unchecked")
90 @Override
91 public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, GPSAlmanac>>
92 G changeField(final Function<T, U> converter) {
93 return (G) new FieldGPSAlmanac<>(converter, this);
94 }
95
96 /**
97 * Setter for the Square Root of Semi-Major Axis (m^1/2).
98 * <p>
99 * In addition, this method set the value of the Semi-Major Axis.
100 * </p>
101 * @param sqrtA the Square Root of Semi-Major Axis (m^1/2)
102 */
103 public void setSqrtA(final T sqrtA) {
104 setSma(sqrtA.square());
105 }
106
107 /**
108 * Gets the source of this GPS almanac.
109 * <p>Sources can be SEM or YUMA, when the almanac is read from a file.</p>
110 *
111 * @return the source of this GPS almanac
112 */
113 public String getSource() {
114 return src;
115 }
116
117 /**
118 * Sets the source of this GPS almanac.
119 *
120 * @param source the source of this GPS almanac
121 */
122 public void setSource(final String source) {
123 this.src = source;
124 }
125
126 /**
127 * Gets the satellite "SVN" reference number.
128 *
129 * @return the satellite "SVN" reference number
130 */
131 public int getSVN() {
132 return svn;
133 }
134
135 /**
136 * Sets the "SVN" reference number.
137 *
138 * @param svnNumber the number to set
139 */
140 public void setSVN(final int svnNumber) {
141 this.svn = svnNumber;
142 }
143
144 /**
145 * Gets the Health status.
146 *
147 * @return the Health status
148 */
149 public int getHealth() {
150 return health;
151 }
152
153 /**
154 * Sets the health status.
155 *
156 * @param health the health status to set
157 */
158 public void setHealth(final int health) {
159 this.health = health;
160 }
161
162 /**
163 * Gets the average URA number.
164 *
165 * @return the average URA number
166 */
167 public int getURA() {
168 return ura;
169 }
170
171 /**
172 * Sets the average URA number.
173 *
174 * @param uraNumber the URA number to set
175 */
176 public void setURA(final int uraNumber) {
177 this.ura = uraNumber;
178 }
179
180 /**
181 * Gets the satellite configuration.
182 *
183 * @return the satellite configuration
184 */
185 public int getSatConfiguration() {
186 return config;
187 }
188
189 /**
190 * Sets the satellite configuration.
191 *
192 * @param satConfiguration the satellite configuration to set
193 */
194 public void setSatConfiguration(final int satConfiguration) {
195 this.config = satConfiguration;
196 }
197
198 }