Closed ChemicalNRG closed 7 months ago
trying to get lookaround working. But it is difficult, because an example is only showed in the lookaround repo, which also uses different variable names I believe?
Yes, the lookaround repo is slightly different. You can find the documentation for the Look Around module of streetlevel here: https://streetlevel.readthedocs.io/en/stable/streetlevel.lookaround.html
I'll add some sample code for these functions in a few days or so.
51.50056270050847, 3.885667340737007 as an example will give errors, so maybe 8 digits are the max or something?
I tried the coordinates, and they work fine for me:
In [1]: from streetlevel import lookaround
In [2]: panos = lookaround.get_coverage_tile_by_latlon(51.50056270050847, 3.885667340737007)
In [3]: print(panos[0].id, panos[0].lat, panos[0].lon)
11129494710789177858 51.50188556473774 3.8849992191090337
What is the error message you're getting?
No I used the "Downloading imagery" example of the lookaround repo.
from lookaround import get_coverage_tile_by_latlon, get_pano_face
from lookaround.auth import Authenticator
panos = get_coverage_tile_by_latlon(46.52943, 10.45544)
auth = Authenticator()
zoom = 2
for face in range(0, 6):
image = get_pano_face(panos[0].panoid, panos[0].build_id, face, zoom, auth)
with open(f"{panos[0].panoid}_{face}_{zoom}.heic", "wb") as f:
f.write(image)
I have allready found some errors:
get_pano_face >> get_panorama_face
panoid >> id (also in lookaround.py lines 85, 139, 141, 143 ?)
but I still get this error:
image = get_panorama_face(panos[0].id, panos[0].build_id, face, zoom, auth)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\_PDOK\MapServerZeeland\Repos\streetlevel\streetlevel\lookaround\lookaround.py", line 85, in get_panorama_face
panoid, build_id = _panoid_to_string(pano)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\_PDOK\MapServerZeeland\Repos\streetlevel\streetlevel\lookaround\lookaround.py", line 141, in _panoid_to_string
panoid, build_id = str(pano[0]), str(pano[1])
~~~~^^^
TypeError: 'int' object is not subscriptable
No I used the "Downloading imagery" example of the lookaround repo.
Well there's your problem - you can't just take code for module A and expect it to work for module B. The equivalent code for streetlevel looks like this:
from streetlevel.lookaround import get_coverage_tile_by_latlon, get_panorama_face
from streetlevel.lookaround.auth import Authenticator
panos = get_coverage_tile_by_latlon(46.52943, 10.45544)
auth = Authenticator()
zoom = 2
for face in range(0, 6):
image = get_panorama_face(panos[0], face, zoom, auth)
with open(f"{panos[0].id}_{face}_{zoom}.heic", "wb") as f:
f.write(image)
This will download the first panorama on the tile containing that point. (Note that the list returned by get_coverage_tile_by_latlon
is not sorted by distance to the given point - it's simply in the order in which the API returned it.)
You can simplify this further with the download_panorama_face
function:
from streetlevel.lookaround import get_coverage_tile_by_latlon, download_panorama_face
from streetlevel.lookaround.auth import Authenticator
panos = get_coverage_tile_by_latlon(46.52943, 10.45544)
auth = Authenticator()
zoom = 2
for face in range(0, 6):
download_panorama_face(panos[0], f"{panos[0].id}_{face}_{zoom}.heic", face, zoom, auth)
trying to get lookaround working. But it is difficult, because an example is only showed in the lookaround repo, which also uses different variable names I believe? Also I suspect my input coordinates are sometimes the problem? 51.50056270050847, 3.885667340737007 as an example will give errors, so maybe 8 digits are the max or something? Would be nice if such a limit is needed, it would give an text error so it is clear right away or even better, that code does the rounding