Beispiel #1
0
def find(lat,lon, acc):
    stime = time.time()
    sql = 'select * from shapes'
    l = db.Query(sql)
    print 'findTrips'
    res = set()
    for row in l:
        dis = d((lat,lon),(row[0],row[1])).meters
        if dis <= acc:
            print 'o'
            dis = d((lat,lon),(row[2],row[3])).meters
            if dis <= acc:
                print 'k'
                for shape in row[4].split(';'):
                    res.add(int(shape))
    print time.time()-stime
    return db.get_trips_ids('shape_id',res)
Beispiel #2
0
def find_old(lat, lon, acc):
    acc = int(float(acc))
    stime = time.time()
    sql = 'select * from distinct_new_shapes'
    #sql = 'select * from new_shape'
    l = db.Query(sql)
    print 'findTrips'
    res = set()
    for row in l:
        dis = d((lat, lon), (row[0], row[1])).meters
        if dis <= acc:
            print 'o'
            dis = d((lat, lon), (row[2], row[3])).meters
            if dis <= acc:
                print 'k'
                if type(row[4]) == type(1):
                    res.add(row[4])
                else:
                    for shape in row[4].split(';'):
                        res.add(int(shape))
    print time.time() - stime
    print len(res)
    return db.get_trips_ids('shape_id', res)
Beispiel #3
0
def find_old(lat,lon, acc):
    acc = int(float(acc))
    stime = time.time()
    sql = 'select * from distinct_new_shapes'
    #sql = 'select * from new_shape'
    l = db.Query(sql)
    print 'findTrips'
    res = set()
    for row in l:
        dis = d((lat,lon),(row[0],row[1])).meters
        if dis <= acc:
            print 'o'
            dis = d((lat,lon),(row[2],row[3])).meters
            if dis <= acc:
                print 'k'
                if type(row[4]) == type(1):
                    res.add(row[4])
                else:
                    for shape in row[4].split(';'):
                        res.add(int(shape))
    print time.time()-stime
    print len(res)
    return db.get_trips_ids('shape_id',res)
Beispiel #4
0
def find(bus_line):
    sql = 'select id from routes where bus_num = {0}'.format(bus_line)
    ids = db.First(db.Query(sql))
    return db.get_trips_ids('route_id',ids)
Beispiel #5
0
def find_all(day):
    sql = 'select service_id from calendar where {0} = 1'.format(day)
    return db.get_trips_ids('service_id', db.First(db.Query(sql)))
Beispiel #6
0
def find_all(day):
    sql = 'select service_id from calendar where {0} = 1'.format(day)
    return db.get_trips_ids('service_id',db.First(db.Query(sql)))