Loading src/projCode/laea.js +69 −76 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ proj4.Proj.laea = { init: function() { var t = Math.abs(this.lat0); if (Math.abs(t - proj4.common.HALF_PI) < proj4.common.EPSLN) { this.mode = this.lat0 < 0. ? this.S_POLE : this.N_POLE; this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE; } else if (Math.abs(t) < proj4.common.EPSLN) { this.mode = this.EQUIT; Loading @@ -50,33 +50,35 @@ proj4.Proj.laea = { if (this.es > 0) { var sinphi; this.qp = proj4.common.qsfnz(this.e, 1.0); this.mmf = .5 / (1. - this.es); this.qp = proj4.common.qsfnz(this.e, 1); this.mmf = 0.5 / (1 - this.es); this.apa = this.authset(this.es); switch (this.mode) { case this.N_POLE: this.dd = 1; break; case this.S_POLE: this.dd = 1.; this.dd = 1; break; case this.EQUIT: this.rq = Math.sqrt(.5 * this.qp); this.dd = 1. / this.rq; this.xmf = 1.; this.ymf = .5 * this.qp; this.rq = Math.sqrt(0.5 * this.qp); this.dd = 1.0 / this.rq; this.xmf = 1.0; this.ymf = 0.5 * this.qp; break; case this.OBLIQ: this.rq = Math.sqrt(.5 * this.qp); this.rq = Math.sqrt(0.5 * this.qp); sinphi = Math.sin(this.lat0); this.sinb1 = proj4.common.qsfnz(this.e, sinphi) / this.qp; this.cosb1 = Math.sqrt(1. - this.sinb1 * this.sinb1); this.dd = Math.cos(this.lat0) / (Math.sqrt(1. - this.es * sinphi * sinphi) * this.rq * this.cosb1); this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1); this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1); this.ymf = (this.xmf = this.rq) / this.dd; this.xmf *= this.dd; break; } } else { if (this.mode == this.OBLIQ) { if (this.mode === this.OBLIQ) { this.sinph0 = Math.sin(this.lat0); this.cosph0 = Math.cos(this.lat0); } Loading @@ -89,62 +91,57 @@ proj4.Proj.laea = { /* Forward equations -----------------*/ var x, y; var x, y,coslam, sinlam, sinphi, q, sinb,cosb,b,cosphi; var lam = p.x; var phi = p.y; lam = proj4.common.adjust_lon(lam - this.long0); if (this.sphere) { var coslam, cosphi, sinphi; sinphi = Math.sin(phi); cosphi = Math.cos(phi); coslam = Math.cos(lam); switch (this.mode) { case this.OBLIQ: case this.EQUIT: y = (this.mode == this.EQUIT) ? 1. + cosphi * coslam : 1. + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam; if(this.mode === this.OBLIQ || this.mode === this.EQUIT){ y = (this.mode === this.EQUIT) ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam; if (y <= proj4.common.EPSLN) { proj4.reportError("laea:fwd:y less than eps"); return null; } y = Math.sqrt(2. / y); y = Math.sqrt(2 / y); x = y * cosphi * Math.sin(lam); y *= (this.mode == this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam; break; case this.N_POLE: y *= (this.mode === this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam; } else if(this.mode === this.N_POLE|| this.mode === this.S_POLE){ if(this.mode === this.N_POLE){ coslam = -coslam; case this.S_POLE: } if (Math.abs(phi + this.phi0) < proj4.common.EPSLN) { proj4.reportError("laea:fwd:phi < eps"); return null; } y = proj4.common.FORTPI - phi * .5; y = 2. * ((this.mode == this.S_POLE) ? Math.cos(y) : Math.sin(y)); y = proj4.common.FORTPI - phi * 0.5; y = 2 * ((this.mode === this.S_POLE) ? Math.cos(y) : Math.sin(y)); x = y * Math.sin(lam); y *= coslam; break; } } else { var coslam, sinlam, sinphi, q, sinb = 0.0, cosb = 0.0, b = 0.0; sinb = 0; cosb = 0; b = 0; coslam = Math.cos(lam); sinlam = Math.sin(lam); sinphi = Math.sin(phi); q = proj4.common.qsfnz(this.e, sinphi); if (this.mode == this.OBLIQ || this.mode == this.EQUIT) { if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { sinb = q / this.qp; cosb = Math.sqrt(1. - sinb * sinb); cosb = Math.sqrt(1 - sinb * sinb); } switch (this.mode) { case this.OBLIQ: b = 1. + this.sinb1 * sinb + this.cosb1 * cosb * coslam; b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam; break; case this.EQUIT: b = 1. + cosb * coslam; b = 1 + cosb * coslam; break; case this.N_POLE: b = proj4.common.HALF_PI + phi; Loading @@ -162,23 +159,23 @@ proj4.Proj.laea = { switch (this.mode) { case this.OBLIQ: case this.EQUIT: b = Math.sqrt(2. / b); if (this.mode == this.OBLIQ) { b = Math.sqrt(2 / b); if (this.mode === this.OBLIQ) { y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam); } else { y = (b = Math.sqrt(2. / (1. + cosb * coslam))) * sinb * this.ymf; y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf; } x = this.xmf * b * cosb * sinlam; break; case this.N_POLE: case this.S_POLE: if (q >= 0.) { if (q >= 0) { x = (b = Math.sqrt(q)) * sinlam; y = coslam * ((this.mode == this.S_POLE) ? b : -b); y = coslam * ((this.mode === this.S_POLE) ? b : -b); } else { x = y = 0.; x = y = 0; } break; } Loading Loading @@ -213,26 +210,26 @@ proj4.Proj.laea = { p.y -= this.y0; var x = p.x / this.a; var y = p.y / this.a; var lam, phi; var lam, phi, cCe, sCe, q, rho, ab; if (this.sphere) { var cosz = 0.0, rh, sinz = 0.0; var cosz = 0, rh, sinz = 0; rh = Math.sqrt(x * x + y * y); phi = rh * .5; if (phi > 1.) { phi = rh * 0.5; if (phi > 1) { proj4.reportError("laea:Inv:DataError"); return null; } phi = 2. * Math.asin(phi); if (this.mode == this.OBLIQ || this.mode == this.EQUIT) { phi = 2 * Math.asin(phi); if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { sinz = Math.sin(phi); cosz = Math.cos(phi); } switch (this.mode) { case this.EQUIT: phi = (Math.abs(rh) <= proj4.common.EPSLN) ? 0. : Math.asin(y * sinz / rh); phi = (Math.abs(rh) <= proj4.common.EPSLN) ? 0 : Math.asin(y * sinz / rh); x *= sinz; y = cosz * rh; break; Loading @@ -249,26 +246,23 @@ proj4.Proj.laea = { phi -= proj4.common.HALF_PI; break; } lam = (y == 0. && (this.mode == this.EQUIT || this.mode == this.OBLIQ)) ? 0. : Math.atan2(x, y); lam = (y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ)) ? 0 : Math.atan2(x, y); } else { var cCe, sCe, q, rho, ab = 0.0; switch (this.mode) { case this.EQUIT: case this.OBLIQ: ab = 0; if(this.mode === this.OBLIQ || this.mode === this.EQUIT){ x /= this.dd; y *= this.dd; rho = Math.sqrt(x * x + y * y); if (rho < proj4.common.EPSLN) { p.x = 0.; p.x = 0; p.y = this.phi0; return p; } sCe = 2. * Math.asin(.5 * rho / this.rq); sCe = 2 * Math.asin(0.5 * rho / this.rq); cCe = Math.cos(sCe); x *= (sCe = Math.sin(sCe)); if (this.mode == this.OBLIQ) { if (this.mode === this.OBLIQ) { ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho; q = this.qp * ab; y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe; Loading @@ -278,24 +272,23 @@ proj4.Proj.laea = { q = this.qp * ab; y = rho * cCe; } break; case this.N_POLE: }else if(this.mode === this.N_POLE || this.mode === this.S_POLE){ if(this.mode === this.N_POLE){ y = -y; case this.S_POLE: } q = (x * x + y * y); if (!q) { p.x = 0.; p.x = 0; p.y = this.phi0; return p; } /* q = this.qp - q; */ ab = 1. - q / this.qp; if (this.mode == this.S_POLE) { ab = 1 - q / this.qp; if (this.mode === this.S_POLE) { ab = -ab; } break; } lam = Math.atan2(x, y); phi = this.authlat(Math.asin(ab), this.apa); Loading Loading @@ -337,16 +330,16 @@ proj4.Proj.laea = { }, //lamazInv() /* determine latitude from authalic latitude */ P00: .33333333333333333333, P01: .17222222222222222222, P02: .10257936507936507936, P10: .06388888888888888888, P11: .06640211640211640211, P20: .01641501294219154443, P00: 0.33333333333333333333, P01: 0.17222222222222222222, P02: 0.10257936507936507936, P10: 0.06388888888888888888, P11: 0.06640211640211640211, P20: 0.01641501294219154443, authset: function(es) { var t; var APA = new Array(); var APA = []; APA[0] = es * this.P00; t = es * es; APA[0] += t * this.P01; Loading Loading
src/projCode/laea.js +69 −76 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ proj4.Proj.laea = { init: function() { var t = Math.abs(this.lat0); if (Math.abs(t - proj4.common.HALF_PI) < proj4.common.EPSLN) { this.mode = this.lat0 < 0. ? this.S_POLE : this.N_POLE; this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE; } else if (Math.abs(t) < proj4.common.EPSLN) { this.mode = this.EQUIT; Loading @@ -50,33 +50,35 @@ proj4.Proj.laea = { if (this.es > 0) { var sinphi; this.qp = proj4.common.qsfnz(this.e, 1.0); this.mmf = .5 / (1. - this.es); this.qp = proj4.common.qsfnz(this.e, 1); this.mmf = 0.5 / (1 - this.es); this.apa = this.authset(this.es); switch (this.mode) { case this.N_POLE: this.dd = 1; break; case this.S_POLE: this.dd = 1.; this.dd = 1; break; case this.EQUIT: this.rq = Math.sqrt(.5 * this.qp); this.dd = 1. / this.rq; this.xmf = 1.; this.ymf = .5 * this.qp; this.rq = Math.sqrt(0.5 * this.qp); this.dd = 1.0 / this.rq; this.xmf = 1.0; this.ymf = 0.5 * this.qp; break; case this.OBLIQ: this.rq = Math.sqrt(.5 * this.qp); this.rq = Math.sqrt(0.5 * this.qp); sinphi = Math.sin(this.lat0); this.sinb1 = proj4.common.qsfnz(this.e, sinphi) / this.qp; this.cosb1 = Math.sqrt(1. - this.sinb1 * this.sinb1); this.dd = Math.cos(this.lat0) / (Math.sqrt(1. - this.es * sinphi * sinphi) * this.rq * this.cosb1); this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1); this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1); this.ymf = (this.xmf = this.rq) / this.dd; this.xmf *= this.dd; break; } } else { if (this.mode == this.OBLIQ) { if (this.mode === this.OBLIQ) { this.sinph0 = Math.sin(this.lat0); this.cosph0 = Math.cos(this.lat0); } Loading @@ -89,62 +91,57 @@ proj4.Proj.laea = { /* Forward equations -----------------*/ var x, y; var x, y,coslam, sinlam, sinphi, q, sinb,cosb,b,cosphi; var lam = p.x; var phi = p.y; lam = proj4.common.adjust_lon(lam - this.long0); if (this.sphere) { var coslam, cosphi, sinphi; sinphi = Math.sin(phi); cosphi = Math.cos(phi); coslam = Math.cos(lam); switch (this.mode) { case this.OBLIQ: case this.EQUIT: y = (this.mode == this.EQUIT) ? 1. + cosphi * coslam : 1. + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam; if(this.mode === this.OBLIQ || this.mode === this.EQUIT){ y = (this.mode === this.EQUIT) ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam; if (y <= proj4.common.EPSLN) { proj4.reportError("laea:fwd:y less than eps"); return null; } y = Math.sqrt(2. / y); y = Math.sqrt(2 / y); x = y * cosphi * Math.sin(lam); y *= (this.mode == this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam; break; case this.N_POLE: y *= (this.mode === this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam; } else if(this.mode === this.N_POLE|| this.mode === this.S_POLE){ if(this.mode === this.N_POLE){ coslam = -coslam; case this.S_POLE: } if (Math.abs(phi + this.phi0) < proj4.common.EPSLN) { proj4.reportError("laea:fwd:phi < eps"); return null; } y = proj4.common.FORTPI - phi * .5; y = 2. * ((this.mode == this.S_POLE) ? Math.cos(y) : Math.sin(y)); y = proj4.common.FORTPI - phi * 0.5; y = 2 * ((this.mode === this.S_POLE) ? Math.cos(y) : Math.sin(y)); x = y * Math.sin(lam); y *= coslam; break; } } else { var coslam, sinlam, sinphi, q, sinb = 0.0, cosb = 0.0, b = 0.0; sinb = 0; cosb = 0; b = 0; coslam = Math.cos(lam); sinlam = Math.sin(lam); sinphi = Math.sin(phi); q = proj4.common.qsfnz(this.e, sinphi); if (this.mode == this.OBLIQ || this.mode == this.EQUIT) { if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { sinb = q / this.qp; cosb = Math.sqrt(1. - sinb * sinb); cosb = Math.sqrt(1 - sinb * sinb); } switch (this.mode) { case this.OBLIQ: b = 1. + this.sinb1 * sinb + this.cosb1 * cosb * coslam; b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam; break; case this.EQUIT: b = 1. + cosb * coslam; b = 1 + cosb * coslam; break; case this.N_POLE: b = proj4.common.HALF_PI + phi; Loading @@ -162,23 +159,23 @@ proj4.Proj.laea = { switch (this.mode) { case this.OBLIQ: case this.EQUIT: b = Math.sqrt(2. / b); if (this.mode == this.OBLIQ) { b = Math.sqrt(2 / b); if (this.mode === this.OBLIQ) { y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam); } else { y = (b = Math.sqrt(2. / (1. + cosb * coslam))) * sinb * this.ymf; y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf; } x = this.xmf * b * cosb * sinlam; break; case this.N_POLE: case this.S_POLE: if (q >= 0.) { if (q >= 0) { x = (b = Math.sqrt(q)) * sinlam; y = coslam * ((this.mode == this.S_POLE) ? b : -b); y = coslam * ((this.mode === this.S_POLE) ? b : -b); } else { x = y = 0.; x = y = 0; } break; } Loading Loading @@ -213,26 +210,26 @@ proj4.Proj.laea = { p.y -= this.y0; var x = p.x / this.a; var y = p.y / this.a; var lam, phi; var lam, phi, cCe, sCe, q, rho, ab; if (this.sphere) { var cosz = 0.0, rh, sinz = 0.0; var cosz = 0, rh, sinz = 0; rh = Math.sqrt(x * x + y * y); phi = rh * .5; if (phi > 1.) { phi = rh * 0.5; if (phi > 1) { proj4.reportError("laea:Inv:DataError"); return null; } phi = 2. * Math.asin(phi); if (this.mode == this.OBLIQ || this.mode == this.EQUIT) { phi = 2 * Math.asin(phi); if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { sinz = Math.sin(phi); cosz = Math.cos(phi); } switch (this.mode) { case this.EQUIT: phi = (Math.abs(rh) <= proj4.common.EPSLN) ? 0. : Math.asin(y * sinz / rh); phi = (Math.abs(rh) <= proj4.common.EPSLN) ? 0 : Math.asin(y * sinz / rh); x *= sinz; y = cosz * rh; break; Loading @@ -249,26 +246,23 @@ proj4.Proj.laea = { phi -= proj4.common.HALF_PI; break; } lam = (y == 0. && (this.mode == this.EQUIT || this.mode == this.OBLIQ)) ? 0. : Math.atan2(x, y); lam = (y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ)) ? 0 : Math.atan2(x, y); } else { var cCe, sCe, q, rho, ab = 0.0; switch (this.mode) { case this.EQUIT: case this.OBLIQ: ab = 0; if(this.mode === this.OBLIQ || this.mode === this.EQUIT){ x /= this.dd; y *= this.dd; rho = Math.sqrt(x * x + y * y); if (rho < proj4.common.EPSLN) { p.x = 0.; p.x = 0; p.y = this.phi0; return p; } sCe = 2. * Math.asin(.5 * rho / this.rq); sCe = 2 * Math.asin(0.5 * rho / this.rq); cCe = Math.cos(sCe); x *= (sCe = Math.sin(sCe)); if (this.mode == this.OBLIQ) { if (this.mode === this.OBLIQ) { ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho; q = this.qp * ab; y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe; Loading @@ -278,24 +272,23 @@ proj4.Proj.laea = { q = this.qp * ab; y = rho * cCe; } break; case this.N_POLE: }else if(this.mode === this.N_POLE || this.mode === this.S_POLE){ if(this.mode === this.N_POLE){ y = -y; case this.S_POLE: } q = (x * x + y * y); if (!q) { p.x = 0.; p.x = 0; p.y = this.phi0; return p; } /* q = this.qp - q; */ ab = 1. - q / this.qp; if (this.mode == this.S_POLE) { ab = 1 - q / this.qp; if (this.mode === this.S_POLE) { ab = -ab; } break; } lam = Math.atan2(x, y); phi = this.authlat(Math.asin(ab), this.apa); Loading Loading @@ -337,16 +330,16 @@ proj4.Proj.laea = { }, //lamazInv() /* determine latitude from authalic latitude */ P00: .33333333333333333333, P01: .17222222222222222222, P02: .10257936507936507936, P10: .06388888888888888888, P11: .06640211640211640211, P20: .01641501294219154443, P00: 0.33333333333333333333, P01: 0.17222222222222222222, P02: 0.10257936507936507936, P10: 0.06388888888888888888, P11: 0.06640211640211640211, P20: 0.01641501294219154443, authset: function(es) { var t; var APA = new Array(); var APA = []; APA[0] = es * this.P00; t = es * es; APA[0] += t * this.P01; Loading