Commit 17568153 authored by Luc Maisonobe's avatar Luc Maisonobe

Added write of CCSDS units.

parent 551fef1b
......@@ -16,8 +16,6 @@
*/
package org.orekit.files.ccsds.definitions;
import java.util.List;
import org.orekit.utils.units.Unit;
/**
......@@ -61,10 +59,10 @@ public class Units {
public static final Unit REV_PER_DAY = Unit.parse("rev/d");
/** Scaled revolutions per square day unit. */
public static final Unit REV_PER_DAY2_SCALED = Unit.parse("rev/d²").scale("2rev/d²", 2.0);
public static final Unit REV_PER_DAY2_SCALED = Unit.parse("2rev/d²");
/** Scaled revolutions per cubic day divieded by 6 unit. */
public static final Unit REV_PER_DAY3_SCALED = Unit.parse("rev/d³").scale("6rev/d³", 6.0);
public static final Unit REV_PER_DAY3_SCALED = Unit.parse("6rev/d³");
/** Degree per second unit. */
public static final Unit DEG_PER_S = Unit.parse("°/s");
......@@ -87,30 +85,4 @@ public class Units {
// nothing to do
}
/** Convert a list of units to a bracketed string.
* @param units lists to output (may be null or empty)
* @return bracketed string (null if units list is null or empty)
*/
public static String outputBracketed(final List<Unit> units) {
if (units == null || units.isEmpty()) {
// nothing to output
return null;
}
final StringBuilder builder = new StringBuilder();
builder.append('[');
boolean first = true;
for (final Unit unit : units) {
if (!first) {
builder.append(',');
}
builder.append(unit.getName());
first = false;
}
builder.append(']');
return builder.toString();
}
}
......@@ -49,11 +49,11 @@ public class AdmMetadataWriter extends AbstractWriter {
generator.writeComments(metadata.getComments());
// object
generator.writeEntry(AdmMetadataKey.OBJECT_NAME.name(), metadata.getObjectName(), true);
generator.writeEntry(AdmMetadataKey.OBJECT_ID.name(), metadata.getObjectID(), true);
generator.writeEntry(AdmMetadataKey.OBJECT_NAME.name(), metadata.getObjectName(), null, true);
generator.writeEntry(AdmMetadataKey.OBJECT_ID.name(), metadata.getObjectID(), null, true);
// center
generator.writeEntry(AdmMetadataKey.CENTER_NAME.name(), metadata.getCenter().getName(), true);
generator.writeEntry(AdmMetadataKey.CENTER_NAME.name(), metadata.getCenter().getName(), null, true);
// time
generator.writeEntry(MetadataKey.TIME_SYSTEM.name(), metadata.getTimeSystem(), true);
......
......@@ -305,16 +305,16 @@ public class AemWriter extends AbstractMessageWriter<Header, AemSegment, AemFile
generator.writeComments(metadata.getComments());
// objects
generator.writeEntry(AdmMetadataKey.OBJECT_NAME.name(), metadata.getObjectName(), true);
generator.writeEntry(AdmMetadataKey.OBJECT_ID.name(), metadata.getObjectID(), true);
generator.writeEntry(AdmMetadataKey.OBJECT_NAME.name(), metadata.getObjectName(), null, true);
generator.writeEntry(AdmMetadataKey.OBJECT_ID.name(), metadata.getObjectID(), null, true);
if (metadata.getCenter() != null) {
generator.writeEntry(AdmMetadataKey.CENTER_NAME.name(), metadata.getCenter().getName(), false);
generator.writeEntry(AdmMetadataKey.CENTER_NAME.name(), metadata.getCenter().getName(), null, false);
}
// frames
generator.writeEntry(AemMetadataKey.REF_FRAME_A.name(), metadata.getEndpoints().getFrameA().getName(), true);
generator.writeEntry(AemMetadataKey.REF_FRAME_B.name(), metadata.getEndpoints().getFrameB().getName(), true);
generator.writeEntry(AemMetadataKey.ATTITUDE_DIR.name(), metadata.getEndpoints().isA2b() ? A_TO_B : B_TO_A, true);
generator.writeEntry(AemMetadataKey.REF_FRAME_A.name(), metadata.getEndpoints().getFrameA().getName(), null, true);
generator.writeEntry(AemMetadataKey.REF_FRAME_B.name(), metadata.getEndpoints().getFrameB().getName(), null, true);
generator.writeEntry(AemMetadataKey.ATTITUDE_DIR.name(), metadata.getEndpoints().isA2b() ? A_TO_B : B_TO_A, null, true);
// time
generator.writeEntry(MetadataKey.TIME_SYSTEM.name(), metadata.getTimeSystem(), true);
......@@ -329,11 +329,11 @@ public class AemWriter extends AbstractMessageWriter<Header, AemSegment, AemFile
// types
final AttitudeType attitudeType = metadata.getAttitudeType();
generator.writeEntry(AemMetadataKey.ATTITUDE_TYPE.name(), attitudeType.toString(), true);
generator.writeEntry(AemMetadataKey.ATTITUDE_TYPE.name(), attitudeType.toString(), null, true);
if (attitudeType == AttitudeType.QUATERNION ||
attitudeType == AttitudeType.QUATERNION_DERIVATIVE ||
attitudeType == AttitudeType.QUATERNION_RATE) {
generator.writeEntry(AemMetadataKey.QUATERNION_TYPE.name(), metadata.isFirst() ? FIRST : LAST, false);
generator.writeEntry(AemMetadataKey.QUATERNION_TYPE.name(), metadata.isFirst() ? FIRST : LAST, null, false);
}
if (attitudeType == AttitudeType.EULER_ANGLE ||
......@@ -345,23 +345,23 @@ public class AemWriter extends AbstractMessageWriter<Header, AemSegment, AemFile
}
generator.writeEntry(AemMetadataKey.EULER_ROT_SEQ.name(),
metadata.getEulerRotSeq().name().replace('X', '1').replace('Y', '2').replace('Z', '3'),
false);
null, false);
}
if (attitudeType == AttitudeType.QUATERNION_RATE ||
attitudeType == AttitudeType.EULER_ANGLE_RATE) {
generator.writeEntry(AemMetadataKey.RATE_FRAME.name(),
metadata.rateFrameIsA() ? REF_FRAME_A : REF_FRAME_B,
false);
null, false);
}
// interpolation
generator.writeEntry(AemMetadataKey.INTERPOLATION_METHOD.name(),
metadata.getInterpolationMethod(),
false);
null, false);
generator.writeEntry(AemMetadataKey.INTERPOLATION_DEGREE.name(),
Integer.toString(metadata.getInterpolationDegree()),
false);
null, false);
// Stop metadata
generator.exitSection();
......
......@@ -55,6 +55,9 @@ public class AttitudeWriter implements AttitudeEphemerisFileWriter {
/** Output name for error messages. */
private final String outputName;
/** Column number for aligning units. */
private final int unitsColumn;
/**
* Constructor used to create a new AEM writer configured with the necessary parameters
* to successfully fill in all required fields that aren't part of a standard object.
......@@ -79,16 +82,19 @@ public class AttitudeWriter implements AttitudeEphemerisFileWriter {
* @param template template for metadata
* @param fileFormat file format to use
* @param outputName output name for error messages
* @param unitsColumn columns number for aligning units (if negative or zero, units are not output)
* @since 11.0
*/
public AttitudeWriter(final AemWriter writer,
final Header header, final AemMetadata template,
final FileFormat fileFormat, final String outputName) {
this.writer = writer;
this.header = header;
this.metadata = template.copy();
this.fileFormat = fileFormat;
this.outputName = outputName;
final FileFormat fileFormat, final String outputName,
final int unitsColumn) {
this.writer = writer;
this.header = header;
this.metadata = template.copy();
this.fileFormat = fileFormat;
this.outputName = outputName;
this.unitsColumn = unitsColumn;
}
/** Get current metadata.
......@@ -136,8 +142,8 @@ public class AttitudeWriter implements AttitudeEphemerisFileWriter {
}
try (Generator generator = fileFormat == FileFormat.KVN ?
new KvnGenerator(appendable, AemWriter.KVN_PADDING_WIDTH, outputName) :
new XmlGenerator(appendable, XmlGenerator.DEFAULT_INDENT, outputName)) {
new KvnGenerator(appendable, AemWriter.KVN_PADDING_WIDTH, outputName, unitsColumn) :
new XmlGenerator(appendable, XmlGenerator.DEFAULT_INDENT, outputName, unitsColumn > 0)) {
writer.writeHeader(generator, header);
......
......@@ -58,11 +58,11 @@ class ApmQuaternionWriter extends AbstractWriter {
generator.writeEntry(ApmQuaternionKey.EPOCH.name(), timeConverter, quaternion.getEpoch(), true);
// endpoints
generator.writeEntry(ApmQuaternionKey.Q_FRAME_A.name(), quaternion.getEndpoints().getFrameA().getName(), true);
generator.writeEntry(ApmQuaternionKey.Q_FRAME_B.name(), quaternion.getEndpoints().getFrameB().getName(), true);
generator.writeEntry(ApmQuaternionKey.Q_FRAME_A.name(), quaternion.getEndpoints().getFrameA().getName(), null, true);
generator.writeEntry(ApmQuaternionKey.Q_FRAME_B.name(), quaternion.getEndpoints().getFrameB().getName(), null, true);
generator.writeEntry(ApmQuaternionKey.Q_DIR.name(),
quaternion.getEndpoints().isA2b() ? AttitudeEndoints.A2B : AttitudeEndoints.B2A,
true);
null, true);
// quaternion
final Quaternion q = quaternion.getQuaternion();
......
......@@ -58,21 +58,21 @@ class EulerWriter extends AbstractWriter {
generator.writeComments(euler.getComments());
// endpoints
generator.writeEntry(EulerKey.EULER_FRAME_A.name(), euler.getEndpoints().getFrameA().getName(), true);
generator.writeEntry(EulerKey.EULER_FRAME_B.name(), euler.getEndpoints().getFrameB().getName(), true);
generator.writeEntry(EulerKey.EULER_FRAME_A.name(), euler.getEndpoints().getFrameA().getName(), null, true);
generator.writeEntry(EulerKey.EULER_FRAME_B.name(), euler.getEndpoints().getFrameB().getName(), null, true);
generator.writeEntry(EulerKey.EULER_DIR.name(),
euler.getEndpoints().isA2b() ? AttitudeEndoints.A2B : AttitudeEndoints.B2A,
true);
null, true);
// angles
final String seq = euler.getEulerRotSeq().name();
final double[] angles = euler.getRotationAngles();
generator.writeEntry(EulerKey.EULER_ROT_SEQ.name(),
seq.replace('X', '1').replace('Y', '2').replace('Z', '3'),
true);
null, true);
generator.writeEntry(EulerKey.RATE_FRAME.name(),
euler.rateFrameIsA() ? EulerKey.EULER_FRAME_A.name() : EulerKey.EULER_FRAME_B.name(),
true);
null, true);
// if we don't have rates, at least we need angles
// (we may have only rates, as orientation is already given by mandatory quaternion)
......
......@@ -62,7 +62,7 @@ class ManeuverWriter extends AbstractWriter {
generator.writeEntry(ManeuverKey.MAN_DURATION.name(), maneuver.getDuration(), Unit.SECOND, true);
// frame
generator.writeEntry(ManeuverKey.MAN_REF_FRAME.name(), maneuver.getRefFrameString(), false);
generator.writeEntry(ManeuverKey.MAN_REF_FRAME.name(), maneuver.getRefFrameString(), null, false);
// torque
final Vector3D torque = maneuver.getTorque();
......
......@@ -53,7 +53,7 @@ class SpacecraftParametersWriter extends AbstractWriter {
if (spacecraftParameters.getInertiaReferenceFrame() != null) {
generator.writeEntry(SpacecraftParametersKey.INERTIA_REF_FRAME.name(),
spacecraftParameters.getInertiaReferenceFrame().getName(),
false);
null, false);
}
// inertia matrix
......
......@@ -52,11 +52,11 @@ class SpinStabilizedWriter extends AbstractWriter {
generator.writeComments(spinStabilized.getComments());
// endpoints
generator.writeEntry(SpinStabilizedKey.SPIN_FRAME_A.name(), spinStabilized.getEndpoints().getFrameA().getName(), true);
generator.writeEntry(SpinStabilizedKey.SPIN_FRAME_B.name(), spinStabilized.getEndpoints().getFrameB().getName(), true);
generator.writeEntry(SpinStabilizedKey.SPIN_FRAME_A.name(), spinStabilized.getEndpoints().getFrameA().getName(), null, true);
generator.writeEntry(SpinStabilizedKey.SPIN_FRAME_B.name(), spinStabilized.getEndpoints().getFrameB().getName(), null, true);
generator.writeEntry(SpinStabilizedKey.SPIN_DIR.name(),
spinStabilized.getEndpoints().isA2b() ? AttitudeEndoints.A2B : AttitudeEndoints.B2A,
true);
null, true);
// spin
generator.writeEntry(SpinStabilizedKey.SPIN_ALPHA.name(), spinStabilized.getSpinAlpha(), Unit.DEGREE, true);
......
......@@ -53,28 +53,28 @@ public class CartesianCovarianceWriter extends AbstractWriter {
// covariance block
generator.writeComments(covariance.getComments());
// note that there are no epochs in the OPM/OMM covariance matrices (but there are epochs in OEM covariance matrices)
generator.writeEntry(CartesianCovarianceKey.COV_REF_FRAME.name(), covariance.getReferenceFrame().getName(), false);
generator.writeEntry(CartesianCovarianceKey.CX_X.name(), matrix.getEntry(0, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CY_X.name(), matrix.getEntry(1, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CY_Y.name(), matrix.getEntry(1, 1), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_X.name(), matrix.getEntry(2, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_Y.name(), matrix.getEntry(2, 1), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_Z.name(), matrix.getEntry(2, 2), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X.name(), matrix.getEntry(3, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Y.name(), matrix.getEntry(3, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Z.name(), matrix.getEntry(3, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X_DOT.name(), matrix.getEntry(3, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X.name(), matrix.getEntry(4, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y.name(), matrix.getEntry(4, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Z.name(), matrix.getEntry(4, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X_DOT.name(), matrix.getEntry(4, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y_DOT.name(), matrix.getEntry(4, 4), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X.name(), matrix.getEntry(5, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y.name(), matrix.getEntry(5, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z.name(), matrix.getEntry(5, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X_DOT.name(), matrix.getEntry(5, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y_DOT.name(), matrix.getEntry(5, 4), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z_DOT.name(), matrix.getEntry(5, 5), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.COV_REF_FRAME.name(), covariance.getReferenceFrame().getName(), null, false);
generator.writeEntry(CartesianCovarianceKey.CX_X.name(), matrix.getEntry(0, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CY_X.name(), matrix.getEntry(1, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CY_Y.name(), matrix.getEntry(1, 1), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_X.name(), matrix.getEntry(2, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_Y.name(), matrix.getEntry(2, 1), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_Z.name(), matrix.getEntry(2, 2), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X.name(), matrix.getEntry(3, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Y.name(), matrix.getEntry(3, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Z.name(), matrix.getEntry(3, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X_DOT.name(), matrix.getEntry(3, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X.name(), matrix.getEntry(4, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y.name(), matrix.getEntry(4, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Z.name(), matrix.getEntry(4, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X_DOT.name(), matrix.getEntry(4, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y_DOT.name(), matrix.getEntry(4, 4), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X.name(), matrix.getEntry(5, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y.name(), matrix.getEntry(5, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z.name(), matrix.getEntry(5, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X_DOT.name(), matrix.getEntry(5, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y_DOT.name(), matrix.getEntry(5, 4), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z_DOT.name(), matrix.getEntry(5, 5), Units.KM2_PER_S2, true);
}
......
......@@ -55,12 +55,12 @@ public class CommonMetadataWriter extends AbstractWriter {
generator.writeComments(metadata.getComments());
// object
generator.writeEntry(OdmMetadataKey.OBJECT_NAME.name(), metadata.getObjectName(), true);
generator.writeEntry(CommonMetadataKey.OBJECT_ID.name(), metadata.getObjectID(), true);
generator.writeEntry(OdmMetadataKey.OBJECT_NAME.name(), metadata.getObjectName(), null, true);
generator.writeEntry(CommonMetadataKey.OBJECT_ID.name(), metadata.getObjectID(), null, true);
// frames
generator.writeEntry(CommonMetadataKey.CENTER_NAME.name(), metadata.getCenter().getName(), true);
generator.writeEntry(CommonMetadataKey.REF_FRAME.name(), metadata.getReferenceFrame().getName(), true);
generator.writeEntry(CommonMetadataKey.CENTER_NAME.name(), metadata.getCenter().getName(), null, true);
generator.writeEntry(CommonMetadataKey.REF_FRAME.name(), metadata.getReferenceFrame().getName(), null, true);
generator.writeEntry(CommonMetadataKey.REF_FRAME_EPOCH.name(), timeConverter, metadata.getFrameEpoch(), false);
// time
......
......@@ -22,7 +22,6 @@ import java.util.List;
import org.hipparchus.linear.RealMatrix;
import org.orekit.files.ccsds.definitions.TimeConverter;
import org.orekit.files.ccsds.definitions.Units;
import org.orekit.files.ccsds.section.AbstractWriter;
import org.orekit.files.ccsds.utils.FileFormat;
import org.orekit.files.ccsds.utils.generation.Generator;
......@@ -61,15 +60,15 @@ class CovarianceHistoryWriter extends AbstractWriter {
generator.writeComments(metadata.getComments());
// identifiers
generator.writeEntry(CovarianceHistoryMetadataKey.COV_ID.name(), metadata.getCovID(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_PREV_ID.name(), metadata.getCovPrevID(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_NEXT_ID.name(), metadata.getCovNextID(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_BASIS.name(), metadata.getCovBasis(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_BASIS_ID.name(), metadata.getCovBasisID(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_ID.name(), metadata.getCovID(), null, false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_PREV_ID.name(), metadata.getCovPrevID(), null, false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_NEXT_ID.name(), metadata.getCovNextID(), null, false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_BASIS.name(), metadata.getCovBasis(), null, false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_BASIS_ID.name(), metadata.getCovBasisID(), null, false);
// references
generator.writeEntry(CovarianceHistoryMetadataKey.COV_REF_FRAME.name(), metadata.getCovReferenceFrame().getName(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_FRAME_EPOCH.name(), timeConverter, metadata.getCovFrameEpoch(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_REF_FRAME.name(), metadata.getCovReferenceFrame().getName(), null, false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_FRAME_EPOCH.name(), timeConverter, metadata.getCovFrameEpoch(), false);
// scaling
generator.writeEntry(CovarianceHistoryMetadataKey.COV_SCALE_MIN.name(), metadata.getCovScaleMin(), Unit.ONE, false);
......@@ -77,8 +76,8 @@ class CovarianceHistoryWriter extends AbstractWriter {
generator.writeEntry(CovarianceHistoryMetadataKey.COV_CONFIDENCE.name(), metadata.getCovConfidence(), Unit.PERCENT, false);
// elements
generator.writeEntry(CovarianceHistoryMetadataKey.COV_TYPE.name(), metadata.getCovType(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_UNITS.name(), Units.outputBracketed(metadata.getCovUnits()), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_TYPE.name(), metadata.getCovType(), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_UNITS.name(), generator.unitsListToString(metadata.getCovUnits()), null, false);
// data
final List<Unit> units = metadata.getCovType().getUnits();
......@@ -92,7 +91,7 @@ class CovarianceHistoryWriter extends AbstractWriter {
line.append(AccurateFormatter.format(units.get(i).fromSI(units.get(j).fromSI(matrix.getEntry(i, j)))));
}
if (generator.getFormat() == FileFormat.XML) {
generator.writeEntry(OcmFile.COV_LINE, line.toString(), true);
generator.writeEntry(OcmFile.COV_LINE, line.toString(), null, true);
} else {
generator.writeRawData(line);
generator.newLine();
......
......@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.List;
import org.orekit.files.ccsds.definitions.TimeConverter;
import org.orekit.files.ccsds.definitions.Units;
import org.orekit.files.ccsds.section.AbstractWriter;
import org.orekit.files.ccsds.utils.FileFormat;
import org.orekit.files.ccsds.utils.generation.Generator;
......@@ -60,24 +59,24 @@ class ManeuverHistoryWriter extends AbstractWriter {
generator.writeComments(metadata.getComments());
// identifiers
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_ID.name(), metadata.getManID(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PREV_ID.name(), metadata.getManPrevID(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_NEXT_ID.name(), metadata.getManNextID(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_BASIS.name(), metadata.getManBasis(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_BASIS_ID.name(), metadata.getManBasisID(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_DEVICE_ID.name(), metadata.getManDeviceID(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_ID.name(), metadata.getManID(), null, false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PREV_ID.name(), metadata.getManPrevID(), null, false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_NEXT_ID.name(), metadata.getManNextID(), null, false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_BASIS.name(), metadata.getManBasis(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_BASIS_ID.name(), metadata.getManBasisID(), null, false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_DEVICE_ID.name(), metadata.getManDeviceID(), null, false);
// time
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PREV_EPOCH.name(), timeConverter, metadata.getManPrevEpoch(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_NEXT_EPOCH.name(), timeConverter, metadata.getManNextEpoch(), false);
// references
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PURPOSE.name(), metadata.getManPurpose(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PRED_SOURCE.name(), metadata.getManPredSource(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_REF_FRAME.name(), metadata.getManReferenceFrame().getName(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_FRAME_EPOCH.name(), timeConverter, metadata.getManFrameEpoch(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PURPOSE.name(), metadata.getManPurpose(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PRED_SOURCE.name(), metadata.getManPredSource(), null, false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_REF_FRAME.name(), metadata.getManReferenceFrame().getName(), null, false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_FRAME_EPOCH.name(), timeConverter, metadata.getManFrameEpoch(), false);
if (metadata.getGravitationalAssist() != null) {
generator.writeEntry(ManeuverHistoryMetadataKey.GRAV_ASSIST_NAME.name(), metadata.getGravitationalAssist().getName(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.GRAV_ASSIST_NAME.name(), metadata.getGravitationalAssist().getName(), null, false);
}
// duty cycle
......@@ -98,12 +97,12 @@ class ManeuverHistoryWriter extends AbstractWriter {
value.append(AccurateFormatter.format(Unit.ONE.fromSI(metadata.getDcRefDir().getY())));
value.append(' ');
value.append(AccurateFormatter.format(Unit.ONE.fromSI(metadata.getDcRefDir().getZ())));
generator.writeEntry(ManeuverHistoryMetadataKey.DC_REF_DIR.name(), value.toString(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_REF_DIR.name(), value.toString(), null, false);
}
if (metadata.getDcBodyFrame() != null) {
generator.writeEntry(ManeuverHistoryMetadataKey.DC_BODY_FRAME.name(),
metadata.getDcBodyFrame().toString().replace(' ', '_'),
false);
null, false);
}
generator.writeEntry(ManeuverHistoryMetadataKey.DC_PA_START_ANGLE.name(), metadata.getDcPhaseStartAngle(), Unit.DEGREE, false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_PA_STOP_ANGLE.name(), metadata.getDcPhaseStopAngle(), Unit.DEGREE, false);
......@@ -117,8 +116,8 @@ class ManeuverHistoryWriter extends AbstractWriter {
}
composition.append(types.get(i).name());
}
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_COMPOSITION.name(), composition.toString(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_UNITS.name(), Units.outputBracketed(metadata.getManUnits()), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_COMPOSITION.name(), composition.toString(), null, false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_UNITS.name(), generator.unitsListToString(metadata.getManUnits()), null, false);
// data
for (final Maneuver maneuver : history.getManeuvers()) {
......@@ -130,7 +129,7 @@ class ManeuverHistoryWriter extends AbstractWriter {
line.append(types.get(i).outputField(timeConverter, maneuver));
}
if (generator.getFormat() == FileFormat.XML) {
generator.writeEntry(OcmFile.MAN_LINE, line.toString(), true);
generator.writeEntry(OcmFile.MAN_LINE, line.toString(), null, true);
} else {
generator.writeRawData(line);
generator.newLine();
......
......@@ -58,67 +58,67 @@ class OcmMetadataWriter extends AbstractWriter {
generator.writeComments(metadata.getComments());
generator.writeEntry(OcmMetadataKey.CLASSIFICATION.name(),
metadata.getClassification(), false);
metadata.getClassification(), null, false);
// object
generator.writeEntry(OdmMetadataKey.OBJECT_NAME.name(),
metadata.getObjectName(), false);
metadata.getObjectName(), null, false);
generator.writeEntry(OcmMetadataKey.INTERNATIONAL_DESIGNATOR.name(),
metadata.getInternationalDesignator(), false);
metadata.getInternationalDesignator(), null, false);
generator.writeEntry(OcmMetadataKey.CATALOG_NAME.name(),
metadata.getCatalogName(), false);
metadata.getCatalogName(), null, false);
generator.writeEntry(OcmMetadataKey.OBJECT_DESIGNATOR.name(),
metadata.getObjectDesignator(), false);
metadata.getObjectDesignator(), null, false);
generator.writeEntry(OcmMetadataKey.ALTERNATE_NAMES.name(),
metadata.getAlternateNames(), false);
// originator
generator.writeEntry(OcmMetadataKey.ORIGINATOR_POC.name(),
metadata.getOriginatorPOC(), false);
metadata.getOriginatorPOC(), null, false);
generator.writeEntry(OcmMetadataKey.ORIGINATOR_POSITION.name(),
metadata.getOriginatorPosition(), false);
metadata.getOriginatorPosition(), null, false);
generator.writeEntry(OcmMetadataKey.ORIGINATOR_PHONE.name(),
metadata.getOriginatorPhone(), false);
metadata.getOriginatorPhone(), null, false);
generator.writeEntry(OcmMetadataKey.ORIGINATOR_ADDRESS.name(),
metadata.getOriginatorAddress(), false);
metadata.getOriginatorAddress(), null, false);
// technical
generator.writeEntry(OcmMetadataKey.TECH_ORG.name(),
metadata.getTechOrg(), false);
metadata.getTechOrg(), null, false);
generator.writeEntry(OcmMetadataKey.TECH_POC.name(),
metadata.getTechPOC(), false);
metadata.getTechPOC(), null, false);
generator.writeEntry(OcmMetadataKey.TECH_POSITION.name(),
metadata.getTechPosition(), false);
metadata.getTechPosition(), null, false);
generator.writeEntry(OcmMetadataKey.TECH_PHONE.name(),
metadata.getTechPhone(), false);
metadata.getTechPhone(), null, false);
generator.writeEntry(OcmMetadataKey.TECH_ADDRESS.name(),
metadata.getTechAddress(), false);
metadata.getTechAddress(), null, false);
// messages
generator.writeEntry(OcmMetadataKey.PREVIOUS_MESSAGE_ID.name(),
metadata.getPreviousMessageID(), false);
metadata.getPreviousMessageID(), null, false);
generator.writeEntry(OcmMetadataKey.NEXT_MESSAGE_ID.name(),
metadata.getNextMessageID(), false);