Station.java

  1. /* Copyright 2002-2024 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.
  30.  * The {@link #getEccentricities(AbsoluteDate)} method can be
  31.  * used to access the site antenna eccentricity values for a
  32.  * given epoch.
  33.  * </p>
  34.  * @author Bryan Cazabonne
  35.  * @since 10.3
  36.  */
  37. public class Station {

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

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

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

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

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

  48.     /** TimeSpanMap of site antenna eccentricities. */
  49.     private TimeSpanMap<Vector3D> eccentricitiesTimeSpanMap;

  50.     /** Antenna type.
  51.      * @since 12.0
  52.      */
  53.     private TimeSpanMap<String> antennaTypesMap;

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

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

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

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

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

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

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

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

  97.     /**
  98.      * Get start of validity.
  99.      * @return start of validity
  100.      */
  101.     public AbsoluteDate getValidFrom() {
  102.         return validFrom;
  103.     }

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

  111.     /**
  112.      * Get end of validity.
  113.      * @return end of validity
  114.      */
  115.     public AbsoluteDate getValidUntil() {
  116.         return validUntil;
  117.     }

  118.     /**
  119.      * Set the end of validity.
  120.      * @param validUntil the end of validity to set
  121.      */
  122.     public void setValidUntil(final AbsoluteDate validUntil) {
  123.         this.validUntil = validUntil;
  124.     }

  125.     /**
  126.      * Get the reference system used to define the eccentricity vector (local or cartesian).
  127.      * @return the reference system used to define the eccentricity vector
  128.      */
  129.     public ReferenceSystem getEccRefSystem() {
  130.         return eccRefSystem;
  131.     }

  132.     /**
  133.      * Set the reference system used to define the eccentricity vector (local or cartesian).
  134.      * @param eccRefSystem the reference system used to define the eccentricity vector
  135.      */
  136.     public void setEccRefSystem(final ReferenceSystem eccRefSystem) {
  137.         this.eccRefSystem = eccRefSystem;
  138.     }

  139.     /**
  140.      * Get the station antenna eccentricities for the given epoch.
  141.      * <p>
  142.      * Vector convention: X-Y-Z or UP-NORTH-EAST.
  143.      * See {@link #getEccRefSystem()} method.
  144.      * <p>
  145.      * If there is no eccentricity values for the given epoch, an
  146.      * exception is thrown.
  147.      * @param date epoch
  148.      * @return station antenna eccentricities (m)
  149.      * @since 11.1
  150.      */
  151.     public Vector3D getEccentricities(final AbsoluteDate date) {
  152.         final Vector3D eccAtEpoch = eccentricitiesTimeSpanMap.get(date);
  153.         // If the entry is null, there is no valid eccentricity values for the input epoch
  154.         if (eccAtEpoch == null) {
  155.             // Throw an exception
  156.             throw new OrekitException(OrekitMessages.MISSING_STATION_DATA_FOR_EPOCH, date);
  157.         }
  158.         return eccAtEpoch;
  159.     }

  160.     /**
  161.      * Get the TimeSpanMap of site antenna eccentricities.
  162.      * @return the TimeSpanMap of site antenna eccentricities
  163.      * @since 11.1
  164.      */
  165.     public TimeSpanMap<Vector3D> getEccentricitiesTimeSpanMap() {
  166.         return eccentricitiesTimeSpanMap;
  167.     }

  168.     /** Add a station eccentricity vector entry valid before a limit date.<br>
  169.      * Using <code>addStationEccentricitiesValidBefore(entry, t)</code> will make <code>entry</code>
  170.      * valid in ]-∞, t[ (note the open bracket).
  171.      * @param entry station eccentricity vector entry
  172.      * @param latestValidityDate date before which the entry is valid
  173.      * (must be different from <b>all</b> dates already used for transitions)
  174.      * @since 11.1
  175.      */
  176.     public void addStationEccentricitiesValidBefore(final Vector3D entry, final AbsoluteDate latestValidityDate) {
  177.         eccentricitiesTimeSpanMap.addValidBefore(entry, latestValidityDate, false);
  178.     }

  179.     /** Add a station eccentricity vector entry valid after a limit date.<br>
  180.      * Using <code>addStationEccentricitiesValidAfter(entry, t)</code> will make <code>entry</code>
  181.      * valid in [t, +∞[ (note the closed bracket).
  182.      * @param entry station eccentricity vector entry
  183.      * @param earliestValidityDate date after which the entry is valid
  184.      * (must be different from <b>all</b> dates already used for transitions)
  185.      * @since 11.1
  186.      */
  187.     public void addStationEccentricitiesValidAfter(final Vector3D entry, final AbsoluteDate earliestValidityDate) {
  188.         eccentricitiesTimeSpanMap.addValidAfter(entry, earliestValidityDate, false);
  189.     }

  190.     /**
  191.      * Get the antenna type for the given epoch.
  192.      * If there is no antenna types for the given epoch, an
  193.      * exception is thrown.
  194.      * @param date epoch
  195.      * @return antenna type
  196.      * @since 12.0
  197.      */
  198.     public String getAntennaType(final AbsoluteDate date) {
  199.         final String typeAtEpoch = antennaTypesMap.get(date);
  200.         // If the entry is null, there is no valid type for the input epoch
  201.         if (typeAtEpoch == null) {
  202.             // Throw an exception
  203.             throw new OrekitException(OrekitMessages.MISSING_STATION_DATA_FOR_EPOCH, date);
  204.         }
  205.         return typeAtEpoch;
  206.     }

  207.     /**
  208.      * Get the TimeSpanMap of site antenna type.
  209.      * @return the TimeSpanMap of site antenna type
  210.      * @since 12.0
  211.      */
  212.     public TimeSpanMap<String> getAntennaTypeTimeSpanMap() {
  213.         return antennaTypesMap;
  214.     }

  215.     /** Add a antenna type entry valid before a limit date.<br>
  216.      * Using <code>addAntennaTypeValidBefore(entry, t)</code> will make <code>entry</code>
  217.      * valid in ]-∞, t[ (note the open bracket).
  218.      * @param entry antenna type entry
  219.      * @param latestValidityDate date before which the entry is valid
  220.      * (must be different from <b>all</b> dates already used for transitions)
  221.      * @since 12.0
  222.      */
  223.     public void addAntennaTypeValidBefore(final String entry, final AbsoluteDate latestValidityDate) {
  224.         antennaTypesMap.addValidBefore(entry, latestValidityDate, false);
  225.     }

  226.     /** Add a antenna type entry valid after a limit date.<br>
  227.      * Using <code>addAntennaTypeValidAfter(entry, t)</code> will make <code>entry</code>
  228.      * valid in [t, +∞[ (note the closed bracket).
  229.      * @param entry antenna type entry
  230.      * @param earliestValidityDate date after which the entry is valid
  231.      * (must be different from <b>all</b> dates already used for transitions)
  232.      * @since 12.0
  233.      */
  234.     public void addAntennaTypeValidAfter(final String entry, final AbsoluteDate earliestValidityDate) {
  235.         antennaTypesMap.addValidAfter(entry, earliestValidityDate, false);
  236.     }

  237.     /**
  238.      * Get the station position.
  239.      * @return the station position (m)
  240.      */
  241.     public Vector3D getPosition() {
  242.         return position;
  243.     }

  244.     /**
  245.      * Set the station position.
  246.      * @param position the position to set
  247.      */
  248.     public void setPosition(final Vector3D position) {
  249.         this.position = position;
  250.     }

  251.     /**
  252.      * Get the station velocity.
  253.      * @return the station velocity (m/s)
  254.      */
  255.     public Vector3D getVelocity() {
  256.         return velocity;
  257.     }

  258.     /**
  259.      * Set the station velocity.
  260.      * @param velocity the velocity to set
  261.      */
  262.     public void setVelocity(final Vector3D velocity) {
  263.         this.velocity = velocity;
  264.     }

  265.     /**
  266.      * Get the coordinates reference epoch.
  267.      * @return the coordinates reference epoch
  268.      */
  269.     public AbsoluteDate getEpoch() {
  270.         return epoch;
  271.     }

  272.     /**
  273.      * Set the coordinates reference epoch.
  274.      * @param epoch the epoch to set
  275.      */
  276.     public void setEpoch(final AbsoluteDate epoch) {
  277.         this.epoch = epoch;
  278.     }

  279.     /** Eccentricity reference system. */
  280.     public enum ReferenceSystem {

  281.         /** Local reference system Up, North, East. */
  282.         UNE("UNE"),

  283.         /** Cartesian reference system X, Y, Z. */
  284.         XYZ("XYZ");

  285.         /** Codes map. */
  286.         private static final Map<String, ReferenceSystem> CODES_MAP = new HashMap<>();
  287.         static {
  288.             for (final ReferenceSystem type : values()) {
  289.                 CODES_MAP.put(type.getName(), type);
  290.             }
  291.         }

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

  294.         /**
  295.          * Constructor.
  296.          * @param name name used to define the reference system in SINEX file
  297.          */
  298.         ReferenceSystem(final String name) {
  299.             this.name = name;
  300.         }

  301.         /**
  302.          * Get the name used to define the reference system in SINEX file.
  303.          * @return the name
  304.          */
  305.         public String getName() {
  306.             return name;
  307.         }

  308.         /**
  309.          * Get the eccentricity reference system corresponding to the given value.
  310.          * @param value given value
  311.          * @return the corresponding eccentricity reference system
  312.          */
  313.         public static ReferenceSystem getEccRefSystem(final String value) {
  314.             return CODES_MAP.get(value);
  315.         }

  316.     }

  317. }