class Util{ /** * 换行符 */ static enterChar:string = '\r\n'; /** * 获取绝对路径 * @param pa 路径数组 * @param first 表示第一个首字母斜杠也要去掉 */ static getAbsPath(pa:string[],first?:boolean):string{ //如果first为true,所有'/'开头都要去掉‘/’,否则第一个不去掉 let i=first?0:1; for(;i{ dst[item] = src[item]; }); } /** * 产生时间 * @param year * @param month * @param date * @param hour * @param minute * @param second * @returns */ static genTime(year:number,month:number,date:number,hour:number,minute:number,second:number){ let addCount = 0; if(second >= 60){ addCount = (second-59) * 1000; second = 59; } return new Date(year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second).getTime() + addCount; } /** * 高度经纬度 转xyz * @param height 高度(m) * @param lamda 经度 * @param b 纬度 * @returns [x,y,z] */ static hlb2Xyz(height,lamda,b){ let a = 6378137.0; lamda *= Math.PI/180; b *= Math.PI/180; // let scale = 637813.7*2; let scale = 1; height += a; let x = height*Math.sin(lamda)*Math.cos(b)/scale; let y = height*Math.sin(b)/scale; let z = height * Math.cos(lamda) * Math.cos(b)/scale; return [x.toFixed(1),y.toFixed(1),-z.toFixed(1)]; } /** * * @param str 源串 * @param code 加密方法 * @returns 加密串 */ static encrypt(str,code):string{ const hash = require('crypto').createHash(code); hash.update(str); return hash.digest('hex'); } } export{Util}