niney 1.0.1
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/index.d.ts +49 -0
- package/index.js +4091 -0
- package/package.json +15 -0
package/index.js
ADDED
|
@@ -0,0 +1,4091 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
4
|
+
/* Merging js from "mergejs.txt" begins */
|
|
5
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/* Last merge : vr 5 jun 2026 19:09:51 CEST */
|
|
9
|
+
|
|
10
|
+
/* Merging order :
|
|
11
|
+
|
|
12
|
+
- utils/BoundsModel.js
|
|
13
|
+
- utils/Bounds.js
|
|
14
|
+
- utils/Timer.js
|
|
15
|
+
- utils/AnimationTimer.js
|
|
16
|
+
- utils/PanSpeedTimer.js
|
|
17
|
+
- geometrymodel/Geometry.js
|
|
18
|
+
- geometrymodel/GeometryCollection.js
|
|
19
|
+
- geometrymodel/Point.js
|
|
20
|
+
- geometrymodel/Envelope.js
|
|
21
|
+
- geometrymodel/GeometryTools.js
|
|
22
|
+
- geometrymodel/LineString.js
|
|
23
|
+
- geometrymodel/Polygon.js
|
|
24
|
+
- geometrymodel/converters/WKTConverter.js
|
|
25
|
+
- geometrymodel/converters/SVGConverter.js
|
|
26
|
+
- geometrymodel/converters/CSSConverter.js
|
|
27
|
+
- geometrymodel/converters/JSONConverter.js
|
|
28
|
+
- featuremodel/Feature.js
|
|
29
|
+
- featuremodel/FeatureModel.js
|
|
30
|
+
- featuremodel/FeatureType.js
|
|
31
|
+
- featuremodel/Property.js
|
|
32
|
+
- featuremodel/PropertyType.js
|
|
33
|
+
- featuremodel/commands/EmptyFeatureCommand.js
|
|
34
|
+
- featuremodel/commands/SelectFeatureCommand.js
|
|
35
|
+
- featuremodel/commands/AggressiveSelectFeatureCommand.js
|
|
36
|
+
- featuremodel/commands/ToggleSelectFeatureCommand.js
|
|
37
|
+
- featuremodel/commands/ToURLFeatureCommand.js
|
|
38
|
+
- featuremodel/converters/CSVConverter.js
|
|
39
|
+
- filtermodel/FilterModel.js
|
|
40
|
+
- filtermodel/Filter.js
|
|
41
|
+
- filtermodel/converters/URLFilterConverter.js
|
|
42
|
+
- focusmodel/CenterScale.js
|
|
43
|
+
- focusmodel/FocusModel.js
|
|
44
|
+
- focusmodel/EnvelopeModel.js
|
|
45
|
+
- focusmodel/ZoomLevel.js
|
|
46
|
+
- focusmodel/SRS.js
|
|
47
|
+
- mapcontroller/MapController.js
|
|
48
|
+
- layermodel/Layer.js
|
|
49
|
+
- layermodel/Loader.js
|
|
50
|
+
- layermodel/Tile.js
|
|
51
|
+
- layermodel/VectorTile.js
|
|
52
|
+
- layermodel/TileModel.js
|
|
53
|
+
- layermodel/VectorTileModel.js
|
|
54
|
+
- layermodel/UTFGridModel.js
|
|
55
|
+
- layermodel/WMSInfo.js
|
|
56
|
+
- layermodel/WMSModel.js
|
|
57
|
+
- layermodel/MapFeatureModel.js
|
|
58
|
+
- layermodel/protocols/WMSProtocol.js
|
|
59
|
+
- selectionmodel/SelectionModel.js
|
|
60
|
+
- stylemodel/converters/URLClassificationConverter.js
|
|
61
|
+
- niney.es2015.js
|
|
62
|
+
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
67
|
+
/* Merging js: utils/BoundsModel.js begins */
|
|
68
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
export function BoundsModel() {
|
|
72
|
+
this.incubationTimer = new Timer(1000, 1);
|
|
73
|
+
this.bounds = null;
|
|
74
|
+
this.incubationBounds = null;
|
|
75
|
+
|
|
76
|
+
var boundsModel = this;
|
|
77
|
+
this.incubationTimer.timerHandler = function() {
|
|
78
|
+
boundsModel.incubationBounds = boundsModel.bounds;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
BoundsModel.prototype.setBounds = function(bounds) {
|
|
83
|
+
if (this.bounds == null) {
|
|
84
|
+
this.bounds = bounds;
|
|
85
|
+
this.incubationBounds = bounds;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (this.bounds.equals(bounds)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.bounds = bounds;
|
|
93
|
+
this.setIncubationBounds();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
BoundsModel.prototype.setIncubationBounds = function() {
|
|
97
|
+
this.incubationTimer.reset();
|
|
98
|
+
this.incubationTimer.start();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
104
|
+
/* Merging js: utils/Bounds.js begins */
|
|
105
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export function Bounds(width, height) {
|
|
109
|
+
this.width = width;
|
|
110
|
+
this.height = height;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Bounds.prototype.equals = function(o) {
|
|
114
|
+
return ((o != null) && (this.width == o.width) && (this.height == o.height));
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
120
|
+
/* Merging js: utils/Timer.js begins */
|
|
121
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
export function Timer(delay, numRepeats) {
|
|
125
|
+
this.delay = delay;
|
|
126
|
+
this.numRepeats = numRepeats;
|
|
127
|
+
this.currentCount = 0;
|
|
128
|
+
this.scope = null;
|
|
129
|
+
this.interval = -1;
|
|
130
|
+
this.timerHandler = function() { };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Timer.prototype.start = function() {
|
|
134
|
+
if ((this.interval == -1) && ((this.currentCount < this.numRepeats) || (this.numRepeats == -1))) {
|
|
135
|
+
var timer = this;
|
|
136
|
+
this.interval = setInterval(function() {
|
|
137
|
+
timer.currentCount++;
|
|
138
|
+
timer.tick();
|
|
139
|
+
if (timer.currentCount == timer.numRepeats) {
|
|
140
|
+
timer.stop();
|
|
141
|
+
}
|
|
142
|
+
}, this.delay);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
Timer.prototype.stop = function() {
|
|
147
|
+
if (this.interval != -1) {
|
|
148
|
+
clearInterval(this.interval);
|
|
149
|
+
this.interval = -1;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
Timer.prototype.reset = function() {
|
|
154
|
+
this.stop();
|
|
155
|
+
this.currentCount = 0;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
Timer.prototype.isRunning = function() {
|
|
159
|
+
return (this.interval != -1);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
Timer.prototype.tick = function() {
|
|
163
|
+
if (this.scope != null) {
|
|
164
|
+
this.scope.$apply(this.timerHandler);
|
|
165
|
+
} else {
|
|
166
|
+
this.timerHandler.apply();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
173
|
+
/* Merging js: utils/AnimationTimer.js begins */
|
|
174
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
export function AnimationTimer(duration) {
|
|
178
|
+
this.delay = -1;
|
|
179
|
+
this.numRepeats = -1;
|
|
180
|
+
this.currentCount = 0; // now - startTime
|
|
181
|
+
this.scope = null;
|
|
182
|
+
this.interval = -1;
|
|
183
|
+
this.timerHandler = function() { };
|
|
184
|
+
|
|
185
|
+
this.duration = duration;
|
|
186
|
+
this.startTime = -1;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
AnimationTimer.prototype = new Timer();
|
|
190
|
+
AnimationTimer.prototype.constructor = AnimationTimer;
|
|
191
|
+
|
|
192
|
+
AnimationTimer.prototype.start = function() {
|
|
193
|
+
if (this.interval == -1) {
|
|
194
|
+
this.startTime = performance.now();
|
|
195
|
+
var timer = this;
|
|
196
|
+
this.interval = window.requestAnimationFrame(preTick);
|
|
197
|
+
|
|
198
|
+
function preTick() {
|
|
199
|
+
timer.currentCount = performance.now() - timer.startTime;
|
|
200
|
+
if ((timer.duration > -1) && (timer.currentCount > timer.duration)) {
|
|
201
|
+
timer.currentCount = timer.duration;
|
|
202
|
+
timer.tick();
|
|
203
|
+
timer.stop();
|
|
204
|
+
} else {
|
|
205
|
+
timer.tick();
|
|
206
|
+
timer.interval = window.requestAnimationFrame(preTick);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
AnimationTimer.prototype.stop = function() {
|
|
213
|
+
if (this.interval != -1) {
|
|
214
|
+
window.cancelAnimationFrame(this.interval);
|
|
215
|
+
this.interval = -1;
|
|
216
|
+
this.startTime = -1;
|
|
217
|
+
this.currentCount = 0;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
AnimationTimer.prototype.reset = function() {
|
|
222
|
+
this.stop();
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
228
|
+
/* Merging js: utils/PanSpeedTimer.js begins */
|
|
229
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
export function PanSpeedTimer() {
|
|
233
|
+
this.delay = -1;
|
|
234
|
+
this.numRepeats = -1;
|
|
235
|
+
this.currentCount = 0;
|
|
236
|
+
this.scope = null;
|
|
237
|
+
this.interval = -1;
|
|
238
|
+
this.timerHandler = function() { };
|
|
239
|
+
|
|
240
|
+
this.duration = -1;
|
|
241
|
+
this.startTime = -1;
|
|
242
|
+
|
|
243
|
+
this.panned = false;
|
|
244
|
+
this.panEvents = [];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
PanSpeedTimer.prototype = new AnimationTimer();
|
|
248
|
+
PanSpeedTimer.prototype.constructor = PanSpeedTimer;
|
|
249
|
+
|
|
250
|
+
PanSpeedTimer.prototype.start = function(panEvent) {
|
|
251
|
+
panEvent.time = performance.now();
|
|
252
|
+
this.panEvents.push(panEvent);
|
|
253
|
+
|
|
254
|
+
AnimationTimer.prototype.start.call(this);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
PanSpeedTimer.prototype.resetAndGetSpeed = function(panEvent) {
|
|
258
|
+
var speed = {h: 0, v: 0, z: 1};
|
|
259
|
+
|
|
260
|
+
if (panEvent.touches == null) {
|
|
261
|
+
this.push(panEvent);
|
|
262
|
+
} else {
|
|
263
|
+
// For touch events, make sure that only events with the same number of touches are included in the speed calculation.
|
|
264
|
+
var eventSeries = [];
|
|
265
|
+
for (var i = 0; i < this.panEvents.length; i++) {
|
|
266
|
+
// Group them in series of subsequent events with the same number of touches.
|
|
267
|
+
if ((i == 0) || (this.panEvents[i].touches.length != this.panEvents[i - 1].touches.length)) {
|
|
268
|
+
eventSeries.push([this.panEvents[i]]);
|
|
269
|
+
} else {
|
|
270
|
+
eventSeries[eventSeries.length - 1].push(this.panEvents[i]);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
this.panEvents = eventSeries.sort(function(a, b) { return b.length - a.length; })[0]; // Select the event series with the most members.
|
|
274
|
+
panEvent = this.panEvents[this.panEvents.length - 1];
|
|
275
|
+
}
|
|
276
|
+
var previousEvent = this.panEvents[0];
|
|
277
|
+
var timeSpan = panEvent.time - previousEvent.time;
|
|
278
|
+
if (timeSpan > 0) {
|
|
279
|
+
speed.h = (panEvent.clientX - previousEvent.clientX) / timeSpan;
|
|
280
|
+
speed.v = (panEvent.clientY - previousEvent.clientY) / timeSpan;
|
|
281
|
+
if (panEvent.touches != null) {
|
|
282
|
+
speed.z = Math.pow(panEvent.radius / previousEvent.radius, 1 / timeSpan);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this.panned = false;
|
|
287
|
+
this.panEvents = [];
|
|
288
|
+
|
|
289
|
+
AnimationTimer.prototype.reset.call(this);
|
|
290
|
+
|
|
291
|
+
return speed;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
PanSpeedTimer.prototype.push = function(panEvent) {
|
|
295
|
+
panEvent.time = performance.now();
|
|
296
|
+
this.panned = true;
|
|
297
|
+
this.panEvents.push(panEvent);
|
|
298
|
+
while (panEvent.time - this.panEvents[0].time > 100) {
|
|
299
|
+
this.panEvents.shift();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export function decorateTouchEvent(touchEvent, lastTouchOnly) {
|
|
304
|
+
if (touchEvent.touches == null) { // Not a touch event.
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
var touch = touchEvent.touches[touchEvent.touches.length - 1];
|
|
309
|
+
if (touchEvent.touches.length == 0) {
|
|
310
|
+
touchEvent.clientX = touchEvent.changedTouches[0].clientX;
|
|
311
|
+
touchEvent.clientY = touchEvent.changedTouches[0].clientY;
|
|
312
|
+
touchEvent.radius = 1;
|
|
313
|
+
} else if ((touchEvent.touches.length == 1) || lastTouchOnly) {
|
|
314
|
+
touchEvent.clientX = touch.clientX;
|
|
315
|
+
touchEvent.clientY = touch.clientY;
|
|
316
|
+
touchEvent.radius = 1;
|
|
317
|
+
} else { // 2 or more touches.
|
|
318
|
+
var minX = touch.clientX;
|
|
319
|
+
var minY = touch.clientY;
|
|
320
|
+
var maxX = touch.clientX;
|
|
321
|
+
var maxY = touch.clientY;
|
|
322
|
+
for (var i = 0; i < touchEvent.touches.length - 1; i++) {
|
|
323
|
+
touch = touchEvent.touches[i];
|
|
324
|
+
if (minX > touch.clientX) {
|
|
325
|
+
minX = touch.clientX;
|
|
326
|
+
}
|
|
327
|
+
if (minY > touch.clientY) {
|
|
328
|
+
minY = touch.clientY;
|
|
329
|
+
}
|
|
330
|
+
if (maxX < touch.clientX) {
|
|
331
|
+
maxX = touch.clientX;
|
|
332
|
+
}
|
|
333
|
+
if (maxY < touch.clientY) {
|
|
334
|
+
maxY = touch.clientY;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
touchEvent.clientX = (minX + maxX) / 2;
|
|
338
|
+
touchEvent.clientY = (minY + maxY) / 2;
|
|
339
|
+
touchEvent.radius = Math.sqrt((maxX - minX) * (maxX - minX) + (maxY - minY) * (maxY - minY));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
346
|
+
/* Merging js: geometrymodel/Geometry.js begins */
|
|
347
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
export function Geometry() {
|
|
351
|
+
this.$parent = null; // Starts with $ to prevent recursion in angular.equals (geometry.childGeometries[0].$parent == geometry and so on).
|
|
352
|
+
this.childGeometries = [];
|
|
353
|
+
this.envelope = null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
Geometry.prototype.setParent = function(parent) {
|
|
357
|
+
if (this.$parent == parent) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (this.$parent != null) {
|
|
361
|
+
var previousParent = this.$parent;
|
|
362
|
+
this.$parent = null;
|
|
363
|
+
previousParent.removeChild(this);
|
|
364
|
+
}
|
|
365
|
+
if (parent != null) {
|
|
366
|
+
this.$parent = parent;
|
|
367
|
+
parent.addChild(this);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
Geometry.prototype.addChild = function(child) {
|
|
372
|
+
if (this.isChild(child)) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
this.childGeometries.push(child);
|
|
377
|
+
child.setParent(this);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
Geometry.prototype.removeChild = function(child) {
|
|
381
|
+
if (!this.isChild(child)) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
386
|
+
if (this.childGeometries[i] == child) {
|
|
387
|
+
this.childGeometries.splice(i, 1);
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
child.$parent = null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
Geometry.prototype.isChild = function(child) {
|
|
395
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
396
|
+
if (this.childGeometries[i] == child) {
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
Geometry.prototype.getPoints = function() {
|
|
404
|
+
var points = [];
|
|
405
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
406
|
+
points = points.concat(this.childGeometries[i].getPoints());
|
|
407
|
+
}
|
|
408
|
+
return points;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
Geometry.prototype.getEndPoint = function() {
|
|
412
|
+
var points = this.getPoints();
|
|
413
|
+
return points[points.length - 1];
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
Geometry.prototype.getCenterPoint = function() {
|
|
417
|
+
var points = this.getPoints();
|
|
418
|
+
var sumX = 0;
|
|
419
|
+
var sumY = 0;
|
|
420
|
+
for (var i = 0; i < points.length; i++) {
|
|
421
|
+
sumX += points[i].x;
|
|
422
|
+
sumY += points[i].y;
|
|
423
|
+
}
|
|
424
|
+
return new Point(sumX / points.length, sumY / points.length);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
Geometry.prototype.getLineStrings = function() {
|
|
428
|
+
var lineStrings = [];
|
|
429
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
430
|
+
lineStrings = lineStrings.concat(this.childGeometries[i].getLineStrings());
|
|
431
|
+
}
|
|
432
|
+
return lineStrings;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
Geometry.prototype.getEnvelope = function() {
|
|
436
|
+
if (this.envelope == null) {
|
|
437
|
+
var points = this.getPoints();
|
|
438
|
+
var minX = Number.MAX_VALUE;
|
|
439
|
+
var minY = Number.MAX_VALUE;
|
|
440
|
+
var maxX = -Number.MAX_VALUE;
|
|
441
|
+
var maxY = -Number.MAX_VALUE;
|
|
442
|
+
for (var i = 0; i < points.length; i++) {
|
|
443
|
+
if (minX > points[i].x) {
|
|
444
|
+
minX = points[i].x;
|
|
445
|
+
}
|
|
446
|
+
if (minY > points[i].y) {
|
|
447
|
+
minY = points[i].y;
|
|
448
|
+
}
|
|
449
|
+
if (maxX < points[i].x) {
|
|
450
|
+
maxX = points[i].x;
|
|
451
|
+
}
|
|
452
|
+
if (maxY < points[i].y) {
|
|
453
|
+
maxY = points[i].y;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
this.envelope = new Envelope(minX, minY, maxX, maxY);
|
|
457
|
+
}
|
|
458
|
+
return this.envelope;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
Geometry.prototype.round = function(numDecimals) {
|
|
462
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
463
|
+
this.childGeometries[i].round(numDecimals);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (this.envelope != null) {
|
|
467
|
+
this.envelope.round(numDecimals);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
Geometry.prototype.intersects = function(geometry) {
|
|
472
|
+
return this.getEnvelope().intersects(geometry);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
Geometry.prototype.equals = function(geometry) {
|
|
476
|
+
if (geometry == null) {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
if (this.childGeometries.length != geometry.childGeometries.length) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
483
|
+
if (!this.childGeometries[i].equals(geometry.childGeometries[i])) {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
Geometry.prototype.clone = function() {
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
Geometry.prototype.invalidateEnvelope = function() {
|
|
495
|
+
this.envelope = null;
|
|
496
|
+
if (this.$parent != null) {
|
|
497
|
+
this.$parent.invalidateEnvelope();
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
Geometry.prototype.getLabelPoint = function(numSlices) {
|
|
502
|
+
return this.getCenterPoint();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
508
|
+
/* Merging js: geometrymodel/GeometryCollection.js begins */
|
|
509
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
export function GeometryCollection(geometries) {
|
|
513
|
+
this.$parent = null;
|
|
514
|
+
this.childGeometries = [];
|
|
515
|
+
this.envelope = null;
|
|
516
|
+
|
|
517
|
+
if ((geometries == null) || (geometries.length == 0)) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
for (var i = 0; i < geometries.length; i++) {
|
|
522
|
+
geometries[i].setParent(this);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
GeometryCollection.prototype = new Geometry();
|
|
527
|
+
GeometryCollection.prototype.constructor = GeometryCollection;
|
|
528
|
+
|
|
529
|
+
GeometryCollection.prototype.clone = function() {
|
|
530
|
+
var clonedGeometries = [];
|
|
531
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
532
|
+
clonedGeometries.push(this.childGeometries[i].clone());
|
|
533
|
+
}
|
|
534
|
+
return new GeometryCollection(clonedGeometries);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
540
|
+
/* Merging js: geometrymodel/Point.js begins */
|
|
541
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
export function Point(x, y) {
|
|
545
|
+
this.$parent = null;
|
|
546
|
+
this.childGeometries = [];
|
|
547
|
+
this.envelope = null;
|
|
548
|
+
|
|
549
|
+
this.x = x;
|
|
550
|
+
this.y = y;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
Point.prototype = new Geometry();
|
|
554
|
+
Point.prototype.constructor = Point;
|
|
555
|
+
|
|
556
|
+
Point.prototype.addChild = function(child) { }
|
|
557
|
+
|
|
558
|
+
Point.prototype.removeChild = function(child) { }
|
|
559
|
+
|
|
560
|
+
Point.prototype.getPoints = function() {
|
|
561
|
+
return [this];
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
Point.prototype.getEndPoint = function() {
|
|
565
|
+
return this;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
Point.prototype.getCenterPoint = function() {
|
|
569
|
+
return this.clone();
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
Point.prototype.getEnvelope = function() {
|
|
573
|
+
if (this.envelope == null) {
|
|
574
|
+
this.envelope = new Envelope(this.x, this.y, this.x, this.y);
|
|
575
|
+
}
|
|
576
|
+
return this.envelope;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
Point.prototype.round = function(numDecimals) {
|
|
580
|
+
var pow = Math.pow(10, numDecimals);
|
|
581
|
+
this.x = Math.round(this.x * pow) / pow;
|
|
582
|
+
this.y = Math.round(this.y * pow) / pow;
|
|
583
|
+
|
|
584
|
+
if (this.envelope != null) {
|
|
585
|
+
this.envelope.round(numDecimals);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
Point.prototype.intersects = function(geometry) {
|
|
590
|
+
if (geometry instanceof Point) {
|
|
591
|
+
return this.equals(geometry);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (geometry instanceof Polygon) {
|
|
595
|
+
var numWindings = 0;
|
|
596
|
+
var points = geometry.getPoints();
|
|
597
|
+
for (var i = 0; i < points.length - 1; i++) {
|
|
598
|
+
if (points[i].y <= this.y) {
|
|
599
|
+
if ((points[i + 1].y > this.y) && (this.isLeft(points[i], points[i + 1]) > 0)) {
|
|
600
|
+
numWindings++;
|
|
601
|
+
}
|
|
602
|
+
} else {
|
|
603
|
+
if ((points[i + 1].y <= this.y) && (this.isLeft(points[i], points[i + 1]) < 0)) {
|
|
604
|
+
numWindings--;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return numWindings != 0;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
if (geometry instanceof Envelope) {
|
|
612
|
+
return (
|
|
613
|
+
(this.x >= geometry.minX) &&
|
|
614
|
+
(this.y >= geometry.minY) &&
|
|
615
|
+
(this.x <= geometry.maxX) &&
|
|
616
|
+
(this.y <= geometry.maxY)
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return this.intersects(geometry.getEnvelope());
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
Point.prototype.isLeft = function(point0, point1) {
|
|
624
|
+
return (point1.x - point0.x) * (this.y - point0.y) - (this.x - point0.x) * (point1.y - point0.y);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
Point.prototype.equals = function(geometry) {
|
|
628
|
+
if (!(geometry instanceof Point)) {
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
if ((this.x == geometry.x) && (this.y == geometry.y)) {
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
Point.prototype.clone = function() {
|
|
638
|
+
return new Point(this.x, this.y);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
Point.prototype.getDistance = function(point) {
|
|
642
|
+
var dx = this.x - point.x;
|
|
643
|
+
var dy = this.y - point.y;
|
|
644
|
+
var distance = Math.sqrt((dx * dx) + (dy * dy));
|
|
645
|
+
return distance;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
Point.prototype.setXY = function(x, y) {
|
|
649
|
+
this.x = x;
|
|
650
|
+
this.y = y;
|
|
651
|
+
|
|
652
|
+
this.invalidateEnvelope();
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
Point.prototype.move = function(dx, dy) {
|
|
656
|
+
this.x += dx;
|
|
657
|
+
this.y += dy;
|
|
658
|
+
|
|
659
|
+
this.invalidateEnvelope();
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
665
|
+
/* Merging js: geometrymodel/Envelope.js begins */
|
|
666
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
export function Envelope(minX, minY, maxX, maxY) {
|
|
670
|
+
this.$parent = null;
|
|
671
|
+
this.childGeometries = [];
|
|
672
|
+
this.envelope = null;
|
|
673
|
+
|
|
674
|
+
this.minX = minX;
|
|
675
|
+
this.minY = minY;
|
|
676
|
+
this.maxX = maxX;
|
|
677
|
+
this.maxY = maxY;
|
|
678
|
+
|
|
679
|
+
var point0 = new Point(minX, minY);
|
|
680
|
+
var point1 = new Point(maxX, maxY);
|
|
681
|
+
point0.setParent(this);
|
|
682
|
+
point1.setParent(this);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
Envelope.prototype = new Geometry();
|
|
686
|
+
Envelope.prototype.constructor = Envelope;
|
|
687
|
+
|
|
688
|
+
Envelope.prototype.getEnvelope = function() {
|
|
689
|
+
if (this.envelope == null) {
|
|
690
|
+
this.envelope = this.clone();
|
|
691
|
+
}
|
|
692
|
+
return this.envelope;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
Envelope.prototype.round = function(numDecimals) {
|
|
696
|
+
var pow = Math.pow(10, numDecimals);
|
|
697
|
+
this.minX = Math.round(this.minX * pow) / pow;
|
|
698
|
+
this.minY = Math.round(this.minY * pow) / pow;
|
|
699
|
+
this.maxX = Math.round(this.maxX * pow) / pow;
|
|
700
|
+
this.maxY = Math.round(this.maxY * pow) / pow;
|
|
701
|
+
|
|
702
|
+
Geometry.prototype.round.call(this, numDecimals);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
Envelope.prototype.intersects = function(geometry) {
|
|
706
|
+
if (geometry instanceof Point) {
|
|
707
|
+
return geometry.intersects(this);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
if (geometry instanceof Envelope) {
|
|
711
|
+
return (
|
|
712
|
+
(this.minX <= geometry.maxX) &&
|
|
713
|
+
(this.minY <= geometry.maxY) &&
|
|
714
|
+
(this.maxX >= geometry.minX) &&
|
|
715
|
+
(this.maxY >= geometry.minY)
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
return this.intersects(geometry.getEnvelope());
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
Envelope.prototype.equals = function(geometry) {
|
|
723
|
+
if (!(geometry instanceof Envelope)) {
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
return (
|
|
728
|
+
(this.minX == geometry.minX) &&
|
|
729
|
+
(this.minY == geometry.minY) &&
|
|
730
|
+
(this.maxX == geometry.maxX) &&
|
|
731
|
+
(this.maxY == geometry.maxY)
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
Envelope.prototype.clone = function() {
|
|
736
|
+
return new Envelope(this.minX, this.minY, this.maxX, this.maxY);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
Envelope.prototype.invalidateEnvelope = function() {
|
|
740
|
+
Geometry.prototype.invalidateEnvelope.call(this);
|
|
741
|
+
|
|
742
|
+
if (this.childGeometries[0].x <= this.childGeometries[1].x) {
|
|
743
|
+
this.minX = this.childGeometries[0].x;
|
|
744
|
+
this.maxX = this.childGeometries[1].x;
|
|
745
|
+
} else {
|
|
746
|
+
this.minX = this.childGeometries[1].x;
|
|
747
|
+
this.maxX = this.childGeometries[0].x;
|
|
748
|
+
}
|
|
749
|
+
if (this.childGeometries[0].y <= this.childGeometries[1].y) {
|
|
750
|
+
this.minY = this.childGeometries[0].y;
|
|
751
|
+
this.maxY = this.childGeometries[1].y;
|
|
752
|
+
} else {
|
|
753
|
+
this.minY = this.childGeometries[1].y;
|
|
754
|
+
this.maxY = this.childGeometries[0].y;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
Envelope.prototype.getWidth = function() {
|
|
759
|
+
return this.maxX - this.minX;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
Envelope.prototype.getHeight = function() {
|
|
763
|
+
return this.maxY - this.minY;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
Envelope.prototype.grow = function(factor) {
|
|
767
|
+
var displacementFactor = (factor - 1) / 2;
|
|
768
|
+
var dx = this.getWidth() * displacementFactor;
|
|
769
|
+
var dy = this.getHeight() * displacementFactor;
|
|
770
|
+
var minX = this.minX - dx;
|
|
771
|
+
var minY = this.minY - dy;
|
|
772
|
+
var maxX = this.maxX + dx;
|
|
773
|
+
var maxY = this.maxY + dy;
|
|
774
|
+
|
|
775
|
+
this.childGeometries[0].setXY(minX, minY);
|
|
776
|
+
this.childGeometries[1].setXY(maxX, maxY);
|
|
777
|
+
|
|
778
|
+
this.invalidateEnvelope();
|
|
779
|
+
|
|
780
|
+
return this;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
Envelope.prototype.intersection = function(envelope) {
|
|
784
|
+
if (!(envelope instanceof Envelope)) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
return new Envelope(
|
|
789
|
+
Math.max(this.minX, envelope.minX),
|
|
790
|
+
Math.max(this.minY, envelope.minY),
|
|
791
|
+
Math.min(this.maxX, envelope.maxX),
|
|
792
|
+
Math.min(this.maxY, envelope.maxY)
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
Envelope.prototype.toString = function() {
|
|
797
|
+
return "Envelope(" + this.minX + ", " + this.minY + ", " + this.maxX + ", " + this.maxY + ")";
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
803
|
+
/* Merging js: geometrymodel/GeometryTools.js begins */
|
|
804
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
export function GeometryTools() { }
|
|
808
|
+
|
|
809
|
+
GeometryTools.getGeometryClass = function(geometryType) {
|
|
810
|
+
geometryType = geometryType.toUpperCase();
|
|
811
|
+
if (geometryType == "POINT") {
|
|
812
|
+
return Point;
|
|
813
|
+
} else if (geometryType == "ENVELOPE") {
|
|
814
|
+
return Envelope;
|
|
815
|
+
} else if (geometryType == "CIRCLE") {
|
|
816
|
+
return Circle;
|
|
817
|
+
} else if (geometryType == "LINESTRING") {
|
|
818
|
+
return LineString;
|
|
819
|
+
} else if (geometryType == "POLYGON") {
|
|
820
|
+
return Polygon;
|
|
821
|
+
}
|
|
822
|
+
return null;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
GeometryTools.transform = function(geometry, srid) {
|
|
826
|
+
if (geometry == null) {
|
|
827
|
+
throw new Error("No geometry given.");
|
|
828
|
+
}
|
|
829
|
+
if (!(geometry instanceof Point)) {
|
|
830
|
+
throw new Error("Given geometry is not a point. Only point geometries are currently supported.");
|
|
831
|
+
}
|
|
832
|
+
var point = geometry;
|
|
833
|
+
|
|
834
|
+
if ((point.srid == 4326) && (srid == 900913)) {
|
|
835
|
+
var x = point.x * 20037508.3427892 / 180;
|
|
836
|
+
var y = Math.log(Math.tan((90 + point.y) * Math.PI / 360)) * 180 / Math.PI;
|
|
837
|
+
y = y * 20037508.3427892 / 180;
|
|
838
|
+
point = new Point(x, y);
|
|
839
|
+
point.srid = srid;
|
|
840
|
+
return point;
|
|
841
|
+
} else if ((point.srid == 900913) && (srid == 4326)) {
|
|
842
|
+
var x = point.x * 180 / 20037508.3427892;
|
|
843
|
+
var y = point.y * 180 / 20037508.3427892;
|
|
844
|
+
y = Math.atan(Math.exp(y / 180 * Math.PI)) * 360 / Math.PI - 90;
|
|
845
|
+
point = new Point(x, y);
|
|
846
|
+
point.srid = srid;
|
|
847
|
+
return point;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
throw new Error("Given SRID transformation is currently not supported.");
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
855
|
+
/* Merging js: geometrymodel/LineString.js begins */
|
|
856
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
export function LineString(points) {
|
|
860
|
+
this.$parent = null;
|
|
861
|
+
this.childGeometries = [];
|
|
862
|
+
this.envelope = null;
|
|
863
|
+
|
|
864
|
+
if ((points == null) || (points.length < 2)) {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
for (var i = 0; i < points.length; i++) {
|
|
869
|
+
points[i].setParent(this);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
LineString.prototype = new Geometry();
|
|
874
|
+
LineString.prototype.constructor = LineString;
|
|
875
|
+
|
|
876
|
+
LineString.prototype.addChild = function(child) {
|
|
877
|
+
if (this.isChild(child)) {
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
if (!(child instanceof Point)) {
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
this.childGeometries.push(child);
|
|
885
|
+
child.setParent(this);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
LineString.prototype.removeChild = function(child) {
|
|
889
|
+
if (!this.isChild(child)) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (this.childGeometries.length == 2) {
|
|
894
|
+
if (child == this.childGeometries[0]) {
|
|
895
|
+
this.childGeometries[0] = this.childGeometries[1].clone();
|
|
896
|
+
this.childGeometries[0].$parent = this;
|
|
897
|
+
} else { // (child == this.childGeometries[1])
|
|
898
|
+
this.childGeometries[1] = this.childGeometries[0].clone();
|
|
899
|
+
this.childGeometries[1].$parent = this;
|
|
900
|
+
}
|
|
901
|
+
} else {
|
|
902
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
903
|
+
if (this.childGeometries[i] == child) {
|
|
904
|
+
this.childGeometries.splice(i, 1);
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
child.$parent = null;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
LineString.prototype.getLineStrings = function() {
|
|
913
|
+
return [this];
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
LineString.prototype.clone = function() {
|
|
917
|
+
var clonedPoints = [];
|
|
918
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
919
|
+
clonedPoints.push(this.childGeometries[i].clone());
|
|
920
|
+
}
|
|
921
|
+
return new LineString(clonedPoints);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
LineString.prototype.getLength = function() {
|
|
925
|
+
var length = 0;
|
|
926
|
+
for (var i = 1; i < this.childGeometries.length; i++) {
|
|
927
|
+
length += this.childGeometries[i].getDistance(this.childGeometries[i - 1]);
|
|
928
|
+
}
|
|
929
|
+
return length;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
LineString.prototype.getArea = function() {
|
|
933
|
+
var area = 0;
|
|
934
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
935
|
+
var j = (i + 1) % this.childGeometries.length;
|
|
936
|
+
area += this.childGeometries[i].x * this.childGeometries[j].y;
|
|
937
|
+
area -= this.childGeometries[i].y * this.childGeometries[j].x;
|
|
938
|
+
}
|
|
939
|
+
return Math.abs(area / 2);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
LineString.prototype.getLabelPoint = function(numSlices) {
|
|
943
|
+
var labelDistance = this.getLength() / 2;
|
|
944
|
+
var cumulativeDistance = 0;
|
|
945
|
+
for (var i = 1; i < this.childGeometries.length; i++) {
|
|
946
|
+
var point = this.childGeometries[i];
|
|
947
|
+
var previousPoint = this.childGeometries[i - 1];
|
|
948
|
+
var additionalDistance = point.getDistance(previousPoint);
|
|
949
|
+
if (cumulativeDistance + additionalDistance >= labelDistance) {
|
|
950
|
+
var ratio = (labelDistance - cumulativeDistance) / additionalDistance;
|
|
951
|
+
var pointX = (point.x - previousPoint.x) * ratio + previousPoint.x;
|
|
952
|
+
var pointY = (point.y - previousPoint.y) * ratio + previousPoint.y;
|
|
953
|
+
return new Point(pointX, pointY);
|
|
954
|
+
}
|
|
955
|
+
cumulativeDistance += additionalDistance;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
962
|
+
/* Merging js: geometrymodel/Polygon.js begins */
|
|
963
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
export function Polygon(lineStrings) {
|
|
967
|
+
this.$parent = null;
|
|
968
|
+
this.childGeometries = [];
|
|
969
|
+
this.envelope = null;
|
|
970
|
+
|
|
971
|
+
if ((lineStrings == null) || (lineStrings.length < 1)) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
for (var i = 0; i < lineStrings.length; i++) {
|
|
976
|
+
lineStrings[i].setParent(this);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
Polygon.prototype = new Geometry();
|
|
981
|
+
Polygon.prototype.constructor = Polygon;
|
|
982
|
+
|
|
983
|
+
Polygon.prototype.getPoints = function() {
|
|
984
|
+
return this.childGeometries[0].getPoints();
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
Polygon.prototype.intersects = function(geometry) {
|
|
988
|
+
if (geometry instanceof Point) {
|
|
989
|
+
return geometry.intersects(this);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
return this.getEnvelope().intersects(geometry);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
Polygon.prototype.clone = function() {
|
|
996
|
+
var clonedLineStrings = [];
|
|
997
|
+
for (var i = 0; i < this.childGeometries.length; i++) {
|
|
998
|
+
clonedLineStrings.push(this.childGeometries[i].clone());
|
|
999
|
+
}
|
|
1000
|
+
return new Polygon(clonedLineStrings);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
Polygon.prototype.getLength = function() {
|
|
1004
|
+
return this.childGeometries[0].getLength();
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
Polygon.prototype.getArea = function() {
|
|
1008
|
+
return this.childGeometries[0].getArea();
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
Polygon.prototype.getLabelPoint = function(numSlices) {
|
|
1012
|
+
var horizontalScanLines = [];
|
|
1013
|
+
var envelope = this.getEnvelope();
|
|
1014
|
+
for (var i = 0; i < numSlices; i++) {
|
|
1015
|
+
var y = envelope.minY + envelope.getHeight() / (numSlices + 1) * (i + 1);
|
|
1016
|
+
horizontalScanLines.push(this.getHorizontalScanLine(y));
|
|
1017
|
+
horizontalScanLines[i].malusFactor = 1 - 0.2 / (numSlices - 1) * Math.abs((numSlices - 1) / 2 - i);
|
|
1018
|
+
}
|
|
1019
|
+
var horizontalScanLine = horizontalScanLines.sort(function(a, b) { return b.distance * b.malusFactor - a.distance * a.malusFactor; })[0];
|
|
1020
|
+
var pointX = (horizontalScanLine.x0 + horizontalScanLine.x1) / 2;
|
|
1021
|
+
var pointY = horizontalScanLine.y;
|
|
1022
|
+
var verticalScanLine = this.getVerticalScanLine(pointX, pointY);
|
|
1023
|
+
var marginFactor = 0.3;
|
|
1024
|
+
var marginMinY = verticalScanLine.y0 + marginFactor * (verticalScanLine.y1 - verticalScanLine.y0);
|
|
1025
|
+
var marginMaxY = verticalScanLine.y1 - marginFactor * (verticalScanLine.y1 - verticalScanLine.y0);
|
|
1026
|
+
if (pointY <= marginMinY) {
|
|
1027
|
+
return new Point(pointX, marginMinY);
|
|
1028
|
+
}
|
|
1029
|
+
if (pointY >= marginMaxY) {
|
|
1030
|
+
return new Point(pointX, marginMaxY);
|
|
1031
|
+
}
|
|
1032
|
+
return new Point(pointX, pointY);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
Polygon.prototype.getHorizontalScanLine = function(y) {
|
|
1036
|
+
var points = this.getPoints();
|
|
1037
|
+
var segments = [];
|
|
1038
|
+
for (var i = 1; i < points.length; i++) {
|
|
1039
|
+
if (points[i - 1].y == points[i].y) {
|
|
1040
|
+
continue; // Skip horizontal segments;
|
|
1041
|
+
}
|
|
1042
|
+
segments.push([points[i - 1], points[i]]);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
var selectedSegments = [];
|
|
1046
|
+
for (var j = 0; j < segments.length; j++) {
|
|
1047
|
+
var segment = segments[j];
|
|
1048
|
+
var minY = Math.min(segment[0].y, segment[1].y);
|
|
1049
|
+
var maxY = Math.max(segment[0].y, segment[1].y);
|
|
1050
|
+
var nextSegment = (j < segments.length - 1)? segments[j + 1]: segments[0];
|
|
1051
|
+
var nextMinY = Math.min(nextSegment[0].y, nextSegment[1].y);
|
|
1052
|
+
var nextMaxY = Math.max(nextSegment[0].y, nextSegment[1].y);
|
|
1053
|
+
if ((y < minY) || (y > maxY)) {
|
|
1054
|
+
continue; // No intersection, so skip current segment.
|
|
1055
|
+
}
|
|
1056
|
+
if (((y == minY) && (y == nextMaxY)) || ((y == maxY) && (y == nextMinY))) {
|
|
1057
|
+
continue; // Treat current and next segment as one, so skip current segment.
|
|
1058
|
+
}
|
|
1059
|
+
if (((y == minY) && (y == nextMinY)) || ((y == maxY) && (y == nextMaxY))) {
|
|
1060
|
+
if (j < segments.length - 1) {
|
|
1061
|
+
j++; // Skip both current and next segment;
|
|
1062
|
+
continue;
|
|
1063
|
+
} else {
|
|
1064
|
+
selectedSegments.splice(0, 1); // Skip last segment and remove first segment;
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
selectedSegments.push({
|
|
1069
|
+
x: (y - segment[0].y) / (segment[1].y - segment[0].y) * (segment[1].x - segment[0].x) + segment[0].x,
|
|
1070
|
+
segment: segment
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
selectedSegments.sort(function(a, b) { return a.x - b.x; });
|
|
1074
|
+
|
|
1075
|
+
var scanLines = [];
|
|
1076
|
+
for (var k = 0; k < selectedSegments.length; k = k + 2) {
|
|
1077
|
+
scanLines.push({
|
|
1078
|
+
x0: selectedSegments[k].x,
|
|
1079
|
+
x1: selectedSegments[k + 1].x,
|
|
1080
|
+
y: y,
|
|
1081
|
+
distance: selectedSegments[k + 1].x - selectedSegments[k].x
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
return scanLines.sort(function(a, b) { return b.distance - a.distance; })[0]; // Returns the longest scanline.
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
Polygon.prototype.getVerticalScanLine = function(x, y) {
|
|
1088
|
+
var points = this.getPoints();
|
|
1089
|
+
var segments = [];
|
|
1090
|
+
for (var i = 1; i < points.length; i++) {
|
|
1091
|
+
if (points[i - 1].x == points[i].x) {
|
|
1092
|
+
continue; // Skip vertical segments;
|
|
1093
|
+
}
|
|
1094
|
+
segments.push([points[i - 1], points[i]]);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
var selectedSegments = [];
|
|
1098
|
+
for (var j = 0; j < segments.length; j++) {
|
|
1099
|
+
var segment = segments[j];
|
|
1100
|
+
var minX = Math.min(segment[0].x, segment[1].x);
|
|
1101
|
+
var maxX = Math.max(segment[0].x, segment[1].x);
|
|
1102
|
+
var nextSegment = (j < segments.length - 1)? segments[j + 1]: segments[0];
|
|
1103
|
+
var nextMinX = Math.min(nextSegment[0].x, nextSegment[1].x);
|
|
1104
|
+
var nextMaxX = Math.max(nextSegment[0].x, nextSegment[1].x);
|
|
1105
|
+
if ((x < minX) || (x > maxX)) {
|
|
1106
|
+
continue; // No intersection, so skip current segment.
|
|
1107
|
+
}
|
|
1108
|
+
if (((x == minX) && (x == nextMaxX)) || ((x == maxX) && (x == nextMinX))) {
|
|
1109
|
+
continue; // Treat current and next segment as one, so skip current segment.
|
|
1110
|
+
}
|
|
1111
|
+
if (((x == minX) && (x == nextMinX)) || ((x == maxX) && (x == nextMaxX))) {
|
|
1112
|
+
if (j < segments.length - 1) {
|
|
1113
|
+
j++; // Skip both current and next segment;
|
|
1114
|
+
continue;
|
|
1115
|
+
} else {
|
|
1116
|
+
selectedSegments.splice(0, 1); // Skip last segment and remove first segment;
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
selectedSegments.push({
|
|
1121
|
+
y: (x - segment[0].x) / (segment[1].x - segment[0].x) * (segment[1].y - segment[0].y) + segment[0].y,
|
|
1122
|
+
segment: segment
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
selectedSegments.sort(function(a, b) { return a.y - b.y; });
|
|
1126
|
+
|
|
1127
|
+
for (var k = 0; k < selectedSegments.length; k = k + 2) {
|
|
1128
|
+
if ((y >= selectedSegments[k].y) && (y <= selectedSegments[k + 1].y)) { // Returns the scanline that matches the given y.
|
|
1129
|
+
return {
|
|
1130
|
+
x: x,
|
|
1131
|
+
y0: selectedSegments[k].y,
|
|
1132
|
+
y1: selectedSegments[k + 1].y,
|
|
1133
|
+
distance: selectedSegments[k + 1].y - selectedSegments[k].y
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1142
|
+
/* Merging js: geometrymodel/converters/WKTConverter.js begins */
|
|
1143
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
export function WKTConverter() {
|
|
1147
|
+
this.sridRegExp = /^"?SRID=(\d+);(.*)/;
|
|
1148
|
+
this.geometryCollectionRegExp = /^"?GEOMETRYCOLLECTION\s?\((.*?)\)"?$/;
|
|
1149
|
+
this.multiGeometryRegExp = /^"?MULTI(POINT|LINESTRING|POLYGON)\s?\((.*?)\)"?$/;
|
|
1150
|
+
this.pointRegExp = /^"?POINT\s?\(([-\d\s\.]*)\)"?$/;
|
|
1151
|
+
this.lineStringRegExp = /^"?LINESTRING\s?\(([-\d\s\.,]*)\)"?$/;
|
|
1152
|
+
this.polygonRegExp = /^"?POLYGON\s?\(([-\d\s\.,\(\)]*)\)"?$/;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
WKTConverter.prototype.wktToGeometry = function(wkt) {
|
|
1156
|
+
var sridString = null;
|
|
1157
|
+
if (wkt.search(this.sridRegExp) == 0) {
|
|
1158
|
+
sridString = wkt.replace(this.sridRegExp, "$1");
|
|
1159
|
+
wkt = wkt.replace(this.sridRegExp, "$2");
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
var geometry = null;
|
|
1163
|
+
if (wkt.search(this.geometryCollectionRegExp) == 0) {
|
|
1164
|
+
geometry = this.wktToGeometryCollection(wkt);
|
|
1165
|
+
} else if (wkt.search(this.multiGeometryRegExp) == 0) {
|
|
1166
|
+
geometry = this.wktToMultiGeometry(wkt);
|
|
1167
|
+
} else if (wkt.search(this.pointRegExp) == 0) {
|
|
1168
|
+
geometry = this.wktToPoint(wkt);
|
|
1169
|
+
} else if (wkt.search(this.lineStringRegExp) == 0) {
|
|
1170
|
+
geometry = this.wktToLineString(wkt);
|
|
1171
|
+
} else if (wkt.search(this.polygonRegExp) == 0) {
|
|
1172
|
+
geometry = this.wktToPolygon(wkt);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
if ((geometry != null) && (sridString != null) && (sridString != "") && (sridString != "900913")) {
|
|
1176
|
+
geometry.srid = parseInt(sridString);
|
|
1177
|
+
geometry = GeometryTools.transform(geometry, 900913);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
return geometry;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
WKTConverter.prototype.wktToGeometryCollection = function(wkt) {
|
|
1184
|
+
var geometries = [];
|
|
1185
|
+
wkt = wkt.match(this.geometryCollectionRegExp)[1];
|
|
1186
|
+
for (var i = 0; i < wkt.length;) {
|
|
1187
|
+
wkt = wkt.substring(i).replace(/^,\s?/, "");
|
|
1188
|
+
var closingBrackets = wkt.match(/^(POINT|LINESTRING|POLYGON)(\(\(?)/)[2].replace(/\(/g, ")");
|
|
1189
|
+
i = wkt.indexOf(closingBrackets) + closingBrackets.length;
|
|
1190
|
+
geometries.push(this.wktToGeometry(wkt.substring(0, i)));
|
|
1191
|
+
}
|
|
1192
|
+
return new GeometryCollection(geometries);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
WKTConverter.prototype.wktToMultiGeometry = function(wkt) {
|
|
1196
|
+
var geometries = [];
|
|
1197
|
+
var match = wkt.match(this.multiGeometryRegExp);
|
|
1198
|
+
var geometryType = match[1];
|
|
1199
|
+
wkt = match[2];
|
|
1200
|
+
var closingBrackets = wkt.match(/^\(\(?/)[0].replace(/\(/g, ")");
|
|
1201
|
+
for (var i = 0; i < wkt.length;) {
|
|
1202
|
+
wkt = wkt.substring(i).replace(/^,\s?/, "");
|
|
1203
|
+
i = wkt.indexOf(closingBrackets) + closingBrackets.length;
|
|
1204
|
+
geometries.push(this.wktToGeometry(geometryType + wkt.substring(0, i)));
|
|
1205
|
+
}
|
|
1206
|
+
return new GeometryCollection(geometries);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
WKTConverter.prototype.wktToPoint = function(wkt) {
|
|
1210
|
+
wkt = wkt.match(this.pointRegExp)[1];
|
|
1211
|
+
var coordStrings = wkt.split(" ");
|
|
1212
|
+
return new Point(parseFloat(coordStrings[0]), parseFloat(coordStrings[1]));
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
WKTConverter.prototype.wktToLineString = function(wkt) {
|
|
1216
|
+
var points = [];
|
|
1217
|
+
wkt = wkt.match(this.lineStringRegExp)[1];
|
|
1218
|
+
var pointStrings = wkt.split(/,\s?/);
|
|
1219
|
+
for (var i = 0; i < pointStrings.length; i++) {
|
|
1220
|
+
var coordStrings = pointStrings[i].split(" ");
|
|
1221
|
+
points.push(new Point(parseFloat(coordStrings[0]), parseFloat(coordStrings[1])));
|
|
1222
|
+
}
|
|
1223
|
+
return new LineString(points);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
WKTConverter.prototype.wktToPolygon = function(wkt) {
|
|
1227
|
+
var lineStrings = [];
|
|
1228
|
+
wkt = wkt.match(this.polygonRegExp)[1];
|
|
1229
|
+
var closingBrackets = ")";
|
|
1230
|
+
for (var i = 0; i < wkt.length;) {
|
|
1231
|
+
wkt = wkt.substring(i).replace(/^,\s?/, "");
|
|
1232
|
+
i = wkt.indexOf(closingBrackets) + 1;
|
|
1233
|
+
lineStrings.push(this.wktToLineString("LINESTRING" + wkt.substring(0, i)));
|
|
1234
|
+
}
|
|
1235
|
+
return new Polygon(lineStrings);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
WKTConverter.prototype.geometryToWKT = function(geometry) {
|
|
1239
|
+
if (geometry instanceof GeometryCollection) {
|
|
1240
|
+
return this.geometryCollectionToWKT(geometry);
|
|
1241
|
+
} else if (geometry instanceof Point) {
|
|
1242
|
+
return this.pointToWKT(geometry);
|
|
1243
|
+
} else if (geometry instanceof LineString) {
|
|
1244
|
+
return this.lineStringToWKT(geometry);
|
|
1245
|
+
} else if (geometry instanceof Polygon) {
|
|
1246
|
+
return this.polygonToWKT(geometry);
|
|
1247
|
+
}
|
|
1248
|
+
return null;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
WKTConverter.prototype.geometryCollectionToWKT = function(geometryCollection) {
|
|
1252
|
+
var wkt = "GEOMETRYCOLLECTION(";
|
|
1253
|
+
for (var i = 0; i < geometryCollection.childGeometries.length; i++) {
|
|
1254
|
+
wkt += this.geometryToWKT(geometryCollection.childGeometries[i]);
|
|
1255
|
+
if (i < geometryCollection.childGeometries.length - 1) {
|
|
1256
|
+
wkt += ",";
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return wkt + ")";
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
WKTConverter.prototype.pointToWKT = function(point) {
|
|
1263
|
+
return "POINT(" + point.x + " " + point.y + ")";
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
WKTConverter.prototype.lineStringToWKT = function(lineString) {
|
|
1267
|
+
return "LINESTRING" + this.childCoordsToWKT(lineString);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
WKTConverter.prototype.polygonToWKT = function(polygon) {
|
|
1271
|
+
return "POLYGON" + this.childCoordsToWKT(polygon);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
WKTConverter.prototype.childCoordsToWKT = function(geometry) {
|
|
1275
|
+
var wkt = "(";
|
|
1276
|
+
for (var i = 0; i < geometry.childGeometries.length; i++) {
|
|
1277
|
+
var child = geometry.childGeometries[i];
|
|
1278
|
+
if (child instanceof Point) {
|
|
1279
|
+
wkt += child.x + " " + child.y;
|
|
1280
|
+
} else if (child.childGeometries.length > 0) {
|
|
1281
|
+
wkt += this.childCoordsToWKT(child);
|
|
1282
|
+
}
|
|
1283
|
+
if (i < geometry.childGeometries.length - 1) {
|
|
1284
|
+
wkt += ",";
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
return wkt + ")";
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
WKTConverter.prototype.wktToCoordPath = function(wkt) {
|
|
1291
|
+
return wkt.replace(/[^\d]+$/, "").replace(/^[^\d]+([\d.\s]+),\s*/g, "M $1 L ").replace(/\)+,\s*\(+([\d.\s]+),\s*/g, " M $1 L ");
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1297
|
+
/* Merging js: geometrymodel/converters/SVGConverter.js begins */
|
|
1298
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
export function SVGConverter() { }
|
|
1302
|
+
|
|
1303
|
+
SVGConverter.prototype.pathToGeometry = function(path) {
|
|
1304
|
+
var points = [];
|
|
1305
|
+
var pointStrings = path.replace(/^M *| +Z.*$/g, "").split(/ +[KL] */); // Converts the first linestring only, because it is hard to determine whether subsequent linestrings are interior or exterior.
|
|
1306
|
+
for (var i = 0; i < pointStrings.length; i++) {
|
|
1307
|
+
var coordStrings = pointStrings[i].split(" ");
|
|
1308
|
+
points.push(new Point(parseFloat(coordStrings[0]), parseFloat(coordStrings[1])));
|
|
1309
|
+
}
|
|
1310
|
+
if (points.length == 1) {
|
|
1311
|
+
return points[0];
|
|
1312
|
+
}
|
|
1313
|
+
if (!points[0].equals(points[points.length - 1])) {
|
|
1314
|
+
return new LineString(points);
|
|
1315
|
+
}
|
|
1316
|
+
return new Polygon([new LineString(points)]);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
SVGConverter.prototype.geometryToPixPath = function(bounds, centerScale, geometry) {
|
|
1320
|
+
var path = "";
|
|
1321
|
+
var lineStrings = geometry.getLineStrings();
|
|
1322
|
+
for (var i = 0; i < lineStrings.length; i++) {
|
|
1323
|
+
path += "M ";
|
|
1324
|
+
var points = lineStrings[i].getPoints();
|
|
1325
|
+
for (var j = 0; j < points.length; j++) {
|
|
1326
|
+
if (j == 1) {
|
|
1327
|
+
path += "L ";
|
|
1328
|
+
}
|
|
1329
|
+
var x = centerScale.getPixX(bounds.width, points[j].x);
|
|
1330
|
+
var y = centerScale.getPixY(bounds.height, points[j].y);
|
|
1331
|
+
path += x + " " + y + " ";
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
return path;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
SVGConverter.prototype.geometryToWorldPath = function(geometry) {
|
|
1338
|
+
var path = "";
|
|
1339
|
+
var lineStrings = geometry.getLineStrings();
|
|
1340
|
+
for (var i = 0; i < lineStrings.length; i++) {
|
|
1341
|
+
path += "M ";
|
|
1342
|
+
var points = lineStrings[i].getPoints();
|
|
1343
|
+
for (var j = 0; j < points.length; j++) {
|
|
1344
|
+
if (j == 1) {
|
|
1345
|
+
path += "L ";
|
|
1346
|
+
}
|
|
1347
|
+
path += points[j].x + " " + points[j].y + " ";
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
return path;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1356
|
+
/* Merging js: geometrymodel/converters/CSSConverter.js begins */
|
|
1357
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
export function CSSConverter() { }
|
|
1361
|
+
|
|
1362
|
+
CSSConverter.prototype.pointToPixCSS = function(bounds, centerScale, point, css) {
|
|
1363
|
+
var pixCSS = {
|
|
1364
|
+
left: Math.round(centerScale.getPixX(bounds.width, point.x)) + "px",
|
|
1365
|
+
top: Math.round(centerScale.getPixY(bounds.height, point.y)) + "px"
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
if (css == null) {
|
|
1369
|
+
return pixCSS;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
var propertyNames = ["fontSize", "fontFamily", "fontWeight", "color", "textShadow"];
|
|
1373
|
+
for (var i = 0; i < propertyNames.length; i++) {
|
|
1374
|
+
var propertyName = propertyNames[i];
|
|
1375
|
+
if (css[propertyName] != null) {
|
|
1376
|
+
pixCSS[propertyName] = css[propertyName];
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
return pixCSS;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
CSSConverter.prototype.pointToWorldCSS = function(point, css) {
|
|
1384
|
+
var worldCSS = {
|
|
1385
|
+
left: Math.round(point.x) + "px",
|
|
1386
|
+
top: Math.round(point.y) + "px"
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1389
|
+
if (css == null) {
|
|
1390
|
+
return worldCSS;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
var propertyNames = ["fontSize", "fontFamily", "fontWeight", "color", "textShadow"];
|
|
1394
|
+
for (var i = 0; i < propertyNames.length; i++) {
|
|
1395
|
+
var propertyName = propertyNames[i];
|
|
1396
|
+
if (css[propertyName] != null) {
|
|
1397
|
+
worldCSS[propertyName] = css[propertyName];
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
return worldCSS;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1407
|
+
/* Merging js: geometrymodel/converters/JSONConverter.js begins */
|
|
1408
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
export function JsonConverter() { }
|
|
1412
|
+
|
|
1413
|
+
JsonConverter.prototype.geometryToJson = function(geometry, stringify) {
|
|
1414
|
+
var getType = function(geometry) {
|
|
1415
|
+
if (geometry instanceof GeometryCollection) {
|
|
1416
|
+
return "GeometryCollection";
|
|
1417
|
+
}
|
|
1418
|
+
if (geometry instanceof Point) {
|
|
1419
|
+
return "Point";
|
|
1420
|
+
}
|
|
1421
|
+
if (geometry instanceof LineString) {
|
|
1422
|
+
return "LineString";
|
|
1423
|
+
}
|
|
1424
|
+
if (geometry instanceof Polygon) {
|
|
1425
|
+
return "Polygon";
|
|
1426
|
+
}
|
|
1427
|
+
if (geometry instanceof Envelope) {
|
|
1428
|
+
return "Envelope";
|
|
1429
|
+
}
|
|
1430
|
+
return "Geometry";
|
|
1431
|
+
};
|
|
1432
|
+
var getCoordinates = function(geometry) {
|
|
1433
|
+
if (geometry instanceof Point) {
|
|
1434
|
+
return [geometry.x, geometry.y];
|
|
1435
|
+
}
|
|
1436
|
+
var coordinates = [];
|
|
1437
|
+
for (var i = 0; i < geometry.childGeometries.length; i++) {
|
|
1438
|
+
coordinates.push(getCoordinates(geometry.childGeometries[i]));
|
|
1439
|
+
}
|
|
1440
|
+
return coordinates;
|
|
1441
|
+
};
|
|
1442
|
+
var json = {
|
|
1443
|
+
type: getType(geometry),
|
|
1444
|
+
coordinates: getCoordinates(geometry)
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
if (stringify) {
|
|
1448
|
+
return JSON.stringify(json);
|
|
1449
|
+
}
|
|
1450
|
+
return json;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1456
|
+
/* Merging js: featuremodel/Feature.js begins */
|
|
1457
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
export function Feature(featureType, propertyValues) {
|
|
1461
|
+
this.featureType = featureType;
|
|
1462
|
+
this.propertyValues = propertyValues;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1468
|
+
/* Merging js: featuremodel/FeatureModel.js begins */
|
|
1469
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
export function FeatureModel(features, type) {
|
|
1473
|
+
this.features = features;
|
|
1474
|
+
this.featureType = type;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1479
|
+
/* Merging js: featuremodel/FeatureType.js begins */
|
|
1480
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
export function FeatureType(name, properties) {
|
|
1484
|
+
this.name = name;
|
|
1485
|
+
this.properties = properties;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1490
|
+
/* Merging js: featuremodel/Property.js begins */
|
|
1491
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
export function Property(name, type) {
|
|
1495
|
+
this.name = name;
|
|
1496
|
+
this.type = type;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1501
|
+
/* Merging js: featuremodel/PropertyType.js begins */
|
|
1502
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
export function PropertyType() { }
|
|
1506
|
+
|
|
1507
|
+
PropertyType.prototype.BOOLEAN = "boolean";
|
|
1508
|
+
PropertyType.prototype.DOUBLE = "double";
|
|
1509
|
+
PropertyType.prototype.INTEGER = "integer";
|
|
1510
|
+
PropertyType.prototype.STRING = "string";
|
|
1511
|
+
PropertyType.prototype.GEOMETRY = "geometry";
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1515
|
+
/* Merging js: featuremodel/commands/EmptyFeatureCommand.js begins */
|
|
1516
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
export function EmptyFeatureCommand() { }
|
|
1520
|
+
|
|
1521
|
+
EmptyFeatureCommand.prototype.perform = function() { }
|
|
1522
|
+
|
|
1523
|
+
export var defaultFeatureCommands = [new EmptyFeatureCommand(), new EmptyFeatureCommand(), new EmptyFeatureCommand()];
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1528
|
+
/* Merging js: featuremodel/commands/SelectFeatureCommand.js begins */
|
|
1529
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
export function SelectFeatureCommand(selectionModel, index) {
|
|
1533
|
+
this.selectionModel = selectionModel;
|
|
1534
|
+
this.index = index;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
SelectFeatureCommand.prototype.perform = function(feature) {
|
|
1538
|
+
if (this.selectionModel == null) {
|
|
1539
|
+
throw new Error("No selection model present.");
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
if (feature == null) {
|
|
1543
|
+
this.selectionModel.selectedFeatures[this.index] = null;
|
|
1544
|
+
} else if (this.selectionModel.selectedFeatures[this.index] == null) {
|
|
1545
|
+
this.selectionModel.selectedFeatures[this.index] = feature;
|
|
1546
|
+
} else if (this.selectionModel.selectedFeatures[this.index] != feature) {
|
|
1547
|
+
this.selectionModel.selectedFeatures[this.index] = feature;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1554
|
+
/* Merging js: featuremodel/commands/AggressiveSelectFeatureCommand.js begins */
|
|
1555
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
export function AggressiveSelectFeatureCommand(selectionModel, index) {
|
|
1559
|
+
this.selectionModel = selectionModel;
|
|
1560
|
+
this.index = index;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
AggressiveSelectFeatureCommand.prototype.perform = function(feature) {
|
|
1564
|
+
if (this.selectionModel == null) {
|
|
1565
|
+
throw new Error("No selection model present.");
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
if (feature == null) {
|
|
1569
|
+
this.selectionModel.selectedFeatures[this.index] = null;
|
|
1570
|
+
} else {
|
|
1571
|
+
this.selectionModel.selectedFeatures[this.index] = angular.copy(feature);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1578
|
+
/* Merging js: featuremodel/commands/ToggleSelectFeatureCommand.js begins */
|
|
1579
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
export function ToggleSelectFeatureCommand(selectionModel, index) {
|
|
1583
|
+
this.selectionModel = selectionModel;
|
|
1584
|
+
this.index = index;
|
|
1585
|
+
this.idPropertyName = null;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
ToggleSelectFeatureCommand.prototype.perform = function(feature) {
|
|
1589
|
+
if (this.selectionModel == null) {
|
|
1590
|
+
throw new Error("No selection model present.");
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
if (feature == null) {
|
|
1594
|
+
this.selectionModel.selectedFeatures[this.index] = null;
|
|
1595
|
+
} else if (this.selectionModel.selectedFeatures[this.index] == null) {
|
|
1596
|
+
this.selectionModel.selectedFeatures[this.index] = feature;
|
|
1597
|
+
} else if ((this.idPropertyName == null) && (this.selectionModel.selectedFeatures[this.index] != feature)) {
|
|
1598
|
+
this.selectionModel.selectedFeatures[this.index] = feature;
|
|
1599
|
+
} else if ((this.idPropertyName != null) && (this.selectionModel.selectedFeatures[this.index][this.idPropertyName] != feature[this.idPropertyName])) {
|
|
1600
|
+
this.selectionModel.selectedFeatures[this.index] = feature;
|
|
1601
|
+
} else {
|
|
1602
|
+
this.selectionModel.selectedFeatures[this.index] = null;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1609
|
+
/* Merging js: featuremodel/commands/ToURLFeatureCommand.js begins */
|
|
1610
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1611
|
+
|
|
1612
|
+
|
|
1613
|
+
export function ToURLFeatureCommand() { }
|
|
1614
|
+
|
|
1615
|
+
ToURLFeatureCommand.prototype.perform = function(feature) {
|
|
1616
|
+
if (feature == null) {
|
|
1617
|
+
throw new Error("No feature given.");
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
var urlString = this.getURL(feature.propertyValues);
|
|
1621
|
+
if (urlString != null) {
|
|
1622
|
+
window.open(this.getURL(feature.propertyValues));
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
ToURLFeatureCommand.prototype.getURL = function(propertyValues) {
|
|
1627
|
+
if (propertyValues == null) {
|
|
1628
|
+
return null;
|
|
1629
|
+
}
|
|
1630
|
+
for (var i = 0; i < propertyValues.length; i++) {
|
|
1631
|
+
if (this.isURL(propertyValues[i])) {
|
|
1632
|
+
return propertyValues[i];
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
return null;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
ToURLFeatureCommand.prototype.isURL = function(str) {
|
|
1639
|
+
var regexp = new RegExp("^s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+$");
|
|
1640
|
+
return regexp.test(str);
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
|
|
1644
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1645
|
+
/* Merging js: featuremodel/converters/CSVConverter.js begins */
|
|
1646
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
export function CSVConverter() { }
|
|
1650
|
+
|
|
1651
|
+
CSVConverter.prototype.csvToFeatures = function(csv, simple, fieldSeparator, textDelimiter, featureType) {
|
|
1652
|
+
var features = [];
|
|
1653
|
+
var lines = this.csvToLines(csv, simple, fieldSeparator, textDelimiter);
|
|
1654
|
+
var feature = null;
|
|
1655
|
+
var errorLines = [];
|
|
1656
|
+
for (var i = 0; i < lines.length; i++) {
|
|
1657
|
+
try {
|
|
1658
|
+
feature = this.lineToFeature(lines[i], featureType);
|
|
1659
|
+
features.push(feature);
|
|
1660
|
+
} catch (e) {
|
|
1661
|
+
errorLines.push(i);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
if (errorLines.length > 0) {
|
|
1666
|
+
throw new Error("Could not convert " + errorLines.length + " out of " + lines.length + " csv lines to features. Error lines: " + errorLines);
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
return features;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
CSVConverter.prototype.csvToLines = function(csv, simple, fieldSeparator, textDelimiter) {
|
|
1673
|
+
csv = csv.replace(new RegExp("^\\s+"), "").replace(new RegExp("\\s+$"), "");
|
|
1674
|
+
if (simple) {
|
|
1675
|
+
lines = csv.split("\n");
|
|
1676
|
+
for (var h = 0; h < lines.length; h++) {
|
|
1677
|
+
lines[h] = lines[h].split(fieldSeparator);
|
|
1678
|
+
}
|
|
1679
|
+
} else {
|
|
1680
|
+
var endOfFile = false;
|
|
1681
|
+
var endOfLine = false;
|
|
1682
|
+
var i = -1;
|
|
1683
|
+
var j = -1;
|
|
1684
|
+
var fields = [];
|
|
1685
|
+
var lines = [];
|
|
1686
|
+
while (!endOfFile) {
|
|
1687
|
+
endOfLine = false;
|
|
1688
|
+
while (!endOfLine) {
|
|
1689
|
+
if (csv.indexOf(textDelimiter) == 0) {
|
|
1690
|
+
csv = csv.substring(textDelimiter.length);
|
|
1691
|
+
i = csv.search(new RegExp(textDelimiter + "($|\n|" + fieldSeparator + ")"));
|
|
1692
|
+
j = i + textDelimiter.length;
|
|
1693
|
+
} else {
|
|
1694
|
+
i = csv.search(new RegExp("($|\n|" + fieldSeparator + ")"));
|
|
1695
|
+
j = i;
|
|
1696
|
+
}
|
|
1697
|
+
fields.push(csv.substring(0, i));
|
|
1698
|
+
csv = csv.substring(j);
|
|
1699
|
+
if (csv.indexOf(fieldSeparator) == 0) {
|
|
1700
|
+
csv = csv.substring(fieldSeparator.length);
|
|
1701
|
+
} else if (csv.indexOf("\n") == 0) {
|
|
1702
|
+
csv = csv.substring(1);
|
|
1703
|
+
lines.push(fields);
|
|
1704
|
+
fields = [];
|
|
1705
|
+
endOfLine = true;
|
|
1706
|
+
} else if (csv.length == 0) {
|
|
1707
|
+
lines.push(fields);
|
|
1708
|
+
endOfFile = true;
|
|
1709
|
+
endOfLine = true;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
return lines;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
CSVConverter.prototype.lineToFeature = function(fields, featureType) {
|
|
1719
|
+
var properties = featureType.properties;
|
|
1720
|
+
if (fields.length != properties.length) {
|
|
1721
|
+
throw new Error("Number of fields of " + fields.length + " in the csv does not match the number of properties of " + properties.length + " in the featuretype.");
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
var propertyValues = [];
|
|
1725
|
+
var wktConverter = new WKTConverter();
|
|
1726
|
+
for (var i = 0; i < properties.length; i++) {
|
|
1727
|
+
if (fields[i] == "") {
|
|
1728
|
+
propertyValues.push(null);
|
|
1729
|
+
} else if (properties[i].type == PropertyType.prototype.GEOMETRY) {
|
|
1730
|
+
propertyValues.push(wktConverter.wktToGeometry(fields[i]));
|
|
1731
|
+
} else {
|
|
1732
|
+
propertyValues.push(fields[i]);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
return new Feature(featureType, propertyValues);
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1741
|
+
/* Merging js: filtermodel/FilterModel.js begins */
|
|
1742
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1743
|
+
|
|
1744
|
+
|
|
1745
|
+
export function FilterModel() {
|
|
1746
|
+
this.filters = [];
|
|
1747
|
+
this.filter = null;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
FilterModel.EQUALS = 0;
|
|
1751
|
+
FilterModel.LESS_OR_EQUALS = 1;
|
|
1752
|
+
FilterModel.GREATER_OR_EQUALS = 2;
|
|
1753
|
+
FilterModel.IN = 3;
|
|
1754
|
+
|
|
1755
|
+
|
|
1756
|
+
|
|
1757
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1758
|
+
/* Merging js: filtermodel/Filter.js begins */
|
|
1759
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
export function Filter(propertyIndexOrName, value, operator) {
|
|
1763
|
+
this.propertyIndex = (typeof propertyIndexOrName == "number"? propertyIndexOrName: null);
|
|
1764
|
+
this.propertyName = (typeof propertyIndexOrName == "string"? propertyIndexOrName: null);
|
|
1765
|
+
this.value = (!Array.isArray(value) && (parseFloat(value) == value))? parseFloat(value): value;
|
|
1766
|
+
this.operator = (operator && (operator.toUpperCase() == "IN"))? FilterModel.IN: (operator == "<=")? FilterModel.LESS_OR_EQUALS: (operator == ">=")? FilterModel.GREATER_OR_EQUALS: FilterModel.EQUALS;
|
|
1767
|
+
this.title = null;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1773
|
+
/* Merging js: filtermodel/converters/URLFilterConverter.js begins */
|
|
1774
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
export function URLFilterConverter() { }
|
|
1778
|
+
|
|
1779
|
+
URLFilterConverter.prototype.filterModelsToURLFilter = function(filterModels) {
|
|
1780
|
+
var urlFilters = [];
|
|
1781
|
+
for (var i = 0; i < filterModels.length; i++) {
|
|
1782
|
+
if (filterModels[i].filter != null) {
|
|
1783
|
+
urlFilters.push(this.filterToURLFilter(filterModels[i].filter));
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
return urlFilters.join(":::");
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
URLFilterConverter.prototype.filterToURLFilter = function(filter) {
|
|
1791
|
+
return filter.propertyName + "::EQ::" + filter.value;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1797
|
+
/* Merging js: focusmodel/CenterScale.js begins */
|
|
1798
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1799
|
+
|
|
1800
|
+
|
|
1801
|
+
export function CenterScale(centerX, centerY, scale, yFactor) {
|
|
1802
|
+
this.coordPixFactor = 0.000352778;
|
|
1803
|
+
|
|
1804
|
+
this.centerX = centerX;
|
|
1805
|
+
this.centerY = centerY;
|
|
1806
|
+
this.scale = scale;
|
|
1807
|
+
|
|
1808
|
+
this.yFactor = (yFactor == null)? -1: yFactor;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
CenterScale.prototype.equals = function(centerScale) {
|
|
1812
|
+
if (centerScale == null) {
|
|
1813
|
+
return false;
|
|
1814
|
+
}
|
|
1815
|
+
if ((this.centerX == centerScale.centerX) && (this.centerY == centerScale.centerY) &&
|
|
1816
|
+
(this.scale == centerScale.scale)
|
|
1817
|
+
) {
|
|
1818
|
+
return true;
|
|
1819
|
+
}
|
|
1820
|
+
return false;
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
CenterScale.prototype.clone = function() {
|
|
1824
|
+
return new CenterScale(this.centerX, this.centerY, this.scale, this.yFactor);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
CenterScale.prototype.subtract = function(centerScale) {
|
|
1828
|
+
return new CenterScale(this.centerX - centerScale.centerX, this.centerY - centerScale.centerY, this.scale - centerScale.scale);
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
CenterScale.prototype.toEnvelope = function(width, height) {
|
|
1832
|
+
var numHorzCoords = width * this.coordPixFactor * this.scale;
|
|
1833
|
+
var numVertCoords = height * this.coordPixFactor * this.scale;
|
|
1834
|
+
var minX = this.centerX - numHorzCoords / 2;
|
|
1835
|
+
var minY = this.centerY - numVertCoords / 2;
|
|
1836
|
+
var maxX = minX + numHorzCoords;
|
|
1837
|
+
var maxY = minY + numVertCoords;
|
|
1838
|
+
return new Envelope(minX, minY, maxX, maxY);
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
CenterScale.prototype.toOffset = function(pixXOffset, pixYOffset) {
|
|
1842
|
+
var a = this.coordPixFactor * this.scale;
|
|
1843
|
+
return new CenterScale(this.centerX + pixXOffset * a, this.centerY + pixYOffset * a * this.yFactor, this.scale);
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
CenterScale.prototype.fromOffset = function(pixXOffset, pixYOffset) {
|
|
1847
|
+
var a = this.coordPixFactor * this.scale;
|
|
1848
|
+
return new CenterScale(this.centerX - pixXOffset * a, this.centerY - pixYOffset * a * this.yFactor, this.scale);
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
CenterScale.prototype.getNumWorldCoords = function(numPixs) {
|
|
1852
|
+
return numPixs * this.coordPixFactor * this.scale;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
CenterScale.prototype.getWorldX = function(width, pixX) {
|
|
1856
|
+
pixX = pixX - (width / 2);
|
|
1857
|
+
var worldX = this.centerX + pixX * this.coordPixFactor * this.scale;
|
|
1858
|
+
return worldX;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
CenterScale.prototype.getWorldY = function(height, pixY) {
|
|
1862
|
+
pixY = pixY - (height / 2);
|
|
1863
|
+
var worldY = this.centerY + pixY * this.coordPixFactor * this.scale * this.yFactor;
|
|
1864
|
+
return worldY;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
CenterScale.prototype.getNumPixs = function(numWorldCoords) {
|
|
1868
|
+
return numWorldCoords / this.coordPixFactor / this.scale;
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
CenterScale.prototype.getPixX = function(width, worldX) {
|
|
1872
|
+
var pixX = (worldX - this.centerX) / (this.coordPixFactor * this.scale);
|
|
1873
|
+
pixX = pixX + (width / 2);
|
|
1874
|
+
return pixX;
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
CenterScale.prototype.getPixY = function(height, worldY) {
|
|
1878
|
+
var pixY = (worldY - this.centerY) / (this.coordPixFactor * this.scale) * this.yFactor;
|
|
1879
|
+
pixY = pixY + (height / 2);
|
|
1880
|
+
return pixY;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
CenterScale.prototype.toString = function() {
|
|
1884
|
+
return "CenterScale(" + this.centerX + ", " + this.centerY + ", " + this.scale + ")";
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1890
|
+
/* Merging js: focusmodel/FocusModel.js begins */
|
|
1891
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
export function FocusModel() {
|
|
1895
|
+
this.animationTimer = new AnimationTimer(1000);
|
|
1896
|
+
this.incubationTimer = new Timer(1000, 1);
|
|
1897
|
+
this.srs = new SRS();
|
|
1898
|
+
this.maxEnvelope = new Envelope(this.srs.minX, this.srs.minY, this.srs.maxX, this.srs.maxY);
|
|
1899
|
+
this.minScale = 846.37503189876580;
|
|
1900
|
+
this.maxScale = 443744272.72414012;
|
|
1901
|
+
this.scaleToZoomLevels = false;
|
|
1902
|
+
this.centerScale = null;
|
|
1903
|
+
this.animation = null;
|
|
1904
|
+
this.animationCenterScale = null;
|
|
1905
|
+
this.incubationCenterScale = null;
|
|
1906
|
+
|
|
1907
|
+
var focusModel = this;
|
|
1908
|
+
this.animationTimer.timerHandler = function() {
|
|
1909
|
+
var progress = focusModel.animationTimer.currentCount / focusModel.animationTimer.duration;
|
|
1910
|
+
|
|
1911
|
+
if (progress < 1) {
|
|
1912
|
+
var base = focusModel.animation.base;
|
|
1913
|
+
var delta = focusModel.animation.target.subtract(base);
|
|
1914
|
+
|
|
1915
|
+
focusModel.animationCenterScale = new CenterScale(
|
|
1916
|
+
base.centerX + (-delta.centerX * progress * progress + 2 * delta.centerX * progress),
|
|
1917
|
+
base.centerY + (-delta.centerY * progress * progress + 2 * delta.centerY * progress),
|
|
1918
|
+
base.scale + (-delta.scale * progress * progress + 2 * delta.scale * progress)
|
|
1919
|
+
).fromOffset(focusModel.animation.pixXOffset, focusModel.animation.pixYOffset);
|
|
1920
|
+
} else {
|
|
1921
|
+
focusModel.animationCenterScale = focusModel.centerScale;
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
this.incubationTimer.timerHandler = function() {
|
|
1925
|
+
focusModel.incubationCenterScale = focusModel.centerScale;
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
FocusModel.ALWAYS_LOWER = 0;
|
|
1930
|
+
FocusModel.ALWAYS_NEAREST = 1;
|
|
1931
|
+
FocusModel.ALWAYS_UPPER = 2;
|
|
1932
|
+
FocusModel.IF_REQUIRED_LOWER = 3;
|
|
1933
|
+
FocusModel.IF_REQUIRED_NEAREST = 4;
|
|
1934
|
+
FocusModel.IF_REQUIRED_UPPER = 5;
|
|
1935
|
+
FocusModel.IF_REQUIRED = 6;
|
|
1936
|
+
FocusModel.NEVER = 7;
|
|
1937
|
+
|
|
1938
|
+
// Click or touch while zooming/panning.
|
|
1939
|
+
FocusModel.prototype.grab = function(x, y, pixXOffset, pixYOffset) {
|
|
1940
|
+
var grabbedAnimation = false;
|
|
1941
|
+
|
|
1942
|
+
if (this.animationTimer.isRunning()) {
|
|
1943
|
+
// if (this.animationCenterScale.scale == this.centerScale.scale) {
|
|
1944
|
+
this.animationTimer.reset();
|
|
1945
|
+
this.centerScale = this.animationCenterScale;
|
|
1946
|
+
// } else {
|
|
1947
|
+
// this.centerScale = this.centercon(new CenterScale(x, y, this.centerScale.scale).fromOffset(pixXOffset, pixYOffset));
|
|
1948
|
+
// this.animation = {
|
|
1949
|
+
// base: new CenterScale(x, y, this.animation.base.scale),
|
|
1950
|
+
// target: this.centerScale.toOffset(pixXOffset, pixYOffset),
|
|
1951
|
+
// pixXOffset: pixXOffset,
|
|
1952
|
+
// pixYOffset: pixYOffset
|
|
1953
|
+
// };
|
|
1954
|
+
// }
|
|
1955
|
+
this.setIncubationCenterScale();
|
|
1956
|
+
|
|
1957
|
+
grabbedAnimation = true;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
if (!this.animationTimer.isRunning()) {
|
|
1961
|
+
this.animation = {
|
|
1962
|
+
base: new CenterScale(x, y, this.centerScale.scale),
|
|
1963
|
+
target: this.centerScale.toOffset(pixXOffset, pixYOffset),
|
|
1964
|
+
pixXOffset: pixXOffset,
|
|
1965
|
+
pixYOffset: pixYOffset
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
return grabbedAnimation;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
// Pan with mouse move or one-finger touch.
|
|
1973
|
+
FocusModel.prototype.pan = function(pixXOffset, pixYOffset) {
|
|
1974
|
+
this.animation.pixXOffset = pixXOffset;
|
|
1975
|
+
this.animation.pixYOffset = pixYOffset;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
// Pan/zoom with multi-finger touch.
|
|
1979
|
+
FocusModel.prototype.pinchPan = function(centerScale, pixXOffset, pixYOffset) {
|
|
1980
|
+
centerScale = this.scalecon(centerScale, FocusModel.NEVER);
|
|
1981
|
+
if (this.animationTimer.isRunning()) {
|
|
1982
|
+
this.animationTimer.reset();
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
this.animation = {
|
|
1986
|
+
base: centerScale,
|
|
1987
|
+
target: centerScale,
|
|
1988
|
+
pixXOffset: pixXOffset,
|
|
1989
|
+
pixYOffset: pixYOffset
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
FocusModel.prototype.panimate = function() {
|
|
1994
|
+
if (!this.animationTimer.isRunning()) {
|
|
1995
|
+
var centerScale = this.centercon(this.animation.target.fromOffset(this.animation.pixXOffset, this.animation.pixYOffset));
|
|
1996
|
+
if (!this.centerScale.equals(centerScale)) {
|
|
1997
|
+
this.centerScale = this.animationCenterScale = centerScale;
|
|
1998
|
+
this.setIncubationCenterScale();
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
// Zoom with mouse wheel.
|
|
2004
|
+
FocusModel.prototype.zoom = function(centerScale, pixXOffset, pixYOffset) {
|
|
2005
|
+
centerScale = this.scalecon(centerScale, FocusModel.IF_REQUIRED);
|
|
2006
|
+
if (this.animationCenterScale.scale == centerScale.scale) {
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
this.centerScale = this.centercon(centerScale.fromOffset(pixXOffset, pixYOffset));
|
|
2011
|
+
this.animation = {
|
|
2012
|
+
base: new CenterScale(centerScale.centerX, centerScale.centerY, this.animationCenterScale.scale),
|
|
2013
|
+
target: this.centerScale.toOffset(pixXOffset, pixYOffset),
|
|
2014
|
+
pixXOffset: pixXOffset,
|
|
2015
|
+
pixYOffset: pixYOffset
|
|
2016
|
+
};
|
|
2017
|
+
this.setAnimationCenterScale();
|
|
2018
|
+
this.setIncubationCenterScale();
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
FocusModel.prototype.setCenterScale = function(centerScale, zoomLevelPolicy) {
|
|
2022
|
+
if (centerScale == null) {
|
|
2023
|
+
return;
|
|
2024
|
+
}
|
|
2025
|
+
if (zoomLevelPolicy == null) {
|
|
2026
|
+
zoomLevelPolicy = FocusModel.IF_REQUIRED;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
centerScale = this.centercon(this.scalecon(centerScale, zoomLevelPolicy));
|
|
2030
|
+
if (this.centerScale == null) {
|
|
2031
|
+
this.centerScale = centerScale;
|
|
2032
|
+
this.animation = {base: centerScale, target: centerScale, pixXOffset: 0, pixYOffset: 0};
|
|
2033
|
+
this.animationCenterScale = centerScale;
|
|
2034
|
+
this.incubationCenterScale = centerScale;
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
if (this.centerScale.equals(centerScale)) {
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
this.centerScale = centerScale;
|
|
2042
|
+
this.animation = {base: this.animationCenterScale, target: centerScale, pixXOffset: 0, pixYOffset: 0};
|
|
2043
|
+
this.setAnimationCenterScale();
|
|
2044
|
+
this.setIncubationCenterScale();
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
FocusModel.prototype.setAnimationCenterScale = function() {
|
|
2048
|
+
this.animationTimer.reset();
|
|
2049
|
+
this.animationTimer.start();
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
FocusModel.prototype.setIncubationCenterScale = function() {
|
|
2053
|
+
this.incubationTimer.reset();
|
|
2054
|
+
this.incubationTimer.start();
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
// Center-related conditions. Relevant for zooming and panning.
|
|
2058
|
+
FocusModel.prototype.centercon = function(centerScale) {
|
|
2059
|
+
if (
|
|
2060
|
+
(centerScale.centerX < this.maxEnvelope.minX) ||
|
|
2061
|
+
(centerScale.centerY < this.maxEnvelope.minY) ||
|
|
2062
|
+
(centerScale.centerX > this.maxEnvelope.maxX) ||
|
|
2063
|
+
(centerScale.centerY > this.maxEnvelope.maxY)
|
|
2064
|
+
) {
|
|
2065
|
+
var centerX = Math.min(Math.max(centerScale.centerX, this.maxEnvelope.minX), this.maxEnvelope.maxX);
|
|
2066
|
+
var centerY = Math.min(Math.max(centerScale.centerY, this.maxEnvelope.minY), this.maxEnvelope.maxY);
|
|
2067
|
+
return new CenterScale(centerX, centerY, centerScale.scale);
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
return centerScale;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
// Scale-related conditions. Relevant for zooming only.
|
|
2074
|
+
FocusModel.prototype.scalecon = function(centerScale, zoomLevelPolicy) {
|
|
2075
|
+
if (centerScale.scale < this.minScale) {
|
|
2076
|
+
return this.scalecon(new CenterScale(centerScale.centerX, centerScale.centerY, this.minScale), zoomLevelPolicy);
|
|
2077
|
+
}
|
|
2078
|
+
if (centerScale.scale > this.maxScale) {
|
|
2079
|
+
return this.scalecon(new CenterScale(centerScale.centerX, centerScale.centerY, this.maxScale), zoomLevelPolicy);
|
|
2080
|
+
}
|
|
2081
|
+
if (
|
|
2082
|
+
((zoomLevelPolicy >= FocusModel.ALWAYS_LOWER) && (zoomLevelPolicy <= FocusModel.ALWAYS_UPPER)) ||
|
|
2083
|
+
((zoomLevelPolicy >= FocusModel.IF_REQUIRED_LOWER) && (zoomLevelPolicy <= FocusModel.IF_REQUIRED) && this.scaleToZoomLevels)
|
|
2084
|
+
) {
|
|
2085
|
+
if (zoomLevelPolicy == FocusModel.IF_REQUIRED) {
|
|
2086
|
+
zoomLevelPolicy = undefined;
|
|
2087
|
+
} else {
|
|
2088
|
+
zoomLevelPolicy = zoomLevelPolicy % 3;
|
|
2089
|
+
}
|
|
2090
|
+
var zoomLevelScale = this.srs.getZoomLevel(centerScale.scale, zoomLevelPolicy).scale;
|
|
2091
|
+
if (centerScale.scale != zoomLevelScale) {
|
|
2092
|
+
return new CenterScale(centerScale.centerX, centerScale.centerY, zoomLevelScale);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
return centerScale;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
|
|
2100
|
+
|
|
2101
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2102
|
+
/* Merging js: focusmodel/EnvelopeModel.js begins */
|
|
2103
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2104
|
+
|
|
2105
|
+
|
|
2106
|
+
export function EnvelopeModel(boundsModel, focusModel) {
|
|
2107
|
+
this.boundsModel = boundsModel;
|
|
2108
|
+
this.focusModel = focusModel;
|
|
2109
|
+
|
|
2110
|
+
this.bounds = null;
|
|
2111
|
+
this.centerScale = null;
|
|
2112
|
+
this.animationCenterScale = null;
|
|
2113
|
+
this.incubationCenterScale = null;
|
|
2114
|
+
|
|
2115
|
+
this.envelope = null;
|
|
2116
|
+
this.animationEnvelope = null;
|
|
2117
|
+
this.incubationEnvelope = null;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
EnvelopeModel.prototype.setEnvelope = function(envelope) {
|
|
2121
|
+
var bounds = this.boundsModel.bounds;
|
|
2122
|
+
var centerScale = this.focusModel.centerScale;
|
|
2123
|
+
|
|
2124
|
+
var centerX = envelope.minX + envelope.getWidth() / 2;
|
|
2125
|
+
var centerY = envelope.minY + envelope.getHeight() / 2;
|
|
2126
|
+
var scale = Math.max(envelope.getWidth() / bounds.width, envelope.getHeight() / bounds.height) / centerScale.coordPixFactor * 1.05;
|
|
2127
|
+
this.focusModel.setCenterScale(new CenterScale(centerX, centerY, scale), FocusModel.IF_REQUIRED_UPPER);
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
EnvelopeModel.prototype.getEnvelope = function() {
|
|
2131
|
+
var bounds = this.boundsModel.bounds;
|
|
2132
|
+
var centerScale = this.focusModel.centerScale;
|
|
2133
|
+
|
|
2134
|
+
if (this.bounds != bounds) {
|
|
2135
|
+
this.bounds = bounds;
|
|
2136
|
+
this.envelope = null;
|
|
2137
|
+
this.animationEnvelope = null;
|
|
2138
|
+
this.incubationEnvelope = null;
|
|
2139
|
+
}
|
|
2140
|
+
if (this.centerScale != centerScale) {
|
|
2141
|
+
this.centerScale = centerScale;
|
|
2142
|
+
this.envelope = null;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
if ((this.envelope == null) && (bounds != null) && (centerScale != null)) {
|
|
2146
|
+
this.envelope = centerScale.toEnvelope(bounds.width, bounds.height);
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
return this.envelope;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
EnvelopeModel.prototype.getAnimationEnvelope = function() {
|
|
2153
|
+
var bounds = this.boundsModel.bounds;
|
|
2154
|
+
var animationCenterScale = this.focusModel.animationCenterScale;
|
|
2155
|
+
|
|
2156
|
+
if (this.bounds != bounds) {
|
|
2157
|
+
this.bounds = bounds;
|
|
2158
|
+
this.envelope = null;
|
|
2159
|
+
this.animationEnvelope = null;
|
|
2160
|
+
this.incubationEnvelope = null;
|
|
2161
|
+
}
|
|
2162
|
+
if (this.animationCenterScale != animationCenterScale) {
|
|
2163
|
+
this.animationCenterScale = animationCenterScale;
|
|
2164
|
+
this.animationEnvelope = null;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
if ((this.animationEnvelope == null) && (bounds != null) && (animationCenterScale != null)) {
|
|
2168
|
+
this.animationEnvelope = animationCenterScale.toEnvelope(bounds.width, bounds.height);
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
return this.animationEnvelope;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
EnvelopeModel.prototype.getIncubationEnvelope = function() {
|
|
2175
|
+
var bounds = this.boundsModel.bounds;
|
|
2176
|
+
var incubationCenterScale = this.focusModel.incubationCenterScale;
|
|
2177
|
+
|
|
2178
|
+
if (this.bounds != bounds) {
|
|
2179
|
+
this.bounds = bounds;
|
|
2180
|
+
this.envelope = null;
|
|
2181
|
+
this.animationEnvelope = null;
|
|
2182
|
+
this.incubationEnvelope = null;
|
|
2183
|
+
}
|
|
2184
|
+
if (this.incubtionCenterScale != incubationCenterScale) {
|
|
2185
|
+
this.incubationCenterScale = incubationCenterScale;
|
|
2186
|
+
this.incubationEnvelope = null;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
if ((this.incubationEnvelope == null) && (bounds != null) && (incubationCenterScale != null)) {
|
|
2190
|
+
this.incubationEnvelope = incubationCenterScale.toEnvelope(bounds.width, bounds.height);
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
return this.incubationEnvelope;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
|
|
2197
|
+
|
|
2198
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2199
|
+
/* Merging js: focusmodel/ZoomLevel.js begins */
|
|
2200
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
export function ZoomLevel(zoomLevel, scale, resolution) {
|
|
2204
|
+
this.zoomLevel = zoomLevel;
|
|
2205
|
+
this.scale = scale;
|
|
2206
|
+
this.resolution = resolution;
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2212
|
+
/* Merging js: focusmodel/SRS.js begins */
|
|
2213
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2214
|
+
|
|
2215
|
+
|
|
2216
|
+
export function SRS() {
|
|
2217
|
+
this.srid = 900913;
|
|
2218
|
+
this.zoomLevels = [
|
|
2219
|
+
new ZoomLevel(0, 443744272.72414012, 156543.0339),
|
|
2220
|
+
new ZoomLevel(1, 221872136.36207006, 78271.51695),
|
|
2221
|
+
new ZoomLevel(2, 110936068.18103503, 39135.758475),
|
|
2222
|
+
new ZoomLevel(3, 55468034.090517517, 19567.8792375),
|
|
2223
|
+
new ZoomLevel(4, 27734017.045258758, 9783.93961875),
|
|
2224
|
+
new ZoomLevel(5, 13867008.522629379, 4891.969809375),
|
|
2225
|
+
new ZoomLevel(6, 6933504.261314690, 2445.9849046875),
|
|
2226
|
+
new ZoomLevel(7, 3466752.130657345, 1222.99245234375),
|
|
2227
|
+
new ZoomLevel(8, 1733376.065328672, 611.496226171875),
|
|
2228
|
+
new ZoomLevel(9, 866688.0326643360, 305.7481130859375),
|
|
2229
|
+
new ZoomLevel(10, 433344.01633216810, 152.87405654296876),
|
|
2230
|
+
new ZoomLevel(11, 216672.00816608404, 76.43702827148438),
|
|
2231
|
+
new ZoomLevel(12, 108336.00408304202, 38.21851413574219),
|
|
2232
|
+
new ZoomLevel(13, 54168.002041521010, 19.109257067871095),
|
|
2233
|
+
new ZoomLevel(14, 27084.001020760505, 9.554628533935547),
|
|
2234
|
+
new ZoomLevel(15, 13542.000510380252, 4.777314266967774),
|
|
2235
|
+
new ZoomLevel(16, 6771.0002551901260, 2.388657133483887),
|
|
2236
|
+
new ZoomLevel(17, 3385.5001275950630, 1.1943285667419434),
|
|
2237
|
+
new ZoomLevel(18, 1692.7500637975315, 0.5971642833709717),
|
|
2238
|
+
new ZoomLevel(19, 846.37503189876580, 0.2985821416854859),
|
|
2239
|
+
new ZoomLevel(20, 423.18751594938290, 0.1492910708427429)
|
|
2240
|
+
];
|
|
2241
|
+
this.minX = -20037508.3427892;
|
|
2242
|
+
this.minY = -20037508.3427892;
|
|
2243
|
+
this.maxX = 20037508.3427892;
|
|
2244
|
+
this.maxY = 20037508.3427892;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
SRS.LOWER = 0;
|
|
2248
|
+
SRS.NEAREST = 1;
|
|
2249
|
+
SRS.UPPER = 2;
|
|
2250
|
+
|
|
2251
|
+
SRS.prototype.getZoomLevel = function(scale, policy) {
|
|
2252
|
+
if (policy == null) {
|
|
2253
|
+
policy = SRS.NEAREST;
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
if (policy == SRS.LOWER) {
|
|
2257
|
+
for (var i = 0; i < this.zoomLevels.length - 1; i++) {
|
|
2258
|
+
if (scale >= this.zoomLevels[i].scale) {
|
|
2259
|
+
return this.zoomLevels[i];
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
return this.zoomLevels[this.zoomLevels.length - 1];
|
|
2263
|
+
} else if ((policy == SRS.NEAREST) || (policy >= 3)) {
|
|
2264
|
+
for (var i = 0; i < this.zoomLevels.length - 1; i++) {
|
|
2265
|
+
if (
|
|
2266
|
+
(scale >= (this.zoomLevels[i].scale + this.zoomLevels[i + 1].scale) / 2) ||
|
|
2267
|
+
((policy >= 3) && (policy == this.zoomLevels[i].zoomLevel))
|
|
2268
|
+
) {
|
|
2269
|
+
return this.zoomLevels[i];
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
return this.zoomLevels[this.zoomLevels.length - 1];
|
|
2273
|
+
} else { // policy == SRS.UPPER
|
|
2274
|
+
for (var i = this.zoomLevels.length - 1; i > 0; i--) {
|
|
2275
|
+
if (scale <= this.zoomLevels[i].scale) {
|
|
2276
|
+
return this.zoomLevels[i];
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
return this.zoomLevels[0];
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2286
|
+
/* Merging js: mapcontroller/MapController.js begins */
|
|
2287
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
export function MapController(element, env, scope) {
|
|
2291
|
+
var mouseWheelTime = performance.now();
|
|
2292
|
+
var mouseWheelDelta = -1;
|
|
2293
|
+
|
|
2294
|
+
var panTimer = new PanSpeedTimer(); // Role of timer is 2-fold: measure pan speed, but also apply digest cycle every tick.
|
|
2295
|
+
panTimer.scope = scope;
|
|
2296
|
+
panTimer.timerHandler = function() { env.focusModel.panimate(); };
|
|
2297
|
+
|
|
2298
|
+
element.addEventListener("wheel", mouseWheelHandler);
|
|
2299
|
+
element.addEventListener("mousedown", pressHandler);
|
|
2300
|
+
element.addEventListener("touchstart", pressHandler);
|
|
2301
|
+
document.addEventListener("mousemove", mouseMoveHandler);
|
|
2302
|
+
|
|
2303
|
+
this.destroy = function() {
|
|
2304
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
function mouseWheelHandler(mouseEvent) {
|
|
2308
|
+
mouseEvent.preventDefault();
|
|
2309
|
+
|
|
2310
|
+
var delta = mouseEvent.deltaY;
|
|
2311
|
+
if (delta == 0) {
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
var width = env.boundsModel.bounds.width;
|
|
2316
|
+
var height = env.boundsModel.bounds.height;
|
|
2317
|
+
|
|
2318
|
+
var cs = env.focusModel.centerScale;
|
|
2319
|
+
var acs = env.focusModel.animationCenterScale;
|
|
2320
|
+
|
|
2321
|
+
if (env.mouseWheelAction == "HORIZONTAL_PAN") {
|
|
2322
|
+
if (delta > 0) {
|
|
2323
|
+
env.focusModel.setCenterScale(new CenterScale(
|
|
2324
|
+
cs.centerX - acs.getNumWorldCoords(width / 2),
|
|
2325
|
+
cs.centerY,
|
|
2326
|
+
cs.scale
|
|
2327
|
+
));
|
|
2328
|
+
} else {
|
|
2329
|
+
env.focusModel.setCenterScale(new CenterScale(
|
|
2330
|
+
cs.centerX + acs.getNumWorldCoords(width / 2),
|
|
2331
|
+
cs.centerY,
|
|
2332
|
+
cs.scale
|
|
2333
|
+
));
|
|
2334
|
+
}
|
|
2335
|
+
} else if (env.mouseWheelAction == "VERTICAL_PAN") {
|
|
2336
|
+
if (delta > 0) {
|
|
2337
|
+
env.focusModel.setCenterScale(new CenterScale(
|
|
2338
|
+
cs.centerX,
|
|
2339
|
+
cs.centerY + acs.getNumWorldCoords(height / 2),
|
|
2340
|
+
cs.scale
|
|
2341
|
+
));
|
|
2342
|
+
} else {
|
|
2343
|
+
env.focusModel.setCenterScale(new CenterScale(
|
|
2344
|
+
cs.centerX,
|
|
2345
|
+
cs.centerY - acs.getNumWorldCoords(height / 2),
|
|
2346
|
+
cs.scale
|
|
2347
|
+
));
|
|
2348
|
+
}
|
|
2349
|
+
} else { // ZOOM
|
|
2350
|
+
var now = performance.now();
|
|
2351
|
+
var reverseZoom = (mouseWheelDelta * delta < 0);
|
|
2352
|
+
if (
|
|
2353
|
+
(env.focusModel.scaleToZoomLevels && (mouseWheelTime < now - 250)) ||
|
|
2354
|
+
(!env.focusModel.scaleToZoomLevels && (mouseWheelTime < now - 50)) || reverseZoom
|
|
2355
|
+
) {
|
|
2356
|
+
mouseWheelTime = now;
|
|
2357
|
+
mouseWheelDelta = delta;
|
|
2358
|
+
|
|
2359
|
+
var zoomFactor = env.focusModel.scaleToZoomLevels? 2: 1.3;
|
|
2360
|
+
if (delta < 0) {
|
|
2361
|
+
zoomFactor = 1 / zoomFactor;
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
var mouseX = mouseEvent.clientX - element.getBoundingClientRect().left;
|
|
2365
|
+
var mouseY = mouseEvent.clientY - element.getBoundingClientRect().top;
|
|
2366
|
+
|
|
2367
|
+
var worldX = acs.getWorldX(width, mouseX);
|
|
2368
|
+
var worldY = acs.getWorldY(height, mouseY);
|
|
2369
|
+
var scale = (reverseZoom? acs.scale: cs.scale) * zoomFactor;
|
|
2370
|
+
|
|
2371
|
+
var pixXOffset = mouseX - (width / 2);
|
|
2372
|
+
var pixYOffset = mouseY - (height / 2);
|
|
2373
|
+
|
|
2374
|
+
env.focusModel.zoom(new CenterScale(worldX, worldY, scale), pixXOffset, pixYOffset);
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
function pressHandler(event) {
|
|
2380
|
+
if (panTimer.isRunning()) { // From 1 to 2 fingers is not a true press anymore.
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
event.preventDefault();
|
|
2385
|
+
decorateTouchEvent(event, false);
|
|
2386
|
+
|
|
2387
|
+
var pressX = event.clientX - element.getBoundingClientRect().left;
|
|
2388
|
+
var pressY = event.clientY - element.getBoundingClientRect().top;
|
|
2389
|
+
|
|
2390
|
+
var width = env.boundsModel.bounds.width;
|
|
2391
|
+
var height = env.boundsModel.bounds.height;
|
|
2392
|
+
|
|
2393
|
+
var cs = env.focusModel.animationCenterScale;
|
|
2394
|
+
var worldX = cs.getWorldX(width, pressX);
|
|
2395
|
+
var worldY = cs.getWorldY(height, pressY);
|
|
2396
|
+
|
|
2397
|
+
var pixXOffset = pressX - (width / 2);
|
|
2398
|
+
var pixYOffset = pressY - (height / 2);
|
|
2399
|
+
|
|
2400
|
+
var grabbedAnimation = env.focusModel.grab(worldX, worldY, pixXOffset, pixYOffset);
|
|
2401
|
+
|
|
2402
|
+
panTimer.start(event);
|
|
2403
|
+
panTimer.panned = grabbedAnimation;
|
|
2404
|
+
|
|
2405
|
+
if (event.type == "mousedown") {
|
|
2406
|
+
document.addEventListener("mouseup", releaseHandler);
|
|
2407
|
+
} else { // touchstart
|
|
2408
|
+
document.addEventListener("touchmove", touchMoveHandler);
|
|
2409
|
+
document.addEventListener("touchend", releaseHandler);
|
|
2410
|
+
document.addEventListener("touchcancel", releaseHandler);
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
if (env.pressFunction != null) {
|
|
2414
|
+
if (scope != null) {
|
|
2415
|
+
scope.$apply(env.pressFunction(worldX, worldY));
|
|
2416
|
+
} else {
|
|
2417
|
+
env.pressFunction(worldX, worldY);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
function mouseMoveHandler(mouseEvent) {
|
|
2423
|
+
if (!panTimer.isRunning() && (env.mouseMoveFunction == null)) {
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
var mouseX = mouseEvent.clientX - element.getBoundingClientRect().left;
|
|
2428
|
+
var mouseY = mouseEvent.clientY - element.getBoundingClientRect().top;
|
|
2429
|
+
|
|
2430
|
+
var width = env.boundsModel.bounds.width;
|
|
2431
|
+
var height = env.boundsModel.bounds.height;
|
|
2432
|
+
|
|
2433
|
+
if (panTimer.isRunning()) {
|
|
2434
|
+
mouseEvent.preventDefault();
|
|
2435
|
+
|
|
2436
|
+
var previousEvent = panTimer.panEvents[panTimer.panEvents.length - 1];
|
|
2437
|
+
if ((previousEvent.clientX != mouseEvent.clientX) || (previousEvent.clientY != mouseEvent.clientY)) {
|
|
2438
|
+
var pixXOffset = mouseX - (width / 2);
|
|
2439
|
+
var pixYOffset = mouseY - (height / 2);
|
|
2440
|
+
|
|
2441
|
+
env.focusModel.pan(pixXOffset, pixYOffset);
|
|
2442
|
+
|
|
2443
|
+
panTimer.push(mouseEvent);
|
|
2444
|
+
}
|
|
2445
|
+
} else { // (env.mouseMoveFunction != null)
|
|
2446
|
+
var cs = env.focusModel.animationCenterScale;
|
|
2447
|
+
var worldX = cs.getWorldX(width, mouseX);
|
|
2448
|
+
var worldY = cs.getWorldY(height, mouseY);
|
|
2449
|
+
|
|
2450
|
+
if (scope != null) {
|
|
2451
|
+
scope.$apply(env.mouseMoveFunction(worldX, worldY, mouseEvent.ctrlKey, mouseEvent.shiftKey));
|
|
2452
|
+
} else {
|
|
2453
|
+
env.mouseMoveFunction(worldX, worldY, mouseEvent.ctrlKey, mouseEvent.shiftKey);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
function touchMoveHandler(touchEvent) {
|
|
2459
|
+
touchEvent.preventDefault();
|
|
2460
|
+
decorateTouchEvent(touchEvent, false);
|
|
2461
|
+
|
|
2462
|
+
var pinchX = touchEvent.clientX - element.getBoundingClientRect().left;
|
|
2463
|
+
var pinchY = touchEvent.clientY - element.getBoundingClientRect().top;
|
|
2464
|
+
|
|
2465
|
+
var width = env.boundsModel.bounds.width;
|
|
2466
|
+
var height = env.boundsModel.bounds.height;
|
|
2467
|
+
|
|
2468
|
+
var pixXOffset = pinchX - (width / 2);
|
|
2469
|
+
var pixYOffset = pinchY - (height / 2);
|
|
2470
|
+
|
|
2471
|
+
var previousEvent = panTimer.panEvents[panTimer.panEvents.length - 1];
|
|
2472
|
+
if ((touchEvent.touches.length == 1) && (previousEvent.touches.length == 1)) {
|
|
2473
|
+
env.focusModel.pan(pixXOffset, pixYOffset);
|
|
2474
|
+
} else {
|
|
2475
|
+
var cs = env.focusModel.animationCenterScale;
|
|
2476
|
+
var worldX = -1;
|
|
2477
|
+
var worldY = -1;
|
|
2478
|
+
var scale = cs.scale;
|
|
2479
|
+
|
|
2480
|
+
if (touchEvent.touches.length != previousEvent.touches.length) {
|
|
2481
|
+
worldX = cs.getWorldX(width, pinchX);
|
|
2482
|
+
worldY = cs.getWorldY(height, pinchY);
|
|
2483
|
+
} else {
|
|
2484
|
+
worldX = env.focusModel.animation.target.centerX;
|
|
2485
|
+
worldY = env.focusModel.animation.target.centerY;
|
|
2486
|
+
scale = env.focusModel.animation.target.scale / (touchEvent.radius / previousEvent.radius);
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
env.focusModel.pinchPan(new CenterScale(worldX, worldY, scale), pixXOffset, pixYOffset);
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
panTimer.push(touchEvent);
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
function releaseHandler(event) {
|
|
2496
|
+
if ((event.touches != null) && (event.touches.length > 0)) { // From 2 to 1 fingers is not a true release yet.
|
|
2497
|
+
return;
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
decorateTouchEvent(event, false);
|
|
2501
|
+
|
|
2502
|
+
var cs = env.focusModel.animationCenterScale;
|
|
2503
|
+
|
|
2504
|
+
var tapped = (!panTimer.panned)? panTimer.currentCount: false;
|
|
2505
|
+
var speed = panTimer.resetAndGetSpeed(event);
|
|
2506
|
+
if ((speed.h != 0) || (speed.v != 0) || (speed.z != 1)) {
|
|
2507
|
+
var zoomLevelPolicy = FocusModel.NEVER; // On touch devices, don't do the zoom level check.
|
|
2508
|
+
if (event.type == "mouseup") {
|
|
2509
|
+
zoomLevelPolicy = FocusModel.IF_REQUIRED;
|
|
2510
|
+
}
|
|
2511
|
+
env.focusModel.setCenterScale(new CenterScale(
|
|
2512
|
+
cs.centerX - cs.getNumWorldCoords(speed.h) * 250, // 250 = 1000 / 4 = animationDuration / deceleration
|
|
2513
|
+
cs.centerY + cs.getNumWorldCoords(speed.v) * 250,
|
|
2514
|
+
cs.scale / Math.pow(speed.z, 250)
|
|
2515
|
+
), zoomLevelPolicy);
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
if (event.type == "mouseup") {
|
|
2519
|
+
document.removeEventListener("mouseup", releaseHandler);
|
|
2520
|
+
} else { // touchend || touchcancel
|
|
2521
|
+
document.removeEventListener("touchmove", touchMoveHandler);
|
|
2522
|
+
document.removeEventListener("touchend", releaseHandler);
|
|
2523
|
+
document.removeEventListener("touchcancel", releaseHandler);
|
|
2524
|
+
|
|
2525
|
+
// Stop emulated mouse event. Calling touchEvent.preventDefault() does not prevent mouse emulation in iOS.
|
|
2526
|
+
element.removeEventListener("mousedown", pressHandler);
|
|
2527
|
+
setTimeout(function() { element.removeEventListener("mousedown", pressHandler); element.addEventListener("mousedown", pressHandler); }, 1000);
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
if ((env.releaseFunction != null) || ((env.tapFunction != null) && tapped)) {
|
|
2531
|
+
var releaseX = event.clientX - element.getBoundingClientRect().left;
|
|
2532
|
+
var releaseY = event.clientY - element.getBoundingClientRect().top;
|
|
2533
|
+
|
|
2534
|
+
var width = env.boundsModel.bounds.width;
|
|
2535
|
+
var height = env.boundsModel.bounds.height;
|
|
2536
|
+
|
|
2537
|
+
var worldX = cs.getWorldX(width, releaseX);
|
|
2538
|
+
var worldY = cs.getWorldY(height, releaseY);
|
|
2539
|
+
|
|
2540
|
+
if (env.releaseFunction != null) {
|
|
2541
|
+
if (scope != null) {
|
|
2542
|
+
scope.$apply(env.releaseFunction(worldX, worldY));
|
|
2543
|
+
} else {
|
|
2544
|
+
env.releaseFunction(worldX, worldY);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
if ((env.tapFunction != null) && tapped) { // tapped contains the tap duration.
|
|
2548
|
+
if (scope != null) {
|
|
2549
|
+
scope.$apply(env.tapFunction(worldX, worldY, tapped, event.ctrlKey, event.shiftKey));
|
|
2550
|
+
} else {
|
|
2551
|
+
env.tapFunction(worldX, worldY, tapped, event.ctrlKey, event.shiftKey);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
|
|
2559
|
+
|
|
2560
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2561
|
+
/* Merging js: layermodel/Layer.js begins */
|
|
2562
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2563
|
+
|
|
2564
|
+
|
|
2565
|
+
export function Layer(name) {
|
|
2566
|
+
this.name = name;
|
|
2567
|
+
this.baseURL = "https://tile.openstreetmap.org/";
|
|
2568
|
+
this.styleURL = null;
|
|
2569
|
+
this.urlExtension = "$Z/$X/$Y.png";
|
|
2570
|
+
this.format = "image/png";
|
|
2571
|
+
this.visible = true;
|
|
2572
|
+
this.title = name;
|
|
2573
|
+
this.filterModels = [];
|
|
2574
|
+
this.classification = null;
|
|
2575
|
+
this.vendorSpecifics = {};
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
Layer.prototype.forceReload = function() {
|
|
2579
|
+
this.vendorSpecifics.epochtime = performance.now();
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2584
|
+
/* Merging js: layermodel/Loader.js begins */
|
|
2585
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
export function Loader() {
|
|
2589
|
+
this.layers = {};
|
|
2590
|
+
this.numLoading = 0;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
Loader.prototype.add = function(key) {
|
|
2594
|
+
if (this.layers[key] == null) {
|
|
2595
|
+
this.layers[key] = 0;
|
|
2596
|
+
}
|
|
2597
|
+
this.layers[key]++;
|
|
2598
|
+
this.setNumLoading();
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
Loader.prototype.subtract = function(key) {
|
|
2602
|
+
this.layers[key]--;
|
|
2603
|
+
this.setNumLoading();
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
Loader.prototype.set = function(key) {
|
|
2607
|
+
this.layers[key] = 1;
|
|
2608
|
+
this.setNumLoading();
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
Loader.prototype.reset = function(key) {
|
|
2612
|
+
this.layers[key] = 0;
|
|
2613
|
+
this.setNumLoading();
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
Loader.prototype.remove = function(key) {
|
|
2617
|
+
delete this.layers[key];
|
|
2618
|
+
this.setNumLoading();
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
Loader.prototype.setNumLoading = function() {
|
|
2622
|
+
this.numLoading = 0;
|
|
2623
|
+
for (var key in this.layers) {
|
|
2624
|
+
this.numLoading += this.layers[key];
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
|
|
2629
|
+
|
|
2630
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2631
|
+
/* Merging js: layermodel/Tile.js begins */
|
|
2632
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
export function Tile(minX, maxY, scale, tileX, tileY, tileWidth, tileHeight, url) {
|
|
2636
|
+
this.minX = minX;
|
|
2637
|
+
this.maxY = maxY;
|
|
2638
|
+
this.scale = scale;
|
|
2639
|
+
this.tileX = tileX;
|
|
2640
|
+
this.tileY = tileY;
|
|
2641
|
+
this.tileWidth = tileWidth;
|
|
2642
|
+
this.tileHeight = tileHeight;
|
|
2643
|
+
this.url = url;
|
|
2644
|
+
this.x = 0;
|
|
2645
|
+
this.y = 0;
|
|
2646
|
+
this.scaling = 1;
|
|
2647
|
+
this.completed = false;
|
|
2648
|
+
this.corrupted = false;
|
|
2649
|
+
this.data = null;
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
Tile.prototype.reset = function(bounds, centerScale) {
|
|
2653
|
+
this.x = centerScale.getPixX(bounds.width, this.minX);
|
|
2654
|
+
this.y = centerScale.getPixY(bounds.height, this.maxY);
|
|
2655
|
+
this.scaling = this.scale / centerScale.scale;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
Tile.prototype.resetWithPoint = function(bounds, centerScale, minX, maxY) {
|
|
2659
|
+
this.x = centerScale.getPixX(bounds.width, minX);
|
|
2660
|
+
this.y = centerScale.getPixY(bounds.height, maxY);
|
|
2661
|
+
this.scaling = this.scale / centerScale.scale;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
Tile.prototype.resetWithEnvelope = function(bounds, centerScale, envelope) {
|
|
2665
|
+
var minPixX = centerScale.getPixX(bounds.width, envelope.minX);
|
|
2666
|
+
var minPixY = centerScale.getPixY(bounds.height, envelope.maxY);
|
|
2667
|
+
var maxPixX = centerScale.getPixX(bounds.width, envelope.maxX);
|
|
2668
|
+
//var maxPixY = centerScale.getPixY(bounds.height, envelope.minY);
|
|
2669
|
+
|
|
2670
|
+
this.x = minPixX;
|
|
2671
|
+
this.y = minPixY;
|
|
2672
|
+
this.scaling = (maxPixX - minPixX) / this.tileWidth;
|
|
2673
|
+
//var vertScaling = (maxPixY - minPixY) / this.tileHeight;
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
Tile.prototype.toCSS = function() {
|
|
2677
|
+
return {left: this.x + "px", top: this.y + "px", width: (this.tileWidth * this.scaling) + "px", height: (this.tileHeight * this.scaling) + "px"};
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
|
|
2681
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2682
|
+
/* Merging js: layermodel/VectorTile.js begins */
|
|
2683
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2684
|
+
|
|
2685
|
+
|
|
2686
|
+
export function VectorTile(minX, maxY, scale, tileX, tileY, tileWidth, tileHeight, url) {
|
|
2687
|
+
this.minX = minX;
|
|
2688
|
+
this.maxY = maxY;
|
|
2689
|
+
this.scale = scale;
|
|
2690
|
+
this.tileX = tileX;
|
|
2691
|
+
this.tileY = tileY;
|
|
2692
|
+
this.tileWidth = tileWidth;
|
|
2693
|
+
this.tileHeight = tileHeight;
|
|
2694
|
+
this.url = url;
|
|
2695
|
+
this.x = 0;
|
|
2696
|
+
this.y = 0;
|
|
2697
|
+
this.scaling = 1;
|
|
2698
|
+
this.completed = false;
|
|
2699
|
+
this.corrupted = false;
|
|
2700
|
+
this.data = null;
|
|
2701
|
+
|
|
2702
|
+
this.snoopData = null;
|
|
2703
|
+
this.symbology = null;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
VectorTile.prototype = new Tile();
|
|
2707
|
+
VectorTile.prototype.constructor = VectorTile;
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2712
|
+
/* Merging js: layermodel/TileModel.js begins */
|
|
2713
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
export function TileModel() {
|
|
2717
|
+
this.bounds = null;
|
|
2718
|
+
this.srs = null;
|
|
2719
|
+
this.maxZoomLevel = null;
|
|
2720
|
+
this.maxEnvelope = null;
|
|
2721
|
+
this.centerScale = null;
|
|
2722
|
+
this.animationCenterScale = null;
|
|
2723
|
+
this.envelope = null;
|
|
2724
|
+
this.animationEnvelope = null;
|
|
2725
|
+
this.layer = null;
|
|
2726
|
+
this.loader = null;
|
|
2727
|
+
this.protocol = "TMS";
|
|
2728
|
+
this.numResetRuns = 1;
|
|
2729
|
+
this.tileWidth = 256;
|
|
2730
|
+
this.tileHeight = 256;
|
|
2731
|
+
this.tiles = [];
|
|
2732
|
+
this.tileIndex = {};
|
|
2733
|
+
this.ctx = null; // Used only for tile models that draw on a canvas.
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
TileModel.prototype.setBoundsAndCenterScales = function(bounds, centerScale, animationCenterScale, envelope, animationEnvelope) {
|
|
2737
|
+
if (bounds == null) {
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
var boundsChanged = false;
|
|
2742
|
+
var centerScaleChanged = false;
|
|
2743
|
+
var animationCenterScaleChanged = false;
|
|
2744
|
+
if (!bounds.equals(this.bounds)) {
|
|
2745
|
+
this.bounds = bounds;
|
|
2746
|
+
boundsChanged = true;
|
|
2747
|
+
}
|
|
2748
|
+
if (!centerScale.equals(this.centerScale)) {
|
|
2749
|
+
this.centerScale = centerScale;
|
|
2750
|
+
centerScaleChanged = true;
|
|
2751
|
+
}
|
|
2752
|
+
if (!animationCenterScale.equals(this.animationCenterScale)) {
|
|
2753
|
+
this.animationCenterScale = animationCenterScale;
|
|
2754
|
+
animationCenterScaleChanged = true;
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
this.envelope = envelope;
|
|
2758
|
+
this.animationEnvelope = animationEnvelope;
|
|
2759
|
+
|
|
2760
|
+
if (boundsChanged || centerScaleChanged) {
|
|
2761
|
+
this.loadTiles();
|
|
2762
|
+
}
|
|
2763
|
+
if (boundsChanged || animationCenterScaleChanged) {
|
|
2764
|
+
this.resetTiles();
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
TileModel.prototype.setBounds = function(bounds, envelope, animationEnvelope) {
|
|
2769
|
+
if (bounds == null) {
|
|
2770
|
+
return;
|
|
2771
|
+
}
|
|
2772
|
+
if (bounds.equals(this.bounds)) {
|
|
2773
|
+
return;
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
this.bounds = bounds;
|
|
2777
|
+
this.envelope = envelope;
|
|
2778
|
+
this.animationEnvelope = animationEnvelope;
|
|
2779
|
+
this.loadTiles();
|
|
2780
|
+
this.resetTiles();
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
TileModel.prototype.setCenterScale = function(centerScale, envelope) {
|
|
2784
|
+
this.centerScale = centerScale;
|
|
2785
|
+
this.envelope = envelope;
|
|
2786
|
+
this.loadTiles();
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
TileModel.prototype.setAnimationCenterScale = function(animationCenterScale, animationEnvelope) {
|
|
2790
|
+
this.animationCenterScale = animationCenterScale;
|
|
2791
|
+
this.animationEnvelope = animationEnvelope;
|
|
2792
|
+
this.resetTiles();
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
TileModel.prototype.setLayer = function(layer) {
|
|
2796
|
+
if (this.layer == layer) {
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
if ((this.loader != null) && (this.layer != null)) {
|
|
2801
|
+
this.loader.remove(this.layer.name);
|
|
2802
|
+
}
|
|
2803
|
+
if ((this.loader != null) && (layer != null)) {
|
|
2804
|
+
this.loader.reset(layer.name);
|
|
2805
|
+
}
|
|
2806
|
+
this.layer = layer;
|
|
2807
|
+
this.tiles = [];
|
|
2808
|
+
this.tileIndex = {};
|
|
2809
|
+
this.loadTiles();
|
|
2810
|
+
//this.resetTiles();
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
TileModel.prototype.loadTiles = function() {
|
|
2814
|
+
if (this.bounds == null) {
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
if (this.centerScale == null) {
|
|
2818
|
+
return;
|
|
2819
|
+
}
|
|
2820
|
+
if ((this.layer == null) || (!this.layer.visible)) {
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
var envelope = this.envelope;
|
|
2825
|
+
if (envelope == null) {
|
|
2826
|
+
envelope = this.centerScale.toEnvelope(this.bounds.width, this.bounds.height);
|
|
2827
|
+
}
|
|
2828
|
+
if (this.maxEnvelope != null) {
|
|
2829
|
+
envelope = envelope.intersection(this.maxEnvelope);
|
|
2830
|
+
}
|
|
2831
|
+
if (envelope == null) {
|
|
2832
|
+
return;
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
var zoomLevel = this.srs.getZoomLevel(this.centerScale.scale, this.maxZoomLevel);
|
|
2836
|
+
var tp = this.getTilePositions(zoomLevel, envelope);
|
|
2837
|
+
for (var i = 0; i < tp.length; i++) {
|
|
2838
|
+
var tile = tp[i].tile;
|
|
2839
|
+
if ((tile == null) || (tile.corrupted && (tile.corrupted + 7000 < performance.now())) || tp[i].tileNeedsReload) {
|
|
2840
|
+
if (tile == null) {
|
|
2841
|
+
tile = this.createAndAddTile(zoomLevel, tp[i].tileX, tp[i].tileY);
|
|
2842
|
+
} else {
|
|
2843
|
+
tile.completed = false;
|
|
2844
|
+
tile.corrupted = false;
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
if (this.loader != null) {
|
|
2848
|
+
this.loader.add(this.layer.name);
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
this.loadTileData(tile);
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
TileModel.prototype.resetTiles = function() {
|
|
2857
|
+
if (this.bounds == null) {
|
|
2858
|
+
return;
|
|
2859
|
+
}
|
|
2860
|
+
if (this.animationCenterScale == null) {
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
if (this.ctx != null) {
|
|
2865
|
+
this.ctx.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
|
2866
|
+
} else {
|
|
2867
|
+
for (var i = 0; i < this.tiles.length; i++) {
|
|
2868
|
+
this.tiles[i].completed = false;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
if ((this.layer == null) || (!this.layer.visible)) {
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
var envelope = this.animationEnvelope;
|
|
2877
|
+
if (envelope == null) {
|
|
2878
|
+
envelope = this.animationCenterScale.toEnvelope(this.bounds.width, this.bounds.height);
|
|
2879
|
+
}
|
|
2880
|
+
if (this.maxEnvelope != null) {
|
|
2881
|
+
envelope = envelope.intersection(this.maxEnvelope);
|
|
2882
|
+
}
|
|
2883
|
+
if (envelope == null) {
|
|
2884
|
+
return;
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2887
|
+
var zoomLevel = this.srs.getZoomLevel(this.animationCenterScale.scale, this.maxZoomLevel);
|
|
2888
|
+
var tp = this.getTilePositions(zoomLevel, envelope);
|
|
2889
|
+
for (var j = 0; j < this.numResetRuns; j++) {
|
|
2890
|
+
for (var k = 0; k < tp.length; k++) {
|
|
2891
|
+
var tile = tp[k].tile;
|
|
2892
|
+
if (this.ctx != null) {
|
|
2893
|
+
if ((tile != null) && tile.completed && !tile.corrupted && !tp[k].tileNeedsReload) {
|
|
2894
|
+
tile.reset(this.bounds, this.animationCenterScale);
|
|
2895
|
+
this.drawTile(tile, false, j);
|
|
2896
|
+
} else if (j == 0) {
|
|
2897
|
+
var minX = tp[k].tileX * this.tileWidth * zoomLevel.resolution + this.srs.minX;
|
|
2898
|
+
var maxY = -(tp[k].tileY * this.tileHeight * zoomLevel.resolution - this.srs.maxY);
|
|
2899
|
+
this.drawTilesAroundZoomLevel(zoomLevel.zoomLevel, zoomLevel.resolution, minX, maxY);
|
|
2900
|
+
}
|
|
2901
|
+
} else {
|
|
2902
|
+
if ((tile != null) && and (j == 0)) {
|
|
2903
|
+
tile.reset(this.bounds, this.animationCenterScale);
|
|
2904
|
+
tile.completed = true;
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
TileModel.prototype.getTilePositions = function(zoomLevel, envelope) {
|
|
2912
|
+
var tilePositions = [];
|
|
2913
|
+
var tileLimit = Math.pow(2, zoomLevel.zoomLevel);
|
|
2914
|
+
var leftTileX = Math.floor((envelope.minX - this.srs.minX) / zoomLevel.resolution / this.tileWidth);
|
|
2915
|
+
var topTileY = Math.max(Math.floor((this.srs.maxY - envelope.maxY) / zoomLevel.resolution / this.tileHeight), 0);
|
|
2916
|
+
var rightTileX = Math.floor((envelope.maxX - this.srs.minX) / zoomLevel.resolution / this.tileWidth);
|
|
2917
|
+
var bottomTileY = Math.min(Math.floor((this.srs.maxY - envelope.minY) / zoomLevel.resolution / this.tileHeight), tileLimit - 1);
|
|
2918
|
+
|
|
2919
|
+
for (var tileY = topTileY; tileY <= bottomTileY; tileY++) {
|
|
2920
|
+
for (var tileX = leftTileX; tileX <= rightTileX; tileX++) {
|
|
2921
|
+
var tile = this.getTile(zoomLevel.zoomLevel, tileX, tileY);
|
|
2922
|
+
tilePositions.push({
|
|
2923
|
+
tileX: tileX,
|
|
2924
|
+
tileY: tileY,
|
|
2925
|
+
tile: tile,
|
|
2926
|
+
tileNeedsReload: tile? this.tileNeedsReload(tile): null
|
|
2927
|
+
});
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
return tilePositions;
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2934
|
+
TileModel.prototype.createAndAddTile = function(zoomLevel, tileX, tileY) {
|
|
2935
|
+
var minX = tileX * this.tileWidth * zoomLevel.resolution + this.srs.minX;
|
|
2936
|
+
var maxY = -(tileY * this.tileHeight * zoomLevel.resolution - this.srs.maxY);
|
|
2937
|
+
|
|
2938
|
+
var url = null;
|
|
2939
|
+
if (this.protocol != "WMTS") {
|
|
2940
|
+
var tileLimit = Math.pow(2, zoomLevel.zoomLevel);
|
|
2941
|
+
url = this.layer.urlExtension;
|
|
2942
|
+
url = url.replace("$Z", zoomLevel.zoomLevel);
|
|
2943
|
+
url = url.replace("$X", ((tileX % tileLimit) + tileLimit) % tileLimit);
|
|
2944
|
+
url = url.replace("$Y", tileY);
|
|
2945
|
+
url = this.layer.baseURL + url;
|
|
2946
|
+
} else {
|
|
2947
|
+
var maxX = (tileX + 1) * this.tileWidth * zoomLevel.resolution + this.srs.minX;
|
|
2948
|
+
var minY = -((tileY + 1) * this.tileHeight * zoomLevel.resolution - this.srs.maxY);
|
|
2949
|
+
url = WMSProtocol.getMapURL(this.layer, this.srs, minX, minY, maxX, maxY, this.tileWidth, this.tileHeight, true, null);
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
var tile = this.createTile(minX, maxY, zoomLevel.scale, tileX, tileY, this.tileWidth, this.tileHeight, url);
|
|
2953
|
+
|
|
2954
|
+
this.addTile(zoomLevel.zoomLevel, tile);
|
|
2955
|
+
|
|
2956
|
+
return tile;
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
TileModel.prototype.createTile = function(minX, maxY, scale, tileX, tileY, tileWidth, tileHeight, url) {
|
|
2960
|
+
return new Tile(minX, maxY, scale, tileX, tileY, tileWidth, tileHeight, url);
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
TileModel.prototype.addTile = function(zoomLevel, tile) {
|
|
2964
|
+
var tileX = tile.tileX;
|
|
2965
|
+
var tileY = tile.tileY;
|
|
2966
|
+
|
|
2967
|
+
if (this.tileIndex[zoomLevel] == null) {
|
|
2968
|
+
this.tileIndex[zoomLevel] = {};
|
|
2969
|
+
}
|
|
2970
|
+
if (this.tileIndex[zoomLevel][tileX] == null) {
|
|
2971
|
+
this.tileIndex[zoomLevel][tileX] = {};
|
|
2972
|
+
}
|
|
2973
|
+
this.tileIndex[zoomLevel][tileX][tileY] = this.tiles.push(tile) - 1;
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
TileModel.prototype.getTile = function(zoomLevel, tileX, tileY) {
|
|
2977
|
+
if ((this.tileIndex[zoomLevel] == null) || (this.tileIndex[zoomLevel][tileX] == null) || (this.tileIndex[zoomLevel][tileX][tileY] == null)) {
|
|
2978
|
+
return null;
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
return this.tiles[this.tileIndex[zoomLevel][tileX][tileY]];
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
TileModel.prototype.tileNeedsReload = function(tile) {
|
|
2985
|
+
return false;
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
TileModel.prototype.loadTileData = function(tile) {
|
|
2989
|
+
if (this.ctx != null) {
|
|
2990
|
+
var f = function(t, env, success) { return function() { env.completeTile(t, success); }};
|
|
2991
|
+
|
|
2992
|
+
tile.data = new Image();
|
|
2993
|
+
tile.data.addEventListener("load", f(tile, this, true));
|
|
2994
|
+
tile.data.addEventListener("error", f(tile, this, false));
|
|
2995
|
+
tile.data.src = tile.url;
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
TileModel.prototype.completeTile = function(tile, success) {
|
|
3000
|
+
var zoomLevel = this.srs.getZoomLevel(tile.scale, this.maxZoomLevel);
|
|
3001
|
+
if (this.getTile(zoomLevel.zoomLevel, tile.tileX, tile.tileY) != tile) {
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
if (this.loader != null) {
|
|
3006
|
+
this.loader.subtract(this.layer.name);
|
|
3007
|
+
}
|
|
3008
|
+
tile.completed = true;
|
|
3009
|
+
|
|
3010
|
+
if (success) {
|
|
3011
|
+
tile.corrupted = false;
|
|
3012
|
+
|
|
3013
|
+
if (
|
|
3014
|
+
(this.layer != null) && this.layer.visible &&
|
|
3015
|
+
(this.animationCenterScale != null) && (this.srs.getZoomLevel(this.animationCenterScale.scale, this.maxZoomLevel).zoomLevel == zoomLevel.zoomLevel)
|
|
3016
|
+
) {
|
|
3017
|
+
this.resetTiles();
|
|
3018
|
+
}
|
|
3019
|
+
} else {
|
|
3020
|
+
tile.corrupted = performance.now();
|
|
3021
|
+
|
|
3022
|
+
console.log("Error loading tile: " + tile.url);
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
TileModel.prototype.drawTilesAroundZoomLevel = function(zl, rs, minX, maxY) {
|
|
3027
|
+
// Find any completed tile in the zoom levels above the given zoom level.
|
|
3028
|
+
for (var zoomLevel = zl - 1, resolution = rs * 2; zoomLevel >= 0; zoomLevel--, resolution *= 2) {
|
|
3029
|
+
var zoomFactor = Math.pow(2, zl - zoomLevel);
|
|
3030
|
+
var subTileX = Math.round((minX - this.srs.minX) / resolution / this.tileWidth * zoomFactor) / zoomFactor;
|
|
3031
|
+
var tileX = Math.floor(subTileX);
|
|
3032
|
+
var subTileY = Math.round((this.srs.maxY - maxY) / resolution / this.tileHeight * zoomFactor) / zoomFactor;
|
|
3033
|
+
var tileY = Math.max(Math.floor(subTileY), 0);
|
|
3034
|
+
var tile = this.getTile(zoomLevel, tileX, tileY);
|
|
3035
|
+
if ((tile != null) && tile.completed && !tile.corrupted && !this.tileNeedsReload(tile)) {
|
|
3036
|
+
tile.resetWithPoint(this.bounds, this.animationCenterScale, minX, maxY);
|
|
3037
|
+
this.drawTilePartly(tile, (subTileX % 1) * tile.tileWidth, (subTileY % 1) * tile.tileHeight, tile.tileWidth / zoomFactor, tile.tileHeight / zoomFactor);
|
|
3038
|
+
break;
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
// Find completed tiles in the (single one) zoom level below the given zoom level.
|
|
3043
|
+
var zoomLevel = zl + 1;
|
|
3044
|
+
var resolution = rs / 2;
|
|
3045
|
+
var leftTileX = Math.round((minX - this.srs.minX) / resolution / this.tileWidth);
|
|
3046
|
+
var topTileY = Math.max(Math.round((this.srs.maxY - maxY) / resolution / this.tileHeight), 0);
|
|
3047
|
+
for (var tileY = topTileY; tileY <= topTileY + 1; tileY++) {
|
|
3048
|
+
for (var tileX = leftTileX; tileX <= leftTileX + 1; tileX++) {
|
|
3049
|
+
var tile = this.getTile(zoomLevel, tileX, tileY);
|
|
3050
|
+
if ((tile != null) && tile.completed && !tile.corrupted && !this.tileNeedsReload(tile)) {
|
|
3051
|
+
tile.reset(this.bounds, this.animationCenterScale);
|
|
3052
|
+
this.drawTile(tile, true);
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
|
|
3058
|
+
TileModel.prototype.drawTile = function(tile, clear, run) {
|
|
3059
|
+
var x = Math.round(tile.x);
|
|
3060
|
+
var y = Math.round(tile.y);
|
|
3061
|
+
var width = Math.round(tile.x - x + tile.scaling * tile.tileWidth);
|
|
3062
|
+
var height = Math.round(tile.y - y + tile.scaling * tile.tileHeight);
|
|
3063
|
+
if (clear) {
|
|
3064
|
+
this.ctx.clearRect(x, y, width, height);
|
|
3065
|
+
}
|
|
3066
|
+
this.drawTileImage(tile, x, y, width, height, run);
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
TileModel.prototype.drawTileImage = function(tile, dx, dy, dWidth, dHeight, run) {
|
|
3070
|
+
this.ctx.drawImage(tile.data, dx, dy, dWidth, dHeight);
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
TileModel.prototype.drawTilePartly = function(tile, x, y, width, height) {
|
|
3074
|
+
this.ctx.drawImage(
|
|
3075
|
+
tile.data,
|
|
3076
|
+
x, y,
|
|
3077
|
+
width, height,
|
|
3078
|
+
Math.round(tile.x), Math.round(tile.y),
|
|
3079
|
+
Math.ceil(tile.scaling * width), Math.ceil(tile.scaling * height)
|
|
3080
|
+
);
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
|
|
3084
|
+
|
|
3085
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3086
|
+
/* Merging js: layermodel/VectorTileModel.js begins */
|
|
3087
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3088
|
+
|
|
3089
|
+
|
|
3090
|
+
export function VectorTileModel() {
|
|
3091
|
+
this.bounds = null;
|
|
3092
|
+
this.srs = null;
|
|
3093
|
+
this.maxZoomLevel = null;
|
|
3094
|
+
this.maxEnvelope = null;
|
|
3095
|
+
this.centerScale = null;
|
|
3096
|
+
this.animationCenterScale = null;
|
|
3097
|
+
this.envelope = null;
|
|
3098
|
+
this.animationEnvelope = null;
|
|
3099
|
+
this.layer = null;
|
|
3100
|
+
this.loader = null;
|
|
3101
|
+
this.protocol = "MVT";
|
|
3102
|
+
this.numResetRuns = 2;
|
|
3103
|
+
this.tileWidth = 256;
|
|
3104
|
+
this.tileHeight = 256;
|
|
3105
|
+
this.tiles = [];
|
|
3106
|
+
this.tileIndex = {};
|
|
3107
|
+
this.ctx = null; // Used only for tile models that draw on a canvas.
|
|
3108
|
+
|
|
3109
|
+
this.snoopMargin = 32;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
VectorTileModel.prototype = new TileModel();
|
|
3113
|
+
VectorTileModel.prototype.constructor = VectorTileModel;
|
|
3114
|
+
|
|
3115
|
+
VectorTileModel.prototype.createTile = function(minX, maxY, scale, tileX, tileY, tileWidth, tileHeight, url) {
|
|
3116
|
+
return new VectorTile(minX, maxY, scale, tileX, tileY, tileWidth, tileHeight, url);
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
VectorTileModel.prototype.tileNeedsReload = function(tile) { } // Set by component;
|
|
3120
|
+
|
|
3121
|
+
VectorTileModel.prototype.loadTileData = function(tile) { } // Set by component;
|
|
3122
|
+
|
|
3123
|
+
VectorTileModel.prototype.drawTileImage = function(tile, dx, dy, dWidth, dHeight, run) {
|
|
3124
|
+
if (run == 0) {
|
|
3125
|
+
this.ctx.drawImage(tile.data, dx, dy, dWidth, dHeight);
|
|
3126
|
+
} else if (tile.snoopData != null) {
|
|
3127
|
+
var scaledSnoopMargin = Math.round(tile.scaling * this.snoopMargin);
|
|
3128
|
+
this.ctx.drawImage(
|
|
3129
|
+
tile.snoopData,
|
|
3130
|
+
0, 0,
|
|
3131
|
+
tile.tileWidth + 2 * this.snoopMargin, tile.tileHeight + 2 * this.snoopMargin,
|
|
3132
|
+
dx - scaledSnoopMargin, dy - scaledSnoopMargin,
|
|
3133
|
+
dWidth + 2 * scaledSnoopMargin, dHeight + 2 * scaledSnoopMargin
|
|
3134
|
+
);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
VectorTileModel.prototype.drawTilePartly = function(tile, x, y, width, height) {
|
|
3139
|
+
this.ctx.drawImage(
|
|
3140
|
+
tile.data,
|
|
3141
|
+
x, y,
|
|
3142
|
+
width, height,
|
|
3143
|
+
Math.round(tile.x), Math.round(tile.y),
|
|
3144
|
+
Math.ceil(tile.scaling * width), Math.ceil(tile.scaling * height)
|
|
3145
|
+
);
|
|
3146
|
+
if (tile.snoopData != null) {
|
|
3147
|
+
this.ctx.drawImage(
|
|
3148
|
+
tile.snoopData,
|
|
3149
|
+
x + this.snoopMargin, y + this.snoopMargin,
|
|
3150
|
+
width, height,
|
|
3151
|
+
Math.round(tile.x), Math.round(tile.y),
|
|
3152
|
+
Math.ceil(tile.scaling * width), Math.ceil(tile.scaling * height)
|
|
3153
|
+
);
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
|
|
3159
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3160
|
+
/* Merging js: layermodel/UTFGridModel.js begins */
|
|
3161
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3162
|
+
|
|
3163
|
+
|
|
3164
|
+
export function UTFGridModel() {
|
|
3165
|
+
this.bounds = null;
|
|
3166
|
+
this.srs = null;
|
|
3167
|
+
this.maxZoomLevel = null;
|
|
3168
|
+
this.maxEnvelope = null;
|
|
3169
|
+
this.centerScale = null;
|
|
3170
|
+
this.animationCenterScale = null;
|
|
3171
|
+
this.envelope = null;
|
|
3172
|
+
this.animationEnvelope = null;
|
|
3173
|
+
this.layer = null;
|
|
3174
|
+
this.loader = null;
|
|
3175
|
+
this.protocol = "UTFGrid";
|
|
3176
|
+
this.numResetRuns = 1;
|
|
3177
|
+
this.tileWidth = 256;
|
|
3178
|
+
this.tileHeight = 256;
|
|
3179
|
+
this.tiles = [];
|
|
3180
|
+
this.tileIndex = {};
|
|
3181
|
+
this.ctx = null; // Not used for UTFGrid tile models.
|
|
3182
|
+
|
|
3183
|
+
this.resolution = 4;
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
UTFGridModel.prototype = new TileModel();
|
|
3187
|
+
UTFGridModel.prototype.constructor = UTFGridModel;
|
|
3188
|
+
|
|
3189
|
+
UTFGridModel.prototype.loadTileData = function(tile) {
|
|
3190
|
+
/*var f = function(t) {
|
|
3191
|
+
return function(data, status, headers, config) {
|
|
3192
|
+
t.data = eval(data);
|
|
3193
|
+
}
|
|
3194
|
+
}(tile);
|
|
3195
|
+
this.http({ method: "GET", url: tile.url, cache: true }).success(f);*/
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3198
|
+
UTFGridModel.prototype.getFeature = function(pixX, pixY) {
|
|
3199
|
+
var zoomLevel = this.srs.getZoomLevel(this.animationCenterScale.scale, this.maxZoomLevel);
|
|
3200
|
+
var worldX = this.animationCenterScale.getWorldX(this.bounds.width, pixX);
|
|
3201
|
+
var worldY = this.animationCenterScale.getWorldY(this.bounds.height, pixY);
|
|
3202
|
+
var tileX = Math.floor((worldX - this.srs.minX) / zoomLevel.resolution / this.tileWidth);
|
|
3203
|
+
var tileY = Math.max(Math.floor((this.srs.maxY - worldY) / zoomLevel.resolution / this.tileHeight), 0);
|
|
3204
|
+
var tile = this.getTile(zoomLevel.zoomLevel, tileX, tileY);
|
|
3205
|
+
if (tile == null) {
|
|
3206
|
+
return null;
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
var utfGrid = tile.data;
|
|
3210
|
+
if (utfGrid == null) {
|
|
3211
|
+
return null;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
var xInTile = Math.floor((pixX - tile.x) / tile.scaling / this.resolution);
|
|
3215
|
+
var yInTile = Math.floor((pixY - tile.y) / tile.scaling / this.resolution);
|
|
3216
|
+
if (utfGrid.grid[yInTile] == null) {
|
|
3217
|
+
return null;
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
var index = this.getIndex(utfGrid.grid[yInTile].charCodeAt(xInTile));
|
|
3221
|
+
var key = utfGrid.keys[index];
|
|
3222
|
+
if (!utfGrid.data.hasOwnProperty(key)) {
|
|
3223
|
+
return null;
|
|
3224
|
+
}
|
|
3225
|
+
|
|
3226
|
+
return utfGrid.data[key];
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
UTFGridModel.prototype.getIndex = function(utfCode) {
|
|
3230
|
+
if (utfCode >= 93) {
|
|
3231
|
+
utfCode--;
|
|
3232
|
+
}
|
|
3233
|
+
if (utfCode >= 35) {
|
|
3234
|
+
utfCode--;
|
|
3235
|
+
}
|
|
3236
|
+
return utfCode - 32;
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
function grid(utfGridString) {
|
|
3240
|
+
return utfGridString;
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
|
|
3245
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3246
|
+
/* Merging js: layermodel/WMSInfo.js begins */
|
|
3247
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
export function WMSInfo(x, y) {
|
|
3251
|
+
this.x = x;
|
|
3252
|
+
this.y = y;
|
|
3253
|
+
this.value = null;
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
|
|
3258
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3259
|
+
/* Merging js: layermodel/WMSModel.js begins */
|
|
3260
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
export function WMSModel() {
|
|
3264
|
+
this.bounds = null;
|
|
3265
|
+
this.incubationBounds = null;
|
|
3266
|
+
this.srs = null;
|
|
3267
|
+
this.centerScale = null;
|
|
3268
|
+
this.animationCenterScale = null;
|
|
3269
|
+
this.layer = null;
|
|
3270
|
+
this.loader = null;
|
|
3271
|
+
this.autoClassification = true;
|
|
3272
|
+
this.info = null;
|
|
3273
|
+
this.tile = null;
|
|
3274
|
+
this.previousTile = null;
|
|
3275
|
+
this.ctx = null;
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
WMSModel.prototype.setBounds = function(bounds) {
|
|
3279
|
+
if ((bounds == null) || (bounds.equals(this.bounds))) {
|
|
3280
|
+
return;
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
this.bounds = bounds;
|
|
3284
|
+
this.resetTiles();
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
WMSModel.prototype.setIncubationBounds = function(incubationBounds) {
|
|
3288
|
+
this.incubationBounds = incubationBounds;
|
|
3289
|
+
this.load();
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
WMSModel.prototype.setCenterScale = function(centerScale) {
|
|
3293
|
+
this.centerScale = centerScale;
|
|
3294
|
+
this.load();
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
WMSModel.prototype.setAnimationCenterScale = function(animationCenterScale) {
|
|
3298
|
+
this.animationCenterScale = animationCenterScale;
|
|
3299
|
+
this.resetTiles();
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
WMSModel.prototype.setLayer = function(layer) {
|
|
3303
|
+
if ((this.loader != null) && (this.layer != null)) {
|
|
3304
|
+
this.loader.remove(this.layer.name);
|
|
3305
|
+
}
|
|
3306
|
+
if ((this.loader != null) && (layer != null)) {
|
|
3307
|
+
this.loader.reset(layer.name);
|
|
3308
|
+
}
|
|
3309
|
+
this.layer = layer;
|
|
3310
|
+
this.tile = null;
|
|
3311
|
+
this.previousTile = null;
|
|
3312
|
+
this.load();
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
WMSModel.prototype.load = function(infoOnly) {
|
|
3316
|
+
if (this.bounds == null) {
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
if (this.centerScale == null) {
|
|
3320
|
+
return;
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
if (this.info != null) {
|
|
3324
|
+
this.info.value = null;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
if (!infoOnly) {
|
|
3328
|
+
if ((this.tile != null) && this.tile.completed && !this.tile.corrupted) {
|
|
3329
|
+
this.previousTile = this.tile;
|
|
3330
|
+
}
|
|
3331
|
+
this.tile = null;
|
|
3332
|
+
|
|
3333
|
+
if (this.ctx != null) {
|
|
3334
|
+
this.ctx.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
if ((this.layer == null) || (!this.layer.visible)) {
|
|
3339
|
+
return;
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
var envelope = this.centerScale.toEnvelope(this.bounds.width, this.bounds.height);
|
|
3343
|
+
var minX = envelope.minX;
|
|
3344
|
+
var minY = envelope.minY;
|
|
3345
|
+
var maxX = envelope.maxX;
|
|
3346
|
+
var maxY = envelope.maxY;
|
|
3347
|
+
|
|
3348
|
+
if ((minX > this.srs.maxX) || (minY > this.srs.maxY) || (maxX < this.srs.minX) || (maxY < this.srs.minY)) {
|
|
3349
|
+
return;
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
minX = Math.max(minX, this.srs.minX);
|
|
3353
|
+
minY = Math.max(minY, this.srs.minY);
|
|
3354
|
+
maxX = Math.min(maxX, this.srs.maxX);
|
|
3355
|
+
maxY = Math.min(maxY, this.srs.maxY);
|
|
3356
|
+
|
|
3357
|
+
var tileWidth = Math.round(this.centerScale.getNumPixs(maxX - minX));
|
|
3358
|
+
var tileHeight = Math.round(this.centerScale.getNumPixs(maxY - minY));
|
|
3359
|
+
|
|
3360
|
+
if (this.info != null) {
|
|
3361
|
+
var f = function(info) {
|
|
3362
|
+
return function() {
|
|
3363
|
+
if ((xhr.readyState == 4) && (xhr.status == 200)) {
|
|
3364
|
+
info.value = xhr.responseText;
|
|
3365
|
+
}
|
|
3366
|
+
};
|
|
3367
|
+
}(this.info);
|
|
3368
|
+
var x = Math.round(this.info.x - this.centerScale.getPixX(this.bounds.width, minX));
|
|
3369
|
+
var y = Math.round(this.info.y - this.centerScale.getPixY(this.bounds.height, maxY));
|
|
3370
|
+
var url = WMSProtocol.getMapURL(this.layer, this.srs, minX, minY, maxX, maxY, tileWidth, tileHeight, this.autoClassification, { x: x, y: y });
|
|
3371
|
+
var xhr = new XMLHttpRequest();
|
|
3372
|
+
xhr.open("GET", url);
|
|
3373
|
+
xhr.onreadystatechange = f;
|
|
3374
|
+
xhr.send();
|
|
3375
|
+
}
|
|
3376
|
+
|
|
3377
|
+
if (!infoOnly) {
|
|
3378
|
+
var url = WMSProtocol.getMapURL(this.layer, this.srs, minX, minY, maxX, maxY, tileWidth, tileHeight, this.autoClassification, null);
|
|
3379
|
+
|
|
3380
|
+
if (this.loader != null) {
|
|
3381
|
+
this.loader.set(this.layer.name);
|
|
3382
|
+
}
|
|
3383
|
+
this.tile = new Tile(minX, maxY, this.centerScale.scale, 1, 1, tileWidth, tileHeight, url);
|
|
3384
|
+
|
|
3385
|
+
if (this.animationCenterScale != null) {
|
|
3386
|
+
this.tile.reset(this.bounds, this.animationCenterScale);
|
|
3387
|
+
if (this.previousTile != null) {
|
|
3388
|
+
this.previousTile.reset(this.bounds, this.animationCenterScale);
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
if (this.ctx != null) {
|
|
3393
|
+
if (this.previousTile != null) {
|
|
3394
|
+
this.drawTile(this.previousTile);
|
|
3395
|
+
}
|
|
3396
|
+
|
|
3397
|
+
var f = function(t, env, success) { return function() { env.completeTile(t, success); }};
|
|
3398
|
+
this.tile.data = new Image();
|
|
3399
|
+
this.tile.data.addEventListener("load", f(this.tile, this, true));
|
|
3400
|
+
this.tile.data.addEventListener("error", f(this.tile, this, false));
|
|
3401
|
+
|
|
3402
|
+
const tile = this.tile;
|
|
3403
|
+
const postBody = WMSProtocol.getPostBody(this.layer);
|
|
3404
|
+
if (postBody == null) {
|
|
3405
|
+
tile.data.src = tile.url;
|
|
3406
|
+
} else {
|
|
3407
|
+
fetch(tile.url, {
|
|
3408
|
+
method: "POST",
|
|
3409
|
+
headers: {"Content-Type": "application/x-www-form-urlencoded"},
|
|
3410
|
+
body: postBody
|
|
3411
|
+
})
|
|
3412
|
+
.then(response => {
|
|
3413
|
+
if (!response.ok) {
|
|
3414
|
+
this.completeTile(tile, false);
|
|
3415
|
+
}
|
|
3416
|
+
return response.blob();
|
|
3417
|
+
})
|
|
3418
|
+
.then(blob => {
|
|
3419
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
3420
|
+
tile.data.addEventListener("load", () => URL.revokeObjectURL(objectUrl), { once: true });
|
|
3421
|
+
tile.data.addEventListener("error", () => URL.revokeObjectURL(objectUrl), { once: true });
|
|
3422
|
+
tile.data.src = objectUrl;
|
|
3423
|
+
})
|
|
3424
|
+
.catch(() => {
|
|
3425
|
+
this.completeTile(tile, false);
|
|
3426
|
+
});
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
WMSModel.prototype.resetTiles = function() {
|
|
3433
|
+
if (this.bounds == null) {
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
if (this.animationCenterScale == null) {
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
if (this.tile != null) {
|
|
3441
|
+
this.tile.reset(this.bounds, this.animationCenterScale);
|
|
3442
|
+
if (this.previousTile != null) {
|
|
3443
|
+
this.previousTile.reset(this.bounds, this.animationCenterScale);
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
if (this.ctx != null) {
|
|
3448
|
+
this.ctx.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
|
3449
|
+
if (this.tile != null) {
|
|
3450
|
+
if (this.tile.completed && !this.tile.corrupted) {
|
|
3451
|
+
this.drawTile(this.tile);
|
|
3452
|
+
} else if (this.previousTile != null) {
|
|
3453
|
+
this.drawTile(this.previousTile);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
WMSModel.prototype.completeTile = function(tile, success) {
|
|
3460
|
+
if (this.tile != tile) {
|
|
3461
|
+
return;
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
if (this.loader != null) {
|
|
3465
|
+
this.loader.reset(this.layer.name);
|
|
3466
|
+
}
|
|
3467
|
+
tile.completed = true;
|
|
3468
|
+
|
|
3469
|
+
if (success) {
|
|
3470
|
+
tile.corrupted = false;
|
|
3471
|
+
|
|
3472
|
+
this.previousTile = null;
|
|
3473
|
+
|
|
3474
|
+
if (this.animationCenterScale != null) {
|
|
3475
|
+
tile.reset(this.bounds, this.animationCenterScale);
|
|
3476
|
+
if (this.ctx != null) {
|
|
3477
|
+
this.ctx.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
|
3478
|
+
this.drawTile(tile);
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
} else {
|
|
3482
|
+
tile.corrupted = performance.now();
|
|
3483
|
+
|
|
3484
|
+
console.log("Error loading WMS: " + tile.url);
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
|
|
3488
|
+
WMSModel.prototype.drawTile = function(tile) {
|
|
3489
|
+
this.ctx.drawImage(
|
|
3490
|
+
tile.data,
|
|
3491
|
+
Math.round(tile.x), Math.round(tile.y),
|
|
3492
|
+
Math.round(tile.scaling * tile.tileWidth), Math.round(tile.scaling * tile.tileHeight)
|
|
3493
|
+
);
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
|
|
3497
|
+
|
|
3498
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3499
|
+
/* Merging js: layermodel/MapFeatureModel.js begins */
|
|
3500
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3501
|
+
|
|
3502
|
+
|
|
3503
|
+
export function MapFeatureModel() {
|
|
3504
|
+
this.bounds = null;
|
|
3505
|
+
this.centerScale = null;
|
|
3506
|
+
this.envelope = null;
|
|
3507
|
+
this.features = null;
|
|
3508
|
+
this.geometries = null;
|
|
3509
|
+
this.geometry = null;
|
|
3510
|
+
|
|
3511
|
+
this.animating = false;
|
|
3512
|
+
|
|
3513
|
+
this.animate = true;
|
|
3514
|
+
this.filter = null;
|
|
3515
|
+
this.maxScale = Number.MAX_VALUE;
|
|
3516
|
+
this.envelopeCheck = false;
|
|
3517
|
+
this.propertyIndex = -1;
|
|
3518
|
+
this.idPropertyName = "id";
|
|
3519
|
+
this.geometryPropertyName = "geometry";
|
|
3520
|
+
this.includePoints = false;
|
|
3521
|
+
this.fillRule = "evenodd";
|
|
3522
|
+
this.ctxShared = false;
|
|
3523
|
+
this.cssFunction = null;
|
|
3524
|
+
this.label = false;
|
|
3525
|
+
|
|
3526
|
+
this.patterns = null;
|
|
3527
|
+
this.ctx = null;
|
|
3528
|
+
this.ctxHasSnoopMargin = false;
|
|
3529
|
+
this.style = null;
|
|
3530
|
+
|
|
3531
|
+
this.inverseFillPath = "";
|
|
3532
|
+
this.glShaderCenter = null;
|
|
3533
|
+
this.glShaderScale = null;
|
|
3534
|
+
|
|
3535
|
+
this.filterFeatures = [];
|
|
3536
|
+
this.vertices = [];
|
|
3537
|
+
this.mapFeatures = [];
|
|
3538
|
+
this.nonPointGeometries = [];
|
|
3539
|
+
this.points = [];
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
MapFeatureModel.prototype.setFilter = function(filterExpression) {
|
|
3543
|
+
this.filter = null;
|
|
3544
|
+
if (filterExpression != null) {
|
|
3545
|
+
var match = filterExpression.match(/(\[(\d+)\]|[\w\.]*)\s*([=<>]=)\s*(.*)/); // Does not support IN operator.
|
|
3546
|
+
if (match[2] != null) {
|
|
3547
|
+
this.filter = new Filter(parseInt(match[2]), match[4], match[3]); // propertyIndex
|
|
3548
|
+
} else {
|
|
3549
|
+
this.filter = new Filter(match[1], match[4], match[3]); // propertyName
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
MapFeatureModel.prototype.setBounds = function(bounds) {
|
|
3555
|
+
this.bounds = bounds;
|
|
3556
|
+
this.setMapFeatures();
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
MapFeatureModel.prototype.setCenterScale = function(centerScale) {
|
|
3560
|
+
this.centerScale = centerScale;
|
|
3561
|
+
this.setMapFeatures();
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
MapFeatureModel.prototype.setFeatures = function(features) {
|
|
3565
|
+
this.features = features;
|
|
3566
|
+
this.filterFeatures = [];
|
|
3567
|
+
|
|
3568
|
+
if (features == null) {
|
|
3569
|
+
return;
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3572
|
+
for (var i = 0; i < features.length; i++) {
|
|
3573
|
+
var feature = features[i];
|
|
3574
|
+
if (feature.propertyValues != null) { // Feature from a feature model.
|
|
3575
|
+
var id = i;
|
|
3576
|
+
var geometry = feature.propertyValues[
|
|
3577
|
+
(feature.propertyValues.length + this.propertyIndex) % feature.propertyValues.length
|
|
3578
|
+
];
|
|
3579
|
+
if ((geometry != null) && (
|
|
3580
|
+
(this.filter == null) || (this.filter.propertyIndex == null) ||
|
|
3581
|
+
(feature.propertyValues[this.filter.propertyIndex] == this.filter.value)
|
|
3582
|
+
)) {
|
|
3583
|
+
this.filterFeatures.push({id: id, geometry: geometry, feature: feature});
|
|
3584
|
+
}
|
|
3585
|
+
} else { // POJO feature.
|
|
3586
|
+
var geometries = getFeatureValues(feature, this.geometryPropertyName);
|
|
3587
|
+
if (geometries[0] == null) {
|
|
3588
|
+
continue;
|
|
3589
|
+
}
|
|
3590
|
+
var ids = getFeatureValues(feature, this.idPropertyName);
|
|
3591
|
+
if ((ids[0] == null) || (ids.length != geometries.length)) {
|
|
3592
|
+
ids = null;
|
|
3593
|
+
}
|
|
3594
|
+
var filterValues = null;
|
|
3595
|
+
if ((this.filter != null) && (this.filter.propertyName != null) && (this.filter.propertyName != "")) {
|
|
3596
|
+
filterValues = getFeatureValues(feature, this.filter.propertyName);
|
|
3597
|
+
if (filterValues.length != geometries.length) {
|
|
3598
|
+
continue;
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3602
|
+
for (var j = 0; j < geometries.length; j++) {
|
|
3603
|
+
if ((this.filter != null) && (this.filter.propertyName != null) && (
|
|
3604
|
+
((this.filter.propertyName == "") && (this.filter.operator == FilterModel.EQUALS) && (i != this.filter.value)) || // e.g. "== 0", the first feature
|
|
3605
|
+
((this.filter.propertyName == "") && (this.filter.operator == FilterModel.LESS_OR_EQUALS) && !(i <= this.filter.value)) || // e.g. "<= 2", the first 3 features
|
|
3606
|
+
((this.filter.propertyName == "") && (this.filter.operator == FilterModel.GREATER_OR_EQUALS) && !(i >= this.filter.value)) || // e.g. ">= 6", all features, except first 5
|
|
3607
|
+
((this.filter.propertyName != "") && (this.filter.operator == FilterModel.EQUALS) && (filterValues[j] != this.filter.value)) || // e.g. "foo == bar"
|
|
3608
|
+
((this.filter.propertyName != "") && (this.filter.operator == FilterModel.LESS_OR_EQUALS) && !(filterValues[j] <= this.filter.value)) || // e.g. "foo <= bar"
|
|
3609
|
+
((this.filter.propertyName != "") && (this.filter.operator == FilterModel.GREATER_OR_EQUALS) && !(filterValues[j] >= this.filter.value)) || // e.g. "foo >= bar"
|
|
3610
|
+
((this.filter.propertyName != "") && (this.filter.operator == FilterModel.IN) && !this.filter.value.includes(filterValues[j])) // e.g. "foo IN [bar]"
|
|
3611
|
+
)) {
|
|
3612
|
+
continue;
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
this.filterFeatures.push({
|
|
3616
|
+
id: (ids != null)? ids[j]: (i + "-" + j),
|
|
3617
|
+
geometry: geometries[j],
|
|
3618
|
+
feature: feature
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
function getFeatureValues(feature, propertyName) {
|
|
3625
|
+
var propertyNameParts = propertyName.split(".");
|
|
3626
|
+
var featureBranches = [feature];
|
|
3627
|
+
while ((propertyNameParts.length > 0) && (featureBranches[0] != null)) {
|
|
3628
|
+
var propertyNamePart = propertyNameParts.shift();
|
|
3629
|
+
var nextBranches = [];
|
|
3630
|
+
for (var i = 0; i < featureBranches.length; i++) {
|
|
3631
|
+
var nextBranch = featureBranches[i][propertyNamePart];
|
|
3632
|
+
if (!Array.isArray(nextBranch)) {
|
|
3633
|
+
nextBranches.push(nextBranch);
|
|
3634
|
+
} else {
|
|
3635
|
+
for (var j = 0; j < nextBranch.length; j++) {
|
|
3636
|
+
nextBranches.push(nextBranch[j]);
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
featureBranches = nextBranches;
|
|
3641
|
+
}
|
|
3642
|
+
return featureBranches;
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
if (this.ctx instanceof WebGLRenderingContext) {
|
|
3646
|
+
this.setVertices();
|
|
3647
|
+
}
|
|
3648
|
+
this.setMapFeatures();
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
MapFeatureModel.prototype.setGeometries = function(geometries) {
|
|
3652
|
+
this.geometries = geometries;
|
|
3653
|
+
|
|
3654
|
+
if (this.ctx instanceof WebGLRenderingContext) {
|
|
3655
|
+
this.setVertices();
|
|
3656
|
+
}
|
|
3657
|
+
this.setMapFeatures();
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
MapFeatureModel.prototype.setGeometry = function(geometry) {
|
|
3661
|
+
this.geometry = geometry;
|
|
3662
|
+
|
|
3663
|
+
if (this.ctx instanceof WebGLRenderingContext) {
|
|
3664
|
+
this.setVertices();
|
|
3665
|
+
}
|
|
3666
|
+
this.setMapFeatures();
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
MapFeatureModel.prototype.setAnimating = function(animating) {
|
|
3670
|
+
this.animating = animating;
|
|
3671
|
+
if (!this.animate) {
|
|
3672
|
+
this.setMapFeatures();
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
MapFeatureModel.prototype.setVertices = function() { // Only works with point geometries.
|
|
3677
|
+
this.vertices = [];
|
|
3678
|
+
var graphicSize = parseFloat(this.style.getPropertyValue("--graphic-size") || 8);
|
|
3679
|
+
|
|
3680
|
+
if (this.features != null) {
|
|
3681
|
+
for (var i = 0; i < this.filterFeatures.length; i++) {
|
|
3682
|
+
this.vertices.push(this.filterFeatures[i].geometry.x);
|
|
3683
|
+
this.vertices.push(this.filterFeatures[i].geometry.y);
|
|
3684
|
+
|
|
3685
|
+
if (this.cssFunction != null) {
|
|
3686
|
+
var css = {};
|
|
3687
|
+
this.cssFunction(css, this.filterFeatures[i]);
|
|
3688
|
+
if (css.graphicSize != null) {
|
|
3689
|
+
this.vertices.push(Math.min(css.graphicSize, graphicSize) / graphicSize);
|
|
3690
|
+
} else {
|
|
3691
|
+
this.vertices.push(1);
|
|
3692
|
+
}
|
|
3693
|
+
} else {
|
|
3694
|
+
this.vertices.push(1);
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
} else if (this.geometries != null) {
|
|
3698
|
+
for (var i = 0; i < this.geometries.length; i++) {
|
|
3699
|
+
this.vertices.push(this.geometries[i].x);
|
|
3700
|
+
this.vertices.push(this.geometries[i].y);
|
|
3701
|
+
this.vertices.push(1);
|
|
3702
|
+
}
|
|
3703
|
+
} else { // this.geometry != null
|
|
3704
|
+
this.vertices.push(this.geometry.x);
|
|
3705
|
+
this.vertices.push(this.geometry.y);
|
|
3706
|
+
this.vertices.push(1);
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3709
|
+
//console.log("Number of points: " + (this.vertices.length / 3));
|
|
3710
|
+
this.ctx.bufferData(this.ctx.ARRAY_BUFFER, new Float32Array(this.vertices), this.ctx.STATIC_DRAW);
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3713
|
+
MapFeatureModel.prototype.setMapFeatures = function() {
|
|
3714
|
+
if (this.bounds == null) {
|
|
3715
|
+
return;
|
|
3716
|
+
}
|
|
3717
|
+
if (this.centerScale == null) {
|
|
3718
|
+
return;
|
|
3719
|
+
}
|
|
3720
|
+
if ((this.envelope == null) && this.envelopeCheck) {
|
|
3721
|
+
return;
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
if (this.ctx instanceof WebGLRenderingContext) {
|
|
3725
|
+
this.ctx.viewport(0, 0, this.bounds.width, this.bounds.height);
|
|
3726
|
+
//this.ctx.clearColor(0, 0, 0, 0);
|
|
3727
|
+
//this.ctx.clear(this.ctx.COLOR_BUFFER_BIT);
|
|
3728
|
+
} else if (this.ctx != null) {
|
|
3729
|
+
if (!this.ctxShared) {
|
|
3730
|
+
this.ctx.setTransform(1, 0, 0, 1, 0, 0); // ctx.resetTransform();
|
|
3731
|
+
this.ctx.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
|
3732
|
+
}
|
|
3733
|
+
} else {
|
|
3734
|
+
this.mapFeatures = [];
|
|
3735
|
+
this.nonPointGeometries = [];
|
|
3736
|
+
this.points = [];
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3739
|
+
if ((this.features == null) && (this.geometries == null) && (this.geometry == null)) {
|
|
3740
|
+
return;
|
|
3741
|
+
}
|
|
3742
|
+
if (!this.animate && this.animating) {
|
|
3743
|
+
return;
|
|
3744
|
+
}
|
|
3745
|
+
if (this.maxScale < this.centerScale.scale) {
|
|
3746
|
+
return;
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
if (this.ctx instanceof WebGLRenderingContext) {
|
|
3750
|
+
this.ctx.uniform4f(this.glShaderCenter, this.centerScale.centerX, this.centerScale.centerY, 0, 0);
|
|
3751
|
+
this.ctx.uniform4f(this.glShaderScale, this.centerScale.getNumWorldCoords(this.bounds.width) / 2, this.centerScale.getNumWorldCoords(this.bounds.height) / 2, 1, 1);
|
|
3752
|
+
|
|
3753
|
+
this.ctx.drawArrays(this.ctx.POINTS, 0, this.vertices.length / 3);
|
|
3754
|
+
return;
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3757
|
+
var css = {};
|
|
3758
|
+
if (this.ctx != null) {
|
|
3759
|
+
var scaling = this.centerScale.getNumPixs(1);
|
|
3760
|
+
var yFactor = this.centerScale.yFactor;
|
|
3761
|
+
var dx = this.bounds.width / 2 - this.centerScale.centerX * scaling;
|
|
3762
|
+
var dy = this.bounds.height / 2 - this.centerScale.centerY * scaling * yFactor;
|
|
3763
|
+
this.ctx.setTransform(scaling, 0, 0, scaling * yFactor, dx, dy);
|
|
3764
|
+
|
|
3765
|
+
if (this.style.getPropertyValue("fill").match(/^url/))
|
|
3766
|
+
(this.ctx.fillStyle = css.fill = this.patterns[this.style.getPropertyValue("fill")]).setTransform({a: 1 / scaling, b: 0, c: 0, d: 1 / scaling, e: 0, f: 0});
|
|
3767
|
+
else
|
|
3768
|
+
this.ctx.fillStyle = css.fill = this.style.getPropertyValue("fill");
|
|
3769
|
+
this.ctx.strokeStyle = css.stroke = this.style.getPropertyValue("stroke");
|
|
3770
|
+
this.ctx.lineWidth = css.scaledStrokeWidth = (css.strokeWidth = parseFloat(this.style.getPropertyValue("stroke-width").replace(/^([\d.]{4})[\d]+/, "$1"))) / scaling; // Max significance of 3, e.g. 1.25 or 12.5 or 10.
|
|
3771
|
+
if (this.style.getPropertyValue("stroke-dasharray") != "none")
|
|
3772
|
+
this.ctx.setLineDash( css.scaledStrokeDasharray = (css.strokeDasharray = this.style.getPropertyValue("stroke-dasharray").split(/[, ]+/).map(a => parseFloat(a))).map(a => a / scaling));
|
|
3773
|
+
this.ctx.lineCap = css.strokeLinecap = this.style.getPropertyValue("stroke-linecap");
|
|
3774
|
+
this.ctx.lineJoin = css.strokeLinejoin = this.style.getPropertyValue("stroke-linejoin");
|
|
3775
|
+
/* Will be */ css.strokeFilter = this.style.getPropertyValue("--stroke-filter") || "none";
|
|
3776
|
+
/* applied */ css.scaledGraphicSize = (css.graphicSize = parseFloat(this.style.getPropertyValue("--graphic-size") || 8) + 1) / scaling;
|
|
3777
|
+
/* to ctx */ css.inverseFill = this.ctxHasSnoopMargin? false: !!parseInt(this.style.getPropertyValue("--inverse-fill") || 0);
|
|
3778
|
+
/* in */ css.confineFill = !!parseInt(this.style.getPropertyValue("--confine-fill") || 0);
|
|
3779
|
+
/* due time. */ css.scaledConfineFillWidth = (css.confineFillWidth = parseFloat(this.style.getPropertyValue("stroke-width").replace(/^[\d.]{1,4}|px$/g, "") || 12)) / scaling; // No decimal point allowed. No trailing zero allowed, e.g. 10 must be 9 or 11.
|
|
3780
|
+
this.ctx.font = (css.scaledFontSize = (css.fontSize = parseFloat(this.style.getPropertyValue("font-size"))) / scaling) + "px "
|
|
3781
|
+
+ (css.fontFamily = this.style.getPropertyValue("font-family"));
|
|
3782
|
+
this.ctx.textAlign = "center";
|
|
3783
|
+
this.ctx.textBaseline = "middle";
|
|
3784
|
+
|
|
3785
|
+
this.startInverseFill(css);
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
if (this.features != null) {
|
|
3789
|
+
for (var i = 0; i < this.filterFeatures.length; i++) {
|
|
3790
|
+
if (this.cssFunction != null) { // Implies a canvas.
|
|
3791
|
+
var scaling = this.centerScale.getNumPixs(1);
|
|
3792
|
+
this.cssFunction(css, this.filterFeatures[i], scaling);
|
|
3793
|
+
|
|
3794
|
+
if (css.fill instanceof CanvasPattern)
|
|
3795
|
+
(this.ctx.fillStyle = css.fill).setTransform({a: 1 / scaling, b: 0, c: 0, d: 1 / scaling, e: 0, f: 0});
|
|
3796
|
+
else
|
|
3797
|
+
this.ctx.fillStyle = css.fill;
|
|
3798
|
+
this.ctx.strokeStyle = css.stroke;
|
|
3799
|
+
this.ctx.lineWidth = css.scaledStrokeWidth = parseFloat(css.strokeWidth) / scaling;
|
|
3800
|
+
if (css.strokeDasharray != null)
|
|
3801
|
+
this.ctx.setLineDash( css.scaledStrokeDasharray = css.strokeDasharray.map(a => parseFloat(a) / scaling));
|
|
3802
|
+
this.ctx.lineCap = css.strokeLinecap;
|
|
3803
|
+
this.ctx.lineJoin = css.strokeLinejoin;
|
|
3804
|
+
css.scaledGraphicSize = parseFloat(css.graphicSize) / scaling;
|
|
3805
|
+
this.ctx.font = (css.scaledFontSize = parseFloat(css.fontSize) / scaling) + "px " + css.fontFamily;
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
this.assignGeometry(this.filterFeatures[i], this.filterFeatures[i].geometry, css);
|
|
3809
|
+
}
|
|
3810
|
+
} else if (this.geometries != null) {
|
|
3811
|
+
for (var i = 0; i < this.geometries.length; i++) {
|
|
3812
|
+
this.assignGeometry(null, this.geometries[i], css);
|
|
3813
|
+
}
|
|
3814
|
+
} else { // this.geometry != null
|
|
3815
|
+
this.assignGeometry(null, this.geometry, css);
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
if (this.ctx != null) {
|
|
3819
|
+
this.completeInverseFill(css);
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
|
|
3823
|
+
MapFeatureModel.prototype.startInverseFill = function(css) {
|
|
3824
|
+
if (!css.inverseFill) {
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
var t = this.ctx.getTransform();
|
|
3829
|
+
var c = this.ctx.canvas;
|
|
3830
|
+
var envelope = (new Envelope(-t.e / t.a, -(t.f - c.height) / t.d, -(t.e - c.width) / t.a, -t.f / t.d)).grow(1.1);
|
|
3831
|
+
var path = "M" + envelope.minX + " " + envelope.maxY + " H" + envelope.maxX + " V" + envelope.minY + " H" + envelope.minX + " Z ";
|
|
3832
|
+
if (!css.confineFill) {
|
|
3833
|
+
this.inverseFillPath = path;
|
|
3834
|
+
} else {
|
|
3835
|
+
this.ctx.fill(new Path2D(path), this.fillRule);
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
|
|
3839
|
+
MapFeatureModel.prototype.assignGeometry = function(mapFeature, geometry, css) {
|
|
3840
|
+
if (css.visibility == "hidden") {
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
if (this.envelopeCheck && !geometry.intersects(this.envelope)) {
|
|
3844
|
+
return;
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3847
|
+
if (mapFeature != null) {
|
|
3848
|
+
if (this.ctx != null) {
|
|
3849
|
+
} else {
|
|
3850
|
+
this.mapFeatures.push(mapFeature);
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
|
|
3854
|
+
if (!(geometry instanceof Geometry)) { // geometry is a path string that renders on a (transformed) canvas.
|
|
3855
|
+
this.drawPath(geometry, css);
|
|
3856
|
+
} else if (geometry instanceof Point) {
|
|
3857
|
+
if (this.ctx != null) {
|
|
3858
|
+
this.ctx.beginPath();
|
|
3859
|
+
if (css.rectWidth) {
|
|
3860
|
+
var scaling = this.centerScale.getNumPixs(1);
|
|
3861
|
+
var scaledOffsetX = css.offsetX / scaling;
|
|
3862
|
+
var scaledRectWidth = css.rectWidth / scaling;
|
|
3863
|
+
var scaledRectHeight = css.rectHeight / scaling;
|
|
3864
|
+
this.ctx.rect(geometry.x + scaledOffsetX, geometry.y, scaledRectWidth, scaledRectHeight);
|
|
3865
|
+
} else {
|
|
3866
|
+
this.ctx.arc(geometry.x, geometry.y, css.scaledGraphicSize / 2, 0, 2 * Math.PI);
|
|
3867
|
+
}
|
|
3868
|
+
this.ctx.fill();
|
|
3869
|
+
this.ctx.filter = css.strokeFilter;
|
|
3870
|
+
this.ctx.stroke();
|
|
3871
|
+
this.ctx.filter = "none";
|
|
3872
|
+
} else {
|
|
3873
|
+
this.points.push(geometry);
|
|
3874
|
+
}
|
|
3875
|
+
} else if ((geometry instanceof LineString) || (geometry instanceof Polygon) || (geometry instanceof Envelope)) {
|
|
3876
|
+
if (this.ctx != null) {
|
|
3877
|
+
var path = (new SVGConverter()).geometryToWorldPath(geometry);
|
|
3878
|
+
this.drawPath(path, css);
|
|
3879
|
+
} else {
|
|
3880
|
+
this.nonPointGeometries.push(geometry);
|
|
3881
|
+
if (this.includePoints) {
|
|
3882
|
+
Array.prototype.push.apply(this.points, geometry.getPoints());
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
} else { // Multi-geometry or geometry collection.
|
|
3886
|
+
for (var i = 0; i < geometry.childGeometries.length; i++) {
|
|
3887
|
+
this.assignGeometry(null, geometry.childGeometries[i], css);
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3892
|
+
MapFeatureModel.prototype.completeInverseFill = function(css) {
|
|
3893
|
+
if (!css.inverseFill) {
|
|
3894
|
+
return;
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
if (!css.confineFill) {
|
|
3898
|
+
this.drawPath(this.inverseFillPath, css, true);
|
|
3899
|
+
this.inverseFillPath = "";
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
MapFeatureModel.prototype.drawPath = function(path, css, last) {
|
|
3904
|
+
if (this.label) {
|
|
3905
|
+
this.drawText(css);
|
|
3906
|
+
return;
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
if (css.inverseFill && !css.confineFill && !last) {
|
|
3910
|
+
this.inverseFillPath += path;
|
|
3911
|
+
return;
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3914
|
+
var stroke = !this.ctxShared? new Path2D(path): new Path2D(path.replace(/K/g, "M").replace(/Z/g, ""));
|
|
3915
|
+
if (css.fill != "none") {
|
|
3916
|
+
if (!css.confineFill) {
|
|
3917
|
+
var fill = !this.ctxShared? stroke: new Path2D(path.replace(/K/g, "L"));
|
|
3918
|
+
this.ctx.fill(fill, this.fillRule);
|
|
3919
|
+
} else if (!css.inverseFill) {
|
|
3920
|
+
var backupStyles = {strokeStyle: this.ctx.strokeStyle, lineWidth: this.ctx.lineWidth};
|
|
3921
|
+
this.ctx.strokeStyle = css.fill;
|
|
3922
|
+
this.ctx.lineWidth = css.scaledConfineFillWidth;
|
|
3923
|
+
this.ctx.stroke(stroke);
|
|
3924
|
+
Object.assign(this.ctx, backupStyles);
|
|
3925
|
+
}
|
|
3926
|
+
}
|
|
3927
|
+
this.ctx.filter = css.strokeFilter;
|
|
3928
|
+
this.ctx.stroke(stroke);
|
|
3929
|
+
this.ctx.filter = "none";
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
MapFeatureModel.prototype.drawText = function(css) {
|
|
3933
|
+
if ((css.labelText == null) || (css.labelPoint == null)) {
|
|
3934
|
+
return;
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
this.ctx.strokeText(css.labelText, css.labelPoint.x, css.labelPoint.y);
|
|
3938
|
+
this.ctx.fillText(css.labelText, css.labelPoint.x, css.labelPoint.y);
|
|
3939
|
+
}
|
|
3940
|
+
|
|
3941
|
+
|
|
3942
|
+
|
|
3943
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3944
|
+
/* Merging js: layermodel/protocols/WMSProtocol.js begins */
|
|
3945
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
3946
|
+
|
|
3947
|
+
|
|
3948
|
+
export function WMSProtocol() { }
|
|
3949
|
+
|
|
3950
|
+
WMSProtocol.getMapURL = function(layer, srs, minX, minY, maxX, maxY, tileWidth, tileHeight, autoClassification, infoPoint) {
|
|
3951
|
+
var url = layer.baseURL;
|
|
3952
|
+
url += (url.indexOf("?") == -1? "?": "&") + "SERVICE=WMS";
|
|
3953
|
+
url += "&VERSION=1.1.1";
|
|
3954
|
+
url += "&REQUEST=" + (infoPoint == null? "GetMap": "GetFeatureInfo");
|
|
3955
|
+
|
|
3956
|
+
if (layer.styleURL == null) {
|
|
3957
|
+
url += "&LAYERS=" + layer.name;
|
|
3958
|
+
url += "&STYLES=";
|
|
3959
|
+
} else {
|
|
3960
|
+
var sldURL = layer.styleURL;
|
|
3961
|
+
if (layer.name != null) {
|
|
3962
|
+
sldURL += "?layer=" + layer.name;
|
|
3963
|
+
}
|
|
3964
|
+
var urlFilter = (new URLFilterConverter()).filterModelsToURLFilter(layer.filterModels);
|
|
3965
|
+
if (urlFilter.length > 0) {
|
|
3966
|
+
sldURL += "&filter=" + urlFilter;
|
|
3967
|
+
}
|
|
3968
|
+
if (layer.classification != null) {
|
|
3969
|
+
sldURL += "&classification=" + encodeURIComponent(URLClassificationConverter.classificationToURLClassification(layer.classification));
|
|
3970
|
+
if ((urlFilter.length == 0) || (!autoClassification)) {
|
|
3971
|
+
sldURL += "::noFilter";
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
url += "&SLD=" + encodeURIComponent(sldURL);
|
|
3975
|
+
}
|
|
3976
|
+
url += "&TRANSPARENT=true";
|
|
3977
|
+
url += "&SRS=EPSG:" + srs.srid;
|
|
3978
|
+
url += "&BBOX=" + minX + "," + minY + "," + maxX + "," + maxY;
|
|
3979
|
+
url += "&WIDTH=" + tileWidth;
|
|
3980
|
+
url += "&HEIGHT=" + tileHeight;
|
|
3981
|
+
url += "&FORMAT=" + layer.format;
|
|
3982
|
+
url += "&EXCEPTIONS=application/vnd.ogc.se_xml";
|
|
3983
|
+
|
|
3984
|
+
if (infoPoint != null) {
|
|
3985
|
+
url += "&QUERY_LAYERS=" + layer.name;
|
|
3986
|
+
url += "&X=" + infoPoint.x;
|
|
3987
|
+
url += "&Y=" + infoPoint.y;
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
for (var key in layer.vendorSpecifics) {
|
|
3991
|
+
if (!key.startsWith("post:")) {
|
|
3992
|
+
url += "&" + key + "=" + layer.vendorSpecifics[key];
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
|
|
3996
|
+
return url;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
WMSProtocol.getPostBody = function(layer) {
|
|
4000
|
+
var params = {};
|
|
4001
|
+
for (var key in layer.vendorSpecifics) {
|
|
4002
|
+
if (key.startsWith("post:")) {
|
|
4003
|
+
params[key.substring(5)] = layer.vendorSpecifics[key];
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
if (Object.keys(params).length > 0) {
|
|
4007
|
+
return new URLSearchParams(params).toString();
|
|
4008
|
+
}
|
|
4009
|
+
return null;
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
|
|
4013
|
+
|
|
4014
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
4015
|
+
/* Merging js: selectionmodel/SelectionModel.js begins */
|
|
4016
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
4017
|
+
|
|
4018
|
+
|
|
4019
|
+
export function SelectionModel() {
|
|
4020
|
+
this.selectedFeatures = null;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
|
|
4024
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
4025
|
+
/* Merging js: stylemodel/converters/URLClassificationConverter.js begins */
|
|
4026
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
4027
|
+
|
|
4028
|
+
|
|
4029
|
+
export function URLClassificationConverter() { }
|
|
4030
|
+
|
|
4031
|
+
URLClassificationConverter.classificationToURLClassification = function(classification) {
|
|
4032
|
+
var urlClassification = classification.propertyName + "::";
|
|
4033
|
+
|
|
4034
|
+
if (classification.numClasses != null) {
|
|
4035
|
+
urlClassification += classification.numClasses + "::";
|
|
4036
|
+
} else if (classification.thresholds != null) {
|
|
4037
|
+
urlClassification += classification.thresholds.join(":") + "::";
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
if (classification.colors != null) {
|
|
4041
|
+
var colorString = null;
|
|
4042
|
+
for (var i = 0; i < classification.colors.length; i++) {
|
|
4043
|
+
colorString = classification.colors[i].toString(16).toUpperCase();
|
|
4044
|
+
while (colorString.length < 6) {
|
|
4045
|
+
colorString = "0" + colorString;
|
|
4046
|
+
}
|
|
4047
|
+
colorString = "#" + colorString;
|
|
4048
|
+
|
|
4049
|
+
urlClassification += colorString;
|
|
4050
|
+
if (i < classification.colors.length - 1) {
|
|
4051
|
+
urlClassification += ":";
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
if (classification.numbers != null) {
|
|
4055
|
+
urlClassification += "::";
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
if (classification.numbers != null) {
|
|
4060
|
+
for (var j = 0; j < classification.numbers.length; j++) {
|
|
4061
|
+
urlClassification += classification.numbers[j];
|
|
4062
|
+
if (j < classification.numbers.length - 1) {
|
|
4063
|
+
urlClassification += ":";
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
return urlClassification;
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
|
|
4072
|
+
|
|
4073
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
4074
|
+
/* Merging js: niney.es2015.js begins */
|
|
4075
|
+
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
4076
|
+
|
|
4077
|
+
|
|
4078
|
+
const boundsModel = new BoundsModel();
|
|
4079
|
+
boundsModel.setBounds(new Bounds(window.innerWidth, window.innerHeight));
|
|
4080
|
+
window.addEventListener("resize", function(resizeEvent) {
|
|
4081
|
+
boundsModel.setBounds(new Bounds(window.innerWidth, window.innerHeight));
|
|
4082
|
+
});
|
|
4083
|
+
|
|
4084
|
+
export const windowBoundsModel = boundsModel;
|
|
4085
|
+
export const defaultBoundsModel = new BoundsModel();
|
|
4086
|
+
|
|
4087
|
+
export const defaultFocusModel = new FocusModel();
|
|
4088
|
+
export const defaultEnvelopeModel = new EnvelopeModel(defaultBoundsModel, defaultFocusModel);
|
|
4089
|
+
|
|
4090
|
+
export const defaultTilesLayer = new Layer("Tiles");
|
|
4091
|
+
|