Ejemplo n.º 1
0
def sampleAndGetStreetImageLinks(endPoints, sampleNum, picNum, ptrNum, intersectionPointInfo):
    """
    Randomly select end points from the endPoint collection.
    For each selected end point, call Google map street view image api
    to get the street view images.
    :return:
    """
    print "sampling street images..."

    # get 2x sampled points for skipping some images that are missing its date
    sampledPoints = random.sample(endPoints, sampleNum) if sampleNum < len(endPoints) * 2 else endPoints
    sampleData = []  # store (picture number, file name, lat and lng, link to image)
    progress = Progress(10)
    headings = CONFIG["gmap"]["headings"]
    sampleNumDelta = len(headings)
    for point in sampledPoints:
        progress.printProgress()
        result = getSurroundingStreetViewLinks(point, picNum, ptrNum, intersectionPointInfo)
        sampleData += result
        picNum += sampleNumDelta
        ptrNum += 1
    print ""
    return sampleData
Ejemplo n.º 2
0
def sampleAndDownloadStreetImage(endPoints, sampleNum, picNum, ptrNum,
                                 targetDirectory, intersectionPointInfo):
    """
    Randomly select end points from the endPoint collection.
    For each selected end point, call Google map street view image api
    to get the street view images.
    :return:
    """
    print "downloading street images..."
    sampledPoints = random.sample(
        endPoints, sampleNum) if sampleNum < len(endPoints) else endPoints
    sampleData = []  # store (picture number, file name, lat and lng)
    progress = Progress(10)
    headings = CONFIG["gmap"]["headings"]
    sampleNumDelta = len(headings)
    for point in sampledPoints:
        progress.printProgress()
        result = downloadSurroundingStreetView(point, targetDirectory, picNum,
                                               ptrNum, intersectionPointInfo)
        sampleData += result
        picNum += sampleNumDelta
        ptrNum += 1
    print ""
    return sampleData