def get_image_from_gps(coords: str) -> Result:
    """
    Get a result object containing the link to an street view image
    in the vicinity of the specified lat and long coordinates
    
    use as results.download_links(".") 
    change "." to another path not to download in cwd

    ex: 
    res = get_image_from_gps("45.5307147,-73.6157818")
    res.download_links("~/Downloads") 
    
    """
    params = {
        "size": "512x512",
        "location": coords,
        "pitch": "10",
        "radius": "1000",
        "key": "ASK MIKE OR VICTOR",
        "source": "outdoor",
        "fov": "120",
    }
    api_list = gsv_helpers.api_list(params)
    results = gsv_api.results(api_list)
    return results
示例#2
0
 def test_api_list(self):
   apiargs = {
     'location': '46.414382,10.013988',
     'size': '640x300',
     'heading': '0'
   }
   api_list = helpers.api_list(apiargs)
   self.assertTrue(1 == len(api_list))
示例#3
0
 def test_api_list_multi(self):
   apiargs = {
     'location': '46.414382,10.013988;40.720032,-73.988354',
     'size': '640x300;640x640',
     'heading': '0;90;180;270',
     'fov': '0;90;120',
     'pitch': '-90;0;90'
   }
   api_list = helpers.api_list(apiargs)
   self.assertTrue(144 == len(api_list))
   
def get_image_from_gps_adresses(params):
    """
    Get a result object containing the link to an street view image
    in the vicinity of the specified lat and long coordinates
    
    use as results.download_links(".") 
    change "." to another path not to download in cwd
    ex: 
    res = get_image_from_gps("45.5307147,-73.6157818")
    res.download_links("~/Downloads") 
    
    """
    api_list = gsv_helpers.api_list(params)
    results = gsv_api.results(api_list)
    return (results)
示例#5
0
def fetch_street_view_image(address: str, geocoder_api_key: str,
                            streetview_api_key: str) -> gsv_api.results:
    """Retrieve StreetView images for the address."""
    geocoder = GoogleGeocoder(geocoder_api_key)
    result = geocoder.get(address)[0]
    params = {
        "size": "600x600",
        "location": result.formatted_address,
        "pitch": "0",
        "key": streetview_api_key,
        "source": "outdoor",
        "fov": "120",
    }
    api_list = gsv_helpers.api_list(params)
    results = gsv_api.results(api_list)
    return results
示例#6
0
    next(csv_reader)  # skip the header
    for row in csv_reader:
        centroid_lat = str(row[1])
        centroid_lon = str(row[2])
        # the coord is saved as x 1e7 integer to preserve precision
        # to obtain the actual coord needs to divide by 1e7
        location_str += centroid_lat[:-7] + '.' + centroid_lat[
            -7:] + ',' + centroid_lon[:-7] + '.' + centroid_lon[-7:] + ';'

print('...reading parameters...')
params = {
    'size': '512x512',  # max 640x640 pixels
    'location': location_str[:-1],
    #'heading': '0;30;60;90;120;150;180;210;240;270;300;330', # if don't specify heading it will face the coordinate point
    'pitch': '10',
    'key': gsv_api_key,
    'source': 'outdoor'
}

# Create a results object
street_view_list = gsvhelpers.api_list(params)
print('...data querying from API...')
results = gsvapi.results(street_view_list)

# Download images to directory 'downloads'
# results.preview()
print('...saving images...')
results.download_links(csv_filename[17:-4])
print('...saving metadata...')
results.save_metadata('street_view_metadata.json')