def compute_overlap(da, db, dist_tol, time_tol):
    """
    returns the TimeGps set [da_i, da_j, db_k, db_l] or False if no overlap
    """
    
    #look for matches by time and distance
    matches = []
    for pta in da.coords:
        for ptb in db.coords:
            
            #times are chronological
            if ptb.time-pta.time > time_tol:
                break
            if pta.time-ptb.time > time_tol:
                continue
            
            if hm.approx_dist(pta.gps, ptb.gps) < dist_tol:
                matches.append([pta, ptb])
            
    #determine the furthest apart pair of matches
    largest_dist = 0
    furthest_pair = False
    for pair1 in matches:
        for pair2 in matches:
            this_dist = hm.haversine_dist(pair1[0].gps, pair2[0].gps)
            if this_dist > largest_dist:
                largest_dist = this_dist
                furthest_pair = [pair1[0], pair2[0], pair1[1], pair2[1]]
                
    return furthest_pair
 def set_distance(self):
     cum_dist = 0
     for i in range(len(self.coords) - 1):
         cum_dist += hm.haversine_dist(self.coords[i].gps,
                                       self.coords[i + 1].gps)
     self.distance = cum_dist
示例#3
0
 def set_distance(self):
     cum_dist = 0
     for i in range(len(self.coords)-1):
         cum_dist += hm.haversine_dist(self.coords[i].gps, 
                                       self.coords[i+1].gps)
     self.distance = cum_dist