SatInSystem.java

  1. /* Copyright 2002-2024 Luc Maisonobe
  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.gnss;

  18. /** Container for satellite system and PRN.
  19.  * @author Luc Maisonobe
  20.  * @since 12.0
  21.  */
  22. public class SatInSystem {

  23.     /** Satellite system. */
  24.     private final SatelliteSystem system;

  25.     /** PRN number. */
  26.     private final int prn;

  27.     /** Simple constructor.
  28.      * @param system satellite system
  29.      * @param prn Pseudo Random Number
  30.      */
  31.     public SatInSystem(final SatelliteSystem system, final int prn) {
  32.         this.system = system;
  33.         this.prn    = prn;
  34.     }

  35.     /** Get the system this satellite belongs to.
  36.      * @return system this satellite belongs to
  37.      */
  38.     public SatelliteSystem getSystem() {
  39.         return system;
  40.     }

  41.     /** Get the Pseudo Random Number of the satellite.
  42.      * @return Pseudo Random Number of the satellite
  43.      */
  44.     public int getPRN() {
  45.         return prn;
  46.     }

  47.     /** Get a 2-digits Pseudo Random Number for RINEX files.
  48.      * @return 2-digits Pseudo Random Number for RINEX files
  49.      */
  50.     public int getTwoDigitsRinexPRN() {
  51.         return system == SatelliteSystem.SBAS ? prn - 100 : (system == SatelliteSystem.QZSS ? prn - 192 : prn);
  52.     }

  53.     @Override
  54.     public boolean equals(final Object object) {
  55.         if (object instanceof SatInSystem) {
  56.             final SatInSystem other = (SatInSystem) object;
  57.             return getSystem().equals(other.getSystem()) && getPRN() == other.getPRN();
  58.         }
  59.         return false;
  60.     }

  61.     @Override
  62.     public int hashCode() {
  63.         return getSystem().hashCode() ^ getPRN();
  64.     }

  65. }