Ok @Gabriel2020 , so a couple of things to keep in mind here .
The java snippet in the thread that you are referring to, as mentioned, performed a very specific task described here, and I stated its limitations along with questions that needed to be answered regarding any additional rules that might be required:
I suspect that within the limitations I stated, it is doing what it was coded to do. If it isn’t working as you needit to, it’s probably because it did not take into account ORIGIN and DESTINY.
But I thought that this all moved on with the following post…
Did this later solution not fully cover the calculations you needed? In that post you will see I said
Generally if I ditch an idea it is because I found it deficient compared with an alternative so I’m not sure we should be trying to start from here again unless we really need to.