GPSAlmanac.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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. import org.hipparchus.util.FastMath;
  19. import org.orekit.propagation.analytical.gnss.GPSOrbitalElements;
  20. import org.orekit.time.AbsoluteDate;
  21. import org.orekit.time.GPSDate;


  22. /**
  23.  * This class holds a GPS almanac as read from SEM or YUMA files.
  24.  *
  25.  * <p>Depending on the source (SEM or YUMA), some fields may be filled in or not.
  26.  * An almanac read from a YUMA file doesn't hold SVN number, average URA and satellite
  27.  * configuration.</p>
  28.  *
  29.  * @author Pascal Parraud
  30.  * @since 8.0
  31.  *
  32.  */
  33. public class GPSAlmanac implements GPSOrbitalElements {

  34.     // Fields
  35.     /** Source of the almanac. */
  36.     private final String src;
  37.     /** PRN number. */
  38.     private final int prn;
  39.     /** SVN number. */
  40.     private final int svn;
  41.     /** Health status. */
  42.     private final int health;
  43.     /** Average URA. */
  44.     private final int ura;
  45.     /** Satellite configuration. */
  46.     private final int config;
  47.     /** GPS week. */
  48.     private final int week;
  49.     /** Time of applicability. */
  50.     private final double toa;
  51.     /** Semi-major axis. */
  52.     private final double sma;
  53.     /** Eccentricity. */
  54.     private final double ecc;
  55.     /** Inclination. */
  56.     private final double inc;
  57.     /** Longitude of Orbital Plane. */
  58.     private final double om0;
  59.     /** Rate of Right Ascension. */
  60.     private final double dom;
  61.     /** Argument of perigee. */
  62.     private final double aop;
  63.     /** Mean anomaly. */
  64.     private final double anom;
  65.     /** Zeroth order clock correction. */
  66.     private final double af0;
  67.     /** First order clock correction. */
  68.     private final double af1;

  69.     /**
  70.      * Constructor.
  71.      *
  72.      * @param source the source of the almanac (SEM, YUMA, user defined)
  73.      * @param prn the PRN number
  74.      * @param svn the SVN number
  75.      * @param week the GPS week
  76.      * @param toa the Time of Applicability
  77.      * @param sqa the Square Root of Semi-Major Axis (m^1/2)
  78.      * @param ecc the eccentricity
  79.      * @param inc the inclination (rad)
  80.      * @param om0 the geographic longitude of the orbital plane at the weekly epoch (rad)
  81.      * @param dom the Rate of Right Ascension (rad/s)
  82.      * @param aop the Argument of Perigee (rad)
  83.      * @param anom the Mean Anomaly (rad)
  84.      * @param af0 the Zeroth Order Clock Correction (s)
  85.      * @param af1 the First Order Clock Correction (s/s)
  86.      * @param health the Health status
  87.      * @param ura the average URA
  88.      * @param config the satellite configuration
  89.      */
  90.     public GPSAlmanac(final String source, final int prn, final int svn,
  91.                       final int week, final double toa,
  92.                       final double sqa, final double ecc, final double inc,
  93.                       final double om0, final double dom, final double aop,
  94.                       final double anom, final double af0, final double af1,
  95.                       final int health, final int ura, final int config) {
  96.         this.src = source;
  97.         this.prn = prn;
  98.         this.svn = svn;
  99.         this.week = week;
  100.         this.toa = toa;
  101.         this.sma = sqa * sqa;
  102.         this.ecc = ecc;
  103.         this.inc = inc;
  104.         this.om0 = om0;
  105.         this.dom = dom;
  106.         this.aop = aop;
  107.         this.anom = anom;
  108.         this.af0 = af0;
  109.         this.af1 = af1;
  110.         this.health = health;
  111.         this.ura = ura;
  112.         this.config = config;
  113.     }

  114.     @Override
  115.     public AbsoluteDate getDate() {
  116.         return new GPSDate(week, toa * 1000.).getDate();
  117.     }

  118.     /**
  119.      * Gets the source of this GPS almanac.
  120.      * <p>Sources can be SEM or YUMA, when the almanac is read from a file.</p>
  121.      *
  122.      * @return the source of this GPS almanac
  123.      */
  124.     public String getSource() {
  125.         return src;
  126.     }

  127.     @Override
  128.     public int getPRN() {
  129.         return prn;
  130.     }

  131.     /**
  132.      * Gets the satellite "SVN" reference number.
  133.      *
  134.      * @return the satellite "SVN" reference number
  135.      */
  136.     public int getSVN() {
  137.         return svn;
  138.     }

  139.     @Override
  140.     public int getWeek() {
  141.         return week;
  142.     }

  143.     @Override
  144.     public double getTime() {
  145.         return toa;
  146.     }

  147.     @Override
  148.     public double getSma() {
  149.         return sma;
  150.     }

  151.     @Override
  152.     public double getMeanMotion() {
  153.         final double absA = FastMath.abs(sma);
  154.         return FastMath.sqrt(GPS_MU / absA) / absA;
  155.     }

  156.     @Override
  157.     public double getE() {
  158.         return ecc;
  159.     }

  160.     @Override
  161.     public double getI0() {
  162.         return inc;
  163.     }

  164.     @Override
  165.     public double getIDot() {
  166.         return 0;
  167.     }

  168.     @Override
  169.     public double getOmega0() {
  170.         return om0;
  171.     }

  172.     @Override
  173.     public double getOmegaDot() {
  174.         return dom;
  175.     }

  176.     @Override
  177.     public double getPa() {
  178.         return aop;
  179.     }

  180.     @Override
  181.     public double getM0() {
  182.         return anom;
  183.     }

  184.     @Override
  185.     public double getCuc() {
  186.         return 0;
  187.     }

  188.     @Override
  189.     public double getCus() {
  190.         return 0;
  191.     }

  192.     @Override
  193.     public double getCrc() {
  194.         return 0;
  195.     }

  196.     @Override
  197.     public double getCrs() {
  198.         return 0;
  199.     }

  200.     @Override
  201.     public double getCic() {
  202.         return 0;
  203.     }

  204.     @Override
  205.     public double getCis() {
  206.         return 0;
  207.     }

  208.     @Override
  209.     public double getAf0() {
  210.         return af0;
  211.     }

  212.     @Override
  213.     public double getAf1() {
  214.         return af1;
  215.     }

  216.     /**
  217.      * Gets the Health status.
  218.      *
  219.      * @return the Health status
  220.      */
  221.     public int getHealth() {
  222.         return health;
  223.     }

  224.     /**
  225.      * Gets the average URA number.
  226.      *
  227.      * @return the average URA number
  228.      */
  229.     public int getURA() {
  230.         return ura;
  231.     }

  232.     /**
  233.      * Gets the satellite configuration.
  234.      *
  235.      * @return the satellite configuration
  236.      */
  237.     public int getSatConfiguration() {
  238.         return config;
  239.     }

  240. }