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.metric.ntrip;
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  /** Enumerate for navigation system in {@link DataStreamRecord}.
26   * @author Luc Maisonobe
27   * @since 11.0
28   */
29  public enum NavigationSystem {
30  
31      /** GPS. */
32      GPS("GPS"),
33  
34      /** Glonass. */
35      GLO("GLO", "Glonass"),
36  
37      /** Galileo. */
38      GAL("GAL", "Galileo"),
39  
40      /** Beidou. */
41      BDS("BDS", "Beidou"),
42  
43      /** QZNSS. */
44      QZS("QZS", "QZNSS"),
45  
46      /** SBAS. */
47      SBAS("SBAS"),
48  
49      /** NavIC. */
50      IRS("IRS", "IRNSS"),
51  
52      /** No navigation system for this stream. */
53      EMPTY("");
54  
55      /** Keywords map. */
56      private static final Map<String, NavigationSystem> KEYWORDS_MAP = new HashMap<>();
57      static {
58          for (final NavigationSystem type : values()) {
59              KEYWORDS_MAP.put(type.getKeyword(), type);
60          }
61      }
62  
63      /** Keyword. */
64      private final String keyword;
65  
66      /** Name. */
67      private final String name;
68  
69      /** Simple constructor.
70       * @param keyword keyword in the sourcetable records
71       */
72      NavigationSystem(final String keyword) {
73          this(keyword, keyword);
74      }
75  
76      /** Simple constructor.
77       * @param keyword keyword in the sourcetable records
78       * @param name readable name
79       */
80      NavigationSystem(final String keyword, final String name) {
81          this.keyword = keyword;
82          this.name    = name;
83      }
84  
85      /** Get keyword.
86       * @return keyword
87       */
88      private String getKeyword() {
89          return keyword;
90      }
91  
92      /** {@inheritDoc} */
93      @Override
94      public String toString() {
95          return name;
96      }
97  
98      /** Get the navigation system corresponding to a keyword.
99       * @param keyword navigation system keyword
100      * @return the navigation system corresponding to the keyword
101      */
102     public static NavigationSystem getNavigationSystem(final String keyword) {
103         final NavigationSystem system = KEYWORDS_MAP.get(keyword);
104         if (system == null) {
105             throw new OrekitException(OrekitMessages.UNKNOWN_NAVIGATION_SYSTEM, keyword);
106         }
107         return system;
108     }
109 
110 }