source:
trunk/workshop-routing-foss4g/web/proj4js/lib/projCode/aeqd.js
@
81
Revision 76, 2.2 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 1 | Proj4js.Proj.aeqd = { |
2 | ||
3 | init : function() { | |
4 | this.sin_p12=Math.sin(this.lat0); | |
5 | this.cos_p12=Math.cos(this.lat0); | |
6 | }, | |
7 | ||
8 | forward: function(p) { | |
9 | var lon=p.x; | |
10 | var lat=p.y; | |
11 | var ksp; | |
12 | ||
13 | var sinphi=Math.sin(p.y); | |
14 | var cosphi=Math.cos(p.y); | |
15 | var dlon = Proj4js.common.adjust_lon(lon - this.long0); | |
16 | var coslon = Math.cos(dlon); | |
17 | var g = this.sin_p12 * sinphi + this.cos_p12 * cosphi * coslon; | |
18 | if (Math.abs(Math.abs(g) - 1.0) < Proj4js.common.EPSLN) { | |
19 | ksp = 1.0; | |
20 | if (g < 0.0) { | |
21 | Proj4js.reportError("aeqd:Fwd:PointError"); | |
22 | return; | |
23 | } | |
24 | } else { | |
25 | var z = Math.acos(g); | |
26 | ksp = z/Math.sin(z); | |
27 | } | |
28 | p.x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon); | |
29 | p.y = this.y0 + this.a * ksp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * coslon); | |
30 | return p; | |
31 | }, | |
32 | ||
33 | inverse: function(p){ | |
34 | p.x -= this.x0; | |
35 | p.y -= this.y0; | |
36 | ||
37 | var rh = Math.sqrt(p.x * p.x + p.y *p.y); | |
38 | if (rh > (2.0 * Proj4js.common.HALF_PI * this.a)) { | |
39 | Proj4js.reportError("aeqdInvDataError"); | |
40 | return; | |
41 | } | |
42 | var z = rh / this.a; | |
43 | ||
44 | var sinz=Math.sin(z); | |
45 | var cosz=Math.cos(z); | |
46 | ||
47 | var lon = this.long0; | |
48 | var lat; | |
49 | if (Math.abs(rh) <= Proj4js.common.EPSLN) { | |
50 | lat = this.lat0; | |
51 | } else { | |
52 | lat = Proj4js.common.asinz(cosz * this.sin_p12 + (p.y * sinz * this.cos_p12) / rh); | |
53 | var con = Math.abs(this.lat0) - Proj4js.common.HALF_PI; | |
54 | if (Math.abs(con) <= Proj4js.common.EPSLN) { | |
55 | if (lat0 >= 0.0) { | |
56 | lon = Proj4js.common.adjust_lon(this.long0 + Math.atan2(p.x , -p.y)); | |
57 | } else { | |
58 | lon = Proj4js.common.adjust_lon(this.long0 - Math.atan2(-p.x , p.y)); | |
59 | } | |
60 | } else { | |
61 | con = cosz - this.sin_p12 * Math.sin(lat); | |
62 | if ((Math.abs(con) < Proj4js.common.EPSLN) && (Math.abs(p.x) < Proj4js.common.EPSLN)) { | |
63 | //no-op, just keep the lon value as is | |
64 | } else { | |
65 | var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh)); | |
66 | lon = Proj4js.common.adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh))); | |
67 | } | |
68 | } | |
69 | } | |
70 | ||
71 | p.x = lon; | |
72 | p.y = lat; | |
73 | return p; | |
74 | } | |
75 | }; |
Note: See TracBrowser
for help on using the repository browser.