[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Users] Re. how to deletgate Orbit class??



Jim,

On Thu, 2018-01-25 at 14:13 +0000, Schatzman, James wrote:
Thanks for the suggestions. Yes, Propagator is more convenient to work with than Orbit, because it is an interface. However, the Propagator.propagate methods return SpacecraftState objects. The problem is the SpacecraftState class which uses an Orbit object to do all its work.

So return the biased state. Something like:

Orbit truth = ...;
return new SpacecraftState(bias.apply(truth));

A similar construct would work when implementing a PVCP.

Unfortunately, just writing a new class that implements PVCoordinatesProvider would be insufficient, because of the SpacecraftState issue.

Why? PVCP returns a PVC not a SpacecraftState.

So... I would like to post a request for a future enhancement, that Orbit be converted into an interface.

That would be a significant change to the design of the library. Creating a sublcass of Orbit is specifically prevented because the class is designed to work with only the subclasses that currently exist. Before making extensive changes of this kind it is good to have a well defined use case and show that the existing features of the library do not meet the need. Specifically, why do you need to subclass Orbit? If you can explain this I may be able to suggest other features in Orekit that will better serve your needs.

An Orbit is a set of orbital elements at an instant in time. Your subclass does not fit this definition so under the current design it should not be an Orbit. From what I understand of your use case at this point it seems like a good opportunity to apply Joshua Bloch's "Effective Java" Item #16: Favor composition over inheritance.

I think that I have made it work as is, subclassing Orbit and overriding everything in Orbit with delegation so that the base class is non-functional (except for the constructor).

This is a code smell that usually indicates inheritance was the wrong design choice.

Best Regards,
Evan

Jim


________________________________________
From: orekit-users-request@orekit.org [orekit-users-request@orekit.org] on behalf of Ward, Evan [Evan.Ward@nrl.navy.mil]
Sent: Thursday, January 25, 2018 6:09 AM
To: orekit-users@orekit.org
Subject: Re: [Orekit Users] Re. how to deletgate Orbit class??

Hi Jim,

Welcome to the Orekit mailing lists.

On Wed, 2018-01-24 at 23:02 +0100, schatzman-james@n-ask.com wrote:

There are some errors in the previous code. The methods that return
PVCoordinates need to be to fixed to called the apply() method in BiasModel to
apply the biases, and the methods that take otherFrame/outputFrame make this
slightly harder. Oh well!


It looks like you're only applying the bias in the getPVCoordinates method. Have you considered extending PVCoordinatesProvider instead of Orbit? The Orbit class hierarchy is used to represent different types of orbital elements at a single instant in time, though they can be either osculating or mean elements. From my limited understanding of your problem I think you would be better served implementing a PVCP or extending a Propagator if you need event detection and step handlers. Is there a reason it needs to be an Orbit?

Best Regards,
Evan



So... I can fix that, but I am still concerned about the issues of the
constructor and the protected methods. I could tweak the Orekit source code.
Maybe that would work. I have made some other tweaks but updating my own
version of Orekit as the official version gets updated is a pain.

I am still hoping that there is some way to do this in virgin Orekit. Any
suggestions?

Thanks!

Jim