FieldAbstractNavigationMessage.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 org.hipparchus.util.FastMath;
  21. import org.orekit.time.FieldAbsoluteDate;

  22. import java.util.function.Function;

  23. /**
  24.  * Base class for GNSS navigation messages.
  25.  * @param <T> type of the field elements
  26.  * @param <O> type of the orbital elements (non-field version)
  27.  * @author Luc Maisonobe
  28.  * @since 13.0
  29.  *
  30.  * @see FieldGPSLegacyNavigationMessage
  31.  * @see FieldGalileoNavigationMessage
  32.  * @see FieldBeidouLegacyNavigationMessage
  33.  * @see FieldQZSSLegacyNavigationMessage
  34.  * @see FieldNavicLegacyNavigationMessage
  35.  */
  36. public abstract class FieldAbstractNavigationMessage<T extends CalculusFieldElement<T>,
  37.                                                      O extends AbstractNavigationMessage<O>>
  38.     extends FieldAbstractAlmanac<T, O> {

  39.     /** Mean Motion Difference from Computed Value. */
  40.     private T deltaN0;

  41.     /** Time of clock epoch. */
  42.     private FieldAbsoluteDate<T> epochToc;

  43.     /** Transmission time. */
  44.     private T transmissionTime;

  45.     /** Constructor from non-field instance.
  46.      * @param field    field to which elements belong
  47.      * @param original regular non-field instance
  48.      */
  49.     protected FieldAbstractNavigationMessage(final Field<T> field, final O original) {
  50.         super(field, original);
  51.         setDeltaN0(field.getZero().newInstance(original.getDeltaN0()));
  52.         setEpochToc(new FieldAbsoluteDate<>(field, original.getEpochToc()));
  53.         setTransmissionTime(field.getZero().newInstance(original.getTransmissionTime()));
  54.     }

  55.     /** Constructor from different field instance.
  56.      * @param <V> type of the old field elements
  57.      * @param original regular non-field instance
  58.      * @param converter for field elements
  59.      */
  60.     protected <V extends CalculusFieldElement<V>> FieldAbstractNavigationMessage(final Function<V, T> converter,
  61.                                                                                  final FieldAbstractNavigationMessage<V, O> original) {
  62.         super(converter, original);
  63.         setDeltaN0(converter.apply(original.getDeltaN0()));
  64.         setEpochToc(new FieldAbsoluteDate<>(getMu().getField(), original.getEpochToc().toAbsoluteDate()));
  65.         setTransmissionTime(converter.apply(original.getTransmissionTime()));
  66.     }

  67.     /**
  68.      * Getter for Square Root of Semi-Major Axis (√m).
  69.      * @return Square Root of Semi-Major Axis (√m)
  70.      */
  71.     public T getSqrtA() {
  72.         return FastMath.sqrt(getSma());
  73.     }

  74.     /**
  75.      * Setter for the Square Root of Semi-Major Axis (√m).
  76.      * <p>
  77.      * In addition, this method set the value of the Semi-Major Axis.
  78.      * </p>
  79.      * @param sqrtA the Square Root of Semi-Major Axis (√m)
  80.      */
  81.     public void setSqrtA(final T sqrtA) {
  82.         setSma(sqrtA.square());
  83.     }

  84.     /** {@inheritDoc} */
  85.     @Override
  86.     public T getDeltaN0() {
  87.         return deltaN0;
  88.     }

  89.     /**
  90.      * Setter for the delta of satellite mean motion.
  91.      * @param deltaN0 the value to set
  92.      */
  93.     public void setDeltaN0(final T deltaN0) {
  94.         this.deltaN0 = deltaN0;
  95.     }

  96.     /**
  97.      * Getter for the time of clock epoch.
  98.      * @return the time of clock epoch
  99.      */
  100.     public FieldAbsoluteDate<T> getEpochToc() {
  101.         return epochToc;
  102.     }

  103.     /**
  104.      * Setter for the time of clock epoch.
  105.      * @param epochToc the epoch to set
  106.      */
  107.     public void setEpochToc(final FieldAbsoluteDate<T> epochToc) {
  108.         this.epochToc = epochToc;
  109.     }

  110.     /**
  111.      * Getter for transmission time.
  112.      * @return transmission time
  113.      */
  114.     public T getTransmissionTime() {
  115.         return transmissionTime;
  116.     }

  117.     /**
  118.      * Setter for transmission time.
  119.      * @param transmissionTime transmission time
  120.      */
  121.     public void setTransmissionTime(final T transmissionTime) {
  122.         this.transmissionTime = transmissionTime;
  123.     }

  124. }