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  
19  import org.hipparchus.CalculusFieldElement;
20  import org.hipparchus.Field;
21  
22  import java.util.function.Function;
23  
24  /**
25   * This class holds a QZSS almanac as read from YUMA files.
26   *
27   * @param <T> type of the field elements
28   * @author Luc Maisonobe
29   * @since 13.0
30   *
31   */
32  public class FieldQZSSAlmanac<T extends CalculusFieldElement<T>>
33      extends FieldAbstractAlmanac<T, QZSSAlmanac> {
34  
35      /** Source of the almanac. */
36      private String src;
37  
38      /** Health status. */
39      private int health;
40  
41      /** Constructor from non-field instance.
42       * @param field    field to which elements belong
43       * @param original regular non-field instance
44       */
45      public FieldQZSSAlmanac(final Field<T> field, final QZSSAlmanac original) {
46          super(field, original);
47          setSource(original.getSource());
48          setHealth(original.getHealth());
49      }
50  
51      /** Constructor from different field instance.
52       * @param <V> type of the old field elements
53       * @param original regular non-field instance
54       * @param converter for field elements
55       */
56      public <V extends CalculusFieldElement<V>> FieldQZSSAlmanac(final Function<V, T> converter,
57                                                                  final FieldQZSSAlmanac<V> original) {
58          super(converter, original);
59          setSource(original.getSource());
60          setHealth(original.getHealth());
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public QZSSAlmanac toNonField() {
66          return new QZSSAlmanac(this);
67      }
68  
69      /** {@inheritDoc} */
70      @SuppressWarnings("unchecked")
71      @Override
72      public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, QZSSAlmanac>>
73          G changeField(final Function<T, U> converter) {
74          return (G) new FieldQZSSAlmanac<>(converter, this);
75      }
76  
77      /**
78       * Setter for the Square Root of Semi-Major Axis (m^1/2).
79       * <p>
80       * In addition, this method set the value of the Semi-Major Axis.
81       * </p>
82       * @param sqrtA the Square Root of Semi-Major Axis (m^1/2)
83       */
84      public void setSqrtA(final T sqrtA) {
85          setSma(sqrtA.square());
86      }
87  
88      /**
89       * Gets the source of this QZSS almanac.
90       *
91       * @return the source of this QZSS almanac
92       */
93      public String getSource() {
94          return src;
95      }
96  
97      /**
98       * Sets the source of this GPS almanac.
99       *
100      * @param source the source of this GPS almanac
101      */
102     public void setSource(final String source) {
103         this.src = source;
104     }
105 
106     /**
107      * Gets the Health status.
108      *
109      * @return the Health status
110      */
111     public int getHealth() {
112         return health;
113     }
114 
115     /**
116      * Sets the health status.
117      *
118      * @param health the health status to set
119      */
120     public void setHealth(final int health) {
121         this.health = health;
122     }
123 
124 }