ODMMetaData.java

  1. /* Copyright 2002-2018 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.      * @throws OrekitException if the reference frame cannot be created.
  203.      */
  204.     public Frame getFrame() throws OrekitException {
  205.         final Frame frame = this.getRefFrame();
  206.         final CelestialBody body = this.getCenterBody();
  207.         if (body == null) {
  208.             throw new OrekitException(OrekitMessages.NO_DATA_LOADED_FOR_CELESTIAL_BODY,
  209.                     this.getCenterName());
  210.         }
  211.         // Just return frame if we don't need to shift the center based on CENTER_NAME
  212.         // MCI and ICRF are the only non-earth centered frames specified in Annex A.
  213.         final String frameString = this.getFrameString();
  214.         final boolean isMci = "MCI".equals(frameString);
  215.         final boolean isIcrf = "ICRF".equals(frameString);
  216.         final boolean isSolarSystemBarycenter =
  217.                 CelestialBodyFactory.SOLAR_SYSTEM_BARYCENTER.equals(body.getName());
  218.         if ((!(isMci || isIcrf) && CelestialBodyFactory.EARTH.equals(body.getName())) ||
  219.                 (isMci && CelestialBodyFactory.MARS.equals(body.getName())) ||
  220.                 (isIcrf && isSolarSystemBarycenter)) {
  221.             return frame;
  222.         }
  223.         // else, translate frame to specified center.
  224.         return new CcsdsModifiedFrame(frame, frameString, body, this.getCenterName());
  225.     }

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

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

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

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

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

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

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

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

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

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

  301. }