1 /* Copyright 2002-2025 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
18 package org.orekit.files.ccsds.ndm.odm.oem;
19
20 import java.util.List;
21
22 import org.orekit.files.ccsds.ndm.odm.CartesianCovariance;
23 import org.orekit.files.ccsds.section.Segment;
24 import org.orekit.files.general.EphemerisFile;
25 import org.orekit.frames.Frame;
26 import org.orekit.time.AbsoluteDate;
27 import org.orekit.utils.CartesianDerivativesFilter;
28 import org.orekit.utils.TimeStampedPVCoordinates;
29
30 /** The Ephemerides Blocks class contain metadata, the list of ephemerides data
31 * lines and optional covariance matrices (and their metadata). The reason
32 * for which the ephemerides have been separated into blocks is that the
33 * ephemerides of two different blocks are not suited for interpolation.
34 * @author sports
35 */
36 public class OemSegment extends Segment<OemMetadata, OemData>
37 implements EphemerisFile.EphemerisSegment<TimeStampedPVCoordinates> {
38
39 /** Gravitational parameter in m³/s². */
40 private final double mu;
41
42 /** Simple constructor.
43 * @param metadata segment metadata
44 * @param data segment data
45 * @param mu gravitational parameter in m³/s²
46 */
47 public OemSegment(final OemMetadata metadata, final OemData data, final double mu) {
48 super(metadata, data);
49 this.mu = mu;
50 }
51
52 /** {@inheritDoc} */
53 @Override
54 public double getMu() {
55 return mu;
56 }
57
58 /** {@inheritDoc} */
59 @Override
60 public List<TimeStampedPVCoordinates> getCoordinates() {
61 return getData().getCoordinates();
62 }
63
64 /** {@inheritDoc} */
65 @Override
66 public CartesianDerivativesFilter getAvailableDerivatives() {
67 return getData().getAvailableDerivatives();
68 }
69
70 /** Get an unmodifiable view of Covariance Matrices.
71 * @return unmodifiable view of Covariance Matrices
72 */
73 public List<CartesianCovariance> getCovarianceMatrices() {
74 return getData().getCovarianceMatrices();
75 }
76
77 /** {@inheritDoc} */
78 @Override
79 public Frame getFrame() {
80 return getMetadata().getFrame();
81 }
82
83 /** {@inheritDoc}
84 * <p>
85 * This implementation returns {@link #getFrame() defining frame}
86 * if it is {@link Frame#isPseudoInertial() pseudo-inertial}, or
87 * its closest {@link Frame#getParent() ancestor} that is
88 * pseudo-inertial.
89 * </p>
90 */
91 @Override
92 public Frame getInertialFrame() {
93 Frame frame = getFrame();
94 while (!frame.isPseudoInertial()) {
95 frame = frame.getParent();
96 }
97 return frame;
98 }
99
100 /** {@inheritDoc} */
101 @Override
102 public AbsoluteDate getStart() {
103 // useable start time overrides start time if it is set
104 final AbsoluteDate start = getMetadata().getUseableStartTime();
105 if (start != null) {
106 return start;
107 } else {
108 return getMetadata().getStartTime();
109 }
110 }
111
112 /** {@inheritDoc} */
113 @Override
114 public AbsoluteDate getStop() {
115 // useable stop time overrides stop time if it is set
116 final AbsoluteDate stop = getMetadata().getUseableStopTime();
117 if (stop != null) {
118 return stop;
119 } else {
120 return getMetadata().getStopTime();
121 }
122 }
123
124 /** {@inheritDoc} */
125 @Override
126 public int getInterpolationSamples() {
127 // From the standard it is not entirely clear how to interpret the degree.
128 return getMetadata().getInterpolationDegree() + 1;
129 }
130
131 }