SOURCE

var canvasData = [{ "outDirec": "", "outlanewidth": "3.5", "bufferType": 3, "roadName": "解放路", "exitNum": "2", "bufferWidth": "0.5", "entranceNum": "2", "inlanetype": ["e45", "e35"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [""], "reWalk": "0", "roadWidth": 19 }, { "exitNum": "3", "outDirec": "", "bufferWidth": "0.5", "entranceNum": "3", "outlanewidth": "3.5", "bufferType": "1", "inlanetype": ["e05", "e05", "e05"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [], "reWalk": 0, "roadName": "" }, { "outDirec": "", "outlanewidth": "3.5", "bufferType": 3, "roadName": "环城西路", "exitNum": "3", "bufferWidth": "0.5", "entranceNum": "3", "inlanetype": ["e45", "e05", "e75"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [""], "reWalk": "0", "roadWidth": 26 }, { "exitNum": "3", "outDirec": "", "bufferWidth": "0.5", "entranceNum": "3", "outlanewidth": "3.5", "bufferType": "1", "inlanetype": ["e05", "e05", "e05"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [], "reWalk": 0, "roadName": "" }, { "outDirec": "", "outlanewidth": "3.5", "bufferType": 3, "roadName": "解放路", "exitNum": "2", "bufferWidth": "0.5", "entranceNum": "2", "inlanetype": ["e25", "e35"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [""], "reWalk": "0", "roadWidth": 19 }, { "exitNum": "3", "outDirec": "", "bufferWidth": "0.5", "entranceNum": "3", "outlanewidth": "3.5", "bufferType": "1", "inlanetype": ["e05", "e05", "e05"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [], "reWalk": 0, "roadName": "" }, { "outDirec": "", "outlanewidth": "3.5", "bufferType": 3, "roadName": "环城西路", "exitNum": "3", "bufferWidth": "0.5", "entranceNum": "3", "inlanetype": ["e45", "e05", "e75"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [""], "reWalk": "0", "roadWidth": 26 }, { "exitNum": "3", "outDirec": "", "bufferWidth": "0.5", "entranceNum": "3", "outlanewidth": "3.5", "bufferType": "1", "inlanetype": ["e05", "e05", "e05"], "entranceWidth": "3.5", "footwalk": true, "mergeLine": [], "reWalk": 0, "roadName": "" }, [1, 3, 5, 7], "3101201061", 115, [{ "data": [{ "lane_type": 1, "in_lane_arrowdir": "e46", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 0, "lane_id": 1, "lane_direction": 1, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 2, "turn_around": 0, "str_ahead_per": 50, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 50, "id": 0, "traffic_capacity": 900 }, { "lane_type": 1, "in_lane_arrowdir": "e36", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 50, "lane_id": 2, "lane_direction": 1, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 1, "turn_around": 0, "str_ahead_per": 50, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 0, "id": 1, "traffic_capacity": 900 }], "id": 1 }, { "data": [{ "lane_type": 1, "in_lane_arrowdir": "e46", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 0, "lane_id": 3, "lane_direction": 3, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 3, "turn_around": 0, "str_ahead_per": 50, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 50, "id": 0, "traffic_capacity": 900 }, { "lane_type": 1, "in_lane_arrowdir": "e06", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 0, "lane_id": 4, "lane_direction": 3, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 2, "turn_around": 0, "str_ahead_per": 100, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 0, "id": 1, "traffic_capacity": 1200 }, { "lane_type": 1, "in_lane_arrowdir": "e76", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 50, "lane_id": 5, "lane_direction": 3, "turn_around_per": 50, "ahead_right": 0, "is_shortlane": 0, "lane_no": 1, "turn_around": 0, "str_ahead_per": 0, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 0, "id": 2, "traffic_capacity": 700 }], "id": 3 }, { "data": [{ "lane_type": 1, "in_lane_arrowdir": "e26", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 0, "lane_id": 6, "lane_direction": 5, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 2, "turn_around": 0, "str_ahead_per": 0, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 100, "id": 0, "traffic_capacity": 800 }, { "lane_type": 1, "in_lane_arrowdir": "e36", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 50, "lane_id": 7, "lane_direction": 5, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 1, "turn_around": 0, "str_ahead_per": 50, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 0, "id": 1, "traffic_capacity": 900 }], "id": 5 }, { "data": [{ "lane_type": 1, "in_lane_arrowdir": "e46", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 0, "lane_id": 8, "lane_direction": 7, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 3, "turn_around": 0, "str_ahead_per": 50, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 50, "id": 0, "traffic_capacity": 900 }, { "lane_type": 1, "in_lane_arrowdir": "e06", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 0, "lane_id": 9, "lane_direction": 7, "turn_around_per": 0, "ahead_right": 0, "is_shortlane": 0, "lane_no": 2, "turn_around": 0, "str_ahead_per": 100, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 0, "id": 1, "traffic_capacity": 1200 }, { "lane_type": 1, "in_lane_arrowdir": "e76", "in_out_type": 0, "lane_width": 3.5, "lane_lenth": 50, "turn_left_per": 50, "lane_id": 10, "lane_direction": 7, "turn_around_per": 50, "ahead_right": 0, "is_shortlane": 0, "lane_no": 1, "turn_around": 0, "str_ahead_per": 0, "waitarea_lenth": 0, "is_wait": 0, "turn_right_per": 0, "id": 2, "traffic_capacity": 700 }], "id": 7 }]];
var crowdData = { "code": 200, "message": "成功", "data": [{ "COUNTTIME": 1697090736000, "CROWDINDEX": 1, "CROSSID": "3101201061", "LANENO": 18, "DIRECTION": "5" }, { "COUNTTIME": 1697090736000, "CROWDINDEX": 1, "CROSSID": "3101201061", "LANENO": 20, "DIRECTION": "5" }, { "COUNTTIME": 1697090736000, "CROWDINDEX": 1, "CROSSID": "3101201061", "LANENO": 19, "DIRECTION": "5" }, { "COUNTTIME": 1697090736000, "CROWDINDEX": 1, "CROSSID": "3101201061", "LANENO": 14, "DIRECTION": "7" }], "timestamp": 1697090787563 };
crowdData = crowdData.data;

var crowdDitToCavDir = {
    1: 6, 2: 7, 3: 0, 4: 1, 5: 2, 6: 3, 7: 4, 8: 5
}

for(var i=0;y<crowdData.length;y++){
    var cditem = crowdData[y];
    // 转为画图dir
    var canvasdirection = crowdDitToCavDir[cditem.direction];
    
}
console 命令行工具 X clear

                    
>
console