GLONASSAnalyticalPropagatorBuilder.java

  1. /* Copyright 2002-2022 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. import org.orekit.annotation.DefaultDataContext;
  19. import org.orekit.attitudes.AttitudeProvider;
  20. import org.orekit.attitudes.InertialProvider;
  21. import org.orekit.data.DataContext;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.frames.Frames;
  24. import org.orekit.propagation.Propagator;
  25. import org.orekit.propagation.analytical.gnss.data.GLONASSOrbitalElements;
  26. import org.orekit.utils.IERSConventions;

  27. /**
  28.  * This nested class aims at building a GLONASSAnalyticalPropagator.
  29.  * <p>It implements the classical builder pattern.</p>
  30.  * @author Bryan Cazabonne
  31.  * @since 11.0
  32.  */
  33. public class GLONASSAnalyticalPropagatorBuilder {

  34.     //////////
  35.     // Required parameter
  36.     //////////

  37.     /** The GLONASS orbital elements. */
  38.     private final GLONASSOrbitalElements orbit;

  39.     ///////////
  40.     // Optional parameters
  41.     //////////

  42.     /** The attitude provider. */
  43.     private AttitudeProvider attitudeProvider;

  44.     /** The mass. */
  45.     private double mass;

  46.     /** The ECI frame. */
  47.     private Frame eci;

  48.     /** The ECEF frame. */
  49.     private Frame ecef;

  50.     /** Data context. */
  51.     private DataContext dataContext;

  52.     /** Initializes the builder.
  53.      * <p>The GLONASS orbital elements is the only requested parameter to build a GLONASSAnalyticalPropagator.</p>
  54.      * <p>The attitude provider is set by default to be aligned with the EME2000 frame.<br>
  55.      * The mass is set by default to the
  56.      *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
  57.      * The data context is by default to the
  58.      *  {@link DataContext#getDefault() default data context}.<br>
  59.      * The ECI frame is set by default to the
  60.      *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
  61.      *  context.<br>
  62.      * The ECEF frame is set by default to the
  63.      *  {@link org.orekit.frames.Predefined#ITRF_CIO_CONV_2010_SIMPLE_EOP
  64.      *  CIO/2010-based ITRF simple EOP} in the default data context.
  65.      * </p>
  66.      *
  67.      * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
  68.      * Another data context can be set using
  69.      * {@code Builder(final GLONASSOrbitalElements gpsOrbElt, final DataContext dataContext)}</p>
  70.      *
  71.      * @param glonassOrbElt the GLONASS orbital elements to be used by the GLONASS analytical propagator.
  72.      * @see #attitudeProvider(AttitudeProvider provider)
  73.      * @see #mass(double mass)
  74.      * @see #eci(Frame inertial)
  75.      * @see #ecef(Frame bodyFixed)
  76.      */
  77.     @DefaultDataContext
  78.     public GLONASSAnalyticalPropagatorBuilder(final GLONASSOrbitalElements glonassOrbElt) {
  79.         this(glonassOrbElt, DataContext.getDefault());
  80.     }

  81.     /** Initializes the builder.
  82.      * <p>The GLONASS orbital elements is the only requested parameter to build a GLONASSAnalyticalPropagator.</p>
  83.      * <p>The attitude provider is set by default to be aligned with the EME2000 frame.<br>
  84.      * The mass is set by default to the
  85.      *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
  86.      * The ECI frame is set by default to the
  87.      *  {@link Frames#getEME2000() EME2000 frame}.<br>
  88.      * The ECEF frame is set by default to the
  89.      *  {@link Frames#getITRF(IERSConventions, boolean) CIO/2010-based ITRF simple
  90.      *  EOP}.
  91.      * </p>
  92.      *
  93.      * @param glonassOrbElt the GLONASS orbital elements to be used by the GLONASS propagator.
  94.      * @param dataContext the data context to use for frames and time scales.
  95.      * @see #attitudeProvider(AttitudeProvider provider)
  96.      * @see #mass(double mass)
  97.      * @see #eci(Frame inertial)
  98.      * @see #ecef(Frame bodyFixed)
  99.      * @since 10.1
  100.      */
  101.     public GLONASSAnalyticalPropagatorBuilder(final GLONASSOrbitalElements glonassOrbElt,
  102.                                               final DataContext dataContext) {
  103.         this.orbit = glonassOrbElt;
  104.         this.dataContext = dataContext;
  105.         this.mass  = Propagator.DEFAULT_MASS;
  106.         final Frames frames = dataContext.getFrames();
  107.         this.eci   = frames.getEME2000();
  108.         this.ecef  = frames.getITRF(IERSConventions.IERS_2010, true);
  109.         attitudeProvider = InertialProvider.of(this.eci);
  110.     }

  111.     /** Sets the attitude provider.
  112.      *
  113.      * @param userProvider the attitude provider
  114.      * @return the updated builder
  115.      */
  116.     public GLONASSAnalyticalPropagatorBuilder attitudeProvider(final AttitudeProvider userProvider) {
  117.         this.attitudeProvider = userProvider;
  118.         return this;
  119.     }

  120.     /** Sets the mass.
  121.      *
  122.      * @param userMass the mass (in kg)
  123.      * @return the updated builder
  124.      */
  125.     public GLONASSAnalyticalPropagatorBuilder mass(final double userMass) {
  126.         this.mass = userMass;
  127.         return this;
  128.     }

  129.     /** Sets the Earth Centered Inertial frame used for propagation.
  130.      *
  131.      * @param inertial the ECI frame
  132.      * @return the updated builder
  133.      */
  134.     public GLONASSAnalyticalPropagatorBuilder eci(final Frame inertial) {
  135.         this.eci = inertial;
  136.         return this;
  137.     }

  138.     /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
  139.      *
  140.      * @param bodyFixed the ECEF frame
  141.      * @return the updated builder
  142.      */
  143.     public GLONASSAnalyticalPropagatorBuilder ecef(final Frame bodyFixed) {
  144.         this.ecef = bodyFixed;
  145.         return this;
  146.     }

  147.     /** Sets the data context used by the propagator. Does not update the ECI or ECEF
  148.      * frames which must be done separately using {@link #eci(Frame)} and {@link
  149.      * #ecef(Frame)}.
  150.      *
  151.      * @param context used for propagation.
  152.      * @return the updated builder.
  153.      */
  154.     public GLONASSAnalyticalPropagatorBuilder dataContext(final DataContext context) {
  155.         this.dataContext = context;
  156.         return this;
  157.     }

  158.     /** Finalizes the build.
  159.      *
  160.      * @return the built GLONASSPropagator
  161.      */
  162.     public GLONASSAnalyticalPropagator build() {
  163.         return new GLONASSAnalyticalPropagator(orbit, eci, ecef, attitudeProvider, mass, dataContext);
  164.     }

  165. }