OmmData.java

  1. /* Copyright 2002-2024 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.omm;

  18. import org.orekit.errors.OrekitException;
  19. import org.orekit.errors.OrekitMessages;
  20. import org.orekit.files.ccsds.ndm.odm.CartesianCovariance;
  21. import org.orekit.files.ccsds.ndm.odm.KeplerianElements;
  22. import org.orekit.files.ccsds.ndm.odm.KeplerianElementsKey;
  23. import org.orekit.files.ccsds.ndm.odm.SpacecraftParameters;
  24. import org.orekit.files.ccsds.ndm.odm.UserDefined;
  25. import org.orekit.files.ccsds.section.Data;

  26. /**
  27.  * Container for Orbit Mean-elements Message data.
  28.  * @author Luc Maisonobe
  29.  * @since 11.0
  30.  */
  31. public class OmmData implements Data {

  32.     /** Keplerian elements block. */
  33.     private final KeplerianElements keplerianElementsBlock;

  34.     /** Spacecraft parameters block. */
  35.     private final SpacecraftParameters spacecraftParameters;

  36.     /** TLE block. */
  37.     private final OmmTle tleBlock;

  38.     /** Covariance matrix logical block being read. */
  39.     private final CartesianCovariance covarianceBlock;

  40.     /** User defined parameters. */
  41.     private final UserDefined userDefinedBlock;

  42.     /** Mass. */
  43.     private final double mass;

  44.     /** Simple constructor.
  45.      * @param keplerianElementsBlock Keplerian elements logical block
  46.      * @param spacecraftParameters spacecraft parameters logical block (may be null)
  47.      * @param tleBlock TLE logical block (may be null)
  48.      * @param covarianceBlock covariance matrix logical block (may be null)
  49.      * @param userDefinedBlock user-defined logical block
  50.      * @param mass mass (always defined, even if there is no {@code spacecraftParameters} block
  51.      */
  52.     public OmmData(final KeplerianElements keplerianElementsBlock,
  53.                    final SpacecraftParameters spacecraftParameters,
  54.                    final OmmTle tleBlock,
  55.                    final CartesianCovariance covarianceBlock,
  56.                    final UserDefined userDefinedBlock,
  57.                    final double mass) {
  58.         this.keplerianElementsBlock = keplerianElementsBlock;
  59.         this.spacecraftParameters   = spacecraftParameters;
  60.         this.tleBlock               = tleBlock;
  61.         this.covarianceBlock        = covarianceBlock;
  62.         this.userDefinedBlock       = userDefinedBlock;
  63.         this.mass                   = mass;
  64.     }

  65.     /** {@inheritDoc} */
  66.     @Override
  67.     public void validate(final double version) {
  68.         if (keplerianElementsBlock == null) {
  69.             throw new OrekitException(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY,
  70.                                       KeplerianElementsKey.EPOCH);
  71.         }
  72.         keplerianElementsBlock.validate(version);
  73.         if (spacecraftParameters != null) {
  74.             spacecraftParameters.validate(version);
  75.         }
  76.         if (tleBlock == null) {
  77.             // semi-major axis was not checked above, we do it now
  78.             keplerianElementsBlock.checkNotNaN(keplerianElementsBlock.getA(),
  79.                                                KeplerianElementsKey.SEMI_MAJOR_AXIS.name());
  80.         } else {
  81.             // in OMM with TLE block, only mean motion is allowed, not semi-major axis
  82.             keplerianElementsBlock.checkNotNaN(keplerianElementsBlock.getMeanMotion(),
  83.                                                KeplerianElementsKey.MEAN_MOTION.name());
  84.             tleBlock.validate(version);
  85.         }
  86.         if (covarianceBlock != null) {
  87.             covarianceBlock.setEpoch(keplerianElementsBlock.getEpoch());
  88.             covarianceBlock.validate(version);
  89.         }
  90.         if (userDefinedBlock != null) {
  91.             userDefinedBlock.validate(version);
  92.         }
  93.     }

  94.     /** Get the Keplerian elements logical block.
  95.      * @return Keplerian elements block
  96.      */
  97.     public KeplerianElements getKeplerianElementsBlock() {
  98.         return keplerianElementsBlock;
  99.     }

  100.     /** Get the spacecraft parameters logical block.
  101.      * @return spacecraft parameters block (may be null)
  102.      */
  103.     public SpacecraftParameters getSpacecraftParametersBlock() {
  104.         return spacecraftParameters;
  105.     }

  106.     /** Get the TLE logical block.
  107.      * @return TLE block
  108.      */
  109.     public OmmTle getTLEBlock() {
  110.         return tleBlock;
  111.     }

  112.     /** Get the covariance matrix logical block.
  113.      * @return covariance matrix block (may be null)
  114.      */
  115.     public CartesianCovariance getCovarianceBlock() {
  116.         return covarianceBlock;
  117.     }

  118.     /** Get the user defined parameters logical block.
  119.      * @return user defined parameters block (may be null)
  120.      */
  121.     public UserDefined getUserDefinedBlock() {
  122.         return userDefinedBlock;
  123.     }

  124.     /** Get the mass.
  125.      * @return mass
  126.      */
  127.     public double getMass() {
  128.         return mass;
  129.     }

  130. }