示例#1
0
def truck_data(truck_id):
    database.connect()
    query = TruckData.select()
    query = query.where(TruckData.truck_id == truck_id)
    query = query.order_by(TruckData.timestamp.desc())
    data = [d.get_default_dict() for d in query]
    return json.dumps(data)
    database.close()
示例#2
0
def truck_data(truck_id):
    database.connect()
    query = TruckData.select()
    query = query.where(TruckData.truck_id == truck_id)
    query = query.order_by(TruckData.timestamp.desc())
    data = [d.get_default_dict() for d in query]
    return json.dumps(data)
    database.close()
示例#3
0
def location_data(lat, lon, radius):
    database.connect()
    # NOTE: the "radius" is a square threshold, not circular
    query = TruckData.select()
    query = query.where(TruckData.latitude > lat - radius)
    query = query.where(TruckData.latitude < lat + radius)
    query = query.where(TruckData.longitude > lon - radius)
    query = query.where(TruckData.longitude < lon + radius)
    query = query.order_by(TruckData.timestamp.desc())
    data = [d.get_default_dict() for d in query]
    return json.dumps(data)
    database.close()
示例#4
0
def location_data(lat, lon, radius):
    database.connect()
    # NOTE: the "radius" is a square threshold, not circular
    query = TruckData.select()
    query = query.where(TruckData.latitude > lat - radius)
    query = query.where(TruckData.latitude < lat + radius)
    query = query.where(TruckData.longitude > lon - radius)
    query = query.where(TruckData.longitude < lon + radius)
    query = query.order_by(TruckData.timestamp.desc())
    data = [d.get_default_dict() for d in query]
    return json.dumps(data)
    database.close()
示例#5
0
def recent_data():
    database.connect()
    collected = []
    for truck, points in json.loads(request.data).iteritems():
        for time, coords in points.iteritems():
            new = TruckData()
            new.timestamp = float(time)
            new.truck_id = int(truck)
            new.latitude = float(coords[0])
            new.longitude = float(coords[1])
            new.save()
            collected.append(new)

    database.close()
    return "success"
def recent_data():
    database.connect()
    collected = []
    for truck, points in json.loads(request.data).iteritems():
        for time, coords in points.iteritems():
            new = TruckData()
            new.timestamp = float(time)
            new.truck_id = int(truck)
            new.latitude = float(coords[0])
            new.longitude = float(coords[1])
            new.save()
            collected.append(new)

    database.close()
    return "success"
示例#7
0
def all_data():
    database.connect()
    query = TruckData.select().order_by(TruckData.timestamp.desc())
    data = [d.get_default_dict() for d in query]
    return json.dumps(data)
    database.close()
示例#8
0
def all_data():
    database.connect()
    query = TruckData.select().order_by(TruckData.timestamp.desc())
    data = [d.get_default_dict() for d in query]
    return json.dumps(data)
    database.close()