SatelliteSystem.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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. import java.util.HashMap;
  19. import java.util.Map;

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

  22. /**
  23.  * Enumerate for satellite system.
  24.  *
  25.  * @author Luc Maisonobe
  26.  * @since 9.2
  27.  */
  28. public enum SatelliteSystem {

  29.     /** GPS system. */
  30.     GPS('G'),

  31.     /** GLONASS system. */
  32.     GLONASS('R'),

  33.     /** Galileo system. */
  34.     GALILEO('E'),

  35.     /** Beidou system. */
  36.     BEIDOU('C'),

  37.     /** Quasi-Zenith Satellite System system. */
  38.     QZSS('J'),

  39.     /** Indian Regional Navigation Satellite System system. */
  40.     IRNSS('I'),

  41.     /** SBAS system. */
  42.     SBAS('S'),

  43.     /** Mixed system. */
  44.     MIXED('M');

  45.     /** Parsing map. */
  46.     private static final Map<Character, SatelliteSystem> KEYS_MAP = new HashMap<>();
  47.     static {
  48.         for (final SatelliteSystem satelliteSystem : values()) {
  49.             KEYS_MAP.put(satelliteSystem.getKey(), satelliteSystem);
  50.         }
  51.     }

  52.     /** Key for the system. */
  53.     private final char key;

  54.     /** Simple constructor.
  55.      * @param key key letter
  56.      */
  57.     SatelliteSystem(final char key) {
  58.         this.key = key;
  59.     }

  60.     /** Get the key for the system.
  61.      * @return key for the system
  62.      */
  63.     public char getKey() {
  64.         return key;
  65.     }

  66.     /** Parse a string to get the satellite system.
  67.      * <p>
  68.      * The string first character must be the satellite system.
  69.      * </p>
  70.      * @param s string to parse
  71.      * @return the satellite system
  72.      * @exception OrekitIllegalArgumentException if the string does not correspond to a satellite system key
  73.      */
  74.     public static SatelliteSystem parseSatelliteSystem(final String s)
  75.         throws OrekitIllegalArgumentException {
  76.         final SatelliteSystem satelliteSystem = KEYS_MAP.get(s.charAt(0));
  77.         if (satelliteSystem == null) {
  78.             throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_SATELLITE_SYSTEM, s.charAt(0));
  79.         }
  80.         return satelliteSystem;
  81.     }

  82. }