FieldCommonGnssData.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.propagation.analytical.gnss.data;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;

  20. import java.util.function.Function;

  21. /** Container for common GNSS data contained in almanac and navigation messages.
  22.  * @param <T> type of the field elements
  23.  * @param <O> type of the orbital elements (non-field version)
  24.  * @author Luc Maisonobe
  25.  * @since 13.0
  26.  */
  27. public abstract class FieldCommonGnssData<T extends CalculusFieldElement<T>,
  28.                                           O extends CommonGnssData<O>>
  29.     extends FieldGnssOrbitalElements<T, O>
  30.     implements FieldGNSSClockElements<T> {

  31.     /** SV zero-th order clock correction (s). */
  32.     private T af0;

  33.     /** SV first order clock correction (s/s). */
  34.     private T af1;

  35.     /** SV second order clock correction (s/s²). */
  36.     private T af2;

  37.     /** Group delay differential TGD for L1-L2 correction. */
  38.     private T tgd;

  39.     /** Time Of Clock. */
  40.     private T toc;

  41.     /** Constructor from non-field instance.
  42.      * @param field    field to which elements belong
  43.      * @param original regular non-field instance
  44.      */
  45.     protected FieldCommonGnssData(final Field<T> field, final O original) {
  46.         super(field, original);
  47.         setAf0(field.getZero().newInstance(original.getAf0()));
  48.         setAf1(field.getZero().newInstance(original.getAf1()));
  49.         setAf2(field.getZero().newInstance(original.getAf2()));
  50.         setTGD(field.getZero().newInstance(original.getTGD()));
  51.         setToc(field.getZero().newInstance(original.getToc()));
  52.     }

  53.     /** Constructor from different field instance.
  54.      * @param <V> type of the old field elements
  55.      * @param original regular non-field instance
  56.      * @param converter for field elements
  57.      */
  58.     protected <V extends CalculusFieldElement<V>> FieldCommonGnssData(final Function<V, T> converter,
  59.                                                                       final FieldCommonGnssData<V, O> original) {
  60.         super(converter, original);
  61.         setAf0(converter.apply(original.getAf0()));
  62.         setAf1(converter.apply(original.getAf1()));
  63.         setAf2(converter.apply(original.getAf2()));
  64.         setTGD(converter.apply(original.getTGD()));
  65.         setToc(converter.apply(original.getToc()));
  66.     }

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public T getAf0() {
  70.         return af0;
  71.     }

  72.     /**
  73.      * Setter for the SV Clock Bias Correction Coefficient (s).
  74.      * @param af0 the SV Clock Bias Correction Coefficient to set
  75.      */
  76.     public void setAf0(final T af0) {
  77.         this.af0 = af0;
  78.     }

  79.     /** {@inheritDoc} */
  80.     @Override
  81.     public T getAf1() {
  82.         return af1;
  83.     }

  84.     /**
  85.      * Setter for the SV Clock Drift Correction Coefficient (s/s).
  86.      * @param af1 the SV Clock Drift Correction Coefficient to set
  87.      */
  88.     public void setAf1(final T af1) {
  89.         this.af1 = af1;
  90.     }

  91.     /** {@inheritDoc} */
  92.     @Override
  93.     public T getAf2() {
  94.         return af2;
  95.     }

  96.     /**
  97.      * Setter for the Drift Rate Correction Coefficient (s/s²).
  98.      * @param af2 the Drift Rate Correction Coefficient to set
  99.      */
  100.     public void setAf2(final T af2) {
  101.         this.af2 = af2;
  102.     }

  103.     /**
  104.      * Set the estimated group delay differential TGD for L1-L2 correction.
  105.      * @param groupDelayDifferential the estimated group delay differential TGD for L1-L2 correction (s)
  106.      */
  107.     public void setTGD(final T groupDelayDifferential) {
  108.         this.tgd = groupDelayDifferential;
  109.     }

  110.     /** {@inheritDoc} */
  111.     @Override
  112.     public T getTGD() {
  113.         return tgd;
  114.     }

  115.     /**
  116.      * Set the time of clock.
  117.      * @param toc the time of clock (s)
  118.      * @see #getAf0()
  119.      * @see #getAf1()
  120.      * @see #getAf2()
  121.      */
  122.     public void setToc(final T toc) {
  123.         this.toc = toc;
  124.     }

  125.     /** {@inheritDoc} */
  126.     @Override
  127.     public T getToc() {
  128.         return toc;
  129.     }

  130. }