Straighten and center a cylindrical panorama on a sphere

I’ve tried for many hours to achieve this :

I would like to make procedural vector transformations to project an image of a central cylindrical panorama onto a sphere…

BUT:

This panorama image may have any orientation (yaw, pitch, roll) and any vertical field of view with truncated angles that may not be the same above and below and the only known value is the horizontal field of view.

The end goal is to have a sphere that you can rotate to straighten the panorama as well as a “vertical center” slider that you can tweak to get the horizon (or equator for a map) in the middle.

I was able to achieve the straightening aspect of it (yaw, pitch, roll) but adding the vertical centering to the table seems to complicate things drastically.

In the end, this setup would for example allow you to straighten this portion of the Earth:

The only thing you know is that this image spans over 360 degrees horizontally. Now you want the result to match the actual Earth.

Here is my blend file with my current progress:
Panorama straightener.zip (4.6 MB)

I tried to make it as easily understandable as possible. I also colored the node groups that concern vertical alignment in yellow. You can slide the Vertical orientation slider on the right and rotate the sphere to see what it currently does.
Then replace the image texture by the other one present in the blend and the goal is to get a straight and undeformed portion of Earth out of this one.

I made an add-on: Panospheres.
It lets you reorient a central cylindrical panorama among many other things. Read the readme there.
Updates and improvements to come.