CCSDSFrame.java

  1. /* Copyright 2002-2017 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 org.orekit.bodies.CelestialBodyFactory;
  19. import org.orekit.errors.OrekitException;
  20. import org.orekit.errors.OrekitMessages;
  21. import org.orekit.frames.Frame;
  22. import org.orekit.frames.FramesFactory;
  23. import org.orekit.frames.HelmertTransformation;
  24. import org.orekit.frames.LOFType;
  25. import org.orekit.utils.IERSConventions;

  26. /** Frames used in CCSDS Orbit Data Messages.
  27.  * @author Steven Ports
  28.  * @since 6.1
  29.  */
  30. public enum CCSDSFrame {

  31.     /** Earth Mean Equator and Equinox of J2000. */
  32.     EME2000(null) {

  33.         /** {@inheritDoc} */
  34.         @Override
  35.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  36.             throws OrekitException {
  37.             return FramesFactory.getEME2000();
  38.         }

  39.     },

  40.     /** Geocentric Celestial Reference Frame. */
  41.     GCRF(null) {

  42.         /** {@inheritDoc} */
  43.         @Override
  44.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  45.             throws OrekitException {
  46.             return FramesFactory.getGCRF();
  47.         }

  48.     },

  49.     /** Greenwich Rotating Coordinates. */
  50.     GRC(null) {

  51.         /** {@inheritDoc} */
  52.         @Override
  53.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  54.             throws OrekitException {
  55.             if (conventions == null) {
  56.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  57.             }
  58.             return FramesFactory.getITRFEquinox(conventions, simpleEOP);
  59.         }

  60.     },

  61.     /** International Celestial Reference Frame. */
  62.     ICRF(null) {

  63.         /** {@inheritDoc} */
  64.         @Override
  65.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  66.             throws OrekitException {
  67.             return FramesFactory.getICRF();
  68.         }

  69.     },

  70.     /** International Celestial Reference Frame 2008. */
  71.     ITRF2008(null) {

  72.         /** {@inheritDoc} */
  73.         @Override
  74.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  75.                 throws OrekitException {
  76.             if (conventions == null) {
  77.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  78.             }
  79.             return FramesFactory.getITRF(conventions, simpleEOP);
  80.         }

  81.     },

  82.     /** International Celestial Reference Frame 2005. */
  83.     ITRF2005(null) {

  84.         /** {@inheritDoc} */
  85.         @Override
  86.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  87.             throws OrekitException {
  88.             if (conventions == null) {
  89.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  90.             }
  91.             final Frame itrf2008 = FramesFactory.getITRF(conventions, simpleEOP);
  92.             final HelmertTransformation.Predefined predefinedHT =
  93.                     HelmertTransformation.Predefined.ITRF_2008_TO_ITRF_2005;
  94.             return predefinedHT.createTransformedITRF(itrf2008, toString());
  95.         }

  96.     },

  97.     /** International Celestial Reference Frame 2000. */
  98.     ITRF2000(null) {

  99.         /** {@inheritDoc} */
  100.         @Override
  101.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  102.             throws OrekitException {
  103.             if (conventions == null) {
  104.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  105.             }
  106.             final Frame itrf2008 = FramesFactory.getITRF(conventions, simpleEOP);
  107.             final HelmertTransformation.Predefined predefinedHT =
  108.                     HelmertTransformation.Predefined.ITRF_2008_TO_ITRF_2000;
  109.             return predefinedHT.createTransformedITRF(itrf2008, toString());
  110.         }

  111.     },

  112.     /** International Celestial Reference Frame 1993. */
  113.     ITRF93(null) {

  114.         /** {@inheritDoc} */
  115.         @Override
  116.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  117.             throws OrekitException {
  118.             if (conventions == null) {
  119.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  120.             }
  121.             final Frame itrf2008 = FramesFactory.getITRF(conventions, simpleEOP);
  122.             final HelmertTransformation.Predefined predefinedHT =
  123.                     HelmertTransformation.Predefined.ITRF_2008_TO_ITRF_93;
  124.             return predefinedHT.createTransformedITRF(itrf2008, toString());
  125.         }

  126.     },

  127.     /** International Celestial Reference Frame 1997. */
  128.     ITRF97(null) {

  129.         /** {@inheritDoc} */
  130.         @Override
  131.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  132.             throws OrekitException {
  133.             if (conventions == null) {
  134.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  135.             }
  136.             final Frame itrf2008 = FramesFactory.getITRF(conventions, simpleEOP);
  137.             final HelmertTransformation.Predefined predefinedHT =
  138.                     HelmertTransformation.Predefined.ITRF_2008_TO_ITRF_97;
  139.             return predefinedHT.createTransformedITRF(itrf2008, toString());
  140.         }

  141.     },

  142.     /** Mars Centered Inertial. */
  143.     MCI(null) {

  144.         /** {@inheritDoc} */
  145.         @Override
  146.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  147.             throws OrekitException {
  148.             return CelestialBodyFactory.getMars().getInertiallyOrientedFrame();
  149.         }

  150.     },

  151.     /** True of Date, Rotating. */
  152.     TDR(null) {

  153.         /** {@inheritDoc} */
  154.         @Override
  155.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  156.             throws OrekitException {
  157.             if (conventions == null) {
  158.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  159.             }
  160.             return FramesFactory.getGTOD(conventions, simpleEOP);
  161.         }

  162.     },

  163.     /**
  164.      * True Equator Mean Equinox.
  165.      * TEME may be used only for OMMs based on NORAD
  166.      * Two Line Element sets, and in no other circumstances.
  167.      */
  168.     TEME(null) {

  169.         /** {@inheritDoc} */
  170.         @Override
  171.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  172.             throws OrekitException {
  173.             return FramesFactory.getTEME();
  174.         }

  175.     },

  176.     /** True of Date. */
  177.     TOD(null) {

  178.         /** {@inheritDoc} */
  179.         @Override
  180.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  181.             throws OrekitException {
  182.             if (conventions == null) {
  183.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  184.             }
  185.             return FramesFactory.getTOD(conventions, simpleEOP);
  186.         }

  187.     },

  188.     /** Radial, Transverse (along-track) and Normal. */
  189.     RTN(LOFType.QSW),

  190.     /** Another name for Radial, Transverse (along-track) and Normal. */
  191.     RSW(LOFType.QSW),

  192.     /** TNW : x-axis along the velocity vector, W along the orbital angular momentum vector and
  193.     N completes the right handed system. */
  194.     TNW(LOFType.TNW);

  195.     /** Type of Local Orbital Frame (may be null). */
  196.     private final LOFType lofType;

  197.     /** Simple constructor.
  198.      * @param lofType type of Local Orbital Frame (null if frame is not a Local Orbital Frame)
  199.      */
  200.     CCSDSFrame(final LOFType lofType) {
  201.         this.lofType = lofType;
  202.     }

  203.     /** Check if the frame is a Local Orbital frame.
  204.      * @return true if the frame is a Local Orbital Frame
  205.      */
  206.     public boolean isLof() {
  207.         return lofType != null;
  208.     }

  209.     /** Get the type of Local Orbital frame.
  210.      * <p>
  211.      * If the frame is not a Local Orbital frame (i.e. if this method returns null),
  212.      * then the {@link #getFrame(IERSConventions, boolean) getFrame} method must be used to
  213.      * retrieve the absolute frame.
  214.      * </p>
  215.      * @return type of Local Orbital Frame, or null if the frame is not a local orbital frame
  216.      * @see #isLof()
  217.      */
  218.     public LOFType getLofType() {
  219.         return lofType;
  220.     }

  221.     /**
  222.      * Get the frame corresponding to the CCSDS constant.
  223.      * @param conventions IERS conventions to use
  224.      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
  225.      * @return frame corresponding to the CCSDS constant
  226.      * @exception OrekitException if the frame cannot be retrieved or if it
  227.      * is a Local Orbital Frame
  228.      * @see #isLof()
  229.      */
  230.     public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  231.         throws OrekitException {
  232.         throw new OrekitException(OrekitMessages.CCSDS_INVALID_FRAME, toString());
  233.     }

  234. }