1 /* Copyright 2002-2024 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 Map<Integer, Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>>> emitterSystemModifiers =
60 modifiers.get(emitterSystem);
61 if (emitterSystemModifiers == null) {
62 // build a new map for this satellite system
63 emitterSystemModifiers = new HashMap<>();
64 modifiers.put(emitterSystem, emitterSystemModifiers);
65 }
66
67 // select emitter satellite
68 Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>> emitterSatelliteModifiers =
69 emitterSystemModifiers.get(emitterPrnNumber);
70 if (emitterSatelliteModifiers == null) {
71 // build a new map for this satellite
72 emitterSatelliteModifiers = new HashMap<>();
73 emitterSystemModifiers.put(emitterPrnNumber, emitterSatelliteModifiers);
74 }
75
76 // select receiver satellite system
77 Map<Integer, InterSatellitesWindUp> receiverSystemModifiers =
78 emitterSatelliteModifiers.get(receiverSystem);
79 if (receiverSystemModifiers == null) {
80 // build a new map for this satellite system
81 receiverSystemModifiers = new HashMap<>();
82 emitterSatelliteModifiers.put(receiverSystem, receiverSystemModifiers);
83 }
84
85 // select receiver satellite
86 InterSatellitesWindUp receiverSatelliteModifier = receiverSystemModifiers.get(receiverPrnNumber);
87 if (receiverSatelliteModifier == null) {
88 // build a new wind-up modifier
89 receiverSatelliteModifier = new InterSatellitesWindUp(emitterDipole, receiverDipole);
90 receiverSystemModifiers.put(receiverPrnNumber, receiverSatelliteModifier);
91 }
92
93 return receiverSatelliteModifier;
94
95 }
96
97 }