-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path作业9.html
263 lines (257 loc) · 9.93 KB
/
作业9.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<html>
<meta charset="utf-8">
<head>
<script src="Line.js"></script>
<style>
polyline{fill-opacity: 0;stroke:#a89cc8;stroke-width:1}
.land{fill-opacity: 1;fill:#636363;stroke:#eeeeee;stroke-width:0.5}
.china{fill-opacity: 1;fill:#5f4d93;stroke:#eeeeee;stroke-width:1}
</style>
<script>
pi=3.1415926;
a=6378245;
b=6356863;
e2=0.0066934;
e1=0.0818132;
function rad(x)
{
return pi*x/180
}
function Q1()
{
alert('需要约20秒');
result="";
for(xx=-180;xx<=180;xx=xx+10)
{
line="";
for(yy=-80;yy<=80;yy=yy+1)
{
if(yy!=0) {
line = line + Q1_get_xy(xx, yy) + ' ';
}
}
result=result+"<polyline points='"+line+"'/>";
}
for(yy=-80;yy<=80;yy=yy+10)
{
line="";
for(xx=-180;xx<=180;xx=xx+1)
{
if(yy!=0) {
line = line + Q1_get_xy(xx, yy) + ' ';
}
else{
line = line + Q1_get_xy(xx, (yy+0.001)) + ' ';
}
}
result=result+"<polyline points='"+line+"'/>";
}
length=data().length;
Line=data();
max=length/2;
line="<polyline class='land' points='";
for(iii=1;iii<=max;iii=iii+1)
{
yy=Line[2*iii-1];
xx=Line[2*iii-2];
if(xx>-500) {
line=line+Q1_get_xy(xx,yy)+' ';
}
else
{
line=line+"'/> <polyline class='land' points='";
}
}
line=line+"'/>";
result=result+line;
document.getElementById('answer1').innerHTML=result;
}
function Q1_get_xy(xx,yy)
{
Phi=rad(yy);
Lambada=rad(xx);
N=get_N(Phi);
x=get_SM(0,Phi)+N*(1/Math.tan(Phi))*(1-Math.cos(Lambada*Math.sin(Phi)));
y=N*(1/Math.tan(Phi))*Math.sin(Lambada*Math.sin(Phi));
x=200-x/80000;
y=300+y/80000;
xy=y.toString()+','+x.toString();
return xy;
}
function get_N(rad)
{
return (a)/Math.pow((1-e2*Math.sin(rad)*Math.sin(rad)),0.5);
}
function get_M(rad)
{
return (a*(1-e2)) / Math.pow((1-e2*Math.sin(rad)*Math.sin(rad)),1.5);
}
function get_SM(rad_min,rad_max)
{
gap=(rad_max-rad_min)/1000;
SM=0;
for(i=rad_min+0.5*gap;Math.abs(i)<Math.abs(rad_max);i=i+gap)
{
M=(a*(1-e2))/Math.pow((1-e2*Math.sin(i)*Math.sin(i)),1.5);
SM=SM+M*gap;
}
return SM;
}
function Q2()
{
document.getElementById('answer2').innerHTML="waiting";
input=[[0,30],[0,60],[0,90],[30,30],[30,60],[30,90],[60,30],[60,60],[60,90],[90,30],[90,60],[90,90]];
ans="<tr><th>λ</th><th>φ</th><th>m</th><th>P</th><th>ω</th></tr>";
for ( var i = 0; i <input.length; i++){
ans=ans+Q2_get_ans(input[i][0],input[i][1])
}
ans="<table style='position:absolute;left:50%;margin-left:-200px;width:400px;text-align: center'>"+ans+"</table>";
document.getElementById('answer2').innerHTML=ans;
}
function degree(rad)
{
return (rad/pi)*180;
}
function Q2_get_ans(xx,yy)
{
Lambada=rad(xx);
Phi=rad(yy);
Delta=Lambada*Math.sin(Phi);
Epsilon=Math.atan((Delta - Math.sin(Delta)) / (Math.cos(Delta) - (1 + Math.tan(Phi)*Math.tan(Phi)*get_M(0,Phi) / get_N(Phi))));
P=1 + 2 * Math.sin(Delta / 2)*Math.sin(Delta / 2)*get_N(Phi) / (get_M(Phi)*Math.tan(Phi)*Math.tan(Phi));
m=P/Math.cos(Epsilon);
Omega=2 * Math.atan(Math.pow(((m*m+1)/ P-2),0.5)/2);
Omega1=degree(Omega)-degree(Omega)%1;
Omega2=degree(Omega)%1*60-(degree(Omega)%1*60)%1;
line="<tr><td>"+xx+"</td><td>"+yy+"</td><td>"+m.toString().slice(0,5)+"</td><td>"+P.toString().slice(0,5)+"</td><td>"+Omega1.toString()+'°'+Omega2.toString()+'′'+"</td></tr>";
return line;
}
function get_U(Phi)
{
return Math.tan(pi/4+Phi/2)*Math.pow(((1-e1*Math.sin(Phi))/(1+e1*Math.sin(Phi))),e1/2);
}
function Q3()
{
Phi_1=rad(25);
Phi_2=rad(47);
Phi_sta=rad(15);
Lambada0=rad(110);
r1=get_N(Phi_1)*Math.cos(Phi_1);
r2=get_N(Phi_2)*Math.cos(Phi_2);
U1=get_U(Phi_1);
U2=get_U(Phi_2);
U_sta=get_U(Phi_sta);
Sigma=(Math.log(r1)-Math.log(r2))/(Math.log(U2)-Math.log(U1));
K=r1*Math.pow(U1,Sigma)/Sigma;
Rho_sta=K/Math.pow(U_sta,Sigma);
result="";
for(xx=70;xx<=150;xx=xx+5)
{
line="";
line_n="";
for(yy=15;yy<=60;yy=yy+1)
{
line = line + get_Q3_xy(xx,yy,Sigma,Lambada0,K,Rho_sta)[0] + ' ';
line_n = line_n + get_Q3_xy(xx,yy,Sigma,Lambada0,K,Rho_sta)[1] + ' ';
}
result=result+"<polyline><animate attributeType='XML' attributeName='points' from='" +line+"' to='"+line_n+"'dur='10s' repeatCount='indefinite'></animate></polyline>";
}
for(yy=15;yy<=60;yy=yy+5)
{
line="";
line_n="";
for(xx=70;xx<=150;xx=xx+1)
{
line = line + get_Q3_xy(xx,yy,Sigma,Lambada0,K,Rho_sta)[0] + ' ';
line_n = line_n + get_Q3_xy(xx,yy,Sigma,Lambada0,K,Rho_sta)[1] + ' ';
}
result=result+"<polyline><animate attributeType='XML' attributeName='points' from='" +line+"' to='"+line_n+"'dur='10s' repeatCount='indefinite'></animate></polyline>";
}
length=cdata().length;
Line=cdata();
max=length/2;
line='';
line_n='';
for(iii=1;iii<=max;iii=iii+1)
{
yy=Line[2*iii-1];
xx=Line[2*iii-2];
if(xx>-500) {
line = line + get_Q3_xy(xx,yy,Sigma,Lambada0,K,Rho_sta)[0] + ' ';
line_n = line_n + get_Q3_xy(xx,yy,Sigma,Lambada0,K,Rho_sta)[1] + ' ';
}
else
{
result=result+"<polyline class='china'><animate attributeType='XML' attributeName='points' from='" +line+"' to='"+line_n+"'dur='10s' repeatCount='indefinite'></animate></polyline>";
line="";
line_n="";
}
}
result=result+"<polyline class='china'><animate attributeType='XML' attributeName='points' from='" +line+"' to='"+line_n+"'dur='10s' repeatCount='indefinite'></animate></polyline>";
document.getElementById('answer3').innerHTML=result;
}
function get_Q3_xy(xx,yy,Sigma,Lambada0,K,Rho_sta)
{
Lambada=rad(xx);
Phi=rad(yy);
Delta=Sigma*(Lambada-Lambada0);
Rho=K/Math.pow(get_U(Phi),Sigma);
x=(Rho_sta-Rho*Math.cos(Delta));
y=(Rho*Math.sin(Delta));
D_n=Math.atan(y/(Rho_sta-x));
Lambada_n=D_n/Sigma;
y_n=a*Lambada_n;
x_n=a*Math.log(Math.pow((K/Math.pow(((Rho_sta-x)*(Rho_sta-x)+y*y),0.5)),1/Sigma));
x=350-x/25000;
y=300+y/25000;
x_n=400-x_n/25000;
y_n=300+y_n/25000;
xy=y.toString()+','+x.toString();
xy_n=y_n.toString()+','+x_n.toString();
return [xy,xy_n];
}
</script>
</head>
<body>
<div style="text-align: center;position: absolute;top:0px;left: 0px;right: 0px;height: 200px;background: linear-gradient(50deg, #a89cc8 50%, #C8E0EC 75%, #a89cc8 0%);background-size: 180px 200px;font-size: 40px;">
<p style="top:80px;">实习作业9</p>
<p style="top:110px;font-size: 18px;">张景源 <a href="mailto:dev@sgis.site" style="text-underline:none">dev@sgis.site</a></p>
</div>
<div style="text-align: center;position: absolute;top:240px;left: 0px;right: 0px;height:auto;background-color:#ffffff;font-size: 18px;">
<p>
第一题<br/>
<b>绘制普通多圆锥投影经纬格网,并加绘世界轮廓</b>
<br/>
<button onclick="Q1()">Run</button>
<br/>
<br/>
<svg id="answer1" style="width: 600px;height: 400px;border: #c79cc8 solid 2px;left: 50%;"></svg>
</p>
<p id="answer1"></p>
<p>
第二题<br/>
<b>普通多圆锥投影的经线长度比、面积比和角度变形情况</b>
<br/>
<button onclick="Q2()">Run</button>
<br/>
<br/>
<span id="answer2" style="text-align: center"></span>
</p>
<br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<p>
第三题<br/>
<b>利用等角圆锥投影公式,经投影变换后,绘制等角圆柱投影的经纬格网</b>
<br/>
<button onclick="Q3()">Run</button>
<br/>
<br/>
<svg id="answer3" style="width: 600px;height: 400px;border: #c79cc8 solid 2px;left: 50%;">
</svg>
</polyline>
<br/>
<br/>
<br/>
</div>
</body>
</html>