1   /* Copyright 2002-2021 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      /** No navigation system for this stream. */
50      EMPTY("");
51  
52      /** Keywords map. */
53      private static final Map<String, NavigationSystem> KEYWORDS_MAP = new HashMap<String, NavigationSystem>();
54      static {
55          for (final NavigationSystem type : values()) {
56              KEYWORDS_MAP.put(type.getKeyword(), type);
57          }
58      }
59  
60      /** Keyword. */
61      private final String keyword;
62  
63      /** Name. */
64      private final String name;
65  
66      /** Simple constructor.
67       * @param keyword keyword in the sourcetable records
68       */
69      NavigationSystem(final String keyword) {
70          this(keyword, keyword);
71      }
72  
73      /** Simple constructor.
74       * @param keyword keyword in the sourcetable records
75       * @param name readable name
76       */
77      NavigationSystem(final String keyword, final String name) {
78          this.keyword = keyword;
79          this.name    = name;
80      }
81  
82      /** Get keyword.
83       * @return keyword
84       */
85      private String getKeyword() {
86          return keyword;
87      }
88  
89      /** {@inheritDoc} */
90      @Override
91      public String toString() {
92          return name;
93      }
94  
95      /** Get the navigation system corresponding to a keyword.
96       * @param keyword navigation system keyword
97       * @return the navigation system corresponding to the keyword
98       */
99      public static NavigationSystem getNavigationSystem(final String keyword) {
100         final NavigationSystem system = KEYWORDS_MAP.get(keyword);
101         if (system == null) {
102             throw new OrekitException(OrekitMessages.UNKNOWN_NAVIGATION_SYSTEM, keyword);
103         }
104         return system;
105     }
106 
107 }