Esempio n. 1
0
def tsp(curr_loc):
    res = SensorData.all_newest_both()

    res = sorted(res, key=lambda a: a[1].estValue(a[0]))

    res = res[:8]

    logging.info(res)

    points = [curr_loc] + ["{0},{1}".format(w[0].wgs84.lat, w[0].wgs84.lon) for w in res] + [curr_loc]

    route = maps(points)

    logging.info("route {0}".format(route))

    order = route['routes'][0]['waypoint_order']
    waypoints = route['geocoded_waypoints']

    ans = [curr_loc]
    wps = []
    for o in order:
        ans.append(points[1:-1][o])
        wps.append(waypoints[o])

    logging.info("ans {0}".format(ans))

    return ans, waypoints