RTNCovarianceWriter.java

  1. /* Copyright 2002-2022 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.cdm;

  18. import java.io.IOException;

  19. import org.orekit.files.ccsds.definitions.Units;
  20. import org.orekit.files.ccsds.section.AbstractWriter;
  21. import org.orekit.files.ccsds.utils.generation.Generator;

  22. /**
  23.  * Writer for RTN covariance matrix data block for CCSDS Conjunction Data Messages.
  24.  *
  25.  * @author Melina Vanel
  26.  * @since 11.2
  27.  */
  28. public class RTNCovarianceWriter extends AbstractWriter {

  29.     /** RTN covariance block. */
  30.     private final RTNCovariance rtnCovariance;

  31.     /** Create a writer.
  32.      * @param xmlTag name of the XML tag surrounding the section
  33.      * @param kvnTag name of the KVN tag surrounding the section (may be null)
  34.      * @param RTNCovariance RTN covariance data to write
  35.      */
  36.     RTNCovarianceWriter(final String xmlTag, final String kvnTag,
  37.                         final RTNCovariance RTNCovariance) {
  38.         super(xmlTag, kvnTag);
  39.         this.rtnCovariance = RTNCovariance;
  40.     }

  41.     /** {@inheritDoc} */
  42.     @Override
  43.     protected void writeContent(final Generator generator) throws IOException {

  44.         generator.writeComments(rtnCovariance.getComments());

  45.         // RTN covariance matrix
  46.         generator.writeEntry(RTNCovarianceKey.CR_R.name(),         rtnCovariance.getCrr(),       Units.M2,          true);
  47.         generator.writeEntry(RTNCovarianceKey.CT_R.name(),         rtnCovariance.getCtr(),       Units.M2,          true);
  48.         generator.writeEntry(RTNCovarianceKey.CT_T.name(),         rtnCovariance.getCtt(),       Units.M2,          true);
  49.         generator.writeEntry(RTNCovarianceKey.CN_R.name(),         rtnCovariance.getCnr(),       Units.M2,          true);
  50.         generator.writeEntry(RTNCovarianceKey.CN_T.name(),         rtnCovariance.getCnt(),       Units.M2,          true);
  51.         generator.writeEntry(RTNCovarianceKey.CN_N.name(),         rtnCovariance.getCnn(),       Units.M2,          true);
  52.         generator.writeEntry(RTNCovarianceKey.CRDOT_R.name(),      rtnCovariance.getCrdotr(),    Units.M2_PER_S,    true);
  53.         generator.writeEntry(RTNCovarianceKey.CRDOT_T.name(),      rtnCovariance.getCrdott(),    Units.M2_PER_S,    true);
  54.         generator.writeEntry(RTNCovarianceKey.CRDOT_N.name(),      rtnCovariance.getCrdotn(),    Units.M2_PER_S,    true);
  55.         generator.writeEntry(RTNCovarianceKey.CRDOT_RDOT.name(),   rtnCovariance.getCrdotrdot(), Units.M2_PER_S2,   true);
  56.         generator.writeEntry(RTNCovarianceKey.CTDOT_R.name(),      rtnCovariance.getCtdotr(),    Units.M2_PER_S,    true);
  57.         generator.writeEntry(RTNCovarianceKey.CTDOT_T.name(),      rtnCovariance.getCtdott(),    Units.M2_PER_S,    true);
  58.         generator.writeEntry(RTNCovarianceKey.CTDOT_N.name(),      rtnCovariance.getCtdotn(),    Units.M2_PER_S,    true);
  59.         generator.writeEntry(RTNCovarianceKey.CTDOT_RDOT.name(),   rtnCovariance.getCtdotrdot(), Units.M2_PER_S2,   true);
  60.         generator.writeEntry(RTNCovarianceKey.CTDOT_TDOT.name(),   rtnCovariance.getCtdottdot(), Units.M2_PER_S2,   true);
  61.         generator.writeEntry(RTNCovarianceKey.CNDOT_R.name(),      rtnCovariance.getCndotr(),    Units.M2_PER_S,    true);
  62.         generator.writeEntry(RTNCovarianceKey.CNDOT_T.name(),      rtnCovariance.getCndott(),    Units.M2_PER_S,    true);
  63.         generator.writeEntry(RTNCovarianceKey.CNDOT_N.name(),      rtnCovariance.getCndotn(),    Units.M2_PER_S,    true);
  64.         generator.writeEntry(RTNCovarianceKey.CNDOT_RDOT.name(),   rtnCovariance.getCndotrdot(), Units.M2_PER_S2,   true);
  65.         generator.writeEntry(RTNCovarianceKey.CNDOT_TDOT.name(),   rtnCovariance.getCndottdot(), Units.M2_PER_S2,   true);
  66.         generator.writeEntry(RTNCovarianceKey.CNDOT_NDOT.name(),   rtnCovariance.getCndotndot(), Units.M2_PER_S2,   true);
  67.         generator.writeEntry(RTNCovarianceKey.CDRG_R.name(),       rtnCovariance.getCdrgr(),     Units.M3_PER_KG,   false);
  68.         generator.writeEntry(RTNCovarianceKey.CDRG_T.name(),       rtnCovariance.getCdrgt(),     Units.M3_PER_KG,   false);
  69.         generator.writeEntry(RTNCovarianceKey.CDRG_N.name(),       rtnCovariance.getCdrgn(),     Units.M3_PER_KG,   false);
  70.         generator.writeEntry(RTNCovarianceKey.CDRG_RDOT.name(),    rtnCovariance.getCdrgrdot(),  Units.M3_PER_KGS,  false);
  71.         generator.writeEntry(RTNCovarianceKey.CDRG_TDOT.name(),    rtnCovariance.getCdrgtdot(),  Units.M3_PER_KGS,  false);
  72.         generator.writeEntry(RTNCovarianceKey.CDRG_NDOT.name(),    rtnCovariance.getCdrgndot(),  Units.M3_PER_KGS,  false);
  73.         generator.writeEntry(RTNCovarianceKey.CDRG_DRG.name(),     rtnCovariance.getCdrgdrg(),   Units.M4_PER_KG2,  false);
  74.         generator.writeEntry(RTNCovarianceKey.CSRP_R.name(),       rtnCovariance.getCsrpr(),     Units.M3_PER_KG,   false);
  75.         generator.writeEntry(RTNCovarianceKey.CSRP_T.name(),       rtnCovariance.getCsrpt(),     Units.M3_PER_KG,   false);
  76.         generator.writeEntry(RTNCovarianceKey.CSRP_N.name(),       rtnCovariance.getCsrpn(),     Units.M3_PER_KG,   false);
  77.         generator.writeEntry(RTNCovarianceKey.CSRP_RDOT.name(),    rtnCovariance.getCsrprdot(),  Units.M3_PER_KGS,  false);
  78.         generator.writeEntry(RTNCovarianceKey.CSRP_TDOT.name(),    rtnCovariance.getCsrptdot(),  Units.M3_PER_KGS,  false);
  79.         generator.writeEntry(RTNCovarianceKey.CSRP_NDOT.name(),    rtnCovariance.getCsrpndot(),  Units.M3_PER_KGS,  false);
  80.         generator.writeEntry(RTNCovarianceKey.CSRP_DRG.name(),     rtnCovariance.getCsrpdrg(),   Units.M4_PER_KG2,  false);
  81.         generator.writeEntry(RTNCovarianceKey.CSRP_SRP.name(),     rtnCovariance.getCsrpsrp(),   Units.M4_PER_KG2,  false);
  82.         generator.writeEntry(RTNCovarianceKey.CTHR_R.name(),       rtnCovariance.getCthrr(),     Units.M2_PER_S2,   false);
  83.         generator.writeEntry(RTNCovarianceKey.CTHR_T.name(),       rtnCovariance.getCthrt(),     Units.M2_PER_S2,   false);
  84.         generator.writeEntry(RTNCovarianceKey.CTHR_N.name(),       rtnCovariance.getCthrn(),     Units.M2_PER_S2,   false);
  85.         generator.writeEntry(RTNCovarianceKey.CTHR_RDOT.name(),    rtnCovariance.getCthrrdot(),  Units.M2_PER_S3,   false);
  86.         generator.writeEntry(RTNCovarianceKey.CTHR_TDOT.name(),    rtnCovariance.getCthrtdot(),  Units.M2_PER_S3,   false);
  87.         generator.writeEntry(RTNCovarianceKey.CTHR_NDOT.name(),    rtnCovariance.getCthrndot(),  Units.M2_PER_S3,   false);
  88.         generator.writeEntry(RTNCovarianceKey.CTHR_DRG.name(),     rtnCovariance.getCthrdrg(),   Units.M3_PER_KGS2, false);
  89.         generator.writeEntry(RTNCovarianceKey.CTHR_SRP.name(),     rtnCovariance.getCthrsrp(),   Units.M3_PER_KGS2, false);
  90.         generator.writeEntry(RTNCovarianceKey.CTHR_THR.name(),     rtnCovariance.getCthrthr(),   Units.M2_PER_S4,   false);

  91.     }
  92. }