한국공항공사(KAC) - 서버
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.3 KiB

const fs = require('fs');
const codeService = require('../service/codeService');
module.exports = {
mainFoler : 'CoordinateFolder',
codeFoler : 'LocationCode',
extension : '.geojson',
ctprvn : 'ctprvn',
sig : 'sig',
emd: 'emd',
li : 'li',
cdLength : [2,5,8,10],
baseProperties: new Map(),
/**
* 초반세팅, paht는 index.js[실행JS] 기준으로 넣으면
* @param {*} path
*/
init : function(path) {
let directoryCheck = fs.existsSync(path + this.mainFoler)
if(!directoryCheck) {
fs.mkdirSync(path + this.mainFoler)
}
directoryCheck = fs.existsSync(path + this.codeFoler)
if(!directoryCheck){
fs.mkdirSync(path + this.codeFoler)
}
for(let i = 0; i < this.cdLength.length; i++){
switch (this.cdLength[i]) {
case 2:
this.baseProperties.set(this.cdLength[i], this.ctprvn)
break;
case 5:
this.baseProperties.set(this.cdLength[i], this.sig)
break;
case 8:
this.baseProperties.set(this.cdLength[i], this.emd)
break;
case 10:
this.baseProperties.set(this.cdLength[i], this.li)
break;
}
}
},
/**
* Yn이 true면 실행안함, false면 실행
* @param {*} yn
* @param {*} features
* @returns
*/
makeCodeFolder: function (yn, features){
if(yn){
return;
}
for(let i = 0; i < this.cdLength.length; i++){
let key = this.cdLength[i]
let value = this.baseProperties.get(key);
let path = './' + this.codeFoler + '/' + value;
let coordiArr = codeService.allCodeServcie(key, features);
let directoryCheck = fs.existsSync(path);
if(!directoryCheck){
fs.mkdirSync(path)
}
path = path + '/' + value + this.extension;
fs.writeFileSync(path, JSON.stringify(coordiArr), (err) => {
console.log(err)
})
}
},
}