Station.java

  1. /* Copyright 2002-2022 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.files.sinex;

  18. import java.util.HashMap;
  19. import java.util.Map;

  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.orekit.errors.OrekitException;
  22. import org.orekit.errors.OrekitMessages;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.utils.TimeSpanMap;

  25. /**
  26.  * Station model.
  27.  * <p>
  28.  * Since Orekit 11.1, this class handles multiple site antenna
  29.  * eccentricity. The {@link #getEccentricities()} method
  30.  * provides the last known eccentricity values.
  31.  * The {@link #getEccentricities(AbsoluteDate)} method can be
  32.  * used to access the site antenna eccentricity values for a
  33.  * given epoch.
  34.  * </p>
  35.  * @author Bryan Cazabonne
  36.  * @since 10.3
  37.  */
  38. public class Station {

  39.     /** Site code. */
  40.     private String siteCode;

  41.     /** DOMES number. */
  42.     private String domes;

  43.     /** Start of validity. */
  44.     private AbsoluteDate validFrom;

  45.     /** End of validity. */
  46.     private AbsoluteDate validUntil;

  47.     /** Eccentricity reference system. */
  48.     private ReferenceSystem eccRefSystem;

  49.     /** Latest site antenna eccentricities (m). */
  50.     private Vector3D eccentricities;

  51.     /** TimeSpanMap of site antenna eccentricities. */
  52.     private TimeSpanMap<Vector3D> eccentricitiesTimeSpanMap;

  53.     /** Station position. */
  54.     private Vector3D position;

  55.     /** Station velocity. */
  56.     private Vector3D velocity;

  57.     /** Coordinates reference epoch. */
  58.     private AbsoluteDate epoch;

  59.     /**
  60.      * Constructor.
  61.      */
  62.     public Station() {
  63.         this.eccentricities            = Vector3D.ZERO;
  64.         this.eccentricitiesTimeSpanMap = new TimeSpanMap<>(null);
  65.         this.position                  = Vector3D.ZERO;
  66.         this.velocity                  = Vector3D.ZERO;
  67.     }

  68.     /**
  69.      * Get the site code (station identifier).
  70.      * @return the site code
  71.      */
  72.     public String getSiteCode() {
  73.         return siteCode;
  74.     }

  75.     /**
  76.      * Set the site code (station identifier).
  77.      * @param siteCode the site code to set
  78.      */
  79.     public void setSiteCode(final String siteCode) {
  80.         this.siteCode = siteCode;
  81.     }

  82.     /**
  83.      * Get the site DOMES number.
  84.      * @return the DOMES number
  85.      */
  86.     public String getDomes() {
  87.         return domes;
  88.     }

  89.     /**
  90.      * Set the DOMES number.
  91.      * @param domes the DOMES number to set
  92.      */
  93.     public void setDomes(final String domes) {
  94.         this.domes = domes;
  95.     }

  96.     /**
  97.      * Get start of validity.
  98.      * @return start of validity
  99.      */
  100.     public AbsoluteDate getValidFrom() {
  101.         if (validFrom == null) {
  102.             validFrom = eccentricitiesTimeSpanMap.getFirstTransition().getDate();
  103.         }
  104.         return validFrom;
  105.     }

  106.     /**
  107.      * Set the start of validity.
  108.      * @param validFrom the start of validity to set
  109.      */
  110.     public void setValidFrom(final AbsoluteDate validFrom) {
  111.         this.validFrom = validFrom;
  112.     }

  113.     /**
  114.      * Get end of validity.
  115.      * @return end of validity
  116.      */
  117.     public AbsoluteDate getValidUntil() {
  118.         if (validUntil == null) {
  119.             validUntil = eccentricitiesTimeSpanMap.getLastTransition().getDate();
  120.         }
  121.         return validUntil;
  122.     }

  123.     /**
  124.      * Set the end of validity.
  125.      * @param validUntil the end of validity to set
  126.      */
  127.     public void setValidUntil(final AbsoluteDate validUntil) {
  128.         this.validUntil = validUntil;
  129.     }

  130.     /**
  131.      * Get the reference system used to define the eccentricity vector (local or cartesian).
  132.      * @return the reference system used to define the eccentricity vector
  133.      */
  134.     public ReferenceSystem getEccRefSystem() {
  135.         return eccRefSystem;
  136.     }

  137.     /**
  138.      * Set the reference system used to define the eccentricity vector (local or cartesian).
  139.      * @param eccRefSystem the reference system used to define the eccentricity vector
  140.      */
  141.     public void setEccRefSystem(final ReferenceSystem eccRefSystem) {
  142.         this.eccRefSystem = eccRefSystem;
  143.     }

  144.     /**
  145.      * Get the last known station antenna eccentricities.
  146.      * <p>
  147.      * Vector convention: X-Y-Z or UP-NORTH-EAST.
  148.      * See {@link #getEccRefSystem()} method.
  149.      * </p>
  150.      * @return station antenna eccentricities (m)
  151.      */
  152.     public Vector3D getEccentricities() {
  153.         return eccentricities;
  154.     }

  155.     /**
  156.      * Set the last known station antenna eccentricities.
  157.      * @param eccentricities the eccenticities to set (m)
  158.      */
  159.     public void setEccentricities(final Vector3D eccentricities) {
  160.         this.eccentricities = eccentricities;
  161.     }

  162.     /**
  163.      * Get the station antenna eccentricities for the given epoch.
  164.      * <p>
  165.      * Vector convention: X-Y-Z or UP-NORTH-EAST.
  166.      * See {@link #getEccRefSystem()} method.
  167.      * <p>
  168.      * If there is no eccentricity values for the given epoch, an
  169.      * exception is thrown. It is possible to access the last known
  170.      * values using the {@link #getEccentricities()} method.
  171.      * @param date epoch
  172.      * @return station antenna eccentricities (m)
  173.      * @since 11.1
  174.      */
  175.     public Vector3D getEccentricities(final AbsoluteDate date) {
  176.         final Vector3D eccAtEpoch = eccentricitiesTimeSpanMap.get(date);
  177.         // If the entry is null, there is no valid eccentricity values for the input epoch
  178.         if (eccAtEpoch == null) {
  179.             // Throw an exception
  180.             throw new OrekitException(OrekitMessages.NO_STATION_ECCENTRICITY_FOR_EPOCH, date, getValidFrom(), getValidUntil());
  181.         }
  182.         return eccAtEpoch;
  183.     }

  184.     /**
  185.      * Get the TimeSpanMap of site antenna eccentricities.
  186.      * @return the TimeSpanMap of site antenna eccentricities
  187.      * @since 11.1
  188.      */
  189.     public TimeSpanMap<Vector3D> getEccentricitiesTimeSpanMap() {
  190.         return eccentricitiesTimeSpanMap;
  191.     }

  192.     /** Add a station eccentricity vector entry valid before a limit date.<br>
  193.      * Using <code>addStationEccentricitiesValidBefore(entry, t)</code> will make <code>entry</code>
  194.      * valid in ]-∞, t[ (note the open bracket).
  195.      * @param entry station eccentricity vector entry
  196.      * @param latestValidityDate date before which the entry is valid
  197.      * (must be different from <b>all</b> dates already used for transitions)
  198.      * @since 11.1
  199.      */
  200.     public void addStationEccentricitiesValidBefore(final Vector3D entry, final AbsoluteDate latestValidityDate) {
  201.         eccentricitiesTimeSpanMap.addValidBefore(entry, latestValidityDate, false);
  202.     }

  203.     /** Add a station eccentricity vector entry valid after a limit date.<br>
  204.      * Using <code>addStationEccentricitiesValidAfter(entry, t)</code> will make <code>entry</code>
  205.      * valid in [t, +∞[ (note the closed bracket).
  206.      * @param entry station eccentricity vector entry
  207.      * @param earliestValidityDate date after which the entry is valid
  208.      * (must be different from <b>all</b> dates already used for transitions)
  209.      * @since 11.1
  210.      */
  211.     public void addStationEccentricitiesValidAfter(final Vector3D entry, final AbsoluteDate earliestValidityDate) {
  212.         eccentricitiesTimeSpanMap.addValidAfter(entry, earliestValidityDate, false);
  213.     }

  214.     /**
  215.      * Get the station position.
  216.      * @return the station position (m)
  217.      */
  218.     public Vector3D getPosition() {
  219.         return position;
  220.     }

  221.     /**
  222.      * Set the station position.
  223.      * @param position the position to set
  224.      */
  225.     public void setPosition(final Vector3D position) {
  226.         this.position = position;
  227.     }

  228.     /**
  229.      * Get the station velocity.
  230.      * @return the station velocity (m/s)
  231.      */
  232.     public Vector3D getVelocity() {
  233.         return velocity;
  234.     }

  235.     /**
  236.      * Set the station velocity.
  237.      * @param velocity the velocity to set
  238.      */
  239.     public void setVelocity(final Vector3D velocity) {
  240.         this.velocity = velocity;
  241.     }

  242.     /**
  243.      * Get the coordinates reference epoch.
  244.      * @return the coordinates reference epoch
  245.      */
  246.     public AbsoluteDate getEpoch() {
  247.         return epoch;
  248.     }

  249.     /**
  250.      * Set the coordinates reference epoch.
  251.      * @param epoch the epoch to set
  252.      */
  253.     public void setEpoch(final AbsoluteDate epoch) {
  254.         this.epoch = epoch;
  255.     }

  256.     /** Eccentricity reference system. */
  257.     public enum ReferenceSystem {

  258.         /** Local reference system Up, North, East. */
  259.         UNE("UNE"),

  260.         /** Cartesian reference system X, Y, Z. */
  261.         XYZ("XYZ");

  262.         /** Codes map. */
  263.         private static final Map<String, ReferenceSystem> CODES_MAP = new HashMap<>();
  264.         static {
  265.             for (final ReferenceSystem type : values()) {
  266.                 CODES_MAP.put(type.getName(), type);
  267.             }
  268.         }

  269.         /** Name used to define the reference system in SINEX file. */
  270.         private final String name;

  271.         /**
  272.          * Constructor.
  273.          * @param name name used to define the reference system in SINEX file
  274.          */
  275.         ReferenceSystem(final String name) {
  276.             this.name = name;
  277.         }

  278.         /**
  279.          * Get the name used to define the reference system in SINEX file.
  280.          * @return the name
  281.          */
  282.         public String getName() {
  283.             return name;
  284.         }

  285.         /**
  286.          * Get the eccentricity reference system corresponding to the given value.
  287.          * @param value given value
  288.          * @return the corresponding eccentricity reference system
  289.          */
  290.         public static ReferenceSystem getEccRefSystem(final String value) {
  291.             return CODES_MAP.get(value);
  292.         }

  293.     }

  294. }