SinexBiasParseInfo.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.ObservationType;
  19. import org.orekit.gnss.SatInSystem;
  20. import org.orekit.gnss.SatelliteSystem;
  21. import org.orekit.gnss.TimeSystem;
  22. import org.orekit.time.TimeScales;

  23. import java.util.HashMap;
  24. import java.util.Map;
  25. import java.util.function.BiFunction;

  26. /** Parse information for Solution INdependent EXchange (SINEX) bias files.
  27.  * @author Luc Maisonobe
  28.  * @since 13.0
  29.  */
  30. public class SinexBiasParseInfo extends ParseInfo<SinexBias> {

  31.     /** Mapper from satellite system and string to observation type. */
  32.     private final BiFunction<? super SatelliteSystem, ? super String, ? extends ObservationType> typeBuilder;

  33.     /** DSB description. */
  34.     private final BiasDescription description;

  35.     /** DSB data. */
  36.     private final Map<String, StationDifferentialSignalBias> stationsDsb;

  37.     /** DSB data. */
  38.     private final Map<SatInSystem, SatelliteDifferentialSignalBias> satellitesDsb;

  39.     /** OSB data. */
  40.     private final Map<String, StationObservableSpecificSignalBias> stationsOsb;

  41.     /** OSB data. */
  42.     private final Map<SatInSystem, SatelliteObservableSpecificSignalBias> satellitesOsb;

  43.     /** Simple constructor.
  44.      * @param timeScales time scales
  45.      * @param typeBuilder mapper from string to observation type
  46.      */
  47.     SinexBiasParseInfo(final TimeScales timeScales,
  48.                        final BiFunction<? super SatelliteSystem, ? super String, ? extends ObservationType> typeBuilder) {
  49.         super(timeScales);
  50.         this.description   = new BiasDescription();
  51.         this.stationsDsb   = new HashMap<>();
  52.         this.satellitesDsb = new HashMap<>();
  53.         this.stationsOsb   = new HashMap<>();
  54.         this.satellitesOsb = new HashMap<>();
  55.         this.typeBuilder   = typeBuilder;
  56.     }

  57.     /** Get description.
  58.      * @return description
  59.      */
  60.     BiasDescription getDescription() {
  61.         return description;
  62.     }

  63.     /** Get satellite DSB.
  64.      * @param satellite satellite identifier
  65.      * @return satellite DSB
  66.      */
  67.     SatelliteDifferentialSignalBias getSatelliteDsb(final SatInSystem satellite) {
  68.         return satellitesDsb.computeIfAbsent(satellite, SatelliteDifferentialSignalBias::new);
  69.     }

  70.     /** Get station DSB.
  71.      * @param siteCode station site code
  72.      * @return station DSB
  73.      */
  74.     StationDifferentialSignalBias getStationDsb(final String siteCode) {
  75.         return stationsDsb.computeIfAbsent(siteCode, StationDifferentialSignalBias::new);
  76.     }

  77.     /** Get satellite OSB.
  78.      * @param satellite satellite identifier
  79.      * @return satellite OSB
  80.      */
  81.     SatelliteObservableSpecificSignalBias getSatelliteOsb(final SatInSystem satellite) {
  82.         return satellitesOsb.computeIfAbsent(satellite, SatelliteObservableSpecificSignalBias::new);
  83.     }

  84.     /** Get station OSB.
  85.      * @param siteCode station site code
  86.      * @return station OSB
  87.      */
  88.     StationObservableSpecificSignalBias getStationOsb(final String siteCode) {
  89.         return stationsOsb.computeIfAbsent(siteCode, StationObservableSpecificSignalBias::new);
  90.     }

  91.     /** Set time system.
  92.      * @param timeSystem time system
  93.      */
  94.     void setTimeSystem(final TimeSystem timeSystem) {
  95.         getDescription().setTimeSystem(timeSystem);
  96.         setTimeScale(timeSystem.getTimeScale(getTimeScales()));
  97.     }

  98.     /** Extract an observation type from current line.
  99.      * @param system satellite system
  100.      * @param start  start index of the string
  101.      * @param length length of the string
  102.      * @return parsed observation type (null if field is empty)
  103.      */
  104.     protected ObservationType parseObservationType(final SatelliteSystem system, final int start, final int length) {
  105.         final String type = parseString(start, length);
  106.         return type.isEmpty() ? null : typeBuilder.apply(system, type);
  107.     }

  108.     /** {@inheritDoc} */
  109.     @Override
  110.     protected SinexBias build() {
  111.         return new SinexBias(getTimeScales(), getCreationDate(), getStartDate(), getEndDate(),
  112.                              description, stationsDsb, satellitesDsb, stationsOsb, satellitesOsb);
  113.     }

  114. }