示例#1
0
文件: v1.py 项目: prkng/api
 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
示例#2
0
文件: v1.py 项目: prkng/api
    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
示例#3
0
文件: v1.py 项目: prkng/api
    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
示例#4
0
文件: admin.py 项目: prkng/api
def get_reports():
    """
    Get a list of reports
    """
    city = request.args.get('city', 'montreal')
    reports = City.get_reports(city)
    return jsonify(reports=reports), 200
示例#5
0
文件: admin.py 项目: prkng/api
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
示例#6
0
文件: admin.py 项目: prkng/api
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
示例#7
0
文件: v1.py 项目: prkng/api
 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
示例#8
0
文件: v1.py 项目: prkng/api
    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
示例#9
0
文件: v1.py 项目: prkng/api
    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
示例#10
0
文件: v0.py 项目: prkng/api
    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
示例#11
0
文件: v1.py 项目: prkng/api
 def get(self):
     """
     Returns coverage area information
     """
     return City.get_all(), 200