geojs 1.12.4 → 1.12.5

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/geo.lean.js CHANGED
@@ -25073,7 +25073,7 @@ module.exports = _sceneObject;
25073
25073
  * @constant
25074
25074
  * @type {string}
25075
25075
  */
25076
- module.exports = "5ad0374165eab0d4a487723bc62b58070d532854";
25076
+ module.exports = "1fd3450e4c094c4475819ff627ee93484c684c3c";
25077
25077
 
25078
25078
  /***/ }),
25079
25079
 
@@ -36912,7 +36912,7 @@ module.exports = _vectorFeature;
36912
36912
  * @constant
36913
36913
  * @type {string}
36914
36914
  */
36915
- module.exports = "1.12.4";
36915
+ module.exports = "1.12.5";
36916
36916
 
36917
36917
  /***/ }),
36918
36918
 
@@ -44665,7 +44665,7 @@ var _webgl_polygonFeature = function webgl_polygonFeature(arg) {
44665
44665
  arg = arg || {};
44666
44666
  polygonFeature.call(this, arg);
44667
44667
  var vgl = __webpack_require__(1611);
44668
- var earcut = __webpack_require__(2087);
44668
+ var earcut = __webpack_require__(9747);
44669
44669
  earcut = earcut.__esModule ? earcut.default : earcut;
44670
44670
  var transform = __webpack_require__(5325);
44671
44671
  var util = __webpack_require__(642);
@@ -73403,6 +73403,630 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__7606__;
73403
73403
 
73404
73404
  /***/ }),
73405
73405
 
