MultiplexedMeasurementBuilder.java

  1. /* Copyright 2002-2024 Luc Maisonobe
  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.ArrayList;
  19. import java.util.Collections;
  20. import java.util.List;
  21. import java.util.Map;

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


  28. /** Builder for {@link MultiplexedMeasurement} measurements.
  29.  * @author Luc Maisonobe
  30.  * @since 12.0
  31.  */
  32. public class MultiplexedMeasurementBuilder implements MeasurementBuilder<MultiplexedMeasurement> {

  33.     /** Builders for individual measurements. */
  34.     private final List<MeasurementBuilder<?>> builders;

  35.     /** Satellites related to this builder. */
  36.     private final ObservableSatellite[] satellites;

  37.     /** Modifiers that apply to the measurement.*/
  38.     private final List<EstimationModifier<MultiplexedMeasurement>> modifiers;

  39.     /** Simple constructor.
  40.      * @param builders builders for multiplexed measurements
  41.      */
  42.     public MultiplexedMeasurementBuilder(final List<MeasurementBuilder<?>> builders) {
  43.         this.builders  = builders;
  44.         this.modifiers = new ArrayList<>();

  45.         final List<ObservableSatellite> list = new ArrayList<>();
  46.         for (final MeasurementBuilder<?> builder : builders) {
  47.             for (final ObservableSatellite satellite : builder.getSatellites()) {
  48.                 if (!list.contains(satellite)) {
  49.                     list.add(satellite);
  50.                 }
  51.             }
  52.         }
  53.         this.satellites = list.toArray(new ObservableSatellite[0]);

  54.     }

  55.     /** {@inheritDoc}
  56.      * <p>
  57.      * This implementation stores the time span of the measurements generation.
  58.      * </p>
  59.      */
  60.     @Override
  61.     public void init(final AbsoluteDate start, final AbsoluteDate end) {
  62.         for (final MeasurementBuilder<?> builder : builders) {
  63.             builder.init(start, end);
  64.         }
  65.     }

  66.     /** {@inheritDoc} */
  67.     @Override
  68.     public void addModifier(final EstimationModifier<MultiplexedMeasurement> modifier) {
  69.         modifiers.add(modifier);
  70.     }

  71.     /** {@inheritDoc} */
  72.     @Override
  73.     public List<EstimationModifier<MultiplexedMeasurement>> getModifiers() {
  74.         return Collections.unmodifiableList(modifiers);
  75.     }

  76.     /** {@inheritDoc} */
  77.     @Override
  78.     public MultiplexedMeasurement build(final AbsoluteDate date, final Map<ObservableSatellite, OrekitStepInterpolator> interpolators) {

  79.         final List<ObservedMeasurement<?>> measurements = new ArrayList<>(builders.size());
  80.         for (final MeasurementBuilder<?> builder : builders) {
  81.             measurements.add(builder.build(date, interpolators));
  82.         }


  83.         // generate measurement
  84.         final MultiplexedMeasurement measurement = new MultiplexedMeasurement(measurements);
  85.         for (final EstimationModifier<MultiplexedMeasurement> modifier : getModifiers()) {
  86.             measurement.addModifier(modifier);
  87.         }
  88.         return measurement;

  89.     }

  90.     /** {@inheritDoc} */
  91.     @Override
  92.     public ObservableSatellite[] getSatellites() {
  93.         return satellites.clone();
  94.     }

  95. }