GLONASSAnalyticalPropagatorBuilder.java

  1. /* Copyright 2002-2024 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.FrameAlignedProvider;
  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.GLONASSAlmanac;
  26. import org.orekit.propagation.analytical.gnss.data.GLONASSNavigationMessage;
  27. import org.orekit.propagation.analytical.gnss.data.GLONASSOrbitalElements;
  28. import org.orekit.utils.IERSConventions;

  29. /**
  30.  * This nested class aims at building a GLONASSAnalyticalPropagator.
  31.  * <p>It implements the classical builder pattern.</p>
  32.  * <p>
  33.  * <b>Caution:</b> The Glonass analytical propagator can only be used with {@link GLONASSAlmanac}.
  34.  * Using this propagator with a {@link GLONASSNavigationMessage} is prone to error.
  35.  * </p>
  36.  * @author Bryan Cazabonne
  37.  * @since 11.0
  38.  */
  39. public class GLONASSAnalyticalPropagatorBuilder {

  40.     //////////
  41.     // Required parameter
  42.     //////////

  43.     /** The GLONASS orbital elements. */
  44.     private final GLONASSOrbitalElements orbit;

  45.     ///////////
  46.     // Optional parameters
  47.     //////////

  48.     /** The attitude provider. */
  49.     private AttitudeProvider attitudeProvider;

  50.     /** The mass. */
  51.     private double mass;

  52.     /** The ECI frame. */
  53.     private Frame eci;

  54.     /** The ECEF frame. */
  55.     private Frame ecef;

  56.     /** Data context. */
  57.     private DataContext dataContext;

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

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

  117.     /** Sets the attitude provider.
  118.      *
  119.      * @param userProvider the attitude provider
  120.      * @return the updated builder
  121.      */
  122.     public GLONASSAnalyticalPropagatorBuilder attitudeProvider(final AttitudeProvider userProvider) {
  123.         this.attitudeProvider = userProvider;
  124.         return this;
  125.     }

  126.     /** Sets the mass.
  127.      *
  128.      * @param userMass the mass (in kg)
  129.      * @return the updated builder
  130.      */
  131.     public GLONASSAnalyticalPropagatorBuilder mass(final double userMass) {
  132.         this.mass = userMass;
  133.         return this;
  134.     }

  135.     /** Sets the Earth Centered Inertial frame used for propagation.
  136.      *
  137.      * @param inertial the ECI frame
  138.      * @return the updated builder
  139.      */
  140.     public GLONASSAnalyticalPropagatorBuilder eci(final Frame inertial) {
  141.         this.eci = inertial;
  142.         return this;
  143.     }

  144.     /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
  145.      *
  146.      * @param bodyFixed the ECEF frame
  147.      * @return the updated builder
  148.      */
  149.     public GLONASSAnalyticalPropagatorBuilder ecef(final Frame bodyFixed) {
  150.         this.ecef = bodyFixed;
  151.         return this;
  152.     }

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

  164.     /** Finalizes the build.
  165.      *
  166.      * @return the built GLONASSPropagator
  167.      */
  168.     public GLONASSAnalyticalPropagator build() {
  169.         return new GLONASSAnalyticalPropagator(orbit, eci, ecef, attitudeProvider, mass, dataContext);
  170.     }

  171. }