source:
trunk/workshop-routing-foss4g/web/proj4js/lib/projCode/sterea.js
@
81
Revision 76, 1.6 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 1 | |
2 | Proj4js.Proj.sterea = { | |
3 | dependsOn : 'gauss', | |
4 | ||
5 | init : function() { | |
6 | Proj4js.Proj['gauss'].init.apply(this); | |
7 | if (!this.rc) { | |
8 | Proj4js.reportError("sterea:init:E_ERROR_0"); | |
9 | return; | |
10 | } | |
11 | this.sinc0 = Math.sin(this.phic0); | |
12 | this.cosc0 = Math.cos(this.phic0); | |
13 | this.R2 = 2.0 * this.rc; | |
14 | if (!this.title) this.title = "Oblique Stereographic Alternative"; | |
15 | }, | |
16 | ||
17 | forward : function(p) { | |
18 | p.x = Proj4js.common.adjust_lon(p.x-this.long0); /* adjust del longitude */ | |
19 | Proj4js.Proj['gauss'].forward.apply(this, [p]); | |
20 | sinc = Math.sin(p.y); | |
21 | cosc = Math.cos(p.y); | |
22 | cosl = Math.cos(p.x); | |
23 | k = this.k0 * this.R2 / (1.0 + this.sinc0 * sinc + this.cosc0 * cosc * cosl); | |
24 | p.x = k * cosc * Math.sin(p.x); | |
25 | p.y = k * (this.cosc0 * sinc - this.sinc0 * cosc * cosl); | |
26 | p.x = this.a * p.x + this.x0; | |
27 | p.y = this.a * p.y + this.y0; | |
28 | return p; | |
29 | }, | |
30 | ||
31 | inverse : function(p) { | |
32 | var lon,lat; | |
33 | p.x = (p.x - this.x0) / this.a; /* descale and de-offset */ | |
34 | p.y = (p.y - this.y0) / this.a; | |
35 | ||
36 | p.x /= this.k0; | |
37 | p.y /= this.k0; | |
38 | if ( (rho = Math.sqrt(p.x*p.x + p.y*p.y)) ) { | |
39 | c = 2.0 * Math.atan2(rho, this.R2); | |
40 | sinc = Math.sin(c); | |
41 | cosc = Math.cos(c); | |
42 | lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho); | |
43 | lon = Math.atan2(p.x * sinc, rho * this.cosc0 * cosc - p.y * this.sinc0 * sinc); | |
44 | } else { | |
45 | lat = this.phic0; | |
46 | lon = 0.; | |
47 | } | |
48 | ||
49 | p.x = lon; | |
50 | p.y = lat; | |
51 | Proj4js.Proj['gauss'].inverse.apply(this,[p]); | |
52 | p.x = Proj4js.common.adjust_lon(p.x + this.long0); /* adjust longitude to CM */ | |
53 | return p; | |
54 | } | |
55 | }; | |
56 |
Note: See TracBrowser
for help on using the repository browser.