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.GLONASSAlmanac;
27  import org.orekit.propagation.analytical.gnss.data.GLONASSNavigationMessage;
28  import org.orekit.propagation.analytical.gnss.data.GLONASSOrbitalElements;
29  import org.orekit.utils.IERSConventions;
30  
31  /**
32   * This nested class aims at building a GLONASSAnalyticalPropagator.
33   * <p>It implements the classical builder pattern.</p>
34   * <p>
35   * <b>Caution:</b> The Glonass analytical propagator can only be used with {@link GLONASSAlmanac}.
36   * Using this propagator with a {@link GLONASSNavigationMessage} is prone to error.
37   * </p>
38   * @author Bryan Cazabonne
39   * @since 11.0
40   */
41  public class GLONASSAnalyticalPropagatorBuilder {
42  
43      //////////
44      // Required parameter
45      //////////
46  
47      /** The GLONASS orbital elements. */
48      private final GLONASSOrbitalElements orbit;
49  
50      ///////////
51      // Optional parameters
52      //////////
53  
54      /** The attitude provider. */
55      private AttitudeProvider attitudeProvider;
56  
57      /** The mass. */
58      private double mass;
59  
60      /** The ECI frame. */
61      private Frame eci;
62  
63      /** The ECEF frame. */
64      private Frame ecef;
65  
66      /** Data context. */
67      private DataContext dataContext;
68  
69      /** Initializes the builder.
70       * <p>The GLONASS orbital elements is the only requested parameter to build a GLONASSAnalyticalPropagator.</p>
71       * <p>The attitude provider is set by default to be aligned with the EME2000 frame.<br>
72       * The mass is set by default to the
73       *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
74       * The data context is by default to the
75       *  {@link DataContext#getDefault() default data context}.<br>
76       * The ECI frame is set by default to the
77       *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
78       *  context.<br>
79       * The ECEF frame is set by default to the
80       *  {@link org.orekit.frames.Predefined#ITRF_CIO_CONV_2010_SIMPLE_EOP
81       *  CIO/2010-based ITRF simple EOP} in the default data context.
82       * </p>
83       *
84       * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
85       * Another data context can be set using
86       * {@code Builder(final GLONASSOrbitalElements gpsOrbElt, final DataContext dataContext)}</p>
87       *
88       * @param glonassOrbElt the GLONASS orbital elements to be used by the GLONASS analytical propagator.
89       * @see #attitudeProvider(AttitudeProvider provider)
90       * @see #mass(double mass)
91       * @see #eci(Frame inertial)
92       * @see #ecef(Frame bodyFixed)
93       */
94      @DefaultDataContext
95      public GLONASSAnalyticalPropagatorBuilder(final GLONASSOrbitalElements glonassOrbElt) {
96          this(glonassOrbElt, DataContext.getDefault());
97      }
98  
99      /** Initializes the builder.
100      * <p>The GLONASS orbital elements is the only requested parameter to build a GLONASSAnalyticalPropagator.</p>
101      * <p>The attitude provider is set by default to be aligned with the EME2000 frame.<br>
102      * The mass is set by default to the
103      *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
104      * The ECI frame is set by default to the
105      *  {@link Frames#getEME2000() EME2000 frame}.<br>
106      * The ECEF frame is set by default to the
107      *  {@link Frames#getITRF(IERSConventions, boolean) CIO/2010-based ITRF simple
108      *  EOP}.
109      * </p>
110      *
111      * @param glonassOrbElt the GLONASS orbital elements to be used by the GLONASS propagator.
112      * @param dataContext the data context to use for frames and time scales.
113      * @see #attitudeProvider(AttitudeProvider provider)
114      * @see #mass(double mass)
115      * @see #eci(Frame inertial)
116      * @see #ecef(Frame bodyFixed)
117      * @since 10.1
118      */
119     public GLONASSAnalyticalPropagatorBuilder(final GLONASSOrbitalElements glonassOrbElt,
120                                               final DataContext dataContext) {
121         this.orbit            = glonassOrbElt;
122         this.dataContext      = dataContext;
123         this.mass             = Propagator.DEFAULT_MASS;
124         final Frames frames   = dataContext.getFrames();
125         this.eci              = frames.getEME2000();
126         this.ecef             = frames.getITRF(IERSConventions.IERS_2010, true);
127         this.attitudeProvider = FrameAlignedProvider.of(this.eci);
128     }
129 
130     /** Sets the attitude provider.
131      *
132      * @param userProvider the attitude provider
133      * @return the updated builder
134      */
135     public GLONASSAnalyticalPropagatorBuilder attitudeProvider(final AttitudeProvider userProvider) {
136         this.attitudeProvider = userProvider;
137         return this;
138     }
139 
140     /** Sets the mass.
141      *
142      * @param userMass the mass (in kg)
143      * @return the updated builder
144      */
145     public GLONASSAnalyticalPropagatorBuilder mass(final double userMass) {
146         this.mass = userMass;
147         return this;
148     }
149 
150     /** Sets the Earth Centered Inertial frame used for propagation.
151      *
152      * @param inertial the ECI frame
153      * @return the updated builder
154      */
155     public GLONASSAnalyticalPropagatorBuilder eci(final Frame inertial) {
156         this.eci = inertial;
157         return this;
158     }
159 
160     /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
161      *
162      * @param bodyFixed the ECEF frame
163      * @return the updated builder
164      */
165     public GLONASSAnalyticalPropagatorBuilder ecef(final Frame bodyFixed) {
166         this.ecef = bodyFixed;
167         return this;
168     }
169 
170     /** Sets the data context used by the propagator. Does not update the ECI or ECEF
171      * frames which must be done separately using {@link #eci(Frame)} and {@link
172      * #ecef(Frame)}.
173      *
174      * @param context used for propagation.
175      * @return the updated builder.
176      */
177     public GLONASSAnalyticalPropagatorBuilder dataContext(final DataContext context) {
178         this.dataContext = context;
179         return this;
180     }
181 
182     /** Finalizes the build.
183      *
184      * @return the built GLONASSPropagator
185      */
186     public GLONASSAnalyticalPropagator build() {
187         return new GLONASSAnalyticalPropagator(orbit, eci, ecef, attitudeProvider, mass, dataContext);
188     }
189 
190 }