ODMMetaData.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.files.ccsds;

  18. import java.util.ArrayList;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.orekit.bodies.CelestialBody;
  22. import org.orekit.bodies.CelestialBodyFactory;
  23. import org.orekit.errors.OrekitException;
  24. import org.orekit.errors.OrekitMessages;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.time.AbsoluteDate;

  27. /** This class gathers the meta-data present in the Orbital Data Message (ODM).
  28.  * @author sports
  29.  * @since 6.1
  30.  */
  31. public class ODMMetaData {

  32.     /** ODM file to which these meta-data belong. */
  33.     private final ODMFile odmFile;

  34.     /** Time System: used for metadata, orbit state and covariance data. */
  35.     private CcsdsTimeScale timeSystem;

  36.     /** Spacecraft name for which the orbit state is provided. */
  37.     private String objectName;

  38.     /** Object identifier of the object for which the orbit state is provided. */
  39.     private String objectID;

  40.     /** Launch Year. */
  41.     private int launchYear;

  42.     /** Launch number. */
  43.     private int launchNumber;

  44.     /** Piece of launch (from "A" to "ZZZ"). */
  45.     private String launchPiece;

  46.     /** Origin of reference frame. */
  47.     private String centerName;

  48.     /** Celestial body corresponding to the center name. */
  49.     private CelestialBody centerBody;

  50.     /** Tests whether the body corresponding to the center name can be
  51.      * created through the {@link org.orekit.bodies.CelestialBodyFactory} in order to obtain the
  52.      * corresponding gravitational coefficient. */
  53.     private boolean hasCreatableBody;

  54.     /** Reference frame in which data are given: used for state vector
  55.      * and Keplerian elements data (and for the covariance reference frame if none is given). */
  56.     private Frame refFrame;

  57.     /** The reference frame specifier, as it appeared in the file. */
  58.     private String refFrameString;

  59.     /** Epoch of reference frame, if not intrinsic to the definition of the
  60.      * reference frame. */
  61.     private String frameEpochString;

  62.     /** Epoch of reference frame, if not intrinsic to the definition of the
  63.      * reference frame. */
  64.     private AbsoluteDate frameEpoch;

  65.     /** Metadata comments. The list contains a string for each line of comment. */
  66.     private List<String> comment;

  67.     /** Create a new meta-data.
  68.      * @param odmFile ODM file to which these meta-data belong
  69.      */
  70.     ODMMetaData(final ODMFile odmFile) {
  71.         this.odmFile = odmFile;
  72.         comment = new ArrayList<String>();
  73.     }

  74.     /** Get the ODM file to which these meta-data belong.
  75.      * @return ODM file to which these meta-data belong
  76.      */
  77.     public ODMFile getODMFile() {
  78.         return odmFile;
  79.     }

  80.     /** Get the Time System that: for OPM, is used for metadata, state vector,
  81.      * maneuver and covariance data, for OMM, is used for metadata, orbit state
  82.      * and covariance data, for OEM, is used for metadata, ephemeris and
  83.      * covariance data.
  84.      * @return the time system
  85.      */
  86.     public CcsdsTimeScale getTimeSystem() {
  87.         return timeSystem;
  88.     }

  89.     /** Set the Time System that: for OPM, is used for metadata, state vector,
  90.      * maneuver and covariance data, for OMM, is used for metadata, orbit state
  91.      * and covariance data, for OEM, is used for metadata, ephemeris and
  92.      * covariance data.
  93.      * @param timeSystem the time system to be set
  94.      */
  95.     void setTimeSystem(final CcsdsTimeScale timeSystem) {
  96.         this.timeSystem = timeSystem;
  97.     }

  98.     /** Get the spacecraft name for which the orbit state is provided.
  99.      * @return the spacecraft name
  100.      */
  101.     public String getObjectName() {
  102.         return objectName;
  103.     }

  104.     /** Set the spacecraft name for which the orbit state is provided.
  105.      * @param objectName the spacecraft name to be set
  106.      */
  107.     void setObjectName(final String objectName) {
  108.         this.objectName = objectName;
  109.     }

  110.     /** Get the spacecraft ID for which the orbit state is provided.
  111.      * @return the spacecraft ID
  112.      */
  113.     public String getObjectID() {
  114.         return objectID;
  115.     }

  116.     /** Set the spacecraft ID for which the orbit state is provided.
  117.      * @param objectID the spacecraft ID to be set
  118.      */
  119.     void setObjectID(final String objectID) {
  120.         this.objectID = objectID;
  121.     }

  122.     /** Set the launch year.
  123.      * @param launchYear launch year
  124.      */
  125.     void setLaunchYear(final int launchYear) {
  126.         this.launchYear = launchYear;
  127.     }

  128.     /** Get the launch year.
  129.      * @return launch year
  130.      */
  131.     public int getLaunchYear() {
  132.         return launchYear;
  133.     }

  134.     /** Set the launch number.
  135.      * @param launchNumber launch number
  136.      */
  137.     void setLaunchNumber(final int launchNumber) {
  138.         this.launchNumber = launchNumber;
  139.     }

  140.     /** Get the launch number.
  141.      * @return launch number
  142.      */
  143.     public int getLaunchNumber() {
  144.         return launchNumber;
  145.     }

  146.     /** Set the piece of launch.
  147.      * @param launchPiece piece of launch
  148.      */
  149.     void setLaunchPiece(final String launchPiece) {
  150.         this.launchPiece = launchPiece;
  151.     }

  152.     /** Get the piece of launch.
  153.      * @return piece of launch
  154.      */
  155.     public String getLaunchPiece() {
  156.         return launchPiece;
  157.     }

  158.     /** Get the origin of reference frame.
  159.      * @return the origin of reference frame.
  160.      */
  161.     public String getCenterName() {
  162.         return centerName;
  163.     }

  164.     /** Set the origin of reference frame.
  165.      * @param centerName the origin of reference frame to be set
  166.      */
  167.     void setCenterName(final String centerName) {
  168.         this.centerName = centerName;
  169.     }

  170.     /** Get the {@link CelestialBody} corresponding to the center name.
  171.      * @return the center body
  172.      */
  173.     public CelestialBody getCenterBody() {
  174.         return centerBody;
  175.     }

  176.     /** Set the {@link CelestialBody} corresponding to the center name.
  177.      * @param centerBody the {@link CelestialBody} to be set
  178.      */
  179.     void setCenterBody(final CelestialBody centerBody) {
  180.         this.centerBody = centerBody;
  181.     }

  182.     /** Get boolean testing whether the body corresponding to the centerName
  183.      * attribute can be created through the {@link org.orekit.bodies.CelestialBodyFactory}.
  184.      * @return true if {@link CelestialBody} can be created from centerName
  185.      *         false otherwise
  186.      */
  187.     public boolean getHasCreatableBody() {
  188.         return hasCreatableBody;
  189.     }

  190.     /** Set boolean testing whether the body corresponding to the centerName
  191.      * attribute can be created through the {@link org.orekit.bodies.CelestialBodyFactory}.
  192.      * @param hasCreatableBody the boolean to be set.
  193.      */
  194.     void setHasCreatableBody(final boolean hasCreatableBody) {
  195.         this.hasCreatableBody = hasCreatableBody;
  196.     }

  197.     /**
  198.      * Get the reference frame in which data are given: used for state vector and
  199.      * Keplerian elements data (and for the covariance reference frame if none is given).
  200.      *
  201.      * @return the reference frame
  202.      */
  203.     public Frame getFrame() {
  204.         final Frame frame = this.getRefFrame();
  205.         final CelestialBody body = this.getCenterBody();
  206.         if (body == null) {
  207.             throw new OrekitException(OrekitMessages.NO_DATA_LOADED_FOR_CELESTIAL_BODY,
  208.                     this.getCenterName());
  209.         }
  210.         // Just return frame if we don't need to shift the center based on CENTER_NAME
  211.         // MCI and ICRF are the only non-earth centered frames specified in Annex A.
  212.         final String frameString = this.getFrameString();
  213.         final boolean isMci = "MCI".equals(frameString);
  214.         final boolean isIcrf = "ICRF".equals(frameString);
  215.         final boolean isSolarSystemBarycenter =
  216.                 CelestialBodyFactory.SOLAR_SYSTEM_BARYCENTER.equals(body.getName());
  217.         if ((!(isMci || isIcrf) && CelestialBodyFactory.EARTH.equals(body.getName())) ||
  218.                 (isMci && CelestialBodyFactory.MARS.equals(body.getName())) ||
  219.                 (isIcrf && isSolarSystemBarycenter)) {
  220.             return frame;
  221.         }
  222.         // else, translate frame to specified center.
  223.         return new CcsdsModifiedFrame(frame, frameString, body, this.getCenterName());
  224.     }

  225.     /**
  226.      * Get the the value of {@code REF_FRAME} as an Orekit {@link Frame}. The {@code
  227.      * CENTER_NAME} key word has not been applied yet, so the returned frame may not
  228.      * correspond to the reference frame of the data in the file.
  229.      *
  230.      * @return The reference frame specified by the {@code REF_FRAME} keyword.
  231.      * @see #getFrame()
  232.      */
  233.     public Frame getRefFrame() {
  234.         return refFrame;
  235.     }

  236.     /** Set the reference frame in which data are given: used for state vector
  237.      * and Keplerian elements data (and for the covariance reference frame if none is given).
  238.      * @param refFrame the reference frame to be set
  239.      */
  240.     void setRefFrame(final Frame refFrame) {
  241.         this.refFrame = refFrame;
  242.     }

  243.     /**
  244.      * Get the reference frame specifier as it appeared in the file.
  245.      *
  246.      * @return the frame name as it appeared in the file.
  247.      * @see #getFrame()
  248.      */
  249.     public String getFrameString() {
  250.         return this.refFrameString;
  251.     }

  252.     /**
  253.      * Set the reference frame name.
  254.      *
  255.      * @param frame specifier as it appeared in the file.
  256.      */
  257.     void setFrameString(final String frame) {
  258.         this.refFrameString = frame;
  259.     }

  260.     /** Get epoch of reference frame, if not intrinsic to the definition of the
  261.      * reference frame.
  262.      * @return epoch of reference frame
  263.      */
  264.     public String getFrameEpochString() {
  265.         return frameEpochString;
  266.     }

  267.     /** Set epoch of reference frame, if not intrinsic to the definition of the
  268.      * reference frame.
  269.      * @param frameEpochString the epoch of reference frame to be set
  270.      */
  271.     void setFrameEpochString(final String frameEpochString) {
  272.         this.frameEpochString = frameEpochString;
  273.     }

  274.     /** Get epoch of reference frame, if not intrinsic to the definition of the
  275.      * reference frame.
  276.      * @return epoch of reference frame
  277.      */
  278.     public AbsoluteDate getFrameEpoch() {
  279.         return frameEpoch;
  280.     }

  281.     /** Set epoch of reference frame, if not intrinsic to the definition of the
  282.      * reference frame.
  283.      * @param frameEpoch the epoch of reference frame to be set
  284.      */
  285.     void setFrameEpoch(final AbsoluteDate frameEpoch) {
  286.         this.frameEpoch = frameEpoch;
  287.     }

  288.     /** Get the meta-data comment.
  289.      * @return meta-data comment
  290.      */
  291.     public List<String> getComment() {
  292.         return Collections.unmodifiableList(comment);
  293.     }

  294.     /** Set the meta-data comment.
  295.      * @param comment comment to set
  296.      */
  297.     void setComment(final List<String> comment) {
  298.         this.comment = new ArrayList<String>(comment);
  299.     }

  300. }