1   /* Copyright Luc Maisonobe
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.sp3;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.orekit.attitudes.AttitudeProvider;
24  import org.orekit.files.general.EphemerisFile;
25  import org.orekit.frames.Frame;
26  import org.orekit.propagation.BoundedPropagator;
27  import org.orekit.time.AbsoluteDate;
28  import org.orekit.utils.CartesianDerivativesFilter;
29  
30  /** One segment of an {@link SP3Ephemeris}.
31   * @author Thomas Neidhart
32   * @author Evan Ward
33   * @author Luc Maisonobe
34   * @since 12.0
35   */
36  public class SP3Segment implements EphemerisFile.EphemerisSegment<SP3Coordinate> {
37  
38      /** Standard gravitational parameter in m³ / s². */
39      private final double mu;
40  
41      /** Reference frame. */
42      private final Frame frame;
43  
44      /** Number of points to use for interpolation. */
45      private final int interpolationSamples;
46  
47      /** Available derivatives. */
48      private final CartesianDerivativesFilter filter;
49  
50      /** Ephemeris Data. */
51      private final List<SP3Coordinate> coordinates;
52  
53      /** Simple constructor.
54       * @param mu standard gravitational parameter to use for creating
55       * {@link org.orekit.orbits.Orbit Orbits} from the ephemeris data.
56       * @param frame reference frame
57       * @param interpolationSamples number of points to use for interpolation
58       * @param filter available derivatives
59       */
60      public SP3Segment(final double mu, final Frame frame,
61                        final int interpolationSamples, final CartesianDerivativesFilter filter) {
62          this.mu                   = mu;
63          this.frame                = frame;
64          this.interpolationSamples = interpolationSamples;
65          this.filter               = filter;
66          this.coordinates          = new ArrayList<>();
67      }
68  
69      /** {@inheritDoc} */
70      @Override
71      public double getMu() {
72          return mu;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public AbsoluteDate getStart() {
78          return coordinates.get(0).getDate();
79      }
80  
81      /** {@inheritDoc} */
82      @Override
83      public AbsoluteDate getStop() {
84          return coordinates.get(coordinates.size() - 1).getDate();
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      public Frame getFrame() {
90          return frame;
91      }
92  
93      /** {@inheritDoc} */
94      @Override
95      public int getInterpolationSamples() {
96          return interpolationSamples;
97      }
98  
99      /** {@inheritDoc} */
100     @Override
101     public CartesianDerivativesFilter getAvailableDerivatives() {
102         return filter;
103     }
104 
105     /** {@inheritDoc} */
106     @Override
107     public List<SP3Coordinate> getCoordinates() {
108         return Collections.unmodifiableList(this.coordinates);
109     }
110 
111     /** Adds a new P/V coordinate.
112      * @param coord the P/V coordinate of the satellite
113      */
114     public void addCoordinate(final SP3Coordinate coord) {
115         coordinates.add(coord);
116     }
117 
118     /** {@inheritDoc} */
119     @Override
120     public BoundedPropagator getPropagator() {
121         return EphemerisFile.EphemerisSegment.super.getPropagator();
122     }
123 
124     /** {@inheritDoc} */
125     @Override
126     public BoundedPropagator getPropagator(final AttitudeProvider attitudeProvider) {
127         return EphemerisFile.EphemerisSegment.super.getPropagator(attitudeProvider);
128     }
129 
130 }