NDM object from strings

Hi Orekit community,

I was wondering if there is a way to create an Ndm object such as Opm or Cdm from a String?
So without reading a file.

Best,
Romain.

Yes, but beware, some Java is involved!
CCSDS parsing is based on an Orekit interface called DataSource, which acts as a proxy to underlying binary streams or character readers and delays opening of the channel until it is really needed. The delaying property is of no use in your case, since you already have the string, but you must anyway provide a way to open a reader on your string. The following should work:

  String message = getTheStringMessage();
  DataSource ds  = new DataSource("some-name-for-my-message",
                                  () -> new StringReader(message));
  Opm opm        = new ParserBuilder().parseMessage(ds);

Dear Luc,

thank you! I see that this involves Java’s lambda expression. I think you can guess my next question :sweat_smile:: how to replicate that with the Python wrapper???

Cheers,
Romain.

Anybody out there to figure this one out?
Or better, could this constructor of DataSource be added to the Java code?

Romain.

Hello,

sorry to bring this back up, but is it acceptable from a design perspective to have the way to initialize DataSource of Luc basically turned into a proper constructor?
This would simplify the life of the Pythoners out there trying to parse NDMs from strings.

Cheers,
Romain.

Perhaps we could add a StringDataSource (or some better name) that would extend the DataSource class.

Hi,

Sorry for a bit late response, but what is needed is that we introduce a new class PythonReaderOpener that represents the ReaderOpener interface and can be subclassed in Python to implement the openOnece() method.

I can add this in coming version of the wrapper.

1 Like