mirrorworld.yandex: Yandex Panorama¶
Finding panoramas¶
- find_panorama(lat, lon, session=None)[source]¶
Searches for a panorama near the given point.
Aerial panoramas are ignored by this API call.
- Parameters:
- Returns:
A YandexPanorama object if a panorama was found, or None.
- Return type:
YandexPanorama | None
Usage sample:
from mirrorworld import yandex pano = yandex.find_panorama(43.249064, 76.941999) print(pano.lat, pano.lon) print(pano.id) print(pano.date)
- async find_panorama_async(lat, lon, session)[source]¶
- Parameters:
- Return type:
YandexPanorama | None
Usage sample:
from mirrorworld import yandex from aiohttp import ClientSession async with ClientSession() as session: pano = await yandex.find_panorama_async(43.249064, 76.941999, session) print(pano.lat, pano.lon) print(pano.id) print(pano.date)
- find_panorama_by_id(panoid, session=None)[source]¶
Fetches metadata of a specific panorama.
- Parameters:
panoid (str) – The pano ID.
session (Session) – (optional) A requests session.
- Returns:
A YandexPanorama object if a panorama with this ID exists, or None.
- Return type:
YandexPanorama | None
Usage sample:
from mirrorworld import yandex pano = yandex.find_panorama_by_id("1532719828_788624743_23_1678861237") print(pano.lat, pano.lon) print(pano.date) print(pano.heading)
- async find_panorama_by_id_async(panoid, session)[source]¶
- Parameters:
panoid (str)
session (ClientSession)
- Return type:
YandexPanorama | None
Usage sample:
from mirrorworld import yandex from aiohttp import ClientSession async with ClientSession() as session: pano = await yandex.find_panorama_by_id_async("1532719828_788624743_23_1678861237", session) print(pano.lat, pano.lon) print(pano.date) print(pano.heading)
Downloading panoramas¶
- get_panorama(pano, zoom=0, refetch=False)[source]¶
Downloads a panorama and returns it as PIL image.
Note that most official car coverage has its bottom part cropped out.
- Parameters:
pano (YandexPanorama) – The panorama to download.
zoom (int) – (optional) Image size; 0 is highest, 4 is lowest. The dimensions of a zoom level of a specific panorama depend on the camera used. If the requested zoom level does not exist, the highest available level will be downloaded. Defaults to 0.
refetch (bool) – (optional) If True, the metadata of the panorama will be refetched if
pano.image_sizesis not set. This will make an additional network request. Defaults to False.- Returns:
A PIL image containing the panorama.
- Return type:
Image
- async get_panorama_async(pano, session, zoom=0, refetch=False)[source]¶
- Parameters:
pano (YandexPanorama)
session (ClientSession)
zoom (int)
refetch (bool)
- Return type:
Image
- download_panorama(pano, path, zoom=0, pil_args=None, refetch=False)[source]¶
Downloads a panorama to a file. If the chosen format is JPEG, Exif and XMP GPano metadata are included.
Note that most official car coverage has its bottom part cropped out.
- Parameters:
pano (YandexPanorama) – The panorama to download.
path (str) – Output path.
zoom (int) – (optional) Image size; 0 is highest, 4 is lowest. The dimensions of a zoom level of a specific panorama depend on the camera used. If the requested zoom level does not exist, the highest available level will be downloaded. Defaults to 0.
pil_args (dict | None) – (optional) Additional arguments for PIL’s Image.save method, e.g.
{"quality":100}. Defaults to{}.refetch (bool) – (optional) If True, the metadata of the panorama will be refetched if
pano.image_sizesis not set. This will make an additional network request. Defaults to False.- Return type:
None
Usage sample:
from mirrorworld import yandex pano = yandex.find_panorama_by_id("1532719828_788624743_23_1678861237") yandex.download_panorama(pano, f"{pano.id}.jpg")
- async download_panorama_async(pano, path, session, zoom=0, pil_args=None, refetch=False)[source]¶
- Parameters:
pano (YandexPanorama)
path (str)
session (ClientSession)
zoom (int)
pil_args (dict | None)
refetch (bool)
- Return type:
None
Usage sample:
from mirrorworld import yandex from aiohttp import ClientSession async with ClientSession() as session: pano = await yandex.find_panorama_by_id_async("1532719828_788624743_23_1678861237", session) await yandex.download_panorama_async(pano, f"{pano.id}.jpg", session)
Data classes¶
- class Address(lat, lon, house_number, street_name_and_house_number)[source]¶
An address whose marker is overlaid on the panorama.
- class Marker(lat, lon, name, description, style)[source]¶
A marker which is neither an address, company, nor landmark.
- class Place(id, lat, lon, name, tags)[source]¶
A company or landmark whose marker is overlaid on the panorama.
- class YandexPanorama(id, lat, lon, heading=None, image_id=None, tile_size=None, image_sizes=None, neighbors=None, links=None, historical=None, date=None, height=None, street_name=None, places=None, addresses=None, other_markers=None, author=None, author_avatar_url=None)[source]¶
Metadata of a Yandex panorama.
ID, latitude and longitude are always present. The availability of other metadata depends on which function was called and what was returned by the API.
- Parameters:
- heading: float = None¶
Heading in radians, where 0° is south, 90° is west, 180° is north and 270° is east.
- tile_size: Size = None¶
Yandex panoramas are broken up into a grid of tiles. This returns the size of one tile.
- image_sizes: List[Size] = None¶
The image sizes in which this panorama can be downloaded, from highest to lowest. Indices correspond to zoom levels.
- neighbors: List[YandexPanorama] = None¶
A list of nearby panoramas.
- historical: List[YandexPanorama] = None¶
A list of panoramas with a different date at the same location.
- other_markers: List[Marker] = None¶
Represents other markers which are neither an address, company, nor landmark.
- author_avatar_url: str = None¶
URL of the uploader’s avatar; only set for third-party panoramas. Replace
%swithsmall(25x25),normal(100x100) orbig(500x500) to get the respective size.
- permalink(heading=0.0, pitch=0.0, map_zoom=17.0, radians=True)[source]¶
Creates a permalink to this panorama.
- 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.
self (YandexPanorama)
- Returns:
A Yandex Maps URL which will open this panorama.
- Return type:
Miscellaneous¶
- build_permalink(id=None, lat=None, lon=None, heading=0.0, pitch=0.0, map_zoom=17.0, radians=True)[source]¶
Creates a permalink to the given panorama. All parameters are optional, but either a location, or a pano ID, or both must be passed.
- Parameters:
id (str) – (optional) The pano ID.
lat (float) – (optional) Latitude of the panorama’s location.
lon (float) – (optional) 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 Yandex Maps URL which will open the given panorama.
- Return type: