Commit 9d847e61 authored by GC's avatar GC Committed by Maxime Journot
Browse files

Fix issue-942: 'N/A' value not recognized for field MANEUVERABLE when

parsing CDMs

- Updated mechanism to read and write N/A values as Maneuvrable enum
- Added CDM Parser test for the issue
- Added CDM Writer test for the issue
parent 3241e766
......@@ -67,7 +67,7 @@ public enum CdmMetadataKey {
COVARIANCE_METHOD((token, context, container) -> token.processAsEnum(CovarianceMethod.class, container::setCovarianceMethod)),
/** Manoeuver capacity. */
MANEUVERABLE((token, context, container) -> token.processAsEnum(Maneuvrable.class, container::setManeuverable)),
MANEUVERABLE((token, context, container) -> token.processAsManeuvrableEnum(container::setManeuverable)),
/** Central body for Object 1 and 2. */
ORBIT_CENTER((token, context, container) -> token.processAsCenter(container::setOrbitCenter,
......
......@@ -86,7 +86,7 @@ public class CdmMetadataWriter extends AbstractWriter {
generator.writeEntry(CdmMetadataKey.COVARIANCE_METHOD.name(),
metadata.getCovarianceMethod(), true);
generator.writeEntry(CdmMetadataKey.MANEUVERABLE.name(),
metadata.getManeuverable(), true);
metadata.getManeuverable().getValue(), null, true);
if (metadata.getOrbitCenter() != null) {
generator.writeEntry(CdmMetadataKey.ORBIT_CENTER.name(),
metadata.getOrbitCenter().getName(), null, false);
......
......@@ -23,12 +23,37 @@ package org.orekit.files.ccsds.ndm.cdm;
public enum Maneuvrable {
/** Maneuvrable. */
YES,
YES("YES"),
/** Non Maneuvrable. */
NO,
NO("NO"),
/** Don't know or not applicable. */
NOT_APPLICABLE;
N_A("N/A");
/** Value of the enum .*/
private String value;
Maneuvrable(final String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return this.getValue();
}
public static Maneuvrable getEnum(final String keyValue) {
for (Maneuvrable v : values()) {
if (v.getValue().equalsIgnoreCase(keyValue)) {
return v;
}
}
throw new IllegalArgumentException();
}
}
......@@ -37,6 +37,7 @@ import org.orekit.files.ccsds.definitions.OrbitRelativeFrame;
import org.orekit.files.ccsds.definitions.SpacecraftBodyFrame;
import org.orekit.files.ccsds.definitions.TimeSystem;
import org.orekit.files.ccsds.ndm.ParsedUnitsBehavior;
import org.orekit.files.ccsds.ndm.cdm.Maneuvrable;
import org.orekit.files.ccsds.utils.ContextBinding;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.units.Unit;
......@@ -602,6 +603,17 @@ public class ParseToken {
return true;
}
/** Process the content of the Maneuvrable enum.
* @param consumer consumer of the enum
* @return always returns {@code true}
*/
public boolean processAsManeuvrableEnum(final ManeuvrableConsumer consumer) {
if (type == TokenType.ENTRY) {
consumer.accept(Maneuvrable.getEnum(getRawContent()));
}
return true;
}
/** Generate a parse exception for this entry.
* @param cause underlying cause exception (may be null)
* @return exception for this entry
......@@ -830,4 +842,11 @@ public class ParseToken {
void accept(List<Unit> value);
}
/** Interface representing instance methods that consume Maneuvrable values. */
public interface ManeuvrableConsumer {
/** Consume a Maneuvrable.
* @param value value to consume
*/
void accept(Maneuvrable value);
}
}
......@@ -1035,4 +1035,44 @@ public class CdmParserTest {
}
}
@Test
public void test_issue_942_KVN() {
// File
final String ex = "/ccsds/cdm/CDMExample_issue942.txt";
// Initialize the parser
final CdmParser parser = new ParserBuilder().buildCdmParser();
final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
// Generated CDM file
final Cdm file = parser.parseMessage(source);
// OBJECT1
Assert.assertEquals(Maneuvrable.N_A, file.getMetadataObject1().getManeuverable());
// OBJECT2
Assert.assertEquals(Maneuvrable.NO, file.getMetadataObject2().getManeuverable());
}
@Test
public void test_issue_942_XML() {
// File
final String ex = "/ccsds/cdm/CDMExample_issue942.xml";
// Initialize the parser
final CdmParser parser = new ParserBuilder().buildCdmParser();
final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
// Generated CDM file
final Cdm file = parser.parseMessage(source);
// OBJECT1
Assert.assertEquals(Maneuvrable.N_A, file.getMetadataObject1().getManeuverable());
// OBJECT2
Assert.assertEquals(Maneuvrable.NO, file.getMetadataObject2().getManeuverable());
}
}
......@@ -58,6 +58,16 @@ public class CdmWriterTest extends AbstractWriterTest<CdmHeader, CdmSegment, Cdm
public void testWriteExample4() {
doTest("/ccsds/cdm/CDMExample4.txt");
}
@Test
public void testWrite_issue_942_KVN() {
doTest("/ccsds/cdm/CDMExample_issue942.txt");
}
@Test
public void testWrite_issue_942_XML() {
doTest("/ccsds/cdm/CDMExample_issue942.xml");
}
}
CCSDS_CDM_VERS = 1.0
CREATION_DATE = 2010-03-12T22:31:12.000
ORIGINATOR = JSPOC
MESSAGE_ID = 201113719185
TCA = 2010-03-13T22:37:52.618
MISS_DISTANCE = 715 [m]
OBJECT = OBJECT1
OBJECT_DESIGNATOR = 12345
CATALOG_NAME = SATCAT
OBJECT_NAME = SATELLITE A
INTERNATIONAL_DESIGNATOR = 1997−030E
EPHEMERIS_NAME = EPHEMERIS SATELLITE A
COVARIANCE_METHOD = CALCULATED
MANEUVERABLE = N/A
REF_FRAME = EME2000
X = 2570.097065 [km]
Y = 2244.654904 [km]
Z = 6281.497978 [km]
X_DOT = 4.418769571 [km/s]
Y_DOT = 4.833547743 [km/s]
Z_DOT = -3.526774282 [km/s]
CR_R = 4.142E+01 [m**2]
CT_R = -8.579E+00 [m**2]
CT_T = 2.533E+03 [m**2]
CN_R = -2.313E+01 [m**2]
CN_T = 1.336E+01 [m**2]
CN_N = 7.098E+01 [m**2]
CRDOT_R = 2.520E-03 [m**2/s]
CRDOT_T = -5.476E+00 [m**2/s]
CRDOT_N = 8.626E-04 [m**2/s]
CRDOT_RDOT = 5.744E-03 [m**2/s**2]
CTDOT_R = -1.006E-02 [m**2/s]
CTDOT_T = 4.041E-03 [m**2/s]
CTDOT_N = -1.359E-03 [m**2/s]
CTDOT_RDOT = -1.502E-05 [m**2/s**2]
CTDOT_TDOT = 1.049E-05 [m**2/s**2]
CNDOT_R = 1.053E-03 [m**2/s]
CNDOT_T = -3.412E-03 [m**2/s]
CNDOT_N = 1.213E-02 [m**2/s]
CNDOT_RDOT = -3.004E-06 [m**2/s**2]
CNDOT_TDOT = -1.091E-06 [m**2/s**2]
CNDOT_NDOT = 5.529E-05 [m**2/s**2]
OBJECT = OBJECT2
OBJECT_DESIGNATOR = 30337
CATALOG_NAME = SATCAT
OBJECT_NAME = FENGYUN 1C DEB
INTERNATIONAL_DESIGNATOR = 1999-025AA
EPHEMERIS_NAME = NONE
COVARIANCE_METHOD = CALCULATED
MANEUVERABLE = NO
REF_FRAME = EME2000
X = 2569.540800 [km]
Y = 2245.093614 [km]
Z = 6281.599946 [km]
X_DOT = -2.888612500 [km/s]
Y_DOT = -6.007247516 [km/s]
Z_DOT = 3.328770172 [km/s]
CR_R = 1.337E+03 [m**2]
CT_R = -4.806E+04 [m**2]
CT_T = 2.492E+06 [m**2]
CN_R = -3.298E+01 [m**2]
CN_T = -7.5888E+02 [m**2]
CN_N = 7.105E+01 [m**2]
CRDOT_R = 2.591E-03 [m**2/s]
CRDOT_T = -4.152E-02 [m**2/s]
CRDOT_N = -1.784E-06 [m**2/s]
CRDOT_RDOT = 6.886E-05 [m**2/s**2]
CTDOT_R = -1.016E-02 [m**2/s]
CTDOT_T = -1.506E-04 [m**2/s]
CTDOT_N = 1.637E-03 [m**2/s]
CTDOT_RDOT = -2.987E-06 [m**2/s**2]
CTDOT_TDOT = 1.059E-05 [m**2/s**2]
CNDOT_R = 4.400E-03 [m**2/s]
CNDOT_T = 8.482E-03 [m**2/s]
CNDOT_N = 8.633E-05 [m**2/s]
CNDOT_RDOT = -1.903E-06 [m**2/s**2]
CNDOT_TDOT = -4.594E-06 [m**2/s**2]
CNDOT_NDOT = 5.178E-05 [m**2/s**2]
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<cdm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://sanaregistry.org/r/ndmxml/ndmxml-1.0-master.xsd"
id="CCSDS_CDM_VERS" version="1.0">
<header>
<COMMENT>Sample CDM - XML version</COMMENT>
<CREATION_DATE>2010-03-12T22:31:12.000</CREATION_DATE>
<ORIGINATOR>JSPOC</ORIGINATOR>
<MESSAGE_FOR>SATELLITE A</MESSAGE_FOR>
<MESSAGE_ID>20111371985</MESSAGE_ID>
</header>
<body>
<relativeMetadataData>
<COMMENT>Relative Metadata/Data</COMMENT>
<TCA>2010-03-13T22:37:52.618</TCA>
<MISS_DISTANCE units="m">715</MISS_DISTANCE>
<RELATIVE_SPEED units="m/s">14762</RELATIVE_SPEED>
<relativeStateVector>
<RELATIVE_POSITION_R units="m">27.4</RELATIVE_POSITION_R>
<RELATIVE_POSITION_T units="m">-70.2</RELATIVE_POSITION_T>
<RELATIVE_POSITION_N units="m">711.8</RELATIVE_POSITION_N>
<RELATIVE_VELOCITY_R units="m/s">-7.2</RELATIVE_VELOCITY_R>
<RELATIVE_VELOCITY_T units="m/s">-14692.0</RELATIVE_VELOCITY_T>
<RELATIVE_VELOCITY_N units="m/s">-1437.2</RELATIVE_VELOCITY_N>
</relativeStateVector>
<START_SCREEN_PERIOD>2010-03-12T18:29:32.212</START_SCREEN_PERIOD>
<STOP_SCREEN_PERIOD>2010-03-15T18:29:32.212</STOP_SCREEN_PERIOD>
<SCREEN_VOLUME_FRAME>RTN</SCREEN_VOLUME_FRAME>
<SCREEN_VOLUME_SHAPE>ELLIPSOID</SCREEN_VOLUME_SHAPE>
<SCREEN_VOLUME_X units="m">200</SCREEN_VOLUME_X>
<SCREEN_VOLUME_Y units="m">1000</SCREEN_VOLUME_Y>
<SCREEN_VOLUME_Z units="m">1000</SCREEN_VOLUME_Z>
<SCREEN_ENTRY_TIME>2010-03-13T20:25:43.222</SCREEN_ENTRY_TIME>
<SCREEN_EXIT_TIME>2010-03-13T23:44:29.324</SCREEN_EXIT_TIME>
<COLLISION_PROBABILITY>4.835E-05</COLLISION_PROBABILITY>
<COLLISION_PROBABILITY_METHOD>FOSTER-1992</COLLISION_PROBABILITY_METHOD>
</relativeMetadataData>
<segment>
<metadata>
<COMMENT>Object1 Metadata</COMMENT>
<OBJECT>OBJECT1</OBJECT>
<OBJECT_DESIGNATOR>12345</OBJECT_DESIGNATOR>
<CATALOG_NAME>SATCAT</CATALOG_NAME>
<OBJECT_NAME>SATELLITE A</OBJECT_NAME>
<INTERNATIONAL_DESIGNATOR>1997-030E</INTERNATIONAL_DESIGNATOR>
<OBJECT_TYPE>PAYLOAD</OBJECT_TYPE>
<OPERATOR_CONTACT_POSITION>OSA</OPERATOR_CONTACT_POSITION>
<OPERATOR_ORGANIZATION>EUMETSAT</OPERATOR_ORGANIZATION>
<OPERATOR_PHONE>+49615130312</OPERATOR_PHONE>
<OPERATOR_EMAIL>JOHN.DOE@SOMEWHERE>NET</OPERATOR_EMAIL>
<EPHEMERIS_NAME>EPHEMERIS SATELLITE A</EPHEMERIS_NAME>
<COVARIANCE_METHOD>CALCULATED</COVARIANCE_METHOD>
<MANEUVERABLE>N/A</MANEUVERABLE>
<REF_FRAME>EME2000</REF_FRAME>
<GRAVITY_MODEL>EGM-96: 36D 36O</GRAVITY_MODEL>
<ATMOSPHERIC_MODEL>JACCHIA 70 DCA</ATMOSPHERIC_MODEL>
<N_BODY_PERTURBATIONS>MOON,SUN</N_BODY_PERTURBATIONS>
<SOLAR_RAD_PRESSURE>NO</SOLAR_RAD_PRESSURE>
<EARTH_TIDES>NO</EARTH_TIDES>
<INTRACK_THRUST>NO</INTRACK_THRUST>
</metadata>
<data>
<COMMENT>Object1 Data</COMMENT>
<odParameters>
<COMMENT>Object1 OD Parameters</COMMENT>
<TIME_LASTOB_START>2010-03-12T02:14:12.746</TIME_LASTOB_START>
<TIME_LASTOB_END>2010-03-12T02:14:12.746</TIME_LASTOB_END>
<RECOMMENDED_OD_SPAN units="d">7.88</RECOMMENDED_OD_SPAN>
<ACTUAL_OD_SPAN units="d">5.50</ACTUAL_OD_SPAN>
<OBS_AVAILABLE>592</OBS_AVAILABLE>
<OBS_USED>59</OBS_USED>
<TRACKS_AVAILABLE>123</TRACKS_AVAILABLE>
<TRACKS_USED>119</TRACKS_USED>
<RESIDUALS_ACCEPTED units="%" >97.8</RESIDUALS_ACCEPTED>
<WEIGHTED_RMS>0.864</WEIGHTED_RMS>
</odParameters>
<additionalParameters>
<COMMENT>Object 1 Additional Parameters</COMMENT>
<AREA_PC units="m**2">5.2</AREA_PC>
<MASS units="kg">2516</MASS>
<CD_AREA_OVER_MASS units="m**2/kg">0.045663</CD_AREA_OVER_MASS>
<CR_AREA_OVER_MASS units="m**2/kg">0.000000</CR_AREA_OVER_MASS>
<THRUST_ACCELERATION units="m/s**2">0.0</THRUST_ACCELERATION>
<SEDR units="W/kg">4.54570E-05</SEDR>
</additionalParameters>
<stateVector>
<COMMENT>Object1 State Vector</COMMENT>
<X units="km">2570.097065</X>
<Y units="km">2244.654904</Y>
<Z units="km">6281.497978</Z>
<X_DOT units="km/s">4.418769571</X_DOT>
<Y_DOT units="km/s">4.833547743</Y_DOT>
<Z_DOT units="km/s">-3.526774282</Z_DOT>
</stateVector>
<covarianceMatrix>
<COMMENT>Object1 Covariance in the RTN Coordinate Frame </COMMENT>
<CR_R units="m**2">4.142E+01</CR_R>
<CT_R units="m**2">-8.579E+00</CT_R>
<CT_T units="m**2">2.533E+03</CT_T>
<CN_R units="m**2">-2.313E+01</CN_R>
<CN_T units="m**2">1.336E+01</CN_T>
<CN_N units="m**2">7.098E+01</CN_N>
<CRDOT_R units="m**2/s">2.520E-03</CRDOT_R>
<CRDOT_T units="m**2/s">-5.476E+00</CRDOT_T>
<CRDOT_N units="m**2/s">8.626E-04</CRDOT_N>
<CRDOT_RDOT units="m**2/s**2">5.744E-03</CRDOT_RDOT>
<CTDOT_R units="m**2/s">-1.006E-02</CTDOT_R>
<CTDOT_T units="m**2/s">4.041E-03</CTDOT_T>
<CTDOT_N units="m**2/s">-1.359E-03</CTDOT_N>
<CTDOT_RDOT units="m**2/s**2">-1.502E-05</CTDOT_RDOT>
<CTDOT_TDOT units="m**2/s**2">1.049E-05</CTDOT_TDOT>
<CNDOT_R units="m**2/s">1.053E-03</CNDOT_R>
<CNDOT_T units="m**2/s">-3.412E-03</CNDOT_T>
<CNDOT_N units="m**2/s">1.213E-02</CNDOT_N>
<CNDOT_RDOT units="m**2/s**2">-3.004E-06</CNDOT_RDOT>
<CNDOT_TDOT units="m**2/s**2">-1.091E-06</CNDOT_TDOT>
<CNDOT_NDOT units="m**2/s**2">5.529E-05</CNDOT_NDOT>
</covarianceMatrix>
</data>
</segment>
<segment>
<metadata>
<COMMENT>Object2 Metadata</COMMENT>
<OBJECT>OBJECT2</OBJECT>
<OBJECT_DESIGNATOR>30337</OBJECT_DESIGNATOR>
<CATALOG_NAME>SATCAT</CATALOG_NAME>
<OBJECT_NAME>FENGYUN 1C DEB</OBJECT_NAME>
<INTERNATIONAL_DESIGNATOR>1999-025AA</INTERNATIONAL_DESIGNATOR>
<OBJECT_TYPE>DEBRIS</OBJECT_TYPE>
<EPHEMERIS_NAME>NONE</EPHEMERIS_NAME>
<COVARIANCE_METHOD>CALCULATED</COVARIANCE_METHOD>
<MANEUVERABLE>NO</MANEUVERABLE>
<REF_FRAME>EME2000</REF_FRAME>
<GRAVITY_MODEL>EGM-96: 36D 36O</GRAVITY_MODEL>
<ATMOSPHERIC_MODEL>JACCHIA 70 DCA</ATMOSPHERIC_MODEL>
<N_BODY_PERTURBATIONS>MOON,SUN</N_BODY_PERTURBATIONS>
<SOLAR_RAD_PRESSURE>YES</SOLAR_RAD_PRESSURE>
<EARTH_TIDES>NO</EARTH_TIDES>
<INTRACK_THRUST>NO</INTRACK_THRUST>
</metadata>
<data>
<COMMENT>Object2 Data</COMMENT>
<odParameters>
<COMMENT>Object2 OD Parameters</COMMENT>
<TIME_LASTOB_START>2010-03-12T01:14:12.746</TIME_LASTOB_START>
<TIME_LASTOB_END>2010-03-12T03:14:12.746</TIME_LASTOB_END>
<RECOMMENDED_OD_SPAN units="d">2.63</RECOMMENDED_OD_SPAN>
<ACTUAL_OD_SPAN units="d">2.63</ACTUAL_OD_SPAN>
<OBS_AVAILABLE>59</OBS_AVAILABLE>
<OBS_USED>58</OBS_USED>
<TRACKS_AVAILABLE>15</TRACKS_AVAILABLE>
<TRACKS_USED>15</TRACKS_USED>
<RESIDUALS_ACCEPTED units="%" >97.8</RESIDUALS_ACCEPTED>
<WEIGHTED_RMS>0.864</WEIGHTED_RMS>
</odParameters>
<additionalParameters>
<COMMENT>Object2 Additional Parameters</COMMENT>
<COMMENT>Apogee Altitude=768 km</COMMENT>
<COMMENT>Perigee Altitude=414 km</COMMENT>
<COMMENT>Inclination=98.8 deg</COMMENT>
<AREA_PC units="m**2">0.9</AREA_PC>
<CD_AREA_OVER_MASS units="m**2/kg">0.118668</CD_AREA_OVER_MASS>
<CR_AREA_OVER_MASS units="m**2/kg">0.075204</CR_AREA_OVER_MASS>
<THRUST_ACCELERATION units="m/s**2">0.0</THRUST_ACCELERATION>
<SEDR units="W/kg">5.40900E-03</SEDR>
</additionalParameters>
<stateVector>
<COMMENT>Object2 State Vector</COMMENT>
<X units="km">2569.540800</X>
<Y units="km">2245.093614</Y>
<Z units="km">6281.599946</Z>
<X_DOT units="km/s">-2.888612500</X_DOT>
<Y_DOT units="km/s">-6.007247516</Y_DOT>
<Z_DOT units="km/s">3.328770172</Z_DOT>
</stateVector>
<covarianceMatrix>
<COMMENT>Object2 Covariance in the RTN Coordinate Frame</COMMENT>
<CR_R units="m**2">1.337E+03</CR_R>
<CT_R units="m**2">-4.806E+04</CT_R>
<CT_T units="m**2">2.492E+06</CT_T>
<CN_R units="m**2">-3.298E+01</CN_R>
<CN_T units="m**2">-7.5888E+02</CN_T>
<CN_N units="m**2">7.105E+01</CN_N>
<CRDOT_R units="m**2/s">2.591E-03</CRDOT_R>
<CRDOT_T units="m**2/s">-4.152E-02</CRDOT_T>
<CRDOT_N units="m**2/s">-1.784E-06</CRDOT_N>
<CRDOT_RDOT units="m**2/s**2">6.886E-05</CRDOT_RDOT>
<CTDOT_R units="m**2/s">-1.016E-02</CTDOT_R>
<CTDOT_T units="m**2/s">-1.506E-04</CTDOT_T>
<CTDOT_N units="m**2/s">1.637E-03</CTDOT_N>
<CTDOT_RDOT units="m**2/s**2">-2.987E-06</CTDOT_RDOT>
<CTDOT_TDOT units="m**2/s**2">1.059E-05</CTDOT_TDOT>
<CNDOT_R units="m**2/s">4.400E-03</CNDOT_R>
<CNDOT_T units="m**2/s">8.482E-03</CNDOT_T>
<CNDOT_N units="m**2/s">8.633E-05</CNDOT_N>
<CNDOT_RDOT units="m**2/s**2">-1.903E-06</CNDOT_RDOT>
<CNDOT_TDOT units="m**2/s**2">-4.594E-06</CNDOT_TDOT>
<CNDOT_NDOT units="m**2/s**2">5.178E-05</CNDOT_NDOT>
</covarianceMatrix>
</data>
</segment>
</body>
</cdm>
\ No newline at end of file
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