Пример #1
0
def localize():
    image = request.files['image']
    estimate = hulop.localize_image(image, request.form['user'], request.form['map'])
    image.stream.seek(0)
    image.save(os.path.join('./images', image.filename))
    if estimate:
        return json.dumps({'location': estimate})
    else:
        return json.dumps({'error': 'could not localize'}), 400
Пример #2
0
def localize():
    image = request.files['image']
    estimate = hulop.localize_image(image, request.form['user'],
                                    request.form['map'])
    image.stream.seek(0)
    image.save(os.path.join('./images', image.filename))
    if estimate:
        return json.dumps({'location': estimate})
    else:
        return json.dumps({'error': 'could not localize'}), 400
Пример #3
0
def create_message():
    estimate = hulop.localize_image(request.files['image'],
                                    request.form['user'], request.form['map'])
    if estimate:
        loc = estimate['t']
        new_id = database.insert(
            'hotspot_messages', ('message', 'x', 'y', 'z'),
            (request.form['message'], loc[0], loc[1], loc[2]))
        hotspot = database.query('select * from hotspot_messages where id=?',
                                 [new_id],
                                 one=True)
        return json.dumps(hotspot), 201
    else:
        return json.dumps({'error': 'could not localize'}), 400
Пример #4
0
def create_message():
    estimate = hulop.localize_image(
        request.files['image'],
        request.form['user'],
        request.form['map']
    )
    if estimate:
        loc = estimate['t']
        new_id = database.insert(
            'hotspot_messages',
            ('message','x','y','z'),
            (request.form['message'], loc[0], loc[1], loc[2])
        )
        hotspot = database.query('select * from hotspot_messages where id=?', [new_id], one=True)
        return json.dumps(hotspot), 201
    else:
        return json.dumps({'error': 'could not localize'}), 400
Пример #5
0
def nearby():
    estimate = hulop.localize_image(
        request.files['image'],
        request.form['user'],
        request.form['map']
    )
    if estimate:
        loc = estimate['t']
        results = []
        radius = request.form['radius']
        for h in database.query('select * from hotspots'):
            h_loc = (h['x'],h['y'],h['z'])
            if util.dist(loc[:2], h_loc[:2]) < radius:
                direction = util.clockwise(estimate['t'], estimate['R'], h_loc)
                results.append({'description': h['category'], 'direction': direction})
        return json.dumps({'location':estimate, 'nearby':results})
    else:
        return json.dumps({'error': 'could not localize'}), 400
Пример #6
0
def nearby():
    estimate = hulop.localize_image(request.files['image'],
                                    request.form['user'], request.form['map'])
    if estimate:
        loc = estimate['t']
        results = []
        radius = request.form['radius']
        for h in database.query('select * from hotspots'):
            h_loc = (h['x'], h['y'], h['z'])
            if util.dist(loc[:2], h_loc[:2]) < radius:
                direction = util.clockwise(estimate['t'], estimate['R'], h_loc)
                results.append({
                    'description': h['category'],
                    'direction': direction
                })
        return json.dumps({'location': estimate, 'nearby': results})
    else:
        return json.dumps({'error': 'could not localize'}), 400