1   /* Copyright 2002-2022 CS GROUP
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.files.ilrs;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.orekit.errors.OrekitException;
23  import org.orekit.errors.OrekitMessages;
24  
25  /**
26   * Container for Consolidated laser ranging Data Format (CDR) header.
27   * @author Bryan Cazabonne
28   * @since 10.3
29   */
30  public class CRDHeader extends ILRSHeader {
31  
32      /** Station name from official list. */
33      private String stationName;
34  
35      /** System identifier: Crustal Dynamics Project (CDP) Pad Identifier for SLR. */
36      private int systemIdentifier;
37  
38      /** System number: Crustal Dynamics Project (CDP) 2-digit system number for SLR. */
39      private int systemNumber;
40  
41      /** System occupancy: Crustal Dynamics Project (CDP) 2-digit occupancy sequence number for SLR. */
42      private int systemOccupancy;
43  
44      /** Station Epoch Time Scale. */
45      private int epochIdentifier;
46  
47      /** Station network. */
48      private String stationNetword;
49  
50      /** Spacecraft Epoch Time Scale (transponders only). */
51      private int spacecraftEpochTimeScale;
52  
53      /** Data type. */
54      private int dataType;
55  
56      /** A flag to indicate the data release. */
57      private int dataReleaseFlag;
58  
59      /** Tropospheric refraction correction applied indicator. */
60      private boolean isTroposphericRefractionApplied;
61  
62      /** Center of mass correction applied indicator. */
63      private boolean isCenterOfMassCorrectionApplied;
64  
65      /** Receive amplitude correction applied indicator. */
66      private boolean isReceiveAmplitudeCorrectionApplied;
67  
68      /** Station system delay applied indicator. */
69      private boolean isStationSystemDelayApplied;
70  
71      /** Spacecraft system delay applied (transponders) indicator. */
72      private boolean isTransponderDelayApplied;
73  
74      /** Range type. */
75      private RangeType rangeType;
76  
77      /** Data quality indicator. */
78      private int qualityIndicator;
79  
80      /** Prediction type (CPF or TLE). */
81      private int predictionType;
82  
83      /** Year of century from CPF or TLE. */
84      private int yearOfCentury;
85  
86      /**
87       * Date and time.
88       * CPF starting date and hour (MMDDHH) from CPF H2 record or
89       * TLE epoch day/fractional day.
90       */
91      private String dateAndTime;
92  
93      /** Prediction provider (CPF provider in H1 record or TLE source). */
94      private String predictionProvider;
95  
96      /**
97       * Get the station name from official list.
98       * @return the station name from official list
99       */
100     public String getStationName() {
101         return stationName;
102     }
103 
104     /**
105      * Set the station name from official list.
106      * @param stationName the station name to set
107      */
108     public void setStationName(final String stationName) {
109         this.stationName = stationName;
110     }
111 
112     /**
113      * Get the system identifier.
114      * @return the system identifier
115      */
116     public int getSystemIdentifier() {
117         return systemIdentifier;
118     }
119 
120     /**
121      * Set the system identifier.
122      * @param systemIdentifier the system identifier to set
123      */
124     public void setSystemIdentifier(final int systemIdentifier) {
125         this.systemIdentifier = systemIdentifier;
126     }
127 
128     /**
129      * Get the system number.
130      * @return the system number
131      */
132     public int getSystemNumber() {
133         return systemNumber;
134     }
135 
136     /**
137      * Set the system number.
138      * @param systemNumber the system number to set
139      */
140     public void setSystemNumber(final int systemNumber) {
141         this.systemNumber = systemNumber;
142     }
143 
144     /**
145      * Get the system occupancy.
146      * @return the system occupancy
147      */
148     public int getSystemOccupancy() {
149         return systemOccupancy;
150     }
151 
152     /**
153      * Set the system occupancy.
154      * @param systemOccupancy the system occupancy to set
155      */
156     public void setSystemOccupancy(final int systemOccupancy) {
157         this.systemOccupancy = systemOccupancy;
158     }
159 
160     /**
161      * Get the epoch identifier.
162      * <p>
163      * 3 = UTC (UNSO) ; 4 = UTC (GPS) ; 7 = UTC (BIPM) ; 10 = UTC (Station Time Scale)
164      * </p>
165      * @return the epoch identifier
166      */
167     public int getEpochIdentifier() {
168         return epochIdentifier;
169     }
170 
171     /**
172      * Set the epoch identifier.
173      * @param epochIdentifier the epoch identifier to set
174      */
175     public void setEpochIdentifier(final int epochIdentifier) {
176         this.epochIdentifier = epochIdentifier;
177     }
178 
179     /**
180      * Get the station network.
181      * @return the station network
182      */
183     public String getStationNetword() {
184         return stationNetword;
185     }
186 
187     /**
188      * Set the station network.
189      * @param stationNetword the station network to set
190      */
191     public void setStationNetword(final String stationNetword) {
192         this.stationNetword = stationNetword;
193     }
194 
195     /**
196      * Get the spacecraft epoch time scale.
197      * @return the spacecraft epoch time scale
198      */
199     public int getSpacecraftEpochTimeScale() {
200         return spacecraftEpochTimeScale;
201     }
202 
203     /**
204      * Set the spacecraft epoch time scale.
205      * @param spacecraftEpochTimeScale the spacecraft epoch time scale to set
206      */
207     public void setSpacecraftEpochTimeScale(final int spacecraftEpochTimeScale) {
208         this.spacecraftEpochTimeScale = spacecraftEpochTimeScale;
209     }
210 
211     /**
212      * Get the data type.
213      * <p>
214      * 0 = full rate ; 1 = normal point ; 2 = sampled engineering
215      * </p>
216      * @return the data type
217      */
218     public int getDataType() {
219         return dataType;
220     }
221 
222     /**
223      * Set the data type.
224      * @param dataType the data type to set
225      */
226     public void setDataType(final int dataType) {
227         this.dataType = dataType;
228     }
229 
230     /**
231      * Get the flag indicating the data release.
232      * @return the flag indicating the data release
233      */
234     public int getDataReleaseFlag() {
235         return dataReleaseFlag;
236     }
237 
238     /**
239      * Set the flag indicating the data release.
240      * @param dataReleaseFlag the flag to set
241      */
242     public void setDataReleaseFlag(final int dataReleaseFlag) {
243         this.dataReleaseFlag = dataReleaseFlag;
244     }
245 
246     /**
247      * Get the tropospheric refraction correction applied indicator.
248      * @return true if tropospheric refraction correction is applied
249      */
250     public boolean isTroposphericRefractionApplied() {
251         return isTroposphericRefractionApplied;
252     }
253 
254     /**
255      * Set the tropospheric refraction correction applied indicator.
256      * @param isTroposphericRefractionApplied true if tropospheric refraction correction is applied
257      */
258     public void setIsTroposphericRefractionApplied(final boolean isTroposphericRefractionApplied) {
259         this.isTroposphericRefractionApplied = isTroposphericRefractionApplied;
260     }
261 
262     /**
263      * Get the center of mass correction applied indicator.
264      * @return true if center of mass correction is applied
265      */
266     public boolean isCenterOfMassCorrectionApplied() {
267         return isCenterOfMassCorrectionApplied;
268     }
269 
270     /**
271      * Set the center of mass correction applied indicator.
272      * @param isCenterOfMassCorrectionApplied true if center of mass correction is applied
273      */
274     public void setIsCenterOfMassCorrectionApplied(final boolean isCenterOfMassCorrectionApplied) {
275         this.isCenterOfMassCorrectionApplied = isCenterOfMassCorrectionApplied;
276     }
277 
278     /**
279      * Get the receive amplitude correction applied indicator.
280      * @return true if receive amplitude correction is applied
281      */
282     public boolean isReceiveAmplitudeCorrectionApplied() {
283         return isReceiveAmplitudeCorrectionApplied;
284     }
285 
286     /**
287      * Set the receive amplitude correction applied indicator.
288      * @param isReceiveAmplitudeCorrectionApplied true if receive amplitude correction is applied
289      */
290     public void setIsReceiveAmplitudeCorrectionApplied(final boolean isReceiveAmplitudeCorrectionApplied) {
291         this.isReceiveAmplitudeCorrectionApplied = isReceiveAmplitudeCorrectionApplied;
292     }
293 
294     /**
295      * Get the station system delay applied indicator.
296      * @return true if station system delay is applied
297      */
298     public boolean isStationSystemDelayApplied() {
299         return isStationSystemDelayApplied;
300     }
301 
302     /**
303      * Set the station system delay applied indicator.
304      * @param isStationSystemDelayApplied true if station system delay is applied
305      */
306     public void setIsStationSystemDelayApplied(final boolean isStationSystemDelayApplied) {
307         this.isStationSystemDelayApplied = isStationSystemDelayApplied;
308     }
309 
310     /**
311      * Get the spacecraft system delay applied (transponders) indicator.
312      * @return true if transponder delay is applied
313      */
314     public boolean isTransponderDelayApplied() {
315         return isTransponderDelayApplied;
316     }
317 
318     /**
319      * Set the spacecraft system delay applied (transponders) indicator.
320      * @param isTransponderDelayApplied true if transponder delay is applied
321      */
322     public void setIsTransponderDelayApplied(final boolean isTransponderDelayApplied) {
323         this.isTransponderDelayApplied = isTransponderDelayApplied;
324     }
325 
326     /**
327      * Get the range type.
328      * @return the range type
329      */
330     public RangeType getRangeType() {
331         return rangeType;
332     }
333 
334     /**
335      * Set the range type indicator.
336      * @param indicator range type indicator
337      */
338     public void setRangeType(final int indicator) {
339         this.rangeType = RangeType.getRangeType(indicator);
340     }
341 
342     /**
343      * Get the data quality indicator.
344      * @return the data quality indicator
345      */
346     public int getQualityIndicator() {
347         return qualityIndicator;
348     }
349 
350     /**
351      * Set the data quality indicator.
352      * @param qualityIndicator the indicator to set
353      */
354     public void setQualityIndicator(final int qualityIndicator) {
355         this.qualityIndicator = qualityIndicator;
356     }
357 
358     /**
359      * Get the prediction type (CPF or TLE).
360      * @return the prediction type
361      */
362     public int getPredictionType() {
363         return predictionType;
364     }
365 
366     /**
367      * Set the prediction type.
368      * @param predictionType the prediction type to set
369      */
370     public void setPredictionType(final int predictionType) {
371         this.predictionType = predictionType;
372     }
373 
374     /**
375      * Get the year of century from CPF or TLE.
376      * @return the year of century from CPF or TLE
377      */
378     public int getYearOfCentury() {
379         return yearOfCentury;
380     }
381 
382     /**
383      * Set the year of century from CPF or TLE.
384      * @param yearOfCentury the year of century to set
385      */
386     public void setYearOfCentury(final int yearOfCentury) {
387         this.yearOfCentury = yearOfCentury;
388     }
389 
390 
391     /**
392      * Get the date and time as the string value.
393      * <p>
394      * Depending the prediction type, this value can represent the
395      * CPF starting date and hour (MMDDHH) from CPF H2 record or
396      * TLE epoch day/fractional day
397      * </p>
398      * @return the date and time as the string value
399      */
400     public String getDateAndTime() {
401         return dateAndTime;
402     }
403 
404     /**
405      * Set the string value of date and time.
406      * @param dateAndTime the date and time to set
407      */
408     public void setDateAndTime(final String dateAndTime) {
409         this.dateAndTime = dateAndTime;
410     }
411 
412     /**
413      * Get the prediction provider.
414      * @return the preditction provider
415      */
416     public String getPredictionProvider() {
417         return predictionProvider;
418     }
419 
420     /**
421      * Set the prediction provider.
422      * @param predictionProvider the prediction provider to set
423      */
424     public void setPredictionProvider(final String predictionProvider) {
425         this.predictionProvider = predictionProvider;
426     }
427 
428     /** Range type for SLR data. */
429     public enum RangeType {
430 
431         /** No ranges (i.e. transmit time only). */
432         NO_RANGES(0),
433 
434         /** One-way ranging. */
435         ONE_WAY(1),
436 
437         /** Two-way ranging. */
438         TWO_WAY(2),
439 
440         /** Received times only. */
441         RECEIVED_ONLY(3),
442 
443         /** Mixed. */
444         MIXED(4);
445 
446         /** Codes map. */
447         private static final Map<Integer, RangeType> CODES_MAP = new HashMap<>();
448         static {
449             for (final RangeType type : values()) {
450                 CODES_MAP.put(type.getIndicator(), type);
451             }
452         }
453 
454         /** range type indicator. */
455         private final int indicator;
456 
457         /**
458          * Constructor.
459          * @param indicator range type indicator
460          */
461         RangeType(final int indicator) {
462             this.indicator = indicator;
463         }
464 
465         /**
466          * Get the range type indicator.
467          * @return the range type indicator
468          */
469         public int getIndicator() {
470             return indicator;
471         }
472 
473         /**
474          * Get the range type for the given indicator.
475          * @param id indicator
476          * @return the range type corresponding to the indicator
477          */
478         public static RangeType getRangeType(final int id) {
479             final RangeType type = CODES_MAP.get(id);
480             if (type == null) {
481                // Invalid value. An exception is thrown
482                 throw new OrekitException(OrekitMessages.INVALID_RANGE_INDICATOR_IN_CRD_FILE, id);
483             }
484             return type;
485         }
486 
487     }
488 
489 }