BiasDescriptionPredicate.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.sinex;

  18. import org.orekit.gnss.TimeSystem;

  19. import java.util.function.Predicate;

  20. /** Predicates for bias description blocks.
  21.  * @author Luc Maisonobe
  22.  * @since 13.0
  23.  */
  24. enum BiasDescriptionPredicate implements Predicate<SinexBiasParseInfo> {

  25.     /** Predicate for OBSERVATION_SAMPLING line. */
  26.     OBSERVATION_SAMPLING {
  27.         /** {@inheritDoc} */
  28.         @Override
  29.         protected void store(final SinexBiasParseInfo parseInfo) {
  30.             parseInfo.getDescription().setObservationSampling(parseInfo.parseInt(41, 12));
  31.         }
  32.     },

  33.     /** Predicate for PARAMETER_SPACING line. */
  34.     PARAMETER_SPACING {
  35.         /** {@inheritDoc} */
  36.         @Override
  37.         protected void store(final SinexBiasParseInfo parseInfo) {
  38.             parseInfo.getDescription().setParameterSpacing(parseInfo.parseInt(41, 12));
  39.         }
  40.     },

  41.     /** Predicate for DETERMINATION_METHOD line. */
  42.     DETERMINATION_METHOD {
  43.         /** {@inheritDoc} */
  44.         @Override
  45.         protected void store(final SinexBiasParseInfo parseInfo) {
  46.             parseInfo.getDescription().setDeterminationMethod(parseInfo.parseString(41, 39));
  47.         }
  48.     },

  49.     /** Predicate for BIAS_MODE line. */
  50.     BIAS_MODE {
  51.         /** {@inheritDoc} */
  52.         @Override
  53.         protected void store(final SinexBiasParseInfo parseInfo) {
  54.             parseInfo.getDescription().setBiasMode(parseInfo.parseString(41, 39));
  55.         }
  56.     },

  57.     /** Predicate for TIME_SYSTEM line. */
  58.     TIME_SYSTEM {
  59.         /** {@inheritDoc} */
  60.         @Override
  61.         protected void store(final SinexBiasParseInfo parseInfo) {
  62.             final String ts = parseInfo.parseString(41, 3);
  63.             if ("UTC".equals(ts)) {
  64.                 parseInfo.setTimeSystem(TimeSystem.UTC);
  65.             } else if ("TAI".equals(ts)) {
  66.                 parseInfo.setTimeSystem(TimeSystem.TAI);
  67.             } else {
  68.                 parseInfo.setTimeSystem(TimeSystem.parseOneLetterCode(ts));
  69.             }
  70.         }
  71.     };

  72.     /** {@inheritDoc} */
  73.     @Override
  74.     public boolean test(final SinexBiasParseInfo parseInfo) {
  75.         if (name().equals(parseInfo.parseString(1, 39))) {
  76.             // this is the data type we are concerned with
  77.             store(parseInfo);
  78.             return true;
  79.         } else {
  80.             // it is a data type for another predicate
  81.             return false;
  82.         }
  83.     }

  84.     /** Store parsed fields.
  85.      * @param parseInfo container for parse info
  86.      */
  87.     protected abstract void store(SinexBiasParseInfo parseInfo);

  88. }