1   /* Copyright 2002-2025 CS GROUP
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;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.orekit.annotation.DefaultDataContext;
21  import org.orekit.attitudes.AttitudeProvider;
22  import org.orekit.attitudes.FrameAlignedProvider;
23  import org.orekit.data.DataContext;
24  import org.orekit.frames.Frame;
25  import org.orekit.frames.Frames;
26  import org.orekit.propagation.Propagator;
27  import org.orekit.propagation.analytical.gnss.data.FieldGnssOrbitalElements;
28  import org.orekit.utils.IERSConventions;
29  
30  /**
31   * This nested class aims at building a GNSSPropagator.
32   * <p>It implements the classical builder pattern.</p>
33   * @param <T> type of the field elements
34   * @author Pascal Parraud
35   * @since 13.0
36   */
37  public class FieldGnssPropagatorBuilder<T extends CalculusFieldElement<T>> {
38  
39      /** The GNSS propagation model orbital elements. */
40      private final FieldGnssOrbitalElements<T, ?> orbitalElements;
41  
42      /** The attitude provider. */
43      private AttitudeProvider attitudeProvider;
44  
45      /** The mass. */
46      private T mass;
47  
48      /** The ECI frame. */
49      private Frame eci;
50  
51      /** The ECEF frame. */
52      private Frame ecef;
53  
54      /**
55       * Initializes the builder.
56       * <p>The GNSS orbital elements is the only requested parameter to build a GNSSPropagator.</p>
57       * <p>The attitude provider is set by default to be aligned with the EME2000 frame.<br>
58       * The mass is set by default to the
59       *  {@link Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
60       * The ECI frame is set by default to the
61       *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
62       *  context.<br>
63       * The ECEF frame is set by default to the
64       *  {@link org.orekit.frames.Predefined#ITRF_CIO_CONV_2010_SIMPLE_EOP
65       *  CIO/2010-based ITRF simple EOP} in the default data context.
66       * </p>
67       *
68       * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
69       * Another data context can be set using
70       * {@code Builder(final GNSSOrbitalElements gpsOrbElt, final Frames frames)}</p>
71       *
72       * @param orbitalElements the GNSS orbital elements to be used by the propagator.
73       * @see #attitudeProvider(AttitudeProvider provider)
74       * @see #mass(CalculusFieldElement mass)
75       * @see #eci(Frame inertial)
76       * @see #ecef(Frame bodyFixed)
77       */
78      @DefaultDataContext
79      public FieldGnssPropagatorBuilder(final FieldGnssOrbitalElements<T, ?> orbitalElements) {
80          this(orbitalElements, DataContext.getDefault().getFrames());
81      }
82  
83      /** Initializes the builder.
84       * <p>The GNSS orbital elements is the only requested parameter to build a GNSSPropagator.</p>
85       * <p>The attitude provider is set by default to be aligned with the EME2000 frame.<br>
86       * The mass is set by default to the
87       *  {@link Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
88       * The ECI frame is set by default to the
89       *  {@link Frames#getEME2000() EME2000 frame}.<br>
90       * The ECEF frame is set by default to the
91       *  {@link Frames#getITRF(IERSConventions, boolean)} CIO/2010-based ITRF simple EOP}.
92       * </p>
93       *
94       * @see #attitudeProvider(AttitudeProvider provider)
95       * @param orbitalElements orbital elements
96       * @param frames set of frames to use.
97       * @see #attitudeProvider(AttitudeProvider provider)
98       * @see #mass(CalculusFieldElement mass)
99       * @see #eci(Frame inertial)
100      * @see #ecef(Frame bodyFixed)
101      */
102     public FieldGnssPropagatorBuilder(final FieldGnssOrbitalElements<T, ?> orbitalElements, final Frames frames) {
103         this.orbitalElements  = orbitalElements;
104         this.mass             = orbitalElements.getMu().newInstance(Propagator.DEFAULT_MASS);
105         this.eci              = frames.getEME2000();
106         this.ecef             = frames.getITRF(IERSConventions.IERS_2010, true);
107         this.attitudeProvider = FrameAlignedProvider.of(this.eci);
108     }
109 
110     /** Sets the attitude provider.
111      *
112      * @param userProvider the attitude provider
113      * @return the updated builder
114      */
115     public FieldGnssPropagatorBuilder<T> attitudeProvider(final AttitudeProvider userProvider) {
116         this.attitudeProvider = userProvider;
117         return this;
118     }
119 
120     /** Sets the mass.
121      *
122      * @param userMass the mass (in kg)
123      * @return the updated builder
124      */
125     public FieldGnssPropagatorBuilder<T> mass(final T userMass) {
126         this.mass = userMass;
127         return this;
128     }
129 
130     /** Sets the Earth Centered Inertial frame used for propagation.
131      *
132      * @param inertial the ECI frame
133      * @return the updated builder
134      */
135     public FieldGnssPropagatorBuilder<T> eci(final Frame inertial) {
136         this.eci = inertial;
137         return this;
138     }
139 
140     /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
141      *
142      * @param bodyFixed the ECEF frame
143      * @return the updated builder
144      */
145     public FieldGnssPropagatorBuilder<T> ecef(final Frame bodyFixed) {
146         this.ecef = bodyFixed;
147         return this;
148     }
149 
150     /** Finalizes the build.
151      *
152      * @return the built GNSSPropagator
153      */
154     public FieldGnssPropagator<T> build() {
155         return new FieldGnssPropagator<>(orbitalElements, eci, ecef, attitudeProvider, mass);
156     }
157 
158 }