1 /* Copyright 2002-2026 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.ArrayList;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.orekit.data.DataContext;
25 import org.orekit.files.ccsds.ndm.NdmConstituent;
26 import org.orekit.files.ccsds.ndm.adm.AdmHeader;
27 import org.orekit.files.general.AttitudeEphemerisFile;
28 import org.orekit.utils.IERSConventions;
29 import org.orekit.utils.TimeStampedAngularCoordinates;
30
31 /**
32 * This class stores all the information of the Attitude Ephemeris Message (AEM) File parsed
33 * by AEMParser. It contains the header and a list of Attitude Ephemerides Blocks each
34 * containing metadata and a list of attitude ephemerides data lines.
35 * @author Bryan Cazabonne
36 * @since 10.2
37 */
38 public class Aem extends NdmConstituent<AdmHeader, AemSegment>
39 implements AttitudeEphemerisFile<TimeStampedAngularCoordinates, AemSegment> {
40
41 /** Root element for XML files. */
42 public static final String ROOT = "aem";
43
44 /** Key for format version. */
45 public static final String FORMAT_VERSION_KEY = "CCSDS_AEM_VERS";
46
47 /** Default name for unknown object. */
48 public static final String UNKNOWN_OBJECT = "UNKNOWN";
49
50 /** Simple constructor.
51 * @param header file header
52 * @param segments file segments
53 * @param conventions IERS conventions
54 * @param dataContext used for creating frames, time scales, etc.
55 */
56 public Aem(final AdmHeader header, final List<AemSegment> segments,
57 final IERSConventions conventions, final DataContext dataContext) {
58 super(header, segments, conventions, dataContext);
59 }
60
61 /** {@inheritDoc}
62 * <p>
63 * The metadata entries checked for use as the key are the following ones,
64 * the first non-null being used. The map from AEM files always contains only
65 * one object.
66 * <ul>
67 * <li>{@link org.orekit.files.ccsds.ndm.adm.AdmMetadata#getObjectID()} OBJECT_ID}
68 * if non-null and not equal to {@link #UNKNOWN_OBJECT}</li>
69 * <li>{@link org.orekit.files.ccsds.ndm.adm.AdmMetadata#getObjectName() OBJECT_NAME}</li>
70 * <li>the default name {@link #UNKNOWN_OBJECT} for unknown objects</li>
71 * </ul>
72 */
73 @Override
74 public Map<String, AemSatelliteEphemeris> getSatellites() {
75 final Map<String, List<AemSegment>> byName = new HashMap<>();
76 for (final AemSegment segment : getSegments()) {
77 final String name;
78 if (segment.getMetadata().getObjectID() != null &&
79 !UNKNOWN_OBJECT.equals(segment.getMetadata().getObjectID())) {
80 name = segment.getMetadata().getObjectID();
81 } else if (segment.getMetadata().getObjectName() != null) {
82 name = segment.getMetadata().getObjectName();
83 } else {
84 name = UNKNOWN_OBJECT;
85 }
86 byName.putIfAbsent(name, new ArrayList<>());
87 byName.get(name).add(segment);
88 }
89 final Map<String, AemSatelliteEphemeris> ret = new HashMap<>();
90 for (final Map.Entry<String, List<AemSegment>> entry : byName.entrySet()) {
91 ret.put(entry.getKey(), new AemSatelliteEphemeris(entry.getKey(), entry.getValue()));
92 }
93 return ret;
94 }
95
96 }