ODMFile.java

  1. /* Copyright 2002-2013 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.errors.OrekitException;
  22. import org.orekit.errors.OrekitMessages;
  23. import org.orekit.files.general.OrbitFile;
  24. import org.orekit.files.general.SatelliteTimeCoordinate;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.utils.IERSConventions;

  27. /**
  28.  * The ODMFile (Orbit Data Message) class represents any of the three orbit messages used by the CCSDS,
  29.  * i.e. the Orbit Parameter Message (OPM), the Mean-Elements Message (OMM) and the Orbit Ephemeris Message (OEM).
  30.  * It contains the information of the message's header and configuration data (set in the parser).
  31.  * @author sports
  32.  * @since 6.1
  33.  */
  34. public abstract class ODMFile implements OrbitFile {

  35.     /** CCSDS Format version. */
  36.     private double formatVersion;

  37.     /** Header comments. The list contains a string for each line of comment. */
  38.     private List<String> headerComment;

  39.     /** File creation date and time in UTC. */
  40.     private AbsoluteDate creationDate;

  41.     /** Creating agency or operator. */
  42.     private String originator;

  43.     /** Gravitational coefficient set by the user in the parser. */
  44.     private double muSet;

  45.     /** Gravitational coefficient parsed in the ODM File. */
  46.     private double muParsed;

  47.     /** Gravitational coefficient created from the knowledge of the central body. */
  48.     private double muCreated;

  49.     /** IERS conventions used. */
  50.     private IERSConventions conventions;

  51.     /** Final gravitational coefficient (used for the public methods that need such a parameter, ex: generateCartesianOrbit).
  52.      * In order of decreasing priority, finalMU is equal to: the coefficient parsed in the file, the coefficient set by the
  53.      * user with the parser's method setMu, the coefficient created from the knowledge of the central body.
  54.      */
  55.     private double muUsed;

  56.     /** Initial Date for MET or MRT time systems. */
  57.     private AbsoluteDate missionReferenceDate;

  58.     /** ODMFile constructor. */
  59.     public ODMFile() {
  60.         muSet     = Double.NaN;
  61.         muParsed  = Double.NaN;
  62.         muCreated = Double.NaN;
  63.         muUsed    = Double.NaN;
  64.     }

  65.     /**
  66.      * Get the gravitational coefficient set by the user.
  67.      * @return the coefficient
  68.      */
  69.     public double getMuSet() {
  70.         return muSet;
  71.     }

  72.     /**
  73.      * Set the gravitational coefficient set by the user.
  74.      * @param muSet the coefficient to be set
  75.      */
  76.     void setMuSet(final double muSet) {
  77.         this.muSet = muSet;
  78.     }

  79.     /**
  80.      * Get the gravitational coefficient parsed in the ODM File.
  81.      * @return the coefficient
  82.      */
  83.     public double getMuParsed() {
  84.         return muParsed;
  85.     }

  86.     /**
  87.      * Set the gravitational coefficient parsed in the ODM File.
  88.      * @param muParsed the coefficient to be set
  89.      */
  90.     void setMuParsed(final double muParsed) {
  91.         this.muParsed = muParsed;
  92.     }

  93.     /**
  94.      * Get the gravitational coefficient created from the knowledge of the central body.
  95.      * @return the coefficient
  96.      */
  97.     public double getMuCreated() {
  98.         return muCreated;
  99.     }

  100.     /**
  101.      * Set the gravitational coefficient created from the knowledge of the central body.
  102.      * @param muCreated the coefficient to be set
  103.      */
  104.     void setMuCreated(final double muCreated) {
  105.         this.muCreated = muCreated;
  106.     }

  107.     /**
  108.      * Get the used gravitational coefficient.
  109.      * @return the coefficient
  110.      */
  111.     public double getMuUsed() {
  112.         return muUsed;
  113.     }

  114.     /**
  115.      * Set the gravitational coefficient created from the knowledge of the central body.
  116.      * In order of decreasing priority, finalMU is set equal to:
  117.      * <ol>
  118.      *   <li>the coefficient parsed in the file,</li>
  119.      *   <li>the coefficient set by the user with the parser's method setMu,</li>
  120.      *   <li>the coefficient created from the knowledge of the central body.</li>
  121.      * </ol>
  122.      * @throws OrekitException if no gravitational coefficient can be found
  123.      */
  124.     protected void setMuUsed() throws OrekitException {
  125.         if (!Double.isNaN(muParsed)) {
  126.             muUsed = muParsed;
  127.         } else if (!Double.isNaN(muSet)) {
  128.             muUsed = muSet;
  129.         } else if (!Double.isNaN(muCreated)) {
  130.             muUsed = muCreated;
  131.         } else {
  132.             throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_GM);
  133.         }
  134.     }

  135.     /** Get IERS conventions.
  136.      * @return conventions IERS conventions
  137.      * @exception OrekitException if no IERS conventions have been set
  138.      */
  139.     public IERSConventions getConventions() throws OrekitException {
  140.         if (conventions != null) {
  141.             return conventions;
  142.         } else {
  143.             throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  144.         }
  145.     }

  146.     /** Set IERS conventions.
  147.      * @param conventions IERS conventions to be set
  148.      */
  149.     void setConventions(final IERSConventions conventions) {
  150.         this.conventions = conventions;
  151.     }

  152.     /** Get reference date for Mission Elapsed Time and Mission Relative Time time systems.
  153.      * @return the reference date
  154.      */
  155.     public AbsoluteDate getMissionReferenceDate() {
  156.         return missionReferenceDate;
  157.     }

  158.     /** Set reference date for Mission Elapsed Time and Mission Relative Time time systems.
  159.      * @param missionReferenceDate reference date for Mission Elapsed Time and Mission Relative Time time systems.
  160.      */
  161.     void setMissionReferenceDate(final AbsoluteDate missionReferenceDate) {
  162.         this.missionReferenceDate = missionReferenceDate;
  163.     }

  164.     /** Get the CCSDS ODM (OPM, OMM or OEM) format version.
  165.      * @return format version
  166.      */
  167.     public double getFormatVersion() {
  168.         return formatVersion;
  169.     }

  170.     /** Set the CCSDS ODM (OPM, OMM or OEM) format version.
  171.      * @param formatVersion the format version to be set
  172.      */
  173.     void setFormatVersion(final double formatVersion) {
  174.         this.formatVersion = formatVersion;
  175.     }

  176.     /** Get the header comment.
  177.      * @return header comment
  178.      */
  179.     public List<String> getHeaderComment() {
  180.         return headerComment;
  181.     }

  182.     /** Set the header comment.
  183.      * @param headerComment header comment
  184.      */
  185.     void setHeaderComment(final List<String> headerComment) {
  186.         this.headerComment = new ArrayList<String>(headerComment);
  187.     }

  188.     /** Get the file creation date and time in UTC.
  189.      * @return the file creation date and time in UTC.
  190.      */
  191.     public AbsoluteDate getCreationDate() {
  192.         return creationDate;
  193.     }

  194.     /** Set the file creation date and time in UTC.
  195.      * @param creationDate the creation date to be set
  196.      */
  197.     void setCreationDate(final AbsoluteDate creationDate) {
  198.         this.creationDate = creationDate;
  199.     }

  200.     /** Get the file originator.
  201.      * @return originator the file originator.
  202.      */
  203.     public String getOriginator() {
  204.         return originator;
  205.     }

  206.     /** Set the file originator.
  207.      * @param originator the originator to be set
  208.      */
  209.     void setOriginator(final String originator) {
  210.         this.originator = originator;
  211.     }

  212.     /**
  213.      * Not supported by CCSDS orbit messages.
  214.      * @return always throws an {@link UnsupportedOperationException}
  215.      * @throws UnsupportedOperationException always
  216.      */
  217.     @Override
  218.     public double getEpochInterval() {
  219.         throw new UnsupportedOperationException();
  220.     }

  221.     /**
  222.      * Not supported by CCSDS orbit messages.
  223.      * @return always throws an {@link UnsupportedOperationException}
  224.      * @throws UnsupportedOperationException always
  225.      */
  226.     @Override
  227.     public int getNumberOfEpochs() {
  228.         throw new UnsupportedOperationException();
  229.     }

  230.     /** {@inheritDoc} */
  231.     @Override
  232.     public boolean containsSatellite(final String satId) {
  233.         return getSatellite(satId) != null;
  234.     }

  235.     /** {@inheritDoc} */
  236.     @Override
  237.     public List<SatelliteTimeCoordinate> getSatelliteCoordinates(final String satId) {
  238.         return Collections.emptyList();
  239.     }

  240. }