Orbital elements "getters" in (Field)SpacecraftState

Hi all,

since we’re talking about touching to SpacecraftState on another thread, could we actually ditch the methods like getA, getHx, etc. there?
They’re not very safe methods as they return NaN/null if there is no orbit in the object, which was impossilbe when they were originally introduced. I would say it’s up to the user to call getOrbit beforehand.

Cheers,
Romain.

1 Like

I agree with this change. Having a method that return a value or a NaN/null is dangerous.

On the subject of getters, I noticed that detectors like ElevationDetector and ElevationExtremumDetector have getters for the topocentric frame, but the GroundAtNightDetector doesn’t for some reason. A (very) trivial thing, but I did have to subclass it to add that. For consistency, it might be nice to have getters for values that are guaranteed to be non-null.

Thanks for reporting this Tom. A while ago I created this issue, the idea being to reduce code duplication especially on getters for detectors based on topocentric frames (or just geocentric). This would solve your problem so I’ll try fixing it shortly. Of course, if somebody wants to do it instead, just let me know.

Cheers,
Romain

Thank you, Serrof. While I would enjoy helping, I suspect it would cost you more time to explain exactly what you want and how to implement it than to just implement it yourself, and thus I would be more annoying than helpful. :wink:

Hi Tom,

If you want to simply do the hotfix and add this specific missing getter, you can go ahead by creating an issue and opening a merge request :wink:

Cheers,
Romain.