source:
trunk/workshop-routing-foss4g/web/proj4js/lib/projCode/gauss.js
@
77
Revision 76, 1.4 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | |
2 | Proj4js.Proj.gauss = { |
3 | |
4 | init : function() { |
5 | sphi = Math.sin(this.lat0); |
6 | cphi = Math.cos(this.lat0); |
7 | cphi *= cphi; |
8 | this.rc = Math.sqrt(1.0 - this.es) / (1.0 - this.es * sphi * sphi); |
9 | this.C = Math.sqrt(1.0 + this.es * cphi * cphi / (1.0 - this.es)); |
10 | this.phic0 = Math.asin(sphi / this.C); |
11 | this.ratexp = 0.5 * this.C * this.e; |
12 | 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)); |
13 | }, |
14 | |
15 | forward : function(p) { |
16 | var lon = p.x; |
17 | var lat = p.y; |
18 | |
19 | 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; |
20 | p.x = this.C * lon; |
21 | return p; |
22 | }, |
23 | |
24 | inverse : function(p) { |
25 | var DEL_TOL = 1e-14; |
26 | var lon = p.x / this.C; |
27 | var lat = p.y; |
28 | num = Math.pow(Math.tan(0.5 * lat + Proj4js.common.FORTPI)/this.K, 1./this.C); |
29 | for (var i = Proj4js.common.MAX_ITER; i>0; --i) { |
30 | lat = 2.0 * Math.atan(num * Proj4js.common.srat(this.e * Math.sin(p.y), -0.5 * this.e)) - Proj4js.common.HALF_PI; |
31 | if (Math.abs(lat - p.y) < DEL_TOL) break; |
32 | p.y = lat; |
33 | } |
34 | /* convergence failed */ |
35 | if (!i) { |
36 | Proj4js.reportError("gauss:inverse:convergence failed"); |
37 | return null; |
38 | } |
39 | p.x = lon; |
40 | p.y = lat; |
41 | return p; |
42 | } |
43 | }; |
44 |
Note: See TracBrowser
for help on using the repository browser.