def get_stay_points_v2(userid = 1,max_distence = 0.2, max_speed = 2, max_time=15*60):
    print "Welcome"
     #units :km
    #userid = 0
    gps_obj_list = dbutils.get_gps_record_time_order(userid, 0,-1)
    stay_point_list = []
    counts = len(gps_obj_list)
    tmp_point_list = []
    i =0
    while i < counts :
        j = i + 1
        point_i =gps_obj_list[i]
        k = 0
        
        #del tmp_point_list[:]
        tmp_point_list = []
        tmp_point_list.insert(0, point_i)
        while (j < counts) :
            point_j = gps_obj_list[j]
            euclidean_distence = base_op.get_distance(point_i, point_j)
            t_diff = point_j.gps_UTC_unix_timestamp - point_i.gps_UTC_unix_timestamp
            #print "distence = %f km" % euclidean_distence
            k = k + 1
            tmp_point_list.insert(k, point_j)
            if t_diff > max_time :
                #t_diff = point_j.gps_UTC_unix_timestamp - point_i.gps_UTC_unix_timestamp
                meanSpeed =  euclidean_distence / t_diff  * 1000      
                #print "speed = %f m/s" % meanSpeed
                #if t_diff > max_timethreshold:
                if meanSpeed < max_speed:
                    #print "distence = %f km" % euclidean_distence
                    #print "speed = %f m/s" % meanSpeed
                    #print "time = %f s" % t_diff
                    
                    tmp_point_list.pop();
                    s = stay_point.stay_point()
                    s.userid = userid
                    calc_mean_pos(s, tmp_point_list)
                    stay_point_list.append(s)
                    #dbutils.insert_staypoint(s)
                    i = j
                    break
                else:
                    i = j
                    break;
            j = j+1
        if j == counts :
            s = stay_point.stay_point()
            s.userid = userid
            calc_mean_pos(s, tmp_point_list)
            stay_point_list.append(s)
            #dbutils.insert_staypoint(s)
            i = j
    #    break;
    #for gps_record in gps_obj_list :
     #   gps_record.show()
    #print "\n"
    return stay_point_list
def get_stay_points(userid=1, max_distence=0.2, max_speed=2):
    print "Welcome"
    #units :km
    #userid = 0
    gps_obj_list = dbutils.get_gps_record_time_order(userid, 0, -1)
    stay_point_list = []
    counts = len(gps_obj_list)
    tmp_point_list = []
    i = 0
    while i < counts:
        j = i + 1
        point_i = gps_obj_list[i]
        k = 0

        #del tmp_point_list[:]
        tmp_point_list = []
        tmp_point_list.insert(0, point_i)
        while (j < counts):
            point_j = gps_obj_list[j]
            euclidean_distence = base_op.get_distance(point_i, point_j)
            #print "distence = %f km" % euclidean_distence
            k = k + 1
            tmp_point_list.insert(k, point_j)
            if euclidean_distence > max_distence:
                t_diff = point_j.gps_UTC_unix_timestamp - point_i.gps_UTC_unix_timestamp
                meanSpeed = euclidean_distence / t_diff * 1000
                #print "speed = %f m/s" % meanSpeed
                #if t_diff > max_timethreshold:
                if meanSpeed < max_speed:
                    print "distence = %f km" % euclidean_distence
                    print "speed = %f m/s" % meanSpeed
                    print "time = %f s" % t_diff

                    tmp_point_list.pop()
                    s = stay_point.stay_point()
                    s.userid = userid
                    calc_mean_pos(s, tmp_point_list)
                    stay_point_list.append(s)
                    #dbutils.insert_staypoint(s)
                    i = j
                    break
                else:
                    i = j
                    break
            j = j + 1
        if j == counts:
            s = stay_point.stay_point()
            s.userid = userid
            calc_mean_pos(s, tmp_point_list)
            stay_point_list.append(s)
            dbutils.insert_staypoint(s)
            i = j
    #    break;
    #for gps_record in gps_obj_list :
    #   gps_record.show()
    #print "\n"
    return stay_point_list
def getSpeed(currentPoint, nextPoint):
    euclidean_distence = base_op.get_distance(currentPoint, nextPoint)
    #print "distence = %f km" % euclidean_distence
    time_tmp = nextPoint.gps_UTC_unix_timestamp - currentPoint.gps_UTC_unix_timestamp
    try :
        speedVal = euclidean_distence*3600/abs(time_tmp)
    except ZeroDivisionError:
        raise
    return speedVal
Пример #4
0
def getSpeed(currentPoint, nextPoint):
    euclidean_distence = base_op.get_distance(currentPoint, nextPoint)
    #print "distence = %f km" % euclidean_distence
    time_tmp = nextPoint.gps_UTC_unix_timestamp - currentPoint.gps_UTC_unix_timestamp
    try:
        speedVal = euclidean_distence * 3600 / abs(time_tmp)
    except ZeroDivisionError:
        raise
    return speedVal