[76] | 1 | /******************************************************************************* |
---|
| 2 | NAME ALBERS CONICAL EQUAL AREA |
---|
| 3 | |
---|
| 4 | PURPOSE: Transforms input longitude and latitude to Easting and Northing |
---|
| 5 | for the Albers Conical Equal Area projection. The longitude |
---|
| 6 | and latitude must be in radians. The Easting and Northing |
---|
| 7 | values will be returned in meters. |
---|
| 8 | |
---|
| 9 | PROGRAMMER DATE |
---|
| 10 | ---------- ---- |
---|
| 11 | T. Mittan, Feb, 1992 |
---|
| 12 | |
---|
| 13 | ALGORITHM REFERENCES |
---|
| 14 | |
---|
| 15 | 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
---|
| 16 | Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
---|
| 17 | State Government Printing Office, Washington D.C., 1987. |
---|
| 18 | |
---|
| 19 | 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
---|
| 20 | U.S. Geological Survey Professional Paper 1453 , United State Government |
---|
| 21 | Printing Office, Washington D.C., 1989. |
---|
| 22 | *******************************************************************************/ |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | Proj4js.Proj.aea = { |
---|
| 26 | init : function() { |
---|
| 27 | |
---|
| 28 | if (Math.abs(this.lat1 + this.lat2) < Proj4js.common.EPSLN) { |
---|
| 29 | Proj4js.reportError("aeaInitEqualLatitudes"); |
---|
| 30 | return; |
---|
| 31 | } |
---|
| 32 | this.temp = this.b / this.a; |
---|
| 33 | this.es = 1.0 - Math.pow(this.temp,2); |
---|
| 34 | this.e3 = Math.sqrt(this.es); |
---|
| 35 | |
---|
| 36 | this.sin_po=Math.sin(this.lat1); |
---|
| 37 | this.cos_po=Math.cos(this.lat1); |
---|
| 38 | this.t1=this.sin_po; |
---|
| 39 | this.con = this.sin_po; |
---|
| 40 | this.ms1 = Proj4js.common.msfnz(this.e3,this.sin_po,this.cos_po); |
---|
| 41 | this.qs1 = Proj4js.common.qsfnz(this.e3,this.sin_po,this.cos_po); |
---|
| 42 | |
---|
| 43 | this.sin_po=Math.sin(this.lat2); |
---|
| 44 | this.cos_po=Math.cos(this.lat2); |
---|
| 45 | this.t2=this.sin_po; |
---|
| 46 | this.ms2 = Proj4js.common.msfnz(this.e3,this.sin_po,this.cos_po); |
---|
| 47 | this.qs2 = Proj4js.common.qsfnz(this.e3,this.sin_po,this.cos_po); |
---|
| 48 | |
---|
| 49 | this.sin_po=Math.sin(this.lat0); |
---|
| 50 | this.cos_po=Math.cos(this.lat0); |
---|
| 51 | this.t3=this.sin_po; |
---|
| 52 | this.qs0 = Proj4js.common.qsfnz(this.e3,this.sin_po,this.cos_po); |
---|
| 53 | |
---|
| 54 | if (Math.abs(this.lat1 - this.lat2) > Proj4js.common.EPSLN) { |
---|
| 55 | this.ns0 = (this.ms1 * this.ms1 - this.ms2 *this.ms2)/ (this.qs2 - this.qs1); |
---|
| 56 | } else { |
---|
| 57 | this.ns0 = this.con; |
---|
| 58 | } |
---|
| 59 | this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1; |
---|
| 60 | this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0)/this.ns0; |
---|
| 61 | }, |
---|
| 62 | |
---|
| 63 | /* Albers Conical Equal Area forward equations--mapping lat,long to x,y |
---|
| 64 | -------------------------------------------------------------------*/ |
---|
| 65 | forward: function(p){ |
---|
| 66 | |
---|
| 67 | var lon=p.x; |
---|
| 68 | var lat=p.y; |
---|
| 69 | |
---|
| 70 | this.sin_phi=Math.sin(lat); |
---|
| 71 | this.cos_phi=Math.cos(lat); |
---|
| 72 | |
---|
| 73 | var qs = Proj4js.common.qsfnz(this.e3,this.sin_phi,this.cos_phi); |
---|
| 74 | var rh1 =this.a * Math.sqrt(this.c - this.ns0 * qs)/this.ns0; |
---|
| 75 | var theta = this.ns0 * Proj4js.common.adjust_lon(lon - this.long0); |
---|
| 76 | var x = rh1 * Math.sin(theta) + this.x0; |
---|
| 77 | var y = this.rh - rh1 * Math.cos(theta) + this.y0; |
---|
| 78 | |
---|
| 79 | p.x = x; |
---|
| 80 | p.y = y; |
---|
| 81 | return p; |
---|
| 82 | }, |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | inverse: function(p) { |
---|
| 86 | var rh1,qs,con,theta,lon,lat; |
---|
| 87 | |
---|
| 88 | p.x -= this.x0; |
---|
| 89 | p.y = this.rh - p.y + this.y0; |
---|
| 90 | if (this.ns0 >= 0) { |
---|
| 91 | rh1 = Math.sqrt(p.x *p.x + p.y * p.y); |
---|
| 92 | con = 1.0; |
---|
| 93 | } else { |
---|
| 94 | rh1 = -Math.sqrt(p.x * p.x + p.y *p.y); |
---|
| 95 | con = -1.0; |
---|
| 96 | } |
---|
| 97 | theta = 0.0; |
---|
| 98 | if (rh1 != 0.0) { |
---|
| 99 | theta = Math.atan2(con * p.x, con * p.y); |
---|
| 100 | } |
---|
| 101 | con = rh1 * this.ns0 / this.a; |
---|
| 102 | qs = (this.c - con * con) / this.ns0; |
---|
| 103 | if (this.e3 >= 1e-10) { |
---|
| 104 | con = 1 - .5 * (1.0 -this.es) * Math.log((1.0 - this.e3) / (1.0 + this.e3))/this.e3; |
---|
| 105 | if (Math.abs(Math.abs(con) - Math.abs(qs)) > .0000000001 ) { |
---|
| 106 | lat = this.phi1z(this.e3,qs); |
---|
| 107 | } else { |
---|
| 108 | if (qs >= 0) { |
---|
| 109 | lat = .5 * PI; |
---|
| 110 | } else { |
---|
| 111 | lat = -.5 * PI; |
---|
| 112 | } |
---|
| 113 | } |
---|
| 114 | } else { |
---|
| 115 | lat = this.phi1z(e3,qs); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | lon = Proj4js.common.adjust_lon(theta/this.ns0 + this.long0); |
---|
| 119 | p.x = lon; |
---|
| 120 | p.y = lat; |
---|
| 121 | return p; |
---|
| 122 | }, |
---|
| 123 | |
---|
| 124 | /* Function to compute phi1, the latitude for the inverse of the |
---|
| 125 | Albers Conical Equal-Area projection. |
---|
| 126 | -------------------------------------------*/ |
---|
| 127 | phi1z: function (eccent,qs) { |
---|
| 128 | var con, com, dphi; |
---|
| 129 | var phi = Proj4js.common.asinz(.5 * qs); |
---|
| 130 | if (eccent < Proj4js.common.EPSLN) return phi; |
---|
| 131 | |
---|
| 132 | var eccnts = eccent * eccent; |
---|
| 133 | for (var i = 1; i <= 25; i++) { |
---|
| 134 | sinphi = Math.sin(phi); |
---|
| 135 | cosphi = Math.cos(phi); |
---|
| 136 | con = eccent * sinphi; |
---|
| 137 | com = 1.0 - con * con; |
---|
| 138 | dphi = .5 * com * com / cosphi * (qs / (1.0 - eccnts) - sinphi / com + .5 / eccent * Math.log((1.0 - con) / (1.0 + con))); |
---|
| 139 | phi = phi + dphi; |
---|
| 140 | if (Math.abs(dphi) <= 1e-7) return phi; |
---|
| 141 | } |
---|
| 142 | Proj4js.reportError("aea:phi1z:Convergence error"); |
---|
| 143 | return null; |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | }; |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | |
---|