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.files.sp3;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.orekit.errors.OrekitIllegalArgumentException;
23  import org.orekit.errors.OrekitMessages;
24  
25  /** Enumerate for data used.
26   * @author Luc Maisonobe
27   * @since 12.0
28   */
29  public enum DataUsed {
30  
31      /** Undifferenciated carrier phase. */
32      UNDIFFERENTIATED_CARRIER_PHASE("u"),
33  
34      /** Change in undifferenciated carrier phase. */
35      CHANGE_IN_UNDIFFERENTIATED_CARRIER_PHASE("du"),
36  
37      /** 2-receiver/1-satellite carrier phase. */
38      TWO_RECEIVER_ONE_SATELLITE_CARRIER_PHASE("s"),
39  
40      /** Change in 2-receiver/1-satellite carrier phase. */
41      CHANGE_IN_TWO_RECEIVER_ONE_SATELLITE_CARRIER_PHASE("ds"),
42  
43      /** 2-receiver/2-satellite carrier phase. */
44      TWO_RECEIVER_TWO_SATELLITE_CARRIER_PHASE("d"),
45  
46      /** Change in 2-receiver/2-satellite carrier phase. */
47      CHANGE_IN_TWO_RECEIVER_TWO_SATELLITE_CARRIER_PHASE("dd"),
48  
49      /** Undifferenciated code phase. */
50      UNDIFFERENTIATED_CODE_PHASE("U"),
51  
52      /** Change in undifferenciated code phase. */
53      CHANGE_IN_UNDIFFERENTIATED_CODE_PHASE("dU"),
54  
55      /** 2-receiver/1-satellite code phase. */
56      TWO_RECEIVER_ONE_SATELLITE_CODE_PHASE("S"),
57  
58      /** Change in 2-receiver/1-satellite code phase. */
59      CHANGE_IN_TWO_RECEIVER_ONE_SATELLITE_CODE_PHASE("dS"),
60  
61      /** 2-receiver/2-satellite code phase. */
62      TWO_RECEIVER_TWO_SATELLITE_CODE_PHASE("D"),
63  
64      /** Change in 2-receiver/2-satellite code phase. */
65      CHANGE_IN_TWO_RECEIVER_TWO_SATELLITE_CODE_PHASE("dD"),
66  
67      /** Satellite Laser Ranging. */
68      SATELLITE_LASER_RANGING("SLR"),
69  
70      /** Mixed data. */
71      MIXED("mixed"),
72  
73      /** Orbit data. */
74      ORBIT("ORBIT");
75  
76      /** Numbers map. */
77      private static final Map<String, DataUsed> MAP = new HashMap<>();
78      static {
79          for (final DataUsed dataUsed : values()) {
80              MAP.put(dataUsed.getKey(), dataUsed);
81          }
82      }
83  
84      /** Key for the data used. */
85      private final String key;
86  
87      /** Simple constructor.
88       * @param key for the data used
89       */
90      DataUsed(final String key) {
91          this.key = key;
92      }
93  
94      /** Get the key for the data used.
95       * @return key for the data used
96       */
97      public String getKey() {
98          return key;
99      }
100 
101     /** Parse the string to get the data used.
102      * @param s string to parse
103      * @param fileName file name to generate the error message
104      * @param version format version
105      * @return the data used corresponding to the string
106      * @exception IllegalArgumentException if the string does not correspond to a data used
107      */
108     public static DataUsed parse(final String s, final String fileName, final char version) {
109         final DataUsed dataUsed = MAP.get(s);
110         if (dataUsed == null) {
111             throw new OrekitIllegalArgumentException(OrekitMessages.SP3_INVALID_HEADER_ENTRY, "data used", s, fileName, version);
112         }
113         return dataUsed;
114     }
115 
116 }