Commit ea6d262b authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Fixed missing tags in XML generation by EphemerisWriter.

Fixes #917
parent a0dc51c7
......@@ -21,6 +21,9 @@
</properties>
<body>
<release version="11.2" date="TBD" description="TBD">
<action dev="luc" type="fix" issue="917">
Fixed missing tags in XML generation by EphemerisWriter.
</action>
<action dev="pascal" type="add" issue="911">
Added TDOA and bistatic range rate measurements.
</action>
......
......@@ -173,6 +173,9 @@ public class EphemerisWriter implements EphemerisFileWriter {
metadata.setInterpolationDegree(segment.getInterpolationSamples() - 1);
writer.writeMetadata(generator, metadata);
// we enter data section
writer.startData(generator);
if (segment instanceof OemSegment) {
// write data comments
generator.writeComments(((OemSegment) segment).getData().getComments());
......@@ -193,6 +196,9 @@ public class EphemerisWriter implements EphemerisFileWriter {
writer.writeCovariances(generator, metadata, ((OemSegment) segment).getCovarianceMatrices());
}
// we exit data section
writer.endData(generator);
}
}
......@@ -38,6 +38,7 @@ import org.orekit.time.TimeScale;
* Base class for Navigation Data Message (NDM) files.
* @param <H> type of the header
* @param <S> type of the segments
* @param <F> type of the NDM constituent
* @author Luc Maisonobe
* @since 11.0
*/
......
......@@ -49,7 +49,9 @@ import org.orekit.files.ccsds.ndm.ParserBuilder;
import org.orekit.files.ccsds.ndm.WriterBuilder;
import org.orekit.files.ccsds.ndm.odm.CartesianCovariance;
import org.orekit.files.ccsds.utils.FileFormat;
import org.orekit.files.ccsds.utils.generation.Generator;
import org.orekit.files.ccsds.utils.generation.KvnGenerator;
import org.orekit.files.ccsds.utils.generation.XmlGenerator;
import org.orekit.files.general.EphemerisFile;
import org.orekit.frames.Frame;
import org.orekit.frames.FramesFactory;
......@@ -76,7 +78,20 @@ public class EphemerisWriterTest {
}
@Test
public void testWriteOEM1() throws IOException {
public void testWriteOEM1Kvn() throws IOException {
final CharArrayWriter caw = new CharArrayWriter();
final Generator generator = new KvnGenerator(caw, 0, "", 60);
doTestWriteOEM1(caw, generator);
}
@Test
public void testWriteOEM1Xml() throws IOException {
final CharArrayWriter caw = new CharArrayWriter();
final Generator generator = new XmlGenerator(caw, 2, "", true);
doTestWriteOEM1(caw, generator);
}
private void doTestWriteOEM1(final CharArrayWriter caw, Generator generator) throws IOException {
final String ex = "/ccsds/odm/oem/OEMExample1.txt";
final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
final OemParser parser = new ParserBuilder().withMu(CelestialBodyFactory.getMars().getGM()).buildOemParser();
......@@ -86,8 +101,7 @@ public class EphemerisWriterTest {
withConventions(IERSConventions.IERS_2010).
withDataContext(DataContext.getDefault()).
buildOemWriter();
final CharArrayWriter caw = new CharArrayWriter();
writer.writeMessage(new KvnGenerator(caw, 0, "", 60), oem);
writer.writeMessage(generator, oem);
final byte[] bytes = caw.toString().getBytes(StandardCharsets.UTF_8);
final Oem generatedOem = new ParserBuilder().
......
......@@ -93,7 +93,16 @@ public class OrekitEphemerisFileTest {
}
@Test
public void testWritingToOEM() throws IOException {
public void testWritingToOEMKvn() throws IOException {
doTestWritingToOEM(FileFormat.KVN);
}
@Test
public void testWritingToOEMXml() throws IOException {
doTestWritingToOEM(FileFormat.XML);
}
private void doTestWritingToOEM(final FileFormat fileFormat) throws IOException {
final double muTolerance = 1e-12;
// As the default format for position is 3 digits after decimal point in km the max precision in m is 1
final double positionTolerance = 1.;
......@@ -144,7 +153,7 @@ public class OrekitEphemerisFileTest {
template.setCenter(new BodyFacade("EARTH", CelestialBodyFactory.getCelestialBodies().getEarth()));
template.setReferenceFrame(FrameFacade.map(FramesFactory.getEME2000()));
EphemerisWriter writer = new EphemerisWriter(new WriterBuilder().buildOemWriter(),
null, template, FileFormat.KVN, "dummy", 60);
null, template, fileFormat, "dummy", 60);
writer.write(tempOem, ephemerisFile);
OemParser parser = new ParserBuilder().withMu(body.getGM()).withDefaultInterpolationDegree(2).buildOemParser();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment