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 get_slots(): """ Returns slots inside a boundbox """ res = Slots.get_boundbox( request.args['neLat'], request.args['neLng'], request.args['swLat'], request.args['swLng'], slot_props, request.args.get('checkin'), request.args.get('duration', 0.25), int(request.args.get('type', 0)), request.args.get('invert') in [True, "true"] ) if res == False: return jsonify(status="no feature found"), 404 props = ["id", "geojson", "button_locations", "restrict_types"] slots = [ {field: row[field] for field in props} for row in res ] return jsonify(slots=slots), 200
def get_slot(id): """ Returns data on a specific slot """ res = Slots.get_byid(id, slot_props) if not res: return jsonify(status="feature not found"), 404 slot = {field: res[0][num] for num, field in enumerate(slot_props)} return jsonify(slot=slot), 200
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): """ 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