1 /* Copyright 2002-2023 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 19 import java.util.HashMap; 20 import java.util.Map; 21 22 import org.orekit.errors.OrekitIllegalArgumentException; 23 import org.orekit.errors.OrekitMessages; 24 25 /** 26 * Enumerate for satellite system. 27 * 28 * @author Luc Maisonobe 29 * @since 9.2 30 */ 31 public enum SatelliteSystem { 32 33 /** User-defined system A. 34 * @since 12.0 35 */ 36 USER_DEFINED_A('A', null), 37 38 /** User-defined system B. 39 * @since 12.0 40 */ 41 USER_DEFINED_B('B', null), 42 43 /** Beidou system. */ 44 BEIDOU('C', ObservationTimeScale.BDT), 45 46 /** User-defined system D. 47 * @since 12.0 48 */ 49 USER_DEFINED_D('D', null), 50 51 /** Galileo system. */ 52 GALILEO('E', ObservationTimeScale.GAL), 53 54 /** User-defined system F. 55 * @since 12.0 56 */ 57 USER_DEFINED_F('F', null), 58 59 /** GPS system. */ 60 GPS('G', ObservationTimeScale.GPS), 61 62 /** User-defined system H. 63 * @since 12.0 64 */ 65 USER_DEFINED_H('H', null), 66 67 /** Indian Regional Navigation Satellite System system (NavIC). */ 68 IRNSS('I', ObservationTimeScale.IRN), 69 70 /** Quasi-Zenith Satellite System system. */ 71 QZSS('J', ObservationTimeScale.QZS), 72 73 /** User-defined system K. 74 * @since 12.0 75 */ 76 USER_DEFINED_K('K', null), 77 78 /** User-defined system L. 79 * @since 12.0 80 */ 81 USER_DEFINED_L('L', null), 82 83 /** Mixed system. */ 84 MIXED('M', null), 85 86 /** User-defined system N. 87 * @since 12.0 88 */ 89 USER_DEFINED_N('N', null), 90 91 /** User-defined system O. 92 * @since 12.0 93 */ 94 USER_DEFINED_O('O', null), 95 96 /** User-defined system P. 97 * @since 12.0 98 */ 99 USER_DEFINED_P('P', null), 100 101 /** User-defined system Q. 102 * @since 12.0 103 */ 104 USER_DEFINED_Q('Q', null), 105 106 /** GLONASS system. */ 107 GLONASS('R', ObservationTimeScale.GLO), 108 109 /** SBAS system. */ 110 SBAS('S', null), 111 112 /** User-defined system T. 113 * @since 12.0 114 */ 115 USER_DEFINED_T('T', null), 116 117 /** User-defined system U. 118 * @since 12.0 119 */ 120 USER_DEFINED_U('U', null), 121 122 /** User-defined system V. 123 * @since 12.0 124 */ 125 USER_DEFINED_V('V', null), 126 127 /** User-defined system W. 128 * @since 12.0 129 */ 130 USER_DEFINED_W('W', null), 131 132 /** User-defined system X. 133 * @since 12.0 134 */ 135 USER_DEFINED_X('X', null), 136 137 /** User-defined system Y. 138 * @since 12.0 139 */ 140 USER_DEFINED_Y('Y', null), 141 142 /** User-defined system Z. 143 * @since 12.0 144 */ 145 USER_DEFINED_Z('Z', null); 146 147 /** Parsing map. */ 148 private static final Map<Character, SatelliteSystem> KEYS_MAP = new HashMap<>(); 149 static { 150 for (final SatelliteSystem satelliteSystem : values()) { 151 KEYS_MAP.put(satelliteSystem.getKey(), satelliteSystem); 152 } 153 } 154 155 /** Key for the system. */ 156 private final char key; 157 158 /** Observation time scale. 159 * @since 12.0 160 */ 161 private final ObservationTimeScale observationTimeScale; 162 163 /** Simple constructor. 164 * @param key key letter 165 * @param observationTimeScale observation time scale (may be null) 166 */ 167 SatelliteSystem(final char key, final ObservationTimeScale observationTimeScale) { 168 this.key = key; 169 this.observationTimeScale = observationTimeScale; 170 } 171 172 /** Get the key for the system. 173 * @return key for the system 174 */ 175 public char getKey() { 176 return key; 177 } 178 179 /** Parse a string to get the satellite system. 180 * <p> 181 * The string first character must be the satellite system. 182 * </p> 183 * @param s string to parse 184 * @return the satellite system 185 * @exception OrekitIllegalArgumentException if the string does not correspond to a satellite system key 186 */ 187 public static SatelliteSystem parseSatelliteSystem(final String s) 188 throws OrekitIllegalArgumentException { 189 final SatelliteSystem satelliteSystem = KEYS_MAP.get(s.charAt(0)); 190 if (satelliteSystem == null) { 191 throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_SATELLITE_SYSTEM, s.charAt(0)); 192 } 193 return satelliteSystem; 194 } 195 196 /** Parse a string to get the satellite system. 197 * <p> 198 * The string first character must be the satellite system, or empty to get GPS as default 199 * </p> 200 * @param s string to parse 201 * @return the satellite system 202 * @since 12.0 203 */ 204 public static SatelliteSystem parseSatelliteSystemWithGPSDefault(final String s) { 205 return s.isEmpty() ? SatelliteSystem.GPS : parseSatelliteSystem(s); 206 } 207 208 /** Get observation time scale for satellite system. 209 * @return observation time scale, null if there are not 210 * @since 12.0 211 */ 212 public ObservationTimeScale getObservationTimeScale() { 213 return observationTimeScale; 214 } 215 216 }