1   /* Copyright 2002-2021 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.attitudes.AttitudeProvider;
20  import org.orekit.attitudes.InertialProvider;
21  import org.orekit.frames.Frame;
22  import org.orekit.frames.Frames;
23  import org.orekit.propagation.Propagator;
24  import org.orekit.propagation.analytical.gnss.data.GNSSConstants;
25  import org.orekit.propagation.analytical.gnss.data.SBASOrbitalElements;
26  import org.orekit.utils.IERSConventions;
27  
28  /**
29   * This nested class aims at building a SBASPropagator.
30   * <p>It implements the classical builder pattern.</p>
31   * @since 11.0
32   * @author Bryan Cazabonne
33   */
34  public class SBASPropagatorBuilder {
35  
36      /** The SBAS orbital elements. */
37      private final SBASOrbitalElements orbit;
38  
39      /** The Earth gravity coefficient used for SBAS propagation. */
40      private double mu;
41  
42      /** The attitude provider. */
43      private AttitudeProvider attitudeProvider;
44  
45      /** The mass. */
46      private double mass;
47  
48      /** The ECI frame. */
49      private Frame eci;
50  
51      /** The ECEF frame. */
52      private Frame ecef;
53  
54      /** Initializes the builder.
55       * <p>The SBAS orbital elements is the only requested parameter to build a SBASPropagator.</p>
56       * <p>The attitude provider is set by default be aligned with the EME2000 frame.<br>
57       * The Earth gravity coefficient is set by default to the
58       *  {@link org.orekit.propagation.analytical.gnss.data.GNSSConstants#SBAS_MU SBAS_MU}.<br>
59       * The mass is set by default to the
60       *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
61       * The ECI frame is set by default to the
62       *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame}.<br>
63       * The ECEF frame is set by default to the
64       *  {@link org.orekit.frames.Predefined#ITRF_CIO_CONV_2010_SIMPLE_EOP CIO/2010-based ITRF simple EOP}.
65       * </p>
66       *
67       * @param sbasOrbElt the SBAS orbital elements to be used by the SBAS propagator.
68       * @param frames     set of reference frames to use to initialize {@link
69       *                   #ecef(Frame)}, {@link #eci(Frame)}, and {@link
70       *                   #attitudeProvider(AttitudeProvider)}.
71       * @see #attitudeProvider(AttitudeProvider provider)
72       * @see #mu(double coefficient)
73       * @see #mass(double mass)
74       * @see #eci(Frame inertial)
75       * @see #ecef(Frame bodyFixed)
76       */
77      public SBASPropagatorBuilder(final SBASOrbitalElements sbasOrbElt, final Frames frames) {
78          this.orbit = sbasOrbElt;
79          this.mass  = Propagator.DEFAULT_MASS;
80          this.eci   = frames.getEME2000();
81          this.ecef  = frames.getITRF(IERSConventions.IERS_2010, true);
82          this.mu    = GNSSConstants.SBAS_MU;
83          this.attitudeProvider = new InertialProvider(eci);
84      }
85  
86      /** Sets the attitude provider.
87       *
88       * @param userProvider the attitude provider
89       * @return the updated builder
90       */
91      public SBASPropagatorBuilder attitudeProvider(final AttitudeProvider userProvider) {
92          this.attitudeProvider = userProvider;
93          return this;
94      }
95  
96      /** Sets the Earth gravity coefficient.
97      *
98      * @param coefficient the Earth gravity coefficient
99      * @return the updated builder
100     */
101     public SBASPropagatorBuilder mu(final double coefficient) {
102         this.mu = coefficient;
103         return this;
104     }
105 
106     /** Sets the mass.
107      *
108      * @param userMass the mass (in kg)
109      * @return the updated builder
110      */
111     public SBASPropagatorBuilder mass(final double userMass) {
112         this.mass = userMass;
113         return this;
114     }
115 
116     /** Sets the Earth Centered Inertial frame used for propagation.
117      *
118      * @param inertial the ECI frame
119      * @return the updated builder
120      */
121     public SBASPropagatorBuilder eci(final Frame inertial) {
122         this.eci = inertial;
123         return this;
124     }
125 
126     /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
127      *
128      * @param bodyFixed the ECEF frame
129      * @return the updated builder
130      */
131     public SBASPropagatorBuilder ecef(final Frame bodyFixed) {
132         this.ecef = bodyFixed;
133         return this;
134     }
135 
136     /** Finalizes the build.
137      *
138      * @return the built SBASPropagator
139      */
140     public SBASPropagator build() {
141         return new SBASPropagator(orbit, eci, ecef, attitudeProvider, mass, mu);
142     }
143 
144 }