UtcId.java

  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. import java.util.HashMap;
  19. import java.util.Map;

  20. import org.orekit.errors.OrekitIllegalArgumentException;
  21. import org.orekit.errors.OrekitMessages;

  22. /** Enumerate for the UTC ids.
  23.  * <p>
  24.  * In addition to the ids listed here, Rinex 4.01 table 23 allowed UTC(BIPM) as a
  25.  * possible UTC id for SBAS. This was added in June 2023 and Rinex 4.01 was officially
  26.  * published in July 2023. However, this was quickly removed, in July 2023, i.e. just
  27.  * after publication of Rinex 4.01, as directed by BIPM. It does not appear anymore in
  28.  * Rinex 4.02 which was officially published in October 2024. Due to its transient
  29.  * appearance in the standard, we decided to not include UTC(BIPM) in this enumerate.
  30.  * </p>
  31.  * @author Luc Maisonobe
  32.  * @since 12.0
  33.  */
  34. public enum UtcId {

  35.     /** UTC(USNO). */
  36.     USNO("UTC(USNO)"),

  37.     /** UTC(SU). */
  38.     SU("UTC(SU)"),

  39.     /** UTCGAL. */
  40.     GAL("UTCGAL"),

  41.     /** UTC(NTSC). */
  42.     NTSC("UTC(NTSC)"),

  43.     /** UTC(NICT). */
  44.     NICT("UTC(NICT)"),

  45.     /** UTC(CRL).
  46.      * @since 13.0
  47.      */
  48.     CRL("UTC(CRL)"),

  49.     /** UTC(NIST).
  50.      * @since 13.0
  51.      */
  52.     NIST("UTC(NIST)"),

  53.     /** UTCIRN / UTC(NPLI). */
  54.     IRN("UTCIRN", "UTC(NPLI)"),

  55.     /** UTC(OP). */
  56.     OP("UTC(OP)");

  57.     /** Parsing map. */
  58.     private static final Map<String, UtcId> MAP = new HashMap<>();

  59.     static {
  60.         for (final UtcId utc : values()) {
  61.             for (final String id : utc.ids) {
  62.                 MAP.put(id, utc);
  63.             }
  64.         }
  65.     }

  66.     /** Valid ids. */
  67.     private final String[] ids;

  68.     /** Simple constructor.
  69.      * @param ids valid ids
  70.      */
  71.     UtcId(final String... ids) {
  72.         this.ids = ids.clone();
  73.     }

  74.     /** Parse a string to get the UTC id.
  75.      * @param id string to parse
  76.      * @return the UTC id
  77.      * @exception OrekitIllegalArgumentException if the string does not correspond to a UTC id
  78.      */
  79.     public static UtcId parseUtcId(final String id)
  80.         throws OrekitIllegalArgumentException {
  81.         final UtcId utcId = MAP.get(id);
  82.         if (utcId == null) {
  83.             throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_UTC_ID, id);
  84.         }
  85.         return utcId;
  86.     }

  87. }