def sampleImportantSpot(sTime, eTime, minDis, importantSpot, stay_points_list):
    sampleRes = []
    disThreh = 200  #unit is mile
    n = len(stay_points_list)
    i = 0
    imLat = importantSpot.mean_coordinate_latitude
    imLon = importantSpot.mean_coordinate_longtitude

    while (i < n):
        entTime = stay_points_list[i].arrival_timestamp
        leaTime = stay_points_list[i].leaving_timestamp
        lat = stay_points_list[i].mean_coordinate_latitude
        lon = stay_points_list[i].mean_coordinate_longtitude
        #unit is mile
        dis = base_op.calc_distance(imLat, imLon, lat, lon)
        if (dis < disThreh):
            j = 0
            while (sTime < entTime):
                sTime += 60 * 10
                j = j + 1
                if (j == 6):
                    sampleRes.append(0)
                    j = 0
            while (sTime < leaTime):
                sTime += 60 * 10 * 6
                sampleRes.append(1)
        i += 1
    while (sTime < eTime):
        sTime += 60 * 10 * 6
        sampleRes.append(0)
    print len(sampleRes)
    return sampleRes
def sampleImportantSpot(sTime, eTime, minDis, importantSpot,stay_points_list):
    sampleRes = []   
    disThreh = 200 #unit is mile
    n = len(stay_points_list)
    i = 0
    imLat = importantSpot.mean_coordinate_latitude
    imLon = importantSpot.mean_coordinate_longtitude
    
    while (i < n):
        entTime = stay_points_list[i].arrival_timestamp
        leaTime =stay_points_list[i].leaving_timestamp
        lat = stay_points_list[i].mean_coordinate_latitude
        lon = stay_points_list[i].mean_coordinate_longtitude
        #unit is mile
        dis = base_op.calc_distance(imLat,imLon,lat,lon)
        if (dis < disThreh):
            j = 0
            while(sTime < entTime):
                sTime += 60*10
                j = j + 1;
                if (j== 6) :
                    sampleRes.append(0)
                    j = 0
            while(sTime < leaTime):
                sTime += 60*10*6
                sampleRes.append(1)
        i += 1
    while (sTime < eTime) :
        sTime += 60*10*6
        sampleRes.append(0)
    print len(sampleRes)
    return sampleRes
def getPointsDistence(p1, p2):
    return base_op.calc_distance(p1[0],p1[1],p2[0],p2[1])
def getPointsDistence(p1, p2):
    return base_op.calc_distance(p1[0], p1[1], p2[0], p2[1])