--- /dev/null
+Proj4js.Proj.aeqd = {\r
+\r
+ init : function() {\r
+ this.sin_p12=Math.sin(this.lat0);\r
+ this.cos_p12=Math.cos(this.lat0);\r
+ },\r
+\r
+ forward: function(p) {\r
+ var lon=p.x;\r
+ var lat=p.y;\r
+ var ksp;\r
+\r
+ var sinphi=Math.sin(p.y);\r
+ var cosphi=Math.cos(p.y); \r
+ var dlon = Proj4js.common.adjust_lon(lon - this.long0);\r
+ var coslon = Math.cos(dlon);\r
+ var g = this.sin_p12 * sinphi + this.cos_p12 * cosphi * coslon;\r
+ if (Math.abs(Math.abs(g) - 1.0) < Proj4js.common.EPSLN) {\r
+ ksp = 1.0;\r
+ if (g < 0.0) {\r
+ Proj4js.reportError("aeqd:Fwd:PointError");\r
+ return;\r
+ }\r
+ } else {\r
+ var z = Math.acos(g);\r
+ ksp = z/Math.sin(z);\r
+ }\r
+ p.x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon);\r
+ p.y = this.y0 + this.a * ksp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * coslon);\r
+ return p;\r
+ },\r
+\r
+ inverse: function(p){\r
+ p.x -= this.x0;\r
+ p.y -= this.y0;\r
+\r
+ var rh = Math.sqrt(p.x * p.x + p.y *p.y);\r
+ if (rh > (2.0 * Proj4js.common.HALF_PI * this.a)) {\r
+ Proj4js.reportError("aeqdInvDataError");\r
+ return;\r
+ }\r
+ var z = rh / this.a;\r
+\r
+ var sinz=Math.sin(z);\r
+ var cosz=Math.cos(z);\r
+\r
+ var lon = this.long0;\r
+ var lat;\r
+ if (Math.abs(rh) <= Proj4js.common.EPSLN) {\r
+ lat = this.lat0;\r
+ } else {\r
+ lat = Proj4js.common.asinz(cosz * this.sin_p12 + (p.y * sinz * this.cos_p12) / rh);\r
+ var con = Math.abs(this.lat0) - Proj4js.common.HALF_PI;\r
+ if (Math.abs(con) <= Proj4js.common.EPSLN) {\r
+ if (lat0 >= 0.0) {\r
+ lon = Proj4js.common.adjust_lon(this.long0 + Math.atan2(p.x , -p.y));\r
+ } else {\r
+ lon = Proj4js.common.adjust_lon(this.long0 - Math.atan2(-p.x , p.y));\r
+ }\r
+ } else {\r
+ con = cosz - this.sin_p12 * Math.sin(lat);\r
+ if ((Math.abs(con) < Proj4js.common.EPSLN) && (Math.abs(p.x) < Proj4js.common.EPSLN)) {\r
+ //no-op, just keep the lon value as is\r
+ } else {\r
+ var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));\r
+ lon = Proj4js.common.adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));\r
+ }\r
+ }\r
+ }\r
+\r
+ p.x = lon;\r
+ p.y = lat;\r
+ return p;\r
+ } \r
+};\r