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.cdm;
18  
19  import java.io.IOException;
20  
21  import org.orekit.files.ccsds.definitions.Units;
22  import org.orekit.files.ccsds.section.AbstractWriter;
23  import org.orekit.files.ccsds.utils.generation.Generator;
24  
25  /**
26   * Writer for RTN covariance matrix data block for CCSDS Conjunction Data Messages.
27   *
28   * @author Melina Vanel
29   * @since 11.2
30   */
31  public class RTNCovarianceWriter extends AbstractWriter {
32  
33      /** RTN covariance block. */
34      private final RTNCovariance rtnCovariance;
35  
36      /** Create a writer.
37       * @param xmlTag name of the XML tag surrounding the section
38       * @param kvnTag name of the KVN tag surrounding the section (may be null)
39       * @param RTNCovariance RTN covariance data to write
40       */
41      RTNCovarianceWriter(final String xmlTag, final String kvnTag,
42                          final RTNCovariance RTNCovariance) {
43          super(xmlTag, kvnTag);
44          this.rtnCovariance = RTNCovariance;
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      protected void writeContent(final Generator generator) throws IOException {
50  
51          generator.writeComments(rtnCovariance.getComments());
52  
53          // RTN covariance matrix
54          generator.writeEntry(RTNCovarianceKey.CR_R.name(),         rtnCovariance.getCrr(),       Units.M2,          true);
55          generator.writeEntry(RTNCovarianceKey.CT_R.name(),         rtnCovariance.getCtr(),       Units.M2,          true);
56          generator.writeEntry(RTNCovarianceKey.CT_T.name(),         rtnCovariance.getCtt(),       Units.M2,          true);
57          generator.writeEntry(RTNCovarianceKey.CN_R.name(),         rtnCovariance.getCnr(),       Units.M2,          true);
58          generator.writeEntry(RTNCovarianceKey.CN_T.name(),         rtnCovariance.getCnt(),       Units.M2,          true);
59          generator.writeEntry(RTNCovarianceKey.CN_N.name(),         rtnCovariance.getCnn(),       Units.M2,          true);
60          generator.writeEntry(RTNCovarianceKey.CRDOT_R.name(),      rtnCovariance.getCrdotr(),    Units.M2_PER_S,    true);
61          generator.writeEntry(RTNCovarianceKey.CRDOT_T.name(),      rtnCovariance.getCrdott(),    Units.M2_PER_S,    true);
62          generator.writeEntry(RTNCovarianceKey.CRDOT_N.name(),      rtnCovariance.getCrdotn(),    Units.M2_PER_S,    true);
63          generator.writeEntry(RTNCovarianceKey.CRDOT_RDOT.name(),   rtnCovariance.getCrdotrdot(), Units.M2_PER_S2,   true);
64          generator.writeEntry(RTNCovarianceKey.CTDOT_R.name(),      rtnCovariance.getCtdotr(),    Units.M2_PER_S,    true);
65          generator.writeEntry(RTNCovarianceKey.CTDOT_T.name(),      rtnCovariance.getCtdott(),    Units.M2_PER_S,    true);
66          generator.writeEntry(RTNCovarianceKey.CTDOT_N.name(),      rtnCovariance.getCtdotn(),    Units.M2_PER_S,    true);
67          generator.writeEntry(RTNCovarianceKey.CTDOT_RDOT.name(),   rtnCovariance.getCtdotrdot(), Units.M2_PER_S2,   true);
68          generator.writeEntry(RTNCovarianceKey.CTDOT_TDOT.name(),   rtnCovariance.getCtdottdot(), Units.M2_PER_S2,   true);
69          generator.writeEntry(RTNCovarianceKey.CNDOT_R.name(),      rtnCovariance.getCndotr(),    Units.M2_PER_S,    true);
70          generator.writeEntry(RTNCovarianceKey.CNDOT_T.name(),      rtnCovariance.getCndott(),    Units.M2_PER_S,    true);
71          generator.writeEntry(RTNCovarianceKey.CNDOT_N.name(),      rtnCovariance.getCndotn(),    Units.M2_PER_S,    true);
72          generator.writeEntry(RTNCovarianceKey.CNDOT_RDOT.name(),   rtnCovariance.getCndotrdot(), Units.M2_PER_S2,   true);
73          generator.writeEntry(RTNCovarianceKey.CNDOT_TDOT.name(),   rtnCovariance.getCndottdot(), Units.M2_PER_S2,   true);
74          generator.writeEntry(RTNCovarianceKey.CNDOT_NDOT.name(),   rtnCovariance.getCndotndot(), Units.M2_PER_S2,   true);
75          generator.writeEntry(RTNCovarianceKey.CDRG_R.name(),       rtnCovariance.getCdrgr(),     Units.M3_PER_KG,   false);
76          generator.writeEntry(RTNCovarianceKey.CDRG_T.name(),       rtnCovariance.getCdrgt(),     Units.M3_PER_KG,   false);
77          generator.writeEntry(RTNCovarianceKey.CDRG_N.name(),       rtnCovariance.getCdrgn(),     Units.M3_PER_KG,   false);
78          generator.writeEntry(RTNCovarianceKey.CDRG_RDOT.name(),    rtnCovariance.getCdrgrdot(),  Units.M3_PER_KGS,  false);
79          generator.writeEntry(RTNCovarianceKey.CDRG_TDOT.name(),    rtnCovariance.getCdrgtdot(),  Units.M3_PER_KGS,  false);
80          generator.writeEntry(RTNCovarianceKey.CDRG_NDOT.name(),    rtnCovariance.getCdrgndot(),  Units.M3_PER_KGS,  false);
81          generator.writeEntry(RTNCovarianceKey.CDRG_DRG.name(),     rtnCovariance.getCdrgdrg(),   Units.M4_PER_KG2,  false);
82          generator.writeEntry(RTNCovarianceKey.CSRP_R.name(),       rtnCovariance.getCsrpr(),     Units.M3_PER_KG,   false);
83          generator.writeEntry(RTNCovarianceKey.CSRP_T.name(),       rtnCovariance.getCsrpt(),     Units.M3_PER_KG,   false);
84          generator.writeEntry(RTNCovarianceKey.CSRP_N.name(),       rtnCovariance.getCsrpn(),     Units.M3_PER_KG,   false);
85          generator.writeEntry(RTNCovarianceKey.CSRP_RDOT.name(),    rtnCovariance.getCsrprdot(),  Units.M3_PER_KGS,  false);
86          generator.writeEntry(RTNCovarianceKey.CSRP_TDOT.name(),    rtnCovariance.getCsrptdot(),  Units.M3_PER_KGS,  false);
87          generator.writeEntry(RTNCovarianceKey.CSRP_NDOT.name(),    rtnCovariance.getCsrpndot(),  Units.M3_PER_KGS,  false);
88          generator.writeEntry(RTNCovarianceKey.CSRP_DRG.name(),     rtnCovariance.getCsrpdrg(),   Units.M4_PER_KG2,  false);
89          generator.writeEntry(RTNCovarianceKey.CSRP_SRP.name(),     rtnCovariance.getCsrpsrp(),   Units.M4_PER_KG2,  false);
90          generator.writeEntry(RTNCovarianceKey.CTHR_R.name(),       rtnCovariance.getCthrr(),     Units.M2_PER_S2,   false);
91          generator.writeEntry(RTNCovarianceKey.CTHR_T.name(),       rtnCovariance.getCthrt(),     Units.M2_PER_S2,   false);
92          generator.writeEntry(RTNCovarianceKey.CTHR_N.name(),       rtnCovariance.getCthrn(),     Units.M2_PER_S2,   false);
93          generator.writeEntry(RTNCovarianceKey.CTHR_RDOT.name(),    rtnCovariance.getCthrrdot(),  Units.M2_PER_S3,   false);
94          generator.writeEntry(RTNCovarianceKey.CTHR_TDOT.name(),    rtnCovariance.getCthrtdot(),  Units.M2_PER_S3,   false);
95          generator.writeEntry(RTNCovarianceKey.CTHR_NDOT.name(),    rtnCovariance.getCthrndot(),  Units.M2_PER_S3,   false);
96          generator.writeEntry(RTNCovarianceKey.CTHR_DRG.name(),     rtnCovariance.getCthrdrg(),   Units.M3_PER_KGS2, false);
97          generator.writeEntry(RTNCovarianceKey.CTHR_SRP.name(),     rtnCovariance.getCthrsrp(),   Units.M3_PER_KGS2, false);
98          generator.writeEntry(RTNCovarianceKey.CTHR_THR.name(),     rtnCovariance.getCthrthr(),   Units.M2_PER_S4,   false);
99  
100     }
101 }