WindUpFactory.java

  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. import java.util.HashMap;
  19. import java.util.Map;

  20. import org.orekit.gnss.SatelliteSystem;

  21. /** Factory for {@link WindUp wind-up} modifiers.
  22.  * <p>
  23.  * The factory ensures the same instance is returned for all
  24.  * satellite/receiver pair, thus preserving phase continuity
  25.  * for successive measurements involving the same pair.
  26.  * </p>
  27.  * @author Luc Maisonobe
  28.  * @since 10.1
  29.  */
  30. public class WindUpFactory {

  31.     /** Modifiers cache. */
  32.     private final Map<SatelliteSystem, Map<Integer, Map<String, WindUp>>> modifiers;

  33.     /** Simple constructor.
  34.      */
  35.     public WindUpFactory() {
  36.         this.modifiers = new HashMap<>();
  37.     }

  38.     /** Get a modifier for a satellite/receiver pair.
  39.      * @param system system the satellite belongs to
  40.      * @param prnNumber PRN number
  41.      * @param emitterDipole emitter dipole
  42.      * @param receiverName name of the receiver
  43.      * @return modifier for the satellite/receiver pair
  44.      */
  45.     public WindUp getWindUp(final SatelliteSystem system, final int prnNumber,
  46.                             final Dipole emitterDipole, final String receiverName) {
  47.         // select satellite system
  48.         final Map<Integer, Map<String, WindUp>> systemModifiers;
  49.         synchronized (modifiers) {
  50.             systemModifiers = modifiers.computeIfAbsent(system, s -> new HashMap<>());

  51.             // select satellite
  52.             final Map<String, WindUp> satelliteModifiers =
  53.                 systemModifiers.computeIfAbsent(prnNumber, n -> new HashMap<>());

  54.             // select receiver
  55.             return satelliteModifiers.computeIfAbsent(receiverName, r -> new WindUp(emitterDipole));

  56.         }

  57.     }

  58. }