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