Proj4js LCC and WGS84 coordinate transformations in the

Source: Internet
Author: User
Tags cos sin

Tag:oat    need    ilo   efi   ict    put    using    ecc   wgs84   

Proj4 is a very useful coordinate system conversion library, its rich coordinate system type and development language, make the conversion very convenient, but when we only need the very few coordinate systems to convert each other, the coordinate volume is relatively large, it is faced with performance problems, in view of the use of work, the extraction of the LCC and WGS84 coordinate system transformation , the source code is as follows: ' var lccToWgs84 = function () {"Use strict"; var Epsln = (typeof Number.epsilon = = ' undefined ')? 1.0e-10:number.e Psilon;var CONV = 180/math.pi;var Half_pi = Math.pi/2;var SPI = 3.14159265359;var TWO_PI = 2 * Math.pi;var a = 6378137 var b = 6356752.314245179;var E = 0.08181919084262157;var LAT1 = 0.52359877559829;var lat2 = 1.04719755119659;//var c_la t = 33.30001;//var C_lon = 103.3;var Long0 = 1.8029251173101;var Lat0 = 0;var K0 = 1;//var lat1 = 30/conv;//var lat2 = 60/conv;//var C_lat = 33.30001;//var C_lon = 103.3;//var long0 = c_lon/conv;//var lat0 = C_lat/conv;var Ns;var F0;var Rh;var tsfnz = function (Eccent, phi, Sinphi) {var con = eccent * Sinphi; var com = 0.5 * eccent; con = Math.pow (( (1-con)/(1 + con)), COM); Return (Math.tan (0.5 * (half_pi-phi))/con); var sign = function (x) {return x < 0 -1:1;}; var msfnz = function (eccent, Sinphi, Cosphi) {var con = eccent * SINPHI; return cosphi/(math.sqrt (1-con * con));}; var Adjust_lon = function (x) {return (Math.Abs (x) <= SPI) x: (X-(sign (x) * two_pi));}; var phi2z = function (eccent, ts) {var eccnth = 0.5 * eccent; var con, dphi; var phi = half_pi-2 * Math.atan (TS); for (VA R i = 0; I <= 15; i++) {con = eccent * Math.sin (phi); dphi = half_pi-2 * Math.atan (TS * (Math.pow ((((1-con)/(1 + con), eccnth))-ph I Phi + = Dphi; if (Math.Abs (dphi) <= 0.0000000001) {return phi;}} Console.log ("phi2z has noconvergence"); return-9999;}; function init (PRJSTR) {if (Prjstr.indexof ("") >-1) {var _prjarr = Prjstr.split (""); _prjarr.foreach (function (item, index, input) {if (Item.indexof ("Lat_0") >-1) {lat0 = parsefloat (item.split ("=") [1]) /conv; }})} var sin1 = Math.sin (LAT1); var cos1 = Math.Cos (LAT1); var ms1 = Msfnz (E, sin1, COS1); var ts1 = Tsfnz (E, LAT1, sin1); var sin2 = Math.sin (LAT2); var cos2 = Math.Cos (LAT2); var MS2 = Msfnz (E, SiN2, Cos2); var ts2 = Tsfnz (E, Lat2, sin2); var ts0 = Tsfnz (E, Lat0, Math.sin (lat0)); if (Math.Abs (LAT1-LAT2) > Epsln) {ns = Math.log (MS1/MS2)/Math.log (TS1/TS2);} else {ns = sin1;} if (IsNaN (NS)) {ns = sin1;} F0 = MS1/(NS * MATH.POW (TS1, NS)); RH = A * F0 * MATH.POW (TS0, NS);} function Projcood (lon, LAT) {lon = Lon/conv; lat = lat/conv; if (Math.Abs (2 * math.abs (LAT)-Math.PI) <= Epsln) { Lat = sign (LAT) * (half_pi-2 * Epsln); } var con = Math.Abs (Math.Abs (LAT)-HALF_PI); var ts, Rh1; if (Con > Epsln) {ts = TSFNZ (e, lat, Math.sin (LAT)), Rh1 = A * F0 * MATH.POW (ts, NS);} else {con = lat * NS; if (Con & lt;= 0) {return null;} RH1 = 0; } var theta = ns * Adjust_lon (LON-LONG0); var Nlon = (RH1 * Math.sin (theta)); var Nlat = (RH-RH1 * Math.Cos (theta)); return [Nlon, Nlat];} return {init:init, projcood:projcood};

}();`

Proj4js LCC and WGS84 coordinate transformations in the

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.