Proj4js.Proj.gauss = { init : function() { sphi = Math.sin(this.lat0); cphi = Math.cos(this.lat0); cphi *= cphi; this.rc = Math.sqrt(1.0 - this.es) / (1.0 - this.es * sphi * sphi); this.C = Math.sqrt(1.0 + this.es * cphi * cphi / (1.0 - this.es)); this.phic0 = Math.asin(sphi / this.C); this.ratexp = 0.5 * this.C * this.e; this.K = Math.tan(0.5 * this.phic0 + Proj4js.common.FORTPI) / (Math.pow(Math.tan(0.5*this.lat0 + Proj4js.common.FORTPI), this.C) * Proj4js.common.srat(this.e*sphi, this.ratexp)); }, forward : function(p) { var lon = p.x; var lat = p.y; p.y = 2.0 * Math.atan( this.K * Math.pow(Math.tan(0.5 * lat + Proj4js.common.FORTPI), this.C) * Proj4js.common.srat(this.e * Math.sin(lat), this.ratexp) ) - Proj4js.common.HALF_PI; p.x = this.C * lon; return p; }, inverse : function(p) { var DEL_TOL = 1e-14; var lon = p.x / this.C; var lat = p.y; num = Math.pow(Math.tan(0.5 * lat + Proj4js.common.FORTPI)/this.K, 1./this.C); for (var i = Proj4js.common.MAX_ITER; i>0; --i) { lat = 2.0 * Math.atan(num * Proj4js.common.srat(this.e * Math.sin(p.y), -0.5 * this.e)) - Proj4js.common.HALF_PI; if (Math.abs(lat - p.y) < DEL_TOL) break; p.y = lat; } /* convergence failed */ if (!i) { Proj4js.reportError("gauss:inverse:convergence failed"); return null; } p.x = lon; p.y = lat; return p; } };