FieldGnssPropagatorBuilder.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.hipparchus.CalculusFieldElement;
  19. import org.orekit.annotation.DefaultDataContext;
  20. import org.orekit.attitudes.AttitudeProvider;
  21. import org.orekit.attitudes.FrameAlignedProvider;
  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.FieldGnssOrbitalElements;
  27. import org.orekit.utils.IERSConventions;

  28. /**
  29.  * This nested class aims at building a GNSSPropagator.
  30.  * <p>It implements the classical builder pattern.</p>
  31.  * @param <T> type of the field elements
  32.  * @author Pascal Parraud
  33.  * @since 13.0
  34.  */
  35. public class FieldGnssPropagatorBuilder<T extends CalculusFieldElement<T>> {

  36.     /** The GNSS propagation model orbital elements. */
  37.     private final FieldGnssOrbitalElements<T, ?> orbitalElements;

  38.     /** The attitude provider. */
  39.     private AttitudeProvider attitudeProvider;

  40.     /** The mass. */
  41.     private T mass;

  42.     /** The ECI frame. */
  43.     private Frame eci;

  44.     /** The ECEF frame. */
  45.     private Frame ecef;

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

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

  100.     /** Sets the attitude provider.
  101.      *
  102.      * @param userProvider the attitude provider
  103.      * @return the updated builder
  104.      */
  105.     public FieldGnssPropagatorBuilder<T> attitudeProvider(final AttitudeProvider userProvider) {
  106.         this.attitudeProvider = userProvider;
  107.         return this;
  108.     }

  109.     /** Sets the mass.
  110.      *
  111.      * @param userMass the mass (in kg)
  112.      * @return the updated builder
  113.      */
  114.     public FieldGnssPropagatorBuilder<T> mass(final T userMass) {
  115.         this.mass = userMass;
  116.         return this;
  117.     }

  118.     /** Sets the Earth Centered Inertial frame used for propagation.
  119.      *
  120.      * @param inertial the ECI frame
  121.      * @return the updated builder
  122.      */
  123.     public FieldGnssPropagatorBuilder<T> eci(final Frame inertial) {
  124.         this.eci = inertial;
  125.         return this;
  126.     }

  127.     /** Sets the Earth Centered Earth Fixed frame assimilated to the WGS84 ECEF.
  128.      *
  129.      * @param bodyFixed the ECEF frame
  130.      * @return the updated builder
  131.      */
  132.     public FieldGnssPropagatorBuilder<T> ecef(final Frame bodyFixed) {
  133.         this.ecef = bodyFixed;
  134.         return this;
  135.     }

  136.     /** Finalizes the build.
  137.      *
  138.      * @return the built GNSSPropagator
  139.      */
  140.     public FieldGnssPropagator<T> build() {
  141.         return new FieldGnssPropagator<>(orbitalElements, eci, ecef, attitudeProvider, mass);
  142.     }

  143. }