mirrorworld.streetside: Bing Streetside¶
Finding panoramas¶
- find_panoramas(lat, lon, radius=25, limit=50, session=None)[source]¶
Retrieves panoramas within a square around a point.
The latitudes of the resulting bounding box must be greater than -85.06° and less than 85.06°. If they are not, the function returns None.
- Parameters:
lat (float) – Latitude of the center point.
lon (float) – Longitude of the center point.
radius (float) – (optional) Radius of the square in meters. (Not sure if that’s the correct mathematical term, but you get the idea.) Defaults to 25.
limit (int) – (optional) Maximum number of results to return. Defaults to 50.
session (Session) – (optional) A requests session.
- Returns:
A list of StreetsidePanorama objects.
- Return type:
List[StreetsidePanorama] | None
Usage sample:
from mirrorworld import streetside panos = streetside.find_panoramas(-17.831848, 31.046641) print(panos[0].lat, panos[0].lon) print(panos[0].id) print(panos[0].date)Usage sample:
from mirrorworld import streetside from aiohttp import ClientSession async with ClientSession() as session: panos = await streetside.find_panoramas_async(-17.831848, 31.046641, session) print(panos[0].lat, panos[0].lon) print(panos[0].id) print(panos[0].date)
- find_panoramas_in_bbox(north, west, south, east, limit=50, session=None)[source]¶
Retrieves panoramas within a bounding box.
The latitude parameters must be greater than -85.06° and less than 85.06°. If they are not, the function returns None.
- Parameters:
- Returns:
A list of StreetsidePanorama objects.
- Return type:
List[StreetsidePanorama] | None
- find_panorama_by_id(panoid, session=None)[source]¶
Fetches metadata for a specific panorama.
- Parameters:
panoid (int) – The pano ID.
session (Session) – (optional) A requests session.
- Returns:
A StreetsidePanorama object if a panorama was found, or None.
- Return type:
StreetsidePanorama | None
Usage sample:
from mirrorworld import streetside pano = streetside.find_panorama_by_id(398611371) print(pano.lat, pano.lon) print(pano.date) print(pano.heading)
- async find_panorama_by_id_async(panoid, session)[source]¶
- Parameters:
panoid (int)
session (ClientSession)
- Return type:
StreetsidePanorama | None
Usage sample:
from mirrorworld import streetside from aiohttp import ClientSession async with ClientSession() as session: pano = await streetside.find_panorama_by_id_async(398611371, session) print(pano.lat, pano.lon) print(pano.date) print(pano.heading)
Downloading panoramas¶
- get_panorama(pano, zoom=4, stitching_method=CubemapStitchingMethod.ROW)[source]¶
Downloads a panorama and returns it as PIL image.
- Parameters:
pano (StreetsidePanorama) – The panorama.
zoom (int) – (optional) Image size; 0 is lowest, 4 is highest. Defaults to 4. If 4 is not available, 3 will be downloaded. (Note that only the old Microsoft panoramas go up to 4; the TomTom-provided panoramas stop at 3.)
stitching_method (CubemapStitchingMethod) – (optional) Whether and how the faces of the cubemap are stitched into one image. Defaults to
ROW.- Returns:
A PIL image or a list of six PIL images depending on
stitching_method.- Return type:
List[Image] | Image
- async get_panorama_async(pano, session, zoom=4, stitching_method=CubemapStitchingMethod.ROW)[source]¶
- Parameters:
pano (StreetsidePanorama)
session (ClientSession)
zoom (int)
stitching_method (CubemapStitchingMethod)
- Return type:
List[Image] | Image
- download_panorama(pano, path, zoom=4, stitching_method=CubemapStitchingMethod.ROW, pil_args=None)[source]¶
Downloads a panorama to a file.
- Parameters:
pano (StreetsidePanorama) – The panorama.
path (str) – Output path.
zoom (int) – (optional) Image size; 0 is lowest, 4 is highest. Defaults to 4. If 4 is not available, 3 will be downloaded. (Note that only the old Microsoft panoramas go up to 4; the TomTom-provided panoramas stop at 3.)
stitching_method (CubemapStitchingMethod) – (optional) Whether and how the faces of the cubemap are stitched into one image. Defaults to
ROW.pil_args (dict) – (optional) Additional arguments for PIL’s Image.save method, e.g.
{"quality":100}. Defaults to{}.- Return type:
None
Usage sample:
from mirrorworld import streetside pano = streetside.find_panorama_by_id(398611371) streetside.download_panorama(pano, f"{pano.id}.jpg")
- async download_panorama_async(pano, path, session, zoom=4, stitching_method=CubemapStitchingMethod.ROW, pil_args=None)[source]¶
- Parameters:
pano (StreetsidePanorama)
path (str)
session (ClientSession)
zoom (int)
stitching_method (CubemapStitchingMethod)
pil_args (dict)
- Return type:
None
Usage sample:
from mirrorworld import streetside from aiohttp import ClientSession async with ClientSession() as session: pano = await streetside.find_panorama_by_id_async(398611371, session) await streetside.download_panorama_async(pano, f"{pano.id}.jpg", session)
Data classes¶
- class StreetsidePanorama(id, lat, lon, date, next=None, previous=None, elevation=None, heading=None, pitch=None, roll=None, max_zoom=None)[source]¶
Metadata of a Streetside panorama.
- Parameters:
- heading: float = None¶
Heading in radians, where 0° is north, 90° is east, 180° is south and 270° is west.
- max_zoom: int = None¶
Highest zoom level available; 4 for the original Microsoft panoramas, 3 for the TomTom-provided ones.
- permalink(heading=0.0, pitch=0.0, map_zoom=17.0, radians=False)[source]¶
Creates a permalink to the closest panorama to the given location. Directly linking to a specific panorama by its ID does not appear to be possible.
- Parameters:
heading (float) – (optional) Initial heading of the viewport. Defaults to 0°.
pitch (float) – (optional) Initial pitch of the viewport. Defaults to 0°.
map_zoom (float) – (optional) Initial zoom level of the map. Defaults to 17.
radians (bool) – (optional) Whether angles are in radians. Defaults to False.
- Returns:
A Bing Maps URL which will open the closest panorama to the given location.
- Return type:
Miscellaneous¶
- build_permalink(lat, lon, heading=0.0, pitch=0.0, map_zoom=17.0, radians=False)[source]¶
Creates a permalink to the closest panorama to the given location. Directly linking to a specific panorama by its ID does not appear to be possible.
- Parameters:
lat (float) – Latitude of the panorama’s location.
lon (float) – Longitude of the panorama’s location.
heading (float) – (optional) Initial heading of the viewport. Defaults to 0°.
pitch (float) – (optional) Initial pitch of the viewport. Defaults to 0°.
map_zoom (float) – (optional) Initial zoom level of the map. Defaults to 17.
radians (bool) – (optional) Whether angles are in radians. Defaults to False.
- Returns:
A Bing Maps URL which will open the closest panorama to the given location.
- Return type: