1   /* Copyright 2002-2019 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  
19  import org.orekit.bodies.CelestialBodyFactory;
20  import org.orekit.errors.OrekitException;
21  import org.orekit.errors.OrekitMessages;
22  import org.orekit.frames.Frame;
23  import org.orekit.frames.FramesFactory;
24  import org.orekit.frames.ITRFVersion;
25  import org.orekit.frames.LOFType;
26  import org.orekit.utils.IERSConventions;
27  
28  /** Frames used in CCSDS Orbit Data Messages.
29   * @author Steven Ports
30   * @since 6.1
31   */
32  public enum CCSDSFrame {
33  
34      /** Earth Mean Equator and Equinox of J2000. */
35      EME2000(null) {
36  
37          /** {@inheritDoc} */
38          @Override
39          public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
40              return FramesFactory.getEME2000();
41          }
42  
43      },
44  
45      /** Geocentric Celestial Reference Frame. */
46      GCRF(null) {
47  
48          /** {@inheritDoc} */
49          @Override
50          public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
51              return FramesFactory.getGCRF();
52          }
53  
54      },
55  
56      /** Greenwich Rotating Coordinates. */
57      GRC(null) {
58  
59          /** {@inheritDoc} */
60          @Override
61          public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
62              if (conventions == null) {
63                  throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
64              }
65              return FramesFactory.getITRFEquinox(conventions, simpleEOP);
66          }
67  
68      },
69  
70      /** International Celestial Reference Frame. */
71      ICRF(null) {
72  
73          /** {@inheritDoc} */
74          @Override
75          public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
76              return FramesFactory.getICRF();
77          }
78  
79      },
80  
81      /** International Terrestrial Reference Frame 2014. */
82      ITRF2014(null) {
83  
84          /** {@inheritDoc} */
85          @Override
86          public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
87              if (conventions == null) {
88                  throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
89              }
90              return FramesFactory.getITRF(ITRFVersion.ITRF_2014, conventions, simpleEOP);
91          }
92  
93      },
94  
95      /** International Terrestrial Reference Frame 2008. */
96      ITRF2008(null) {
97  
98          /** {@inheritDoc} */
99          @Override
100         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
101             if (conventions == null) {
102                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
103             }
104             return FramesFactory.getITRF(ITRFVersion.ITRF_2008, conventions, simpleEOP);
105         }
106 
107     },
108 
109     /** International Terrestrial Reference Frame 2005. */
110     ITRF2005(null) {
111 
112         /** {@inheritDoc} */
113         @Override
114         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
115             if (conventions == null) {
116                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
117             }
118             return FramesFactory.getITRF(ITRFVersion.ITRF_2005, conventions, simpleEOP);
119         }
120 
121     },
122 
123     /** International Terrestrial Reference Frame 2000. */
124     ITRF2000(null) {
125 
126         /** {@inheritDoc} */
127         @Override
128         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
129             if (conventions == null) {
130                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
131             }
132             return FramesFactory.getITRF(ITRFVersion.ITRF_2000, conventions, simpleEOP);
133         }
134 
135     },
136 
137     /** International Terrestrial Reference Frame 1993. */
138     ITRF93(null) {
139 
140         /** {@inheritDoc} */
141         @Override
142         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
143             if (conventions == null) {
144                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
145             }
146             return FramesFactory.getITRF(ITRFVersion.ITRF_93, conventions, simpleEOP);
147         }
148 
149     },
150 
151     /** International Terrestrial Reference Frame 1997. */
152     ITRF97(null) {
153 
154         /** {@inheritDoc} */
155         @Override
156         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
157             if (conventions == null) {
158                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
159             }
160             return FramesFactory.getITRF(ITRFVersion.ITRF_97, conventions, simpleEOP);
161         }
162 
163     },
164 
165     /** Mars Centered Inertial. */
166     MCI(null) {
167 
168         /** {@inheritDoc} */
169         @Override
170         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
171             return CelestialBodyFactory.getMars().getInertiallyOrientedFrame();
172         }
173 
174     },
175 
176     /** True of Date, Rotating. */
177     TDR(null) {
178 
179         /** {@inheritDoc} */
180         @Override
181         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
182             if (conventions == null) {
183                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
184             }
185             return FramesFactory.getGTOD(conventions, simpleEOP);
186         }
187 
188     },
189 
190     /**
191      * True Equator Mean Equinox.
192      * TEME may be used only for OMMs based on NORAD
193      * Two Line Element sets, and in no other circumstances.
194      */
195     TEME(null) {
196 
197         /** {@inheritDoc} */
198         @Override
199         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
200             return FramesFactory.getTEME();
201         }
202 
203     },
204 
205     /** True of Date. */
206     TOD(null) {
207 
208         /** {@inheritDoc} */
209         @Override
210         public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
211             if (conventions == null) {
212                 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
213             }
214             return FramesFactory.getTOD(conventions, simpleEOP);
215         }
216 
217     },
218 
219     /** Radial, Transverse (along-track) and Normal. */
220     RTN(LOFType.QSW),
221 
222     /** Another name for Radial, Transverse (along-track) and Normal. */
223     RSW(LOFType.QSW),
224 
225     /** TNW : x-axis along the velocity vector, W along the orbital angular momentum vector and
226     N completes the right handed system. */
227     TNW(LOFType.TNW);
228 
229     /** Type of Local Orbital Frame (may be null). */
230     private final LOFType lofType;
231 
232     /** Simple constructor.
233      * @param lofType type of Local Orbital Frame (null if frame is not a Local Orbital Frame)
234      */
235     CCSDSFrame(final LOFType lofType) {
236         this.lofType = lofType;
237     }
238 
239     /** Check if the frame is a Local Orbital frame.
240      * @return true if the frame is a Local Orbital Frame
241      */
242     public boolean isLof() {
243         return lofType != null;
244     }
245 
246     /** Get the type of Local Orbital frame.
247      * <p>
248      * If the frame is not a Local Orbital frame (i.e. if this method returns null),
249      * then the {@link #getFrame(IERSConventions, boolean) getFrame} method must be used to
250      * retrieve the absolute frame.
251      * </p>
252      * @return type of Local Orbital Frame, or null if the frame is not a local orbital frame
253      * @see #isLof()
254      */
255     public LOFType getLofType() {
256         return lofType;
257     }
258 
259     /**
260      * Get the frame corresponding to the CCSDS constant.
261      * @param conventions IERS conventions to use
262      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
263      * @return frame corresponding to the CCSDS constant
264      * @see #isLof()
265      */
266     public Frame getFrame(final IERSConventions conventions, final boolean simpleEOP) {
267         throw new OrekitException(OrekitMessages.CCSDS_INVALID_FRAME, toString());
268     }
269 
270 }