CCSDSFrame.java

  1. /* Copyright 2002-2020 CS Group
  2.  * Licensed to CS Group (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.annotation.DefaultDataContext;
  19. import org.orekit.data.DataContext;
  20. import org.orekit.errors.OrekitException;
  21. import org.orekit.errors.OrekitMessages;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.frames.ITRFVersion;
  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,
  36.                               final boolean simpleEOP,
  37.                               final DataContext dataContext) {
  38.             return dataContext.getFrames().getEME2000();
  39.         }

  40.     },

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

  43.         /** {@inheritDoc} */
  44.         @Override
  45.         public Frame getFrame(final IERSConventions conventions,
  46.                               final boolean simpleEOP,
  47.                               final DataContext dataContext) {
  48.             return dataContext.getFrames().getGCRF();
  49.         }

  50.     },

  51.     /** Greenwich Rotating Coordinates. */
  52.     GRC(null) {

  53.         /** {@inheritDoc} */
  54.         @Override
  55.         public Frame getFrame(final IERSConventions conventions,
  56.                               final boolean simpleEOP,
  57.                               final DataContext dataContext) {
  58.             if (conventions == null) {
  59.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  60.             }
  61.             return dataContext.getFrames().getITRFEquinox(conventions, simpleEOP);
  62.         }

  63.     },

  64.     /** International Celestial Reference Frame. */
  65.     ICRF(null) {

  66.         /** {@inheritDoc} */
  67.         @Override
  68.         public Frame getFrame(final IERSConventions conventions,
  69.                               final boolean simpleEOP,
  70.                               final DataContext dataContext) {
  71.             return dataContext.getFrames().getICRF();
  72.         }

  73.     },

  74.     /** International Terrestrial Reference Frame 2014. */
  75.     ITRF2014(null) {

  76.         /** {@inheritDoc} */
  77.         @Override
  78.         public Frame getFrame(final IERSConventions conventions,
  79.                               final boolean simpleEOP,
  80.                               final DataContext dataContext) {
  81.             if (conventions == null) {
  82.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  83.             }
  84.             return dataContext.getFrames()
  85.                     .getITRF(ITRFVersion.ITRF_2014, conventions, simpleEOP);
  86.         }

  87.     },

  88.     /** International Terrestrial Reference Frame 2008. */
  89.     ITRF2008(null) {

  90.         /** {@inheritDoc} */
  91.         @Override
  92.         public Frame getFrame(final IERSConventions conventions,
  93.                               final boolean simpleEOP,
  94.                               final DataContext dataContext) {
  95.             if (conventions == null) {
  96.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  97.             }
  98.             return dataContext.getFrames()
  99.                     .getITRF(ITRFVersion.ITRF_2008, conventions, simpleEOP);
  100.         }

  101.     },

  102.     /** International Terrestrial Reference Frame 2005. */
  103.     ITRF2005(null) {

  104.         /** {@inheritDoc} */
  105.         @Override
  106.         public Frame getFrame(final IERSConventions conventions,
  107.                               final boolean simpleEOP,
  108.                               final DataContext dataContext) {
  109.             if (conventions == null) {
  110.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  111.             }
  112.             return dataContext.getFrames()
  113.                     .getITRF(ITRFVersion.ITRF_2005, conventions, simpleEOP);
  114.         }

  115.     },

  116.     /** International Terrestrial Reference Frame 2000. */
  117.     ITRF2000(null) {

  118.         /** {@inheritDoc} */
  119.         @Override
  120.         public Frame getFrame(final IERSConventions conventions,
  121.                               final boolean simpleEOP,
  122.                               final DataContext dataContext) {
  123.             if (conventions == null) {
  124.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  125.             }
  126.             return dataContext.getFrames()
  127.                     .getITRF(ITRFVersion.ITRF_2000, conventions, simpleEOP);
  128.         }

  129.     },

  130.     /** International Terrestrial Reference Frame 1993. */
  131.     ITRF93(null) {

  132.         /** {@inheritDoc} */
  133.         @Override
  134.         public Frame getFrame(final IERSConventions conventions,
  135.                               final boolean simpleEOP,
  136.                               final DataContext dataContext) {
  137.             if (conventions == null) {
  138.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  139.             }
  140.             return dataContext.getFrames()
  141.                     .getITRF(ITRFVersion.ITRF_93, conventions, simpleEOP);
  142.         }

  143.     },

  144.     /** International Terrestrial Reference Frame 1997. */
  145.     ITRF97(null) {

  146.         /** {@inheritDoc} */
  147.         @Override
  148.         public Frame getFrame(final IERSConventions conventions,
  149.                               final boolean simpleEOP,
  150.                               final DataContext dataContext) {
  151.             if (conventions == null) {
  152.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  153.             }
  154.             return dataContext.getFrames()
  155.                     .getITRF(ITRFVersion.ITRF_97, conventions, simpleEOP);
  156.         }

  157.     },

  158.     /** Mars Centered Inertial. */
  159.     MCI(null) {

  160.         /** {@inheritDoc} */
  161.         @Override
  162.         public Frame getFrame(final IERSConventions conventions,
  163.                               final boolean simpleEOP,
  164.                               final DataContext dataContext) {
  165.             return dataContext.getCelestialBodies().getMars()
  166.                     .getInertiallyOrientedFrame();
  167.         }

  168.     },

  169.     /** True of Date, Rotating. */
  170.     TDR(null) {

  171.         /** {@inheritDoc} */
  172.         @Override
  173.         public Frame getFrame(final IERSConventions conventions,
  174.                               final boolean simpleEOP,
  175.                               final DataContext dataContext) {
  176.             if (conventions == null) {
  177.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  178.             }
  179.             return dataContext.getFrames().getGTOD(conventions, simpleEOP);
  180.         }

  181.     },

  182.     /**
  183.      * True Equator Mean Equinox.
  184.      * TEME may be used only for OMMs based on NORAD
  185.      * Two Line Element sets, and in no other circumstances.
  186.      */
  187.     TEME(null) {

  188.         /** {@inheritDoc} */
  189.         @Override
  190.         public Frame getFrame(final IERSConventions conventions,
  191.                               final boolean simpleEOP,
  192.                               final DataContext dataContext) {
  193.             return dataContext.getFrames().getTEME();
  194.         }

  195.     },

  196.     /** True of Date. */
  197.     TOD(null) {

  198.         /** {@inheritDoc} */
  199.         @Override
  200.         public Frame getFrame(final IERSConventions conventions,
  201.                               final boolean simpleEOP,
  202.                               final DataContext dataContext) {
  203.             if (conventions == null) {
  204.                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  205.             }
  206.             return dataContext.getFrames().getTOD(conventions, simpleEOP);
  207.         }

  208.     },

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

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

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

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

  218.     /** Simple constructor.
  219.      * @param lofType type of Local Orbital Frame (null if frame is not a Local Orbital Frame)
  220.      */
  221.     CCSDSFrame(final LOFType lofType) {
  222.         this.lofType = lofType;
  223.     }

  224.     /** Check if the frame is a Local Orbital frame.
  225.      * @return true if the frame is a Local Orbital Frame
  226.      */
  227.     public boolean isLof() {
  228.         return lofType != null;
  229.     }

  230.     /** Get the type of Local Orbital frame.
  231.      * <p>
  232.      * If the frame is not a Local Orbital frame (i.e. if this method returns null),
  233.      * then the {@link #getFrame(IERSConventions, boolean, DataContext) getFrame} method
  234.      * must be used to retrieve the absolute frame.
  235.      * </p>
  236.      * @return type of Local Orbital Frame, or null if the frame is not a local orbital frame
  237.      * @see #isLof()
  238.      */
  239.     public LOFType getLofType() {
  240.         return lofType;
  241.     }

  242.     /**
  243.      * Get the frame corresponding to the CCSDS constant.
  244.      *
  245.      * <p>This method uses the {@link DataContext#getDefault() default data context}.
  246.      *
  247.      * @param conventions IERS conventions to use
  248.      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
  249.      * @return frame corresponding to the CCSDS constant
  250.      * @see #isLof()
  251.      * @see #getFrame(IERSConventions, boolean, DataContext)
  252.      */
  253.     @DefaultDataContext
  254.     public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
  255.         return getFrame(conventions, simpleEOP, DataContext.getDefault());
  256.     }

  257.     /**
  258.      * Get the frame corresponding to the CCSDS constant.
  259.      * @param conventions IERS conventions to use
  260.      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
  261.      * @param dataContext to use when creating the frame.
  262.      * @return frame corresponding to the CCSDS constant
  263.      * @see #isLof()
  264.      * @since 10.1
  265.      */
  266.     public Frame getFrame(final IERSConventions conventions,
  267.                           final boolean simpleEOP,
  268.                           final DataContext dataContext) {
  269.         throw new OrekitException(OrekitMessages.CCSDS_INVALID_FRAME, toString());
  270.     }

  271. }