곽태식

예보 api 추가및 merge오류 삭제

...@@ -25,7 +25,7 @@ app.use('/',express.static(path.join(__dirname, 'code'))); ...@@ -25,7 +25,7 @@ app.use('/',express.static(path.join(__dirname, 'code')));
25 app.use('/Cname/:Cname/Cbirth',express.static(path.join(__dirname, 'public'))); 25 app.use('/Cname/:Cname/Cbirth',express.static(path.join(__dirname, 'public')));
26 app.use('/Cname/:Cname/Cbirth',express.static(path.join(__dirname, 'code'))); 26 app.use('/Cname/:Cname/Cbirth',express.static(path.join(__dirname, 'code')));
27 app.use('/Fname/:Fname/Fbirth',express.static(path.join(__dirname, 'newpublic'))); 27 app.use('/Fname/:Fname/Fbirth',express.static(path.join(__dirname, 'newpublic')));
28 -app.use('/Cname/:Cname/Cbirth',express.static(path.join(__dirname, 'newcode'))); 28 +app.use('/Fname/:Fname/Fbirth',express.static(path.join(__dirname, 'newcode')));
29 29
30 30
31 app.use('/', indexRouter); 31 app.use('/', indexRouter);
......
1 const db = require('./db.js'); 1 const db = require('./db.js');
2 const secret_key = require('../keys/api_option').weather_key; 2 const secret_key = require('../keys/api_option').weather_key;
3 -const traffic_key = require('../keys/api_option').traffic_key; 3 +//const traffic_key = require('../keys/api_option').traffic_key;
4 const requesting = require('request'); 4 const requesting = require('request');
5 const lat = "37.239795"; 5 const lat = "37.239795";
6 const lon = "127.083240"; 6 const lon = "127.083240";
...@@ -56,27 +56,27 @@ module.exports = (server, app) => { ...@@ -56,27 +56,27 @@ module.exports = (server, app) => {
56 } 56 }
57 57
58 // 교통사고정보를 받아오는 함수 58 // 교통사고정보를 받아오는 함수
59 - const req_traffic_API = (year) => { 59 +// const req_traffic_API = (year) => {
60 //async await 사용하기 위하여 promise 사용 60 //async await 사용하기 위하여 promise 사용
61 - return new Promise((resolve, reject) => { 61 +// return new Promise((resolve, reject) => {
62 - requesting.get({ 62 +// requesting.get({
63 - // api를 요청할 주소 -- 시크릿키,위도,경도 입력 63 +// // api를 요청할 주소 -- 시크릿키,위도,경도 입력
64 - url: `http://taas.koroad.or.kr/data/rest/accident/death?authKey=${traffic_key}&searchYear=${year}&siDo=${city}&guGun=${town}&type=json`, 64 +// url: `http://taas.koroad.or.kr/data/rest/accident/death?authKey=${traffic_key}&searchYear=${year}&siDo=${city}&guGun=${town}&type=json`,
65 - json: true 65 +// json: true
66 - }, 66 +// },
67 - //api에게 응답 받았을때 실행되는 callback function 67 +// //api에게 응답 받았을때 실행되는 callback function
68 - function (err, api_res, api_body) { 68 +// function (err, api_res, api_body) {
69 - //err 존재시 promise reject 호출 69 +// //err 존재시 promise reject 호출
70 - if (err) reject(err); 70 +// if (err) reject(err);
71 - 71 +//
72 - // api의 response이 있을경우 promise resolve 호출 72 +// // api의 response이 있을경우 promise resolve 호출
73 - if (api_res) { 73 +// if (api_res) {
74 - console.log("calling traffic api"); 74 +// console.log("calling traffic api");
75 - resolve(api_body); 75 +// resolve(api_body);
76 - } 76 +// }
77 - }); 77 +// });
78 - }) 78 +// })
79 - } 79 +// }
80 const API_bundle = async () => { 80 const API_bundle = async () => {
81 81
82 try { 82 try {
...@@ -89,8 +89,8 @@ module.exports = (server, app) => { ...@@ -89,8 +89,8 @@ module.exports = (server, app) => {
89 Day3_Weather = await req_API("forecast","3days"); //3일예보(단기예보) 89 Day3_Weather = await req_API("forecast","3days"); //3일예보(단기예보)
90 90
91 // 사용자의 생일에 따라서 다른 년도의 교통사고정보를 가져옴. 91 // 사용자의 생일에 따라서 다른 년도의 교통사고정보를 가져옴.
92 - const year = year_start + (client_birth % (year_range+1)); 92 +// const year = year_start + (client_birth % (year_range+1));
93 - Traffic_Accident = await req_traffic_API(year); //교통사고정보 93 +// Traffic_Accident = await req_traffic_API(year); //교통사고정보
94 94
95 95
96 info = { 96 info = {
...@@ -107,12 +107,22 @@ module.exports = (server, app) => { ...@@ -107,12 +107,22 @@ module.exports = (server, app) => {
107 typhoon: Current_Weather.common.stormYn, //현재 태풍 107 typhoon: Current_Weather.common.stormYn, //현재 태풍
108 time: Current_Weather.weather.minutely[0].timeObservation, // 불러온 시각 108 time: Current_Weather.weather.minutely[0].timeObservation, // 불러온 시각
109 109
110 - Forecast_3D: Day3_Weather.weather.forecast3days[0].fcst3hour.wind.wspd64hour, 110 + Forecast_64W: Day3_Weather.weather.forecast3days[0].fcst3hour.wind.wspd61hour,
111 - traffic: Traffic_Accident.totalCount, // 교통사고 발생횟수 111 + Forecast_25W: Day3_Weather.weather.forecast3days[0].fcst3hour.wind.wspd25hour,
112 + Forecast_46W: Day3_Weather.weather.forecast3days[0].fcst3hour.wind.wspd46hour,
113 +
114 + Forecast_25R: Day3_Weather.weather.forecast3days[0].fcst3hour.precipitation.prob25hour,
115 + Forecast_46R: Day3_Weather.weather.forecast3days[0].fcst3hour.precipitation.prob46hour,
116 + Forecast_64R: Day3_Weather.weather.forecast3days[0].fcst3hour.precipitation.prob64hour,
117 +
118 + Forecast_25S: Day3_Weather.weather.forecast3days[0].fcst3hour.sky.code25hour,
119 + Forecast_46S: Day3_Weather.weather.forecast3days[0].fcst3hour.sky.code46hour,
120 + Forecast_64S: Day3_Weather.weather.forecast3days[0].fcst3hour.sky.code64hour,
121 +// traffic: Traffic_Accident.totalCount, // 교통사고 발생횟수
112 death_prob: 0 //확률 122 death_prob: 0 //확률
113 } 123 }
114 console.log("API INFO \n", info); 124 console.log("API INFO \n", info);
115 - console.log("Traffic count:", info.traffic); 125 +// console.log("Traffic count:", info.traffic);
116 126
117 127
118 128
...@@ -130,7 +140,7 @@ module.exports = (server, app) => { ...@@ -130,7 +140,7 @@ module.exports = (server, app) => {
130 //죽을 확률 계산(내맘대로 커스텀) 140 //죽을 확률 계산(내맘대로 커스텀)
131 info.death_prob = ( 141 info.death_prob = (
132 (info.heat / 50) + (Math.abs(info.sensible_temperature - 15) / 10) + (info.discomport / 10) + (info.UV / 10) 142 (info.heat / 50) + (Math.abs(info.sensible_temperature - 15) / 10) + (info.discomport / 10) + (info.UV / 10)
133 - + info.windspd*1 + (info.rain / 10) + (Math.abs(info.current_temperature - 15) / 10) + (info.traffic / 5) 143 + + info.windspd*1 + (info.rain / 10) + (Math.abs(info.current_temperature - 15) / 10) //+ (info.traffic / 5)
134 ); 144 );
135 145
136 //이벤트 기반으로 일정 시간 간격으로 클라이언트에게 보낼 정보 146 //이벤트 기반으로 일정 시간 간격으로 클라이언트에게 보낼 정보
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
38 <script src="highcharts.js"></script> 38 <script src="highcharts.js"></script>
39 <script src="modules/exporting.js"></script> 39 <script src="modules/exporting.js"></script>
40 <script src="modules/export-data.js"></script> 40 <script src="modules/export-data.js"></script>
41 - <script src="kts.js"></script> 41 +
42 <img src="images/indexWallpaper.jpg" alt="" style="z-index:-1; min-width: 100%; min-height: 100%"width="50%" height="100%"> 42 <img src="images/indexWallpaper.jpg" alt="" style="z-index:-1; min-width: 100%; min-height: 100%"width="50%" height="100%">
43 43
44 <div id="banner" > 44 <div id="banner" >
......