SatelliteSystem.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;

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

  20. import org.orekit.errors.OrekitIllegalArgumentException;
  21. import org.orekit.errors.OrekitMessages;
  22. import org.orekit.time.TimeScale;
  23. import org.orekit.time.TimeScales;

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

  31.     /** GPS system. */
  32.     GPS('G'),

  33.     /** GLONASS system. */
  34.     GLONASS('R'),

  35.     /** Galileo system. */
  36.     GALILEO('E'),

  37.     /** Beidou system. */
  38.     BEIDOU('C'),

  39.     /** Quasi-Zenith Satellite System system. */
  40.     QZSS('J'),

  41.     /** Indian Regional Navigation Satellite System system. */
  42.     IRNSS('I'),

  43.     /** SBAS system. */
  44.     SBAS('S'),

  45.     /** Mixed system. */
  46.     MIXED('M');

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

  54.     /** Key for the system. */
  55.     private final char key;

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

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

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

  84.     /** Get default time scale for satellite system.
  85.      * @param timeScales the set of timeScales to use
  86.      * @return the default time scale among the given set matching to satellite system,
  87.      *         null if there are not
  88.      */
  89.     public TimeScale getDefaultTimeSystem(final TimeScales timeScales) {

  90.         TimeScale timeScale = null;
  91.         switch (this) {
  92.             case GPS:
  93.                 timeScale = timeScales.getGPS();
  94.                 break;

  95.             case GALILEO:
  96.                 timeScale = timeScales.getGST();
  97.                 break;

  98.             case GLONASS:
  99.                 timeScale = timeScales.getGLONASS();
  100.                 break;

  101.             case QZSS:
  102.                 timeScale = timeScales.getQZSS();
  103.                 break;

  104.             case BEIDOU:
  105.                 timeScale = timeScales.getBDT();
  106.                 break;

  107.             case IRNSS:
  108.                 timeScale = timeScales.getIRNSS();
  109.                 break;

  110.             // Default value is null
  111.             default:
  112.                 timeScale = null;
  113.                 break;
  114.         }

  115.         return timeScale;
  116.     }

  117. }