function ZdcNearShop(){
this.type = 'ZdcNearShop';
this.result = false;
this.text_data = null;
}
ZdcNearShop.prototype.getResult = function(){
return this.result;
}
ZdcNearShop.prototype.abort = function(){
if( this.httpReq ){
this.httpReq.abort();
}
}
ZdcNearShop.prototype.search = function(opts, callback){
var owner = this;
var enc = "";
var target_url = "http://127.0.0.1/cgi/nkyoten.cgi";
var prm = '';
prm += '&key=53nQiP93lgsvBGnA7vBLnApf9XmgOPB1idX5S7XuomA2fB9zT1rxRzTyrxPzT5ngtzFRlggnFing5z4MoRNL0UngWzFtlgynFEngwz5qoRVLT3';
prm += '&cid='+opts.cid;
prm += '&opt=rkcsymap';
prm += '&pos='+opts.startPos;
prm += '&cnt='+opts.maxCount;
prm += '&enc='+enc;
prm += '&lat='+opts.lat;
prm += '&lon='+opts.lon;
prm += '&latlon='+opts.latlon;
prm += '&jkn='+opts.jkn;
prm += '&rad='+opts.radius;
prm += '&knsu='+opts.limitCount;
prm += '&exkid='+opts.exceptKid;
prm += '&cust='+opts.cust; prm += '&polycol='+opts.polycol; prm += '&exarea='+opts.exarea; var request_url = target_url+'?'+prm;
this.httpReq = new ZdcEmapHttpRequest('EUC', 'EUC');
this.httpReq.request(request_url, function(reference_text,status){
var result = new ZdcNearShopResult(reference_text, status);
result.type = owner.type;
result.options = opts;
owner.result = result;
ZdcEvent.trigger(owner, "end", result);
if( callback != null ){
// mod 2013/05/22 H.Osamoto [
// callback(result);
if (result.hitCount == 0) {
if (opts.researchCount != "") {
var target_url = "http://127.0.0.1/cgi/nkyoten.cgi";
var prm = '';
prm += '&key=53nQiP93lgsvBGnA7vBLnApf9XmgOPB1idX5S7XuomA2fB9zT1rxRzTyrxPzT5ngtzFRlggnFing5z4MoRNL0UngWzFtlgynFEngwz5qoRVLT3';
prm += '&cid='+opts.cid;
prm += '&opt=rkcsymap';
prm += '&pos='+opts.startPos;
prm += '&cnt='+opts.researchCount;
prm += '&enc='+enc;
prm += '&lat='+opts.lat;
prm += '&lon='+opts.lon;
prm += '&latlon='+opts.latlon;
prm += '&jkn='+opts.jkn;
prm += '&rad=1000000';
prm += '&knsu=1';
prm += '&exkid='+opts.exceptKid; // add 2009/10/13 Y.Matsukawa
prm += '&cust='+opts.cust; prm += '&polycol='+opts.polycol; prm += '&exarea='+opts.exarea; var request_url = target_url+'?'+prm;
this.httpReq = new ZdcEmapHttpRequest('EUC', 'EUC');
this.httpReq.request(request_url, function(reference_text,status){
var result = new ZdcNearShopResult(reference_text, status);
result.type = owner.type;
result.options = opts;
// add 2016/01/26 H.Yasunaga search時の再検索のフラグ追加 [
result.researched = "1";
// add 2016/01/26 H.Yasunaga ]
owner.result = result;
ZdcEvent.trigger(owner, "end", result);
if( callback != null ){
callback(result);
}
}, opts.timeout);
} else {
callback(result);
}
} else {
callback(result);
}
// mod 2013/05/22 H.Osamoto ]
}
}, opts.timeout, 1, 1);
}
function ZdcNearShopOptions(frewd){
//default値
this.cid = '99999999';
this.startPos = 1;
this.maxCount = 30;
this.lat = '';
this.lon = '';
this.latlon = '';
this.jkn = '';
this.limitCount = 100; //指定件数
this.radius = 50000; //半径
this.timeout = 60000;
this.pointFlg = '2'; //暫定対応: default: 2 (ZDC ms)
this.exceptKid = ''; //除外する拠点
this.cust = ''; this.researchCount = ''; //再検索時取得件数 add 2013/05/22 H.Osamoto
this.polycol = ''; this.exarea = ''; }
function ZdcNearShopResult(text_data, status){
if( text_data == null ){
ZdcSetErrorStatus.call(this, '', status);
return;
}
//header
var res = new Array();
res = text_data.split('\n');
var header = res.shift();
var cols = header.split('\t');
var retcd = cols[0];
var cnt = parseFloat(cols[1]);
var hitcnt = parseFloat(cols[2]);
var rest = ( retcd.charAt(3) == '0' && retcd.charAt(7) == '1' )? true : false;
//Parameter Error Check
if( retcd.charAt(3) == '1' ){
ZdcSetErrorStatus.call(this, retcd);
return;
}
//record
// add 2016/01/26 H.Yasunaga search時の再検索のフラグ追加 再検索した場合は"1"を設定 [
this.researched = "";
// add 2016/01/26 ]
this.retCode = retcd;
this.type = '';
this.status = status;
this.recCount = cnt;
this.hitCount = hitcnt;
this.rest = rest;
this.items = [];
for(var i=0; i18) lvl = 0;
if (isNaN(lvl) || !lvl || lvl < 1 || lvl >18) lvl = 0;
var item = new ZdcNearShopItem(cols,lvl);
this.items.push(item);
}
}
function ZdcNearShopItem(cols,lvl){
this.id = cols[0];
this.lat = cols[1];
this.lon = cols[2];
this.icon = cols[3];
this.dist = cols[4];
this.nflg = cols[5];
this.name = cols[6];
this.addr = cols[7];
this.col_07 = cols[8];
this.col_04 = cols[9];
this.col_01 = cols[10];
this.col_02 = cols[11];
this.col_06 = cols[12];
this.col_05 = cols[13];
this.col_08 = cols[14];
this.lvl = lvl;
}
var ZdcEmapNearShop = new ZdcNearShop();
// add 2014/10/13 Le Dang Son [
/**
* Change status error
*/
if(typeof ZdcSetErrorStatus == 'undefined'){
ZdcSetErrorStatus = function (_165,st){var _167;if(st==undefined){var _168=_165.charAt(4);var _169=_165.slice(3,5);if(_168=="9"){_167=1;}else{if(_165.substr(4,4)=="1009"){_167=5;}else{if(_168=="2"){_167=6;}else{if(_168=="6"||_168=="7"||_168=="8"||_169=="15"){_167=2;}else{_167=9;}}}}}else{_167=st;}this.retCode=_165||"";this.type="";this.status=_167;this.recCount=0;this.hitCount=0;this.rest=false;this.items=[];}
}
/**
* NearShop Object
*/
function ZdcNearShop2(){
this.type = 'ZdcNearShop2';
this.result = false;
this.text_data = null;
}
/**
* NearShop get result search
*/
ZdcNearShop2.prototype.getResult = function(){
return this.result;
}
/**
* Destroy search
*/
ZdcNearShop2.prototype.abort = function(){
if( this.httpReq ){
this.httpReq.abort();
}
}
/**
* Search near shop
*/
ZdcNearShop2.prototype.search = function(opts, callback){
var owner = this;
var enc = 'UTF-8';//ZDC_ENC
//var target_url = "http://127.0.0.1/cgi/nkyoten.cgi"; mod 2015/02/27 Y.Matsukawa
var target_url = "http://127.0.0.1/cgi/nkyoten.cgi";
var prm = '';
prm += '&key=41nQhzBGnwsvBynAXvBlnAof9MmgYPBlidC5SaXurmA7fB6zTbrxmzTZrxDzTzngjzFtmwIXFnmgrzFhmAbPTo';
prm += '&cid='+opts.cid;
// prm += '&opt=chpracttest'; mod 2016/02/16 H.Osamoto
prm += '&opt=rkcsymap';
prm += '&pos='+opts.startPos;
prm += '&cnt='+opts.maxCount;
prm += '&enc='+enc;
prm += '&lat='+opts.lat;
prm += '&lon='+opts.lon;
prm += '&latlon='+opts.latlon;
prm += '&jkn='+opts.jkn;
prm += '&rad='+opts.radius;
prm += '&knsu='+opts.limitCount;
prm += '&exkid='+opts.exceptKid;
prm += '&cust='+opts.cust;
prm += '&polycol='+opts.polycol;
prm += '&exarea='+opts.exarea;
var request_url = target_url+'?'+prm;
this.httpReq = new ZdcEmapHttpRequest('EUC', 'EUC');
this.httpReq.request(request_url, function(reference_text,status){
var result = new ZdcNearShopResult2(reference_text, status);
result.type = owner.type;
result.options = opts;
owner.result = result;
ZDC.trigger(owner, 'end', result)
if( callback != null ){
// mod 2013/05/22 H.Osamoto [
// callback(result);
if (result.hitCount == 0 || result.hitCount < opts.minCount) {
if (opts.researchCount != "") {
//var target_url = "http://127.0.0.1/cgi/nkyoten.cgi"; mod 2015/02/27 Y.Matsukawa
var target_url = "http://127.0.0.1/cgi/nkyoten.cgi";
var prm = '';
prm += '&key=41nQhzBGnwsvBynAXvBlnAof9MmgYPBlidC5SaXurmA7fB6zTbrxmzTZrxDzTzngjzFtmwIXFnmgrzFhmAbPTo';
prm += '&cid='+opts.cid;
// prm += '&opt=chpracttest'; mod 2016/02/16 H.Osamoto
prm += '&opt=rkcsymap';
prm += '&pos='+opts.startPos;
prm += '&cnt='+opts.researchCount;
prm += '&enc='+enc;
prm += '&lat='+opts.lat;
prm += '&lon='+opts.lon;
prm += '&latlon='+opts.latlon;
prm += '&jkn='+opts.jkn;
prm += '&rad=1000000';
prm += '&knsu='+opts.researchCount;
prm += '&exkid='+opts.exceptKid; // add 2009/10/13 Y.Matsukawa
prm += '&cust='+opts.cust;
prm += '&polycol='+opts.polycol;
prm += '&exarea='+opts.exarea;
var request_url = target_url+'?'+prm;
this.httpReq = new ZdcEmapHttpRequest('EUC', 'EUC');
this.httpReq.request(request_url, function(reference_text,status){
var result = new ZdcNearShopResult2(reference_text, status);
result.type = owner.type;
result.options = opts;
owner.result = result;
ZDC.trigger(owner, 'end', result)
if( callback != null ){
callback(result);
}
}, opts.timeout);
} else {
callback(result);
}
} else {
callback(result);
}
// mod 2013/05/22 H.Osamoto ]
}
}, opts.timeout, 1, 1);
}
function ZdcNearShopOptions2(frewd){
this.cid = '99999999';
this.startPos = 1;
this.maxCount = 30;
this.lat = '';
this.lon = '';
this.latlon = '';
this.jkn = '';
this.limitCount = 100;
this.radius = 50000;
this.timeout = 60000;
this.pointFlg = '2';
this.exceptKid = '';
this.cust = '';
this.researchCount = '';
this.polycol = '';
this.exarea = '';
}
function ZdcNearShopResult2(text_data, status){
if( text_data == null ){
ZdcSetErrorStatus.call(this, '', status);
return;
}
//header
var res = new Array();
res = text_data.split('\n');
var header = res.shift();
var cols = header.split('\t');
var retcd = cols[0];
var cnt = parseFloat(cols[1]);
var hitcnt = parseFloat(cols[2]);
var rest = ( retcd.charAt(3) == '0' && retcd.charAt(7) == '1' )? true : false;
//Parameter Error Check
if( retcd.charAt(3) == '1' ){
ZdcSetErrorStatus.call(this, retcd);
return;
}
//record
this.retCode = retcd;
this.type = '';
this.status = status;
this.recCount = cnt;
this.hitCount = hitcnt;
this.rest = rest;
this.items = [];
for(var i=0; i18) lvl = 0;
var item = new ZdcNearShopItem2(cols,lvl);
this.items.push(item);
}
}
function ZdcNearShopItem2(cols, lvl){
this.id = cols[0];
this.lat = cols[1];
this.lon = cols[2];
this.icon = cols[3];
this.dist = cols[4];
this.nflg = cols[5];
this.name = cols[6];
this.addr = cols[7];
this.col_04 = cols[8];
this.col_05 = cols[9];
this.col_06 = cols[10];
this.col_07 = cols[11];
this.col_08 = cols[12];
this.col_09 = cols[13];
this.col_10 = cols[14];
this.col_11 = cols[15];
this.col_12 = cols[16];
this.col_13 = cols[17];
this.col_14 = cols[18];
this.col_16 = cols[19];
this.col_17 = cols[20];
this.lvl = lvl;
}
var ZdcEmapNearShop2 = new ZdcNearShop2();
// add 2014/10/13 Le Dang Son ]