1   /* Copyright 2002-2025 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.gnss;
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  /**
26   * Enumerate for satellite system.
27   *
28   * @author Luc Maisonobe
29   * @since 9.2
30   */
31  public enum SatelliteSystem {
32  
33      /** User-defined system A.
34       * @since 12.0
35       */
36      USER_DEFINED_A('A', null),
37  
38      /** User-defined system B.
39       * @since 12.0
40       */
41      USER_DEFINED_B('B', null),
42  
43      /** Beidou system. */
44      BEIDOU('C', ObservationTimeScale.BDT),
45  
46      /** User-defined system D.
47       * @since 12.0
48       */
49      USER_DEFINED_D('D', null),
50  
51      /** Galileo system. */
52      GALILEO('E', ObservationTimeScale.GAL),
53  
54      /** User-defined system F.
55       * @since 12.0
56       */
57      USER_DEFINED_F('F', null),
58  
59      /** GPS system. */
60      GPS('G', ObservationTimeScale.GPS),
61  
62      /** User-defined system H.
63       * @since 12.0
64       */
65      USER_DEFINED_H('H', null),
66  
67      /** Navigation with Indian Constellation (NavIC).
68       * <p>
69       * This system was known as Indian Regional Navigation Satellite System (IRNSS).
70       * </p>
71       * @since 13.0
72       */
73      NAVIC('I', ObservationTimeScale.IRN),
74  
75      /** Quasi-Zenith Satellite System system. */
76      QZSS('J', ObservationTimeScale.QZS),
77  
78      /** User-defined system K.
79       * @since 12.0
80       */
81      USER_DEFINED_K('K', null),
82  
83      /** User-defined system L.
84       * @since 12.0
85       */
86      USER_DEFINED_L('L', null),
87  
88      /** Mixed system. */
89      MIXED('M', null),
90  
91      /** User-defined system N.
92       * @since 12.0
93       */
94      USER_DEFINED_N('N', null),
95  
96      /** User-defined system O.
97       * @since 12.0
98       */
99      USER_DEFINED_O('O', null),
100 
101     /** User-defined system P.
102      * @since 12.0
103      */
104     USER_DEFINED_P('P', null),
105 
106     /** User-defined system Q.
107      * @since 12.0
108      */
109     USER_DEFINED_Q('Q', null),
110 
111     /** GLONASS system. */
112     GLONASS('R', ObservationTimeScale.GLO),
113 
114     /** SBAS system. */
115     SBAS('S', null),
116 
117     /** User-defined system T.
118      * @since 12.0
119      */
120     USER_DEFINED_T('T', null),
121 
122     /** User-defined system U.
123      * @since 12.0
124      */
125     USER_DEFINED_U('U', null),
126 
127     /** User-defined system V.
128      * @since 12.0
129      */
130     USER_DEFINED_V('V', null),
131 
132     /** User-defined system W.
133      * @since 12.0
134      */
135     USER_DEFINED_W('W', null),
136 
137     /** User-defined system X.
138      * @since 12.0
139      */
140     USER_DEFINED_X('X', null),
141 
142     /** User-defined system Y.
143      * @since 12.0
144      */
145     USER_DEFINED_Y('Y', null),
146 
147     /** User-defined system Z.
148      * @since 12.0
149      */
150     USER_DEFINED_Z('Z', null);
151 
152     /** Parsing map. */
153     private static final Map<Character, SatelliteSystem> KEYS_MAP = new HashMap<>();
154     static {
155         for (final SatelliteSystem satelliteSystem : values()) {
156             KEYS_MAP.put(satelliteSystem.getKey(), satelliteSystem);
157         }
158     }
159 
160     /** Key for the system. */
161     private final char key;
162 
163     /** Observation time scale.
164      * @since 12.0
165      */
166     private final ObservationTimeScale observationTimeScale;
167 
168     /** Simple constructor.
169      * @param key key letter
170      * @param observationTimeScale observation time scale (may be null)
171      */
172     SatelliteSystem(final char key, final ObservationTimeScale observationTimeScale) {
173         this.key                  = key;
174         this.observationTimeScale = observationTimeScale;
175     }
176 
177     /** Get the key for the system.
178      * @return key for the system
179      */
180     public char getKey() {
181         return key;
182     }
183 
184     /** Parse a string to get the satellite system.
185      * <p>
186      * The string first character must be the satellite system.
187      * </p>
188      * @param s string to parse
189      * @return the satellite system
190      * @exception OrekitIllegalArgumentException if the string does not correspond to a satellite system key
191      */
192     public static SatelliteSystem parseSatelliteSystem(final String s)
193         throws OrekitIllegalArgumentException {
194         final SatelliteSystem satelliteSystem = KEYS_MAP.get(s.charAt(0));
195         if (satelliteSystem == null) {
196             throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_SATELLITE_SYSTEM, s.charAt(0));
197         }
198         return satelliteSystem;
199     }
200 
201     /** Parse a string to get the satellite system.
202      * <p>
203      * The string first character must be the satellite system, or empty to get GPS as default
204      * </p>
205      * @param s string to parse
206      * @return the satellite system
207      * @since 12.0
208      */
209     public static SatelliteSystem parseSatelliteSystemWithGPSDefault(final String s) {
210         return s.isEmpty() ? SatelliteSystem.GPS : parseSatelliteSystem(s);
211     }
212 
213     /** Get observation time scale for satellite system.
214      * @return observation time scale, null if there are not
215      * @since 12.0
216      */
217     public ObservationTimeScale getObservationTimeScale() {
218         return observationTimeScale;
219     }
220 
221 }