FieldGPSAlmanac.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. /**
  22.  * This class holds a GPS almanac as read from SEM or YUMA files.
  23.  *
  24.  * <p>Depending on the source (SEM or YUMA), some fields may be filled in or not.
  25.  * An almanac read from a YUMA file doesn't hold SVN number, average URA and satellite
  26.  * configuration.</p>
  27.  *
  28.  * @param <T> type of the field elements
  29.  * @author Luc Maisonobe
  30.  * @since 13.0
  31.  *
  32.  */
  33. public class FieldGPSAlmanac<T extends CalculusFieldElement<T>>
  34.     extends FieldAbstractAlmanac<T, GPSAlmanac> {

  35.     /** Source of the almanac. */
  36.     private String src;

  37.     /** SVN number. */
  38.     private int svn;

  39.     /** Health status. */
  40.     private int health;

  41.     /** Average URA. */
  42.     private int ura;

  43.     /** Satellite configuration. */
  44.     private int config;

  45.     /** Constructor from non-field instance.
  46.      * @param field    field to which elements belong
  47.      * @param original regular non-field instance
  48.      */
  49.     public FieldGPSAlmanac(final Field<T> field, final GPSAlmanac original) {
  50.         super(field, original);
  51.         setSource(original.getSource());
  52.         setSVN(original.getSVN());
  53.         setHealth(original.getHealth());
  54.         setURA(original.getURA());
  55.         setSatConfiguration(original.getSatConfiguration());
  56.     }

  57.     /** Constructor from different field instance.
  58.      * @param <V> type of the old field elements
  59.      * @param original regular non-field instance
  60.      * @param converter for field elements
  61.      */
  62.     public <V extends CalculusFieldElement<V>> FieldGPSAlmanac(final Function<V, T> converter,
  63.                                                                final FieldGPSAlmanac<V> original) {
  64.         super(converter, original);
  65.         setSource(original.getSource());
  66.         setSVN(original.getSVN());
  67.         setHealth(original.getHealth());
  68.         setURA(original.getURA());
  69.         setSatConfiguration(original.getSatConfiguration());
  70.     }

  71.     /** {@inheritDoc} */
  72.     @Override
  73.     public GPSAlmanac toNonField() {
  74.         return new GPSAlmanac(this);
  75.     }

  76.     /** {@inheritDoc} */
  77.     @SuppressWarnings("unchecked")
  78.     @Override
  79.     public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, GPSAlmanac>>
  80.         G changeField(final Function<T, U> converter) {
  81.         return (G) new FieldGPSAlmanac<>(converter, this);
  82.     }

  83.     /**
  84.      * Setter for the Square Root of Semi-Major Axis (m^1/2).
  85.      * <p>
  86.      * In addition, this method set the value of the Semi-Major Axis.
  87.      * </p>
  88.      * @param sqrtA the Square Root of Semi-Major Axis (m^1/2)
  89.      */
  90.     public void setSqrtA(final T sqrtA) {
  91.         setSma(sqrtA.square());
  92.     }

  93.     /**
  94.      * Gets the source of this GPS almanac.
  95.      * <p>Sources can be SEM or YUMA, when the almanac is read from a file.</p>
  96.      *
  97.      * @return the source of this GPS almanac
  98.      */
  99.     public String getSource() {
  100.         return src;
  101.     }

  102.     /**
  103.      * Sets the source of this GPS almanac.
  104.      *
  105.      * @param source the source of this GPS almanac
  106.      */
  107.     public void setSource(final String source) {
  108.         this.src = source;
  109.     }

  110.     /**
  111.      * Gets the satellite "SVN" reference number.
  112.      *
  113.      * @return the satellite "SVN" reference number
  114.      */
  115.     public int getSVN() {
  116.         return svn;
  117.     }

  118.     /**
  119.      * Sets the "SVN" reference number.
  120.      *
  121.      * @param svnNumber the number to set
  122.      */
  123.     public void setSVN(final int svnNumber) {
  124.         this.svn = svnNumber;
  125.     }

  126.     /**
  127.      * Gets the Health status.
  128.      *
  129.      * @return the Health status
  130.      */
  131.     public int getHealth() {
  132.         return health;
  133.     }

  134.     /**
  135.      * Sets the health status.
  136.      *
  137.      * @param health the health status to set
  138.      */
  139.     public void setHealth(final int health) {
  140.         this.health = health;
  141.     }

  142.     /**
  143.      * Gets the average URA number.
  144.      *
  145.      * @return the average URA number
  146.      */
  147.     public int getURA() {
  148.         return ura;
  149.     }

  150.     /**
  151.      * Sets the average URA number.
  152.      *
  153.      * @param uraNumber the URA number to set
  154.      */
  155.     public void setURA(final int uraNumber) {
  156.         this.ura = uraNumber;
  157.     }

  158.     /**
  159.      * Gets the satellite configuration.
  160.      *
  161.      * @return the satellite configuration
  162.      */
  163.     public int getSatConfiguration() {
  164.         return config;
  165.     }

  166.     /**
  167.      * Sets the satellite configuration.
  168.      *
  169.      * @param satConfiguration the satellite configuration to set
  170.      */
  171.     public void setSatConfiguration(final int satConfiguration) {
  172.         this.config = satConfiguration;
  173.     }

  174. }