def get(self): """ Returns supported parking permits for a given city """ args = permits_parser.parse_args() return City.get_permits(args['city'], args['residential'] in ['true', 'True', True]), 200
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 get_reports(): """ Get a list of reports """ city = request.args.get('city', 'montreal') reports = City.get_reports(city) return jsonify(reports=reports), 200
def get_corrections(): """ Get all corrections made on slots by city """ city = request.args.get('city', 'montreal') corrs = City.get_corrections(city) return jsonify(corrections=corrs), 200
def get_checkins(): """ Get a list of checkins """ city = request.args.get('city', 'montreal') start = request.args.get('start') end = request.args.get('end') checkins = City.get_checkins(city, start, end) return jsonify(checkins=checkins), 200
def post(self): """Submit a report about incorrect data""" args = report_parser.parse_args() city = args["city"] if not args["city"]: city = City.get(args['longitude'], args['latitude']) Reports.add(g.user.id, city, args.get("slot_id", None), args["longitude"], args["latitude"], args.get("image_url", ""), args.get("notes", "")) return "Resource created", 201
def get(self): """ Returns coverage area package versions and metadata """ res = City.get_assets() return { "latest_version": max([x["version"] for x in res]), "versions": {x["version"]: x for x in res} }, 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
def get(self): """ Returns coverage area information """ return City.get_all(), 200