InterSatellitesWindUpFactory.java

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

  20. import org.orekit.gnss.SatelliteSystem;

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

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

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

  38.     /** Get a modifier for an emitter/receiver pair.
  39.      * @param emitterSystem system the emitter satellite belongs to
  40.      * @param emitterPrnNumber emitter satellite PRN number
  41.      * @param emitterDipole emitter dipole
  42.      * @param receiverSystem system the receiver satellite belongs to
  43.      * @param receiverPrnNumber receiver satellite PRN number
  44.      * @param receiverDipole receiver dipole
  45.      * @return modifier for the emitter/receiver pair
  46.      */
  47.     public InterSatellitesWindUp getWindUp(final SatelliteSystem emitterSystem,  final int emitterPrnNumber,
  48.                                            final Dipole emitterDipole,
  49.                                            final SatelliteSystem receiverSystem, final int receiverPrnNumber,
  50.                                            final Dipole receiverDipole) {

  51.         // select emitter satellite system
  52.         final Map<Integer, Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>>> emitterSystemModifiers =
  53.                 modifiers.computeIfAbsent(emitterSystem, k -> new HashMap<>());
  54.         // build a new map for this satellite system

  55.         // select emitter satellite
  56.         final Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>> emitterSatelliteModifiers =
  57.                 emitterSystemModifiers.computeIfAbsent(emitterPrnNumber, k -> new HashMap<>());
  58.         // build a new map for this satellite

  59.         // select receiver satellite system
  60.         final Map<Integer, InterSatellitesWindUp> receiverSystemModifiers =
  61.                 emitterSatelliteModifiers.computeIfAbsent(receiverSystem, k -> new HashMap<>());
  62.         // build a new map for this satellite system

  63.         // select receiver satellite
  64.         InterSatellitesWindUp receiverSatelliteModifier = receiverSystemModifiers.get(receiverPrnNumber);
  65.         if (receiverSatelliteModifier == null) {
  66.             // build a new wind-up modifier
  67.             receiverSatelliteModifier = new InterSatellitesWindUp(emitterDipole, receiverDipole);
  68.             receiverSystemModifiers.put(receiverPrnNumber, receiverSatelliteModifier);
  69.         }

  70.         return receiverSatelliteModifier;

  71.     }

  72. }