1 /* Copyright 2022-2025 Luc Maisonobe
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.files.rinex.navigation;
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 /** Enumerate for the UTC ids.
26 * <p>
27 * In addition to the ids listed here, Rinex 4.01 table 23 allowed UTC(BIPM) as a
28 * possible UTC id for SBAS. This was added in June 2023 and Rinex 4.01 was officially
29 * published in July 2023. However, this was quickly removed, in July 2023, i.e. just
30 * after publication of Rinex 4.01, as directed by BIPM. It does not appear anymore in
31 * Rinex 4.02 which was officially published in October 2024. Due to its transient
32 * appearance in the standard, we decided to not include UTC(BIPM) in this enumerate.
33 * </p>
34 * @author Luc Maisonobe
35 * @since 12.0
36 */
37 public enum UtcId {
38
39 /** UTC(USNO). */
40 USNO("UTC(USNO)"),
41
42 /** UTC(SU). */
43 SU("UTC(SU)"),
44
45 /** UTCGAL. */
46 GAL("UTCGAL"),
47
48 /** UTC(NTSC). */
49 NTSC("UTC(NTSC)"),
50
51 /** UTC(NICT). */
52 NICT("UTC(NICT)"),
53
54 /** UTC(CRL).
55 * @since 13.0
56 */
57 CRL("UTC(CRL)"),
58
59 /** UTC(NIST).
60 * @since 13.0
61 */
62 NIST("UTC(NIST)"),
63
64 /** UTCIRN / UTC(NPLI). */
65 IRN("UTC(NPLI)", "UTCIRN"),
66
67 /** UTC(OP). */
68 OP("UTC(OP)");
69
70 /** Parsing map. */
71 private static final Map<String, UtcId> MAP = new HashMap<>();
72
73 static {
74 for (final UtcId utc : values()) {
75 for (final String id : utc.ids) {
76 MAP.put(id, utc);
77 }
78 }
79 }
80
81 /** Valid ids. */
82 private final String[] ids;
83
84 /** Simple constructor.
85 * @param ids valid ids
86 */
87 UtcId(final String... ids) {
88 this.ids = ids.clone();
89 }
90
91 /** Get reference ID.
92 * @return reference ID
93 * @since 14.0
94 */
95 public String getId() {
96 return ids[0];
97 }
98
99 /** Parse a string to get the UTC id.
100 * @param id string to parse
101 * @return the UTC id
102 * @exception OrekitIllegalArgumentException if the string does not correspond to a UTC id
103 */
104 public static UtcId parseUtcId(final String id)
105 throws OrekitIllegalArgumentException {
106 final UtcId utcId = MAP.get(id);
107 if (utcId == null) {
108 throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_UTC_ID, id);
109 }
110 return utcId;
111 }
112
113 }