SatelliteSystem.java

  1. /* Copyright 2002-2025 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.     /** Navigation with Indian Constellation (NavIC).
  56.      * <p>
  57.      * This system was known as Indian Regional Navigation Satellite System (IRNSS).
  58.      * </p>
  59.      * @since 13.0
  60.      */
  61.     NAVIC('I', ObservationTimeScale.IRN),

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

  64.     /** User-defined system K.
  65.      * @since 12.0
  66.      */
  67.     USER_DEFINED_K('K', null),

  68.     /** User-defined system L.
  69.      * @since 12.0
  70.      */
  71.     USER_DEFINED_L('L', null),

  72.     /** Mixed system. */
  73.     MIXED('M', null),

  74.     /** User-defined system N.
  75.      * @since 12.0
  76.      */
  77.     USER_DEFINED_N('N', null),

  78.     /** User-defined system O.
  79.      * @since 12.0
  80.      */
  81.     USER_DEFINED_O('O', null),

  82.     /** User-defined system P.
  83.      * @since 12.0
  84.      */
  85.     USER_DEFINED_P('P', null),

  86.     /** User-defined system Q.
  87.      * @since 12.0
  88.      */
  89.     USER_DEFINED_Q('Q', null),

  90.     /** GLONASS system. */
  91.     GLONASS('R', ObservationTimeScale.GLO),

  92.     /** SBAS system. */
  93.     SBAS('S', null),

  94.     /** User-defined system T.
  95.      * @since 12.0
  96.      */
  97.     USER_DEFINED_T('T', null),

  98.     /** User-defined system U.
  99.      * @since 12.0
  100.      */
  101.     USER_DEFINED_U('U', null),

  102.     /** User-defined system V.
  103.      * @since 12.0
  104.      */
  105.     USER_DEFINED_V('V', null),

  106.     /** User-defined system W.
  107.      * @since 12.0
  108.      */
  109.     USER_DEFINED_W('W', null),

  110.     /** User-defined system X.
  111.      * @since 12.0
  112.      */
  113.     USER_DEFINED_X('X', null),

  114.     /** User-defined system Y.
  115.      * @since 12.0
  116.      */
  117.     USER_DEFINED_Y('Y', null),

  118.     /** User-defined system Z.
  119.      * @since 12.0
  120.      */
  121.     USER_DEFINED_Z('Z', null);

  122.     /** Parsing map. */
  123.     private static final Map<Character, SatelliteSystem> KEYS_MAP = new HashMap<>();
  124.     static {
  125.         for (final SatelliteSystem satelliteSystem : values()) {
  126.             KEYS_MAP.put(satelliteSystem.getKey(), satelliteSystem);
  127.         }
  128.     }

  129.     /** Key for the system. */
  130.     private final char key;

  131.     /** Observation time scale.
  132.      * @since 12.0
  133.      */
  134.     private final ObservationTimeScale observationTimeScale;

  135.     /** Simple constructor.
  136.      * @param key key letter
  137.      * @param observationTimeScale observation time scale (may be null)
  138.      */
  139.     SatelliteSystem(final char key, final ObservationTimeScale observationTimeScale) {
  140.         this.key                  = key;
  141.         this.observationTimeScale = observationTimeScale;
  142.     }

  143.     /** Get the key for the system.
  144.      * @return key for the system
  145.      */
  146.     public char getKey() {
  147.         return key;
  148.     }

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

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

  176.     /** Get observation time scale for satellite system.
  177.      * @return observation time scale, null if there are not
  178.      * @since 12.0
  179.      */
  180.     public ObservationTimeScale getObservationTimeScale() {
  181.         return observationTimeScale;
  182.     }

  183. }