@@ -0,0 +1,1614 @@
+import pymongo%0Aimport datetime%0Aimport time%0A%0ANYC_POINTS = (74.258 - 73.700) * 1000 * (40.917 - 40.477) * 1000%0A%0Adb = pymongo.MongoClient().taxi%0Adb.trips.create_index(%5B('location', pymongo.GEO2D)%5D)%0A%0Adef get_better(time =datetime.datetime.now() ,location =  (-74.00594, 40.71278)):%0A    time = int(time.strftime('%25H')) * 60%0A    near = db.trips.aggregate(%5B%0A        %7B'$geoNear': %7B%0A            'near': location,%0A            'query' : %7B'time' : time%7D,%0A            'distanceField' : 'distance',%0A            'limit': 100%0A            %7D%0A        %7D,%0A        %7B'$sort': %7B%0A            'count': -1%0A           %7D%0A        %7D%0A    %5D)%0A    percent_loaded = float(db.trips.count())/12748987%0A    return %5B%7B%0A        'location': i%5B'location'%5D,%0A        'distance': i%5B'distance'%5D,%0A        'hour' : float(i%5B'time'%5D)/60,%0A        'time': i%5B'time'%5D,%0A        'avg': (float(i%5B'count'%5D)/(24*31))/percent_loaded%0A        %7D%0A        for i in near%5D%0A%0Adef get_prediction(time =datetime.datetime.now() ,location =  (-74.00594, 40.71278)):%0A    time = int(time.strftime('%25H')) * 60%0A    near = db.trips.find(%0A            %7B%0A            'location': %7B'$near': location%7D,%0A            'time' : time%0A            %7D%0A    ).limit(1)%0A    return %5B%7B%0A        'location': i%5B'location'%5D,%0A        'hour' : float(i%5B'time'%5D)/60,%0A        'time': i%5B'time'%5D,%0A        'avg': (float(i%5B'count'%5D)/(24*31))/percent_loaded%0A        %7D%0A        for i in near%5D%0A%0A%0Aprint location%0Aprint get_prediction()%5B0%5D, get_near()%5B0%5D%0A%0Aprint get_near(time=datetime.datetime.now() + datetime.timedelta(hours=6))%5B0%5D%0Aprint get_near(location=(-73.9935,40.75057))%5B0%5D%0A%0A%0Aprint get_near(location=(-73.99717, 40.73695))%5B0%5D%0A%0A

Add server file