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