@basemaps/landing 6.41.0 → 6.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +21 -0
- package/build/__tests__/map.config.test.js +0 -19
- package/build/__tests__/map.config.test.js.map +1 -1
- package/build/components/debug.js +3 -3
- package/build/components/debug.js.map +1 -1
- package/build/components/layer.switcher.dropdown.d.ts.map +1 -1
- package/build/components/layer.switcher.dropdown.js +26 -2
- package/build/components/layer.switcher.dropdown.js.map +1 -1
- package/build/components/layout.header.d.ts.map +1 -1
- package/build/components/layout.header.js +1 -1
- package/build/components/layout.header.js.map +1 -1
- package/build/components/map.d.ts.map +1 -1
- package/build/components/map.js +6 -3
- package/build/components/map.js.map +1 -1
- package/build/config.d.ts +2 -0
- package/build/config.d.ts.map +1 -1
- package/build/config.js +5 -0
- package/build/config.js.map +1 -1
- package/build/config.map.d.ts.map +1 -1
- package/build/config.map.js +15 -10
- package/build/config.map.js.map +1 -1
- package/build/url.d.ts +0 -13
- package/build/url.d.ts.map +1 -1
- package/build/url.js +1 -39
- package/build/url.js.map +1 -1
- package/package.json +7 -7
- package/dist/android-chrome-192x192.png +0 -0
- package/dist/android-chrome-512x512.png +0 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/assets/fonts/OpenSans-Bold.woff2 +0 -0
- package/dist/assets/fonts/OpenSans-Italic.woff2 +0 -0
- package/dist/assets/fonts/OpenSans-Light.woff2 +0 -0
- package/dist/assets/fonts/OpenSans-Regular.woff2 +0 -0
- package/dist/assets/fonts/OpenSans-SemiBold.woff2 +0 -0
- package/dist/assets/logo-linz.svg +0 -256
- package/dist/assets/logo-nz-govt.svg +0 -11
- package/dist/basemaps-card.jpeg +0 -0
- package/dist/examples/index.html +0 -33
- package/dist/examples/index.leaflet.xyz.3857.html +0 -43
- package/dist/examples/index.maplibre.compare.3857.html +0 -111
- package/dist/examples/index.maplibre.opacity.3857.html +0 -218
- package/dist/examples/index.maplibre.vector.3857.html +0 -48
- package/dist/examples/index.openlayers.attribution.wmts.3857.html +0 -55
- package/dist/examples/index.openlayers.wmts.3857.html +0 -49
- package/dist/examples/index.openlayers.xyz.3857.html +0 -49
- package/dist/favicon-16x16.png +0 -0
- package/dist/favicon-32x32.png +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/index-6.41.0-04bd3d24eee59f30.css +0 -6280
- package/dist/index-6.41.0-ae3950c364b06ab8.js +0 -59403
- package/dist/index-6.41.0-dce2cbdab3dc8de4.js +0 -624
- package/dist/index.css +0 -6280
- package/dist/index.html +0 -26
- package/dist/index.js +0 -624
- package/dist/json-schema/stac-basemaps-extension/1.0/schema.json +0 -144
- package/dist/lib/attribution-6.41.0-a06a4339e5df297e.js +0 -10
- package/dist/lib/attribution-6.41.0-f0099e1099a7c0ac.js +0 -2330
- package/dist/lib/attribution.js +0 -10
|
@@ -1,2330 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
23
|
-
|
|
24
|
-
// ../../node_modules/lineclip/index.js
|
|
25
|
-
var require_lineclip = __commonJS({
|
|
26
|
-
"../../node_modules/lineclip/index.js"(exports, module2) {
|
|
27
|
-
"use strict";
|
|
28
|
-
module2.exports = lineclip2;
|
|
29
|
-
lineclip2.polyline = lineclip2;
|
|
30
|
-
lineclip2.polygon = polygonclip;
|
|
31
|
-
function lineclip2(points, bbox, result) {
|
|
32
|
-
var len = points.length, codeA = bitCode(points[0], bbox), part = [], i, a, b, codeB, lastCode;
|
|
33
|
-
if (!result)
|
|
34
|
-
result = [];
|
|
35
|
-
for (i = 1; i < len; i++) {
|
|
36
|
-
a = points[i - 1];
|
|
37
|
-
b = points[i];
|
|
38
|
-
codeB = lastCode = bitCode(b, bbox);
|
|
39
|
-
while (true) {
|
|
40
|
-
if (!(codeA | codeB)) {
|
|
41
|
-
part.push(a);
|
|
42
|
-
if (codeB !== lastCode) {
|
|
43
|
-
part.push(b);
|
|
44
|
-
if (i < len - 1) {
|
|
45
|
-
result.push(part);
|
|
46
|
-
part = [];
|
|
47
|
-
}
|
|
48
|
-
} else if (i === len - 1) {
|
|
49
|
-
part.push(b);
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
} else if (codeA & codeB) {
|
|
53
|
-
break;
|
|
54
|
-
} else if (codeA) {
|
|
55
|
-
a = intersect(a, b, codeA, bbox);
|
|
56
|
-
codeA = bitCode(a, bbox);
|
|
57
|
-
} else {
|
|
58
|
-
b = intersect(a, b, codeB, bbox);
|
|
59
|
-
codeB = bitCode(b, bbox);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
codeA = lastCode;
|
|
63
|
-
}
|
|
64
|
-
if (part.length)
|
|
65
|
-
result.push(part);
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
function polygonclip(points, bbox) {
|
|
69
|
-
var result, edge, prev, prevInside, i, p, inside;
|
|
70
|
-
for (edge = 1; edge <= 8; edge *= 2) {
|
|
71
|
-
result = [];
|
|
72
|
-
prev = points[points.length - 1];
|
|
73
|
-
prevInside = !(bitCode(prev, bbox) & edge);
|
|
74
|
-
for (i = 0; i < points.length; i++) {
|
|
75
|
-
p = points[i];
|
|
76
|
-
inside = !(bitCode(p, bbox) & edge);
|
|
77
|
-
if (inside !== prevInside)
|
|
78
|
-
result.push(intersect(prev, p, edge, bbox));
|
|
79
|
-
if (inside)
|
|
80
|
-
result.push(p);
|
|
81
|
-
prev = p;
|
|
82
|
-
prevInside = inside;
|
|
83
|
-
}
|
|
84
|
-
points = result;
|
|
85
|
-
if (!points.length)
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
function intersect(a, b, edge, bbox) {
|
|
91
|
-
return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox[3] - a[1]) / (b[1] - a[1]), bbox[3]] : edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox[1] - a[1]) / (b[1] - a[1]), bbox[1]] : edge & 2 ? [bbox[2], a[1] + (b[1] - a[1]) * (bbox[2] - a[0]) / (b[0] - a[0])] : edge & 1 ? [bbox[0], a[1] + (b[1] - a[1]) * (bbox[0] - a[0]) / (b[0] - a[0])] : null;
|
|
92
|
-
}
|
|
93
|
-
function bitCode(p, bbox) {
|
|
94
|
-
var code = 0;
|
|
95
|
-
if (p[0] < bbox[0])
|
|
96
|
-
code |= 1;
|
|
97
|
-
else if (p[0] > bbox[2])
|
|
98
|
-
code |= 2;
|
|
99
|
-
if (p[1] < bbox[1])
|
|
100
|
-
code |= 4;
|
|
101
|
-
else if (p[1] > bbox[3])
|
|
102
|
-
code |= 8;
|
|
103
|
-
return code;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// ../../node_modules/polygon-clipping/dist/polygon-clipping.umd.js
|
|
109
|
-
var require_polygon_clipping_umd = __commonJS({
|
|
110
|
-
"../../node_modules/polygon-clipping/dist/polygon-clipping.umd.js"(exports, module2) {
|
|
111
|
-
(function(global, factory) {
|
|
112
|
-
typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.polygonClipping = factory());
|
|
113
|
-
})(exports, function() {
|
|
114
|
-
"use strict";
|
|
115
|
-
function _classCallCheck(instance, Constructor) {
|
|
116
|
-
if (!(instance instanceof Constructor)) {
|
|
117
|
-
throw new TypeError("Cannot call a class as a function");
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function _defineProperties(target, props) {
|
|
121
|
-
for (var i = 0; i < props.length; i++) {
|
|
122
|
-
var descriptor = props[i];
|
|
123
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
124
|
-
descriptor.configurable = true;
|
|
125
|
-
if ("value" in descriptor)
|
|
126
|
-
descriptor.writable = true;
|
|
127
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
131
|
-
if (protoProps)
|
|
132
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
133
|
-
if (staticProps)
|
|
134
|
-
_defineProperties(Constructor, staticProps);
|
|
135
|
-
return Constructor;
|
|
136
|
-
}
|
|
137
|
-
var Node = function() {
|
|
138
|
-
function Node2(key, data) {
|
|
139
|
-
this.next = null;
|
|
140
|
-
this.key = key;
|
|
141
|
-
this.data = data;
|
|
142
|
-
this.left = null;
|
|
143
|
-
this.right = null;
|
|
144
|
-
}
|
|
145
|
-
return Node2;
|
|
146
|
-
}();
|
|
147
|
-
function DEFAULT_COMPARE(a, b) {
|
|
148
|
-
return a > b ? 1 : a < b ? -1 : 0;
|
|
149
|
-
}
|
|
150
|
-
function splay(i, t, comparator) {
|
|
151
|
-
var N = new Node(null, null);
|
|
152
|
-
var l = N;
|
|
153
|
-
var r = N;
|
|
154
|
-
while (true) {
|
|
155
|
-
var cmp2 = comparator(i, t.key);
|
|
156
|
-
if (cmp2 < 0) {
|
|
157
|
-
if (t.left === null)
|
|
158
|
-
break;
|
|
159
|
-
if (comparator(i, t.left.key) < 0) {
|
|
160
|
-
var y = t.left;
|
|
161
|
-
t.left = y.right;
|
|
162
|
-
y.right = t;
|
|
163
|
-
t = y;
|
|
164
|
-
if (t.left === null)
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
r.left = t;
|
|
168
|
-
r = t;
|
|
169
|
-
t = t.left;
|
|
170
|
-
} else if (cmp2 > 0) {
|
|
171
|
-
if (t.right === null)
|
|
172
|
-
break;
|
|
173
|
-
if (comparator(i, t.right.key) > 0) {
|
|
174
|
-
var y = t.right;
|
|
175
|
-
t.right = y.left;
|
|
176
|
-
y.left = t;
|
|
177
|
-
t = y;
|
|
178
|
-
if (t.right === null)
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
l.right = t;
|
|
182
|
-
l = t;
|
|
183
|
-
t = t.right;
|
|
184
|
-
} else
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
l.right = t.left;
|
|
188
|
-
r.left = t.right;
|
|
189
|
-
t.left = N.right;
|
|
190
|
-
t.right = N.left;
|
|
191
|
-
return t;
|
|
192
|
-
}
|
|
193
|
-
function insert(i, data, t, comparator) {
|
|
194
|
-
var node = new Node(i, data);
|
|
195
|
-
if (t === null) {
|
|
196
|
-
node.left = node.right = null;
|
|
197
|
-
return node;
|
|
198
|
-
}
|
|
199
|
-
t = splay(i, t, comparator);
|
|
200
|
-
var cmp2 = comparator(i, t.key);
|
|
201
|
-
if (cmp2 < 0) {
|
|
202
|
-
node.left = t.left;
|
|
203
|
-
node.right = t;
|
|
204
|
-
t.left = null;
|
|
205
|
-
} else if (cmp2 >= 0) {
|
|
206
|
-
node.right = t.right;
|
|
207
|
-
node.left = t;
|
|
208
|
-
t.right = null;
|
|
209
|
-
}
|
|
210
|
-
return node;
|
|
211
|
-
}
|
|
212
|
-
function split(key, v, comparator) {
|
|
213
|
-
var left = null;
|
|
214
|
-
var right = null;
|
|
215
|
-
if (v) {
|
|
216
|
-
v = splay(key, v, comparator);
|
|
217
|
-
var cmp2 = comparator(v.key, key);
|
|
218
|
-
if (cmp2 === 0) {
|
|
219
|
-
left = v.left;
|
|
220
|
-
right = v.right;
|
|
221
|
-
} else if (cmp2 < 0) {
|
|
222
|
-
right = v.right;
|
|
223
|
-
v.right = null;
|
|
224
|
-
left = v;
|
|
225
|
-
} else {
|
|
226
|
-
left = v.left;
|
|
227
|
-
v.left = null;
|
|
228
|
-
right = v;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
left,
|
|
233
|
-
right
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
function merge(left, right, comparator) {
|
|
237
|
-
if (right === null)
|
|
238
|
-
return left;
|
|
239
|
-
if (left === null)
|
|
240
|
-
return right;
|
|
241
|
-
right = splay(left.key, right, comparator);
|
|
242
|
-
right.left = left;
|
|
243
|
-
return right;
|
|
244
|
-
}
|
|
245
|
-
function printRow(root, prefix, isTail, out, printNode) {
|
|
246
|
-
if (root) {
|
|
247
|
-
out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode(root) + "\n");
|
|
248
|
-
var indent = prefix + (isTail ? " " : "\u2502 ");
|
|
249
|
-
if (root.left)
|
|
250
|
-
printRow(root.left, indent, false, out, printNode);
|
|
251
|
-
if (root.right)
|
|
252
|
-
printRow(root.right, indent, true, out, printNode);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
var Tree = function() {
|
|
256
|
-
function Tree2(comparator) {
|
|
257
|
-
if (comparator === void 0) {
|
|
258
|
-
comparator = DEFAULT_COMPARE;
|
|
259
|
-
}
|
|
260
|
-
this._root = null;
|
|
261
|
-
this._size = 0;
|
|
262
|
-
this._comparator = comparator;
|
|
263
|
-
}
|
|
264
|
-
Tree2.prototype.insert = function(key, data) {
|
|
265
|
-
this._size++;
|
|
266
|
-
return this._root = insert(key, data, this._root, this._comparator);
|
|
267
|
-
};
|
|
268
|
-
Tree2.prototype.add = function(key, data) {
|
|
269
|
-
var node = new Node(key, data);
|
|
270
|
-
if (this._root === null) {
|
|
271
|
-
node.left = node.right = null;
|
|
272
|
-
this._size++;
|
|
273
|
-
this._root = node;
|
|
274
|
-
}
|
|
275
|
-
var comparator = this._comparator;
|
|
276
|
-
var t = splay(key, this._root, comparator);
|
|
277
|
-
var cmp2 = comparator(key, t.key);
|
|
278
|
-
if (cmp2 === 0)
|
|
279
|
-
this._root = t;
|
|
280
|
-
else {
|
|
281
|
-
if (cmp2 < 0) {
|
|
282
|
-
node.left = t.left;
|
|
283
|
-
node.right = t;
|
|
284
|
-
t.left = null;
|
|
285
|
-
} else if (cmp2 > 0) {
|
|
286
|
-
node.right = t.right;
|
|
287
|
-
node.left = t;
|
|
288
|
-
t.right = null;
|
|
289
|
-
}
|
|
290
|
-
this._size++;
|
|
291
|
-
this._root = node;
|
|
292
|
-
}
|
|
293
|
-
return this._root;
|
|
294
|
-
};
|
|
295
|
-
Tree2.prototype.remove = function(key) {
|
|
296
|
-
this._root = this._remove(key, this._root, this._comparator);
|
|
297
|
-
};
|
|
298
|
-
Tree2.prototype._remove = function(i, t, comparator) {
|
|
299
|
-
var x;
|
|
300
|
-
if (t === null)
|
|
301
|
-
return null;
|
|
302
|
-
t = splay(i, t, comparator);
|
|
303
|
-
var cmp2 = comparator(i, t.key);
|
|
304
|
-
if (cmp2 === 0) {
|
|
305
|
-
if (t.left === null) {
|
|
306
|
-
x = t.right;
|
|
307
|
-
} else {
|
|
308
|
-
x = splay(i, t.left, comparator);
|
|
309
|
-
x.right = t.right;
|
|
310
|
-
}
|
|
311
|
-
this._size--;
|
|
312
|
-
return x;
|
|
313
|
-
}
|
|
314
|
-
return t;
|
|
315
|
-
};
|
|
316
|
-
Tree2.prototype.pop = function() {
|
|
317
|
-
var node = this._root;
|
|
318
|
-
if (node) {
|
|
319
|
-
while (node.left) {
|
|
320
|
-
node = node.left;
|
|
321
|
-
}
|
|
322
|
-
this._root = splay(node.key, this._root, this._comparator);
|
|
323
|
-
this._root = this._remove(node.key, this._root, this._comparator);
|
|
324
|
-
return {
|
|
325
|
-
key: node.key,
|
|
326
|
-
data: node.data
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
return null;
|
|
330
|
-
};
|
|
331
|
-
Tree2.prototype.findStatic = function(key) {
|
|
332
|
-
var current = this._root;
|
|
333
|
-
var compare = this._comparator;
|
|
334
|
-
while (current) {
|
|
335
|
-
var cmp2 = compare(key, current.key);
|
|
336
|
-
if (cmp2 === 0)
|
|
337
|
-
return current;
|
|
338
|
-
else if (cmp2 < 0)
|
|
339
|
-
current = current.left;
|
|
340
|
-
else
|
|
341
|
-
current = current.right;
|
|
342
|
-
}
|
|
343
|
-
return null;
|
|
344
|
-
};
|
|
345
|
-
Tree2.prototype.find = function(key) {
|
|
346
|
-
if (this._root) {
|
|
347
|
-
this._root = splay(key, this._root, this._comparator);
|
|
348
|
-
if (this._comparator(key, this._root.key) !== 0)
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
return this._root;
|
|
352
|
-
};
|
|
353
|
-
Tree2.prototype.contains = function(key) {
|
|
354
|
-
var current = this._root;
|
|
355
|
-
var compare = this._comparator;
|
|
356
|
-
while (current) {
|
|
357
|
-
var cmp2 = compare(key, current.key);
|
|
358
|
-
if (cmp2 === 0)
|
|
359
|
-
return true;
|
|
360
|
-
else if (cmp2 < 0)
|
|
361
|
-
current = current.left;
|
|
362
|
-
else
|
|
363
|
-
current = current.right;
|
|
364
|
-
}
|
|
365
|
-
return false;
|
|
366
|
-
};
|
|
367
|
-
Tree2.prototype.forEach = function(visitor, ctx) {
|
|
368
|
-
var current = this._root;
|
|
369
|
-
var Q = [];
|
|
370
|
-
var done = false;
|
|
371
|
-
while (!done) {
|
|
372
|
-
if (current !== null) {
|
|
373
|
-
Q.push(current);
|
|
374
|
-
current = current.left;
|
|
375
|
-
} else {
|
|
376
|
-
if (Q.length !== 0) {
|
|
377
|
-
current = Q.pop();
|
|
378
|
-
visitor.call(ctx, current);
|
|
379
|
-
current = current.right;
|
|
380
|
-
} else
|
|
381
|
-
done = true;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
return this;
|
|
385
|
-
};
|
|
386
|
-
Tree2.prototype.range = function(low, high, fn, ctx) {
|
|
387
|
-
var Q = [];
|
|
388
|
-
var compare = this._comparator;
|
|
389
|
-
var node = this._root;
|
|
390
|
-
var cmp2;
|
|
391
|
-
while (Q.length !== 0 || node) {
|
|
392
|
-
if (node) {
|
|
393
|
-
Q.push(node);
|
|
394
|
-
node = node.left;
|
|
395
|
-
} else {
|
|
396
|
-
node = Q.pop();
|
|
397
|
-
cmp2 = compare(node.key, high);
|
|
398
|
-
if (cmp2 > 0) {
|
|
399
|
-
break;
|
|
400
|
-
} else if (compare(node.key, low) >= 0) {
|
|
401
|
-
if (fn.call(ctx, node))
|
|
402
|
-
return this;
|
|
403
|
-
}
|
|
404
|
-
node = node.right;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return this;
|
|
408
|
-
};
|
|
409
|
-
Tree2.prototype.keys = function() {
|
|
410
|
-
var keys = [];
|
|
411
|
-
this.forEach(function(_a) {
|
|
412
|
-
var key = _a.key;
|
|
413
|
-
return keys.push(key);
|
|
414
|
-
});
|
|
415
|
-
return keys;
|
|
416
|
-
};
|
|
417
|
-
Tree2.prototype.values = function() {
|
|
418
|
-
var values = [];
|
|
419
|
-
this.forEach(function(_a) {
|
|
420
|
-
var data = _a.data;
|
|
421
|
-
return values.push(data);
|
|
422
|
-
});
|
|
423
|
-
return values;
|
|
424
|
-
};
|
|
425
|
-
Tree2.prototype.min = function() {
|
|
426
|
-
if (this._root)
|
|
427
|
-
return this.minNode(this._root).key;
|
|
428
|
-
return null;
|
|
429
|
-
};
|
|
430
|
-
Tree2.prototype.max = function() {
|
|
431
|
-
if (this._root)
|
|
432
|
-
return this.maxNode(this._root).key;
|
|
433
|
-
return null;
|
|
434
|
-
};
|
|
435
|
-
Tree2.prototype.minNode = function(t) {
|
|
436
|
-
if (t === void 0) {
|
|
437
|
-
t = this._root;
|
|
438
|
-
}
|
|
439
|
-
if (t)
|
|
440
|
-
while (t.left) {
|
|
441
|
-
t = t.left;
|
|
442
|
-
}
|
|
443
|
-
return t;
|
|
444
|
-
};
|
|
445
|
-
Tree2.prototype.maxNode = function(t) {
|
|
446
|
-
if (t === void 0) {
|
|
447
|
-
t = this._root;
|
|
448
|
-
}
|
|
449
|
-
if (t)
|
|
450
|
-
while (t.right) {
|
|
451
|
-
t = t.right;
|
|
452
|
-
}
|
|
453
|
-
return t;
|
|
454
|
-
};
|
|
455
|
-
Tree2.prototype.at = function(index2) {
|
|
456
|
-
var current = this._root;
|
|
457
|
-
var done = false;
|
|
458
|
-
var i = 0;
|
|
459
|
-
var Q = [];
|
|
460
|
-
while (!done) {
|
|
461
|
-
if (current) {
|
|
462
|
-
Q.push(current);
|
|
463
|
-
current = current.left;
|
|
464
|
-
} else {
|
|
465
|
-
if (Q.length > 0) {
|
|
466
|
-
current = Q.pop();
|
|
467
|
-
if (i === index2)
|
|
468
|
-
return current;
|
|
469
|
-
i++;
|
|
470
|
-
current = current.right;
|
|
471
|
-
} else
|
|
472
|
-
done = true;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
return null;
|
|
476
|
-
};
|
|
477
|
-
Tree2.prototype.next = function(d) {
|
|
478
|
-
var root = this._root;
|
|
479
|
-
var successor = null;
|
|
480
|
-
if (d.right) {
|
|
481
|
-
successor = d.right;
|
|
482
|
-
while (successor.left) {
|
|
483
|
-
successor = successor.left;
|
|
484
|
-
}
|
|
485
|
-
return successor;
|
|
486
|
-
}
|
|
487
|
-
var comparator = this._comparator;
|
|
488
|
-
while (root) {
|
|
489
|
-
var cmp2 = comparator(d.key, root.key);
|
|
490
|
-
if (cmp2 === 0)
|
|
491
|
-
break;
|
|
492
|
-
else if (cmp2 < 0) {
|
|
493
|
-
successor = root;
|
|
494
|
-
root = root.left;
|
|
495
|
-
} else
|
|
496
|
-
root = root.right;
|
|
497
|
-
}
|
|
498
|
-
return successor;
|
|
499
|
-
};
|
|
500
|
-
Tree2.prototype.prev = function(d) {
|
|
501
|
-
var root = this._root;
|
|
502
|
-
var predecessor = null;
|
|
503
|
-
if (d.left !== null) {
|
|
504
|
-
predecessor = d.left;
|
|
505
|
-
while (predecessor.right) {
|
|
506
|
-
predecessor = predecessor.right;
|
|
507
|
-
}
|
|
508
|
-
return predecessor;
|
|
509
|
-
}
|
|
510
|
-
var comparator = this._comparator;
|
|
511
|
-
while (root) {
|
|
512
|
-
var cmp2 = comparator(d.key, root.key);
|
|
513
|
-
if (cmp2 === 0)
|
|
514
|
-
break;
|
|
515
|
-
else if (cmp2 < 0)
|
|
516
|
-
root = root.left;
|
|
517
|
-
else {
|
|
518
|
-
predecessor = root;
|
|
519
|
-
root = root.right;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return predecessor;
|
|
523
|
-
};
|
|
524
|
-
Tree2.prototype.clear = function() {
|
|
525
|
-
this._root = null;
|
|
526
|
-
this._size = 0;
|
|
527
|
-
return this;
|
|
528
|
-
};
|
|
529
|
-
Tree2.prototype.toList = function() {
|
|
530
|
-
return toList(this._root);
|
|
531
|
-
};
|
|
532
|
-
Tree2.prototype.load = function(keys, values, presort) {
|
|
533
|
-
if (values === void 0) {
|
|
534
|
-
values = [];
|
|
535
|
-
}
|
|
536
|
-
if (presort === void 0) {
|
|
537
|
-
presort = false;
|
|
538
|
-
}
|
|
539
|
-
var size = keys.length;
|
|
540
|
-
var comparator = this._comparator;
|
|
541
|
-
if (presort)
|
|
542
|
-
sort(keys, values, 0, size - 1, comparator);
|
|
543
|
-
if (this._root === null) {
|
|
544
|
-
this._root = loadRecursive(keys, values, 0, size);
|
|
545
|
-
this._size = size;
|
|
546
|
-
} else {
|
|
547
|
-
var mergedList = mergeLists(this.toList(), createList(keys, values), comparator);
|
|
548
|
-
size = this._size + size;
|
|
549
|
-
this._root = sortedListToBST({
|
|
550
|
-
head: mergedList
|
|
551
|
-
}, 0, size);
|
|
552
|
-
}
|
|
553
|
-
return this;
|
|
554
|
-
};
|
|
555
|
-
Tree2.prototype.isEmpty = function() {
|
|
556
|
-
return this._root === null;
|
|
557
|
-
};
|
|
558
|
-
Object.defineProperty(Tree2.prototype, "size", {
|
|
559
|
-
get: function get() {
|
|
560
|
-
return this._size;
|
|
561
|
-
},
|
|
562
|
-
enumerable: true,
|
|
563
|
-
configurable: true
|
|
564
|
-
});
|
|
565
|
-
Object.defineProperty(Tree2.prototype, "root", {
|
|
566
|
-
get: function get() {
|
|
567
|
-
return this._root;
|
|
568
|
-
},
|
|
569
|
-
enumerable: true,
|
|
570
|
-
configurable: true
|
|
571
|
-
});
|
|
572
|
-
Tree2.prototype.toString = function(printNode) {
|
|
573
|
-
if (printNode === void 0) {
|
|
574
|
-
printNode = function printNode2(n) {
|
|
575
|
-
return String(n.key);
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
var out = [];
|
|
579
|
-
printRow(this._root, "", true, function(v) {
|
|
580
|
-
return out.push(v);
|
|
581
|
-
}, printNode);
|
|
582
|
-
return out.join("");
|
|
583
|
-
};
|
|
584
|
-
Tree2.prototype.update = function(key, newKey, newData) {
|
|
585
|
-
var comparator = this._comparator;
|
|
586
|
-
var _a = split(key, this._root, comparator), left = _a.left, right = _a.right;
|
|
587
|
-
if (comparator(key, newKey) < 0) {
|
|
588
|
-
right = insert(newKey, newData, right, comparator);
|
|
589
|
-
} else {
|
|
590
|
-
left = insert(newKey, newData, left, comparator);
|
|
591
|
-
}
|
|
592
|
-
this._root = merge(left, right, comparator);
|
|
593
|
-
};
|
|
594
|
-
Tree2.prototype.split = function(key) {
|
|
595
|
-
return split(key, this._root, this._comparator);
|
|
596
|
-
};
|
|
597
|
-
return Tree2;
|
|
598
|
-
}();
|
|
599
|
-
function loadRecursive(keys, values, start, end) {
|
|
600
|
-
var size = end - start;
|
|
601
|
-
if (size > 0) {
|
|
602
|
-
var middle = start + Math.floor(size / 2);
|
|
603
|
-
var key = keys[middle];
|
|
604
|
-
var data = values[middle];
|
|
605
|
-
var node = new Node(key, data);
|
|
606
|
-
node.left = loadRecursive(keys, values, start, middle);
|
|
607
|
-
node.right = loadRecursive(keys, values, middle + 1, end);
|
|
608
|
-
return node;
|
|
609
|
-
}
|
|
610
|
-
return null;
|
|
611
|
-
}
|
|
612
|
-
function createList(keys, values) {
|
|
613
|
-
var head = new Node(null, null);
|
|
614
|
-
var p = head;
|
|
615
|
-
for (var i = 0; i < keys.length; i++) {
|
|
616
|
-
p = p.next = new Node(keys[i], values[i]);
|
|
617
|
-
}
|
|
618
|
-
p.next = null;
|
|
619
|
-
return head.next;
|
|
620
|
-
}
|
|
621
|
-
function toList(root) {
|
|
622
|
-
var current = root;
|
|
623
|
-
var Q = [];
|
|
624
|
-
var done = false;
|
|
625
|
-
var head = new Node(null, null);
|
|
626
|
-
var p = head;
|
|
627
|
-
while (!done) {
|
|
628
|
-
if (current) {
|
|
629
|
-
Q.push(current);
|
|
630
|
-
current = current.left;
|
|
631
|
-
} else {
|
|
632
|
-
if (Q.length > 0) {
|
|
633
|
-
current = p = p.next = Q.pop();
|
|
634
|
-
current = current.right;
|
|
635
|
-
} else
|
|
636
|
-
done = true;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
p.next = null;
|
|
640
|
-
return head.next;
|
|
641
|
-
}
|
|
642
|
-
function sortedListToBST(list, start, end) {
|
|
643
|
-
var size = end - start;
|
|
644
|
-
if (size > 0) {
|
|
645
|
-
var middle = start + Math.floor(size / 2);
|
|
646
|
-
var left = sortedListToBST(list, start, middle);
|
|
647
|
-
var root = list.head;
|
|
648
|
-
root.left = left;
|
|
649
|
-
list.head = list.head.next;
|
|
650
|
-
root.right = sortedListToBST(list, middle + 1, end);
|
|
651
|
-
return root;
|
|
652
|
-
}
|
|
653
|
-
return null;
|
|
654
|
-
}
|
|
655
|
-
function mergeLists(l1, l2, compare) {
|
|
656
|
-
var head = new Node(null, null);
|
|
657
|
-
var p = head;
|
|
658
|
-
var p1 = l1;
|
|
659
|
-
var p2 = l2;
|
|
660
|
-
while (p1 !== null && p2 !== null) {
|
|
661
|
-
if (compare(p1.key, p2.key) < 0) {
|
|
662
|
-
p.next = p1;
|
|
663
|
-
p1 = p1.next;
|
|
664
|
-
} else {
|
|
665
|
-
p.next = p2;
|
|
666
|
-
p2 = p2.next;
|
|
667
|
-
}
|
|
668
|
-
p = p.next;
|
|
669
|
-
}
|
|
670
|
-
if (p1 !== null) {
|
|
671
|
-
p.next = p1;
|
|
672
|
-
} else if (p2 !== null) {
|
|
673
|
-
p.next = p2;
|
|
674
|
-
}
|
|
675
|
-
return head.next;
|
|
676
|
-
}
|
|
677
|
-
function sort(keys, values, left, right, compare) {
|
|
678
|
-
if (left >= right)
|
|
679
|
-
return;
|
|
680
|
-
var pivot = keys[left + right >> 1];
|
|
681
|
-
var i = left - 1;
|
|
682
|
-
var j = right + 1;
|
|
683
|
-
while (true) {
|
|
684
|
-
do {
|
|
685
|
-
i++;
|
|
686
|
-
} while (compare(keys[i], pivot) < 0);
|
|
687
|
-
do {
|
|
688
|
-
j--;
|
|
689
|
-
} while (compare(keys[j], pivot) > 0);
|
|
690
|
-
if (i >= j)
|
|
691
|
-
break;
|
|
692
|
-
var tmp = keys[i];
|
|
693
|
-
keys[i] = keys[j];
|
|
694
|
-
keys[j] = tmp;
|
|
695
|
-
tmp = values[i];
|
|
696
|
-
values[i] = values[j];
|
|
697
|
-
values[j] = tmp;
|
|
698
|
-
}
|
|
699
|
-
sort(keys, values, left, j, compare);
|
|
700
|
-
sort(keys, values, j + 1, right, compare);
|
|
701
|
-
}
|
|
702
|
-
var isInBbox = function isInBbox2(bbox, point) {
|
|
703
|
-
return bbox.ll.x <= point.x && point.x <= bbox.ur.x && bbox.ll.y <= point.y && point.y <= bbox.ur.y;
|
|
704
|
-
};
|
|
705
|
-
var getBboxOverlap = function getBboxOverlap2(b1, b2) {
|
|
706
|
-
if (b2.ur.x < b1.ll.x || b1.ur.x < b2.ll.x || b2.ur.y < b1.ll.y || b1.ur.y < b2.ll.y)
|
|
707
|
-
return null;
|
|
708
|
-
var lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x;
|
|
709
|
-
var upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x;
|
|
710
|
-
var lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y;
|
|
711
|
-
var upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y;
|
|
712
|
-
return {
|
|
713
|
-
ll: {
|
|
714
|
-
x: lowerX,
|
|
715
|
-
y: lowerY
|
|
716
|
-
},
|
|
717
|
-
ur: {
|
|
718
|
-
x: upperX,
|
|
719
|
-
y: upperY
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
};
|
|
723
|
-
var epsilon = Number.EPSILON;
|
|
724
|
-
if (epsilon === void 0)
|
|
725
|
-
epsilon = Math.pow(2, -52);
|
|
726
|
-
var EPSILON_SQ = epsilon * epsilon;
|
|
727
|
-
var cmp = function cmp2(a, b) {
|
|
728
|
-
if (-epsilon < a && a < epsilon) {
|
|
729
|
-
if (-epsilon < b && b < epsilon) {
|
|
730
|
-
return 0;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
var ab = a - b;
|
|
734
|
-
if (ab * ab < EPSILON_SQ * a * b) {
|
|
735
|
-
return 0;
|
|
736
|
-
}
|
|
737
|
-
return a < b ? -1 : 1;
|
|
738
|
-
};
|
|
739
|
-
var PtRounder = /* @__PURE__ */ function() {
|
|
740
|
-
function PtRounder2() {
|
|
741
|
-
_classCallCheck(this, PtRounder2);
|
|
742
|
-
this.reset();
|
|
743
|
-
}
|
|
744
|
-
_createClass(PtRounder2, [{
|
|
745
|
-
key: "reset",
|
|
746
|
-
value: function reset() {
|
|
747
|
-
this.xRounder = new CoordRounder();
|
|
748
|
-
this.yRounder = new CoordRounder();
|
|
749
|
-
}
|
|
750
|
-
}, {
|
|
751
|
-
key: "round",
|
|
752
|
-
value: function round(x, y) {
|
|
753
|
-
return {
|
|
754
|
-
x: this.xRounder.round(x),
|
|
755
|
-
y: this.yRounder.round(y)
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
}]);
|
|
759
|
-
return PtRounder2;
|
|
760
|
-
}();
|
|
761
|
-
var CoordRounder = /* @__PURE__ */ function() {
|
|
762
|
-
function CoordRounder2() {
|
|
763
|
-
_classCallCheck(this, CoordRounder2);
|
|
764
|
-
this.tree = new Tree();
|
|
765
|
-
this.round(0);
|
|
766
|
-
}
|
|
767
|
-
_createClass(CoordRounder2, [{
|
|
768
|
-
key: "round",
|
|
769
|
-
value: function round(coord) {
|
|
770
|
-
var node = this.tree.add(coord);
|
|
771
|
-
var prevNode = this.tree.prev(node);
|
|
772
|
-
if (prevNode !== null && cmp(node.key, prevNode.key) === 0) {
|
|
773
|
-
this.tree.remove(coord);
|
|
774
|
-
return prevNode.key;
|
|
775
|
-
}
|
|
776
|
-
var nextNode = this.tree.next(node);
|
|
777
|
-
if (nextNode !== null && cmp(node.key, nextNode.key) === 0) {
|
|
778
|
-
this.tree.remove(coord);
|
|
779
|
-
return nextNode.key;
|
|
780
|
-
}
|
|
781
|
-
return coord;
|
|
782
|
-
}
|
|
783
|
-
}]);
|
|
784
|
-
return CoordRounder2;
|
|
785
|
-
}();
|
|
786
|
-
var rounder = new PtRounder();
|
|
787
|
-
var crossProduct = function crossProduct2(a, b) {
|
|
788
|
-
return a.x * b.y - a.y * b.x;
|
|
789
|
-
};
|
|
790
|
-
var dotProduct = function dotProduct2(a, b) {
|
|
791
|
-
return a.x * b.x + a.y * b.y;
|
|
792
|
-
};
|
|
793
|
-
var compareVectorAngles = function compareVectorAngles2(basePt, endPt1, endPt2) {
|
|
794
|
-
var v1 = {
|
|
795
|
-
x: endPt1.x - basePt.x,
|
|
796
|
-
y: endPt1.y - basePt.y
|
|
797
|
-
};
|
|
798
|
-
var v2 = {
|
|
799
|
-
x: endPt2.x - basePt.x,
|
|
800
|
-
y: endPt2.y - basePt.y
|
|
801
|
-
};
|
|
802
|
-
var kross = crossProduct(v1, v2);
|
|
803
|
-
return cmp(kross, 0);
|
|
804
|
-
};
|
|
805
|
-
var length = function length2(v) {
|
|
806
|
-
return Math.sqrt(dotProduct(v, v));
|
|
807
|
-
};
|
|
808
|
-
var sineOfAngle = function sineOfAngle2(pShared, pBase, pAngle) {
|
|
809
|
-
var vBase = {
|
|
810
|
-
x: pBase.x - pShared.x,
|
|
811
|
-
y: pBase.y - pShared.y
|
|
812
|
-
};
|
|
813
|
-
var vAngle = {
|
|
814
|
-
x: pAngle.x - pShared.x,
|
|
815
|
-
y: pAngle.y - pShared.y
|
|
816
|
-
};
|
|
817
|
-
return crossProduct(vAngle, vBase) / length(vAngle) / length(vBase);
|
|
818
|
-
};
|
|
819
|
-
var cosineOfAngle = function cosineOfAngle2(pShared, pBase, pAngle) {
|
|
820
|
-
var vBase = {
|
|
821
|
-
x: pBase.x - pShared.x,
|
|
822
|
-
y: pBase.y - pShared.y
|
|
823
|
-
};
|
|
824
|
-
var vAngle = {
|
|
825
|
-
x: pAngle.x - pShared.x,
|
|
826
|
-
y: pAngle.y - pShared.y
|
|
827
|
-
};
|
|
828
|
-
return dotProduct(vAngle, vBase) / length(vAngle) / length(vBase);
|
|
829
|
-
};
|
|
830
|
-
var horizontalIntersection = function horizontalIntersection2(pt, v, y) {
|
|
831
|
-
if (v.y === 0)
|
|
832
|
-
return null;
|
|
833
|
-
return {
|
|
834
|
-
x: pt.x + v.x / v.y * (y - pt.y),
|
|
835
|
-
y
|
|
836
|
-
};
|
|
837
|
-
};
|
|
838
|
-
var verticalIntersection = function verticalIntersection2(pt, v, x) {
|
|
839
|
-
if (v.x === 0)
|
|
840
|
-
return null;
|
|
841
|
-
return {
|
|
842
|
-
x,
|
|
843
|
-
y: pt.y + v.y / v.x * (x - pt.x)
|
|
844
|
-
};
|
|
845
|
-
};
|
|
846
|
-
var intersection2 = function intersection3(pt1, v1, pt2, v2) {
|
|
847
|
-
if (v1.x === 0)
|
|
848
|
-
return verticalIntersection(pt2, v2, pt1.x);
|
|
849
|
-
if (v2.x === 0)
|
|
850
|
-
return verticalIntersection(pt1, v1, pt2.x);
|
|
851
|
-
if (v1.y === 0)
|
|
852
|
-
return horizontalIntersection(pt2, v2, pt1.y);
|
|
853
|
-
if (v2.y === 0)
|
|
854
|
-
return horizontalIntersection(pt1, v1, pt2.y);
|
|
855
|
-
var kross = crossProduct(v1, v2);
|
|
856
|
-
if (kross == 0)
|
|
857
|
-
return null;
|
|
858
|
-
var ve = {
|
|
859
|
-
x: pt2.x - pt1.x,
|
|
860
|
-
y: pt2.y - pt1.y
|
|
861
|
-
};
|
|
862
|
-
var d1 = crossProduct(ve, v1) / kross;
|
|
863
|
-
var d2 = crossProduct(ve, v2) / kross;
|
|
864
|
-
var x1 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x;
|
|
865
|
-
var y1 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y;
|
|
866
|
-
var x = (x1 + x2) / 2;
|
|
867
|
-
var y = (y1 + y2) / 2;
|
|
868
|
-
return {
|
|
869
|
-
x,
|
|
870
|
-
y
|
|
871
|
-
};
|
|
872
|
-
};
|
|
873
|
-
var SweepEvent = /* @__PURE__ */ function() {
|
|
874
|
-
_createClass(SweepEvent2, null, [{
|
|
875
|
-
key: "compare",
|
|
876
|
-
value: function compare(a, b) {
|
|
877
|
-
var ptCmp = SweepEvent2.comparePoints(a.point, b.point);
|
|
878
|
-
if (ptCmp !== 0)
|
|
879
|
-
return ptCmp;
|
|
880
|
-
if (a.point !== b.point)
|
|
881
|
-
a.link(b);
|
|
882
|
-
if (a.isLeft !== b.isLeft)
|
|
883
|
-
return a.isLeft ? 1 : -1;
|
|
884
|
-
return Segment.compare(a.segment, b.segment);
|
|
885
|
-
}
|
|
886
|
-
}, {
|
|
887
|
-
key: "comparePoints",
|
|
888
|
-
value: function comparePoints(aPt, bPt) {
|
|
889
|
-
if (aPt.x < bPt.x)
|
|
890
|
-
return -1;
|
|
891
|
-
if (aPt.x > bPt.x)
|
|
892
|
-
return 1;
|
|
893
|
-
if (aPt.y < bPt.y)
|
|
894
|
-
return -1;
|
|
895
|
-
if (aPt.y > bPt.y)
|
|
896
|
-
return 1;
|
|
897
|
-
return 0;
|
|
898
|
-
}
|
|
899
|
-
}]);
|
|
900
|
-
function SweepEvent2(point, isLeft) {
|
|
901
|
-
_classCallCheck(this, SweepEvent2);
|
|
902
|
-
if (point.events === void 0)
|
|
903
|
-
point.events = [this];
|
|
904
|
-
else
|
|
905
|
-
point.events.push(this);
|
|
906
|
-
this.point = point;
|
|
907
|
-
this.isLeft = isLeft;
|
|
908
|
-
}
|
|
909
|
-
_createClass(SweepEvent2, [{
|
|
910
|
-
key: "link",
|
|
911
|
-
value: function link(other) {
|
|
912
|
-
if (other.point === this.point) {
|
|
913
|
-
throw new Error("Tried to link already linked events");
|
|
914
|
-
}
|
|
915
|
-
var otherEvents = other.point.events;
|
|
916
|
-
for (var i = 0, iMax = otherEvents.length; i < iMax; i++) {
|
|
917
|
-
var evt = otherEvents[i];
|
|
918
|
-
this.point.events.push(evt);
|
|
919
|
-
evt.point = this.point;
|
|
920
|
-
}
|
|
921
|
-
this.checkForConsuming();
|
|
922
|
-
}
|
|
923
|
-
}, {
|
|
924
|
-
key: "checkForConsuming",
|
|
925
|
-
value: function checkForConsuming() {
|
|
926
|
-
var numEvents = this.point.events.length;
|
|
927
|
-
for (var i = 0; i < numEvents; i++) {
|
|
928
|
-
var evt1 = this.point.events[i];
|
|
929
|
-
if (evt1.segment.consumedBy !== void 0)
|
|
930
|
-
continue;
|
|
931
|
-
for (var j = i + 1; j < numEvents; j++) {
|
|
932
|
-
var evt2 = this.point.events[j];
|
|
933
|
-
if (evt2.consumedBy !== void 0)
|
|
934
|
-
continue;
|
|
935
|
-
if (evt1.otherSE.point.events !== evt2.otherSE.point.events)
|
|
936
|
-
continue;
|
|
937
|
-
evt1.segment.consume(evt2.segment);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
}, {
|
|
942
|
-
key: "getAvailableLinkedEvents",
|
|
943
|
-
value: function getAvailableLinkedEvents() {
|
|
944
|
-
var events = [];
|
|
945
|
-
for (var i = 0, iMax = this.point.events.length; i < iMax; i++) {
|
|
946
|
-
var evt = this.point.events[i];
|
|
947
|
-
if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
|
|
948
|
-
events.push(evt);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
return events;
|
|
952
|
-
}
|
|
953
|
-
}, {
|
|
954
|
-
key: "getLeftmostComparator",
|
|
955
|
-
value: function getLeftmostComparator(baseEvent) {
|
|
956
|
-
var _this = this;
|
|
957
|
-
var cache = /* @__PURE__ */ new Map();
|
|
958
|
-
var fillCache = function fillCache2(linkedEvent) {
|
|
959
|
-
var nextEvent = linkedEvent.otherSE;
|
|
960
|
-
cache.set(linkedEvent, {
|
|
961
|
-
sine: sineOfAngle(_this.point, baseEvent.point, nextEvent.point),
|
|
962
|
-
cosine: cosineOfAngle(_this.point, baseEvent.point, nextEvent.point)
|
|
963
|
-
});
|
|
964
|
-
};
|
|
965
|
-
return function(a, b) {
|
|
966
|
-
if (!cache.has(a))
|
|
967
|
-
fillCache(a);
|
|
968
|
-
if (!cache.has(b))
|
|
969
|
-
fillCache(b);
|
|
970
|
-
var _cache$get = cache.get(a), asine = _cache$get.sine, acosine = _cache$get.cosine;
|
|
971
|
-
var _cache$get2 = cache.get(b), bsine = _cache$get2.sine, bcosine = _cache$get2.cosine;
|
|
972
|
-
if (asine >= 0 && bsine >= 0) {
|
|
973
|
-
if (acosine < bcosine)
|
|
974
|
-
return 1;
|
|
975
|
-
if (acosine > bcosine)
|
|
976
|
-
return -1;
|
|
977
|
-
return 0;
|
|
978
|
-
}
|
|
979
|
-
if (asine < 0 && bsine < 0) {
|
|
980
|
-
if (acosine < bcosine)
|
|
981
|
-
return -1;
|
|
982
|
-
if (acosine > bcosine)
|
|
983
|
-
return 1;
|
|
984
|
-
return 0;
|
|
985
|
-
}
|
|
986
|
-
if (bsine < asine)
|
|
987
|
-
return -1;
|
|
988
|
-
if (bsine > asine)
|
|
989
|
-
return 1;
|
|
990
|
-
return 0;
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
}]);
|
|
994
|
-
return SweepEvent2;
|
|
995
|
-
}();
|
|
996
|
-
var segmentId = 0;
|
|
997
|
-
var Segment = /* @__PURE__ */ function() {
|
|
998
|
-
_createClass(Segment2, null, [{
|
|
999
|
-
key: "compare",
|
|
1000
|
-
value: function compare(a, b) {
|
|
1001
|
-
var alx = a.leftSE.point.x;
|
|
1002
|
-
var blx = b.leftSE.point.x;
|
|
1003
|
-
var arx = a.rightSE.point.x;
|
|
1004
|
-
var brx = b.rightSE.point.x;
|
|
1005
|
-
if (brx < alx)
|
|
1006
|
-
return 1;
|
|
1007
|
-
if (arx < blx)
|
|
1008
|
-
return -1;
|
|
1009
|
-
var aly = a.leftSE.point.y;
|
|
1010
|
-
var bly = b.leftSE.point.y;
|
|
1011
|
-
var ary = a.rightSE.point.y;
|
|
1012
|
-
var bry = b.rightSE.point.y;
|
|
1013
|
-
if (alx < blx) {
|
|
1014
|
-
if (bly < aly && bly < ary)
|
|
1015
|
-
return 1;
|
|
1016
|
-
if (bly > aly && bly > ary)
|
|
1017
|
-
return -1;
|
|
1018
|
-
var aCmpBLeft = a.comparePoint(b.leftSE.point);
|
|
1019
|
-
if (aCmpBLeft < 0)
|
|
1020
|
-
return 1;
|
|
1021
|
-
if (aCmpBLeft > 0)
|
|
1022
|
-
return -1;
|
|
1023
|
-
var bCmpARight = b.comparePoint(a.rightSE.point);
|
|
1024
|
-
if (bCmpARight !== 0)
|
|
1025
|
-
return bCmpARight;
|
|
1026
|
-
return -1;
|
|
1027
|
-
}
|
|
1028
|
-
if (alx > blx) {
|
|
1029
|
-
if (aly < bly && aly < bry)
|
|
1030
|
-
return -1;
|
|
1031
|
-
if (aly > bly && aly > bry)
|
|
1032
|
-
return 1;
|
|
1033
|
-
var bCmpALeft = b.comparePoint(a.leftSE.point);
|
|
1034
|
-
if (bCmpALeft !== 0)
|
|
1035
|
-
return bCmpALeft;
|
|
1036
|
-
var aCmpBRight = a.comparePoint(b.rightSE.point);
|
|
1037
|
-
if (aCmpBRight < 0)
|
|
1038
|
-
return 1;
|
|
1039
|
-
if (aCmpBRight > 0)
|
|
1040
|
-
return -1;
|
|
1041
|
-
return 1;
|
|
1042
|
-
}
|
|
1043
|
-
if (aly < bly)
|
|
1044
|
-
return -1;
|
|
1045
|
-
if (aly > bly)
|
|
1046
|
-
return 1;
|
|
1047
|
-
if (arx < brx) {
|
|
1048
|
-
var _bCmpARight = b.comparePoint(a.rightSE.point);
|
|
1049
|
-
if (_bCmpARight !== 0)
|
|
1050
|
-
return _bCmpARight;
|
|
1051
|
-
}
|
|
1052
|
-
if (arx > brx) {
|
|
1053
|
-
var _aCmpBRight = a.comparePoint(b.rightSE.point);
|
|
1054
|
-
if (_aCmpBRight < 0)
|
|
1055
|
-
return 1;
|
|
1056
|
-
if (_aCmpBRight > 0)
|
|
1057
|
-
return -1;
|
|
1058
|
-
}
|
|
1059
|
-
if (arx !== brx) {
|
|
1060
|
-
var ay = ary - aly;
|
|
1061
|
-
var ax = arx - alx;
|
|
1062
|
-
var by = bry - bly;
|
|
1063
|
-
var bx = brx - blx;
|
|
1064
|
-
if (ay > ax && by < bx)
|
|
1065
|
-
return 1;
|
|
1066
|
-
if (ay < ax && by > bx)
|
|
1067
|
-
return -1;
|
|
1068
|
-
}
|
|
1069
|
-
if (arx > brx)
|
|
1070
|
-
return 1;
|
|
1071
|
-
if (arx < brx)
|
|
1072
|
-
return -1;
|
|
1073
|
-
if (ary < bry)
|
|
1074
|
-
return -1;
|
|
1075
|
-
if (ary > bry)
|
|
1076
|
-
return 1;
|
|
1077
|
-
if (a.id < b.id)
|
|
1078
|
-
return -1;
|
|
1079
|
-
if (a.id > b.id)
|
|
1080
|
-
return 1;
|
|
1081
|
-
return 0;
|
|
1082
|
-
}
|
|
1083
|
-
}]);
|
|
1084
|
-
function Segment2(leftSE, rightSE, rings, windings) {
|
|
1085
|
-
_classCallCheck(this, Segment2);
|
|
1086
|
-
this.id = ++segmentId;
|
|
1087
|
-
this.leftSE = leftSE;
|
|
1088
|
-
leftSE.segment = this;
|
|
1089
|
-
leftSE.otherSE = rightSE;
|
|
1090
|
-
this.rightSE = rightSE;
|
|
1091
|
-
rightSE.segment = this;
|
|
1092
|
-
rightSE.otherSE = leftSE;
|
|
1093
|
-
this.rings = rings;
|
|
1094
|
-
this.windings = windings;
|
|
1095
|
-
}
|
|
1096
|
-
_createClass(Segment2, [{
|
|
1097
|
-
key: "replaceRightSE",
|
|
1098
|
-
value: function replaceRightSE(newRightSE) {
|
|
1099
|
-
this.rightSE = newRightSE;
|
|
1100
|
-
this.rightSE.segment = this;
|
|
1101
|
-
this.rightSE.otherSE = this.leftSE;
|
|
1102
|
-
this.leftSE.otherSE = this.rightSE;
|
|
1103
|
-
}
|
|
1104
|
-
}, {
|
|
1105
|
-
key: "bbox",
|
|
1106
|
-
value: function bbox() {
|
|
1107
|
-
var y1 = this.leftSE.point.y;
|
|
1108
|
-
var y2 = this.rightSE.point.y;
|
|
1109
|
-
return {
|
|
1110
|
-
ll: {
|
|
1111
|
-
x: this.leftSE.point.x,
|
|
1112
|
-
y: y1 < y2 ? y1 : y2
|
|
1113
|
-
},
|
|
1114
|
-
ur: {
|
|
1115
|
-
x: this.rightSE.point.x,
|
|
1116
|
-
y: y1 > y2 ? y1 : y2
|
|
1117
|
-
}
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
}, {
|
|
1121
|
-
key: "vector",
|
|
1122
|
-
value: function vector() {
|
|
1123
|
-
return {
|
|
1124
|
-
x: this.rightSE.point.x - this.leftSE.point.x,
|
|
1125
|
-
y: this.rightSE.point.y - this.leftSE.point.y
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
}, {
|
|
1129
|
-
key: "isAnEndpoint",
|
|
1130
|
-
value: function isAnEndpoint(pt) {
|
|
1131
|
-
return pt.x === this.leftSE.point.x && pt.y === this.leftSE.point.y || pt.x === this.rightSE.point.x && pt.y === this.rightSE.point.y;
|
|
1132
|
-
}
|
|
1133
|
-
}, {
|
|
1134
|
-
key: "comparePoint",
|
|
1135
|
-
value: function comparePoint(point) {
|
|
1136
|
-
if (this.isAnEndpoint(point))
|
|
1137
|
-
return 0;
|
|
1138
|
-
var lPt = this.leftSE.point;
|
|
1139
|
-
var rPt = this.rightSE.point;
|
|
1140
|
-
var v = this.vector();
|
|
1141
|
-
if (lPt.x === rPt.x) {
|
|
1142
|
-
if (point.x === lPt.x)
|
|
1143
|
-
return 0;
|
|
1144
|
-
return point.x < lPt.x ? 1 : -1;
|
|
1145
|
-
}
|
|
1146
|
-
var yDist = (point.y - lPt.y) / v.y;
|
|
1147
|
-
var xFromYDist = lPt.x + yDist * v.x;
|
|
1148
|
-
if (point.x === xFromYDist)
|
|
1149
|
-
return 0;
|
|
1150
|
-
var xDist = (point.x - lPt.x) / v.x;
|
|
1151
|
-
var yFromXDist = lPt.y + xDist * v.y;
|
|
1152
|
-
if (point.y === yFromXDist)
|
|
1153
|
-
return 0;
|
|
1154
|
-
return point.y < yFromXDist ? -1 : 1;
|
|
1155
|
-
}
|
|
1156
|
-
}, {
|
|
1157
|
-
key: "getIntersection",
|
|
1158
|
-
value: function getIntersection(other) {
|
|
1159
|
-
var tBbox = this.bbox();
|
|
1160
|
-
var oBbox = other.bbox();
|
|
1161
|
-
var bboxOverlap = getBboxOverlap(tBbox, oBbox);
|
|
1162
|
-
if (bboxOverlap === null)
|
|
1163
|
-
return null;
|
|
1164
|
-
var tlp = this.leftSE.point;
|
|
1165
|
-
var trp = this.rightSE.point;
|
|
1166
|
-
var olp = other.leftSE.point;
|
|
1167
|
-
var orp = other.rightSE.point;
|
|
1168
|
-
var touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0;
|
|
1169
|
-
var touchesThisLSE = isInBbox(oBbox, tlp) && other.comparePoint(tlp) === 0;
|
|
1170
|
-
var touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0;
|
|
1171
|
-
var touchesThisRSE = isInBbox(oBbox, trp) && other.comparePoint(trp) === 0;
|
|
1172
|
-
if (touchesThisLSE && touchesOtherLSE) {
|
|
1173
|
-
if (touchesThisRSE && !touchesOtherRSE)
|
|
1174
|
-
return trp;
|
|
1175
|
-
if (!touchesThisRSE && touchesOtherRSE)
|
|
1176
|
-
return orp;
|
|
1177
|
-
return null;
|
|
1178
|
-
}
|
|
1179
|
-
if (touchesThisLSE) {
|
|
1180
|
-
if (touchesOtherRSE) {
|
|
1181
|
-
if (tlp.x === orp.x && tlp.y === orp.y)
|
|
1182
|
-
return null;
|
|
1183
|
-
}
|
|
1184
|
-
return tlp;
|
|
1185
|
-
}
|
|
1186
|
-
if (touchesOtherLSE) {
|
|
1187
|
-
if (touchesThisRSE) {
|
|
1188
|
-
if (trp.x === olp.x && trp.y === olp.y)
|
|
1189
|
-
return null;
|
|
1190
|
-
}
|
|
1191
|
-
return olp;
|
|
1192
|
-
}
|
|
1193
|
-
if (touchesThisRSE && touchesOtherRSE)
|
|
1194
|
-
return null;
|
|
1195
|
-
if (touchesThisRSE)
|
|
1196
|
-
return trp;
|
|
1197
|
-
if (touchesOtherRSE)
|
|
1198
|
-
return orp;
|
|
1199
|
-
var pt = intersection2(tlp, this.vector(), olp, other.vector());
|
|
1200
|
-
if (pt === null)
|
|
1201
|
-
return null;
|
|
1202
|
-
if (!isInBbox(bboxOverlap, pt))
|
|
1203
|
-
return null;
|
|
1204
|
-
return rounder.round(pt.x, pt.y);
|
|
1205
|
-
}
|
|
1206
|
-
}, {
|
|
1207
|
-
key: "split",
|
|
1208
|
-
value: function split2(point) {
|
|
1209
|
-
var newEvents = [];
|
|
1210
|
-
var alreadyLinked = point.events !== void 0;
|
|
1211
|
-
var newLeftSE = new SweepEvent(point, true);
|
|
1212
|
-
var newRightSE = new SweepEvent(point, false);
|
|
1213
|
-
var oldRightSE = this.rightSE;
|
|
1214
|
-
this.replaceRightSE(newRightSE);
|
|
1215
|
-
newEvents.push(newRightSE);
|
|
1216
|
-
newEvents.push(newLeftSE);
|
|
1217
|
-
var newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
|
|
1218
|
-
if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
|
|
1219
|
-
newSeg.swapEvents();
|
|
1220
|
-
}
|
|
1221
|
-
if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
|
|
1222
|
-
this.swapEvents();
|
|
1223
|
-
}
|
|
1224
|
-
if (alreadyLinked) {
|
|
1225
|
-
newLeftSE.checkForConsuming();
|
|
1226
|
-
newRightSE.checkForConsuming();
|
|
1227
|
-
}
|
|
1228
|
-
return newEvents;
|
|
1229
|
-
}
|
|
1230
|
-
}, {
|
|
1231
|
-
key: "swapEvents",
|
|
1232
|
-
value: function swapEvents() {
|
|
1233
|
-
var tmpEvt = this.rightSE;
|
|
1234
|
-
this.rightSE = this.leftSE;
|
|
1235
|
-
this.leftSE = tmpEvt;
|
|
1236
|
-
this.leftSE.isLeft = true;
|
|
1237
|
-
this.rightSE.isLeft = false;
|
|
1238
|
-
for (var i = 0, iMax = this.windings.length; i < iMax; i++) {
|
|
1239
|
-
this.windings[i] *= -1;
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
}, {
|
|
1243
|
-
key: "consume",
|
|
1244
|
-
value: function consume(other) {
|
|
1245
|
-
var consumer = this;
|
|
1246
|
-
var consumee = other;
|
|
1247
|
-
while (consumer.consumedBy) {
|
|
1248
|
-
consumer = consumer.consumedBy;
|
|
1249
|
-
}
|
|
1250
|
-
while (consumee.consumedBy) {
|
|
1251
|
-
consumee = consumee.consumedBy;
|
|
1252
|
-
}
|
|
1253
|
-
var cmp2 = Segment2.compare(consumer, consumee);
|
|
1254
|
-
if (cmp2 === 0)
|
|
1255
|
-
return;
|
|
1256
|
-
if (cmp2 > 0) {
|
|
1257
|
-
var tmp = consumer;
|
|
1258
|
-
consumer = consumee;
|
|
1259
|
-
consumee = tmp;
|
|
1260
|
-
}
|
|
1261
|
-
if (consumer.prev === consumee) {
|
|
1262
|
-
var _tmp = consumer;
|
|
1263
|
-
consumer = consumee;
|
|
1264
|
-
consumee = _tmp;
|
|
1265
|
-
}
|
|
1266
|
-
for (var i = 0, iMax = consumee.rings.length; i < iMax; i++) {
|
|
1267
|
-
var ring = consumee.rings[i];
|
|
1268
|
-
var winding = consumee.windings[i];
|
|
1269
|
-
var index2 = consumer.rings.indexOf(ring);
|
|
1270
|
-
if (index2 === -1) {
|
|
1271
|
-
consumer.rings.push(ring);
|
|
1272
|
-
consumer.windings.push(winding);
|
|
1273
|
-
} else
|
|
1274
|
-
consumer.windings[index2] += winding;
|
|
1275
|
-
}
|
|
1276
|
-
consumee.rings = null;
|
|
1277
|
-
consumee.windings = null;
|
|
1278
|
-
consumee.consumedBy = consumer;
|
|
1279
|
-
consumee.leftSE.consumedBy = consumer.leftSE;
|
|
1280
|
-
consumee.rightSE.consumedBy = consumer.rightSE;
|
|
1281
|
-
}
|
|
1282
|
-
}, {
|
|
1283
|
-
key: "prevInResult",
|
|
1284
|
-
value: function prevInResult() {
|
|
1285
|
-
if (this._prevInResult !== void 0)
|
|
1286
|
-
return this._prevInResult;
|
|
1287
|
-
if (!this.prev)
|
|
1288
|
-
this._prevInResult = null;
|
|
1289
|
-
else if (this.prev.isInResult())
|
|
1290
|
-
this._prevInResult = this.prev;
|
|
1291
|
-
else
|
|
1292
|
-
this._prevInResult = this.prev.prevInResult();
|
|
1293
|
-
return this._prevInResult;
|
|
1294
|
-
}
|
|
1295
|
-
}, {
|
|
1296
|
-
key: "beforeState",
|
|
1297
|
-
value: function beforeState() {
|
|
1298
|
-
if (this._beforeState !== void 0)
|
|
1299
|
-
return this._beforeState;
|
|
1300
|
-
if (!this.prev)
|
|
1301
|
-
this._beforeState = {
|
|
1302
|
-
rings: [],
|
|
1303
|
-
windings: [],
|
|
1304
|
-
multiPolys: []
|
|
1305
|
-
};
|
|
1306
|
-
else {
|
|
1307
|
-
var seg = this.prev.consumedBy || this.prev;
|
|
1308
|
-
this._beforeState = seg.afterState();
|
|
1309
|
-
}
|
|
1310
|
-
return this._beforeState;
|
|
1311
|
-
}
|
|
1312
|
-
}, {
|
|
1313
|
-
key: "afterState",
|
|
1314
|
-
value: function afterState() {
|
|
1315
|
-
if (this._afterState !== void 0)
|
|
1316
|
-
return this._afterState;
|
|
1317
|
-
var beforeState = this.beforeState();
|
|
1318
|
-
this._afterState = {
|
|
1319
|
-
rings: beforeState.rings.slice(0),
|
|
1320
|
-
windings: beforeState.windings.slice(0),
|
|
1321
|
-
multiPolys: []
|
|
1322
|
-
};
|
|
1323
|
-
var ringsAfter = this._afterState.rings;
|
|
1324
|
-
var windingsAfter = this._afterState.windings;
|
|
1325
|
-
var mpsAfter = this._afterState.multiPolys;
|
|
1326
|
-
for (var i = 0, iMax = this.rings.length; i < iMax; i++) {
|
|
1327
|
-
var ring = this.rings[i];
|
|
1328
|
-
var winding = this.windings[i];
|
|
1329
|
-
var index2 = ringsAfter.indexOf(ring);
|
|
1330
|
-
if (index2 === -1) {
|
|
1331
|
-
ringsAfter.push(ring);
|
|
1332
|
-
windingsAfter.push(winding);
|
|
1333
|
-
} else
|
|
1334
|
-
windingsAfter[index2] += winding;
|
|
1335
|
-
}
|
|
1336
|
-
var polysAfter = [];
|
|
1337
|
-
var polysExclude = [];
|
|
1338
|
-
for (var _i = 0, _iMax = ringsAfter.length; _i < _iMax; _i++) {
|
|
1339
|
-
if (windingsAfter[_i] === 0)
|
|
1340
|
-
continue;
|
|
1341
|
-
var _ring = ringsAfter[_i];
|
|
1342
|
-
var poly = _ring.poly;
|
|
1343
|
-
if (polysExclude.indexOf(poly) !== -1)
|
|
1344
|
-
continue;
|
|
1345
|
-
if (_ring.isExterior)
|
|
1346
|
-
polysAfter.push(poly);
|
|
1347
|
-
else {
|
|
1348
|
-
if (polysExclude.indexOf(poly) === -1)
|
|
1349
|
-
polysExclude.push(poly);
|
|
1350
|
-
var _index = polysAfter.indexOf(_ring.poly);
|
|
1351
|
-
if (_index !== -1)
|
|
1352
|
-
polysAfter.splice(_index, 1);
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
for (var _i2 = 0, _iMax2 = polysAfter.length; _i2 < _iMax2; _i2++) {
|
|
1356
|
-
var mp = polysAfter[_i2].multiPoly;
|
|
1357
|
-
if (mpsAfter.indexOf(mp) === -1)
|
|
1358
|
-
mpsAfter.push(mp);
|
|
1359
|
-
}
|
|
1360
|
-
return this._afterState;
|
|
1361
|
-
}
|
|
1362
|
-
}, {
|
|
1363
|
-
key: "isInResult",
|
|
1364
|
-
value: function isInResult() {
|
|
1365
|
-
if (this.consumedBy)
|
|
1366
|
-
return false;
|
|
1367
|
-
if (this._isInResult !== void 0)
|
|
1368
|
-
return this._isInResult;
|
|
1369
|
-
var mpsBefore = this.beforeState().multiPolys;
|
|
1370
|
-
var mpsAfter = this.afterState().multiPolys;
|
|
1371
|
-
switch (operation.type) {
|
|
1372
|
-
case "union": {
|
|
1373
|
-
var noBefores = mpsBefore.length === 0;
|
|
1374
|
-
var noAfters = mpsAfter.length === 0;
|
|
1375
|
-
this._isInResult = noBefores !== noAfters;
|
|
1376
|
-
break;
|
|
1377
|
-
}
|
|
1378
|
-
case "intersection": {
|
|
1379
|
-
var least;
|
|
1380
|
-
var most;
|
|
1381
|
-
if (mpsBefore.length < mpsAfter.length) {
|
|
1382
|
-
least = mpsBefore.length;
|
|
1383
|
-
most = mpsAfter.length;
|
|
1384
|
-
} else {
|
|
1385
|
-
least = mpsAfter.length;
|
|
1386
|
-
most = mpsBefore.length;
|
|
1387
|
-
}
|
|
1388
|
-
this._isInResult = most === operation.numMultiPolys && least < most;
|
|
1389
|
-
break;
|
|
1390
|
-
}
|
|
1391
|
-
case "xor": {
|
|
1392
|
-
var diff = Math.abs(mpsBefore.length - mpsAfter.length);
|
|
1393
|
-
this._isInResult = diff % 2 === 1;
|
|
1394
|
-
break;
|
|
1395
|
-
}
|
|
1396
|
-
case "difference": {
|
|
1397
|
-
var isJustSubject = function isJustSubject2(mps) {
|
|
1398
|
-
return mps.length === 1 && mps[0].isSubject;
|
|
1399
|
-
};
|
|
1400
|
-
this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
default:
|
|
1404
|
-
throw new Error("Unrecognized operation type found ".concat(operation.type));
|
|
1405
|
-
}
|
|
1406
|
-
return this._isInResult;
|
|
1407
|
-
}
|
|
1408
|
-
}], [{
|
|
1409
|
-
key: "fromRing",
|
|
1410
|
-
value: function fromRing(pt1, pt2, ring) {
|
|
1411
|
-
var leftPt, rightPt, winding;
|
|
1412
|
-
var cmpPts = SweepEvent.comparePoints(pt1, pt2);
|
|
1413
|
-
if (cmpPts < 0) {
|
|
1414
|
-
leftPt = pt1;
|
|
1415
|
-
rightPt = pt2;
|
|
1416
|
-
winding = 1;
|
|
1417
|
-
} else if (cmpPts > 0) {
|
|
1418
|
-
leftPt = pt2;
|
|
1419
|
-
rightPt = pt1;
|
|
1420
|
-
winding = -1;
|
|
1421
|
-
} else
|
|
1422
|
-
throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
|
|
1423
|
-
var leftSE = new SweepEvent(leftPt, true);
|
|
1424
|
-
var rightSE = new SweepEvent(rightPt, false);
|
|
1425
|
-
return new Segment2(leftSE, rightSE, [ring], [winding]);
|
|
1426
|
-
}
|
|
1427
|
-
}]);
|
|
1428
|
-
return Segment2;
|
|
1429
|
-
}();
|
|
1430
|
-
var RingIn = /* @__PURE__ */ function() {
|
|
1431
|
-
function RingIn2(geomRing, poly, isExterior) {
|
|
1432
|
-
_classCallCheck(this, RingIn2);
|
|
1433
|
-
if (!Array.isArray(geomRing) || geomRing.length === 0) {
|
|
1434
|
-
throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
|
|
1435
|
-
}
|
|
1436
|
-
this.poly = poly;
|
|
1437
|
-
this.isExterior = isExterior;
|
|
1438
|
-
this.segments = [];
|
|
1439
|
-
if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
|
|
1440
|
-
throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
|
|
1441
|
-
}
|
|
1442
|
-
var firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]);
|
|
1443
|
-
this.bbox = {
|
|
1444
|
-
ll: {
|
|
1445
|
-
x: firstPoint.x,
|
|
1446
|
-
y: firstPoint.y
|
|
1447
|
-
},
|
|
1448
|
-
ur: {
|
|
1449
|
-
x: firstPoint.x,
|
|
1450
|
-
y: firstPoint.y
|
|
1451
|
-
}
|
|
1452
|
-
};
|
|
1453
|
-
var prevPoint = firstPoint;
|
|
1454
|
-
for (var i = 1, iMax = geomRing.length; i < iMax; i++) {
|
|
1455
|
-
if (typeof geomRing[i][0] !== "number" || typeof geomRing[i][1] !== "number") {
|
|
1456
|
-
throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
|
|
1457
|
-
}
|
|
1458
|
-
var point = rounder.round(geomRing[i][0], geomRing[i][1]);
|
|
1459
|
-
if (point.x === prevPoint.x && point.y === prevPoint.y)
|
|
1460
|
-
continue;
|
|
1461
|
-
this.segments.push(Segment.fromRing(prevPoint, point, this));
|
|
1462
|
-
if (point.x < this.bbox.ll.x)
|
|
1463
|
-
this.bbox.ll.x = point.x;
|
|
1464
|
-
if (point.y < this.bbox.ll.y)
|
|
1465
|
-
this.bbox.ll.y = point.y;
|
|
1466
|
-
if (point.x > this.bbox.ur.x)
|
|
1467
|
-
this.bbox.ur.x = point.x;
|
|
1468
|
-
if (point.y > this.bbox.ur.y)
|
|
1469
|
-
this.bbox.ur.y = point.y;
|
|
1470
|
-
prevPoint = point;
|
|
1471
|
-
}
|
|
1472
|
-
if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) {
|
|
1473
|
-
this.segments.push(Segment.fromRing(prevPoint, firstPoint, this));
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
_createClass(RingIn2, [{
|
|
1477
|
-
key: "getSweepEvents",
|
|
1478
|
-
value: function getSweepEvents() {
|
|
1479
|
-
var sweepEvents = [];
|
|
1480
|
-
for (var i = 0, iMax = this.segments.length; i < iMax; i++) {
|
|
1481
|
-
var segment = this.segments[i];
|
|
1482
|
-
sweepEvents.push(segment.leftSE);
|
|
1483
|
-
sweepEvents.push(segment.rightSE);
|
|
1484
|
-
}
|
|
1485
|
-
return sweepEvents;
|
|
1486
|
-
}
|
|
1487
|
-
}]);
|
|
1488
|
-
return RingIn2;
|
|
1489
|
-
}();
|
|
1490
|
-
var PolyIn = /* @__PURE__ */ function() {
|
|
1491
|
-
function PolyIn2(geomPoly, multiPoly) {
|
|
1492
|
-
_classCallCheck(this, PolyIn2);
|
|
1493
|
-
if (!Array.isArray(geomPoly)) {
|
|
1494
|
-
throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
|
|
1495
|
-
}
|
|
1496
|
-
this.exteriorRing = new RingIn(geomPoly[0], this, true);
|
|
1497
|
-
this.bbox = {
|
|
1498
|
-
ll: {
|
|
1499
|
-
x: this.exteriorRing.bbox.ll.x,
|
|
1500
|
-
y: this.exteriorRing.bbox.ll.y
|
|
1501
|
-
},
|
|
1502
|
-
ur: {
|
|
1503
|
-
x: this.exteriorRing.bbox.ur.x,
|
|
1504
|
-
y: this.exteriorRing.bbox.ur.y
|
|
1505
|
-
}
|
|
1506
|
-
};
|
|
1507
|
-
this.interiorRings = [];
|
|
1508
|
-
for (var i = 1, iMax = geomPoly.length; i < iMax; i++) {
|
|
1509
|
-
var ring = new RingIn(geomPoly[i], this, false);
|
|
1510
|
-
if (ring.bbox.ll.x < this.bbox.ll.x)
|
|
1511
|
-
this.bbox.ll.x = ring.bbox.ll.x;
|
|
1512
|
-
if (ring.bbox.ll.y < this.bbox.ll.y)
|
|
1513
|
-
this.bbox.ll.y = ring.bbox.ll.y;
|
|
1514
|
-
if (ring.bbox.ur.x > this.bbox.ur.x)
|
|
1515
|
-
this.bbox.ur.x = ring.bbox.ur.x;
|
|
1516
|
-
if (ring.bbox.ur.y > this.bbox.ur.y)
|
|
1517
|
-
this.bbox.ur.y = ring.bbox.ur.y;
|
|
1518
|
-
this.interiorRings.push(ring);
|
|
1519
|
-
}
|
|
1520
|
-
this.multiPoly = multiPoly;
|
|
1521
|
-
}
|
|
1522
|
-
_createClass(PolyIn2, [{
|
|
1523
|
-
key: "getSweepEvents",
|
|
1524
|
-
value: function getSweepEvents() {
|
|
1525
|
-
var sweepEvents = this.exteriorRing.getSweepEvents();
|
|
1526
|
-
for (var i = 0, iMax = this.interiorRings.length; i < iMax; i++) {
|
|
1527
|
-
var ringSweepEvents = this.interiorRings[i].getSweepEvents();
|
|
1528
|
-
for (var j = 0, jMax = ringSweepEvents.length; j < jMax; j++) {
|
|
1529
|
-
sweepEvents.push(ringSweepEvents[j]);
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
return sweepEvents;
|
|
1533
|
-
}
|
|
1534
|
-
}]);
|
|
1535
|
-
return PolyIn2;
|
|
1536
|
-
}();
|
|
1537
|
-
var MultiPolyIn = /* @__PURE__ */ function() {
|
|
1538
|
-
function MultiPolyIn2(geom, isSubject) {
|
|
1539
|
-
_classCallCheck(this, MultiPolyIn2);
|
|
1540
|
-
if (!Array.isArray(geom)) {
|
|
1541
|
-
throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
|
|
1542
|
-
}
|
|
1543
|
-
try {
|
|
1544
|
-
if (typeof geom[0][0][0] === "number")
|
|
1545
|
-
geom = [geom];
|
|
1546
|
-
} catch (ex) {
|
|
1547
|
-
}
|
|
1548
|
-
this.polys = [];
|
|
1549
|
-
this.bbox = {
|
|
1550
|
-
ll: {
|
|
1551
|
-
x: Number.POSITIVE_INFINITY,
|
|
1552
|
-
y: Number.POSITIVE_INFINITY
|
|
1553
|
-
},
|
|
1554
|
-
ur: {
|
|
1555
|
-
x: Number.NEGATIVE_INFINITY,
|
|
1556
|
-
y: Number.NEGATIVE_INFINITY
|
|
1557
|
-
}
|
|
1558
|
-
};
|
|
1559
|
-
for (var i = 0, iMax = geom.length; i < iMax; i++) {
|
|
1560
|
-
var poly = new PolyIn(geom[i], this);
|
|
1561
|
-
if (poly.bbox.ll.x < this.bbox.ll.x)
|
|
1562
|
-
this.bbox.ll.x = poly.bbox.ll.x;
|
|
1563
|
-
if (poly.bbox.ll.y < this.bbox.ll.y)
|
|
1564
|
-
this.bbox.ll.y = poly.bbox.ll.y;
|
|
1565
|
-
if (poly.bbox.ur.x > this.bbox.ur.x)
|
|
1566
|
-
this.bbox.ur.x = poly.bbox.ur.x;
|
|
1567
|
-
if (poly.bbox.ur.y > this.bbox.ur.y)
|
|
1568
|
-
this.bbox.ur.y = poly.bbox.ur.y;
|
|
1569
|
-
this.polys.push(poly);
|
|
1570
|
-
}
|
|
1571
|
-
this.isSubject = isSubject;
|
|
1572
|
-
}
|
|
1573
|
-
_createClass(MultiPolyIn2, [{
|
|
1574
|
-
key: "getSweepEvents",
|
|
1575
|
-
value: function getSweepEvents() {
|
|
1576
|
-
var sweepEvents = [];
|
|
1577
|
-
for (var i = 0, iMax = this.polys.length; i < iMax; i++) {
|
|
1578
|
-
var polySweepEvents = this.polys[i].getSweepEvents();
|
|
1579
|
-
for (var j = 0, jMax = polySweepEvents.length; j < jMax; j++) {
|
|
1580
|
-
sweepEvents.push(polySweepEvents[j]);
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
return sweepEvents;
|
|
1584
|
-
}
|
|
1585
|
-
}]);
|
|
1586
|
-
return MultiPolyIn2;
|
|
1587
|
-
}();
|
|
1588
|
-
var RingOut = /* @__PURE__ */ function() {
|
|
1589
|
-
_createClass(RingOut2, null, [{
|
|
1590
|
-
key: "factory",
|
|
1591
|
-
value: function factory(allSegments) {
|
|
1592
|
-
var ringsOut = [];
|
|
1593
|
-
for (var i = 0, iMax = allSegments.length; i < iMax; i++) {
|
|
1594
|
-
var segment = allSegments[i];
|
|
1595
|
-
if (!segment.isInResult() || segment.ringOut)
|
|
1596
|
-
continue;
|
|
1597
|
-
var prevEvent = null;
|
|
1598
|
-
var event = segment.leftSE;
|
|
1599
|
-
var nextEvent = segment.rightSE;
|
|
1600
|
-
var events = [event];
|
|
1601
|
-
var startingPoint = event.point;
|
|
1602
|
-
var intersectionLEs = [];
|
|
1603
|
-
while (true) {
|
|
1604
|
-
prevEvent = event;
|
|
1605
|
-
event = nextEvent;
|
|
1606
|
-
events.push(event);
|
|
1607
|
-
if (event.point === startingPoint)
|
|
1608
|
-
break;
|
|
1609
|
-
while (true) {
|
|
1610
|
-
var availableLEs = event.getAvailableLinkedEvents();
|
|
1611
|
-
if (availableLEs.length === 0) {
|
|
1612
|
-
var firstPt = events[0].point;
|
|
1613
|
-
var lastPt = events[events.length - 1].point;
|
|
1614
|
-
throw new Error("Unable to complete output ring starting at [".concat(firstPt.x, ",") + " ".concat(firstPt.y, "]. Last matching segment found ends at") + " [".concat(lastPt.x, ", ").concat(lastPt.y, "]."));
|
|
1615
|
-
}
|
|
1616
|
-
if (availableLEs.length === 1) {
|
|
1617
|
-
nextEvent = availableLEs[0].otherSE;
|
|
1618
|
-
break;
|
|
1619
|
-
}
|
|
1620
|
-
var indexLE = null;
|
|
1621
|
-
for (var j = 0, jMax = intersectionLEs.length; j < jMax; j++) {
|
|
1622
|
-
if (intersectionLEs[j].point === event.point) {
|
|
1623
|
-
indexLE = j;
|
|
1624
|
-
break;
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
if (indexLE !== null) {
|
|
1628
|
-
var intersectionLE = intersectionLEs.splice(indexLE)[0];
|
|
1629
|
-
var ringEvents = events.splice(intersectionLE.index);
|
|
1630
|
-
ringEvents.unshift(ringEvents[0].otherSE);
|
|
1631
|
-
ringsOut.push(new RingOut2(ringEvents.reverse()));
|
|
1632
|
-
continue;
|
|
1633
|
-
}
|
|
1634
|
-
intersectionLEs.push({
|
|
1635
|
-
index: events.length,
|
|
1636
|
-
point: event.point
|
|
1637
|
-
});
|
|
1638
|
-
var comparator = event.getLeftmostComparator(prevEvent);
|
|
1639
|
-
nextEvent = availableLEs.sort(comparator)[0].otherSE;
|
|
1640
|
-
break;
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
ringsOut.push(new RingOut2(events));
|
|
1644
|
-
}
|
|
1645
|
-
return ringsOut;
|
|
1646
|
-
}
|
|
1647
|
-
}]);
|
|
1648
|
-
function RingOut2(events) {
|
|
1649
|
-
_classCallCheck(this, RingOut2);
|
|
1650
|
-
this.events = events;
|
|
1651
|
-
for (var i = 0, iMax = events.length; i < iMax; i++) {
|
|
1652
|
-
events[i].segment.ringOut = this;
|
|
1653
|
-
}
|
|
1654
|
-
this.poly = null;
|
|
1655
|
-
}
|
|
1656
|
-
_createClass(RingOut2, [{
|
|
1657
|
-
key: "getGeom",
|
|
1658
|
-
value: function getGeom() {
|
|
1659
|
-
var prevPt = this.events[0].point;
|
|
1660
|
-
var points = [prevPt];
|
|
1661
|
-
for (var i = 1, iMax = this.events.length - 1; i < iMax; i++) {
|
|
1662
|
-
var _pt = this.events[i].point;
|
|
1663
|
-
var _nextPt = this.events[i + 1].point;
|
|
1664
|
-
if (compareVectorAngles(_pt, prevPt, _nextPt) === 0)
|
|
1665
|
-
continue;
|
|
1666
|
-
points.push(_pt);
|
|
1667
|
-
prevPt = _pt;
|
|
1668
|
-
}
|
|
1669
|
-
if (points.length === 1)
|
|
1670
|
-
return null;
|
|
1671
|
-
var pt = points[0];
|
|
1672
|
-
var nextPt = points[1];
|
|
1673
|
-
if (compareVectorAngles(pt, prevPt, nextPt) === 0)
|
|
1674
|
-
points.shift();
|
|
1675
|
-
points.push(points[0]);
|
|
1676
|
-
var step = this.isExteriorRing() ? 1 : -1;
|
|
1677
|
-
var iStart = this.isExteriorRing() ? 0 : points.length - 1;
|
|
1678
|
-
var iEnd = this.isExteriorRing() ? points.length : -1;
|
|
1679
|
-
var orderedPoints = [];
|
|
1680
|
-
for (var _i = iStart; _i != iEnd; _i += step) {
|
|
1681
|
-
orderedPoints.push([points[_i].x, points[_i].y]);
|
|
1682
|
-
}
|
|
1683
|
-
return orderedPoints;
|
|
1684
|
-
}
|
|
1685
|
-
}, {
|
|
1686
|
-
key: "isExteriorRing",
|
|
1687
|
-
value: function isExteriorRing() {
|
|
1688
|
-
if (this._isExteriorRing === void 0) {
|
|
1689
|
-
var enclosing = this.enclosingRing();
|
|
1690
|
-
this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
|
|
1691
|
-
}
|
|
1692
|
-
return this._isExteriorRing;
|
|
1693
|
-
}
|
|
1694
|
-
}, {
|
|
1695
|
-
key: "enclosingRing",
|
|
1696
|
-
value: function enclosingRing() {
|
|
1697
|
-
if (this._enclosingRing === void 0) {
|
|
1698
|
-
this._enclosingRing = this._calcEnclosingRing();
|
|
1699
|
-
}
|
|
1700
|
-
return this._enclosingRing;
|
|
1701
|
-
}
|
|
1702
|
-
}, {
|
|
1703
|
-
key: "_calcEnclosingRing",
|
|
1704
|
-
value: function _calcEnclosingRing() {
|
|
1705
|
-
var leftMostEvt = this.events[0];
|
|
1706
|
-
for (var i = 1, iMax = this.events.length; i < iMax; i++) {
|
|
1707
|
-
var evt = this.events[i];
|
|
1708
|
-
if (SweepEvent.compare(leftMostEvt, evt) > 0)
|
|
1709
|
-
leftMostEvt = evt;
|
|
1710
|
-
}
|
|
1711
|
-
var prevSeg = leftMostEvt.segment.prevInResult();
|
|
1712
|
-
var prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
|
|
1713
|
-
while (true) {
|
|
1714
|
-
if (!prevSeg)
|
|
1715
|
-
return null;
|
|
1716
|
-
if (!prevPrevSeg)
|
|
1717
|
-
return prevSeg.ringOut;
|
|
1718
|
-
if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
|
|
1719
|
-
if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) {
|
|
1720
|
-
return prevSeg.ringOut;
|
|
1721
|
-
} else
|
|
1722
|
-
return prevSeg.ringOut.enclosingRing();
|
|
1723
|
-
}
|
|
1724
|
-
prevSeg = prevPrevSeg.prevInResult();
|
|
1725
|
-
prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
}]);
|
|
1729
|
-
return RingOut2;
|
|
1730
|
-
}();
|
|
1731
|
-
var PolyOut = /* @__PURE__ */ function() {
|
|
1732
|
-
function PolyOut2(exteriorRing) {
|
|
1733
|
-
_classCallCheck(this, PolyOut2);
|
|
1734
|
-
this.exteriorRing = exteriorRing;
|
|
1735
|
-
exteriorRing.poly = this;
|
|
1736
|
-
this.interiorRings = [];
|
|
1737
|
-
}
|
|
1738
|
-
_createClass(PolyOut2, [{
|
|
1739
|
-
key: "addInterior",
|
|
1740
|
-
value: function addInterior(ring) {
|
|
1741
|
-
this.interiorRings.push(ring);
|
|
1742
|
-
ring.poly = this;
|
|
1743
|
-
}
|
|
1744
|
-
}, {
|
|
1745
|
-
key: "getGeom",
|
|
1746
|
-
value: function getGeom() {
|
|
1747
|
-
var geom = [this.exteriorRing.getGeom()];
|
|
1748
|
-
if (geom[0] === null)
|
|
1749
|
-
return null;
|
|
1750
|
-
for (var i = 0, iMax = this.interiorRings.length; i < iMax; i++) {
|
|
1751
|
-
var ringGeom = this.interiorRings[i].getGeom();
|
|
1752
|
-
if (ringGeom === null)
|
|
1753
|
-
continue;
|
|
1754
|
-
geom.push(ringGeom);
|
|
1755
|
-
}
|
|
1756
|
-
return geom;
|
|
1757
|
-
}
|
|
1758
|
-
}]);
|
|
1759
|
-
return PolyOut2;
|
|
1760
|
-
}();
|
|
1761
|
-
var MultiPolyOut = /* @__PURE__ */ function() {
|
|
1762
|
-
function MultiPolyOut2(rings) {
|
|
1763
|
-
_classCallCheck(this, MultiPolyOut2);
|
|
1764
|
-
this.rings = rings;
|
|
1765
|
-
this.polys = this._composePolys(rings);
|
|
1766
|
-
}
|
|
1767
|
-
_createClass(MultiPolyOut2, [{
|
|
1768
|
-
key: "getGeom",
|
|
1769
|
-
value: function getGeom() {
|
|
1770
|
-
var geom = [];
|
|
1771
|
-
for (var i = 0, iMax = this.polys.length; i < iMax; i++) {
|
|
1772
|
-
var polyGeom = this.polys[i].getGeom();
|
|
1773
|
-
if (polyGeom === null)
|
|
1774
|
-
continue;
|
|
1775
|
-
geom.push(polyGeom);
|
|
1776
|
-
}
|
|
1777
|
-
return geom;
|
|
1778
|
-
}
|
|
1779
|
-
}, {
|
|
1780
|
-
key: "_composePolys",
|
|
1781
|
-
value: function _composePolys(rings) {
|
|
1782
|
-
var polys = [];
|
|
1783
|
-
for (var i = 0, iMax = rings.length; i < iMax; i++) {
|
|
1784
|
-
var ring = rings[i];
|
|
1785
|
-
if (ring.poly)
|
|
1786
|
-
continue;
|
|
1787
|
-
if (ring.isExteriorRing())
|
|
1788
|
-
polys.push(new PolyOut(ring));
|
|
1789
|
-
else {
|
|
1790
|
-
var enclosingRing = ring.enclosingRing();
|
|
1791
|
-
if (!enclosingRing.poly)
|
|
1792
|
-
polys.push(new PolyOut(enclosingRing));
|
|
1793
|
-
enclosingRing.poly.addInterior(ring);
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
return polys;
|
|
1797
|
-
}
|
|
1798
|
-
}]);
|
|
1799
|
-
return MultiPolyOut2;
|
|
1800
|
-
}();
|
|
1801
|
-
var SweepLine = /* @__PURE__ */ function() {
|
|
1802
|
-
function SweepLine2(queue) {
|
|
1803
|
-
var comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment.compare;
|
|
1804
|
-
_classCallCheck(this, SweepLine2);
|
|
1805
|
-
this.queue = queue;
|
|
1806
|
-
this.tree = new Tree(comparator);
|
|
1807
|
-
this.segments = [];
|
|
1808
|
-
}
|
|
1809
|
-
_createClass(SweepLine2, [{
|
|
1810
|
-
key: "process",
|
|
1811
|
-
value: function process2(event) {
|
|
1812
|
-
var segment = event.segment;
|
|
1813
|
-
var newEvents = [];
|
|
1814
|
-
if (event.consumedBy) {
|
|
1815
|
-
if (event.isLeft)
|
|
1816
|
-
this.queue.remove(event.otherSE);
|
|
1817
|
-
else
|
|
1818
|
-
this.tree.remove(segment);
|
|
1819
|
-
return newEvents;
|
|
1820
|
-
}
|
|
1821
|
-
var node = event.isLeft ? this.tree.insert(segment) : this.tree.find(segment);
|
|
1822
|
-
if (!node)
|
|
1823
|
-
throw new Error("Unable to find segment #".concat(segment.id, " ") + "[".concat(segment.leftSE.point.x, ", ").concat(segment.leftSE.point.y, "] -> ") + "[".concat(segment.rightSE.point.x, ", ").concat(segment.rightSE.point.y, "] ") + "in SweepLine tree. Please submit a bug report.");
|
|
1824
|
-
var prevNode = node;
|
|
1825
|
-
var nextNode = node;
|
|
1826
|
-
var prevSeg = void 0;
|
|
1827
|
-
var nextSeg = void 0;
|
|
1828
|
-
while (prevSeg === void 0) {
|
|
1829
|
-
prevNode = this.tree.prev(prevNode);
|
|
1830
|
-
if (prevNode === null)
|
|
1831
|
-
prevSeg = null;
|
|
1832
|
-
else if (prevNode.key.consumedBy === void 0)
|
|
1833
|
-
prevSeg = prevNode.key;
|
|
1834
|
-
}
|
|
1835
|
-
while (nextSeg === void 0) {
|
|
1836
|
-
nextNode = this.tree.next(nextNode);
|
|
1837
|
-
if (nextNode === null)
|
|
1838
|
-
nextSeg = null;
|
|
1839
|
-
else if (nextNode.key.consumedBy === void 0)
|
|
1840
|
-
nextSeg = nextNode.key;
|
|
1841
|
-
}
|
|
1842
|
-
if (event.isLeft) {
|
|
1843
|
-
var prevMySplitter = null;
|
|
1844
|
-
if (prevSeg) {
|
|
1845
|
-
var prevInter = prevSeg.getIntersection(segment);
|
|
1846
|
-
if (prevInter !== null) {
|
|
1847
|
-
if (!segment.isAnEndpoint(prevInter))
|
|
1848
|
-
prevMySplitter = prevInter;
|
|
1849
|
-
if (!prevSeg.isAnEndpoint(prevInter)) {
|
|
1850
|
-
var newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
|
|
1851
|
-
for (var i = 0, iMax = newEventsFromSplit.length; i < iMax; i++) {
|
|
1852
|
-
newEvents.push(newEventsFromSplit[i]);
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
var nextMySplitter = null;
|
|
1858
|
-
if (nextSeg) {
|
|
1859
|
-
var nextInter = nextSeg.getIntersection(segment);
|
|
1860
|
-
if (nextInter !== null) {
|
|
1861
|
-
if (!segment.isAnEndpoint(nextInter))
|
|
1862
|
-
nextMySplitter = nextInter;
|
|
1863
|
-
if (!nextSeg.isAnEndpoint(nextInter)) {
|
|
1864
|
-
var _newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
|
|
1865
|
-
for (var _i = 0, _iMax = _newEventsFromSplit.length; _i < _iMax; _i++) {
|
|
1866
|
-
newEvents.push(_newEventsFromSplit[_i]);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
if (prevMySplitter !== null || nextMySplitter !== null) {
|
|
1872
|
-
var mySplitter = null;
|
|
1873
|
-
if (prevMySplitter === null)
|
|
1874
|
-
mySplitter = nextMySplitter;
|
|
1875
|
-
else if (nextMySplitter === null)
|
|
1876
|
-
mySplitter = prevMySplitter;
|
|
1877
|
-
else {
|
|
1878
|
-
var cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter);
|
|
1879
|
-
mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
|
|
1880
|
-
}
|
|
1881
|
-
this.queue.remove(segment.rightSE);
|
|
1882
|
-
newEvents.push(segment.rightSE);
|
|
1883
|
-
var _newEventsFromSplit2 = segment.split(mySplitter);
|
|
1884
|
-
for (var _i2 = 0, _iMax2 = _newEventsFromSplit2.length; _i2 < _iMax2; _i2++) {
|
|
1885
|
-
newEvents.push(_newEventsFromSplit2[_i2]);
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
if (newEvents.length > 0) {
|
|
1889
|
-
this.tree.remove(segment);
|
|
1890
|
-
newEvents.push(event);
|
|
1891
|
-
} else {
|
|
1892
|
-
this.segments.push(segment);
|
|
1893
|
-
segment.prev = prevSeg;
|
|
1894
|
-
}
|
|
1895
|
-
} else {
|
|
1896
|
-
if (prevSeg && nextSeg) {
|
|
1897
|
-
var inter = prevSeg.getIntersection(nextSeg);
|
|
1898
|
-
if (inter !== null) {
|
|
1899
|
-
if (!prevSeg.isAnEndpoint(inter)) {
|
|
1900
|
-
var _newEventsFromSplit3 = this._splitSafely(prevSeg, inter);
|
|
1901
|
-
for (var _i3 = 0, _iMax3 = _newEventsFromSplit3.length; _i3 < _iMax3; _i3++) {
|
|
1902
|
-
newEvents.push(_newEventsFromSplit3[_i3]);
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
if (!nextSeg.isAnEndpoint(inter)) {
|
|
1906
|
-
var _newEventsFromSplit4 = this._splitSafely(nextSeg, inter);
|
|
1907
|
-
for (var _i4 = 0, _iMax4 = _newEventsFromSplit4.length; _i4 < _iMax4; _i4++) {
|
|
1908
|
-
newEvents.push(_newEventsFromSplit4[_i4]);
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
this.tree.remove(segment);
|
|
1914
|
-
}
|
|
1915
|
-
return newEvents;
|
|
1916
|
-
}
|
|
1917
|
-
}, {
|
|
1918
|
-
key: "_splitSafely",
|
|
1919
|
-
value: function _splitSafely(seg, pt) {
|
|
1920
|
-
this.tree.remove(seg);
|
|
1921
|
-
var rightSE = seg.rightSE;
|
|
1922
|
-
this.queue.remove(rightSE);
|
|
1923
|
-
var newEvents = seg.split(pt);
|
|
1924
|
-
newEvents.push(rightSE);
|
|
1925
|
-
if (seg.consumedBy === void 0)
|
|
1926
|
-
this.tree.insert(seg);
|
|
1927
|
-
return newEvents;
|
|
1928
|
-
}
|
|
1929
|
-
}]);
|
|
1930
|
-
return SweepLine2;
|
|
1931
|
-
}();
|
|
1932
|
-
var POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6;
|
|
1933
|
-
var POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
|
|
1934
|
-
var Operation = /* @__PURE__ */ function() {
|
|
1935
|
-
function Operation2() {
|
|
1936
|
-
_classCallCheck(this, Operation2);
|
|
1937
|
-
}
|
|
1938
|
-
_createClass(Operation2, [{
|
|
1939
|
-
key: "run",
|
|
1940
|
-
value: function run(type, geom, moreGeoms) {
|
|
1941
|
-
operation.type = type;
|
|
1942
|
-
rounder.reset();
|
|
1943
|
-
var multipolys = [new MultiPolyIn(geom, true)];
|
|
1944
|
-
for (var i = 0, iMax = moreGeoms.length; i < iMax; i++) {
|
|
1945
|
-
multipolys.push(new MultiPolyIn(moreGeoms[i], false));
|
|
1946
|
-
}
|
|
1947
|
-
operation.numMultiPolys = multipolys.length;
|
|
1948
|
-
if (operation.type === "difference") {
|
|
1949
|
-
var subject = multipolys[0];
|
|
1950
|
-
var _i = 1;
|
|
1951
|
-
while (_i < multipolys.length) {
|
|
1952
|
-
if (getBboxOverlap(multipolys[_i].bbox, subject.bbox) !== null)
|
|
1953
|
-
_i++;
|
|
1954
|
-
else
|
|
1955
|
-
multipolys.splice(_i, 1);
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
if (operation.type === "intersection") {
|
|
1959
|
-
for (var _i2 = 0, _iMax = multipolys.length; _i2 < _iMax; _i2++) {
|
|
1960
|
-
var mpA = multipolys[_i2];
|
|
1961
|
-
for (var j = _i2 + 1, jMax = multipolys.length; j < jMax; j++) {
|
|
1962
|
-
if (getBboxOverlap(mpA.bbox, multipolys[j].bbox) === null)
|
|
1963
|
-
return [];
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
var queue = new Tree(SweepEvent.compare);
|
|
1968
|
-
for (var _i3 = 0, _iMax2 = multipolys.length; _i3 < _iMax2; _i3++) {
|
|
1969
|
-
var sweepEvents = multipolys[_i3].getSweepEvents();
|
|
1970
|
-
for (var _j = 0, _jMax = sweepEvents.length; _j < _jMax; _j++) {
|
|
1971
|
-
queue.insert(sweepEvents[_j]);
|
|
1972
|
-
if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
|
|
1973
|
-
throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
var sweepLine = new SweepLine(queue);
|
|
1978
|
-
var prevQueueSize = queue.size;
|
|
1979
|
-
var node = queue.pop();
|
|
1980
|
-
while (node) {
|
|
1981
|
-
var evt = node.key;
|
|
1982
|
-
if (queue.size === prevQueueSize) {
|
|
1983
|
-
var seg = evt.segment;
|
|
1984
|
-
throw new Error("Unable to pop() ".concat(evt.isLeft ? "left" : "right", " SweepEvent ") + "[".concat(evt.point.x, ", ").concat(evt.point.y, "] from segment #").concat(seg.id, " ") + "[".concat(seg.leftSE.point.x, ", ").concat(seg.leftSE.point.y, "] -> ") + "[".concat(seg.rightSE.point.x, ", ").concat(seg.rightSE.point.y, "] from queue. ") + "Please file a bug report.");
|
|
1985
|
-
}
|
|
1986
|
-
if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
|
|
1987
|
-
throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");
|
|
1988
|
-
}
|
|
1989
|
-
if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) {
|
|
1990
|
-
throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");
|
|
1991
|
-
}
|
|
1992
|
-
var newEvents = sweepLine.process(evt);
|
|
1993
|
-
for (var _i4 = 0, _iMax3 = newEvents.length; _i4 < _iMax3; _i4++) {
|
|
1994
|
-
var _evt = newEvents[_i4];
|
|
1995
|
-
if (_evt.consumedBy === void 0)
|
|
1996
|
-
queue.insert(_evt);
|
|
1997
|
-
}
|
|
1998
|
-
prevQueueSize = queue.size;
|
|
1999
|
-
node = queue.pop();
|
|
2000
|
-
}
|
|
2001
|
-
rounder.reset();
|
|
2002
|
-
var ringsOut = RingOut.factory(sweepLine.segments);
|
|
2003
|
-
var result = new MultiPolyOut(ringsOut);
|
|
2004
|
-
return result.getGeom();
|
|
2005
|
-
}
|
|
2006
|
-
}]);
|
|
2007
|
-
return Operation2;
|
|
2008
|
-
}();
|
|
2009
|
-
var operation = new Operation();
|
|
2010
|
-
var union2 = function union3(geom) {
|
|
2011
|
-
for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2012
|
-
moreGeoms[_key - 1] = arguments[_key];
|
|
2013
|
-
}
|
|
2014
|
-
return operation.run("union", geom, moreGeoms);
|
|
2015
|
-
};
|
|
2016
|
-
var intersection$1 = function intersection3(geom) {
|
|
2017
|
-
for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2018
|
-
moreGeoms[_key2 - 1] = arguments[_key2];
|
|
2019
|
-
}
|
|
2020
|
-
return operation.run("intersection", geom, moreGeoms);
|
|
2021
|
-
};
|
|
2022
|
-
var xor = function xor2(geom) {
|
|
2023
|
-
for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
2024
|
-
moreGeoms[_key3 - 1] = arguments[_key3];
|
|
2025
|
-
}
|
|
2026
|
-
return operation.run("xor", geom, moreGeoms);
|
|
2027
|
-
};
|
|
2028
|
-
var difference = function difference2(subjectGeom) {
|
|
2029
|
-
for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
2030
|
-
clippingGeoms[_key4 - 1] = arguments[_key4];
|
|
2031
|
-
}
|
|
2032
|
-
return operation.run("difference", subjectGeom, clippingGeoms);
|
|
2033
|
-
};
|
|
2034
|
-
var index = {
|
|
2035
|
-
union: union2,
|
|
2036
|
-
intersection: intersection$1,
|
|
2037
|
-
xor,
|
|
2038
|
-
difference
|
|
2039
|
-
};
|
|
2040
|
-
return index;
|
|
2041
|
-
});
|
|
2042
|
-
}
|
|
2043
|
-
});
|
|
2044
|
-
|
|
2045
|
-
// ../linzjs-geojson/build/multipolygon/clipped.js
|
|
2046
|
-
var import_lineclip = __toESM(require_lineclip(), 1);
|
|
2047
|
-
var import_polygon_clipping = __toESM(require_polygon_clipping_umd(), 1);
|
|
2048
|
-
var { intersection, union } = import_polygon_clipping.default;
|
|
2049
|
-
|
|
2050
|
-
// ../linzjs-geojson/build/wgs84.js
|
|
2051
|
-
var normLon = (lon) => {
|
|
2052
|
-
if (lon < -360) {
|
|
2053
|
-
lon = -(-lon % 360);
|
|
2054
|
-
} else if (lon > 360) {
|
|
2055
|
-
lon = lon % 360;
|
|
2056
|
-
}
|
|
2057
|
-
if (lon < -180) {
|
|
2058
|
-
return 360 + lon;
|
|
2059
|
-
} else if (lon > 180) {
|
|
2060
|
-
return lon - 360;
|
|
2061
|
-
}
|
|
2062
|
-
return lon;
|
|
2063
|
-
};
|
|
2064
|
-
var delta = (a, b) => {
|
|
2065
|
-
const d = b - a;
|
|
2066
|
-
if (d > 180) {
|
|
2067
|
-
return d - 360;
|
|
2068
|
-
} else if (d < -180) {
|
|
2069
|
-
return d + 360;
|
|
2070
|
-
}
|
|
2071
|
-
return d;
|
|
2072
|
-
};
|
|
2073
|
-
var calcMid = (a, b) => normLon(a + (b < a ? b + 360 - a : b - a));
|
|
2074
|
-
var Wgs84 = {
|
|
2075
|
-
boxLonCenter(a) {
|
|
2076
|
-
return normLon(a[0] + 0.5 * (a[2] < a[0] ? 360 + a[2] - a[0] : a[2] - a[0]));
|
|
2077
|
-
},
|
|
2078
|
-
delta,
|
|
2079
|
-
crossesAM(a, b) {
|
|
2080
|
-
return Math.sign(delta(a, b)) !== Math.sign(b - a);
|
|
2081
|
-
},
|
|
2082
|
-
normLon,
|
|
2083
|
-
normExtent(extent) {
|
|
2084
|
-
return [normLon(extent[0]), extent[1], normLon(extent[2]), extent[3]];
|
|
2085
|
-
},
|
|
2086
|
-
union(a, b) {
|
|
2087
|
-
if (b == null) {
|
|
2088
|
-
return a.slice();
|
|
2089
|
-
}
|
|
2090
|
-
const axCenter = Wgs84.boxLonCenter(a);
|
|
2091
|
-
const bxCenter = Wgs84.boxLonCenter(b);
|
|
2092
|
-
if (delta(axCenter, bxCenter) < 0) {
|
|
2093
|
-
return this.union(b, a);
|
|
2094
|
-
}
|
|
2095
|
-
const ans = a.slice();
|
|
2096
|
-
const mid = calcMid(axCenter, bxCenter);
|
|
2097
|
-
if (delta(mid, b[0]) < delta(mid, a[0]))
|
|
2098
|
-
ans[0] = b[0];
|
|
2099
|
-
if (delta(mid, b[2]) > delta(mid, a[2]))
|
|
2100
|
-
ans[2] = b[2];
|
|
2101
|
-
if (b[1] < a[1])
|
|
2102
|
-
ans[1] = b[1];
|
|
2103
|
-
if (b[3] > a[3])
|
|
2104
|
-
ans[3] = b[3];
|
|
2105
|
-
return ans;
|
|
2106
|
-
},
|
|
2107
|
-
intersects(a, b) {
|
|
2108
|
-
if (a[1] > b[3] || b[1] > a[3])
|
|
2109
|
-
return false;
|
|
2110
|
-
const a0 = a[0];
|
|
2111
|
-
const b0 = b[0];
|
|
2112
|
-
const a2 = a0 < a[2] ? a[2] : a[2] + 360;
|
|
2113
|
-
const b2 = b0 < b[2] ? b[2] : b[2] + 360;
|
|
2114
|
-
return a0 <= b2 && b0 <= a2 || a0 + 360 <= b2 && b0 <= a2 + 360 || a0 <= b2 + 360 && b0 + 360 <= a2;
|
|
2115
|
-
},
|
|
2116
|
-
ringToBbox(ring) {
|
|
2117
|
-
if (ring.length < 3) {
|
|
2118
|
-
throw new Error("Invalid ring");
|
|
2119
|
-
}
|
|
2120
|
-
let crossing = false;
|
|
2121
|
-
const prev = ring[0];
|
|
2122
|
-
let minX = prev[0];
|
|
2123
|
-
let minY = prev[1];
|
|
2124
|
-
let maxX = minX;
|
|
2125
|
-
let maxY = minY;
|
|
2126
|
-
let pLon = minX;
|
|
2127
|
-
for (let i = 1; i < ring.length; ++i) {
|
|
2128
|
-
const curr = ring[i];
|
|
2129
|
-
let lon = curr[0];
|
|
2130
|
-
const lineCrosses = Wgs84.crossesAM(pLon, lon);
|
|
2131
|
-
if (lineCrosses) {
|
|
2132
|
-
crossing = !crossing;
|
|
2133
|
-
}
|
|
2134
|
-
if (crossing) {
|
|
2135
|
-
if (lon < 0) {
|
|
2136
|
-
lon += 360;
|
|
2137
|
-
} else {
|
|
2138
|
-
pLon += 360;
|
|
2139
|
-
if (i === 1) {
|
|
2140
|
-
minX = maxX = pLon;
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
if (lon < minX)
|
|
2145
|
-
minX = lon;
|
|
2146
|
-
else if (lon > maxX)
|
|
2147
|
-
maxX = lon;
|
|
2148
|
-
const lat = curr[1];
|
|
2149
|
-
if (lat < minY)
|
|
2150
|
-
minY = lat;
|
|
2151
|
-
else if (lat > maxY)
|
|
2152
|
-
maxY = lat;
|
|
2153
|
-
pLon = curr[0];
|
|
2154
|
-
}
|
|
2155
|
-
return [this.normLon(minX), minY, this.normLon(maxX), maxY];
|
|
2156
|
-
},
|
|
2157
|
-
multiPolygonToBbox(multipolygon) {
|
|
2158
|
-
let ans = null;
|
|
2159
|
-
for (const poly of multipolygon) {
|
|
2160
|
-
if (poly.length === 0)
|
|
2161
|
-
continue;
|
|
2162
|
-
const ring = poly[0];
|
|
2163
|
-
if (ring.length < 3)
|
|
2164
|
-
continue;
|
|
2165
|
-
const bbox = this.ringToBbox(ring);
|
|
2166
|
-
ans = ans == null ? bbox : this.union(ans, bbox);
|
|
2167
|
-
}
|
|
2168
|
-
if (ans == null) {
|
|
2169
|
-
throw new Error("Invalid multipolygon");
|
|
2170
|
-
}
|
|
2171
|
-
return ans;
|
|
2172
|
-
},
|
|
2173
|
-
bboxToMultiPolygon(bbox) {
|
|
2174
|
-
const sw = [bbox[0], bbox[1]];
|
|
2175
|
-
const se = [bbox[2], bbox[1]];
|
|
2176
|
-
const nw = [bbox[0], bbox[3]];
|
|
2177
|
-
const ne = [bbox[2], bbox[3]];
|
|
2178
|
-
if (bbox[0] < bbox[2]) {
|
|
2179
|
-
return [[[sw, nw, ne, se, sw]]];
|
|
2180
|
-
}
|
|
2181
|
-
return [[[sw, nw, [180, ne[1]], [180, se[1]], sw]], [[ne, se, [-180, sw[1]], [-180, nw[1]], ne]]];
|
|
2182
|
-
}
|
|
2183
|
-
};
|
|
2184
|
-
|
|
2185
|
-
// ../attribution/src/attribution.ts
|
|
2186
|
-
function escapeHtml(text) {
|
|
2187
|
-
const elm = document.createElement("span");
|
|
2188
|
-
elm.textContent = text;
|
|
2189
|
-
return elm.innerHTML;
|
|
2190
|
-
}
|
|
2191
|
-
var AttributionBounds = class {
|
|
2192
|
-
constructor(collection) {
|
|
2193
|
-
this.boundaries = [];
|
|
2194
|
-
this.collection = collection;
|
|
2195
|
-
const zoom = collection.summaries["linz:zoom"];
|
|
2196
|
-
this.minZoom = zoom.min;
|
|
2197
|
-
this.maxZoom = zoom.max;
|
|
2198
|
-
this.bbox = collection.extent.spatial.bbox[0];
|
|
2199
|
-
this.startDate = collection.extent.temporal?.interval[0][0];
|
|
2200
|
-
this.endDate = collection.extent.temporal?.interval[0][1];
|
|
2201
|
-
}
|
|
2202
|
-
intersects(params) {
|
|
2203
|
-
if (params.zoom > this.maxZoom || params.zoom < this.minZoom)
|
|
2204
|
-
return false;
|
|
2205
|
-
if (params.dateAfter && params.dateBefore && params.dateAfter > params.dateBefore)
|
|
2206
|
-
return false;
|
|
2207
|
-
if (params.dateAfter && this.endDate && params.dateAfter > this.endDate)
|
|
2208
|
-
return false;
|
|
2209
|
-
if (params.dateBefore && this.startDate && params.dateBefore < this.startDate)
|
|
2210
|
-
return false;
|
|
2211
|
-
if (!Wgs84.intersects(params.extent, this.bbox))
|
|
2212
|
-
return false;
|
|
2213
|
-
return this.intersection(Wgs84.bboxToMultiPolygon(params.extent));
|
|
2214
|
-
}
|
|
2215
|
-
intersection(polygon) {
|
|
2216
|
-
for (const boundary of this.boundaries) {
|
|
2217
|
-
if (intersection(boundary, polygon).length > 0)
|
|
2218
|
-
return true;
|
|
2219
|
-
}
|
|
2220
|
-
return false;
|
|
2221
|
-
}
|
|
2222
|
-
addBoundary(ring) {
|
|
2223
|
-
assertRing(ring);
|
|
2224
|
-
this.boundaries.push(ring);
|
|
2225
|
-
}
|
|
2226
|
-
};
|
|
2227
|
-
function assertRing(ring) {
|
|
2228
|
-
for (const outer of ring) {
|
|
2229
|
-
for (const inner of outer) {
|
|
2230
|
-
if (inner.length !== 2)
|
|
2231
|
-
throw new Error("Invalid ring wrong length");
|
|
2232
|
-
}
|
|
2233
|
-
}
|
|
2234
|
-
}
|
|
2235
|
-
function convertToBounds(stac) {
|
|
2236
|
-
const colMap = /* @__PURE__ */ new Map();
|
|
2237
|
-
const result = [];
|
|
2238
|
-
for (const collection of stac.collections) {
|
|
2239
|
-
const attr = new AttributionBounds(collection);
|
|
2240
|
-
result.push(attr);
|
|
2241
|
-
colMap.set(collection.id, attr);
|
|
2242
|
-
}
|
|
2243
|
-
for (const f of stac.features) {
|
|
2244
|
-
const col = colMap.get(f.collection ?? "");
|
|
2245
|
-
if (col == null)
|
|
2246
|
-
throw new Error("Could not match feature to collection: " + f.collection);
|
|
2247
|
-
if (f.geometry.type === "Polygon") {
|
|
2248
|
-
col.addBoundary(f.geometry.coordinates);
|
|
2249
|
-
} else if (f.geometry.type === "MultiPolygon") {
|
|
2250
|
-
for (const poly of f.geometry.coordinates)
|
|
2251
|
-
col.addBoundary(poly);
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
return result;
|
|
2255
|
-
}
|
|
2256
|
-
function getYears(col) {
|
|
2257
|
-
const interval = col.extent?.temporal?.interval;
|
|
2258
|
-
if (interval == null || interval.length === 0)
|
|
2259
|
-
return [-1, -1];
|
|
2260
|
-
const range = interval[0];
|
|
2261
|
-
const y1 = new Date(range[0]).getFullYear();
|
|
2262
|
-
const y2 = (range.length < 2 ? y1 : new Date(range[1]).getFullYear()) - 1;
|
|
2263
|
-
return [y1, y2 < y1 ? y1 : y2];
|
|
2264
|
-
}
|
|
2265
|
-
var Attribution = class {
|
|
2266
|
-
constructor(attributions) {
|
|
2267
|
-
this.attributions = attributions;
|
|
2268
|
-
}
|
|
2269
|
-
static async load(url) {
|
|
2270
|
-
const resp = await fetch(url);
|
|
2271
|
-
if (resp.ok) {
|
|
2272
|
-
const attributionStac = await resp.json();
|
|
2273
|
-
return Attribution.fromStac(attributionStac);
|
|
2274
|
-
}
|
|
2275
|
-
throw new Error(`fetch attribution failed [${resp.status}] ${resp.statusText}`);
|
|
2276
|
-
}
|
|
2277
|
-
static fromStac(json) {
|
|
2278
|
-
return new Attribution(convertToBounds(json).reverse());
|
|
2279
|
-
}
|
|
2280
|
-
filter(params) {
|
|
2281
|
-
params.zoom = Math.round(params.zoom);
|
|
2282
|
-
const filtered = [];
|
|
2283
|
-
const { attributions } = this;
|
|
2284
|
-
if (attributions == null)
|
|
2285
|
-
return filtered;
|
|
2286
|
-
for (const attr of attributions) {
|
|
2287
|
-
if (this.isIgnored != null && this.isIgnored(attr))
|
|
2288
|
-
continue;
|
|
2289
|
-
if (attr.intersects(params))
|
|
2290
|
-
filtered.push(attr);
|
|
2291
|
-
}
|
|
2292
|
-
return filtered;
|
|
2293
|
-
}
|
|
2294
|
-
renderList(list) {
|
|
2295
|
-
if (list.length === 0)
|
|
2296
|
-
return "";
|
|
2297
|
-
let result = escapeHtml(list[0].collection.title);
|
|
2298
|
-
if (list.length > 1) {
|
|
2299
|
-
if (list.length === 2) {
|
|
2300
|
-
result += ` & ${escapeHtml(list[1].collection.title)}`;
|
|
2301
|
-
} else {
|
|
2302
|
-
let [minYear, maxYear] = getYears(list[1].collection);
|
|
2303
|
-
for (let i = 1; i < list.length; ++i) {
|
|
2304
|
-
const [a, b] = getYears(list[i].collection);
|
|
2305
|
-
if (a !== -1 && (minYear === -1 || a < minYear))
|
|
2306
|
-
minYear = a;
|
|
2307
|
-
if (b !== -1 && (maxYear === -1 || b > maxYear))
|
|
2308
|
-
maxYear = b;
|
|
2309
|
-
}
|
|
2310
|
-
if (minYear === -1)
|
|
2311
|
-
minYear = maxYear;
|
|
2312
|
-
if (maxYear !== -1) {
|
|
2313
|
-
result += ` & others ${minYear}-${maxYear}`;
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
return result;
|
|
2318
|
-
}
|
|
2319
|
-
};
|
|
2320
|
-
|
|
2321
|
-
// ../attribution/src/attribution.index.ts
|
|
2322
|
-
window.BasemapsAttribution = Attribution;
|
|
2323
|
-
/**
|
|
2324
|
-
* splaytree v3.1.0
|
|
2325
|
-
* Fast Splay tree for Node and browser
|
|
2326
|
-
*
|
|
2327
|
-
* @author Alexander Milevski <info@w8r.name>
|
|
2328
|
-
* @license MIT
|
|
2329
|
-
* @preserve
|
|
2330
|
-
*/
|