최현영

Highway number function added

...@@ -127,6 +127,17 @@ function typeforecast(typetext){ ...@@ -127,6 +127,17 @@ function typeforecast(typetext){
127 else false; 127 else false;
128 } 128 }
129 129
130 +function isroadnumber(typetext){
131 + if(typetext == '노선정보'){
132 + return true;
133 + }
134 + else{
135 + return false;
136 + }
137 +}
138 +
139 +
140 +
130 141
131 app.post('/hook', function (req, res) { 142 app.post('/hook', function (req, res) {
132 //console.log(jsonForforecast); 143 //console.log(jsonForforecast);
...@@ -134,6 +145,7 @@ app.post('/hook', function (req, res) { ...@@ -134,6 +145,7 @@ app.post('/hook', function (req, res) {
134 var isstart; 145 var isstart;
135 var isforecast; 146 var isforecast;
136 var isselecttypeforecast; 147 var isselecttypeforecast;
148 + var isfindroad;
137 var istypeforecast; 149 var istypeforecast;
138 var eventObj = req.body.events[0]; 150 var eventObj = req.body.events[0];
139 var source = eventObj.source; 151 var source = eventObj.source;
...@@ -153,6 +165,12 @@ app.post('/hook', function (req, res) { ...@@ -153,6 +165,12 @@ app.post('/hook', function (req, res) {
153 helloworld(eventObj); 165 helloworld(eventObj);
154 } 166 }
155 167
168 + isfindroad = isroadnumber(message.text);
169 + if(isfindroad == true){
170 + console.log("노선번호를 궁금해 합니다.")
171 + roadnumber(eventObj);
172 + }
173 +
156 isforecast = firstforecast(message.text); 174 isforecast = firstforecast(message.text);
157 if(isforecast){ 175 if(isforecast){
158 if(message.text == '1'){ 176 if(message.text == '1'){
...@@ -163,6 +181,10 @@ app.post('/hook', function (req, res) { ...@@ -163,6 +181,10 @@ app.post('/hook', function (req, res) {
163 console.log('[request Order] ', message); 181 console.log('[request Order] ', message);
164 viewhtml(eventObj); 182 viewhtml(eventObj);
165 } 183 }
184 + else if (message.text == '3'){
185 + console.log('[request Order] ', message);
186 + //tieupselect(eventObj);
187 + }
166 } 188 }
167 189
168 isselecttypeforecast = selecttypeforecast(message.text); 190 isselecttypeforecast = selecttypeforecast(message.text);
...@@ -220,7 +242,7 @@ function helloworld(eventObj){ ...@@ -220,7 +242,7 @@ function helloworld(eventObj){
220 }, 242 },
221 { 243 {
222 "type":"text", 244 "type":"text",
223 - "text":"현재 교통 예보가 궁금하시다면 1번을, 실시간 교통혼잡 상황을 보실려면 2번을 눌러주세요" 245 + "text":"현재 교통 예보가 궁금하시다면 1번을, 실시간 교통혼잡 상황을 보실려면 2번을, 실시간 정체상황을 알고 싶다면 3번을 눌러주세요. 노선정보는 '노선정보'를 입력해주세요."
224 } 246 }
225 ] 247 ]
226 } 248 }
...@@ -241,11 +263,11 @@ function viewhtml(eventObj){ ...@@ -241,11 +263,11 @@ function viewhtml(eventObj){
241 "messages":[ 263 "messages":[
242 { 264 {
243 "type":"text", 265 "type":"text",
244 - "text":"실시간 교통상황 웹페이지로 안내합니다." 266 + "text":"실시간 전국 국도 및 고속국도 교통상황 웹페이지로 안내합니다."
245 }, 267 },
246 { 268 {
247 "type":"text", 269 "type":"text",
248 - "text":"https://www.chyoss.tk:23023/public/maprealtime.html" 270 + "text":"http://www.chyoss.tk:24024/public/maprealtime.html"
249 } 271 }
250 ] 272 ]
251 } 273 }
...@@ -548,6 +570,42 @@ function normalforecasttoG(eventObj){ ...@@ -548,6 +570,42 @@ function normalforecasttoG(eventObj){
548 570
549 } 571 }
550 572
573 +function roadnumber(eventObj){
574 + request.post(
575 + {
576 + url: TARGET_URL,
577 + headers: {
578 + 'Authorization': `Bearer ${TOKEN}`
579 + },
580 + json: {
581 + "replyToken":eventObj.replyToken,
582 + "messages":[
583 + {
584 + "type":"text",
585 + "text":"고속도로 노선 번호는 다음과 같습니다."
586 + },
587 + {
588 + "type":"text",
589 + "text":"경부 및 남북 구간: 1-경부선, 15-서해안선, 17-평택파주선, 25-호남 및 논산천안선, 27-순천완주선, 29-세종포천지선, 35-통영대전 및 중부선, 37-제2중부선, 45-중부내륙선, 55-중앙선, 65-동해선"
590 + },
591 + {
592 + "type":"text",
593 + "text":"동서 구간 : 10-남해, 12-무안광주 및 광주대구선, 16-울산선, 20-새만금포항선, 30-당진영덕선, 32-아산청주선, 40-평택제천선, 50-영동선, 52-광주원주선, 60-서울양양선"
594 + },
595 + {
596 + "type":"text",
597 + "text":"순환 및 경인 구간: 100-서울외각순환선, 300-대전남부선, 400-수도권제2순환, 600-부산외곽순환선, 110-제2 경인선, 120-경인선, 130-인천공항선"
598 + },
599 + {
600 + "type":"text",
601 + "text":"지선 구간: 102-남해 제1지선, 104-남해 제2지선, 105-남해 제3지선, 151-서천공주선, 153-평택시흥선, 171-오산화성 및 용인서울선, 204-새만금포항지선2, 251-호남지선, 253-고참담양선, 301-상주영천선, 451-중부내륙지선, 551-중앙지선"
602 + }
603 + ]
604 + }
605 + },(error, response, body) => {
606 + console.log(body)
607 + });
608 +}
551 609
552 // var url1 = 'http://data.ex.co.kr/openapi/odtraffic/trafficAmountByCongest'; 610 // var url1 = 'http://data.ex.co.kr/openapi/odtraffic/trafficAmountByCongest';
553 // var queryParams1 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/ 611 // var queryParams1 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/
...@@ -635,6 +693,13 @@ try { ...@@ -635,6 +693,13 @@ try {
635 HTTPS.createServer(option, app).listen(sslport, () => { 693 HTTPS.createServer(option, app).listen(sslport, () => {
636 console.log(`[HTTPS] Server is started on port ${sslport}`); 694 console.log(`[HTTPS] Server is started on port ${sslport}`);
637 }); 695 });
696 +
697 + var server = app.listen(24024, function () {
698 + var host = server.address().address
699 + var port = server.address().port
700 + console.log("Example app listening at http://%s:%s", host, port)
701 + });
702 +
638 } catch (error) { 703 } catch (error) {
639 console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); 704 console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
640 console.log(error); 705 console.log(error);
......
...@@ -26,18 +26,6 @@ ...@@ -26,18 +26,6 @@
26 var POPUP_LAYERS = []; 26 var POPUP_LAYERS = [];
27 var EPSG_4326 = new OpenLayers.Projection('EPSG:4326'); 27 var EPSG_4326 = new OpenLayers.Projection('EPSG:4326');
28 var EPSG_900913 = new OpenLayers.Projection('EPSG:900913'); 28 var EPSG_900913 = new OpenLayers.Projection('EPSG:900913');
29 - function getCORSURL(uri, type) {
30 - var yqlUri = 'http://query.yahooapis.com/v1/public/yql?q=' +
31 - encodeURIComponent('SELECT * FROM ' + type + ' where url="' + uri + '"');
32 - if (type == 'html') {
33 - yqlUri += encodeURIComponent(' and xpath="/*"');
34 - } else if (type == 'json') {
35 - yqlUri += "&callback=&format=json";
36 - } else if (type == 'xml') {
37 - yqlUri += "&format=xml";
38 - }
39 - return yqlUri;
40 - }
41 </script> 29 </script>
42 <script type="text/javascript" src="http://openapi.its.go.kr/javascript/openapi.ntic.js"></script> 30 <script type="text/javascript" src="http://openapi.its.go.kr/javascript/openapi.ntic.js"></script>
43 <script type="text/javascript"> 31 <script type="text/javascript">
...@@ -79,58 +67,7 @@ ...@@ -79,58 +67,7 @@
79 // 교통정보 종료 67 // 교통정보 종료
80 map.addLayers(NOPOP_LAYERS); 68 map.addLayers(NOPOP_LAYERS);
81 map.addLayers(POPUP_LAYERS); 69 map.addLayers(POPUP_LAYERS);
82 -
83 -
84 -
85 - // 아이콘 클릭시 팝업 설정 시작
86 - var controlSelect = new OpenLayers.Control.SelectFeature(POPUP_LAYERS, {
87 - clickout:true, toggle:false, multiple:false,
88 - onSelect:function(feature){
89 - var data = feature.data;
90 - var message ='';
91 - switch(feature.layer.id) {
92 - case 'weatherLayer':
93 - message += weather.getMessage(data);
94 - break;
95 - case 'constructionLayer':
96 - message += construction.getMessage(data);
97 - break;
98 - case 'accidentLayer':
99 - message += accident.getMessage(data);
100 - break;
101 - case 'cctvLayer':
102 - message += cctv.getMessage(data);
103 - break;
104 - case 'warningLayer':
105 - message += warning.getMessage(data);
106 - break;
107 - case 'tourLayer':
108 - message += tour.getMessage(data);
109 - break;
110 - default:
111 - return false;
112 - }
113 - var selectedFeature = feature;
114 - var popup = new OpenLayers.Popup.FramedCloud("popup",
115 - feature.geometry.getBounds().getCenterLonLat(), null,
116 - message, null, true, function(e){controlSelect.unselect(selectedFeature);});
117 - popup.minSize = new OpenLayers.Size(200,200);
118 - popup.maxSize = new OpenLayers.Size(400,400);
119 - feature.popup = popup;
120 - map.addPopup(popup);
121 - },
122 - onUnselect:function(feature){
123 - map.removePopup(feature.popup);
124 - feature.popup.destroy();
125 - feature.popup = null;
126 - }
127 - });
128 - map.addControls([controlSelect]);
129 - controlSelect.activate();
130 - // 아이콘 클릭시 팝업 설정 종료
131 } 70 }
132 </script> 71 </script>
133 </body> 72 </body>
134 </html> 73 </html>
135 -
136 - -->
......