홍용민

남은 시간 예측 기능 model로 옮김

...@@ -64,6 +64,7 @@ for(var i=0; i<routeID.length; i++){ ...@@ -64,6 +64,7 @@ for(var i=0; i<routeID.length; i++){
64 const GateBusUrl = bus_url + '?servicekey=' + process.env.key + '&stationId=' + gateStationID; //국제캠 정문 정류장 64 const GateBusUrl = bus_url + '?servicekey=' + process.env.key + '&stationId=' + gateStationID; //국제캠 정문 정류장
65 let date = new Date(); 65 let date = new Date();
66 let predictTime = ['-1', '-1', '-1', '-1']; 66 let predictTime = ['-1', '-1', '-1', '-1'];
67 +let body = new Object();
67 68
68 function predict(){ 69 function predict(){
69 console.log(GateBusUrl); 70 console.log(GateBusUrl);
...@@ -95,6 +96,25 @@ function predict(){ ...@@ -95,6 +96,25 @@ function predict(){
95 Bus[index]["MaxPredictTime"] = predictHour2 + ":" + predictMinute2; 96 Bus[index]["MaxPredictTime"] = predictHour2 + ":" + predictMinute2;
96 97
97 predictTime = [predictHour1 + "", predictMinute1 + "", predictHour2 + "", predictMinute2 + ""] 98 predictTime = [predictHour1 + "", predictMinute1 + "", predictHour2 + "", predictMinute2 + ""]
99 +
100 + const dateBusDeparture = new Date(date.getFullYear(), date.getMonth(), date.getDate(), predictTime[0]*1, predictTime[1]*1, 0);
101 +
102 + var gapSec = (dateBusDeparture.getTime() - date.getTime())/1000;
103 + var gapHour = Math.floor(gapSec / 60 / 60);
104 + var gapMin = Math.floor((gapSec - gapHour * 3600) / 60);
105 +
106 + // var ans = gapHour + "시간" + gapMin + "분 이상";
107 +
108 + // var ETD_min_H = predictTime[0];
109 + // var ETD_min_M = predictTime[1];
110 + // var ETD_max_H = predictTime[2];
111 + // var ETD_max_M = predictTime[3];
112 +
113 + body.remainTime = gapHour + "시간" + gapMin + "분 이상";
114 + body.ETD_min_H = predictTime[0];
115 + body.ETD_min_M = predictTime[1];
116 + body.ETD_max_H = predictTime[2];
117 + body.ETD_max_M = predictTime[3];
98 } 118 }
99 }) 119 })
100 }) 120 })
......