GNSSPropagatorBuilder.java

  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. 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.GNSSOrbitalElements;
  26. import org.orekit.utils.IERSConventions;

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

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

  37.     /** The GNSS propagation model orbital elements. */
  38.     private final GNSSOrbitalElements<?> orbitalElements;

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

  78.     /** Initializes the builder.
  79.      * <p>The GNSS orbital elements is the only requested parameter to build a GNSSPropagator.</p>
  80.      * <p>The attitude provider is set by default to be aligned with the EME2000 frame.<br>
  81.      * The mass is set by default to the
  82.      *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
  83.      * The ECI frame is set by default to the
  84.      *  {@link Frames#getEME2000() EME2000 frame}.<br>
  85.      * The ECEF frame is set by default to the
  86.      *  {@link Frames#getITRF(IERSConventions, boolean)} CIO/2010-based ITRF simple EOP}.
  87.      * </p>
  88.      *
  89.      * @see #attitudeProvider(AttitudeProvider provider)
  90.      * @param orbitalElements orbital elements
  91.      * @param frames set of frames to use.
  92.      * @see #attitudeProvider(AttitudeProvider provider)
  93.      * @see #mass(double mass)
  94.      * @see #eci(Frame inertial)
  95.      * @see #ecef(Frame bodyFixed)
  96.      */
  97.     public GNSSPropagatorBuilder(final GNSSOrbitalElements<?> orbitalElements, final Frames frames) {
  98.         this.orbitalElements  = orbitalElements;
  99.         this.mass             = Propagator.DEFAULT_MASS;
  100.         this.eci              = frames.getEME2000();
  101.         this.ecef             = frames.getITRF(IERSConventions.IERS_2010, true);
  102.         this.attitudeProvider = FrameAlignedProvider.of(this.eci);
  103.     }

  104.     /** Sets the attitude provider.
  105.      *
  106.      * @param userProvider the attitude provider
  107.      * @return the updated builder
  108.      */
  109.     public GNSSPropagatorBuilder attitudeProvider(final AttitudeProvider userProvider) {
  110.         this.attitudeProvider = userProvider;
  111.         return this;
  112.     }

  113.     /** Sets the mass.
  114.      *
  115.      * @param userMass the mass (in kg)
  116.      * @return the updated builder
  117.      */
  118.     public GNSSPropagatorBuilder mass(final double userMass) {
  119.         this.mass = userMass;
  120.         return this;
  121.     }

  122.     /** Sets the Earth Centered Inertial frame used for propagation.
  123.      *
  124.      * @param inertial the ECI frame
  125.      * @return the updated builder
  126.      */
  127.     public GNSSPropagatorBuilder eci(final Frame inertial) {
  128.         this.eci = inertial;
  129.         return this;
  130.     }

  131.     /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
  132.      *
  133.      * @param bodyFixed the ECEF frame
  134.      * @return the updated builder
  135.      */
  136.     public GNSSPropagatorBuilder ecef(final Frame bodyFixed) {
  137.         this.ecef = bodyFixed;
  138.         return this;
  139.     }

  140.     /** Finalizes the build.
  141.      *
  142.      * @return the built GNSSPropagator
  143.      */
  144.     public GNSSPropagator build() {
  145.         return new GNSSPropagator(orbitalElements, eci, ecef, attitudeProvider, mass);
  146.     }

  147. }