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.ocm;
19
20 import java.util.Collections;
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.odm.OdmHeader;
27 import org.orekit.files.ccsds.section.Segment;
28 import org.orekit.files.general.EphemerisFile;
29 import org.orekit.utils.IERSConventions;
30 import org.orekit.utils.TimeStampedPVCoordinates;
31
32 /** This class gathers the informations present in the Orbit Comprehensive Message (OCM).
33 * @author Luc Maisonobe
34 * @since 11.0
35 */
36 public class Ocm extends NdmConstituent<OdmHeader, Segment<OcmMetadata, OcmData>>
37 implements EphemerisFile<TimeStampedPVCoordinates, TrajectoryStateHistory> {
38
39 /** Root element for XML messages. */
40 public static final String ROOT = "ocm";
41
42 /** Key for format version. */
43 public static final String FORMAT_VERSION_KEY = "CCSDS_OCM_VERS";
44
45 /** Trajectory line element for XML messages. */
46 public static final String TRAJ_LINE = "trajLine";
47
48 /** Covariance line element for XML messages. */
49 public static final String COV_LINE = "covLine";
50
51 /** Maneuver line element for XML messages. */
52 public static final String MAN_LINE = "manLine";
53
54 /** Default name for unknown object. */
55 public static final String UNKNOWN_OBJECT = "UNKNOWN";
56
57 /** Gravitational coefficient to use for building Cartesian/Keplerian orbits. */
58 private final double mu;
59
60 /** Simple constructor.
61 * @param header file header
62 * @param segments ile segments
63 * @param conventions IERS conventions
64 * @param dataContext used for creating frames, time scales, etc.
65 * @param mu Gravitational coefficient to use for building Cartesian/Keplerian orbits.
66 */
67 public Ocm(final OdmHeader header, final List<Segment<OcmMetadata, OcmData>> segments,
68 final IERSConventions conventions, final DataContext dataContext,
69 final double mu) {
70 super(header, segments, conventions, dataContext);
71 this.mu = mu;
72 }
73
74 /** Get the metadata from the single {@link #getSegments() segment}.
75 * @return metadata from the single {@link #getSegments() segment}
76 */
77 public OcmMetadata getMetadata() {
78 return getSegments().get(0).getMetadata();
79 }
80
81 /** Get the data from the single {@link #getSegments() segment}.
82 * @return data from the single {@link #getSegments() segment}
83 */
84 public OcmData getData() {
85 return getSegments().get(0).getData();
86 }
87
88 /** {@inheritDoc}
89 * <p>
90 * The metadata entries checked for use as the key are the following ones,
91 * the first non-null being used. The map from OCM files always contains only
92 * one object.
93 * <ul>
94 * <li>{@link org.orekit.files.ccsds.ndm.odm.OdmMetadata#getObjectName() OBJECT_NAME}</li>
95 * <li>{@link OcmMetadata#getInternationalDesignator() INTERNATIONAL_DESIGNATOR}</li>
96 * <li>{@link OcmMetadata#getObjectDesignator() OBJECT_DESIGNATOR}</li>
97 * <li>the default name {@link #UNKNOWN_OBJECT} for unknown objects</li>
98 * </ul>
99 */
100 @Override
101 public Map<String, OcmSatelliteEphemeris> getSatellites() {
102 // the OCM file has only one segment and a deep structure
103 // the real ephemeris is buried within the orbit histories logical block
104 final String name;
105 if (getMetadata().getObjectName() != null) {
106 name = getMetadata().getObjectName();
107 } else if (getMetadata().getInternationalDesignator() != null) {
108 name = getMetadata().getInternationalDesignator();
109 } else if (getMetadata().getObjectDesignator() != null) {
110 name = getMetadata().getObjectDesignator();
111 } else {
112 name = UNKNOWN_OBJECT;
113 }
114 final List<TrajectoryStateHistory> histories = getSegments().get(0).getData().getTrajectoryBlocks();
115 final OcmSatelliteEphemeris ose = new OcmSatelliteEphemeris(name, mu, histories);
116 return Collections.singletonMap(name, ose);
117 }
118
119 }