NavigationSystem.java

  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.gnss.metric.ntrip;

  18. import java.util.HashMap;
  19. import java.util.Map;

  20. import org.orekit.errors.OrekitException;
  21. import org.orekit.errors.OrekitMessages;

  22. /** Enumerate for navigation system in {@link DataStreamRecord}.
  23.  * @author Luc Maisonobe
  24.  * @since 11.0
  25.  */
  26. public enum NavigationSystem {

  27.     /** GPS. */
  28.     GPS("GPS"),

  29.     /** Glonass. */
  30.     GLO("GLO", "Glonass"),

  31.     /** Galileo. */
  32.     GAL("GAL", "Galileo"),

  33.     /** Beidou. */
  34.     BDS("BDS", "Beidou"),

  35.     /** QZNSS. */
  36.     QZS("QZS", "QZNSS"),

  37.     /** SBAS. */
  38.     SBAS("SBAS"),

  39.     /** No navigation system for this stream. */
  40.     EMPTY("");

  41.     /** Keywords map. */
  42.     private static final Map<String, NavigationSystem> KEYWORDS_MAP = new HashMap<String, NavigationSystem>();
  43.     static {
  44.         for (final NavigationSystem type : values()) {
  45.             KEYWORDS_MAP.put(type.getKeyword(), type);
  46.         }
  47.     }

  48.     /** Keyword. */
  49.     private final String keyword;

  50.     /** Name. */
  51.     private final String name;

  52.     /** Simple constructor.
  53.      * @param keyword keyword in the sourcetable records
  54.      */
  55.     NavigationSystem(final String keyword) {
  56.         this(keyword, keyword);
  57.     }

  58.     /** Simple constructor.
  59.      * @param keyword keyword in the sourcetable records
  60.      * @param name readable name
  61.      */
  62.     NavigationSystem(final String keyword, final String name) {
  63.         this.keyword = keyword;
  64.         this.name    = name;
  65.     }

  66.     /** Get keyword.
  67.      * @return keyword
  68.      */
  69.     private String getKeyword() {
  70.         return keyword;
  71.     }

  72.     /** {@inheritDoc} */
  73.     @Override
  74.     public String toString() {
  75.         return name;
  76.     }

  77.     /** Get the navigation system corresponding to a keyword.
  78.      * @param keyword navigation system keyword
  79.      * @return the navigation system corresponding to the keyword
  80.      */
  81.     public static NavigationSystem getNavigationSystem(final String keyword) {
  82.         final NavigationSystem system = KEYWORDS_MAP.get(keyword);
  83.         if (system == null) {
  84.             throw new OrekitException(OrekitMessages.UNKNOWN_NAVIGATION_SYSTEM, keyword);
  85.         }
  86.         return system;
  87.     }

  88. }