73406
+ /***/ 9747:
73407
+ /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
73408
+
73409
+ "use strict";
73410
+ __webpack_require__.r(__webpack_exports__);
73411
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
73412
+ /* harmony export */ "default": function() { return /* binding */ earcut; },
73413
+ /* harmony export */ deviation: function() { return /* binding */ deviation; },
73414
+ /* harmony export */ flatten: function() { return /* binding */ flatten; }
73415
+ /* harmony export */ });
73416
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
73417
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
73418
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
73419
+ function earcut(data, holeIndices) {
73420
+ var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
73421
+ var hasHoles = holeIndices && holeIndices.length;
73422
+ var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
73423
+ var outerNode = linkedList(data, 0, outerLen, dim, true);
73424
+ var triangles = [];
73425
+ if (!outerNode || outerNode.next === outerNode.prev) return triangles;
73426
+ var minX, minY, invSize;
73427
+ if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
73428
+
73429
+ // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
73430
+ if (data.length > 80 * dim) {
73431
+ minX = Infinity;
73432
+ minY = Infinity;
73433
+ var maxX = -Infinity;
73434
+ var maxY = -Infinity;
73435
+ for (var i = dim; i < outerLen; i += dim) {
73436
+ var x = data[i];
73437
+ var y = data[i + 1];
73438
+ if (x < minX) minX = x;
73439
+ if (y < minY) minY = y;
73440
+ if (x > maxX) maxX = x;
73441
+ if (y > maxY) maxY = y;
73442
+ }
73443
+
73444
+ // minX, minY and invSize are later used to transform coords into integers for z-order calculation
73445
+ invSize = Math.max(maxX - minX, maxY - minY);
73446
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
73447
+ }
73448
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
73449
+ return triangles;
73450
+ }
73451
+
73452
+ // create a circular doubly linked list from polygon points in the specified winding order
73453
+ function linkedList(data, start, end, dim, clockwise) {
73454
+ var last;
73455
+ if (clockwise === signedArea(data, start, end, dim) > 0) {
73456
+ for (var i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
73457
+ } else {
73458
+ for (var _i = end - dim; _i >= start; _i -= dim) last = insertNode(_i / dim | 0, data[_i], data[_i + 1], last);
73459
+ }
73460
+ if (last && equals(last, last.next)) {
73461
+ removeNode(last);
73462
+ last = last.next;
73463
+ }
73464
+ return last;
73465
+ }
73466
+
73467
+ // eliminate colinear or duplicate points
73468
+ function filterPoints(start, end) {
73469
+ if (!start) return start;
73470
+ if (!end) end = start;
73471
+ var p = start,
73472
+ again;
73473
+ do {
73474
+ again = false;
73475
+ if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
73476
+ removeNode(p);
73477
+ p = end = p.prev;
73478
+ if (p === p.next) break;
73479
+ again = true;
73480
+ } else {
73481
+ p = p.next;
73482
+ }
73483
+ } while (again || p !== end);
73484
+ return end;
73485
+ }
73486
+
73487
+ // main ear slicing loop which triangulates a polygon (given as a linked list)
73488
+ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
73489
+ if (!ear) return;
73490
+
73491
+ // interlink polygon nodes in z-order
73492
+ if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
73493
+ var stop = ear;
73494
+
73495
+ // iterate through ears, slicing them one by one
73496
+ while (ear.prev !== ear.next) {
73497
+ var prev = ear.prev;
73498
+ var next = ear.next;
73499
+ if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
73500
+ triangles.push(prev.i, ear.i, next.i); // cut off the triangle
73501
+
73502
+ removeNode(ear);
73503
+
73504
+ // skipping the next vertex leads to less sliver triangles
73505
+ ear = next.next;
73506
+ stop = next.next;
73507
+ continue;
73508
+ }
73509
+ ear = next;
73510
+
73511
+ // if we looped through the whole remaining polygon and can't find any more ears
73512
+ if (ear === stop) {
73513
+ // try filtering points and slicing again
73514
+ if (!pass) {
73515
+ earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
73516
+
73517
+ // if this didn't work, try curing all small self-intersections locally
73518
+ } else if (pass === 1) {
73519
+ ear = cureLocalIntersections(filterPoints(ear), triangles);
73520
+ earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
73521
+
73522
+ // as a last resort, try splitting the remaining polygon into two
73523
+ } else if (pass === 2) {
73524
+ splitEarcut(ear, triangles, dim, minX, minY, invSize);
73525
+ }
73526
+ break;
73527
+ }
73528
+ }
73529
+ }
73530
+
73531
+ // check whether a polygon node forms a valid ear with adjacent nodes
73532
+ function isEar(ear) {
73533
+ var a = ear.prev,
73534
+ b = ear,
73535
+ c = ear.next;
73536
+ if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
73537
+
73538
+ // now make sure we don't have other points inside the potential ear
73539
+ var ax = a.x,
73540
+ bx = b.x,
73541
+ cx = c.x,
73542
+ ay = a.y,
73543
+ by = b.y,
73544
+ cy = c.y;
73545
+
73546
+ // triangle bbox; min & max are calculated like this for speed
73547
+ var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
73548
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
73549
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
73550
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
73551
+ var p = c.next;
73552
+ while (p !== a) {
73553
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
73554
+ p = p.next;
73555
+ }
73556
+ return true;
73557
+ }
73558
+ function isEarHashed(ear, minX, minY, invSize) {
73559
+ var a = ear.prev,
73560
+ b = ear,
73561
+ c = ear.next;
73562
+ if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
73563
+
73564
+ var ax = a.x,
73565
+ bx = b.x,
73566
+ cx = c.x,
73567
+ ay = a.y,
73568
+ by = b.y,
73569
+ cy = c.y;
73570
+
73571
+ // triangle bbox; min & max are calculated like this for speed
73572
+ var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
73573
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
73574
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
73575
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
73576
+
73577
+ // z-order range for the current triangle bbox;
73578
+ var minZ = zOrder(x0, y0, minX, minY, invSize),
73579
+ maxZ = zOrder(x1, y1, minX, minY, invSize);
73580
+ var p = ear.prevZ,
73581
+ n = ear.nextZ;
73582
+
73583
+ // look for points inside the triangle in both directions
73584
+ while (p && p.z >= minZ && n && n.z <= maxZ) {
73585
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
73586
+ p = p.prevZ;
73587
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
73588
+ n = n.nextZ;
73589
+ }
73590
+
73591
+ // look for remaining points in decreasing z-order
73592
+ while (p && p.z >= minZ) {
73593
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
73594
+ p = p.prevZ;
73595
+ }
73596
+
73597
+ // look for remaining points in increasing z-order
73598
+ while (n && n.z <= maxZ) {
73599
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
73600
+ n = n.nextZ;
73601
+ }
73602
+ return true;
73603
+ }
73604
+
73605
+ // go through all polygon nodes and cure small local self-intersections
73606
+ function cureLocalIntersections(start, triangles) {
73607
+ var p = start;
73608
+ do {
73609
+ var a = p.prev,
73610
+ b = p.next.next;
73611
+ if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
73612
+ triangles.push(a.i, p.i, b.i);
73613
+
73614
+ // remove two nodes involved
73615
+ removeNode(p);
73616
+ removeNode(p.next);
73617
+ p = start = b;
73618
+ }
73619
+ p = p.next;
73620
+ } while (p !== start);
73621
+ return filterPoints(p);
73622
+ }
73623
+
73624
+ // try splitting polygon into two and triangulate them independently
73625
+ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
73626
+ // look for a valid diagonal that divides the polygon into two
73627
+ var a = start;
73628
+ do {
73629
+ var b = a.next.next;
73630
+ while (b !== a.prev) {
73631
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
73632
+ // split the polygon in two by the diagonal
73633
+ var c = splitPolygon(a, b);
73634
+
73635
+ // filter colinear points around the cuts
73636
+ a = filterPoints(a, a.next);
73637
+ c = filterPoints(c, c.next);
73638
+
73639
+ // run earcut on each half
73640
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
73641
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
73642
+ return;
73643
+ }
73644
+ b = b.next;
73645
+ }
73646
+ a = a.next;
73647
+ } while (a !== start);
73648
+ }
73649
+
73650
+ // link every hole into the outer loop, producing a single-ring polygon without holes
73651
+ function eliminateHoles(data, holeIndices, outerNode, dim) {
73652
+ var queue = [];
73653
+ for (var i = 0, len = holeIndices.length; i < len; i++) {
73654
+ var start = holeIndices[i] * dim;
73655
+ var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
73656
+ var list = linkedList(data, start, end, dim, false);
73657
+ if (list === list.next) list.steiner = true;
73658
+ queue.push(getLeftmost(list));
73659
+ }
73660
+ queue.sort(compareX);
73661
+
73662
+ // process holes from left to right
73663
+ for (var _i2 = 0; _i2 < queue.length; _i2++) {
73664
+ outerNode = eliminateHole(queue[_i2], outerNode);
73665
+ }
73666
+ return outerNode;
73667
+ }
73668
+ function compareX(a, b) {
73669
+ return a.x - b.x;
73670
+ }
73671
+
73672
+ // find a bridge between vertices that connects hole with an outer ring and and link it
73673
+ function eliminateHole(hole, outerNode) {
73674
+ var bridge = findHoleBridge(hole, outerNode);
73675
+ if (!bridge) {
73676
+ return outerNode;
73677
+ }
73678
+ var bridgeReverse = splitPolygon(bridge, hole);
73679
+
73680
+ // filter collinear points around the cuts
73681
+ filterPoints(bridgeReverse, bridgeReverse.next);
73682
+ return filterPoints(bridge, bridge.next);
73683
+ }
73684
+
73685
+ // David Eberly's algorithm for finding a bridge between hole and outer polygon
73686
+ function findHoleBridge(hole, outerNode) {
73687
+ var p = outerNode;
73688
+ var hx = hole.x;
73689
+ var hy = hole.y;
73690
+ var qx = -Infinity;
73691
+ var m;
73692
+
73693
+ // find a segment intersected by a ray from the hole's leftmost point to the left;
73694
+ // segment's endpoint with lesser x will be potential connection point
73695
+ do {
73696
+ if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
73697
+ var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
73698
+ if (x <= hx && x > qx) {
73699
+ qx = x;
73700
+ m = p.x < p.next.x ? p : p.next;
73701
+ if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
73702
+ }
73703
+ }
73704
+ p = p.next;
73705
+ } while (p !== outerNode);
73706
+ if (!m) return null;
73707
+
73708
+ // look for points inside the triangle of hole point, segment intersection and endpoint;
73709
+ // if there are no points found, we have a valid connection;
73710
+ // otherwise choose the point of the minimum angle with the ray as connection point
73711
+
73712
+ var stop = m;
73713
+ var mx = m.x;
73714
+ var my = m.y;
73715
+ var tanMin = Infinity;
73716
+ p = m;
73717
+ do {
73718
+ if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
73719
+ var tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
73720
+
73721
+ if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
73722
+ m = p;
73723
+ tanMin = tan;
73724
+ }
73725
+ }
73726
+ p = p.next;
73727
+ } while (p !== stop);
73728
+ return m;
73729
+ }
73730
+
73731
+ // whether sector in vertex m contains sector in vertex p in the same coordinates
73732
+ function sectorContainsSector(m, p) {
73733
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
73734
+ }
73735
+
73736
+ // interlink polygon nodes in z-order
73737
+ function indexCurve(start, minX, minY, invSize) {
73738
+ var p = start;
73739
+ do {
73740
+ if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
73741
+ p.prevZ = p.prev;
73742
+ p.nextZ = p.next;
73743
+ p = p.next;
73744
+ } while (p !== start);
73745
+ p.prevZ.nextZ = null;
73746
+ p.prevZ = null;
73747
+ sortLinked(p);
73748
+ }
73749
+
73750
+ // Simon Tatham's linked list merge sort algorithm
73751
+ // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
73752
+ function sortLinked(list) {
73753
+ var numMerges;
73754
+ var inSize = 1;
73755
+ do {
73756
+ var p = list;
73757
+ var e = void 0;
73758
+ list = null;
73759
+ var tail = null;
73760
+ numMerges = 0;
73761
+ while (p) {
73762
+ numMerges++;
73763
+ var q = p;
73764
+ var pSize = 0;
73765
+ for (var i = 0; i < inSize; i++) {
73766
+ pSize++;
73767
+ q = q.nextZ;
73768
+ if (!q) break;
73769
+ }
73770
+ var qSize = inSize;
73771
+ while (pSize > 0 || qSize > 0 && q) {
73772
+ if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
73773
+ e = p;
73774
+ p = p.nextZ;
73775
+ pSize--;
73776
+ } else {
73777
+ e = q;
73778
+ q = q.nextZ;
73779
+ qSize--;
73780
+ }
73781
+ if (tail) tail.nextZ = e;else list = e;
73782
+ e.prevZ = tail;
73783
+ tail = e;
73784
+ }
73785
+ p = q;
73786
+ }
73787
+ tail.nextZ = null;
73788
+ inSize *= 2;
73789
+ } while (numMerges > 1);
73790
+ return list;
73791
+ }
73792
+
73793
+ // z-order of a point given coords and inverse of the longer side of data bbox
73794
+ function zOrder(x, y, minX, minY, invSize) {
73795
+ // coords are transformed into non-negative 15-bit integer range
73796
+ x = (x - minX) * invSize | 0;
73797
+ y = (y - minY) * invSize | 0;
73798
+ x = (x | x << 8) & 0x00FF00FF;
73799
+ x = (x | x << 4) & 0x0F0F0F0F;
73800
+ x = (x | x << 2) & 0x33333333;
73801
+ x = (x | x << 1) & 0x55555555;
73802
+ y = (y | y << 8) & 0x00FF00FF;
73803
+ y = (y | y << 4) & 0x0F0F0F0F;
73804
+ y = (y | y << 2) & 0x33333333;
73805
+ y = (y | y << 1) & 0x55555555;
73806
+ return x | y << 1;
73807
+ }
73808
+
73809
+ // find the leftmost node of a polygon ring
73810
+ function getLeftmost(start) {
73811
+ var p = start,
73812
+ leftmost = start;
73813
+ do {
73814
+ if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;
73815
+ p = p.next;
73816
+ } while (p !== start);
73817
+ return leftmost;
73818
+ }
73819
+
73820
+ // check if a point lies within a convex triangle
73821
+ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
73822
+ return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
73823
+ }
73824
+
73825
+ // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
73826
+ function isValidDiagonal(a, b) {
73827
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (
73828
+ // dones't intersect other edges
73829
+ locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (
73830
+ // locally visible
73831
+ area(a.prev, a, b.prev) || area(a, b.prev, b)) ||
73832
+ // does not create opposite-facing sectors
73833
+ equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
73834
+ }
73835
+
73836
+ // signed area of a triangle
73837
+ function area(p, q, r) {
73838
+ return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
73839
+ }
73840
+
73841
+ // check if two points are equal
73842
+ function equals(p1, p2) {
73843
+ return p1.x === p2.x && p1.y === p2.y;
73844
+ }
73845
+
73846
+ // check if two segments intersect
73847
+ function intersects(p1, q1, p2, q2) {
73848
+ var o1 = sign(area(p1, q1, p2));
73849
+ var o2 = sign(area(p1, q1, q2));
73850
+ var o3 = sign(area(p2, q2, p1));
73851
+ var o4 = sign(area(p2, q2, q1));
73852
+ if (o1 !== o2 && o3 !== o4) return true; // general case
73853
+
73854
+ if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
73855
+ if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
73856
+ if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
73857
+ if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
73858
+
73859
+ return false;
73860
+ }
73861
+
73862
+ // for collinear points p, q, r, check if point q lies on segment pr
73863
+ function onSegment(p, q, r) {
73864
+ return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
73865
+ }
73866
+ function sign(num) {
73867
+ return num > 0 ? 1 : num < 0 ? -1 : 0;
73868
+ }
73869
+
73870
+ // check if a polygon diagonal intersects any polygon segments
73871
+ function intersectsPolygon(a, b) {
73872
+ var p = a;
73873
+ do {
73874
+ if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true;
73875
+ p = p.next;
73876
+ } while (p !== a);
73877
+ return false;
73878
+ }
73879
+
73880
+ // check if a polygon diagonal is locally inside the polygon
73881
+ function locallyInside(a, b) {
73882
+ return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
73883
+ }
73884
+
73885
+ // check if the middle point of a polygon diagonal is inside the polygon
73886
+ function middleInside(a, b) {
73887
+ var p = a;
73888
+ var inside = false;
73889
+ var px = (a.x + b.x) / 2;
73890
+ var py = (a.y + b.y) / 2;
73891
+ do {
73892
+ if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x) inside = !inside;
73893
+ p = p.next;
73894
+ } while (p !== a);
73895
+ return inside;
73896
+ }
73897
+
73898
+ // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
73899
+ // if one belongs to the outer ring and another to a hole, it merges it into a single ring
73900
+ function splitPolygon(a, b) {
73901
+ var a2 = createNode(a.i, a.x, a.y),
73902
+ b2 = createNode(b.i, b.x, b.y),
73903
+ an = a.next,
73904
+ bp = b.prev;
73905
+ a.next = b;
73906
+ b.prev = a;
73907
+ a2.next = an;
73908
+ an.prev = a2;
73909
+ b2.next = a2;
73910
+ a2.prev = b2;
73911
+ bp.next = b2;
73912
+ b2.prev = bp;
73913
+ return b2;
73914
+ }
73915
+
73916
+ // create a node and optionally link it with previous one (in a circular doubly linked list)
73917
+ function insertNode(i, x, y, last) {
73918
+ var p = createNode(i, x, y);
73919
+ if (!last) {
73920
+ p.prev = p;
73921
+ p.next = p;
73922
+ } else {
73923
+ p.next = last.next;
73924
+ p.prev = last;
73925
+ last.next.prev = p;
73926
+ last.next = p;
73927
+ }
73928
+ return p;
73929
+ }
73930
+ function removeNode(p) {
73931
+ p.next.prev = p.prev;
73932
+ p.prev.next = p.next;
73933
+ if (p.prevZ) p.prevZ.nextZ = p.nextZ;
73934
+ if (p.nextZ) p.nextZ.prevZ = p.prevZ;
73935
+ }
73936
+ function createNode(i, x, y) {
73937
+ return {
73938
+ i: i,
73939
+ // vertex index in coordinates array
73940
+ x: x,
73941
+ y: y,
73942
+ // vertex coordinates
73943
+ prev: null,
73944
+ // previous and next vertex nodes in a polygon ring
73945
+ next: null,
73946
+ z: 0,
73947
+ // z-order curve value
73948
+ prevZ: null,
73949
+ // previous and next nodes in z-order
73950
+ nextZ: null,
73951
+ steiner: false // indicates whether this is a steiner point
73952
+ };
73953
+ }
73954
+
73955
+ // return a percentage difference between the polygon area and its triangulation area;
73956
+ // used to verify correctness of triangulation
73957
+ function deviation(data, holeIndices, dim, triangles) {
73958
+ var hasHoles = holeIndices && holeIndices.length;
73959
+ var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
73960
+ var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
73961
+ if (hasHoles) {
73962
+ for (var i = 0, len = holeIndices.length; i < len; i++) {
73963
+ var start = holeIndices[i] * dim;
73964
+ var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
73965
+ polygonArea -= Math.abs(signedArea(data, start, end, dim));
73966
+ }
73967
+ }
73968
+ var trianglesArea = 0;
73969
+ for (var _i3 = 0; _i3 < triangles.length; _i3 += 3) {
73970
+ var a = triangles[_i3] * dim;
73971
+ var b = triangles[_i3 + 1] * dim;
73972
+ var c = triangles[_i3 + 2] * dim;
73973
+ trianglesArea += Math.abs((data[a] - data[c]) * (data[b + 1] - data[a + 1]) - (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
73974
+ }
73975
+ return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);
73976
+ }
73977
+ function signedArea(data, start, end, dim) {
73978
+ var sum = 0;
73979
+ for (var i = start, j = end - dim; i < end; i += dim) {
73980
+ sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
73981
+ j = i;
73982
+ }
73983
+ return sum;
73984
+ }
73985
+
73986
+ // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
73987
+ function flatten(data) {
73988
+ var vertices = [];
73989
+ var holes = [];
73990
+ var dimensions = data[0][0].length;
73991
+ var holeIndex = 0;
73992
+ var prevLen = 0;
73993
+ var _iterator = _createForOfIteratorHelper(data),
73994
+ _step;
73995
+ try {
73996
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
73997
+ var ring = _step.value;
73998
+ var _iterator2 = _createForOfIteratorHelper(ring),
73999
+ _step2;
74000
+ try {
74001
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
74002
+ var p = _step2.value;
74003
+ for (var d = 0; d < dimensions; d++) vertices.push(p[d]);
74004
+ }
74005
+ } catch (err) {
74006
+ _iterator2.e(err);
74007
+ } finally {
74008
+ _iterator2.f();
74009
+ }
74010
+ if (prevLen) {
74011
+ holeIndex += prevLen;
74012
+ holes.push(holeIndex);
74013
+ }
74014
+ prevLen = ring.length;
74015
+ }
74016
+ } catch (err) {
74017
+ _iterator.e(err);
74018
+ } finally {
74019
+ _iterator.f();
74020
+ }
74021
+ return {
74022
+ vertices: vertices,
74023
+ holes: holes,
74024
+ dimensions: dimensions
74025
+ };
74026
+ }
74027
+
74028
+ /***/ }),
74029
+
73406
74030
  /***/ 4279:
