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