OemSegment.java

  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. package org.orekit.files.ccsds.ndm.odm.oem;

  18. import java.util.List;

  19. import org.orekit.files.ccsds.ndm.odm.CartesianCovariance;
  20. import org.orekit.files.ccsds.section.Segment;
  21. import org.orekit.files.general.EphemerisFile;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.utils.CartesianDerivativesFilter;
  25. import org.orekit.utils.TimeStampedPVCoordinates;

  26. /** The Ephemerides Blocks class contain metadata, the list of ephemerides data
  27.  * lines and optional covariance matrices (and their metadata). The reason
  28.  * for which the ephemerides have been separated into blocks is that the
  29.  * ephemerides of two different blocks are not suited for interpolation.
  30.  * @author sports
  31.  */
  32. public class OemSegment extends Segment<OemMetadata, OemData>
  33.     implements EphemerisFile.EphemerisSegment<TimeStampedPVCoordinates> {

  34.     /** Gravitational parameter in m³/s². */
  35.     private final double mu;

  36.     /** Simple constructor.
  37.      * @param metadata segment metadata
  38.      * @param data segment data
  39.      * @param mu gravitational parameter in m³/s²
  40.      */
  41.     public OemSegment(final OemMetadata metadata, final OemData data, final double mu) {
  42.         super(metadata, data);
  43.         this.mu = mu;
  44.     }

  45.     /** {@inheritDoc} */
  46.     @Override
  47.     public double getMu() {
  48.         return mu;
  49.     }

  50.     /** {@inheritDoc} */
  51.     @Override
  52.     public List<TimeStampedPVCoordinates> getCoordinates() {
  53.         return getData().getCoordinates();
  54.     }

  55.     /** {@inheritDoc} */
  56.     @Override
  57.     public CartesianDerivativesFilter getAvailableDerivatives() {
  58.         return getData().getAvailableDerivatives();
  59.     }

  60.     /** Get an unmodifiable view of Covariance Matrices.
  61.      * @return unmodifiable view of Covariance Matrices
  62.      */
  63.     public List<CartesianCovariance> getCovarianceMatrices() {
  64.         return getData().getCovarianceMatrices();
  65.     }

  66.     /** {@inheritDoc} */
  67.     @Override
  68.     public Frame getFrame() {
  69.         return getMetadata().getFrame();
  70.     }

  71.     /** {@inheritDoc}
  72.      * <p>
  73.      * This implementation returns {@link #getFrame() defining frame}
  74.      * if it is {@link Frame#isPseudoInertial() pseudo-inertial}, or
  75.      * its closest {@link Frame#getParent() ancestor} that is
  76.      * pseudo-inertial.
  77.      * </p>
  78.      */
  79.     @Override
  80.     public Frame getInertialFrame() {
  81.         Frame frame = getFrame();
  82.         while (!frame.isPseudoInertial()) {
  83.             frame = frame.getParent();
  84.         }
  85.         return frame;
  86.     }

  87.     /** {@inheritDoc} */
  88.     @Override
  89.     public AbsoluteDate getStart() {
  90.         // useable start time overrides start time if it is set
  91.         final AbsoluteDate start = getMetadata().getUseableStartTime();
  92.         if (start != null) {
  93.             return start;
  94.         } else {
  95.             return getMetadata().getStartTime();
  96.         }
  97.     }

  98.     /** {@inheritDoc} */
  99.     @Override
  100.     public AbsoluteDate getStop() {
  101.         // useable stop time overrides stop time if it is set
  102.         final AbsoluteDate stop = getMetadata().getUseableStopTime();
  103.         if (stop != null) {
  104.             return stop;
  105.         } else {
  106.             return getMetadata().getStopTime();
  107.         }
  108.     }

  109.     /** {@inheritDoc} */
  110.     @Override
  111.     public int getInterpolationSamples() {
  112.         // From the standard it is not entirely clear how to interpret the degree.
  113.         return getMetadata().getInterpolationDegree() + 1;
  114.     }

  115. }