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.frames;
18  
19  import java.io.Externalizable;
20  import java.io.IOException;
21  import java.io.NotSerializableException;
22  import java.io.ObjectInput;
23  import java.io.ObjectOutput;
24  
25  import org.orekit.errors.OrekitException;
26  import org.orekit.propagation.Propagator;
27  import org.orekit.time.AbsoluteDate;
28  import org.orekit.utils.PVCoordinates;
29  import org.orekit.utils.PVCoordinatesProvider;
30  
31  
32  /** Spacecraft frame.
33   * <p>Frame associated to a satellite body, taking into account orbit and attitude.</p>
34   * <p>
35   * Use of this frame is not recommended, and it will probably be withdrawn in a future version.
36   * In many cases, rather than using this frame and its {@link #getTransformTo(Frame, AbsoluteDate)
37   * getTransformTo} method, users should directly get a {@link Transform} using
38   * {@link org.orekit.propagation.SpacecraftState#toTransform()}.
39   * </p>
40   * <p>
41   * Note that despite it extends {@link Frame}, this frame is <em>NOT</em> serializable,
42   * as it relies on {@link Propagator}.
43   * </p>
44   * @deprecated as of 6.0 replaced by {@link org.orekit.propagation.SpacecraftState#toTransform()}
45   * @author Luc Maisonobe
46   */
47  @Deprecated
48  public class SpacecraftFrame extends Frame implements PVCoordinatesProvider {
49  
50      /** Serializable UID. */
51      private static final long serialVersionUID = 6012707827832395314L;
52  
53      /** Simple constructor.
54       * @param propagator orbit/attitude propagator computing spacecraft state evolution
55       * @param name name of the frame
56       */
57      public SpacecraftFrame(final Propagator propagator, final String name) {
58          super(propagator.getFrame(), new LocalProvider(propagator), name, false);
59      }
60  
61      /** Get the underlying propagator.
62       * @return underlying propagator
63       */
64      public Propagator getPropagator() {
65          return ((LocalProvider) getTransformProvider()).getPropagator();
66      }
67  
68      /** Get the {@link PVCoordinates} of the spacecraft frame origin in the selected frame.
69       * @param date current date
70       * @param frame the frame where to define the position
71       * @return position/velocity of the spacecraft frame origin (m and m/s)
72       * @exception OrekitException if position cannot be computed in given frame
73       */
74      public PVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame)
75          throws OrekitException {
76          return getPropagator().getPVCoordinates(date, frame);
77      }
78  
79      /** Local provider for transforms. */
80      private static class LocalProvider implements TransformProvider, Externalizable {
81  
82          /** Serializable UID. */
83          private static final long serialVersionUID = 386815086579675823L;
84  
85          /** Propagator to use. */
86          private final transient Propagator propagator;
87  
88          /** Simple constructor.
89           * @param propagator orbit/attitude propagator computing spacecraft state evolution
90           */
91          public LocalProvider(final Propagator propagator) {
92              this.propagator = propagator;
93          }
94  
95          /** {@inheritDoc} */
96          public Transform getTransform(final AbsoluteDate date) throws OrekitException {
97              return propagator.propagate(date).toTransform();
98          }
99  
100         /** Get the underlying propagator.
101          * @return underlying propagator
102          */
103         public Propagator getPropagator() {
104             return propagator;
105         }
106 
107         /** {@inheritDoc} */
108         public void readExternal(final ObjectInput input) throws IOException {
109             throw new NotSerializableException();
110         }
111 
112         /** {@inheritDoc} */
113         public void writeExternal(final ObjectOutput output) throws IOException {
114             throw new NotSerializableException();
115         }
116 
117     }
118 
119 }