高斯坐标与经纬度坐标互转丨技术开发分享录

高斯坐标与经纬度坐标互转

{{ detail.nickname }}

转载 翻译 {{ formatTime(detail.create_time) }} 字数 {{ detail.content && detail.content.length }} 阅读 {{ detail.read_num }} {{ formatTag(v) }}

"## 一、高斯投影坐标 转 经纬度\n\n```\nfunction GaussToBL(X,Y){\n    let ProjNo;\n    let ZoneWide; 带宽\n    let output = new Array(2);\n    let longitude1,latitude1, longitude0, X0,Y0, xval,yval;//latitude0,\n    let e1,e2,f,a, ee, NN, T,C, M, D,R,u,fai, iPI;\n    iPI = 3.14159265358979324/180.0; 3.1415926535898/180.0;\n    // a = 6378245.0; f = 1.0/298.3; //54年北京坐标系参数\n    a=6378140.0; f=1.0/298.257; //80年西安坐标系参数\n    ZoneWide = 6; 6度带宽\n    ProjNo = parseInt(X/1000000) ; //查找带号\n    longitude0 = (ProjNo-1) * ZoneWide + ZoneWide / 2;\n    longitude0 = longitude0 * iPI ; //中央经线\n\n\n    X0 = ProjNo*1000000+500000;\n    Y0 = 0;\n    xval = X-X0; yval = Y-Y0; //带内大地坐标\n    e2 = 2*f-f*f;\n    e1 = (1.0-Math.sqrt(1-e2))/(1.0+Math.sqrt(1-e2));\n    ee = e2/(1-e2);\n    M = yval;\n    u = M/(a*(1-e2/4-3*e2*e2/64-5*e2*e2*e2/256));\n    fai = u+(3*e1/2-27*e1*e1*e1/32)*Math.sin(2*u)+(21*e1*e1/16-55*e1*e1*e1*e1/32)*Math.sin(4*u) +(151*e1*e1*e1/96)*\n        Math.sin(6*u)+(1097*e1*e1*e1*e1/512)*Math.sin(8*u);\n    C = ee*Math.cos(fai)*Math.cos(fai);\n    T = Math.tan(fai)*Math.tan(fai);\n    NN = a/Math.sqrt(1.0-e2*Math.sin(fai)*Math.sin(fai));\n    R = a*(1-e2)/Math.sqrt((1-e2*Math.sin(fai)*Math.sin(fai))*(1-e2*Math.sin(fai)*Math.sin(fai))*(1-e2*Math.sin\n    (fai)*Math.sin(fai)));\n    D = xval/NN;\n    //计算经度(Longitude) 纬度(Latitude)\n    longitude1 = longitude0+(D-(1+2*T+C)*D*D*D/6+(5-2*C+28*T-3*C*C+8*ee+24*T*T)*D\n        *D*D*D*D/120)/Math.cos(fai);\n    latitude1 = fai -(NN*Math.tan(fai)/R)*(D*D/2-(5+3*T+10*C-4*C*C-9*ee)*D*D*D*D/24\n        +(61+90*T+298*C+45*T*T-256*ee-3*C*C)*D*D*D*D*D*D/720);\n    //转换为度 DD\n    output[0] = longitude1 / iPI;\n    output[1] = latitude1 / iPI;\n    return output;\n}\n```\n\n## 二、经纬度 转 高斯投影坐标\n\n```\nfunction BLToGauss(longitude, latitude){\n    let ProjNo=0;\n    let ZoneWide; 带宽\n    let ret=Array(2);\n    let longitude1,latitude1, longitude0,latitude0, X0,Y0, xval,yval;\n    let a,f, e2,ee, NN, T,C,A, M, iPI;\n    iPI = 0.0174532925199433; 3.1415926535898/180.0;\n    ZoneWide = 6; 6度带宽\n    // a=6378245.0; f=1.0/298.3; //54年北京坐标系参数\n    a=6378140.0; f=1/298.257; //80年西安坐标系参数\n    ProjNo = parseInt(longitude / ZoneWide) ;\n    longitude0 = ProjNo * ZoneWide + ZoneWide / 2;\n    longitude0 = longitude0 * iPI ;\n    latitude0 = 0;\n    longitude1 = longitude * iPI ; //经度转换为弧度\n    latitude1 = latitude * iPI ; //纬度转换为弧度\n    e2=2*f-f*f;\n    ee=e2*(1.0-e2);\n    NN=a/Math.sqrt(1.0-e2*Math.sin(latitude1)*Math.sin(latitude1));\n    T=Math.tan(latitude1)*Math.tan(latitude1);\n    C=ee*Math.cos(latitude1)*Math.cos(latitude1);\n    A=(longitude1-longitude0)*Math.cos(latitude1);\n    M=a*((1-e2/4-3*e2*e2/64-5*e2*e2*e2/256)*latitude1-(3*e2/8+3*e2*e2/32+45*e2*e2\n        *e2/1024)*Math.sin(2*latitude1)\n        +(15*e2*e2/256+45*e2*e2*e2/1024)*Math.sin(4*latitude1)-(35*e2*e2*e2/3072)*Math.sin(6*latitude1));\n    xval = NN*(A+(1-T+C)*A*A*A/6+(5-18*T+T*T+72*C-58*ee)*A*A*A*A*A/120);\n    yval = M+NN*Math.tan(latitude1)*(A*A/2+(5-T+9*C+4*C*C)*A*A*A*A/24\n        +(61-58*T+T*T+600*C-330*ee)*A*A*A*A*A*A/720);\n    X0 = 1000000*(ProjNo+1)+500000;\n    Y0 = 0;\n    xval = xval+X0; yval = yval+Y0;\n    ret[0]=xval;\n    ret[1]=yval;\n\n    return ret;\n}\n```"
PS:写作不易,如要转裁,请标明转载出处。

如果此篇对您有帮助,可小额赞助,以兹鼓励!

猜你想看