Commit 601c3f51 authored by Evan Ward's avatar Evan Ward
Browse files

Merge branch 'oem-no-a-912' into 'develop'

Fix writing OEM without acceleration #912

See merge request orekit/orekit!256
parents 8d966fcb 278e9d1d
......@@ -36,6 +36,9 @@
<action dev="evan" type="fix" issue="882">
Fix StreamingOemWriter in ITRF and without optional fields.
</action>
<action dev="evan" type="fix" issue="912">
Fix StreamingOemWriter without acceleration.
</action>
<action dev="bryan" type="add" issue="900">
Added init method in {Field}AdditionalStateProvider.
</action>
......
......@@ -84,6 +84,9 @@ public class StreamingOemWriter implements AutoCloseable {
/** If the propagator's frame should be used. */
private final boolean useAttitudeFrame;
/** If acceleration should be included in the output. */
private final boolean includeAcceleration;
/** Indicator for writing header. */
private boolean headerWritePending;
......@@ -104,7 +107,8 @@ public class StreamingOemWriter implements AutoCloseable {
}
/**
* Simple constructor.
* Construct a writer that writes position, velocity, and acceleration at
* each time step.
*
* @param generator generator for OEM output
* @param writer writer for the AEM message format
......@@ -114,16 +118,43 @@ public class StreamingOemWriter implements AutoCloseable {
* segment is taken from the first state's attitude.
* Otherwise the {@code template}'s reference frame
* is used, {@link OemMetadata#getReferenceFrame()}.
* @see #StreamingOemWriter(Generator, OemWriter, Header, OemMetadata,
* boolean, boolean)
* @since 11.2
*/
public StreamingOemWriter(final Generator generator, final OemWriter writer,
final Header header, final OemMetadata template,
final boolean useAttitudeFrame) {
this(generator, writer, header, template, useAttitudeFrame, true);
}
/**
* Simple constructor.
*
* @param generator generator for OEM output
* @param writer writer for the AEM message format
* @param header file header (may be null)
* @param template template for metadata
* @param useAttitudeFrame if {@code true} then the reference frame for
* each segment is taken from the first state's
* attitude. Otherwise the {@code template}'s
* reference frame is used, {@link
* OemMetadata#getReferenceFrame()}.
* @param includeAcceleration if {@code true} then acceleration is included
* in the OEM file produced. Otherwise only
* position and velocity is included.
* @since 11.2
*/
public StreamingOemWriter(final Generator generator, final OemWriter writer,
final Header header, final OemMetadata template,
final boolean useAttitudeFrame,
final boolean includeAcceleration) {
this.generator = generator;
this.writer = writer;
this.header = header;
this.metadata = template.copy(header == null ? writer.getDefaultVersion() : header.getFormatVersion());
this.useAttitudeFrame = useAttitudeFrame;
this.includeAcceleration = includeAcceleration;
this.headerWritePending = true;
}
......@@ -195,7 +226,7 @@ public class StreamingOemWriter implements AutoCloseable {
try {
final TimeStampedPVCoordinates pv =
currentState.getPVCoordinates(frame);
writer.writeOrbitEphemerisLine(generator, metadata, pv, true);
writer.writeOrbitEphemerisLine(generator, metadata, pv, includeAcceleration);
} catch (IOException e) {
throw new OrekitException(e, LocalizedCoreFormats.SIMPLE_MESSAGE, e.getLocalizedMessage());
}
......
......@@ -234,6 +234,7 @@ public class StreamingOemWriterTest {
new WriterBuilder().buildOemWriter(),
header,
metadata,
false,
false);
propagator.setStepHandler(30 * 60, writer.newSegment());
propagator.propagate(propagator.getMinDate(), propagator.getMaxDate());
......@@ -250,6 +251,11 @@ public class StreamingOemWriterTest {
MatcherAssert.assertThat(
actualText,
CoreMatchers.not(CoreMatchers.containsString("INTERPOLATION_DEGREE")));
// check no acceleration
MatcherAssert.assertThat(
actualText,
CoreMatchers.containsString(
"\n2017-04-11T22:31:43.121856 -2757.3016318893897 -4173.479601381253 4566.01849801963 6.625901653953951 -1.011817208875361 3.0698336591568833\n"));
}
private static void compareOemEphemerisBlocks(OemSegment block1,
......
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