This repository has been archived by the owner on Feb 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
executable file
·276 lines (250 loc) · 9.28 KB
/
test.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
264
265
266
267
268
269
270
271
272
273
274
275
276
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<TITLE>Geographic Coordinate Transformations in Javascript</TITLE>
<script src="lib/OLprototype.js"></script>
<script src="lib/proj4js.js"></script>
<!--
The *.js files below define individual coordinate systems.
File names must be EPSGwxyz.js where wxyz is the epsg code number.
-->
<SCRIPT type="text/javascript" src="lib/defs/EPSG42304.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG27563.js"></SCRIPT>
<!--
<SCRIPT type="text/javascript" src="lib/defs/EPSG54001.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG54004.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG54009.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG54032.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG102017.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG102757.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG102582.js"></SCRIPT>
<SCRIPT type="text/javascript" src="lib/defs/EPSG102758.js"></SCRIPT>
-->
<SCRIPT type="text/javascript">
Proj4js.libPath = './lib/';
Proj4js.proxyScript = '/mapbuilder/proxy?url=';
var csLeft, csRight;
var projHash = {};
function buildCsList() {
var list ='<SELECT size="1" id="EPSGsel" onchange="pasteCode();">';
list+='<OPTION value selected="selected">Statically Loaded Coordinate Systems:</OPTION>';
for (var def in Proj4js.defs) {
projHash[def] = new Proj4js.Proj(def); //create a Proj for each definition
var title = def+" - "+projHash[def].title;
list+='<OPTION value="'+def+'">'+title+'</OPTION>';
} // for
list+='</SELECT>';
document.write(list);
}
function left2right(){
var xl = document.leftForm.x.value;
var yl = document.leftForm.y.value;
var p = new Proj4js.Point(xl,yl);
Proj4js.transform(csLeft, csRight, p);
document.rightForm.x.value=p.x;
document.rightForm.y.value=p.y;
document.rightForm.z.value=p.z;
}
function right2left(){
var xr = document.rightForm.x.value;
var yr = document.rightForm.y.value;
var p = new Proj4js.Point(xr,yr);
Proj4js.transform(csRight, csLeft, p);
document.leftForm.x.value=p.x;
document.leftForm.y.value=p.y;
document.leftForm.z.value=p.z;
}
// copy srs code from option list into text field
function pasteCode() {
var srsSel = document.topForm.EPSGsel.value;
if (document.topForm.leftRight[0].checked) {
csLeft = projHash[srsSel];
document.leftForm.srs.value=srsSel;
logProj(csLeft);
} else {
csRight = projHash[srsSel];
document.rightForm.srs.value=srsSel;
logProj(csRight);
}
}
function logProj(proj) {
var msg="";
for (var i in proj) {
msg += i + " = " + proj[i] + "\n";
}
//alert(msg);
document.bottomForm.infoText.value=msg;
}
</SCRIPT>
</HEAD>
<!-- <BODY onLoad="enumerate_csList()"> -->
<BODY>
<B>Geographic Coordinate Transformations in Javascript</B>
<UL>
<LI>long / lat are in decimal degrees, west / south is negative
<LI>ignore the Z's, these are NOT orthometric heights
</UL>
<TABLE cellpadding="0" cellspacing="0">
<TBODY>
<TR>
<TD colspan="3">
<FORM action="nothing" name="topForm">
<TABLE cellpadding="0" cellspacing="0">
<TBODY>
<TR>
<TD colspan="3">
<HR>
Select radio button to left or
right of list
to paste selection into left
or right SRS
field.</TD>
</TR>
<TR>
<TD bgcolor="#8080ff"><INPUT type="radio" name="leftRight" value="left" checked></TD>
<TD align="center">
<SCRIPT type="text/javascript">
buildCsList();
</SCRIPT>
</TD>
<TD bgcolor="#00ff80"><INPUT type="radio" name="leftRight" value="right"></TD>
</TR>
</TBODY>
</TABLE>
</FORM>
</TD>
</TR>
<TR>
<TD align="center">
<FORM action="nothing" name="leftForm">
<TABLE cellspacing="0" cellpadding="0" bgcolor="#8080ff">
<TBODY>
<TR>
<TD>SRS:</TD>
<TD align="center"><INPUT size="20" type="text" name="srs" onchange="initCS('L');"></TD>
</TR>
<TR>
<TD align="right">X:</TD>
<TD align="center"><INPUT size="20" type="text" name="x"></TD>
</TR>
<TR>
<TD align="right">Y:</TD>
<TD align="center"><INPUT size="20" type="text" name="y"></TD>
</TR>
<TR>
<TD align="right">Z:</TD>
<TD align="center"><INPUT size="20" type="text" name="z" disabled></TD>
</TR>
<TR>
<TD colspan="2" align="center"><INPUT type="reset" value="reset"></TD>
</TR>
</TBODY>
</TABLE>
</FORM>
</TD>
<TD align="center">
<FORM action="nothing">
<TABLE>
<TBODY>
<TR>
<TD><INPUT type="button" value=" >> " onclick="left2right();"></TD>
</TR>
<TR>
<TD> </TD>
</TR>
<TR>
<TD><INPUT type="button" value=" << " onclick="right2left();"></TD>
</TR>
<TR>
<TD> </TD>
</TR>
</TBODY>
</TABLE>
</FORM>
</TD>
<TD align="center">
<FORM action="nothing" name="rightForm">
<TABLE cellpadding="0" cellspacing="0" bgcolor="#00ff80">
<TBODY>
<TR>
<TD>SRS:</TD>
<TD><INPUT size="20" type="text" name="srs" onchange="initCS('R');"></TD>
</TR>
<TR>
<TD align="right">X:</TD>
<TD><INPUT size="20" type="text" name="x"></TD>
</TR>
<TR>
<TD align="right">Y:</TD>
<TD><INPUT size="20" type="text" name="y"></TD>
</TR>
<TR>
<TD align="right">Z:</TD>
<TD><INPUT size="20" type="text" name="z" disabled></TD>
</TR>
<TR>
<TD colspan="2" align="center"><INPUT type="reset" value="reset"></TD>
</TR>
</TBODY>
</TABLE>
</FORM>
</TD>
</TR>
<TR>
<TD></TD>
<TD align="center"></TD>
<TD></TD>
</TR>
<TR>
<TD colspan="3">
<FORM action="nothing" name="bottomForm">
<TEXTAREA name="infoText" rows="6" cols="60"></TEXTAREA>
</FORM>
</TD>
</TR>
</TBODY>
</TABLE>
<P>checks:<br>
Puerto Rico, 3 param:<br>
$ echo -66 18 | cs2cs -f '%2f' +init=epsg:4326 +to +init=epsg:4139<br>
Luxembourg, 7 param:<br>
$ echo 6 49 | cs2cs -f '%2f' +init=EPSG:4181 +to +proj=longlat +datum=WGS84<br>
Trinidad, 7 param:<br>
$ echo -61 10 | cs2cs -f '%2f' +init=EPSG:4302 +to +proj=longlat +datum=WGS84<br>
</P>
</BODY>
</HTML>
<!--
<SELECT size="1" id="EPSGsel" onchange="pasteCode();">
<OPTION value selected="selected">Coordinate System List</OPTION>
<OPTION value="4326">EPSG:4326 - Long/Lat WGS84</OPTION>
<OPTION value="4269">EPSG:4269 - Long/Lat NAD83</OPTION>
<OPTION value="4965">EPSG:4965 - Long/Lat RGF93G IGN-F FD 2005</OPTION>
<OPTION value="4139">EPSG:4139 - Puerto Rico</OPTION>
<OPTION value="102758">EPSG:102758 - NAD83 StatePlane Wyoming West FIPS 4904 US Survey Feet</OPTION>
<OPTION value="26903">EPSG:26903 - NAD83 / UTM zone 3N</OPTION>
<OPTION value="26904">EPSG:26904 - NAD83 / UTM zone 4N</OPTION>
<OPTION value="26905">EPSG:26905 - NAD83 / UTM zone 5N</OPTION>
<OPTION value="26906">EPSG:26906 - NAD83 / UTM zone 6N</OPTION>
<OPTION value="26907">EPSG:26907 - NAD83 / UTM zone 7N</OPTION>
<OPTION value="26908">EPSG:26908 - NAD83 / UTM zone 8N</OPTION>
<OPTION value="26909">EPSG:26909 - NAD83 / UTM zone 9N</OPTION>
<OPTION value="26910">EPSG:26910 - NAD83 / UTM zone 10N</OPTION>
<OPTION value="26911">EPSG:26911 - NAD83 / UTM zone 11N</OPTION>
<OPTION value="26912">EPSG:26912 - NAD83 / UTM zone 12N</OPTION>
<OPTION value="26913">EPSG:26913 - NAD83 / UTM zone 13N</OPTION>
<OPTION value="26914">EPSG:26914 - NAD83 / UTM zone 14N</OPTION>
<OPTION value="26915">EPSG:26915 - NAD83 / UTM zone 15N</OPTION>
<OPTION value="26916">EPSG:26916 - NAD83 / UTM zone 16N</OPTION>
<OPTION value="26917">EPSG:26917 - NAD83 / UTM zone 17N</OPTION>
<OPTION value="26918">EPSG:26918 - NAD83 / UTM zone 18N</OPTION>
<OPTION value="26919">EPSG:26919 - NAD83 / UTM zone 19N</OPTION>
<OPTION value="26920">EPSG:26920 - NAD83 / UTM zone 20N</OPTION>
<OPTION value="26921">EPSG:26921 - NAD83 / UTM zone 21N</OPTION>
<OPTION value="26922">EPSG:26922 - NAD83 / UTM zone 22N</OPTION>
<OPTION value="26923">EPSG:26923 - NAD83 / UTM zone 23N</OPTION>
<OPTION value="32158">EPSG:32158 - NAD83 StatePlane Wyoming West Meters</OPTION>
<OPTION value="26591">EPSG:26591 - Monte Mario (Rome) / Italy zone 1</OPTION>
<OPTION value="28992">EPSG:28992 - Amersfoort / RD New</OPTION>
</SELECT>
-->