# lng_SE = -66.550709

if gridsize == "small":
    incr = 0.0035961575091
else:
    incr = .2697118131790

# Start in the northwest and iterate to the southeast
print("lat,lng,latnear,lngnear,dist_km")

lat_dist = str(distance_on_unit_sphere(1, 0, 0, 0))
lng_dist = str(distance_on_unit_sphere(approx_longitude, 1,
               approx_longitude, 0))

if scantype == "grid":
    locations = create_area_grid(lat_NW, lng_NW, lat_SE,
                                 lng_SE, increment=incr)
elif scantype == "city_list":
    locations = cities_list(listname)
else:
    locations = create_buildings_list(listname)

for location in locations:
    # Equirectangular approximation at 49th parallel:
    # http://www.movable-type.co.uk/scripts/latlong.html
    sql = "SELECT latitude, longitude,SQRT(POW(" + lat_dist + " * ("
    sql += "latitude - " + str(location[0]) + "), 2) + "
    sql += "POW(" + lat_dist + " * (" + str(location[1]) + " - longitude) "
    sql += "* COS(latitude / " + lng_dist + "), 2)) AS distance FROM "
    sql += "`" + placetype + "` ORDER BY distance LIMIT 0,1"
    c.execute(sql)
    result = c.fetchall()[0]
예제 #2
0
            progress_bar.update(progress)
        finally:
            print_lock.release()
    # Or, no location found
    else:
        print_lock.acquire()
        try:
            print(poi + ',' + curr_location + ',,,')
            progress += 1
            progress_bar.update(progress)
        finally:
            print_lock.release()

if scan_type == "grid":
    # Gets the grid of points in the area to check
    area_grid = create_area_grid(lat_NW, lng_NW, lat_SE, lng_SE, increment)

    progress_bar = (ProgressBar(widgets=[Percentage(), Bar(),
                    ETA()], maxval=(len(area_grid)*len(places))).start())
    progress = 0

    # Has the grid split up into threads and processed
    for place in places:
        create_threads(output_nearest_place, area_grid, place, numthreads=10)
else:
    # List of city centroids
    cities = cities_list(list_name)
    # Has the grid split up into threads and processed

    progress_bar = (ProgressBar(widgets=[Percentage(), Bar(),
                    ETA()], maxval=(len(cities)*len(places))).start())