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 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 /** GPS system. */ 34 GPS('G'), 35 36 /** GLONASS system. */ 37 GLONASS('R'), 38 39 /** Galileo system. */ 40 GALILEO('E'), 41 42 /** Beidou system. */ 43 BEIDOU('C'), 44 45 /** Quasi-Zenith Satellite System system. */ 46 QZSS('J'), 47 48 /** Indian Regional Navigation Satellite System system. */ 49 IRNSS('I'), 50 51 /** SBAS system. */ 52 SBAS('S'), 53 54 /** Mixed system. */ 55 MIXED('M'); 56 57 /** Parsing map. */ 58 private static final Map<Character, SatelliteSystem> KEYS_MAP = new HashMap<>(); 59 static { 60 for (final SatelliteSystem satelliteSystem : values()) { 61 KEYS_MAP.put(satelliteSystem.getKey(), satelliteSystem); 62 } 63 } 64 65 /** Key for the system. */ 66 private final char key; 67 68 /** Simple constructor. 69 * @param key key letter 70 */ 71 SatelliteSystem(final char key) { 72 this.key = key; 73 } 74 75 /** Get the key for the system. 76 * @return key for the system 77 */ 78 public char getKey() { 79 return key; 80 } 81 82 /** Parse a string to get the satellite system. 83 * <p> 84 * The string first character must be the satellite system. 85 * </p> 86 * @param s string to parse 87 * @return the satellite system 88 * @exception OrekitIllegalArgumentException if the string does not correspond to a satellite system key 89 */ 90 public static SatelliteSystem parseSatelliteSystem(final String s) 91 throws OrekitIllegalArgumentException { 92 final SatelliteSystem satelliteSystem = KEYS_MAP.get(s.charAt(0)); 93 if (satelliteSystem == null) { 94 throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_SATELLITE_SYSTEM, s.charAt(0)); 95 } 96 return satelliteSystem; 97 } 98 99 }