Skip to content

Documentation for sv_dlp class

sv_dlp.sv_dlp

sv_dlp classes are responsible for the API scrapping of various street view services.
Key data such as Panorama ID, service, and metadata are stored in sv_dlp classes for syntax convience

postdownload

Inner class that is responsible for tinkering with given panorama Image obtained from self.download_panorama.

save_panorama(img, metadata, edit_exif=True, output=None)

Saves Panorama ID on local drive with metadata-related information.

pano_id must be parsed as a PIL.Image.Image object. If a list is parsed, save_panorama will treat the first element of the list as the panorama.

Parameters
img

Panorama

metadata

Metadata, required for Panorama ID & service for essential requirements

edit_exif

Sets if EXIF Data shall be edited. This edits the datetime, coordinates and camera information (last one varying) on the service.

output

Location (and filename) to be saved to

save_tiles(tiles_io, metadata, output=None)

Saves tiles individually from self.download_panorama.tile_imgs.

If

Parameters
tiles_io

List of Tile Images where each element is stored in a PIL.Image format

metadata

Metadata, required for Panorama ID & service for essential requirements

output

Folder to be saved onto

__init__(service='google')

Initiates sv_dlp class by setting the service to scrape from, and allocating placeholders for pano_id and metadata.

Parameters
service

Input of service to scrape from. Default is Google

Returns
self.service

Function of specified service script

self.service_str

String of given service's name

self.pano_id

Memory Placeholder for Panorama ID

self.metadata

Memory Placeholder for metadata

download_panorama(pano_id=None, lat=None, lng=None, zoom=3)

Obtains Tile URLs List from a given Panorama ID/Coordinate with a specified zoom, downloads each row in a multithreaded way and stitches them.

If self.metadata is not allocated (or does not match with given input), get_metadata is automatically called.

Parameters
pano_id

Panorama ID - Might not work with some services

lat

Latitude

lng

Longitude

Returns
img

Stitched Panorama Image in PIL.Image format

tile_imgs

List of Tile Images where each element is stored in a PIL.Image format

tuple

A tuple is returned if only one variable is assigned

get_available_services(lat=None, lng=None)

Returns all services available for sv_dlp. Will only return a specified amount if coordinates are parsed

Parameters
lat

Latitude

lng

Longitude

Returns
self.available_services

Array of services that are compatible with the given input

get_metadata(pano_id=None, lat=None, lng=None, get_linked_panos=False)

Calls allocated service's get_metadata() function to obtain metadata with given input, and store it to class and variable.

Metadata is returned in a MetadataStructure object, providing the developer a more structured and organized way to handle metadata information with various attributes. Additionally, the .dict() method returns the attributes of each instance of the MetadataStructure class in the form of a dictionary, allowing for easy access and manipulation of the metadata information.

sv_dlp's metadata structure is designed with compatibility in mind, allowing developers to tinker with it no matter the service picked. An example of the returned metadata is the one below:

metadata = MetadataStructure(
    service=service, 
    pano_id=pano_id, 
    lat=lat, 
    lng=lng, 
    date=datetime.datetime(), 
    size=image_size, 
    max_zoom=max_zoom, 
    timeline=[{'pano_id': 'pano_id', 'date': datetime.datetime()}], 
    linked_panos={{'pano_id': pano_id, 'lat': lat, 'lng': lng, 'date': datetime.datetime()}}, 
    misc={}
)

Additionally, the developer has the option to access the metadata in dictionary form by calling the .dict() method. An example is:

metadata = {
    "service": service,
    "pano_id": pano_id,
    "lat": lat,
    "lng": lng,
    "date": datetime.datetime(),
    "size": image_size,
    "max_zoom": max_zoom,
    "misc": { # Only use with exclusive service features
        "is_trekker": len(json[1][0][5][0][3][0][0][2]) > 3,
        "gen": gen,
    },
    "timeline": {
        [{'pano_id'}: pano_id, "date": date}],
        [{'pano_id'}: pano_id, "date": date}],
        [{'pano_id'}: pano_id, "date": date}],
        # and so on...
    }
    "linked_panos": {
        [{'pano_id'}: pano_id, "date": date, "lat": lat, "lng" lng}],
        [{'pano_id'}: pano_id, "date": date, "lat": lat, "lng" lng}],
        [{'pano_id'}: pano_id, "date": date, "lat": lat, "lng" lng}],
        # and so on... 
        # only added if get_linked_panos is true
    },
}
Parameters
pano_id

Panorama ID - Might not work with some services

lat

Latitude

lng

Longitude

get_linked_panos

Sets if linked panos should be returned or not

Returns
metadata

Metadata of given input

self.metadata

Stores metadata in class

.dict()

Function inside object that translates MetadataStructure object to dictionary

get_pano_from_url(url)

Obtains Panorama IDs from URLs. Shortened URLs are redirected automatically

Parameters
url

(Shortened) URL containg Panorama ID

Returns
pano_id

Panorama ID from given URL

get_pano_id(lat, lng)

Translates Latitude and Longitude to Panorama ID by calling class' get_metadata(), then allocates metadata and panorama ID into class and variable respectfully

Parameters
lat

Latitude

lng

Longitude

Returns
pano_id

Panorama ID of given coordinates

self.metadata

Metadata of given input

self.pano_id

Panorama ID of given coordinates

set_service(service)

Picks service script from available attributes in sv_dlp.services

Parameters
service

Input of service to scrape from

Returns
self.service

Function of specified service script

self.service

function of specified service script

self.service_str

string of service's name

short_url(pano_id=None, lat=None, lng=None, heading=0, pitch=0, zoom=90)

Short URLs with parsed input using Internal API calls from specified service. Latitude and Longitude are automatically translated to a Panorama ID, therefore self.pano_id is stored

Parameters
pano_id

Panorama ID

lat

Latitude

lng

Longitude

heading

Heading (must be around -360 - 360)

pitch

Pitch (must be around -90 - 90)

zoom

Zoom

Returns
url

Shortened URL from given panorama ID