Пример #1
0
 def get_matching_points(tp1, tr2_id, excluded_ranges=''):
     """ renvoie pour tp1 les points de t2 susceptible de matcher les points de t1
         avec un order_num >= à order_min
     """
     match = {}
     tps = Trace_point.objects.filter(
         trace=tr2_id).order_by('order_num')
     # if num_min != 0:
     #     tps = tps.filter(order_num__lt = num_min + seg2_search_length)
     #tps = tps.filter(order_num__gt = num_min)
     if excluded_ranges != '':
         excluded_ranges = 'not (' + excluded_ranges[0:-4] + ')'
         tps = tps.extra(where=[excluded_ranges])
     tps = tps.extra(where=[
         '10000*(abs(' + str(tp1.latitude) + '-latitude)+abs(' +
         str(tp1.longitude) + '-longitude)) <' + str(lonlat_delta)
     ])
     tps = tps.order_by('order_num')
     # print tps.query
     if tps.count() > 0:
         min_dist = 1  #on commence avec 1 km
         tp2 = tps[0]
         for t in tps:
             #dist = lib.getDistance(tp1.latitude, tp1.longitude,t.latitude, t.longitude)
             dist = lib.getQuickDistance(tp1.latitude, tp1.longitude,
                                         t.latitude, t.longitude)
             if dist < min_dist:
                 min_dist = dist
                 tp2 = t
         if min_dist < dist_tolerance:
             match[tp1] = tp2
         else:
             return {}
     return match
Пример #2
0
 def get_matching_points(tp1 ,tr2_id,  excluded_ranges=''):
     """ renvoie pour tp1 les points de t2 susceptible de matcher les points de t1
         avec un order_num >= à order_min
     """
     match = {}
     tps = Trace_point.objects.filter(trace=tr2_id).order_by('order_num')
     # if num_min != 0:
     #     tps = tps.filter(order_num__lt = num_min + seg2_search_length)
     #tps = tps.filter(order_num__gt = num_min)
     if excluded_ranges != '':
         excluded_ranges = 'not (' +excluded_ranges[0:-4] +')'
         tps = tps.extra(where=[excluded_ranges])
     tps = tps.extra(where=['10000*(abs('+str(tp1.latitude)+'-latitude)+abs('+str(tp1.longitude)+'-longitude)) <'+str(lonlat_delta)])
     tps = tps.order_by('order_num')
     # print tps.query
     if tps.count()>0:
         min_dist = 1 #on commence avec 1 km
         tp2 = tps[0]
         for t in tps:
             #dist = lib.getDistance(tp1.latitude, tp1.longitude,t.latitude, t.longitude)
             dist = lib.getQuickDistance(tp1.latitude, tp1.longitude,t.latitude, t.longitude)
             if dist < min_dist:
                 min_dist = dist
                 tp2 = t
         if min_dist < dist_tolerance:
             match[tp1] = tp2
         else:
             return {}
     return match
Пример #3
0
 def get_matching_points(tp1, tr2_id, num_min=0, exclude_list=[]):
     """ renvoie pour tp1 les points de t2 susceptible de matcher les points de t1
         avec un order_num >= à order_min
     """
     match = {}
     tps = Trace_point.objects.filter(trace=tr2_id)
     if num_min != 0:
         tps = tps.filter(order_num__lt=num_min + seg2_search_length)
     if len(exclude_list) > 950:
         #handling sqlite limitations (but exclude list should not be so long) i should use excluded_ranges cf previous to do.
         # this is artificially introducing a maxlength to the matching segment
         return {}
     tps = tps.filter(order_num__gt=num_min).exclude(
         order_num__in=exclude_list)
     tps = tps.extra(where=[
         '10000*(abs(' + str(tp1.latitude) + '-latitude)+abs(' +
         str(tp1.longitude) + '-longitude)) <' + str(lonlat_delta)
     ])
     tps = tps.order_by('order_num')
     # print tps.query
     if tps.count() > 0:
         min_dist = 1  #on commence avec 1 km
         tp2 = tps[0]
         for t in tps:
             #dist = lib.getDistance(tp1.latitude, tp1.longitude,t.latitude, t.longitude)
             dist = lib.getQuickDistance(tp1.latitude, tp1.longitude,
                                         t.latitude, t.longitude)
             if dist < min_dist:
                 min_dist = dist
                 tp2 = t
         if min_dist < dist_tolerance:
             match[tp1] = tp2
         else:
             return {}
     return match
Пример #4
0
 def get_matching_points(tp1 ,tr2_id, num_min = 0, exclude_list = []):
     """ renvoie pour tp1 les points de t2 susceptible de matcher les points de t1
         avec un order_num >= à order_min
     """
     match = {}
     tps = Trace_point.objects.filter(trace=tr2_id)
     if num_min != 0:
         tps = tps.filter(order_num__lt = num_min + seg2_search_length)
     if len(exclude_list)>950:
     #handling sqlite limitations (but exclude list should not be so long) i should use excluded_ranges cf previous to do.
     # this is artificially introducing a maxlength to the matching segment
         return {}
     tps = tps.filter(order_num__gt = num_min).exclude(order_num__in=exclude_list)
     tps = tps.extra(where=['10000*(abs('+str(tp1.latitude)+'-latitude)+abs('+str(tp1.longitude)+'-longitude)) <'+str(lonlat_delta)])
     tps = tps.order_by('order_num')
     # print tps.query
     if tps.count()>0:
         min_dist = 1 #on commence avec 1 km
         tp2 = tps[0]
         for t in tps:
             #dist = lib.getDistance(tp1.latitude, tp1.longitude,t.latitude, t.longitude)
             dist = lib.getQuickDistance(tp1.latitude, tp1.longitude,t.latitude, t.longitude)
             if dist < min_dist:
                 min_dist = dist
                 tp2 = t
         if min_dist < dist_tolerance:
             match[tp1] = tp2
         else:
             return {}
     return match