Search code examples
iosgoogle-mapsmathgoogle-street-view

Google Street View: Horizontal to Vertical FOV conversion


Consider a Google Street View panorama. How to convert horizontal Field Of View (FOV) to the vertical one and vice versa?

First, I have tried this formula, supposing that projection is spherical:

VFOW = 2 * arctg(h/w * tg(HFOV / 2))

Where h and w - is height and width of panorama image, VFOW and HFOV - is vertical and horizontal FOV. But this formula gives very inaccurate result. As documentation tells, Street View Service Google Street View uses equirectangular projection. I need you help to derive a conversion formula for this case.


Why do I need this? The problem arose while I were creating an iOS application. In this application some static panorama previews are presented to the user. When user click on such a preview, GMSPanoramaView is opened. The problem is to obtain exactly the same preview as the panorama shown by GMSPanoramaView.

Google Street View Image API allows to specify a horizontal FOV. While GMSPanoramaCamera FOV is:

encompassed by the larger dimension (width or height) of the view in degree

My app supports portrait orientation. In this case the larger dimension is height.


Solution

  • The formula in question is all right.