调整相对流量为单位小时流量
This commit is contained in:
parent
bf5e3c92b2
commit
1e46faa273
|
|
@ -577,3 +577,13 @@ def load_road_mapping(mapping_file: str):
|
|||
continue
|
||||
# 输出道路个数
|
||||
print(f"road_mapping_count: {len(g_road_mapping)}")
|
||||
|
||||
|
||||
def get_hours(start_str, end_str):
|
||||
# 分别提取小时和分钟并转为整数
|
||||
start_h, start_m = map(int, start_str.split(':'))
|
||||
end_h, end_m = map(int, end_str.split(':'))
|
||||
|
||||
# 直接相减计算总小时数
|
||||
total_hours = (end_h - start_h) + (end_m - start_m) / 60
|
||||
return total_hours
|
||||
|
|
|
|||
|
|
@ -401,16 +401,22 @@ def parse_cross_index_dict(delay_index_list, special_time_range, routing_crosses
|
|||
user_favorite_crosses = db_workstation.query_favorite_crosses(userid, nodeid, area_id)
|
||||
user_favorite_crosses = [item['favorite_id'] for item in user_favorite_crosses]
|
||||
cross_week_flow_dict = {}
|
||||
# 20260506 调整相对流量计算单位为单位小时流量
|
||||
for delay_index in delay_index_list:
|
||||
crossid = delay_index.crossid
|
||||
start_hm = delay_index.tp.start_hm
|
||||
end_hm = delay_index.tp.end_hm
|
||||
start_time, end_time = convert_time(start_hm), convert_time(end_hm)
|
||||
hours = get_hours(start_time, end_time)
|
||||
if crossid not in routing_crosses_dict.keys():
|
||||
continue
|
||||
weekdays = parse_wd_bitmap(delay_index.tp.weekday)
|
||||
key = '%s_%s' % (weekdays, crossid)
|
||||
hour_flow = delay_index.delay_info.car_num / hours if hours > 0 else 0
|
||||
if key not in cross_week_flow_dict.keys():
|
||||
cross_week_flow_dict[key] = delay_index.delay_info.car_num
|
||||
if key in cross_week_flow_dict.keys() and delay_index.delay_info.car_num > cross_week_flow_dict[key]:
|
||||
cross_week_flow_dict[key] = delay_index.delay_info.car_num
|
||||
cross_week_flow_dict[key] = hour_flow
|
||||
if key in cross_week_flow_dict.keys() and hour_flow > cross_week_flow_dict[key]:
|
||||
cross_week_flow_dict[key] = hour_flow
|
||||
for delay_index in delay_index_list:
|
||||
crossid = delay_index.crossid
|
||||
if crossid not in routing_crosses_dict.keys():
|
||||
|
|
@ -421,6 +427,7 @@ def parse_cross_index_dict(delay_index_list, special_time_range, routing_crosses
|
|||
if special_time_range != '' and not is_overlap_greater_than_one_hour(start_hm, end_hm, special_time_range):
|
||||
continue
|
||||
start_time, end_time = convert_time(start_hm), convert_time(end_hm)
|
||||
hours = get_hours(start_time, end_time)
|
||||
weekdays = parse_wd_bitmap(delay_index.tp.weekday)
|
||||
weekdays_str = gen_week_str({'weekday': weekdays})
|
||||
if date_type in ('weekend', 'workday'):
|
||||
|
|
@ -439,7 +446,8 @@ def parse_cross_index_dict(delay_index_list, special_time_range, routing_crosses
|
|||
if weekdays not in res[crossid]['delay_infos'].keys():
|
||||
res[crossid]['delay_infos'][weekdays] = []
|
||||
is_peak = 0 if not time_overlap(start_time + '-' + end_time, peak_tp) else 1
|
||||
relative_flow_rate = round(delay_index.delay_info.car_num / cross_week_flow_dict[weekdays + '_' + crossid], 2) if weekdays + '_' + crossid in cross_week_flow_dict.keys() and cross_week_flow_dict[weekdays + '_' + crossid] > 0 else 0
|
||||
item_hour_flow = delay_index.delay_info.car_num / hours if hours > 0 else 0
|
||||
relative_flow_rate = round(item_hour_flow / cross_week_flow_dict[weekdays + '_' + crossid], 2) if weekdays + '_' + crossid in cross_week_flow_dict.keys() and cross_week_flow_dict[weekdays + '_' + crossid] > 0 else 0
|
||||
delay_info = {
|
||||
'start_time': start_time,
|
||||
'end_time': end_time if end_time != '24:00' else '23:59',
|
||||
|
|
|
|||
Loading…
Reference in New Issue