Commit c4176cf7 authored by Pascal Parraud's avatar Pascal Parraud
Browse files

Fixed unmanaged units in OMM

parent 24a4446f
......@@ -20,6 +20,11 @@
<title>Orekit Changes</title>
</properties>
<body>
<release version="11.2" date="TBD" description="TBD">
<action dev="pascal" type="fix" issue="906">
Fixed unmanaged units in OMM.
</action>
</release>
<release version="11.1.1" date="2022-03-17"
description="Version 11.1.1 is a patch release of Orekit.
It fixes issues related to the parsing of SP3 and Rinex files. It also takes
......
......@@ -79,6 +79,9 @@ public class Units {
/** Hertz per second unit. */
public static final Unit HZ_PER_S = Unit.parse("Hz/s");
/** Earth radii reciprocal unit. */
public static final Unit ONE_PER_ER = Unit.parse("1/ER");
/** Private constructor for a utility class.
*/
private Units() {
......
......@@ -19,7 +19,6 @@ package org.orekit.files.ccsds.ndm.odm.omm;
import org.orekit.files.ccsds.definitions.Units;
import org.orekit.files.ccsds.utils.ContextBinding;
import org.orekit.files.ccsds.utils.lexical.ParseToken;
import org.orekit.utils.units.Unit;
/** Keys for {@link OmmTle TLE} entries.
......@@ -44,7 +43,7 @@ public enum OmmTleKey {
REV_AT_EPOCH((token, context, container) -> token.processAsInteger(container::setRevAtEpoch)),
/** SGP/SGP4 drag-like coefficient. */
BSTAR((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
BSTAR((token, context, container) -> token.processAsDouble(Units.ONE_PER_ER, context.getParsedUnitsBehavior(),
container::setBStar)),
/** First time derivative of mean motion. */
......
......@@ -41,6 +41,7 @@ class PrefixedUnit extends Unit {
Unit.MINUTE,
Unit.HOUR,
Unit.DAY,
Unit.DAY.alias("day"),
Unit.YEAR,
Unit.YEAR.alias("yr"),
Unit.HERTZ,
......@@ -71,7 +72,8 @@ class PrefixedUnit extends Unit {
Unit.SOLAR_FLUX_UNIT.alias("SFU"),
Unit.SOLAR_FLUX_UNIT.alias("sfu"),
Unit.TOTAL_ELECTRON_CONTENT_UNIT,
Unit.TOTAL_ELECTRON_CONTENT_UNIT.alias("tecu"));
Unit.TOTAL_ELECTRON_CONTENT_UNIT.alias("tecu"),
Unit.EARTH_RADII);
ALLOWED = new HashMap<>(base.size() * Prefix.values().length);
for (final Unit unit : base) {
ALLOWED.put(unit.getName(), new PrefixedUnit(null, unit));
......
......@@ -133,6 +133,9 @@ public class Unit implements Serializable {
/** Total Electron Content Unit. */
public static final Unit TOTAL_ELECTRON_CONTENT_UNIT = METRE.power(null, new Fraction(-2)).scale("TECU", 1.0e+16);
/** Earth Radii used as Bstar unit in CCSDS OMM. */
public static final Unit EARTH_RADII = new Unit("ER", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO);
/** Serializable UID. */
private static final long serialVersionUID = 20210402L;
......
......@@ -153,6 +153,15 @@ public class OmmParserTest {
validateOMM2(parser.parseMessage(source));
}
@Test
public void testIssue906() throws URISyntaxException {
String name = "/ccsds/odm/omm/OMM-with-units.xml";
final DataSource source = new DataSource(name, () -> getClass().getResourceAsStream(name));
final OmmParser parser = new ParserBuilder().withMu(Constants.EIGEN5C_EARTH_MU).buildOmmParser();
validateOMM2(parser.parseMessage(source));
}
@Test
public void testWriteOMM3() throws URISyntaxException, IOException {
final String name = "/ccsds/odm/omm/OMMExample2.xml";
......
<?xml version="1.0" encoding="UTF-8"?>
<omm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://sanaregistry.org/r/ndmxml/ndmxml-1.0-master.xsd"
id="CCSDS_OMM_VERS" version="3.0">
<header>
<COMMENT> THIS IS AN XML VERSION OF THE OMM </COMMENT>
<CREATION_DATE>2007-065T16:00:00</CREATION_DATE>
<ORIGINATOR>NOAA</ORIGINATOR>
<MESSAGE_ID> OMM 201113719185</MESSAGE_ID>
</header>
<body>
<segment>
<metadata>
<OBJECT_NAME>GOES-9</OBJECT_NAME>
<OBJECT_ID>1995-025A</OBJECT_ID>
<CENTER_NAME>EARTH</CENTER_NAME>
<REF_FRAME>TEME</REF_FRAME>
<TIME_SYSTEM>UTC</TIME_SYSTEM>
<MEAN_ELEMENT_THEORY>SGP/SGP4</MEAN_ELEMENT_THEORY>
</metadata>
<data>
<meanElements>
<EPOCH>2007-064T10:34:41.4264</EPOCH>
<MEAN_MOTION units="rev/day">1.00273272</MEAN_MOTION>
<ECCENTRICITY>0.0005013</ECCENTRICITY>
<INCLINATION units="deg">3.0539</INCLINATION>
<RA_OF_ASC_NODE units="deg">81.7939</RA_OF_ASC_NODE>
<ARG_OF_PERICENTER units="deg">249.2363</ARG_OF_PERICENTER>
<MEAN_ANOMALY units="deg">150.1602</MEAN_ANOMALY>
<GM>398600.8</GM>
</meanElements>
<tleParameters>
<NORAD_CAT_ID>23581</NORAD_CAT_ID>
<ELEMENT_SET_NO>0925</ELEMENT_SET_NO>
<REV_AT_EPOCH>4316</REV_AT_EPOCH>
<BSTAR units="1/ER">0.0001</BSTAR>
<MEAN_MOTION_DOT units="rev/day**2">-0.00000113</MEAN_MOTION_DOT>
<MEAN_MOTION_DDOT units="rev/day**3">0.0</MEAN_MOTION_DDOT>
</tleParameters>
<covarianceMatrix>
<COV_REF_FRAME>TEME</COV_REF_FRAME>
<CX_X>3.331349476038534e-04</CX_X>
<CY_X>4.618927349220216e-04</CY_X>
<CY_Y>6.782421679971363e-04</CY_Y>
<CZ_X>-3.070007847730449e-04</CZ_X>
<CZ_Y>-4.221234189514228e-04</CZ_Y>
<CZ_Z>3.231931992380369e-04</CZ_Z>
<CX_DOT_X>-3.349365033922630e-07</CX_DOT_X>
<CX_DOT_Y>-4.686084221046758e-07</CX_DOT_Y>
<CX_DOT_Z>2.484949578400095e-07</CX_DOT_Z>
<CX_DOT_X_DOT>4.296022805587290e-10</CX_DOT_X_DOT>
<CY_DOT_X>-2.211832501084875e-07</CY_DOT_X>
<CY_DOT_Y>-2.864186892102733e-07</CY_DOT_Y>
<CY_DOT_Z>1.798098699846038e-07</CY_DOT_Z>
<CY_DOT_X_DOT>2.608899201686016e-10</CY_DOT_X_DOT>
<CY_DOT_Y_DOT>1.767514756338532e-10</CY_DOT_Y_DOT>
<CZ_DOT_X>-3.041346050686871e-07</CZ_DOT_X>
<CZ_DOT_Y>-4.989496988610662e-07</CZ_DOT_Y>
<CZ_DOT_Z>3.540310904497689e-07</CZ_DOT_Z>
<CZ_DOT_X_DOT>1.869263192954590e-10</CZ_DOT_X_DOT>
<CZ_DOT_Y_DOT>1.008862586240695e-10</CZ_DOT_Y_DOT>
<CZ_DOT_Z_DOT>6.224444338635500e-10</CZ_DOT_Z_DOT>
</covarianceMatrix>
</data>
</segment>
</body>
</omm>
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