73407
74031
  /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
73408
74032
 
@@ -73914,683 +74538,6 @@ __webpack_require__.r(__webpack_exports__);
73914
74538
  });
73915
74539
 
73916
74540
 
73917
- /***/ }),
73918
-
73919
- /***/ 2087:
73920
- /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
73921
-
73922
- "use strict";
73923
- __webpack_require__.r(__webpack_exports__);
73924
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
73925
- /* harmony export */ "default": function() { return /* binding */ earcut; },
73926
- /* harmony export */ deviation: function() { return /* binding */ deviation; },
73927
- /* harmony export */ flatten: function() { return /* binding */ flatten; }
73928
- /* harmony export */ });
73929
-
73930
- function earcut(data, holeIndices, dim = 2) {
73931
-
73932
- const hasHoles = holeIndices && holeIndices.length;
73933
- const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
73934
- let outerNode = linkedList(data, 0, outerLen, dim, true);
73935
- const triangles = [];
73936
-
73937
- if (!outerNode || outerNode.next === outerNode.prev) return triangles;
73938
-
73939
- let minX, minY, invSize;
73940
-
73941
- if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
73942
-
73943
- // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
73944
- if (data.length > 80 * dim) {
73945
- minX = Infinity;
73946
- minY = Infinity;
73947
- let maxX = -Infinity;
73948
- let maxY = -Infinity;
73949
-
73950
- for (let i = dim; i < outerLen; i += dim) {
73951
- const x = data[i];
73952
- const y = data[i + 1];
73953
- if (x < minX) minX = x;
73954
- if (y < minY) minY = y;
73955
- if (x > maxX) maxX = x;
73956
- if (y > maxY) maxY = y;
73957
- }
73958
-
73959
- // minX, minY and invSize are later used to transform coords into integers for z-order calculation
73960
- invSize = Math.max(maxX - minX, maxY - minY);
73961
- invSize = invSize !== 0 ? 32767 / invSize : 0;
73962
- }
73963
-
73964
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
73965
-
73966
- return triangles;
73967
- }
73968
-
73969
- // create a circular doubly linked list from polygon points in the specified winding order
73970
- function linkedList(data, start, end, dim, clockwise) {
73971
- let last;
73972
-
73973
- if (clockwise === (signedArea(data, start, end, dim) > 0)) {
73974
- for (let i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
73975
- } else {
73976
- for (let i = end - dim; i >= start; i -= dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
73977
- }
73978
-
73979
- if (last && equals(last, last.next)) {
73980
- removeNode(last);
73981
- last = last.next;
73982
- }
73983
-
73984
- return last;
73985
- }
73986
-
73987
- // eliminate colinear or duplicate points
73988
- function filterPoints(start, end) {
73989
- if (!start) return start;
73990
- if (!end) end = start;
73991
-
73992
- let p = start,
73993
- again;
73994
- do {
73995
- again = false;
73996
-
73997
- if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
73998
- removeNode(p);
73999
- p = end = p.prev;
74000
- if (p === p.next) break;
74001
- again = true;
74002
-
74003
- } else {
74004
- p = p.next;
74005
- }
74006
- } while (again || p !== end);
74007
-
74008
- return end;
74009
- }
74010
-
74011
- // main ear slicing loop which triangulates a polygon (given as a linked list)
74012
- function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
74013
- if (!ear) return;
74014
-
74015
- // interlink polygon nodes in z-order
74016
- if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
74017
-
74018
- let stop = ear;
74019
-
74020
- // iterate through ears, slicing them one by one
74021
- while (ear.prev !== ear.next) {
74022
- const prev = ear.prev;
74023
- const next = ear.next;
74024
-
74025
- if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
74026
- triangles.push(prev.i, ear.i, next.i); // cut off the triangle
74027
-
74028
- removeNode(ear);
74029
-
74030
- // skipping the next vertex leads to less sliver triangles
74031
- ear = next.next;
74032
- stop = next.next;
74033
-
74034
- continue;
74035
- }
74036
-
74037
- ear = next;
74038
-
74039
- // if we looped through the whole remaining polygon and can't find any more ears
74040
- if (ear === stop) {
74041
- // try filtering points and slicing again
74042
- if (!pass) {
74043
- earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
74044
-
74045
- // if this didn't work, try curing all small self-intersections locally
74046
- } else if (pass === 1) {
74047
- ear = cureLocalIntersections(filterPoints(ear), triangles);
74048
- earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
74049
-
74050
- // as a last resort, try splitting the remaining polygon into two
74051
- } else if (pass === 2) {
74052
- splitEarcut(ear, triangles, dim, minX, minY, invSize);
74053
- }
74054
-
74055
- break;
74056
- }
74057
- }
74058
- }
74059
-
74060
- // check whether a polygon node forms a valid ear with adjacent nodes
74061
- function isEar(ear) {
74062
- const a = ear.prev,
74063
- b = ear,
74064
- c = ear.next;
74065
-
74066
- if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
74067
-
74068
- // now make sure we don't have other points inside the potential ear
74069
- const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
74070
-
74071
- // triangle bbox; min & max are calculated like this for speed
74072
- const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
74073
- y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
74074
- x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
74075
- y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
74076
-
74077
- let p = c.next;
74078
- while (p !== a) {
74079
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
74080
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
74081
- area(p.prev, p, p.next) >= 0) return false;
74082
- p = p.next;
74083
- }
74084
-
74085
- return true;
74086
- }
74087
-
74088
- function isEarHashed(ear, minX, minY, invSize) {
74089
- const a = ear.prev,
74090
- b = ear,
74091
- c = ear.next;
74092
-
74093
- if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
74094
-
74095
- const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
74096
-
74097
- // triangle bbox; min & max are calculated like this for speed
74098
- const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
74099
- y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
74100
- x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
74101
- y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
74102
-
74103
- // z-order range for the current triangle bbox;
74104
- const minZ = zOrder(x0, y0, minX, minY, invSize),
74105
- maxZ = zOrder(x1, y1, minX, minY, invSize);
74106
-
74107
- let p = ear.prevZ,
74108
- n = ear.nextZ;
74109
-
74110
- // look for points inside the triangle in both directions
74111
- while (p && p.z >= minZ && n && n.z <= maxZ) {
74112
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
74113
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
74114
- p = p.prevZ;
74115
-
74116
- if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
74117
- pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
74118
- n = n.nextZ;
74119
- }
74120
-
74121
- // look for remaining points in decreasing z-order
74122
- while (p && p.z >= minZ) {
74123
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
74124
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
74125
- p = p.prevZ;
74126
- }
74127
-
74128
- // look for remaining points in increasing z-order
74129
- while (n && n.z <= maxZ) {
74130
- if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
74131
- pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
74132
- n = n.nextZ;
74133
- }
74134
-
74135
- return true;
74136
- }
74137
-
74138
- // go through all polygon nodes and cure small local self-intersections
74139
- function cureLocalIntersections(start, triangles) {
74140
- let p = start;
74141
- do {
74142
- const a = p.prev,
74143
- b = p.next.next;
74144
-
74145
- if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
74146
-
74147
- triangles.push(a.i, p.i, b.i);
74148
-
74149
- // remove two nodes involved
74150
- removeNode(p);
74151
- removeNode(p.next);
74152
-
74153
- p = start = b;
74154
- }
74155
- p = p.next;
74156
- } while (p !== start);
74157
-
74158
- return filterPoints(p);
74159
- }
74160
-
74161
- // try splitting polygon into two and triangulate them independently
74162
- function splitEarcut(start, triangles, dim, minX, minY, invSize) {
74163
- // look for a valid diagonal that divides the polygon into two
74164
- let a = start;
74165
- do {
74166
- let b = a.next.next;
74167
- while (b !== a.prev) {
74168
- if (a.i !== b.i && isValidDiagonal(a, b)) {
74169
- // split the polygon in two by the diagonal
74170
- let c = splitPolygon(a, b);
74171
-
74172
- // filter colinear points around the cuts
74173
- a = filterPoints(a, a.next);
74174
- c = filterPoints(c, c.next);
74175
-
74176
- // run earcut on each half
74177
- earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
74178
- earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
74179
- return;
74180
- }
74181
- b = b.next;
74182
- }
74183
- a = a.next;
74184
- } while (a !== start);
74185
- }
74186
-
74187
- // link every hole into the outer loop, producing a single-ring polygon without holes
74188
- function eliminateHoles(data, holeIndices, outerNode, dim) {
74189
- const queue = [];
74190
-
74191
- for (let i = 0, len = holeIndices.length; i < len; i++) {
74192
- const start = holeIndices[i] * dim;
74193
- const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
74194
- const list = linkedList(data, start, end, dim, false);
74195
- if (list === list.next) list.steiner = true;
74196
- queue.push(getLeftmost(list));
74197
- }
74198
-
74199
- queue.sort(compareX);
74200
-
74201
- // process holes from left to right
74202
- for (let i = 0; i < queue.length; i++) {
74203
- outerNode = eliminateHole(queue[i], outerNode);
74204
- }
74205
-
74206
- return outerNode;
74207
- }
74208
-
74209
- function compareX(a, b) {
74210
- return a.x - b.x;
74211
- }
74212
-
74213
- // find a bridge between vertices that connects hole with an outer ring and and link it
74214
- function eliminateHole(hole, outerNode) {
74215
- const bridge = findHoleBridge(hole, outerNode);
74216
- if (!bridge) {
74217
- return outerNode;
74218
- }
74219
-
74220
- const bridgeReverse = splitPolygon(bridge, hole);
74221
-
74222
- // filter collinear points around the cuts
74223
- filterPoints(bridgeReverse, bridgeReverse.next);
74224
- return filterPoints(bridge, bridge.next);
74225
- }
74226
-
74227
- // David Eberly's algorithm for finding a bridge between hole and outer polygon
74228
- function findHoleBridge(hole, outerNode) {
74229
- let p = outerNode;
74230
- const hx = hole.x;
74231
- const hy = hole.y;
74232
- let qx = -Infinity;
74233
- let m;
74234
-
74235
- // find a segment intersected by a ray from the hole's leftmost point to the left;
74236
- // segment's endpoint with lesser x will be potential connection point
74237
- do {
74238
- if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
74239
- const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
74240
- if (x <= hx && x > qx) {
74241
- qx = x;
74242
- m = p.x < p.next.x ? p : p.next;
74243
- if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
74244
- }
74245
- }
74246
- p = p.next;
74247
- } while (p !== outerNode);
74248
-
74249
- if (!m) return null;
74250
-
74251
- // look for points inside the triangle of hole point, segment intersection and endpoint;
74252
- // if there are no points found, we have a valid connection;
74253
- // otherwise choose the point of the minimum angle with the ray as connection point
74254
-
74255
- const stop = m;
74256
- const mx = m.x;
74257
- const my = m.y;
74258
- let tanMin = Infinity;
74259
-
74260
- p = m;
74261
-
74262
- do {
74263
- if (hx >= p.x && p.x >= mx && hx !== p.x &&
74264
- pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
74265
-
74266
- const tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
74267
-
74268
- if (locallyInside(p, hole) &&
74269
- (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
74270
- m = p;
74271
- tanMin = tan;
74272
- }
74273
- }
74274
-
74275
- p = p.next;
74276
- } while (p !== stop);
74277
-
74278
- return m;
74279
- }
74280
-
74281
- // whether sector in vertex m contains sector in vertex p in the same coordinates
74282
- function sectorContainsSector(m, p) {
74283
- return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
74284
- }
74285
-
74286
- // interlink polygon nodes in z-order
74287
- function indexCurve(start, minX, minY, invSize) {
74288
- let p = start;
74289
- do {
74290
- if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
74291
- p.prevZ = p.prev;
74292
- p.nextZ = p.next;
74293
- p = p.next;
74294
- } while (p !== start);
74295
-
74296
- p.prevZ.nextZ = null;
74297
- p.prevZ = null;
74298
-
74299
- sortLinked(p);
74300
- }
74301
-
74302
- // Simon Tatham's linked list merge sort algorithm
74303
- // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
74304
- function sortLinked(list) {
74305
- let numMerges;
74306
- let inSize = 1;
74307
-
74308
- do {
74309
- let p = list;
74310
- let e;
74311
- list = null;
74312
- let tail = null;
74313
- numMerges = 0;
74314
-
74315
- while (p) {
74316
- numMerges++;
74317
- let q = p;
74318
- let pSize = 0;
74319
- for (let i = 0; i < inSize; i++) {
74320
- pSize++;
74321
- q = q.nextZ;
74322
- if (!q) break;
74323
- }
74324
- let qSize = inSize;
74325
-
74326
- while (pSize > 0 || (qSize > 0 && q)) {
74327
-
74328
- if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
74329
- e = p;
74330
- p = p.nextZ;
74331
- pSize--;
74332
- } else {
74333
- e = q;
74334
- q = q.nextZ;
74335
- qSize--;
74336
- }
74337
-
74338
- if (tail) tail.nextZ = e;
74339
- else list = e;
74340
-
74341
- e.prevZ = tail;
74342
- tail = e;
74343
- }
74344
-
74345
- p = q;
74346
- }
74347
-
74348
- tail.nextZ = null;
74349
- inSize *= 2;
74350
-
74351
- } while (numMerges > 1);
74352
-
74353
- return list;
74354
- }
74355
-
74356
- // z-order of a point given coords and inverse of the longer side of data bbox
74357
- function zOrder(x, y, minX, minY, invSize) {
74358
- // coords are transformed into non-negative 15-bit integer range
74359
- x = (x - minX) * invSize | 0;
74360
- y = (y - minY) * invSize | 0;
74361
-
74362
- x = (x | (x << 8)) & 0x00FF00FF;
74363
- x = (x | (x << 4)) & 0x0F0F0F0F;
74364
- x = (x | (x << 2)) & 0x33333333;
74365
- x = (x | (x << 1)) & 0x55555555;
74366
-
74367
- y = (y | (y << 8)) & 0x00FF00FF;
74368
- y = (y | (y << 4)) & 0x0F0F0F0F;
74369
- y = (y | (y << 2)) & 0x33333333;
74370
- y = (y | (y << 1)) & 0x55555555;
74371
-
74372
- return x | (y << 1);
74373
- }
74374
-
74375
- // find the leftmost node of a polygon ring
74376
- function getLeftmost(start) {
74377
- let p = start,
74378
- leftmost = start;
74379
- do {
74380
- if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
74381
- p = p.next;
74382
- } while (p !== start);
74383
-
74384
- return leftmost;
74385
- }
74386
-
74387
- // check if a point lies within a convex triangle
74388
- function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
74389
- return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&
74390
- (ax - px) * (by - py) >= (bx - px) * (ay - py) &&
74391
- (bx - px) * (cy - py) >= (cx - px) * (by - py);
74392
- }
74393
-
74394
- // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
74395
- function isValidDiagonal(a, b) {
74396
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
74397
- (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
74398
- (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
74399
- equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
74400
- }
74401
-
74402
- // signed area of a triangle
74403
- function area(p, q, r) {
74404
- return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
74405
- }
74406
-
74407
- // check if two points are equal
74408
- function equals(p1, p2) {
74409
- return p1.x === p2.x && p1.y === p2.y;
74410
- }
74411
-
74412
- // check if two segments intersect
74413
- function intersects(p1, q1, p2, q2) {
74414
- const o1 = sign(area(p1, q1, p2));
74415
- const o2 = sign(area(p1, q1, q2));
74416
- const o3 = sign(area(p2, q2, p1));
74417
- const o4 = sign(area(p2, q2, q1));
74418
-
74419
- if (o1 !== o2 && o3 !== o4) return true; // general case
74420
-
74421
- if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
74422
- if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
74423
- if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
74424
- if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
74425
-
74426
- return false;
74427
- }
74428
-
74429
- // for collinear points p, q, r, check if point q lies on segment pr
74430
- function onSegment(p, q, r) {
74431
- return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
74432
- }
74433
-
74434
- function sign(num) {
74435
- return num > 0 ? 1 : num < 0 ? -1 : 0;
74436
- }
74437
-
74438
- // check if a polygon diagonal intersects any polygon segments
74439
- function intersectsPolygon(a, b) {
74440
- let p = a;
74441
- do {
74442
- if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
74443
- intersects(p, p.next, a, b)) return true;
74444
- p = p.next;
74445
- } while (p !== a);
74446
-
74447
- return false;
74448
- }
74449
-
74450
- // check if a polygon diagonal is locally inside the polygon
74451
- function locallyInside(a, b) {
74452
- return area(a.prev, a, a.next) < 0 ?
74453
- area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
74454
- area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
74455
- }
74456
-
74457
- // check if the middle point of a polygon diagonal is inside the polygon
74458
- function middleInside(a, b) {
74459
- let p = a;
74460
- let inside = false;
74461
- const px = (a.x + b.x) / 2;
74462
- const py = (a.y + b.y) / 2;
74463
- do {
74464
- if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
74465
- (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
74466
- inside = !inside;
74467
- p = p.next;
74468
- } while (p !== a);
74469
-
74470
- return inside;
74471
- }
74472
-
74473
- // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
74474
- // if one belongs to the outer ring and another to a hole, it merges it into a single ring
74475
- function splitPolygon(a, b) {
74476
- const a2 = createNode(a.i, a.x, a.y),
74477
- b2 = createNode(b.i, b.x, b.y),
74478
- an = a.next,
74479
- bp = b.prev;
74480
-
74481
- a.next = b;
74482
- b.prev = a;
74483
-
74484
- a2.next = an;
74485
- an.prev = a2;
74486
-
74487
- b2.next = a2;
74488
- a2.prev = b2;
74489
-
74490
- bp.next = b2;
74491
- b2.prev = bp;
74492
-
74493
- return b2;
74494
- }
74495
-
74496
- // create a node and optionally link it with previous one (in a circular doubly linked list)
74497
- function insertNode(i, x, y, last) {
74498
- const p = createNode(i, x, y);
74499
-
74500
- if (!last) {
74501
- p.prev = p;
74502
- p.next = p;
74503
-
74504
- } else {
74505
- p.next = last.next;
74506
- p.prev = last;
74507
- last.next.prev = p;
74508
- last.next = p;
74509
- }
74510
- return p;
74511
- }
74512
-
74513
- function removeNode(p) {
74514
- p.next.prev = p.prev;
74515
- p.prev.next = p.next;
74516
-
74517
- if (p.prevZ) p.prevZ.nextZ = p.nextZ;
74518
- if (p.nextZ) p.nextZ.prevZ = p.prevZ;
74519
- }
74520
-
74521
- function createNode(i, x, y) {
74522
- return {
74523
- i, // vertex index in coordinates array
74524
- x, y, // vertex coordinates
74525
- prev: null, // previous and next vertex nodes in a polygon ring
74526
- next: null,
74527
- z: 0, // z-order curve value
74528
- prevZ: null, // previous and next nodes in z-order
74529
- nextZ: null,
74530
- steiner: false // indicates whether this is a steiner point
74531
- };
74532
- }
74533
-
74534
- // return a percentage difference between the polygon area and its triangulation area;
74535
- // used to verify correctness of triangulation
74536
- function deviation(data, holeIndices, dim, triangles) {
74537
- const hasHoles = holeIndices && holeIndices.length;
74538
- const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
74539
-
74540
- let polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
74541
- if (hasHoles) {
74542
- for (let i = 0, len = holeIndices.length; i < len; i++) {
74543
- const start = holeIndices[i] * dim;
74544
- const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
74545
- polygonArea -= Math.abs(signedArea(data, start, end, dim));
74546
- }
74547
- }
74548
-
74549
- let trianglesArea = 0;
74550
- for (let i = 0; i < triangles.length; i += 3) {
74551
- const a = triangles[i] * dim;
74552
- const b = triangles[i + 1] * dim;
74553
- const c = triangles[i + 2] * dim;
74554
- trianglesArea += Math.abs(
74555
- (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
74556
- (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
74557
- }
74558
-
74559
- return polygonArea === 0 && trianglesArea === 0 ? 0 :
74560
- Math.abs((trianglesArea - polygonArea) / polygonArea);
74561
- }
74562
-
74563
- function signedArea(data, start, end, dim) {
74564
- let sum = 0;
74565
- for (let i = start, j = end - dim; i < end; i += dim) {
74566
- sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
74567
- j = i;
74568
- }
74569
- return sum;
74570
- }
74571
-
74572
- // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
74573
- function flatten(data) {
74574
- const vertices = [];
74575
- const holes = [];
74576
- const dimensions = data[0][0].length;
74577
- let holeIndex = 0;
74578
- let prevLen = 0;
74579
-
74580
- for (const ring of data) {
74581
- for (const p of ring) {
74582
- for (let d = 0; d < dimensions; d++) vertices.push(p[d]);
74583
- }
74584
- if (prevLen) {
74585
- holeIndex += prevLen;
74586
- holes.push(holeIndex);
74587
- }
74588
- prevLen = ring.length;
74589
- }
74590
- return {vertices, holes, dimensions};
74591
- }
74592
-
74593
-
74594
74541
  /***/ })
74595
74542
 
74596
74543
  /******/ });