def get(self): """ Return carshare lots and data around the point defined by (x, y) """ args = carshare_parser.parse_args() city = City.get(args['longitude'], args['latitude']) if not city: api.abort(404, "no feature found") res = Carshares.get_lots_within(city, args['longitude'], args['latitude'], args['radius'], args['company'] or False) if not res and args["nearest"]: res = Carshares.get_lots_nearest(city, args["longitude"], args["latitude"], args["nearest"], args['company'] or False) return FeatureCollection([ Feature(id=feat[0], geometry=feat[1], properties={ field: feat[num] for num, field in enumerate( Carshares.lot_properties[2:], start=2) }) for feat in res ]), 200
def get(self): """ Returns slots around the point defined by (x, y) """ args = slots_parser.parse_args() args['compact'] = args['compact'] not in ['false', 'False', False] args['carsharing'] = args['carsharing'] not in [ 'false', 'False', False ] # push map search data to analytics Analytics.add_pos_tobuf("slots", g.user.id, args["latitude"], args["longitude"], args["radius"]) city = City.get(args['longitude'], args['latitude']) if not city: api.abort(404, "no feature found") res = Slots.get_within(city, args['longitude'], args['latitude'], args['radius'], args['duration'], slot_props, args['checkin'], args['permit'], args['carsharing']) return FeatureCollection([ Feature(id=feat['id'], geometry=feat['geojson'], properties=cpt_props(feat) if args['compact'] else nrm_props(feat)) for feat in res ]), 200
def post(self): """ Add a new checkin """ args = post_checkin_parser.parse_args() res = Checkins.add(g.user.id, args['slot_id']) if not res: api.abort(404, "No slot existing with this id") return res, 201
def get(self, id): """ Returns the parking slot corresponding to the id """ res = Slots.get_byid(id, slot_props) if not res: api.abort(404, "feature not found") res = res[0] return Feature(id=res[0], geometry=res[1], properties={ field: res[num] for num, field in enumerate(slot_props[2:], start=2) }), 200
def get(self, id): """ Returns the parking slot corresponding to the id """ args = slot_parser.parse_args() args['filter'] = args['filter'] not in ['false', 'False', False] res = Slots.get_byid(id, slot_props, args['filter'], args['checkin'], args['permit']) if not res: api.abort(404, "feature not found") res = res[0] return Feature(id=res[0], geometry=res[1], properties={ field: res[num] for num, field in enumerate(slot_props[2:], start=2) }), 200
def get(self): """ Return parking lots and garages around the point defined by (x, y) """ args = parking_lot_parser.parse_args() if not args.get("latitude") and not args.get( "longitude") and not args.get("partner_id"): return "Requires either lat/long or partner_id", 400 if args.get("partner_id"): res = ParkingLots.get_bypartnerid(args.get("partner_name"), args["partner_id"]) else: # push map search data to analytics Analytics.add_pos_tobuf("lots", g.user.id, args["latitude"], args["longitude"], args["radius"]) city = City.get(args['longitude'], args['latitude']) if not city: api.abort(404, "no feature found") res = ParkingLots.get_within(args["longitude"], args["latitude"], args["radius"]) if not res and args["nearest"]: res = ParkingLots.get_nearest(args["longitude"], args["latitude"], args["nearest"]) return FeatureCollection([ Feature(id=feat[0], geometry=feat[1], properties={ field: feat[num] for num, field in enumerate(ParkingLots.properties[2:], start=2) }) for feat in res ]), 200
def get(self): """ Returns slots around the point defined by (x, y) """ args = slot_parser.parse_args() city = City.get(args['longitude'], args['latitude']) if not city: api.abort(404, "no feature found") res = Slots.get_within(city, args['longitude'], args['latitude'], args['radius'], args['duration'], slot_props, args['checkin'], args['permit'] in ['false', False], args['permit'] == 'all') return FeatureCollection([ Feature(id=feat['id'], geometry=feat['geojson'], properties={ "button_location": feat["button_location"], "rules": feat["rules"], "way_name": feat["way_name"] }) for feat in res ]), 200