def entry_results(): deplat = float(request.form['deplat']) deplon = float(request.form['deplon']) arrlat = float(request.form['arrlat']) arrlon = float(request.form['arrlon']) drflag = int(request.form['drflag']) es_client = ElasticSearch("http://ec2-54-219-169-37.us-west-1.compute.amazonaws.com:9200") producer = matchRides(es_client,'messages','myMessages',[deplat,deplon],[arrlat,arrlon],drflag) result = producer.matching() print "----------------------" geosmatch=[] if (result != 1): #found matching driver/rider (deplats,deplons,arrlats,arrlons,dist,mid,phone) = result geosmatch = [{"messageid": mid[ind], "phone": str(phone[ind]), "deplat": deplats[ind], "deplon": deplons[ind], "arrlat": arrlats[ind], "arrlon": arrlons[ind], "distance": dist[ind]} for ind in range(len(deplats))] geosmatch.append({"messageid": 0, "phone": '1-000-000-0000', "deplat": deplat, "deplon": deplon, "arrlat": arrlat, "arrlon": arrlon, "distance": [0,0]}) print geosmatch return render_template('map.html',geosmatch=geosmatch) else: return render_template("confirm.html", message = "Sorry, no nearby drivers/riders available")
def simulating(self): producer = matchRides(self.client,self.index,self.type,self.deplocation,self.arrlocation,self.drflag) result = producer.matching() if (result != 1): #found matching drivers/riders (deplats,deplons,arrlats,arrlons,dist,messageid,phone) = result #randomly pick up a user pickup=random.choice(range(len(deplats))) print "picking up driver/rider %d" % pickup requestingProducer = mark4deletionByLatLon(self.client, self.index, self.type, self.deplocation[0], self.deplocation[1]) markid = requestingProducer.marking() #if the requesting rider/driver is still available, check whether the requested driver/rider is available. if markid != 1: requestedProducer = updateByMessageid(self.client, self.index, self.type, messageid[pickup]) success = requestedProducer.updating() if success == 1: print "The driver/rider isn't available anymore. Please select again!" else: self.client.delete(self.index, self.type, markid) print "Both driver and rider have been confirmed!" else: print "You have been selected by other driver/rider."