MeasurementBuilder.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.estimation.measurements.generation;

  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.concurrent.ConcurrentHashMap;

  21. import org.orekit.estimation.measurements.EstimatedMeasurementBase;
  22. import org.orekit.estimation.measurements.EstimationModifier;
  23. import org.orekit.estimation.measurements.ObservableSatellite;
  24. import org.orekit.estimation.measurements.ObservedMeasurement;
  25. import org.orekit.propagation.SpacecraftState;
  26. import org.orekit.propagation.sampling.OrekitStepInterpolator;
  27. import org.orekit.time.AbsoluteDate;


  28. /** Interface for generating individual {@link ObservedMeasurement measurements}.
  29.  * @param <T> the type of the measurement
  30.  * @author Luc Maisonobe
  31.  * @since 9.3
  32.  */
  33. public interface MeasurementBuilder<T extends ObservedMeasurement<T>> {

  34.     /** Initialize builder at the start of a measurements generation.
  35.      * <p>
  36.      * This method is called once at the start of the measurements generation. It
  37.      * may be used by the builder to initialize some internal data
  38.      * if needed, typically setting up parameters reference dates.
  39.      * </p>
  40.      * @param start start of the measurements time span
  41.      * @param end end of the measurements time span
  42.      */
  43.     void init(AbsoluteDate start, AbsoluteDate end);

  44.     /** Add a modifier.
  45.      * @param modifier modifier to add
  46.      */
  47.     void addModifier(EstimationModifier<T> modifier);

  48.     /** Get the modifiers that apply to a measurement.
  49.      * @return modifiers that apply to a measurement
  50.      * @see #addModifier(EstimationModifier)
  51.      */
  52.     List<EstimationModifier<T>> getModifiers();

  53.     /** Get the satellites related to this measurement.
  54.      * @return satellites related to this measurement
  55.      * @since 12.0
  56.      */
  57.     ObservableSatellite[] getSatellites();

  58.     /** Generate a single measurement.
  59.      * @param date measurement date
  60.      * @param interpolators interpolators relevant for this builder
  61.      * @return generated measurement
  62.      * @since 13.0
  63.      */
  64.     EstimatedMeasurementBase<T> build(AbsoluteDate date, Map<ObservableSatellite, OrekitStepInterpolator> interpolators);

  65.     /** Generate a single measurement.<p>
  66.      *
  67.      * Warning: This method uses "shiftedBy" so it is not as accurate as the method above that uses interpolators.
  68.      *
  69.      * @param date measurement date
  70.      * @param states all spacecraft states (i.e. including ones that may not be relevant for the current builder)
  71.      * @return generated measurement
  72.      * @since 12.1
  73.      */
  74.     default EstimatedMeasurementBase<T> build(AbsoluteDate date, SpacecraftState[] states) {
  75.         final Map<ObservableSatellite, OrekitStepInterpolator> interpolators = new ConcurrentHashMap<>();

  76.         for (int i = 0; i < states.length; i++) {
  77.             final ObservableSatellite sat = getSatellites()[i];
  78.             final SpacecraftState state = states[i];

  79.             final OrekitStepInterpolator interpolator = new OrekitStepInterpolator() {
  80.                 /** {@inheritDoc} */
  81.                 @Override
  82.                 public OrekitStepInterpolator restrictStep(final SpacecraftState newPreviousState, final SpacecraftState newCurrentState) {
  83.                     return null;
  84.                 }
  85.                 /** {@inheritDoc} */
  86.                 @Override
  87.                 public boolean isPreviousStateInterpolated() {
  88.                     return false;
  89.                 }
  90.                 /** {@inheritDoc} */
  91.                 @Override
  92.                 public boolean isForward() {
  93.                     return true;
  94.                 }
  95.                 /** {@inheritDoc} */
  96.                 @Override
  97.                 public boolean isCurrentStateInterpolated() {
  98.                     return false;
  99.                 }
  100.                 /** {@inheritDoc} */
  101.                 @Override
  102.                 public SpacecraftState getPreviousState() {
  103.                     return state;
  104.                 }
  105.                 /** {@inheritDoc} */
  106.                 @Override
  107.                 public SpacecraftState getInterpolatedState(final AbsoluteDate date) {
  108.                     return state.shiftedBy(date.durationFrom(state));
  109.                 }
  110.                 /** {@inheritDoc} */
  111.                 @Override
  112.                 public SpacecraftState getCurrentState() {
  113.                     return state;
  114.                 }
  115.             };
  116.             interpolators.put(sat, interpolator);
  117.         }

  118.         return build( date, interpolators);
  119.     }
  120. }