예제 #1
0
파일: communicator.py 프로젝트: Widdin/MAD
    def __walkTrackSpeed(self, start, speed, dest):
        log.debug("__walkTrackSpeed: called, calculating distance and travel_time")
        distance = start.distance(dest)
        travel_time = distance / speed

        if travel_time <= Communicator.UPDATE_INTERVAL:
            log.debug("__walkTrackSpeed: travel_time is <= UPDATE_INTERVAL")
            time.sleep(travel_time)

        log.debug("__walkTrackSpeed: starting to walk")
        while travel_time > Communicator.UPDATE_INTERVAL:
            log.debug("__walkTrackSpeed: sleeping for %s" % str(Communicator.UPDATE_INTERVAL))
            time.sleep(Communicator.UPDATE_INTERVAL)
            log.debug("__walkTrackSpeed: Next round")
            travel_time -= Communicator.UPDATE_INTERVAL
            # move GEOFIX_UPDATE_INTERVAL*speed meters
            # in straight line between last_point and point
            course = start.course(dest)
            distance = Communicator.UPDATE_INTERVAL * speed
            start = start + gpxdata.CourseDistance(course, distance)
            startLat = start.lat
            startLng = start.lon
            log.debug("__walkTrackSpeed: sending location")
            self.setLocation(repr(startLat), repr(startLng), "")
            log.debug("__walkTrackSpeed: done sending location")
예제 #2
0
def walk_track_speed(track, speed, point):
    global curr_lon
    global curr_lat
    while True:
        try:
            next_point = next(track)
        except StopIteration:
            print("done")
            sys.exit(0)
        distance = point.distance(next_point)
        travel_time = distance / speed  # in seconds

        if travel_time <= UPDATE_INTERVAL:
            time.sleep(travel_time)
        while travel_time > UPDATE_INTERVAL:
            time.sleep(UPDATE_INTERVAL)
            travel_time -= UPDATE_INTERVAL
            # move GEOFIX_UPDATE_INTERVAL*speed meters
            # in straight line between last_point and point
            course = point.course(next_point)
            distance = UPDATE_INTERVAL * speed
            point = point + gpxdata.CourseDistance(course, distance)
            curr_lat = point.lat
            curr_lon = point.lon

        point = next_point
        curr_lat = point.lat
        curr_lon = point.lon
예제 #3
0
파일: s2Helper.py 프로젝트: kimzky/MAD
    def get_new_coords(init_loc, distance, bearing):
        """
        Given an initial lat/lng, a distance(in kms), and a bearing (degrees),
        this will calculate the resulting lat/lng coordinates.
        """
        # TODO: check for implementation with gpxdata
        start = gpxdata.TrackPoint(init_loc.lat, init_loc.lng)
        destination = start + gpxdata.CourseDistance(bearing, distance)

        return Location(destination.lat, destination.lon)