CCSDSFrame.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 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 2000. */
  71.     ITRF2000(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.             final Frame itrf2008 = FramesFactory.getITRF(conventions, simpleEOP);
  80.             final HelmertTransformation.Predefined predefinedHT =
  81.                     HelmertTransformation.Predefined.ITRF_2008_TO_ITRF_2000;
  82.             return predefinedHT.createTransformedITRF(itrf2008, toString());
  83.         }

  84.     },

  85.     /** International Celestial Reference Frame 1993. */
  86.     ITRF93(null) {

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

  99.     },

  100.     /** International Celestial Reference Frame 1997. */
  101.     ITRF97(null) {

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

  114.     },

  115.     /** Mars Centered Inertial. */
  116.     MCI(null) {

  117.         /** {@inheritDoc} */
  118.         @Override
  119.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  120.             throws OrekitException {
  121.             return CelestialBodyFactory.getMars().getInertiallyOrientedFrame();
  122.         }

  123.     },

  124.     /** True of Date, Rotating. */
  125.     TDR(null) {

  126.         /** {@inheritDoc} */
  127.         @Override
  128.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  129.             throws OrekitException {
  130.             if (conventions == null) {
  131.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  132.             }
  133.             return FramesFactory.getGTOD(conventions, simpleEOP);
  134.         }

  135.     },

  136.     /**
  137.      * True Equator Mean Equinox.
  138.      * TEME may be used only for OMMs based on NORAD
  139.      * Two Line Element sets, and in no other circumstances.
  140.      */
  141.     TEME(null) {

  142.         /** {@inheritDoc} */
  143.         @Override
  144.         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  145.             throws OrekitException {
  146.             return FramesFactory.getTEME();
  147.         }

  148.     },

  149.     /** True of Date. */
  150.     TOD(null) {

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

  160.     },

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

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

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

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

  170.     /** Simple constructor.
  171.      * @param lofType type of Local Orbital Frame (null if frame is not a Local Orbital Frame)
  172.      */
  173.     private CCSDSFrame(final LOFType lofType) {
  174.         this.lofType = lofType;
  175.     }

  176.     /** Check if the frame is a Local Orbital frame.
  177.      * @return true if the frame is a Local Orbital Frame
  178.      */
  179.     public boolean isLof() {
  180.         return lofType != null;
  181.     }

  182.     /** Get the type of Local Orbital frame.
  183.      * <p>
  184.      * If the frame is not a Local Orbital frame (i.e. if this method returns null),
  185.      * then the {@link #getFrame(IERSConventions, boolean) getFrame} method must be used to
  186.      * retrieve the absolute frame.
  187.      * </p>
  188.      * @return type of Local Orbital Frame, or null if the frame is not a local orbital frame
  189.      * @see #isLof()
  190.      */
  191.     public LOFType getLofType() {
  192.         return lofType;
  193.     }

  194.     /**
  195.      * Get the frame corresponding to the CCSDS constant.
  196.      * @param conventions IERS conventions to use
  197.      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
  198.      * @return frame corresponding to the CCSDS constant
  199.      * @exception OrekitException if the frame cannot be retrieved or if it
  200.      * is a Local Orbital Frame
  201.      * @see #isLof()
  202.      */
  203.     public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP)
  204.         throws OrekitException {
  205.         throw new OrekitException(OrekitMessages.CCSDS_INVALID_FRAME, toString());
  206.     }

  207. }