DESKTOP-PC6TBNS\강환석씨

api calling advanced

1 { 1 {
2 "weather": { 2 "weather": {
3 - "minutely": [{ 3 + "minutely": [
4 - "station": { 4 + {
5 - "longitude": "127.1164", 5 + "station": {
6 - "latitude": "37.2772", 6 + "longitude": "127.1164",
7 - "name": "기흥구", 7 + "latitude": "37.2772",
8 - "id": "371", 8 + "name": "기흥구",
9 - "type": "KMA" 9 + "id": "371",
10 - }, 10 + "type": "KMA"
11 - "wind": { 11 + },
12 - "wdir": "189.50", 12 + "wind": {
13 - "wspd": "2.20" 13 + "wdir": "189.50",
14 - }, 14 + "wspd": "2.20"
15 - "precipitation": { 15 + },
16 - "sinceOntime": "0.00", 16 + "precipitation": {
17 - "type": "0" 17 + "sinceOntime": "0.00",
18 - }, 18 + "type": "0"
19 - "sky": { 19 + },
20 - "code": "SKY_A07", 20 + "sky": {
21 - "name": "흐림" 21 + "code": "SKY_A07",
22 - }, 22 + "name": "흐림"
23 - "rain": { 23 + },
24 - "sinceOntime": "0.00", 24 + "rain": {
25 - "sinceMidnight": "", 25 + "sinceOntime": "0.00",
26 - "last10min": "0.00", 26 + "sinceMidnight": "",
27 - "last15min": "0.00", 27 + "last10min": "0.00",
28 - "last30min": "0.00", 28 + "last15min": "0.00",
29 - "last1hour": "0.00", 29 + "last30min": "0.00",
30 - "last6hour": "0.50", 30 + "last1hour": "0.00",
31 - "last12hour": "0.50", 31 + "last6hour": "0.50",
32 - "last24hour": "0.50" 32 + "last12hour": "0.50",
33 - }, 33 + "last24hour": "0.50"
34 - "temperature": { 34 + },
35 - "tc": "5.90", 35 + "temperature": {
36 - "tmax": "7.00", 36 + "tc": "5.90",
37 - "tmin": "-1.00" 37 + "tmax": "7.00",
38 - }, 38 + "tmin": "-1.00"
39 - "humidity": "", 39 + },
40 - "pressure": { 40 + "humidity": "",
41 - "surface": "", 41 + "pressure": {
42 - "seaLevel": "" 42 + "surface": "",
43 - }, 43 + "seaLevel": ""
44 - "lightning": "0", 44 + },
45 - "timeObservation": "2018-12-06 14:14:00" 45 + "lightning": "0",
46 - }] 46 + "timeObservation": "2018-12-06 14:14:00"
47 + }
48 + ]
47 }, 49 },
48 "common": { 50 "common": {
49 "alertYn": "Y", 51 "alertYn": "Y",
...@@ -54,4 +56,201 @@ ...@@ -54,4 +56,201 @@
54 "requestUrl": "/weather/current/minutely?appKey=key&lat=37.239795&lon=127.083240", 56 "requestUrl": "/weather/current/minutely?appKey=key&lat=37.239795&lon=127.083240",
55 "message": "성공" 57 "message": "성공"
56 } 58 }
59 +},
60 +{
61 + "weather": {
62 + "wIndex": {
63 + "uvindex": [
64 + {
65 + "grid": {
66 + "city": "경기도",
67 + "county": "수원시",
68 + "village": ""
69 + },
70 + "day00": {
71 + "imageUrl": "http://files.weatherplanet.co.kr/weather/01_FCT/INDEX1/20181209/FCT_IDX_A07_1_2018120906_00D.gif",
72 + "index": "20.00",
73 + "comment": "자외선 걱정 없어요"
74 + },
75 + "day01": {
76 + "imageUrl": "http://files.weatherplanet.co.kr/weather/01_FCT/INDEX1/20181209/FCT_IDX_A07_1_2018120906_01D.gif",
77 + "index": "20.00",
78 + "comment": "자외선 걱정 없어요"
79 + },
80 + "day02": {
81 + "imageUrl": "http://files.weatherplanet.co.kr/weather/01_FCT/INDEX1/20181209/FCT_IDX_A07_1_2018120906_02D.gif",
82 + "index": "10.00",
83 + "comment": "자외선 없는 날입니다"
84 + }
85 + }
86 + ],
87 + "timeRelease": "2018-12-09 06:00:00"
88 + }
89 + },
90 + "common": {
91 + "alertYn": "Y",
92 + "stormYn": "N"
93 + },
94 + "result": {
95 + "code": 9200,
96 + "requestUrl": "/weather/index/uv?appKey=c13b1a68-ef31-4131-a1b7-4069c263f82d&version=1&lat=37.239795&lon=127.083240",
97 + "message": "성공"
98 + }
99 +}{
100 + "weather": {
101 + "wIndex": {
102 + "thIndex": [
103 + {
104 + "grid": {
105 + "city": "경기",
106 + "county": "용인시 기흥구",
107 + "village": "상갈동"
108 + },
109 + "forecast": {
110 + "timeRelease": "2018-12-09 14:00:00",
111 + "index43hour": "37.85",
112 + "index4hour": "38.40",
113 + "index7hour": "34.36",
114 + "index10hour": "31.08",
115 + "index13hour": "31.08",
116 + "index16hour": "27.60",
117 + "index19hour": "35.76",
118 + "index22hour": "44.84",
119 + "index25hour": "47.47",
120 + "index28hour": "42.45",
121 + "index31hour": "39.37",
122 + "index34hour": "37.85",
123 + "index37hour": "36.54",
124 + "index40hour": "35.73",
125 + "index46hour": "42.99",
126 + "index49hour": "39.12",
127 + "index52hour": "37.79",
128 + "index55hour": "37.13",
129 + "index58hour": "36.29",
130 + "index61hour": "",
131 + "index64hour": "",
132 + "index67hour": ""
133 + },
134 + "current": {
135 + "timeRelease": "2018-12-09 14:00:00",
136 + "index": "40.49"
137 + }
138 + }
139 + ]
140 + }
141 + },
142 + "common": {
143 + "alertYn": "Y",
144 + "stormYn": "N"
145 + },
146 + "result": {
147 + "code": 9200,
148 + "requestUrl": "/weather/index/th?appKey=c13b1a68-ef31-4131-a1b7-4069c263f82d&version=1&lat=37.239795&lon=127.083240",
149 + "message": "성공"
150 + }
151 +}{
152 + "weather": {
153 + "wIndex": {
154 + "heatIndex": [
155 + {
156 + "grid": {
157 + "city": "경기",
158 + "county": "용인시 기흥구",
159 + "village": "상갈동"
160 + },
161 + "forecast": {
162 + "timeRelease": "2018-12-09 14:00:00",
163 + "index4hour": "37.28",
164 + "index7hour": "70.81",
165 + "index10hour": "91.57",
166 + "index13hour": "91.57",
167 + "index16hour": "110.30",
168 + "index19hour": "71.89",
169 + "index22hour": "36.40",
170 + "index25hour": "27.82",
171 + "index28hour": "50.39",
172 + "index31hour": "61.62",
173 + "index34hour": "71.05",
174 + "index37hour": "75.20",
175 + "index40hour": "79.01",
176 + "index43hour": "71.05",
177 + "index46hour": "52.61",
178 + "index49hour": "67.96",
179 + "index52hour": "69.50",
180 + "index55hour": "69.08",
181 + "index58hour": "74.43",
182 + "index61hour": "",
183 + "index64hour": "",
184 + "index67hour": ""
185 + },
186 + "current": {
187 + "timeRelease": "2018-12-09 14:00:00",
188 + "index": "32.79"
189 + }
190 + }
191 + ]
192 + }
193 + },
194 + "common": {
195 + "alertYn": "Y",
196 + "stormYn": "N"
197 + },
198 + "result": {
199 + "code": 9200,
200 + "requestUrl": "/weather/index/heat?appKey=c13b1a68-ef31-4131-a1b7-4069c263f82d&version=1&lat=37.239795&lon=127.083240",
201 + "message": "성공"
202 + }
203 +}
204 +{
205 + "weather": {
206 + "wIndex": {
207 + "wctIndex": [
208 + {
209 + "grid": {
210 + "city": "경기",
211 + "county": "용인시 기흥구",
212 + "village": "상갈동"
213 + },
214 + "forecast": {
215 + "timeRelease": "2018-12-09 14:00:00",
216 + "index43hour": "-2.17",
217 + "index4hour": "-8.15",
218 + "index7hour": "-6.55",
219 + "index10hour": "-7.00",
220 + "index13hour": "-7.63",
221 + "index16hour": "-9.08",
222 + "index19hour": "-4.71",
223 + "index22hour": "1.18",
224 + "index25hour": "1.53",
225 + "index28hour": "-0.47",
226 + "index31hour": "-3.76",
227 + "index34hour": "-2.37",
228 + "index37hour": "-4.67",
229 + "index40hour": "-4.38",
230 + "index46hour": "-0.67",
231 + "index49hour": "-1.18",
232 + "index52hour": "-2.14",
233 + "index55hour": "-1.65",
234 + "index58hour": "-4.23",
235 + "index61hour": "",
236 + "index64hour": "",
237 + "index67hour": ""
238 + },
239 + "current": {
240 + "timeRelease": "2018-12-09 14:00:00",
241 + "index": "-6.22"
242 + }
243 + }
244 + ]
245 + }
246 + },
247 + "common": {
248 + "alertYn": "Y",
249 + "stormYn": "N"
250 + },
251 + "result": {
252 + "code": 9200,
253 + "requestUrl": "/weather/index/wct?appKey=c13b1a68-ef31-4131-a1b7-4069c263f82d&version=1&lat=37.239795&lon=127.083240",
254 + "message": "성공"
255 + }
57 } 256 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -21,24 +21,29 @@ module.exports = (server, app) => { ...@@ -21,24 +21,29 @@ module.exports = (server, app) => {
21 if (err) throw err; 21 if (err) throw err;
22 // api의 대답이 있을경우 실행 22 // api의 대답이 있을경우 실행
23 if (api_res) { 23 if (api_res) {
24 - console.log(api_body); 24 + return api_body;
25 - // api_body.weather.minutely[0] 25 + // api_body.weather.minutely[0]
26 } 26 }
27 }); 27 });
28 } 28 }
29 io.on('connection', (socket) => { //웹 페이지 연결시 루프 동작 29 io.on('connection', (socket) => { //웹 페이지 연결시 루프 동작
30 let API_CALL; 30 let API_CALL;
31 - 31 + let Current_Weather;
32 - 32 + let Sensible_T;
33 + let Heat_index;
34 + let Discomport_index;
35 + let Ultra_Violet_index;
36 +
33 socket.on("connection", () => { 37 socket.on("connection", () => {
34 API_CALL = setInterval(() => { 38 API_CALL = setInterval(() => {
35 39
36 - CALL("current","minutely"); //현재날씨 (분별) 40 + Current_Weather = CALL("current","minutely"); //현재날씨 (분별)
37 - CALL("index","wct"); //체감온도 41 + Sensible_T = CALL("index","wct"); //체감온도
38 - CALL("index","heat"); //열지수 42 + Heat_index = CALL("index","heat"); //열지수
39 - CALL("index","th"); //불쾌지수 43 + Discomport_index = CALL("index","th"); //불쾌지수
40 - CALL("index","uv"); //자외선지수 44 + Ultra_Violet_index = CALL("index","uv"); //자외선지수
41 45
46 + socket.emit("weatherInfo_minutely_send_to_cliend",info);
42 }, 60 * 1000); //1분마다 호출 47 }, 60 * 1000); //1분마다 호출
43 }); 48 });
44 49
...@@ -50,3 +55,4 @@ module.exports = (server, app) => { ...@@ -50,3 +55,4 @@ module.exports = (server, app) => {
50 55
51 56
52 } 57 }
58 +
......
...@@ -1071,7 +1071,8 @@ ...@@ -1071,7 +1071,8 @@
1071 "jsbn": "0.1.1", 1071 "jsbn": "0.1.1",
1072 "safer-buffer": "2.1.2", 1072 "safer-buffer": "2.1.2",
1073 "tweetnacl": "0.14.5" 1073 "tweetnacl": "0.14.5"
1074 - }, 1074 + }
1075 + },
1075 "sqlstring": { 1076 "sqlstring": {
1076 "version": "2.3.1", 1077 "version": "2.3.1",
1077 "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", 1078 "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
...@@ -1144,7 +1145,8 @@ ...@@ -1144,7 +1145,8 @@
1144 "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", 1145 "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
1145 "requires": { 1146 "requires": {
1146 "punycode": "2.1.1" 1147 "punycode": "2.1.1"
1147 - }, 1148 + }
1149 + },
1148 "util-deprecate": { 1150 "util-deprecate": {
1149 "version": "1.0.2", 1151 "version": "1.0.2",
1150 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 1152 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
...@@ -1199,4 +1201,4 @@ ...@@ -1199,4 +1201,4 @@
1199 "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" 1201 "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
1200 } 1202 }
1201 } 1203 }
1202 -} 1204 +}
...\ No newline at end of file ...\ No newline at end of file
......