InterSatellitesWindUpFactory.java

  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. 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.         Map<Integer, Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>>> emitterSystemModifiers =
  53.                         modifiers.get(emitterSystem);
  54.         if (emitterSystemModifiers == null) {
  55.             // build a new map for this satellite system
  56.             emitterSystemModifiers = new HashMap<>();
  57.             modifiers.put(emitterSystem, emitterSystemModifiers);
  58.         }

  59.         // select emitter satellite
  60.         Map<SatelliteSystem, Map<Integer, InterSatellitesWindUp>> emitterSatelliteModifiers =
  61.                         emitterSystemModifiers.get(emitterPrnNumber);
  62.         if (emitterSatelliteModifiers == null) {
  63.             // build a new map for this satellite
  64.             emitterSatelliteModifiers = new HashMap<>();
  65.             emitterSystemModifiers.put(emitterPrnNumber, emitterSatelliteModifiers);
  66.         }

  67.         // select receiver satellite system
  68.         Map<Integer, InterSatellitesWindUp> receiverSystemModifiers =
  69.                         emitterSatelliteModifiers.get(receiverSystem);
  70.         if (receiverSystemModifiers == null) {
  71.             // build a new map for this satellite system
  72.             receiverSystemModifiers = new HashMap<>();
  73.             emitterSatelliteModifiers.put(receiverSystem, receiverSystemModifiers);
  74.         }

  75.         // select receiver satellite
  76.         InterSatellitesWindUp receiverSatelliteModifier = receiverSystemModifiers.get(receiverPrnNumber);
  77.         if (receiverSatelliteModifier == null) {
  78.             // build a new wind-up modifier
  79.             receiverSatelliteModifier = new InterSatellitesWindUp(emitterDipole, receiverDipole);
  80.             receiverSystemModifiers.put(receiverPrnNumber, receiverSatelliteModifier);
  81.         }

  82.         return receiverSatelliteModifier;

  83.     }

  84. }