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.gnss;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.orekit.gnss.SatelliteSystem;
23  
24  /** Factory for {@link WindUp wind-up} modifiers.
25   * <p>
26   * The factory ensures the same instance is returned for all
27   * satellite/receiver pair, thus preserving phase continuity
28   * for successive measurements involving the same pair.
29   * </p>
30   * @author Luc Maisonobe
31   * @since 10.1
32   */
33  public class WindUpFactory {
34  
35      /** Modifiers cache. */
36      private final Map<SatelliteSystem, Map<Integer, Map<String, WindUp>>> modifiers;
37  
38      /** Simple constructor.
39       */
40      public WindUpFactory() {
41          this.modifiers = new HashMap<>();
42      }
43  
44      /** Get a modifier for a satellite/receiver pair.
45       * @param system system the satellite belongs to
46       * @param prnNumber PRN number
47       * @param emitterDipole emitter dipole
48       * @param receiverName name of the receiver
49       * @return modifier for the satellite/receiver pair
50       */
51      public WindUp getWindUp(final SatelliteSystem system, final int prnNumber,
52                              final Dipole emitterDipole, final String receiverName) {
53          // select satellite system
54          final Map<Integer, Map<String, WindUp>> systemModifiers;
55          synchronized (modifiers) {
56              systemModifiers = modifiers.computeIfAbsent(system, s -> new HashMap<>());
57  
58              // select satellite
59              final Map<String, WindUp> satelliteModifiers =
60                  systemModifiers.computeIfAbsent(prnNumber, n -> new HashMap<>());
61  
62              // select receiver
63              return satelliteModifiers.computeIfAbsent(receiverName, r -> new WindUp(emitterDipole));
64  
65          }
66  
67      }
68  
69  }