-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkoordinaten.html
106 lines (91 loc) · 3.65 KB
/
koordinaten.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.left {
float: left;
margin-left: 1em;
margin-top: 5px;
width: 25em;
}
.right {
float: left;
margin-left: 25em;
margin-top: 5px;
}
</style>
<script src="jquery.min.js"></script>
<script src="proj4.js"></script>
<script>
proj4.defs("EPSG:4647","+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=32500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
proj4.defs("EPSG:25832","+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
proj4.defs("EPSG:31466","+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7 +units=m +no_defs");
proj4.defs("EPSG:31467","+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7 +units=m +no_defs");
proj4.defs("EPSG:31468","+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7 +units=m +no_defs");
var EPSGNames = [
["EPSG:3857","Web Merkator/Google/OpenStreetMap"],
["EPSG:4326","WGS84 Dezimalgrad"],
["EPSG:4326","WGS84 Dezimalgrad lat;lon"],
["EPSG:4647","UTM32 mit Zonenzahl (zE-N)"],
["EPSG:25832", "UTM32 ohne Zonenzahl (E-N)"],
["EPSG:31466", "GK2"],
["EPSG:31467", "GK3"],
["EPSG:31468", "GK4"],
]
$( document ).ready( function() {
for (var i=0; i<EPSGNames.length ;i++ ) {
//console.log(EPSGNames[i][0]+" = " + EPSGNames[i][1]);
s = $("<option />").val(EPSGNames[i][0]).text(EPSGNames[i][1]);
$("#in_proj").append(s);
$("#out_proj").append(s.clone());
}
var reprojectHandler = function() {
var outtext = transformText($("#in_proj").val(), $("#out_proj").val(), $("#inp").val());
$("#outp").val(outtext);
}
$("#out_proj").change( reprojectHandler );
});
var sepCharOut = ";";
var roundToTwo = function(num) {
return +(Math.round(num + "e+2") + "e-2");
}
var transformText = function(inproj, outproj, text) {
var ret = "";
var lines = text.split("\n");
ret += lines[0]+"\n";
// skip header
for (var i=1;i<lines.length;i++) {
var l = lines[i].split(";");
var point = { x: l[0], y: l[1] }
//console.log("X "+ point.x + ", Y " + point.y + "("+l[2]+") von "+ inproj + " nach " + outproj );
var projectedCoordinates = proj4(inproj, outproj, point);
console.log(projectedCoordinates);
if ((outproj == 'EPSG:4326') && ($("#out_proj option:selected").text() == "WGS84 Dezimalgrad lat;lon")) {
// WGS84 lat-lon
ret += roundToTwo(projectedCoordinates.y)+sepCharOut+roundToTwo(projectedCoordinates.x)+sepCharOut+l.slice(2).join(sepCharOut)
} else {
// normalfall
ret += roundToTwo(projectedCoordinates.x)+sepCharOut+roundToTwo(projectedCoordinates.y)+sepCharOut+l.slice(2).join(sepCharOut)
}
ret += "\n";
}
return ret;
}
</script>
</head>
<body>
<div class="left">
Eingabeprojektion: <select id="in_proj" size="1"><option value="null">bitte wählen</option></select><br/>
<textarea id="inp" rows="30" cols="60">X_RECHTS;Y_HOCH;Name
3500000;5700000;Test</textarea>
</div>
<div class="right">
Ausgabeprojektion: <select id="out_proj" size="1"><option value="null">bitte wählen</option></select><br/>
<textarea id="outp" rows="30" cols="60">(bitte Eingabeprojektion wählen)</textarea>
</div>
<div class="left">
<p>Dieses Tool benutzt <a href="http://proj4js.org/">Proj4js</a> und <a href="https://jquery.com/">jQuery</a></p>
</div>
</body>
</html>