node-red-contrib-web-worldmap 2.25.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/README.md +1 -0
- package/package.json +1 -1
- package/worldmap/index.html +2 -2
- package/worldmap/index3d.html +216 -214
- package/worldmap/leaflet/leaflet.mousecoordinate.css +7 -0
- package/worldmap/leaflet/leaflet.mousecoordinate.js +639 -0
- package/worldmap/worldmap.js +9 -21
- package/worldmap.html +4 -0
- package/worldmap.js +3 -0
- package/worldmap/leaflet/3dstyle.json +0 -11296
- package/worldmap/leaflet/Leaflet.Coordinates.css +0 -1
- package/worldmap/leaflet/Leaflet.Coordinates.js +0 -2
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Author : Johannes Rudolph
|
|
3
|
+
Fixes by : D Conway-Jones
|
|
4
|
+
*/
|
|
5
|
+
/* globals L: true */
|
|
6
|
+
L.Control.mouseCoordinate = L.Control.extend({
|
|
7
|
+
options: {
|
|
8
|
+
gps: true,
|
|
9
|
+
gpsLong: false,
|
|
10
|
+
utm: false,
|
|
11
|
+
utmref: false,
|
|
12
|
+
position: 'bottomleft',
|
|
13
|
+
_sm_a: 6378137.0,
|
|
14
|
+
_sm_b: 6356752.314,
|
|
15
|
+
_sm_EccSquared: 6.69437999013e-03,
|
|
16
|
+
_UTMScaleFactor: 0.9996
|
|
17
|
+
},
|
|
18
|
+
onAdd: function(map){
|
|
19
|
+
this._map = map;
|
|
20
|
+
if (L.Browser.mobile || L.Browser.mobileWebkit || L.Browser.mobileWebkit3d || L.Browser.mobileOpera || L.Browser.mobileGecko) {
|
|
21
|
+
return L.DomUtil.create('div');
|
|
22
|
+
}
|
|
23
|
+
var className = 'leaflet-control-mouseCoordinate';
|
|
24
|
+
var container = this._container = L.DomUtil.create('div',className);
|
|
25
|
+
this._gpsPositionContainer = L.DomUtil.create("div","gpsPos",container);
|
|
26
|
+
map.on("mousemove", this._update, this);
|
|
27
|
+
return container;
|
|
28
|
+
},
|
|
29
|
+
_update: function(e){
|
|
30
|
+
//lat: [-90,90]
|
|
31
|
+
//lng: [-180,180]
|
|
32
|
+
var lat = (e.latlng.lat+90)%180;
|
|
33
|
+
var lng = (e.latlng.lng+180)%360;
|
|
34
|
+
if (lat < 0) { lat += 180; }
|
|
35
|
+
lat -=90;
|
|
36
|
+
if (lng < 0) { lng+= 360; }
|
|
37
|
+
lng -= 180;
|
|
38
|
+
|
|
39
|
+
var gps = {lat:lat, lng:lng};
|
|
40
|
+
var content = "<table>";
|
|
41
|
+
if (this.options.gps) {
|
|
42
|
+
//Round for display only
|
|
43
|
+
var dLat = Math.round(lat * 100000) / 100000;
|
|
44
|
+
var dLng = Math.round(lng * 100000) / 100000;
|
|
45
|
+
content += "<tr><td>Lat, Lon </td><td>" + dLat + ", " + dLng +"</td></tr>";
|
|
46
|
+
}
|
|
47
|
+
if (this.options.gpsLong) {
|
|
48
|
+
// var gpsMinuten = this._geo2geodeziminuten(gps);
|
|
49
|
+
// content += "<tr><td>"+ gpsMinuten.NS + " " + gpsMinuten.latgrad + "° "+ gpsMinuten.latminuten+"</td><td> " + gpsMinuten.WE + " "+ gpsMinuten.lnggrad +"° "+ gpsMinuten.lngminuten +"</td></tr>";
|
|
50
|
+
var gpsMinutenSekunden = this._geo2gradminutensekunden(gps);
|
|
51
|
+
content += "<tr><td>"+ gpsMinutenSekunden.NS + " " + gpsMinutenSekunden.latgrad + "° "+ gpsMinutenSekunden.latminuten + "′ "+ gpsMinutenSekunden.latsekunden+"″</td><td> " + gpsMinutenSekunden.WE + " "+ gpsMinutenSekunden.lnggrad +"° "+ gpsMinutenSekunden.lngminuten + "′ "+ gpsMinutenSekunden.lngsekunden+"″</td></tr>";
|
|
52
|
+
}
|
|
53
|
+
if (this.options.utm) {
|
|
54
|
+
var utm = UTM.fromLatLng(gps);
|
|
55
|
+
if (utm !== undefined) {
|
|
56
|
+
content += "<tr><td>UTM</td><td>"+utm.zone+" " +utm.x+" " +utm.y+"</td></tr>";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (this.options.utmref) {
|
|
60
|
+
var utmref = UTMREF.fromUTM(UTM.fromLatLng(gps));
|
|
61
|
+
if(utmref !== undefined){
|
|
62
|
+
content += "<tr><td>MGRS</td><td>"+utmref.zone+" " +utmref.band+" " +utmref.x+" " +utmref.y+"</td></tr>";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (this.options.qth) {
|
|
66
|
+
var qth = QTH.fromLatLng(gps);
|
|
67
|
+
content += "<tr><td>QTH</td><td>"+qth+"</td></tr>";
|
|
68
|
+
}
|
|
69
|
+
if (this.options.nac) {
|
|
70
|
+
var nac = NAC.fromLatLng(gps);
|
|
71
|
+
content += "<tr><td>NAC</td><td>"+nac.y+" "+ nac.x +"</td></tr>";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
content += "</table>";
|
|
75
|
+
this._gpsPositionContainer.innerHTML = content;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
_geo2geodeziminuten: function (gps) {
|
|
81
|
+
var latgrad = parseInt(gps.lat,10);
|
|
82
|
+
var latminuten = Math.round( ((gps.lat - latgrad) * 60) * 10000 ) / 10000;
|
|
83
|
+
|
|
84
|
+
var lnggrad = parseInt(gps.lng,10);
|
|
85
|
+
var lngminuten = Math.round( ((gps.lng - lnggrad) * 60) * 10000 ) / 10000;
|
|
86
|
+
|
|
87
|
+
return this._AddNSEW({latgrad:latgrad, latminuten:latminuten, lnggrad:lnggrad, lngminuten:lngminuten},gps);
|
|
88
|
+
},
|
|
89
|
+
_geo2gradminutensekunden: function (gps) {
|
|
90
|
+
var latgrad = parseInt(gps.lat,10);
|
|
91
|
+
var latminuten = (gps.lat - latgrad) * 60;
|
|
92
|
+
var latsekunden = Math.round(((latminuten - parseInt(latminuten,10)) * 60) * 100) / 100;
|
|
93
|
+
latminuten = parseInt(latminuten,10);
|
|
94
|
+
|
|
95
|
+
var lnggrad = parseInt(gps.lng,10);
|
|
96
|
+
var lngminuten = (gps.lng - lnggrad) * 60;
|
|
97
|
+
var lngsekunden = Math.round(((lngminuten - parseInt(lngminuten,10)) * 60) * 100) /100;
|
|
98
|
+
lngminuten = parseInt(lngminuten,10);
|
|
99
|
+
|
|
100
|
+
return this._AddNSEW({latgrad:latgrad, latminuten:latminuten, latsekunden:latsekunden, lnggrad:lnggrad, lngminuten:lngminuten, lngsekunden:lngsekunden},gps);
|
|
101
|
+
},
|
|
102
|
+
_AddNSEW: function (coord,gps) {
|
|
103
|
+
coord.NS = "N";
|
|
104
|
+
coord.WE = "E";
|
|
105
|
+
if (gps.lat < 0) {
|
|
106
|
+
coord.latgrad = coord.latgrad * (-1);
|
|
107
|
+
coord.latminuten = coord.latminuten * (-1);
|
|
108
|
+
coord.latsekunden = coord.latsekunden * (-1);
|
|
109
|
+
coord.NS = "S";
|
|
110
|
+
}
|
|
111
|
+
if (gps.lng < 0) {
|
|
112
|
+
coord.lnggrad = coord.lnggrad * (-1);
|
|
113
|
+
coord.lngminuten = coord.lngminuten * (-1);
|
|
114
|
+
coord.lngsekunden = coord.lngsekunden * (-1);
|
|
115
|
+
coord.WE = "W";
|
|
116
|
+
}
|
|
117
|
+
return coord;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
L.control.mouseCoordinate = function (options) {
|
|
123
|
+
return new L.Control.mouseCoordinate(options);
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Created by Johannes Rudolph <johannes.rudolph@gmx.com> on 01.09.2016.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @type {{fromLatLng: NAC.fromLatLng, _nac2Letter: NAC._nac2Letter}}
|
|
132
|
+
*/
|
|
133
|
+
var NAC = {
|
|
134
|
+
/**
|
|
135
|
+
* @param {{lat: number, lng: number}}
|
|
136
|
+
* @returns {string}
|
|
137
|
+
*/
|
|
138
|
+
fromLatLng: function(latlng) {
|
|
139
|
+
var lat = latlng.lat;
|
|
140
|
+
var lon = latlng.lng;
|
|
141
|
+
var x = [];
|
|
142
|
+
var y = [];
|
|
143
|
+
var xy = [];
|
|
144
|
+
xy.x = '';
|
|
145
|
+
xy.y = '';
|
|
146
|
+
if (lon >= -180 && lon <= 180) {
|
|
147
|
+
var xlon = (lon + 180) / 360;
|
|
148
|
+
x = this._calcValues(xlon);
|
|
149
|
+
} else {
|
|
150
|
+
x[0] = 0;
|
|
151
|
+
}
|
|
152
|
+
if (lat >= -90 && lat <= 90) {
|
|
153
|
+
var ylat = (lat + 90) / 180;
|
|
154
|
+
y = this._calcValues(ylat);
|
|
155
|
+
} else {
|
|
156
|
+
y[0] = 0;
|
|
157
|
+
}
|
|
158
|
+
for (var i = 0; i < x.length; i++) {
|
|
159
|
+
xy.x += this._nac2Letter(x[i]);
|
|
160
|
+
}
|
|
161
|
+
for (i = 0; i < y.length; i++) {
|
|
162
|
+
xy.y += this._nac2Letter(y[i]);
|
|
163
|
+
}
|
|
164
|
+
return xy;
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @param z
|
|
169
|
+
* @returns {Array}
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
_calcValues: function (z){
|
|
173
|
+
var ret = [];
|
|
174
|
+
ret[0] = parseInt(z * 30,10);
|
|
175
|
+
ret[1] = parseInt((z * 30 - ret[0]) * 30,10);
|
|
176
|
+
ret[2] = parseInt(((z * 30 - ret[0]) * 30 - ret[1]) * 30,10);
|
|
177
|
+
ret[3] = parseInt((((z * 30 - ret[0]) * 30 - ret[1]) * 30 - ret[2]) * 30,10);
|
|
178
|
+
ret[4] = parseInt(((((z * 30 - ret[0]) * 30 - ret[1]) * 30 - ret[2]) * 30 - ret[3]) * 30,10);
|
|
179
|
+
ret[5] = parseInt((((((z * 30 - ret[0]) * 30 - ret[1]) * 30 - ret[2]) * 30 - ret[3]) * 30 - ret[4]) * 30,10);
|
|
180
|
+
return ret;
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @param number
|
|
185
|
+
* @returns {string}
|
|
186
|
+
* @private
|
|
187
|
+
*/
|
|
188
|
+
_nac2Letter: function(number){
|
|
189
|
+
var nac_letters = "0123456789BCDFGHJKLMNPQRSTVWXZ";
|
|
190
|
+
if(!isNaN(number) && number < 30)
|
|
191
|
+
return nac_letters.substr(number,1);
|
|
192
|
+
else return 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Created by Johannes Rudolph <johannes.rudolph@gmx.com> on 01.09.2016.
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @type {{fromLatLng: QTH.fromLatLng}}
|
|
202
|
+
*/
|
|
203
|
+
var QTH = {
|
|
204
|
+
/**
|
|
205
|
+
* @param {{lat: number, lng: number}}
|
|
206
|
+
* @returns {string}
|
|
207
|
+
*/
|
|
208
|
+
fromLatLng: function(latlng){
|
|
209
|
+
/* Long/Lat to QTH locator conversion largely */
|
|
210
|
+
/* inspired from the DL4MFM code found here : */
|
|
211
|
+
/* http://members.aol.com/mfietz/ham/calcloce.html */
|
|
212
|
+
|
|
213
|
+
var ychr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
214
|
+
var ynum = "0123456789";
|
|
215
|
+
var yqth, yi, yk, ydiv, yres, ylp;
|
|
216
|
+
var y = 0;
|
|
217
|
+
var ycalc = [0,0,0];
|
|
218
|
+
var yn = [0,0,0,0,0,0,0];
|
|
219
|
+
|
|
220
|
+
ycalc[1] = latlng.lng+ 180;
|
|
221
|
+
ycalc[2] = latlng.lat + 90;
|
|
222
|
+
|
|
223
|
+
for (yi = 1; yi < 3; ++yi) {
|
|
224
|
+
for (yk = 1; yk < 4; ++yk) {
|
|
225
|
+
if (yk !== 3) {
|
|
226
|
+
if (yi === 1) {
|
|
227
|
+
if (yk === 1) ydiv = 20;
|
|
228
|
+
if (yk === 2) ydiv = 2;
|
|
229
|
+
}
|
|
230
|
+
if (yi === 2) {
|
|
231
|
+
if (yk === 1) ydiv = 10;
|
|
232
|
+
if (yk === 2) ydiv = 1;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
yres = ycalc[yi] / ydiv;
|
|
236
|
+
ycalc[yi] = yres;
|
|
237
|
+
if (ycalc[yi]>0)
|
|
238
|
+
ylp = Math.floor(yres);
|
|
239
|
+
else
|
|
240
|
+
ylp = Math.ceil(yres);
|
|
241
|
+
ycalc[yi] = (ycalc[yi] - ylp) * ydiv;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
if (yi === 1)
|
|
245
|
+
ydiv = 12;
|
|
246
|
+
else
|
|
247
|
+
ydiv = 24;
|
|
248
|
+
|
|
249
|
+
yres = ycalc[yi] * ydiv;
|
|
250
|
+
ycalc[yi] = yres;
|
|
251
|
+
if (ycalc[yi] > 0)
|
|
252
|
+
ylp = Math.floor(yres);
|
|
253
|
+
else
|
|
254
|
+
ylp = Math.ceil(yres);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
++y;
|
|
258
|
+
yn[y] = ylp;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
yqth = ychr.charAt(yn[1]) + ychr.charAt(yn[4]) + ynum.charAt(yn[2]);
|
|
262
|
+
yqth += ynum.charAt(yn[5]) + ychr.charAt(yn[3])+ ychr.charAt(yn[6]);
|
|
263
|
+
return yqth;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Created by Johannes Rudolph <johannes.rudolph@gmx.com> on 01.09.2016.
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @type {{fromLatLng: UTM.fromLatLng, toLatLng: UTM.toLatLng}}
|
|
273
|
+
*/
|
|
274
|
+
var UTM = {
|
|
275
|
+
/**
|
|
276
|
+
*
|
|
277
|
+
* @param {{lat: number, lng: number}}
|
|
278
|
+
* @returns {{zone: string, x: number, y: number}}
|
|
279
|
+
*/
|
|
280
|
+
fromLatLng: function (latlng) {
|
|
281
|
+
//Copyright (c) 2006, HELMUT H. HEIMEIER
|
|
282
|
+
/*
|
|
283
|
+
* Okay, this just gives the wrong result:
|
|
284
|
+
* `UTMREF.fromUTM(UTM.fromLatLng({lat: 0, lng: -179.9999999999999}))`
|
|
285
|
+
* Results in
|
|
286
|
+
* `Object {zone: "02N", band: "HF", x: "50564", y: "00000"}`
|
|
287
|
+
* but should be in zone `01N`...
|
|
288
|
+
**/
|
|
289
|
+
var lw = latlng.lng;
|
|
290
|
+
var bw = latlng.lat;
|
|
291
|
+
if (lw === -180) {
|
|
292
|
+
lw += 1e-13;//Number.MIN_VALUE;
|
|
293
|
+
}
|
|
294
|
+
if (lw === 180) {
|
|
295
|
+
lw -= 1e-13;//umber.MIN_VALUE;
|
|
296
|
+
}
|
|
297
|
+
if (bw === -90) bw += 1e-13;//umber.MIN_VALUE;
|
|
298
|
+
if (bw === 90) bw -= 1e-13;//umber.MIN_VALUE;
|
|
299
|
+
// Geographische Laenge lw und Breite bw im WGS84 Datum
|
|
300
|
+
if (lw <= -180 || lw >= 180 || bw <= -80 || bw >= 84) {
|
|
301
|
+
console.error("Out of lw <= -180 || lw >= 180 || bw <= -80 || bw >= 84 bounds, which is kinda similar to UTM bounds, if you ignore the poles");
|
|
302
|
+
//alert("Werte nicht im Bereich des UTM Systems\n -180 <= LW < +180, -80 < BW < 84 N"); // jshint ignore:line
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
lw = parseFloat(lw);
|
|
306
|
+
bw = parseFloat(bw);
|
|
307
|
+
|
|
308
|
+
// WGS84 Datum
|
|
309
|
+
// Grosse Halbachse a und Abplattung f
|
|
310
|
+
var a = 6378137.000;
|
|
311
|
+
var f = 3.35281068e-3;
|
|
312
|
+
var pi = Math.PI;
|
|
313
|
+
var b_sel = 'CDEFGHJKLMNPQRSTUVWXX';
|
|
314
|
+
|
|
315
|
+
// Polkruemmungshalbmesser c
|
|
316
|
+
var c = a/(1-f);
|
|
317
|
+
|
|
318
|
+
// Quadrat der zweiten numerischen Exzentrizitaet
|
|
319
|
+
var ex2 = (2*f-f*f)/((1-f)*(1-f));
|
|
320
|
+
var ex4 = ex2*ex2;
|
|
321
|
+
var ex6 = ex4*ex2;
|
|
322
|
+
var ex8 = ex4*ex4;
|
|
323
|
+
|
|
324
|
+
// Koeffizienten zur Berechnung der Meridianbogenlaenge
|
|
325
|
+
var e0 = c*(pi/180)*(1 - 3*ex2/4 + 45*ex4/64 - 175*ex6/256 + 11025*ex8/16384);
|
|
326
|
+
var e2 = c*( - 3*ex2/8 + 15*ex4/32 - 525*ex6/1024 + 2205*ex8/4096);
|
|
327
|
+
var e4 = c*(15*ex4/256 - 105*ex6/1024 + 2205*ex8/16384);
|
|
328
|
+
var e6 = c*( - 35*ex6/3072 + 315*ex8/12288);
|
|
329
|
+
|
|
330
|
+
// Laengenzone lz und Breitenzone (Band) bz
|
|
331
|
+
var lzn = parseInt((lw+180)/6,10) + 1;
|
|
332
|
+
var lz = lzn;
|
|
333
|
+
if (lzn < 10) {
|
|
334
|
+
lz = "0" + lzn;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
//Chunk of code from https://github.com/proj4js/mgrs/blob/e43d7d644564c09831587a5f01c911caae991d8c/mgrs.js#L128-L147
|
|
338
|
+
//MIT License
|
|
339
|
+
//Copyright (c) 2012, Mike Adair, Richard Greenwood, Didier Richard, Stephen Irons, Olivier Terral, Calvin Metcalf
|
|
340
|
+
//
|
|
341
|
+
//Portions of this software are based on a port of components from the OpenMap com.bbn.openmap.proj.coords Java package. An initial port was initially created by Patrice G. Cappelaere and included in Community Mapbuilder (http://svn.codehaus.org/mapbuilder/), which is licensed under the LGPL license as per http://www.gnu.org/copyleft/lesser.html. OpenMap is licensed under the following license agreement:
|
|
342
|
+
|
|
343
|
+
// Special zone for Norway
|
|
344
|
+
if (bw >= 56.0 && bw < 64.0 && lw >= 3.0 && lw < 12.0) {
|
|
345
|
+
lz = 32;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Special zones for Svalbard
|
|
349
|
+
if (bw >= 72.0 && bw < 84.0) {
|
|
350
|
+
if (lw >= 0.0 && lw < 9.0) {
|
|
351
|
+
lz = 31;
|
|
352
|
+
}
|
|
353
|
+
else if (lw >= 9.0 && lw < 21.0) {
|
|
354
|
+
lz = 33;
|
|
355
|
+
}
|
|
356
|
+
else if (lw >= 21.0 && lw < 33.0) {
|
|
357
|
+
lz = 35;
|
|
358
|
+
}
|
|
359
|
+
else if (lw >= 33.0 && lw < 42.0) {
|
|
360
|
+
lz = 37;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
//End part of code from proj4js/mgrs
|
|
364
|
+
var bd = parseInt(1 + (bw + 80)/8,10);
|
|
365
|
+
var bz = b_sel.substr(bd-1,1);
|
|
366
|
+
|
|
367
|
+
// Geographische Breite in Radianten br
|
|
368
|
+
var br = bw * pi/180;
|
|
369
|
+
|
|
370
|
+
var tan1 = Math.tan(br);
|
|
371
|
+
var tan2 = tan1*tan1;
|
|
372
|
+
var tan4 = tan2*tan2;
|
|
373
|
+
|
|
374
|
+
var cos1 = Math.cos(br);
|
|
375
|
+
var cos2 = cos1*cos1;
|
|
376
|
+
var cos4 = cos2*cos2;
|
|
377
|
+
var cos3 = cos2*cos1;
|
|
378
|
+
var cos5 = cos4*cos1;
|
|
379
|
+
|
|
380
|
+
var etasq = ex2*cos2;
|
|
381
|
+
|
|
382
|
+
// Querkruemmungshalbmesser nd
|
|
383
|
+
var nd = c/Math.sqrt(1 + etasq);
|
|
384
|
+
|
|
385
|
+
// Meridianbogenlaenge g aus gegebener geographischer Breite bw
|
|
386
|
+
var g = (e0*bw) + (e2*Math.sin(2*br)) + (e4*Math.sin(4*br)) + (e6*Math.sin(6*br));
|
|
387
|
+
|
|
388
|
+
// Laengendifferenz dl zum Bezugsmeridian lh
|
|
389
|
+
var lh = (lzn - 30)*6 - 3;
|
|
390
|
+
var dl = (lw - lh)*pi/180;
|
|
391
|
+
var dl2 = dl*dl;
|
|
392
|
+
var dl4 = dl2*dl2;
|
|
393
|
+
var dl3 = dl2*dl;
|
|
394
|
+
var dl5 = dl4*dl;
|
|
395
|
+
|
|
396
|
+
// Masstabsfaktor auf dem Bezugsmeridian bei UTM Koordinaten m = 0.9996
|
|
397
|
+
// Nordwert nw und Ostwert ew als Funktion von geographischer Breite und Laenge
|
|
398
|
+
var nw;
|
|
399
|
+
if ( bw < 0 ) {
|
|
400
|
+
nw = 10e6 + 0.9996*(g + nd*cos2*tan1*dl2/2 + nd*cos4*tan1*(5-tan2+9*etasq)*dl4/24);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
nw = 0.9996*(g + nd*cos2*tan1*dl2/2 + nd*cos4*tan1*(5-tan2+9*etasq)*dl4/24);
|
|
404
|
+
}
|
|
405
|
+
var ew = 0.9996*( nd*cos1*dl + nd*cos3*(1-tan2+etasq)*dl3/6 + nd*cos5 *(5-18*tan2+tan4)*dl5/120) + 500000;
|
|
406
|
+
|
|
407
|
+
var zone = lz+bz;
|
|
408
|
+
|
|
409
|
+
var nk = nw - parseInt(nw,10);
|
|
410
|
+
if (nk < 0.5) {
|
|
411
|
+
nw = "" + parseInt(nw,10);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
nw = "" + (parseInt(nw,10) + 1);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
while (nw.length < 7) {
|
|
418
|
+
nw = "0" + nw;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
nk = ew - parseInt(ew,10);
|
|
422
|
+
if (nk < 0.5) {
|
|
423
|
+
ew = "0" + parseInt(ew,10);
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
ew = "0" + parseInt(ew+1,10);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return {zone: zone, x: ew, y: nw};
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* @param {{zone: string, x: number, y: number}}
|
|
434
|
+
* @returns {{lat: number, lng: number}}
|
|
435
|
+
*/
|
|
436
|
+
toLatLng: function (utm){
|
|
437
|
+
// Copyright (c) 2006, HELMUT H. HEIMEIER
|
|
438
|
+
|
|
439
|
+
var zone = utm.zone;
|
|
440
|
+
var ew = utm.x;
|
|
441
|
+
var nw = utm.y;
|
|
442
|
+
// Laengenzone zone, Ostwert ew und Nordwert nw im WGS84 Datum
|
|
443
|
+
if (zone === "" || ew === "" || nw === ""){
|
|
444
|
+
zone = "";
|
|
445
|
+
ew = "";
|
|
446
|
+
nw = "";
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
var band = zone.substr(2,1);
|
|
450
|
+
zone = parseFloat(zone);
|
|
451
|
+
ew = parseFloat(ew);
|
|
452
|
+
nw = parseFloat(nw);
|
|
453
|
+
|
|
454
|
+
// WGS84 Datum
|
|
455
|
+
// Grosse Halbachse a und Abplattung f
|
|
456
|
+
var a = 6378137.000;
|
|
457
|
+
var f = 3.35281068e-3;
|
|
458
|
+
var pi = Math.PI;
|
|
459
|
+
|
|
460
|
+
// Polkruemmungshalbmesser c
|
|
461
|
+
var c = a/(1-f);
|
|
462
|
+
|
|
463
|
+
// Quadrat der zweiten numerischen Exzentrizitaet
|
|
464
|
+
var ex2 = (2*f-f*f)/((1-f)*(1-f));
|
|
465
|
+
var ex4 = ex2*ex2;
|
|
466
|
+
var ex6 = ex4*ex2;
|
|
467
|
+
var ex8 = ex4*ex4;
|
|
468
|
+
|
|
469
|
+
// Koeffizienten zur Berechnung der geographischen Breite aus gegebener
|
|
470
|
+
// Meridianbogenlaenge
|
|
471
|
+
var e0 = c*(pi/180)*(1 - 3*ex2/4 + 45*ex4/64 - 175*ex6/256 + 11025*ex8/16384);
|
|
472
|
+
var f2 = (180/pi)*( 3*ex2/8 - 3*ex4/16 + 213*ex6/2048 - 255*ex8/4096);
|
|
473
|
+
var f4 = (180/pi)*( 21*ex4/256 - 21*ex6/256 + 533*ex8/8192);
|
|
474
|
+
var f6 = (180/pi)*( 151*ex6/6144 - 453*ex8/12288);
|
|
475
|
+
|
|
476
|
+
// Entscheidung Nord-/Sued Halbkugel
|
|
477
|
+
var m_nw;
|
|
478
|
+
if (band >= "N"|| band === ""){
|
|
479
|
+
m_nw = nw;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
m_nw = nw - 10e6;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Geographische Breite bf zur Meridianbogenlaenge gf = m_nw
|
|
486
|
+
var sigma = (m_nw/0.9996)/e0;
|
|
487
|
+
var sigmr = sigma*pi/180;
|
|
488
|
+
var bf = sigma + f2*Math.sin(2*sigmr) + f4*Math.sin(4*sigmr) + f6*Math.sin(6*sigmr);
|
|
489
|
+
|
|
490
|
+
// Breite bf in Radianten
|
|
491
|
+
var br = bf * pi/180;
|
|
492
|
+
var tan1 = Math.tan(br);
|
|
493
|
+
var tan2 = tan1*tan1;
|
|
494
|
+
var tan4 = tan2*tan2;
|
|
495
|
+
|
|
496
|
+
var cos1 = Math.cos(br);
|
|
497
|
+
var cos2 = cos1*cos1;
|
|
498
|
+
|
|
499
|
+
var etasq = ex2*cos2;
|
|
500
|
+
|
|
501
|
+
// Querkruemmungshalbmesser nd
|
|
502
|
+
var nd = c/Math.sqrt(1 + etasq);
|
|
503
|
+
var nd2 = nd*nd;
|
|
504
|
+
var nd4 = nd2*nd2;
|
|
505
|
+
var nd6 = nd4*nd2;
|
|
506
|
+
var nd3 = nd2*nd;
|
|
507
|
+
var nd5 = nd4*nd;
|
|
508
|
+
|
|
509
|
+
// Laengendifferenz dl zum Bezugsmeridian lh
|
|
510
|
+
var lh = (zone - 30)*6 - 3;
|
|
511
|
+
var dy = (ew-500000)/0.9996;
|
|
512
|
+
var dy2 = dy*dy;
|
|
513
|
+
var dy4 = dy2*dy2;
|
|
514
|
+
var dy3 = dy2*dy;
|
|
515
|
+
var dy5 = dy3*dy2;
|
|
516
|
+
var dy6 = dy3*dy3;
|
|
517
|
+
|
|
518
|
+
var b2 = - tan1*(1+etasq)/(2*nd2);
|
|
519
|
+
var b4 = tan1*(5+3*tan2+6*etasq*(1-tan2))/(24*nd4);
|
|
520
|
+
var b6 = - tan1*(61+90*tan2+45*tan4)/(720*nd6);
|
|
521
|
+
|
|
522
|
+
var l1 = 1/(nd*cos1);
|
|
523
|
+
var l3 = - (1+2*tan2+etasq)/(6*nd3*cos1);
|
|
524
|
+
var l5 = (5+28*tan2+24*tan4)/(120*nd5*cos1);
|
|
525
|
+
|
|
526
|
+
// Geographische Breite bw und Laenge lw als Funktion von Ostwert ew
|
|
527
|
+
// und Nordwert nw
|
|
528
|
+
var bw = bf + (180/pi) * (b2*dy2 + b4*dy4 + b6*dy6);
|
|
529
|
+
var lw = lh + (180/pi) * (l1*dy + l3*dy3 + l5*dy5);
|
|
530
|
+
|
|
531
|
+
return {lat: bw, lng: lw};
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* Created by Johannes Rudolph <johannes.rudolph@gmx.com> on 01.09.2016.
|
|
536
|
+
*/
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* @type {{fromUTM: UTMREF.fromUTM, toUTM: UTMREF.toUTM}}
|
|
540
|
+
*/
|
|
541
|
+
var UTMREF = {
|
|
542
|
+
/**
|
|
543
|
+
* @param {{zone: string, x: number, y: number}}
|
|
544
|
+
* @returns {{zone, band: string, x: string, y: string}}
|
|
545
|
+
*/
|
|
546
|
+
fromUTM: function (utm) {
|
|
547
|
+
// Copyright (c) 2006, HELMUT H. HEIMEIER
|
|
548
|
+
if(utm === undefined){
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
var zone = utm.zone;
|
|
552
|
+
var ew = utm.x;
|
|
553
|
+
var nw = utm.y;
|
|
554
|
+
// Laengenzone zone, Ostwert ew und Nordwert nw im WGS84 Datum
|
|
555
|
+
var z1 = zone.substr(0, 2);
|
|
556
|
+
var z2 = zone.substr(2, 1);
|
|
557
|
+
var ew1 = parseInt(ew.substr(0, 2),10);
|
|
558
|
+
var nw1 = parseInt(nw.substr(0, 2),10);
|
|
559
|
+
var ew2 = ew.substr(2, 5);
|
|
560
|
+
var nw2 = nw.substr(2, 5);
|
|
561
|
+
var m_east = 'ABCDEFGHJKLMNPQRSTUVWXYZ';
|
|
562
|
+
var m_north = 'ABCDEFGHJKLMNPQRSTUV';
|
|
563
|
+
/*if (z1 < "01" || z1 > "60" || z2 < "C" || z2 > "X") {
|
|
564
|
+
alert(z1 + z2 + " ist keine gueltige UTM Zonenangabe"); // jshint ignore:line
|
|
565
|
+
}*/
|
|
566
|
+
var m_ce;
|
|
567
|
+
var i = z1 % 3;
|
|
568
|
+
if (i === 1) {
|
|
569
|
+
m_ce = ew1 - 1;
|
|
570
|
+
}
|
|
571
|
+
if (i === 2) {
|
|
572
|
+
m_ce = ew1 + 7;
|
|
573
|
+
}
|
|
574
|
+
if (i === 0) {
|
|
575
|
+
m_ce = ew1 + 15;
|
|
576
|
+
}
|
|
577
|
+
i = z1 % 2;
|
|
578
|
+
var m_cn;
|
|
579
|
+
if (i === 1) {
|
|
580
|
+
m_cn = 0;
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
m_cn = 5;
|
|
584
|
+
}
|
|
585
|
+
i = nw1;
|
|
586
|
+
while (i - 20 >= 0) {
|
|
587
|
+
i = i - 20;
|
|
588
|
+
}
|
|
589
|
+
m_cn = m_cn + i;
|
|
590
|
+
if (m_cn > 19) {
|
|
591
|
+
m_cn = m_cn - 20;
|
|
592
|
+
}
|
|
593
|
+
var band = m_east.charAt(m_ce) + m_north.charAt(m_cn);
|
|
594
|
+
|
|
595
|
+
return {zone: zone, band: band, x: ew2, y: nw2};
|
|
596
|
+
},
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* @param {{zone, band: string, x: string, y: string}}
|
|
600
|
+
* @returns {{zone: string, x: number, y: number}}
|
|
601
|
+
*/
|
|
602
|
+
toUTM: function (mgr) {
|
|
603
|
+
// Copyright (c) 2006, HELMUT H. HEIMEIER
|
|
604
|
+
|
|
605
|
+
// Laengenzone zone, Ostwert ew und Nordwert nw im WGS84 Datum
|
|
606
|
+
var m_east_0 = "STUVWXYZ";
|
|
607
|
+
var m_east_1 = "ABCDEFGH";
|
|
608
|
+
var m_east_2 = "JKLMNPQR";
|
|
609
|
+
var m_north_0 = "FGHJKLMNPQRSTUVABCDE";
|
|
610
|
+
var m_north_1 = "ABCDEFGHJKLMNPQRSTUV";
|
|
611
|
+
|
|
612
|
+
//zone = raster.substr(0,3);
|
|
613
|
+
var zone = mgr.zone;
|
|
614
|
+
var r_east = mgr.band.substr(0, 1);
|
|
615
|
+
var r_north = mgr.band.substr(1, 1);
|
|
616
|
+
|
|
617
|
+
var i = parseInt(zone.substr(0, 2),10) % 3;
|
|
618
|
+
var m_ce;
|
|
619
|
+
if (i === 0) {
|
|
620
|
+
m_ce = m_east_0.indexOf(r_east) + 1;
|
|
621
|
+
}
|
|
622
|
+
if (i === 1) {
|
|
623
|
+
m_ce = m_east_1.indexOf(r_east) + 1;
|
|
624
|
+
}
|
|
625
|
+
if (i === 2) {
|
|
626
|
+
m_ce = m_east_2.indexOf(r_east) + 1;
|
|
627
|
+
}
|
|
628
|
+
var ew = "0" + m_ce;
|
|
629
|
+
var m_cn = this._mgr2utm_find_m_cn(zone);
|
|
630
|
+
var nw;
|
|
631
|
+
if (m_cn.length === 1) {
|
|
632
|
+
nw = "0" + m_cn;
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
nw = "" + m_cn;
|
|
636
|
+
}
|
|
637
|
+
return {zone: zone, x: ew, y: nw};
|
|
638
|
+
}
|
|
639
|
+
};
|
package/worldmap/worldmap.js
CHANGED
|
@@ -1199,16 +1199,7 @@ layercontrol = L.control.layers(basemaps, overlays);
|
|
|
1199
1199
|
if (!inIframe) { layercontrol.addTo(map); }
|
|
1200
1200
|
else { showLayerMenu = false;}
|
|
1201
1201
|
|
|
1202
|
-
var coords = L.control.
|
|
1203
|
-
position:"bottomleft", //optional default "bottomright"
|
|
1204
|
-
decimals:4, //optional default 4
|
|
1205
|
-
decimalSeperator:".", //optional default "."
|
|
1206
|
-
labelTemplateLat:" Lat: {y}", //optional default "Lat: {y}"
|
|
1207
|
-
labelTemplateLng:" Lon: {x}", //optional default "Lng: {x}"
|
|
1208
|
-
enableUserInput:false, //optional default true
|
|
1209
|
-
useDMS:true, //optional default false
|
|
1210
|
-
useLatLngOrder: true, //ordering of labels, default false-> lng-lat
|
|
1211
|
-
});
|
|
1202
|
+
var coords = L.control.mouseCoordinate({position:"bottomleft"});
|
|
1212
1203
|
|
|
1213
1204
|
// Add an optional legend
|
|
1214
1205
|
var legend = L.control({ position: "bottomleft" });
|
|
@@ -2193,16 +2184,13 @@ function doCommand(cmd) {
|
|
|
2193
2184
|
if (cmd.hasOwnProperty("coords")) {
|
|
2194
2185
|
try { coords.removeFrom(map); }
|
|
2195
2186
|
catch(e) {}
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
showMouseCoords = "deg";
|
|
2204
|
-
coords.addTo(map);
|
|
2205
|
-
}
|
|
2187
|
+
var opts = {gps:false, gpsLong:false, utm:false, utmref:false, position:"bottomleft"}
|
|
2188
|
+
if (cmd.coords == "deg") { opts.gps = true; }
|
|
2189
|
+
if (cmd.coords == "dms") { opts.gpsLong = true; }
|
|
2190
|
+
if (cmd.coords == "utm") { opts.utm = true; }
|
|
2191
|
+
if (cmd.coords == "mgrs") { opts.utmref = true; }
|
|
2192
|
+
coords.options = opts;
|
|
2193
|
+
coords.addTo(map);
|
|
2206
2194
|
}
|
|
2207
2195
|
if (cmd.hasOwnProperty("legend")) {
|
|
2208
2196
|
if (typeof cmd.legend === "string" && cmd.legend.length > 0) {
|
|
@@ -2213,7 +2201,7 @@ function doCommand(cmd) {
|
|
|
2213
2201
|
return div;
|
|
2214
2202
|
};
|
|
2215
2203
|
legend.addTo(map);
|
|
2216
|
-
}
|
|
2204
|
+
}
|
|
2217
2205
|
legend.getContainer().style.visibility = 'visible'; // if already exist use visibility to show/hide
|
|
2218
2206
|
legend.getContainer().innerHTML = cmd.legend; // set content of legend
|
|
2219
2207
|
}
|