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.adm.aem;
18  
19  import java.util.List;
20  
21  import org.orekit.attitudes.BoundedAttitudeProvider;
22  import org.orekit.attitudes.TabulatedProvider;
23  import org.orekit.errors.OrekitException;
24  import org.orekit.errors.OrekitMessages;
25  import org.orekit.files.ccsds.section.Segment;
26  import org.orekit.files.general.AttitudeEphemerisFile;
27  import org.orekit.frames.Frame;
28  import org.orekit.time.AbsoluteDate;
29  import org.orekit.utils.AngularDerivativesFilter;
30  import org.orekit.utils.TimeStampedAngularCoordinates;
31  
32  /**
33   * This class stores the metadata and data for one attitude segment.
34   * @author Luc Maisonobe
35   * @since 11.0
36   */
37  public class AemSegment extends Segment<AemMetadata, AemData>
38      implements AttitudeEphemerisFile.AttitudeEphemerisSegment<TimeStampedAngularCoordinates> {
39  
40      /** Simple constructor.
41       * @param metadata segment metadata
42       * @param data segment data
43       */
44      public AemSegment(final AemMetadata metadata, final AemData data) {
45          super(metadata, data);
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public List<TimeStampedAngularCoordinates> getAngularCoordinates() {
51          return getData().getAngularCoordinates();
52      }
53  
54      /** {@inheritDoc} */
55      @Override
56      public Frame getReferenceFrame() {
57          final Frame frame = getMetadata().getEndpoints().getExternalFrame().asFrame();
58          if (frame == null) {
59              throw new OrekitException(OrekitMessages.CCSDS_INVALID_FRAME,
60                                        getMetadata().getEndpoints().getExternalFrame().getName());
61          }
62          return frame;
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public AbsoluteDate getStart() {
68          return getMetadata().getStart();
69      }
70  
71      /** {@inheritDoc} */
72      @Override
73      public AbsoluteDate getStop() {
74          return getMetadata().getStop();
75      }
76  
77      /** {@inheritDoc} */
78      @Override
79      public String getInterpolationMethod() {
80          return getMetadata().getInterpolationMethod();
81      }
82  
83      /** {@inheritDoc} */
84      @Override
85      public int getInterpolationSamples() {
86          return getMetadata().getInterpolationSamples();
87      }
88  
89      /** {@inheritDoc} */
90      @Override
91      public AngularDerivativesFilter getAvailableDerivatives() {
92          return getMetadata().getAttitudeType().getAngularDerivativesFilter();
93      }
94  
95      /** {@inheritDoc} */
96      @Override
97      public BoundedAttitudeProvider getAttitudeProvider() {
98          return new TabulatedProvider(getAngularCoordinates(), getInterpolationSamples(),
99                                       getAvailableDerivatives(), getStart(), getStop(),
100                                      getMetadata().getEndpoints());
101     }
102 
103 }