최현영

Highway travel time of IC-to-IC adding...

This diff could not be displayed because it is too large.
......@@ -16,11 +16,16 @@ const TOKEN = 'sqNjA99TptppqvcoVFAnU7Kawsl+s7l+JgnZ7r2is97qrFQraIn0sLQ6mTsIPvXLG
const domain = "www.chyoss.tk"
const sslport = 23023;
const buffer = fs.readFileSync('./whereur/Expressfee.json');
const datafeejson = buffer.toString();
const feebuffer = fs.readFileSync('./whereur/Expressfee.json');
const datafeejson = feebuffer.toString();
const feedata = JSON.parse(datafeejson);
console.log("Expressfee.json 파일 읽기");
const namebuffer = fs.roadFileSync('./whereur/ExpressIC.json');
const datanamejson = namebuffer.toString();
const namedata = JSON.parse(datanamejson);
console.log("Expressname.json 파일 열기");
......@@ -51,11 +56,6 @@ router.route('/process/maprealtime').get(function(req, res){
});
router.route('/process/maprealtime').get(function(req, res){
console.log('process/mapreatime 호출됨');
res.end();
});
router.route('/process/construction').get(function(req, res){
console.log('process/maprealconstruction 호출됨');
res.end();
......@@ -184,6 +184,16 @@ function isroadnumber(typetext){
}
}
function isroadname(typetext){
if(typetext == '나들목정보'){
return true;
}
else{
return false;
}
}
function inputroadnumber(typetext){
if(typetext.indexOf("번") >= 0){
return true;
......@@ -192,6 +202,15 @@ function inputroadnumber(typetext){
return false;
}
}
function israodnameExist(typetext){
if(typetext.indexOf('검색') >= 0){
return true;
}
else{
return false;
}
}
function pushmsg(eventObj){
console.log(eventObj.source.userId);
......@@ -235,7 +254,7 @@ function pushmsg(eventObj){
usercount[eventObj.source.userId] = (usercount[eventObj.source.userId] + 5);
}
}
function wanttokownfee(typetext){
function wanttoknowfee(typetext){
if(typetext.indexOf("-") >= 0){
return true;
}
......@@ -255,13 +274,19 @@ app.post('/hook', function (req, res) {
var isforecast;
var isselecttypeforecast;
var isfindroad;
var isroadname;
var istypeforecast;
var isinputnumber;
var isinputroadname;
var eventObj = req.body.events[0];
var source = eventObj.source;
var message = eventObj.message;
var isnext;
var isfee;
var istime;
// request log
console.log('======================', new Date() ,'======================');
console.log('[request]', req.body);
......@@ -284,6 +309,13 @@ app.post('/hook', function (req, res) {
roadnumber(eventObj);
}
isroadname = isroadname(message.text);
if(isroadname == true){
console.log("나들목 이름을 궁금해 합니다.");
roadname(eventObj);
}
isforecast = firstforecast(message.text);
if(isforecast){
if(message.text == '1'){
......@@ -348,11 +380,22 @@ app.post('/hook', function (req, res) {
//console.log(roadnumberstringLength);
}
isfee = wanttokownfee(message.text);
isfee = wanttoknowfee(message.text);
if(isfee == true){
feelead(eventObj, message.text);
}
istime = wanttoknowtime(message.text);
if(istime == true){
timelead(eventObj, message.text);
}
isinputroadname = israodnameExist(message.text);
if(isinputroadname == true ){
isinputroadname(eventObj, message.text);
}
res.sendStatus(200);
});
......@@ -376,11 +419,11 @@ function helloworld(eventObj){
},
{
"type":"text",
"text":"현재 교통 예보가 궁금하시다면 1번을, 실시간 교통혼잡 상황을 보실려면 2번을, 실시간 정체상황을 알고 싶다면 3번을, 교통요금이 궁금하시다면 4번을 눌러주세요."
"text":"현재 교통 예보가 궁금하시다면 1번을, 실시간 교통혼잡 상황을 보실려면 2번을, 실시간 정체상황을 알고 싶다면 3번을, 교통요금이 궁금하시다면 4번을, 나들목간 평균시간"
},
{
"type":"text",
"text": "노선정보는 '노선정보'를 입력해주세요."
"text": "노선정보는 '노선정보'를 입력해주세요., 나들목정보는 '나들목정보' "
}
]
}
......@@ -757,7 +800,7 @@ function roadnumber(eventObj){
},
{
"type":"text",
"text":"동서 구간 : 10-남해, 12-무안광주 및 광주대구선, 16-울산선, 20-새만금포항선, 30-당진영덕선, 32-아산청주선, 40-평택제천선, 50-영동선, 52-광주원주선, 60-서울양양선"
"text":"동서 구간 : 10-남해, 12-무안광주 및 광주대구선, 16-울산선, 20-새만금포항선, 30-당진영덕선, 32-아산청주선, 40-평택제천선, 50-영동선, 52-광주원주선, 60-서울양양선"
},
{
"type":"text",
......@@ -774,6 +817,37 @@ function roadnumber(eventObj){
});
}
function roadname(eventObj){
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":eventObj.replyToken,
"messages":[
{
"type":"text",
"text":"나들목 이름이 궁금하시다면 <검색:이름>을 입력해 주세요."
},
{
"type":"text",
"text":"예) 검색:서안동"
},
{
"type":"text",
"test":"예) 검색:안동"
}
]
}
},(error, response, body) => {
console.log(body)
});
}
function tieupselect(eventObj){
request.post(
{
......@@ -807,6 +881,46 @@ function tieupselect(eventObj){
});
}
function isinputroadname(eventObj, msg){
var icnamelist = new Array();
var iclist = "";
var ExpressICnameLength = namedata.length;
var icnamelist = msg.split(':');
var isthat = false;
var iscout = 0;
for(var i = 0; i < ExpressICnameLength; i++){
if(namedata.unitLists[i].unitName.indexOf(icnamelist[1]) >= 0 ){
isthat = true;
iclist = "#" + str(iscount) + " " + namedata.unitLists[i].unitName + " ";
}
}
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":eventObj.replyToken,
"messages":[
{
"type":"text",
"text":"검색결과입니다. : " + msg
}
]
}
},(error, response, body) => {
console.log(body)
});
}
function roadcongest(eventObj, msg, userid){
//jsoncongest의 routeNo는 앞의 세자리가 노선 번호, 마지막 숫자가 제1 중부내륙, 제2 중부내륙 처럼 노선번호는 같으나 노선의 경로가 다른 경우를 나타내며, 혹은 구간구간 개통된 고속도로를 구분지을 때도 구별용으로 사용됨으로 필요가 없음.
jsoncongest(function(object){
......@@ -850,6 +964,37 @@ function roadcongest(eventObj, msg, userid){
userroadcongest[userid] = roadnumberstring;
userroadcongestlength[userid] = roadnumberstringLength;
usercount[userid] = 0;
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":eventObj.replyToken,
"messages":[
{
"type":"text",
"text":"검색하신 노선에서 발견된 정체량은 총 " + str(userroadcongestlength[userid]) + "입니다."
},
{
"type":"text",
"text":"계속해서 보실려면 '다음'을 입력해 주세요."
},
{
"type":"text",
"text":"마지막 항목이 나올때까지 계속해서 '다음'을 입력해 주세요."
}
]
}
},(error, response, body) => {
console.log(body)
});
}
if(roadnumberstringLength == 0){
......@@ -948,57 +1093,6 @@ function feelead(eventObj, msg){
}
}
// var url3 = 'http://data.ex.co.kr/openapi/trafficapi/trafficAll';
// var queryParams3 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/
// queryParams3 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */
// request({
// url: url3 + queryParams3,
// method: 'GET'
// }, function (error, response, body) {
// console.log('Status', response.statusCode);
// console.log('Headers', JSON.stringify(response.headers));
// console.log('Reponse received', body);
// var obj = JSON.parse(body);
// console.log(obj);
// console.log(obj.trafficAll[0]);
// });
// var url4 = 'http://data.ex.co.kr/openapi/trafficapi/trafficRegion';
// var queryParams4 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/
// queryParams4 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */
// request({
// url: url4 + queryParams4,
// method: 'GET'
// }, function (error, response, body) {
// console.log('Status', response.statusCode);
// console.log('Headers', JSON.stringify(response.headers));
// console.log('Reponse received', body);
// var obj = JSON.parse(body);
// console.log(obj);
// console.log(obj.trafficRegion[0]);
// });
// var url5 = 'http://data.ex.co.kr/openapi/business/conveniServiceArea';
// var queryParams5 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/
// queryParams5 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */
// request({
// url: url5 + queryParams5,
// method: 'GET'
// }, function (error, response, body) {
// console.log('Status', response.statusCode);
// console.log('Headers', JSON.stringify(response.headers));
// console.log('Reponse received', body);
// var obj = JSON.parse(body);
// console.log(obj);
// console.log(obj.list[0]);
// });
......
<!doctype html>
<html lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>실시간 공사정보</title>
<style type="text/css">
* {
font-family:Arial, Verdana, sans-serif, Dotum, Gulim;
}
html, body { width:100%; height:100%; }
body { margin:0; padding:0; }
</style>
</head>
<body>
<form method="get" action="/process/construction"></form>
<div id="map" style="width:100%; height:100%;"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://openapi.its.go.kr/javascript/jquery.xml2json.js"></script>
<script type="text/javascript" src="http://openlayers.org/api/2.13.1/OpenLayers.js"></script>
<script type="text/javascript" src="http://openapi.its.go.kr/javascript/OpenLayers.Layer.Vworld.js"></script>
<script type="text/javascript">
var API_DOMAIN = 'http://openapi.its.go.kr';
var key = '1590913608992';
var NOPOP_LAYERS = [];
var POPUP_LAYERS = [];
var EPSG_4326 = new OpenLayers.Projection('EPSG:4326');
var EPSG_900913 = new OpenLayers.Projection('EPSG:900913');
function getCORSURL(uri, type) {
var yqlUri = 'http://query.yahooapis.com/v1/public/yql?q=' +
encodeURIComponent('SELECT * FROM ' + type + ' where url="' + uri + '"');
if (type == 'html') {
yqlUri += encodeURIComponent(' and xpath="/*"');
} else if (type == 'json') {
yqlUri += "&callback=&format=json";
} else if (type == 'xml') {
yqlUri += "&format=xml";
}
return yqlUri;
}
</script>
<script type="text/javascript" src="http://openapi.its.go.kr/javascript/openapi.construction.js"></script>
<script type="text/javascript">
window.onload = init;
var map;
function init() {
// 지도 생성
map = new OpenLayers.Map({
div: "map",
projection: EPSG_900913,
displayProjection: EPSG_4326,
units: "m",
maxExtent: new OpenLayers.Bounds(13489539, 3828608, 14943678, 4881604),
restrictedExtent: new OpenLayers.Bounds(13489539, 3828608, 14943678, 4881604),
layers: [
new OpenLayers.Layer.Vworld_Base('Vworld', {numZoomLevels:17, transitionEffect:''})
],
controls: [
new OpenLayers.Control.Navigation()
,new OpenLayers.Control.MousePosition()
,new OpenLayers.Control.ScaleLine()
,new OpenLayers.Control.PanZoomBar({zoomWorldIcon:true})
,new OpenLayers.Control.LayerSwitcher()
,new OpenLayers.Control.OverviewMap({layers:[new OpenLayers.Layer.OSM()], mapOptions:{projection:'EPSG:900913'}, autoPan:true, maximized:true})
]
});
// 지도 레벨 제한
map.events.on({
"zoomend": function(event) {
if (map.getZoom() < 7) map.setCenter(map.getCenter(), 7);
if (map.getZoom() > 14) map.setCenter(map.getCenter(), 14);
}
});
// 지도 초기 위치 설정
map.setCenter(new OpenLayers.LonLat(14217832, 4353272), 7);
// 공사정보 시작
var construction = new Construction('constructionLayer');
construction.getList();
POPUP_LAYERS.push(construction.getLayer());
// 공사정보 종료
map.addLayers(NOPOP_LAYERS);
map.addLayers(POPUP_LAYERS);
// 아이콘 클릭시 팝업 설정 시작
var controlSelect = new OpenLayers.Control.SelectFeature(POPUP_LAYERS, {
clickout:true, toggle:false, multiple:false,
onSelect:function(feature){
var data = feature.data;
var message ='';
switch(feature.layer.id) {
case 'weatherLayer':
message += weather.getMessage(data);
break;
case 'constructionLayer':
message += construction.getMessage(data);
break;
case 'accidentLayer':
message += accident.getMessage(data);
break;
case 'cctvLayer':
message += cctv.getMessage(data);
break;
case 'warningLayer':
message += warning.getMessage(data);
break;
case 'tourLayer':
message += tour.getMessage(data);
break;
default:
return false;
}
var selectedFeature = feature;
var popup = new OpenLayers.Popup.FramedCloud("popup",
feature.geometry.getBounds().getCenterLonLat(), null,
message, null, true, function(e){controlSelect.unselect(selectedFeature);});
popup.minSize = new OpenLayers.Size(200,200);
popup.maxSize = new OpenLayers.Size(400,400);
feature.popup = popup;
map.addPopup(popup);
},
onUnselect:function(feature){
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
});
map.addControls([controlSelect]);
controlSelect.activate();
// 아이콘 클릭시 팝업 설정 종료
}
</script>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>교통정보 OPEN API</title>
<style type="text/css">
* {
font-family:Arial, Verdana, sans-serif, Dotum, Gulim;
}
html, body { width:100%; height:100%; }
body { margin:0; padding:0; }
</style>
</head>
<body>
<form method="get" action="/process/mapcctv"></form>
<div id="map" style="width:100%; height:100%;"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://openapi.its.go.kr/javascript/jquery.xml2json.js"></script>
<script type="text/javascript" src="http://openlayers.org/api/2.13.1/OpenLayers.js"></script>
<script type="text/javascript" src="http://openapi.its.go.kr/javascript/OpenLayers.Layer.Vworld.js"></script>
<script type="text/javascript">
var API_DOMAIN = 'http://openapi.its.go.kr';
var key = '1590913608992';
var NOPOP_LAYERS = [];
var POPUP_LAYERS = [];
var EPSG_4326 = new OpenLayers.Projection('EPSG:4326');
var EPSG_900913 = new OpenLayers.Projection('EPSG:900913');
function getCORSURL(uri, type) {
var yqlUri = 'http://query.yahooapis.com/v1/public/yql?q=' +
encodeURIComponent('SELECT * FROM ' + type + ' where url="' + uri + '"');
if (type == 'html') {
yqlUri += encodeURIComponent(' and xpath="/*"');
} else if (type == 'json') {
yqlUri += "&callback=&format=json";
} else if (type == 'xml') {
yqlUri += "&format=xml";
}
return yqlUri;
}
</script>
<script type="text/javascript" src="http://openapi.its.go.kr/javascript/openapi.cctv.js"></script>
<script type="text/javascript">
window.onload = init;
var map;
function init() {
// 지도 생성
map = new OpenLayers.Map({
div: "map",
projection: EPSG_900913,
displayProjection: EPSG_4326,
units: "m",
maxExtent: new OpenLayers.Bounds(13489539, 3828608, 14943678, 4881604),
restrictedExtent: new OpenLayers.Bounds(13489539, 3828608, 14943678, 4881604),
layers: [
new OpenLayers.Layer.Vworld_Base('Vworld', {numZoomLevels:17, transitionEffect:''})
],
controls: [
new OpenLayers.Control.Navigation()
,new OpenLayers.Control.MousePosition()
,new OpenLayers.Control.ScaleLine()
,new OpenLayers.Control.PanZoomBar({zoomWorldIcon:true})
,new OpenLayers.Control.LayerSwitcher()
,new OpenLayers.Control.OverviewMap({layers:[new OpenLayers.Layer.OSM()], mapOptions:{projection:'EPSG:900913'}, autoPan:true, maximized:true})
]
});
// 지도 레벨 제한
map.events.on({
"zoomend": function(event) {
if (map.getZoom() < 7) map.setCenter(map.getCenter(), 7);
if (map.getZoom() > 14) map.setCenter(map.getCenter(), 14);
}
});
// 지도 초기 위치 설정
map.setCenter(new OpenLayers.LonLat(14217832, 4353272), 7);
// CCTV 시작
var cctv = new CCTV('cctvLayer');
cctv.getList();
POPUP_LAYERS.push(cctv.getLayer());
// CCTV 종료
map.addLayers(NOPOP_LAYERS);
map.addLayers(POPUP_LAYERS);
// 아이콘 클릭시 팝업 설정 시작
var controlSelect = new OpenLayers.Control.SelectFeature(POPUP_LAYERS, {
clickout:true, toggle:false, multiple:false,
onSelect:function(feature){
var data = feature.data;
var message ='';
switch(feature.layer.id) {
case 'weatherLayer':
message += weather.getMessage(data);
break;
case 'constructionLayer':
message += construction.getMessage(data);
break;
case 'accidentLayer':
message += accident.getMessage(data);
break;
case 'cctvLayer':
message += cctv.getMessage(data);
break;
case 'warningLayer':
message += warning.getMessage(data);
break;
case 'tourLayer':
message += tour.getMessage(data);
break;
default:
return false;
}
var selectedFeature = feature;
var popup = new OpenLayers.Popup.FramedCloud("popup",
feature.geometry.getBounds().getCenterLonLat(), null,
message, null, true, function(e){controlSelect.unselect(selectedFeature);});
popup.minSize = new OpenLayers.Size(200,200);
popup.maxSize = new OpenLayers.Size(400,400);
feature.popup = popup;
map.addPopup(popup);
},
onUnselect:function(feature){
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
});
map.addControls([controlSelect]);
controlSelect.activate();
// 아이콘 클릭시 팝업 설정 종료
}
</script>
</body>
</html>
\ No newline at end of file