Example #1
0
def search():
    journals = Journal.query.all()
    form = SearchForm(request.form)

    if request.method == 'POST' and form.validate():
        keyword = form.keyword.data
    return render_template('search/search.html', journals=journals, form=form)
Example #2
0
def search():
    albums = Album.query.all()
    artists = Artist.query.all()
    form = SearchForm(request.form)

    if request.method == 'POST' and form.validate():
        keyword = form.keyword.data
    return render_template('search/search.html', albums=albums, artists=artists, form=form)
Example #3
0
def search():
    form = SearchForm(request.form)
    map = None
    if request.method == 'POST' and form.validate():
        from flask_googlemaps import GoogleMaps, Map
        devices_data = {}  # dict to store data of devices
        devices_location = {}  # dict to store coordinates of devices
        # json_data = request.get_json(silent=True)
        # get json request
        kensa = form.kensa.data
        chiryo = form.chiryo.data
        shikkan = form.shikkan.data
        area = form.area.data
        from_time = form.from_time.data
        to_time = form.to_time.data
        hospital = Hospitals.query.first()
        json_data = {  # for testing
            'user': {
                'x': 35.94149,
                'y': 139.771598
            },
            'devices': [{
                'id': '0001',
                'x': hospital.latitude,
                'y': hospital.longitude,
                'data': 'something'
            }]
        }

        user_location = (json_data['user']['x'], json_data['user']['y'])
        # json example : { 'user' : { 'x' : '300' , 'y' : '300' } }
        # get user_location from json & store as turple (x, y)

        devices_data[str(
            json_data['devices'][0]['id'])] = (json_data['devices'][0]['data'])

        devices_location[str(
            json_data['devices'][0]['id'])] = (json_data['devices'][0]['x'],
                                               json_data['devices'][0]['y'])
        # json example : { 'devices' : { 'id' : '0001', x' : '500', 'y' : '500' }, { ... } }
        # get device_location from json & store turple (x, y) in dictionary with device id as key
        # use for statements or something to get more locations from more devices

        circle = {  # draw circle on map (user_location as center)
            'stroke_color': '#0000FF',
            'stroke_opacity': .5,
            'stroke_weight': 5,
            # line(stroke) style
            'fill_color': '#FFFFFF',
            'fill_opacity': .2,
            # fill style
            'center': {  # set circle to user_location
                'lat': user_location[0],
                'lng': user_location[1]
            },
            'radius': 100  # circle size (50 meters)
        }

        map = Map(
            identifier="map",
            varname="map",
            # set identifier, varname
            lat=user_location[0],
            lng=user_location[1],
            # set map base to user_location
            zoom=12,  # set zoomlevel
            markers=[{
                'lat': devices_location['0001'][0],
                'lng': devices_location['0001'][1],
                'infobox': devices_data['0001']
            }],
            # set markers to location of devices
            circles=[circle]  # pass circles
        )

        return render_template('search.html',
                               map=map,
                               form=form,
                               hospital=hospital)
    return render_template('search.html', form=form)