DataUsed.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.sp3;

  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 data used.
  23.  * @author Luc Maisonobe
  24.  * @since 12.0
  25.  */
  26. public enum DataUsed {

  27.     /** Undifferenciated carrier phase. */
  28.     UNDIFFERENTIATED_CARRIER_PHASE("u"),

  29.     /** Change in undifferenciated carrier phase. */
  30.     CHANGE_IN_UNDIFFERENTIATED_CARRIER_PHASE("du"),

  31.     /** 2-receiver/1-satellite carrier phase. */
  32.     TWO_RECEIVER_ONE_SATELLITE_CARRIER_PHASE("s"),

  33.     /** Change in 2-receiver/1-satellite carrier phase. */
  34.     CHANGE_IN_TWO_RECEIVER_ONE_SATELLITE_CARRIER_PHASE("ds"),

  35.     /** 2-receiver/2-satellite carrier phase. */
  36.     TWO_RECEIVER_TWO_SATELLITE_CARRIER_PHASE("d"),

  37.     /** Change in 2-receiver/2-satellite carrier phase. */
  38.     CHANGE_IN_TWO_RECEIVER_TWO_SATELLITE_CARRIER_PHASE("dd"),

  39.     /** Undifferenciated code phase. */
  40.     UNDIFFERENTIATED_CODE_PHASE("U"),

  41.     /** Change in undifferenciated code phase. */
  42.     CHANGE_IN_UNDIFFERENTIATED_CODE_PHASE("dU"),

  43.     /** 2-receiver/1-satellite code phase. */
  44.     TWO_RECEIVER_ONE_SATELLITE_CODE_PHASE("S"),

  45.     /** Change in 2-receiver/1-satellite code phase. */
  46.     CHANGE_IN_TWO_RECEIVER_ONE_SATELLITE_CODE_PHASE("dS"),

  47.     /** 2-receiver/2-satellite code phase. */
  48.     TWO_RECEIVER_TWO_SATELLITE_CODE_PHASE("D"),

  49.     /** Change in 2-receiver/2-satellite code phase. */
  50.     CHANGE_IN_TWO_RECEIVER_TWO_SATELLITE_CODE_PHASE("dD"),

  51.     /** Satellite Laser Ranging. */
  52.     SATELLITE_LASER_RANGING("SLR"),

  53.     /** Mixed data. */
  54.     MIXED("mixed"),

  55.     /** Orbit data. */
  56.     ORBIT("ORBIT");

  57.     /** Numbers map. */
  58.     private static final Map<String, DataUsed> MAP = new HashMap<>();
  59.     static {
  60.         for (final DataUsed dataUsed : values()) {
  61.             MAP.put(dataUsed.getKey(), dataUsed);
  62.         }
  63.     }

  64.     /** Key for the data used. */
  65.     private final String key;

  66.     /** Simple constructor.
  67.      * @param key for the data used
  68.      */
  69.     DataUsed(final String key) {
  70.         this.key = key;
  71.     }

  72.     /** Get the key for the data used.
  73.      * @return key for the data used
  74.      */
  75.     public String getKey() {
  76.         return key;
  77.     }

  78.     /** Parse the string to get the data used.
  79.      * @param s string to parse
  80.      * @param fileName file name to generate the error message
  81.      * @param version format version
  82.      * @return the data used corresponding to the string
  83.      * @exception IllegalArgumentException if the string does not correspond to a data used
  84.      */
  85.     public static DataUsed parse(final String s, final String fileName, final char version) {
  86.         final DataUsed dataUsed = MAP.get(s);
  87.         if (dataUsed == null) {
  88.             throw new OrekitIllegalArgumentException(OrekitMessages.SP3_INVALID_HEADER_ENTRY, "data used", s, fileName, version);
  89.         }
  90.         return dataUsed;
  91.     }

  92. }