Commit 4a08fb39 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Allow empty comments in CCSDS messages.

Fixes #875
parent d5ed2442
......@@ -21,6 +21,9 @@
</properties>
<body>
<release version="11.1" date="TBD" description="TBD">
<action dev="luc" type="fix" issue="875">
Allow empty comments in CCSDS messages
</action>
<action dev="luc" type="fix" issue="884">
Deprecated TimeSpanMap.getTransitions()
</action>
......
......@@ -54,6 +54,9 @@ public class KvnLexicalAnalyzer implements LexicalAnalyzer {
/** Regular expression matching a value that must be stored in the matcher. */
private static final String VALUE = "(\\p{Graph}.*?)";
/** Regular expression matching a value that must be stored in the matcher. */
private static final String OPTIONAL_VALUE = "((?:(\\p{Graph}.*?)?))";
/** Operators allowed in units specifications. */
private static final String UNITS_OPERATORS = "-+*×.·/⁄^√⁺⁻";
......@@ -82,7 +85,7 @@ public class KvnLexicalAnalyzer implements LexicalAnalyzer {
private static final String LINE_END = "\\p{Blank}*$";
/** Regular expression matching comment entry. */
private static final Pattern COMMENT_ENTRY = Pattern.compile(LINE_START + COMMENT_KEY + VALUE + LINE_END);
private static final Pattern COMMENT_ENTRY = Pattern.compile(LINE_START + COMMENT_KEY + OPTIONAL_VALUE + LINE_END);
/** Regular expression matching non-comment entry with optional units. */
private static final Pattern NON_COMMENT_ENTRY = Pattern.compile(LINE_START + NON_COMMENT_KEY + VALUE + UNITS + LINE_END);
......
......@@ -854,4 +854,17 @@ public class OemParserTest {
}
}
@Test
public void testEmptyComments() {
final String name = "/ccsds/odm/oem/ISS.resampled.truncated.txt";
final ParserBuilder builder = new ParserBuilder();
final DataSource source = new DataSource(name, () -> getClass().getResourceAsStream(name));
final Oem iss = builder.buildOemParser().parseMessage(source);
Assert.assertEquals("1998-067-A", iss.getSegments().get(0).getMetadata().getObjectID());
Assert.assertEquals(23, iss.getSegments().get(0).getData().getComments().size());
Assert.assertEquals("", iss.getSegments().get(0).getData().getComments().get(13));
Assert.assertEquals("", iss.getSegments().get(0).getData().getComments().get(20));
Assert.assertEquals(25, iss.getSegments().get(0).getData().getCoordinates().size());
}
}
CCSDS_OEM_VERS = 2.0
CREATION_DATE = 2022-01-17T20:44:45.347
ORIGINATOR = NASA/JSC/FOD/TOPO
META_START
OBJECT_NAME = ISS
OBJECT_ID = 1998-067-A
CENTER_NAME = Earth
REF_FRAME = EME2000
TIME_SYSTEM = UTC
START_TIME = 2022-01-17T12:00:00.000
USEABLE_START_TIME = 2022-01-17T12:00:00.000
USEABLE_STOP_TIME = 2022-01-18T12:00:00.000
STOP_TIME = 2022-01-18T12:00:00.000
META_STOP
COMMENT This file has been resampled and truncated for tests purposes in Orekit
COMMENT Source: This file was produced by the TOPO office within FOD at JSC.
COMMENT Units are in kg and m^2
COMMENT MASS=458943.00
COMMENT DRAG_AREA=1606.80
COMMENT DRAG_COEFF=2.50
COMMENT SOLAR_RAD_AREA=0.00
COMMENT SOLAR_RAD_COEFF=0.00
COMMENT Orbits start at the ascending node epoch
COMMENT ISS first asc. node: EPOCH = 2022-01-17T13:11:16.404 $ ORBIT = 181 $ LAN(DEG) = 47.81106
COMMENT ISS last asc. node : EPOCH = 2022-02-01T10:42:49.854 $ ORBIT = 412 $ LAN(DEG) = -3.51521
COMMENT Begin sequence of events
COMMENT TRAJECTORY EVENT SUMMARY:
COMMENT
COMMENT | EVENT | TIG | ORB | DV | HA | HP |
COMMENT | | GMT | | M/S | KM | KM |
COMMENT | | | | (F/S) | (NM) | (NM) |
COMMENT =============================================================================
COMMENT SpX-24 Undock 021:15:35:00.000 0.0 427.4 408.1
COMMENT (0.0) (230.8) (220.4)
COMMENT
COMMENT =============================================================================
COMMENT End sequence of events
2022-01-17T12:00:00.000 545.284043961596 4217.457419990610 5288.809933277320 -7.63639664838008 0.16882788525720 0.65634287389035
2022-01-17T13:00:00.000 5021.218457183220 -2714.921344536780 -3693.631863364480 5.15002544728106 3.64780592200467 4.33367398742523
2022-01-17T14:00:00.000 -6687.911740675620 -919.471480770419 -833.593052917269 1.36955636521330 -4.64094929643910 -5.93198469521225
2022-01-17T15:00:00.000 3112.313621599960 3811.924367055610 4673.075852367920 -6.81172981805308 2.03437319674741 2.87362525498788
2022-01-17T16:00:00.000 2876.624414021230 -3771.088079051900 -4874.541375528570 6.92758289217986 2.14591535770002 2.43661503667961
2022-01-17T17:00:00.000 -6642.453263094780 781.543865653408 1220.771963450160 -1.63515310417835 -4.66989023994936 -5.84602762381244
2022-01-17T18:00:00.000 5198.989280538920 2786.735691012140 3358.723447956380 -4.93333891337944 3.56784832168335 4.66270730914219
2022-01-17T19:00:00.000 290.570057165196 -4216.209729497030 -5331.043130454920 7.63943652670443 0.30281661574944 0.18271176210509
2022-01-17T20:00:00.000 -5573.707854469110 2353.651813194330 3092.343451556500 -4.39070210770825 -3.94057178845020 -4.88777263023993
2022-01-17T21:00:00.000 6482.401943449860 1309.002259806120 1542.336624612260 -2.29105234619240 4.51999161924214 5.75438799648035
2022-01-17T22:00:00.000 -2341.027226099470 -3980.900500611360 -4997.066584557640 7.18064810838194 -1.58725121319852 -2.09648811323291
2022-01-17T23:00:00.000 -3644.665795888990 3543.358733302990 4502.561720149590 -6.47176337007731 -2.57090158469360 -3.19960787418242
2022-01-18T00:00:00.000 6764.485456286050 -383.049469691541 -506.126861937655 0.70650665463528 4.73511043287717 5.98497457213724
2022-01-18T01:00:00.000 -4614.581235236200 -3101.904691340830 -3922.299182851540 5.62050724868140 -3.22169421747935 -4.06680559844153
2022-01-18T02:00:00.000 -1152.815308889520 4155.982056162540 5240.984267495580 -7.55507642830036 -0.78247602164734 -1.03313614838411
2022-01-18T03:00:00.000 6001.505183412840 -2011.346908261780 -2477.860233792400 3.58847772510627 4.17942264241684 5.32178612199747
2022-01-18T04:00:00.000 -6179.701026973090 -1721.653714372860 -2265.413455321900 3.19530997553647 -4.33668613764266 -5.43586717301053
2022-01-18T05:00:00.000 1514.780022243560 4092.852822325970 5196.726359615670 -7.47265354269590 1.13276988111949 1.28732383879506
2022-01-18T06:00:00.000 4314.284088277270 -3313.478865544660 -4079.879230477040 5.91056276765595 2.94766991018649 3.86779721061625
2022-01-18T07:00:00.000 -6795.331328816080 -62.285182373835 -271.786343890237 0.27436754536881 -4.75102883567583 -5.99789567174186
2022-01-18T08:00:00.000 3948.514053133290 3364.006107290400 4375.973777052640 -6.23733864750581 2.86691862435333 3.41769240488918
2022-01-18T09:00:00.000 1964.423726602290 -4080.145366267300 -5075.658145251100 7.31954580494835 1.24074921417078 1.84297895067527
2022-01-18T10:00:00.000 -6365.115084670640 1608.234014434410 1761.694562763610 -2.69164086063293 -4.39504187448386 -5.66685118257912
2022-01-18T11:00:00.000 5771.805981803020 2086.700156036010 2901.231690139640 -4.03759321330416 4.13726286144467 5.03857909446502
2022-01-18T12:00:00.000 -686.092044989599 -4188.202787453680 -5317.900983066790 7.60432652821943 -0.66585703863869 -0.45178827864052
Markdown is supported
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