1 /* Copyright 2022-2025 Thales Alenia Space
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.gnss;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.orekit.gnss.SatelliteSystem;
23
24 /** Factory for {@link InterSatellitesWindUp wind-up} modifiers.
25 * <p>
26 * The factory ensures the same instance is returned for all
27 * emitter/receiver pair, thus preserving phase continuity
28 * for successive measurements involving the same pair.
29 * </p>
30 * @author Luc Maisonobe
31 * @since 12.0
32 */
33 public class InterSatellitesWindUpFactory {
34
35 /** Modifiers cache. */
36 private final Map<SatelliteSystem, Map<Integer, Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>>>> modifiers;
37
38 /** Simple constructor.
39 */
40 public InterSatellitesWindUpFactory() {
41 this.modifiers = new HashMap<>();
42 }
43
44 /** Get a modifier for an emitter/receiver pair.
45 * @param emitterSystem system the emitter satellite belongs to
46 * @param emitterPrnNumber emitter satellite PRN number
47 * @param emitterDipole emitter dipole
48 * @param receiverSystem system the receiver satellite belongs to
49 * @param receiverPrnNumber receiver satellite PRN number
50 * @param receiverDipole receiver dipole
51 * @return modifier for the emitter/receiver pair
52 */
53 public InterSatellitesWindUp getWindUp(final SatelliteSystem emitterSystem, final int emitterPrnNumber,
54 final Dipole emitterDipole,
55 final SatelliteSystem receiverSystem, final int receiverPrnNumber,
56 final Dipole receiverDipole) {
57
58 // select emitter satellite system
59 final Map<Integer, Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>>> emitterSystemModifiers =
60 modifiers.computeIfAbsent(emitterSystem, k -> new HashMap<>());
61 // build a new map for this satellite system
62
63 // select emitter satellite
64 final Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>> emitterSatelliteModifiers =
65 emitterSystemModifiers.computeIfAbsent(emitterPrnNumber, k -> new HashMap<>());
66 // build a new map for this satellite
67
68 // select receiver satellite system
69 final Map<Integer, InterSatellitesWindUp> receiverSystemModifiers =
70 emitterSatelliteModifiers.computeIfAbsent(receiverSystem, k -> new HashMap<>());
71 // build a new map for this satellite system
72
73 // select receiver satellite
74 InterSatellitesWindUp receiverSatelliteModifier = receiverSystemModifiers.get(receiverPrnNumber);
75 if (receiverSatelliteModifier == null) {
76 // build a new wind-up modifier
77 receiverSatelliteModifier = new InterSatellitesWindUp(emitterDipole, receiverDipole);
78 receiverSystemModifiers.put(receiverPrnNumber, receiverSatelliteModifier);
79 }
80
81 return receiverSatelliteModifier;
82
83 }
84
85 }