示例#1
0
def get_trs_by_region_id(region_id):
    region = region_svc.get(region_id)
    area = json.loads(region['area'])[0]['point']
    points = [[float(p.split(',')[1]), float(p.split(',')[0])] for p in area]
    points.append(points[0])

    polygon = {'type': 'Polygon', 'coordinates': [points]}

    area_json = geojson_to_wkbelement(json.dumps(polygon))
    log.info('area_json: {}'.format(area_json))
    daily_trs = inner.get_order_transaction(region['city_id'], area_json)
    if not daily_trs:
        daily_trs = 0.0
    daily_amount = float(daily_trs) / 7.0

    return {
        'id': region_id,
        'name': region['name'],
        'trs': round(daily_amount, 2),
    }
示例#2
0
def get_trs_by_region_id(region_id):
    region = region_svc.get(region_id)
    area = json.loads(region['area'])[0]['point']
    points = [[float(p.split(',')[1]), float(p.split(',')[0])]
              for p in area]
    points.append(points[0])

    polygon = {'type': 'Polygon', 'coordinates': [points]}

    area_json = geojson_to_wkbelement(json.dumps(polygon))
    log.info('area_json: {}'.format(area_json))
    daily_trs = inner.get_order_transaction(region['city_id'], area_json)
    if not daily_trs:
        daily_trs = 0.0
    daily_amount = float(daily_trs) / 7.0

    return {
        'id': region_id,
        'name': region['name'],
        'trs': round(daily_amount, 2),
    }
示例#3
0
def get_order_trs_by_area(city_id, area):
    city_trs_cfg = _get_city_trs_cfg(city_id)

    date_from = city_trs_cfg['date_from']
    date_end = city_trs_cfg['date_end']

    points = [[float(p.split(',')[0]), float(p.split(',')[1])]
              for p in area]
    points.append(points[0])

    polygon = {'type': 'Polygon', 'coordinates': [points]}

    area_json = geojson_to_wkbelement(json.dumps(polygon))
    daily_trs = inner.get_order_transaction(city_id, area_json)
    if not daily_trs:
        daily_trs = 0.0
    daily_amount = float(daily_trs) / 7.0

    log.info('daily_amount: {}'.format(daily_amount))
    return {'daily_amount': daily_amount,
            'date_from': date_from,
            'date_end': date_end}
示例#4
0
def get_order_trs_by_area(city_id, area):
    city_trs_cfg = _get_city_trs_cfg(city_id)

    date_from = city_trs_cfg['date_from']
    date_end = city_trs_cfg['date_end']

    points = [[float(p.split(',')[0]), float(p.split(',')[1])] for p in area]
    points.append(points[0])

    polygon = {'type': 'Polygon', 'coordinates': [points]}

    area_json = geojson_to_wkbelement(json.dumps(polygon))
    daily_trs = inner.get_order_transaction(city_id, area_json)
    if not daily_trs:
        daily_trs = 0.0
    daily_amount = float(daily_trs) / 7.0

    log.info('daily_amount: {}'.format(daily_amount))
    return {
        'daily_amount': daily_amount,
        'date_from': date_from,
        'date_end': date_end
    }