Ocm.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.ocm;

  18. import java.util.Collections;
  19. import java.util.List;
  20. import java.util.Map;

  21. import org.orekit.data.DataContext;
  22. import org.orekit.files.ccsds.ndm.NdmConstituent;
  23. import org.orekit.files.ccsds.ndm.odm.OdmHeader;
  24. import org.orekit.files.ccsds.section.Segment;
  25. import org.orekit.files.general.EphemerisFile;
  26. import org.orekit.utils.IERSConventions;
  27. import org.orekit.utils.TimeStampedPVCoordinates;

  28. /** This class gathers the informations present in the Orbit Comprehensive Message (OCM).
  29.  * @author Luc Maisonobe
  30.  * @since 11.0
  31.  */
  32. public class Ocm extends NdmConstituent<OdmHeader, Segment<OcmMetadata, OcmData>>
  33.     implements EphemerisFile<TimeStampedPVCoordinates, TrajectoryStateHistory> {

  34.     /** Root element for XML messages. */
  35.     public static final String ROOT = "ocm";

  36.     /** Key for format version. */
  37.     public static final String FORMAT_VERSION_KEY = "CCSDS_OCM_VERS";

  38.     /** Trajectory line element for XML messages. */
  39.     public static final String TRAJ_LINE = "trajLine";

  40.     /** Covariance line element for XML messages. */
  41.     public static final String COV_LINE = "covLine";

  42.     /** Maneuver line element for XML messages. */
  43.     public static final String MAN_LINE = "manLine";

  44.     /** Default name for unknown object. */
  45.     public static final String UNKNOWN_OBJECT = "UNKNOWN";

  46.     /** Gravitational coefficient to use for building Cartesian/Keplerian orbits. */
  47.     private final double mu;

  48.     /** Simple constructor.
  49.      * @param header file header
  50.      * @param segments ile segments
  51.      * @param conventions IERS conventions
  52.      * @param dataContext used for creating frames, time scales, etc.
  53.      * @param mu Gravitational coefficient to use for building Cartesian/Keplerian orbits.
  54.      */
  55.     public Ocm(final OdmHeader header, final List<Segment<OcmMetadata, OcmData>> segments,
  56.                final IERSConventions conventions, final DataContext dataContext,
  57.                final double mu) {
  58.         super(header, segments, conventions, dataContext);
  59.         this.mu = mu;
  60.     }

  61.     /** Get the metadata from the single {@link #getSegments() segment}.
  62.      * @return metadata from the single {@link #getSegments() segment}
  63.      */
  64.     public OcmMetadata getMetadata() {
  65.         return getSegments().get(0).getMetadata();
  66.     }

  67.     /** Get the data from the single {@link #getSegments() segment}.
  68.      * @return data from the single {@link #getSegments() segment}
  69.      */
  70.     public OcmData getData() {
  71.         return getSegments().get(0).getData();
  72.     }

  73.     /** {@inheritDoc}
  74.      * <p>
  75.      * The metadata entries checked for use as the key are the following ones,
  76.      * the first non-null being used. The map from OCM files always contains only
  77.      * one object.
  78.      * <ul>
  79.      *   <li>{@link org.orekit.files.ccsds.ndm.odm.OdmMetadata#getObjectName() OBJECT_NAME}</li>
  80.      *   <li>{@link OcmMetadata#getInternationalDesignator() INTERNATIONAL_DESIGNATOR}</li>
  81.      *   <li>{@link OcmMetadata#getObjectDesignator() OBJECT_DESIGNATOR}</li>
  82.      *   <li>the default name {@link #UNKNOWN_OBJECT} for unknown objects</li>
  83.      * </ul>
  84.      */
  85.     @Override
  86.     public Map<String, OcmSatelliteEphemeris> getSatellites() {
  87.         // the OCM file has only one segment and a deep structure
  88.         // the real ephemeris is buried within the orbit histories logical block
  89.         final String name;
  90.         if (getMetadata().getObjectName() != null) {
  91.             name = getMetadata().getObjectName();
  92.         } else if (getMetadata().getInternationalDesignator() != null) {
  93.             name = getMetadata().getInternationalDesignator();
  94.         } else if (getMetadata().getObjectDesignator() != null) {
  95.             name = getMetadata().getObjectDesignator();
  96.         } else {
  97.             name = UNKNOWN_OBJECT;
  98.         }
  99.         final List<TrajectoryStateHistory> histories = getSegments().get(0).getData().getTrajectoryBlocks();
  100.         final OcmSatelliteEphemeris        ose       = new OcmSatelliteEphemeris(name, mu, histories);
  101.         return Collections.singletonMap(name, ose);
  102.     }

  103. }