1 package com.gradoservice.proj4as.proj
3 import com.gradoservice.proj4as.ProjConstants;
4 import com.gradoservice.proj4as.ProjPoint;
5 import com.gradoservice.proj4as.Datum;
7 public class ProjAea extends AbstractProjProjection
9 public function ProjAea(data:ProjParams)
14 override public function init():void
16 if (Math.abs(this.lat1 + this.lat2) <ProjConstants.EPSLN) {
17 trace("aeaInitEqualLatitudes");
20 this.temp = this.b / this.a;
21 this.es = 1.0 - Math.pow(this.temp,2);
22 this.e3 = Math.sqrt(this.es);
24 this.sin_po=Math.sin(this.lat1);
25 this.cos_po=Math.cos(this.lat1);
27 this.con = this.sin_po;
28 this.ms1 = ProjConstants.msfnz(this.e3,this.sin_po,this.cos_po);
29 this.qs1 = ProjConstants.qsfnz(this.e3,this.sin_po,this.cos_po);
31 this.sin_po=Math.sin(this.lat2);
32 this.cos_po=Math.cos(this.lat2);
34 this.ms2 = ProjConstants.msfnz(this.e3,this.sin_po,this.cos_po);
35 this.qs2 = ProjConstants.qsfnz(this.e3,this.sin_po,this.cos_po);
37 this.sin_po=Math.sin(this.lat0);
38 this.cos_po=Math.cos(this.lat0);
40 this.qs0 = ProjConstants.qsfnz(this.e3,this.sin_po,this.cos_po);
42 if (Math.abs(this.lat1 - this.lat2) > ProjConstants.EPSLN) {
43 this.ns0 = (this.ms1 * this.ms1 - this.ms2 *this.ms2)/ (this.qs2 - this.qs1);
47 this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1;
48 this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0)/this.ns0;
51 /* Albers Conical Equal Area forward equations--mapping lat,long to x,y
52 -------------------------------------------------------------------*/
53 override public function forward(p:ProjPoint):ProjPoint
58 this.sin_phi=Math.sin(lat);
59 this.cos_phi=Math.cos(lat);
61 var qs:Number = ProjConstants.qsfnz(this.e3,this.sin_phi,this.cos_phi);
62 var rh1:Number =this.a * Math.sqrt(this.c - this.ns0 * qs)/this.ns0;
63 var theta:Number = this.ns0 * ProjConstants.adjust_lon(lon - this.long0);
64 var x:Number = rh1 * Math.sin(theta) + this.x0;
65 var y:Number = this.rh - rh1 * Math.cos(theta) + this.y0;
73 override public function inverse(p:ProjPoint):ProjPoint
83 p.y = this.rh - p.y + this.y0;
85 rh1 = Math.sqrt(p.x *p.x + p.y * p.y);
88 rh1 = -Math.sqrt(p.x * p.x + p.y *p.y);
93 theta = Math.atan2(con * p.x, con * p.y);
95 con = rh1 * this.ns0 / this.a;
96 qs = (this.c - con * con) / this.ns0;
97 if (this.e3 >= 1e-10) {
98 con = 1 - .5 * (1.0 -this.es) * Math.log((1.0 - this.e3) / (1.0 + this.e3))/this.e3;
99 if (Math.abs(Math.abs(con) - Math.abs(qs)) > .0000000001 ) {
100 lat = this.phi1z(this.e3,qs);
109 lat = this.phi1z(e3,qs);
112 lon = ProjConstants.adjust_lon(theta/this.ns0 + this.long0);
118 /* Function to compute phi1, the latitude for the inverse of the
119 Albers Conical Equal-Area projection.
120 -------------------------------------------*/
121 private function phi1z (eccent:Number,qs:Number):Number
126 var phi:Number = ProjConstants.asinz(.5 * qs);
127 if (eccent < ProjConstants.EPSLN) return phi;
129 var eccnts:Number = eccent * eccent;
130 for (var i:int = 1; i <= 25; i++) {
131 sinphi = Math.sin(phi);
132 cosphi = Math.cos(phi);
133 con = eccent * sinphi;
134 com = 1.0 - con * con;
135 dphi = .5 * com * com / cosphi * (qs / (1.0 - eccnts) - sinphi / com + .5 / eccent * Math.log((1.0 - con) / (1.0 + con)));
137 if (Math.abs(dphi) <= 1e-7) return phi;
139 trace("aea:phi1z:Convergence error");