SatelliteSystem.java

  1. /* Copyright 2002-2024 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. /**
  23.  * Enumerate for satellite system.
  24.  *
  25.  * @author Luc Maisonobe
  26.  * @since 9.2
  27.  */
  28. public enum SatelliteSystem {

  29.     /** User-defined system A.
  30.      * @since 12.0
  31.      */
  32.     USER_DEFINED_A('A', null),

  33.     /** User-defined system B.
  34.      * @since 12.0
  35.      */
  36.     USER_DEFINED_B('B', null),

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

  39.     /** User-defined system D.
  40.      * @since 12.0
  41.      */
  42.     USER_DEFINED_D('D', null),

  43.     /** Galileo system. */
  44.     GALILEO('E', ObservationTimeScale.GAL),

  45.     /** User-defined system F.
  46.      * @since 12.0
  47.      */
  48.     USER_DEFINED_F('F', null),

  49.     /** GPS system. */
  50.     GPS('G', ObservationTimeScale.GPS),

  51.     /** User-defined system H.
  52.      * @since 12.0
  53.      */
  54.     USER_DEFINED_H('H', null),

  55.     /** Indian Regional Navigation Satellite System system (NavIC). */
  56.     IRNSS('I', ObservationTimeScale.IRN),

  57.     /** Quasi-Zenith Satellite System system. */
  58.     QZSS('J', ObservationTimeScale.QZS),

  59.     /** User-defined system K.
  60.      * @since 12.0
  61.      */
  62.     USER_DEFINED_K('K', null),

  63.     /** User-defined system L.
  64.      * @since 12.0
  65.      */
  66.     USER_DEFINED_L('L', null),

  67.     /** Mixed system. */
  68.     MIXED('M', null),

  69.     /** User-defined system N.
  70.      * @since 12.0
  71.      */
  72.     USER_DEFINED_N('N', null),

  73.     /** User-defined system O.
  74.      * @since 12.0
  75.      */
  76.     USER_DEFINED_O('O', null),

  77.     /** User-defined system P.
  78.      * @since 12.0
  79.      */
  80.     USER_DEFINED_P('P', null),

  81.     /** User-defined system Q.
  82.      * @since 12.0
  83.      */
  84.     USER_DEFINED_Q('Q', null),

  85.     /** GLONASS system. */
  86.     GLONASS('R', ObservationTimeScale.GLO),

  87.     /** SBAS system. */
  88.     SBAS('S', null),

  89.     /** User-defined system T.
  90.      * @since 12.0
  91.      */
  92.     USER_DEFINED_T('T', null),

  93.     /** User-defined system U.
  94.      * @since 12.0
  95.      */
  96.     USER_DEFINED_U('U', null),

  97.     /** User-defined system V.
  98.      * @since 12.0
  99.      */
  100.     USER_DEFINED_V('V', null),

  101.     /** User-defined system W.
  102.      * @since 12.0
  103.      */
  104.     USER_DEFINED_W('W', null),

  105.     /** User-defined system X.
  106.      * @since 12.0
  107.      */
  108.     USER_DEFINED_X('X', null),

  109.     /** User-defined system Y.
  110.      * @since 12.0
  111.      */
  112.     USER_DEFINED_Y('Y', null),

  113.     /** User-defined system Z.
  114.      * @since 12.0
  115.      */
  116.     USER_DEFINED_Z('Z', null);

  117.     /** Parsing map. */
  118.     private static final Map<Character, SatelliteSystem> KEYS_MAP = new HashMap<>();
  119.     static {
  120.         for (final SatelliteSystem satelliteSystem : values()) {
  121.             KEYS_MAP.put(satelliteSystem.getKey(), satelliteSystem);
  122.         }
  123.     }

  124.     /** Key for the system. */
  125.     private final char key;

  126.     /** Observation time scale.
  127.      * @since 12.0
  128.      */
  129.     private final ObservationTimeScale observationTimeScale;

  130.     /** Simple constructor.
  131.      * @param key key letter
  132.      * @param observationTimeScale observation time scale (may be null)
  133.      */
  134.     SatelliteSystem(final char key, final ObservationTimeScale observationTimeScale) {
  135.         this.key                  = key;
  136.         this.observationTimeScale = observationTimeScale;
  137.     }

  138.     /** Get the key for the system.
  139.      * @return key for the system
  140.      */
  141.     public char getKey() {
  142.         return key;
  143.     }

  144.     /** Parse a string to get the satellite system.
  145.      * <p>
  146.      * The string first character must be the satellite system.
  147.      * </p>
  148.      * @param s string to parse
  149.      * @return the satellite system
  150.      * @exception OrekitIllegalArgumentException if the string does not correspond to a satellite system key
  151.      */
  152.     public static SatelliteSystem parseSatelliteSystem(final String s)
  153.         throws OrekitIllegalArgumentException {
  154.         final SatelliteSystem satelliteSystem = KEYS_MAP.get(s.charAt(0));
  155.         if (satelliteSystem == null) {
  156.             throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_SATELLITE_SYSTEM, s.charAt(0));
  157.         }
  158.         return satelliteSystem;
  159.     }

  160.     /** Parse a string to get the satellite system.
  161.      * <p>
  162.      * The string first character must be the satellite system, or empty to get GPS as default
  163.      * </p>
  164.      * @param s string to parse
  165.      * @return the satellite system
  166.      * @since 12.0
  167.      */
  168.     public static SatelliteSystem parseSatelliteSystemWithGPSDefault(final String s) {
  169.         return s.isEmpty() ? SatelliteSystem.GPS : parseSatelliteSystem(s);
  170.     }

  171.     /** Get observation time scale for satellite system.
  172.      * @return observation time scale, null if there are not
  173.      * @since 12.0
  174.      */
  175.     public ObservationTimeScale getObservationTimeScale() {
  176.         return observationTimeScale;
  177.     }

  178. }