Allowing to update transition dates in TimeSpanMap

TimeSpanMap contains alternating Transition and Span entries.
Span entries can be inserted into the map almost randomly, despite they are often built either chronologically or reverse chronologically. Span entries are inserted by calling addValidBefore, addValidBetween, or addValidAfter, with some dates that will correspond to the transition with the previous or next span.

As of 12.X, these dates are fixed. The map can be populated progressively but once chosen a transition date cannot be changed. In some cases, it would be useful to change the transition dates after the fact. One example is when the transition date is only approximately guessed first and is refined later on during computation.

I would propose to add a resetDate method to the Transition class in order to allow moving it.

Let’s take an example, suppose I have a TimeSpanMap with the following spans and transitions: spanA / 00:00 / spanB / 00:10 / spanC / 00:20 / spanD / 00:30 / spanE. Then refining computation it occurs that the transition between spanC and span D that was initially guessed to occur at 00:20 really happens at 00:20:10. Changing the transition date here is straightforward and does not wreak havoc ; it simply implies that after the update, spanC will still be active at 00:20:05, whereas before the update it would have been spanD that would have been considered active.

Now lets consider another change. Starting from the same map, what should we do if instead of updating the transition from 00:20 to 00:20:10 we want to update it to 00:35? It would then go past the next transition. There are two approaches here. The first approach would be to forbid this and trigger and exception if we see a collision with previous/next transition while moving a transition. The second approach would be to consider users know what they do and if they override a transition, then they may completely wipe out a span (here it would mean deleting spanD and considering that after the update spanC ranges from 00:10 to 00:35 and is followed by spanE). It is of course also possible to set up an API allowing both approaches, which would in fact be in the same spirit as the eraseEarlier boolean in addValidBefore and the eraseLater boolean in addValidAfter. If a collision occurs, then if the erase boolean is true, spans are just deleted and next spans reconnected according to the new transition date, whereas if the erase boolean is false an exception would be triggered.

Of course, moving a transition to infinity should be supported (at least if the erase boolean is true).

My current idea is to allow both approaches and set up the API with such a boolean.

What do Orekit users and developers think about this?

3 Likes

Hi @luc,

Looks like a good feature to add! +1 for this

Cheers,
Maxime

Hi @luc,

This would be a very interesting enhancement to TimeSpanMap which is already a useful object.

+1 !

Cheers,
Vincent

Hi Luc,

Just a suggestion: would it be maybe possible to use polymorphism here? So inherit from the old non resettable TimeSpanMap to implement the resettable one? This way the use of the latter would also be safer, only where it’s needed.

Cheers,
Romain.

It is not possible to use polymorphism. The reason is that the Transition should now be tightly bound to its containing TimeSpanMap because it can invalidate the unique current Span that the map uses to navigate. This happens when we wipe a span that happens to be the current one.

I have implemented the feature, see issue 1561. It mainly consisted in adding one public method to Transition.