def my_nearby_endpoint(): input_json = request.get_json(force=True) # force=True, above, is necessary if another developer # forgot to set the MIME type to 'application/json' lat = float(input_json['lat']) lng = float(input_json['lng']) boop = Firebase() result = boop.getEveryonePoits((lat, lng)) return jsonify({"nearby": result})
def my_incidentheatmap_endpoint(): input_json = request.get_json(force=True) # force=True, above, is necessary if another developer # forgot to set the MIME type to 'application/json' lat = float(input_json['lat']) lng = float(input_json['lng']) boop = Firebase() result = boop.getCrazyHeat(lat, lng) return jsonify({"heatmap": result})
def my_data_event(): base = Firebase() input_json = request.get_json(force=True) data = [] for i in input_json: data.append((i["lat"], i["lng"])) res = base.getIncidents(data[0]) return jsonify({'incidents': res})
def my_update_endpoint(): input_json = request.get_json(force=True) # force=True, above, is necessary if another developer # forgot to set the MIME type to 'application/json' lat = float(input_json['lat']) lng = float(input_json['lng']) userId = str(input_json['type']) boop = Firebase() boop.addIncident(lat, lng, userId) return render_template('home.html')
def my_data(input_json): base = Firebase() data = [] for i in input_json: data.append((i["lat"], i["lng"])) #print(data) res = [] for i in range(len(data)): #print(base.getTraffic(data[i])) if i % 5 == 0: res.append(base.getTraffic(data[i])) if i % 5 != 0 and i == len(data) - 1: res.append(base.getTraffic((data[i]))) total = sum(res) traffic = total / len(res) return traffic
from authentication import Firebase boop = Firebase() incident_locations = [(41.835461, -87.624957), (41.835593, -87.624914), (41.835673, -87.625193), (41.835194, -87.625108), (41.835082, -87.624893), (60.70546, -43.810708), (90.709179, -53.820574)] locations = [(41.835461, -87.624957), (41.835593, -87.624914), (41.835673, -87.625193), (41.835194, -87.625108), (41.835082, -87.624893), (60.70546, -43.810708), (90.709179, -53.820574)] users = ["18","2","3","4","5","6","7"] #for y,i in enumerate(locations): #boop.addIncident(i[0], i[1],"trash") # test #print(boop.getIncidents((41.835461, -87.624957))) data = [(41.835461, -87.624957), (41.835593, -87.624914), (41.835673, -87.625193), (41.835194, -87.625108),