1 | /* Function to compute, phi4, the latitude for the inverse of the |
---|
2 | Polyconic projection. |
---|
3 | ------------------------------------------------------------*/ |
---|
4 | function phi4z (eccent,e0,e1,e2,e3,a,b,c,phi) { |
---|
5 | var sinphi, sin2ph, tanph, ml, mlp, con1, con2, con3, dphi, i; |
---|
6 | |
---|
7 | phi = a; |
---|
8 | for (i = 1; i <= 15; i++) { |
---|
9 | sinphi = Math.sin(phi); |
---|
10 | tanphi = Math.tan(phi); |
---|
11 | c = tanphi * Math.sqrt (1.0 - eccent * sinphi * sinphi); |
---|
12 | sin2ph = Math.sin (2.0 * phi); |
---|
13 | /* |
---|
14 | ml = e0 * *phi - e1 * sin2ph + e2 * sin (4.0 * *phi); |
---|
15 | mlp = e0 - 2.0 * e1 * cos (2.0 * *phi) + 4.0 * e2 * cos (4.0 * *phi); |
---|
16 | */ |
---|
17 | ml = e0 * phi - e1 * sin2ph + e2 * Math.sin (4.0 * phi) - e3 * Math.sin (6.0 * phi); |
---|
18 | mlp = e0 - 2.0 * e1 * Math.cos (2.0 * phi) + 4.0 * e2 * Math.cos (4.0 * phi) - 6.0 * e3 * Math.cos (6.0 * phi); |
---|
19 | con1 = 2.0 * ml + c * (ml * ml + b) - 2.0 * a * (c * ml + 1.0); |
---|
20 | con2 = eccent * sin2ph * (ml * ml + b - 2.0 * a * ml) / (2.0 *c); |
---|
21 | con3 = 2.0 * (a - ml) * (c * mlp - 2.0 / sin2ph) - 2.0 * mlp; |
---|
22 | dphi = con1 / (con2 + con3); |
---|
23 | phi += dphi; |
---|
24 | if (Math.abs(dphi) <= .0000000001 ) return(phi); |
---|
25 | } |
---|
26 | Proj4js.reportError("phi4z: No convergence"); |
---|
27 | return null; |
---|
28 | } |
---|
29 | |
---|
30 | |
---|
31 | /* Function to compute the constant e4 from the input of the eccentricity |
---|
32 | of the spheroid, x. This constant is used in the Polar Stereographic |
---|
33 | projection. |
---|
34 | --------------------------------------------------------------------*/ |
---|
35 | function e4fn(x) { |
---|
36 | var con, com; |
---|
37 | con = 1.0 + x; |
---|
38 | com = 1.0 - x; |
---|
39 | return (Math.sqrt((Math.pow(con,con))*(Math.pow(com,com)))); |
---|
40 | } |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | /******************************************************************************* |
---|
47 | NAME POLYCONIC |
---|
48 | |
---|
49 | PURPOSE: Transforms input longitude and latitude to Easting and |
---|
50 | Northing for the Polyconic projection. The |
---|
51 | longitude and latitude must be in radians. The Easting |
---|
52 | and Northing values will be returned in meters. |
---|
53 | |
---|
54 | PROGRAMMER DATE |
---|
55 | ---------- ---- |
---|
56 | T. Mittan Mar, 1993 |
---|
57 | |
---|
58 | ALGORITHM REFERENCES |
---|
59 | |
---|
60 | 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
---|
61 | Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
---|
62 | State Government Printing Office, Washington D.C., 1987. |
---|
63 | |
---|
64 | 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
---|
65 | U.S. Geological Survey Professional Paper 1453 , United State Government |
---|
66 | Printing Office, Washington D.C., 1989. |
---|
67 | *******************************************************************************/ |
---|
68 | |
---|
69 | Proj4js.Proj.poly = { |
---|
70 | |
---|
71 | /* Initialize the POLYCONIC projection |
---|
72 | ----------------------------------*/ |
---|
73 | init: function() { |
---|
74 | var temp; /* temporary variable */ |
---|
75 | if (this.lat0=0) this.lat0=90;//this.lat0 ca |
---|
76 | |
---|
77 | /* Place parameters in static storage for common use |
---|
78 | -------------------------------------------------*/ |
---|
79 | this.temp = this.b / this.a; |
---|
80 | this.es = 1.0 - Math.pow(this.temp,2);// devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles |
---|
81 | this.e = Math.sqrt(this.es); |
---|
82 | this.e0 = Proj4js.common.e0fn(this.es); |
---|
83 | this.e1 = Proj4js.common.e1fn(this.es); |
---|
84 | this.e2 = Proj4js.common.e2fn(this.es); |
---|
85 | this.e3 = Proj4js.common.e3fn(this.es); |
---|
86 | this.ml0 = Proj4js.common.mlfn(this.e0, this.e1,this.e2, this.e3, this.lat0);//si que des zeros le calcul ne se fait pas |
---|
87 | //if (!this.ml0) {this.ml0=0;} |
---|
88 | }, |
---|
89 | |
---|
90 | |
---|
91 | /* Polyconic forward equations--mapping lat,long to x,y |
---|
92 | ---------------------------------------------------*/ |
---|
93 | forward: function(p) { |
---|
94 | var sinphi, cosphi; /* sin and cos value */ |
---|
95 | var al; /* temporary values */ |
---|
96 | var c; /* temporary values */ |
---|
97 | var con, ml; /* cone constant, small m */ |
---|
98 | var ms; /* small m */ |
---|
99 | var x,y; |
---|
100 | |
---|
101 | var lon=p.x; |
---|
102 | var lat=p.y; |
---|
103 | |
---|
104 | con = Proj4js.common.adjust_lon(lon - this.long0); |
---|
105 | if (Math.abs(lat) <= .0000001) { |
---|
106 | x = this.x0 + this.a * con; |
---|
107 | y = this.y0 - this.a * this.ml0; |
---|
108 | } else { |
---|
109 | sinphi = Math.sin(lat); |
---|
110 | cosphi = Math.cos(lat); |
---|
111 | |
---|
112 | ml = Proj4js.common.mlfn(this.e0, this.e1, this.e2, this.e3, lat); |
---|
113 | ms = Proj4js.common.msfnz(this.e,sinphi,cosphi); |
---|
114 | con = sinphi; |
---|
115 | x = this.x0 + this.a * ms * Math.sin(con)/sinphi; |
---|
116 | y = this.y0 + this.a * (ml - this.ml0 + ms * (1.0 - Math.cos(con))/sinphi); |
---|
117 | } |
---|
118 | |
---|
119 | p.x=x; |
---|
120 | p.y=y; |
---|
121 | return p; |
---|
122 | }, |
---|
123 | |
---|
124 | |
---|
125 | /* Inverse equations |
---|
126 | -----------------*/ |
---|
127 | inverse: function(p) { |
---|
128 | var sin_phi, cos_phi; /* sin and cos value */ |
---|
129 | var al; /* temporary values */ |
---|
130 | var b; /* temporary values */ |
---|
131 | var c; /* temporary values */ |
---|
132 | var con, ml; /* cone constant, small m */ |
---|
133 | var iflg; /* error flag */ |
---|
134 | var lon,lat; |
---|
135 | p.x -= this.x0; |
---|
136 | p.y -= this.y0; |
---|
137 | al = this.ml0 + p.y/this.a; |
---|
138 | iflg = 0; |
---|
139 | |
---|
140 | if (Math.abs(al) <= .0000001) { |
---|
141 | lon = p.x/this.a + this.long0; |
---|
142 | lat = 0.0; |
---|
143 | } else { |
---|
144 | b = al * al + (p.x/this.a) * (p.x/this.a); |
---|
145 | iflg = phi4z(this.es,this.e0,this.e1,this.e2,this.e3,this.al,b,c,lat); |
---|
146 | if (iflg != 1) return(iflg); |
---|
147 | lon = Proj4js.common.adjust_lon((Proj4js.common.asinz(p.x * c / this.a) / Math.sin(lat)) + this.long0); |
---|
148 | } |
---|
149 | |
---|
150 | p.x=lon; |
---|
151 | p.y=lat; |
---|
152 | return p; |
---|
153 | } |
---|
154 | }; |
---|
155 | |
---|
156 | |
---|
157 | |
---|