B06246_09_15-htmlbls.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:QGIS-Python-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码
def googleStreetView(values, feature, parent):
    """
    Returns a path to a local Google Street View 
    image for the feature
    """
    x,y = feature.geometry().asPoint()
    baseurl = "https://maps.googleapis.com/maps/api/streetview?"
    w = 150
    h = 150
    fov = 90
    heading = 235
    pitch = 10
    params = "size={w}x{h}&".format(w,h)
    params += "location={y},{x}&".format(y,x)
    params += "fov={}&heading={}&pitch={}".format(fov, heading, pitch) 
    url = baseurl + params    
    tmpdir = "/qgis_data/tmp/"
    img = tmpdir + str(feature.id()) + ".jpg"
    if not os.path.isfile(img):
        urllib.urlretrieve(url, img)
    uri = "file://" + img
    return uri
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号