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.omm;
19  
20  import java.io.IOException;
21  
22  import org.orekit.files.ccsds.definitions.Units;
23  import org.orekit.files.ccsds.section.AbstractWriter;
24  import org.orekit.files.ccsds.utils.generation.Generator;
25  import org.orekit.utils.units.Unit;
26  
27  /** Writer for Two-Line Elements data.
28   * @author Luc Maisonobe
29   * @since 11.0
30   */
31  class OmmTleWriter extends AbstractWriter {
32  
33      /** Two-Lines Elements block. */
34      private final OmmTle tleBlock;
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 tleBlock Two-Lines Elements to write
40       */
41      OmmTleWriter(final String xmlTag, final String kvnTag,
42                   final OmmTle tleBlock) {
43          super(xmlTag, kvnTag);
44          this.tleBlock = tleBlock;
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      protected void writeContent(final Generator generator) throws IOException {
50  
51          // Keplerian elements block
52          generator.writeComments(tleBlock.getComments());
53          generator.writeEntry(OmmTleKey.EPHEMERIS_TYPE.name(),      tleBlock.getEphemerisType(),      true);
54          generator.writeEntry(OmmTleKey.CLASSIFICATION_TYPE.name(), tleBlock.getClassificationType(), true);
55          generator.writeEntry(OmmTleKey.NORAD_CAT_ID.name(),        tleBlock.getNoradID(),            true);
56          generator.writeEntry(OmmTleKey.ELEMENT_SET_NO.name(),      tleBlock.getElementSetNumber(),   true);
57          generator.writeEntry(OmmTleKey.REV_AT_EPOCH.name(),        tleBlock.getRevAtEpoch(),         true);
58          generator.writeEntry(OmmTleKey.BSTAR.name(),               tleBlock.getBStar(),            Unit.ONE,                  true);
59          generator.writeEntry(OmmTleKey.MEAN_MOTION_DOT.name(),     tleBlock.getMeanMotionDot(),    Units.REV_PER_DAY2_SCALED, true);
60          generator.writeEntry(OmmTleKey.MEAN_MOTION_DDOT.name(),    tleBlock.getMeanMotionDotDot(), Units.REV_PER_DAY3_SCALED, true);
61  
62      }
63  
64  }