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
19 import java.util.List;
20 import java.util.Map;
21 import java.util.concurrent.ConcurrentHashMap;
22
23 import org.orekit.estimation.measurements.EstimatedMeasurementBase;
24 import org.orekit.estimation.measurements.EstimationModifier;
25 import org.orekit.estimation.measurements.ObservableSatellite;
26 import org.orekit.estimation.measurements.ObservedMeasurement;
27 import org.orekit.propagation.SpacecraftState;
28 import org.orekit.propagation.sampling.OrekitStepInterpolator;
29 import org.orekit.time.AbsoluteDate;
30
31
32 /** Interface for generating individual {@link ObservedMeasurement measurements}.
33 * @param <T> the type of the measurement
34 * @author Luc Maisonobe
35 * @since 9.3
36 */
37 public interface MeasurementBuilder<T extends ObservedMeasurement<T>> {
38
39 /** Initialize builder at the start of a measurements generation.
40 * <p>
41 * This method is called once at the start of the measurements generation. It
42 * may be used by the builder to initialize some internal data
43 * if needed, typically setting up parameters reference dates.
44 * </p>
45 * @param start start of the measurements time span
46 * @param end end of the measurements time span
47 */
48 void init(AbsoluteDate start, AbsoluteDate end);
49
50 /** Add a modifier.
51 * @param modifier modifier to add
52 */
53 void addModifier(EstimationModifier<T> modifier);
54
55 /** Get the modifiers that apply to a measurement.
56 * @return modifiers that apply to a measurement
57 * @see #addModifier(EstimationModifier)
58 */
59 List<EstimationModifier<T>> getModifiers();
60
61 /** Get the satellites related to this measurement.
62 * @return satellites related to this measurement
63 * @since 12.0
64 */
65 ObservableSatellite[] getSatellites();
66
67 /** Generate a single measurement.
68 * @param date measurement date
69 * @param interpolators interpolators relevant for this builder
70 * @return generated measurement
71 * @since 13.0
72 */
73 EstimatedMeasurementBase<T> build(AbsoluteDate date, Map<ObservableSatellite, OrekitStepInterpolator> interpolators);
74
75 /** Generate a single measurement.<p>
76 *
77 * Warning: This method uses "shiftedBy" so it is not as accurate as the method above that uses interpolators.
78 *
79 * @param date measurement date
80 * @param states all spacecraft states (i.e. including ones that may not be relevant for the current builder)
81 * @return generated measurement
82 * @since 12.1
83 */
84 default EstimatedMeasurementBase<T> build(AbsoluteDate date, SpacecraftState[] states) {
85 final Map<ObservableSatellite, OrekitStepInterpolator> interpolators = new ConcurrentHashMap<>();
86
87 for (int i = 0; i < states.length; i++) {
88 final ObservableSatellite sat = getSatellites()[i];
89 final SpacecraftState state = states[i];
90
91 final OrekitStepInterpolator interpolator = new OrekitStepInterpolator() {
92 /** {@inheritDoc} */
93 @Override
94 public OrekitStepInterpolator restrictStep(final SpacecraftState newPreviousState, final SpacecraftState newCurrentState) {
95 return null;
96 }
97 /** {@inheritDoc} */
98 @Override
99 public boolean isPreviousStateInterpolated() {
100 return false;
101 }
102 /** {@inheritDoc} */
103 @Override
104 public boolean isForward() {
105 return true;
106 }
107 /** {@inheritDoc} */
108 @Override
109 public boolean isCurrentStateInterpolated() {
110 return false;
111 }
112 /** {@inheritDoc} */
113 @Override
114 public SpacecraftState getPreviousState() {
115 return state;
116 }
117 /** {@inheritDoc} */
118 @Override
119 public SpacecraftState getInterpolatedState(final AbsoluteDate date) {
120 return state.shiftedBy(date.durationFrom(state));
121 }
122 /** {@inheritDoc} */
123 @Override
124 public SpacecraftState getCurrentState() {
125 return state;
126 }
127 };
128 interpolators.put(sat, interpolator);
129 }
130
131 return build( date, interpolators);
132 }
133 }