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.js CHANGED
@@ -28074,7 +28074,7 @@ module.exports = _sceneObject;
28074
28074
  * @constant
28075
28075
  * @type {string}
28076
28076
  */
28077
- module.exports = "5ad0374165eab0d4a487723bc62b58070d532854";
28077
+ module.exports = "1fd3450e4c094c4475819ff627ee93484c684c3c";
28078
28078
 
28079
28079
  /***/ }),
28080
28080
 
@@ -39913,7 +39913,7 @@ module.exports = _vectorFeature;
39913
39913
  * @constant
39914
39914
  * @type {string}
39915
39915
  */
39916
- module.exports = "1.12.4";
39916
+ module.exports = "1.12.5";
39917
39917
 
39918
39918
  /***/ }),
39919
39919
 
@@ -47666,7 +47666,7 @@ var _webgl_polygonFeature = function webgl_polygonFeature(arg) {
47666
47666
  arg = arg || {};
47667
47667
  polygonFeature.call(this, arg);
47668
47668
  var vgl = __webpack_require__(1611);
47669
- var earcut = __webpack_require__(2087);
47669
+ var earcut = __webpack_require__(9747);
47670
47670
  earcut = earcut.__esModule ? earcut.default : earcut;
47671
47671
  var transform = __webpack_require__(5325);
47672
47672
  var util = __webpack_require__(642);
@@ -76384,6 +76384,630 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__4436__;
76384
76384
 
76385
76385
  /***/ }),
76386
76386
 
76387
+ /***/ 9747:
76388
+ /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
76389
+
76390
+ "use strict";
76391
+ __webpack_require__.r(__webpack_exports__);
76392
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
76393
+ /* harmony export */ "default": function() { return /* binding */ earcut; },
76394
+ /* harmony export */ deviation: function() { return /* binding */ deviation; },
76395
+ /* harmony export */ flatten: function() { return /* binding */ flatten; }
76396
+ /* harmony export */ });
76397
+ 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; } } }; }
76398
+ 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; } }
76399
+ 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; }
76400
+ function earcut(data, holeIndices) {
76401
+ var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
76402
+ var hasHoles = holeIndices && holeIndices.length;
76403
+ var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
76404
+ var outerNode = linkedList(data, 0, outerLen, dim, true);
76405
+ var triangles = [];
76406
+ if (!outerNode || outerNode.next === outerNode.prev) return triangles;
76407
+ var minX, minY, invSize;
76408
+ if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
76409
+
76410
+ // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
76411
+ if (data.length > 80 * dim) {
76412
+ minX = Infinity;
76413
+ minY = Infinity;
76414
+ var maxX = -Infinity;
76415
+ var maxY = -Infinity;
76416
+ for (var i = dim; i < outerLen; i += dim) {
76417
+ var x = data[i];
76418
+ var y = data[i + 1];
76419
+ if (x < minX) minX = x;
76420
+ if (y < minY) minY = y;
76421
+ if (x > maxX) maxX = x;
76422
+ if (y > maxY) maxY = y;
76423
+ }
76424
+
76425
+ // minX, minY and invSize are later used to transform coords into integers for z-order calculation
76426
+ invSize = Math.max(maxX - minX, maxY - minY);
76427
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
76428
+ }
76429
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
76430
+ return triangles;
76431
+ }
76432
+
76433
+ // create a circular doubly linked list from polygon points in the specified winding order
76434
+ function linkedList(data, start, end, dim, clockwise) {
76435
+ var last;
76436
+ if (clockwise === signedArea(data, start, end, dim) > 0) {
76437
+ for (var i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
76438
+ } else {
76439
+ for (var _i = end - dim; _i >= start; _i -= dim) last = insertNode(_i / dim | 0, data[_i], data[_i + 1], last);
76440
+ }
76441
+ if (last && equals(last, last.next)) {
76442
+ removeNode(last);
76443
+ last = last.next;
76444
+ }
76445
+ return last;
76446
+ }
76447
+
76448
+ // eliminate colinear or duplicate points
76449
+ function filterPoints(start, end) {
76450
+ if (!start) return start;
76451
+ if (!end) end = start;
76452
+ var p = start,
76453
+ again;
76454
+ do {
76455
+ again = false;
76456
+ if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
76457
+ removeNode(p);
76458
+ p = end = p.prev;
76459
+ if (p === p.next) break;
76460
+ again = true;
76461
+ } else {
76462
+ p = p.next;
76463
+ }
76464
+ } while (again || p !== end);
76465
+ return end;
76466
+ }
76467
+
76468
+ // main ear slicing loop which triangulates a polygon (given as a linked list)
76469
+ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
76470
+ if (!ear) return;
76471
+
76472
+ // interlink polygon nodes in z-order
76473
+ if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
76474
+ var stop = ear;
76475
+
76476
+ // iterate through ears, slicing them one by one
76477
+ while (ear.prev !== ear.next) {
76478
+ var prev = ear.prev;
76479
+ var next = ear.next;
76480
+ if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
76481
+ triangles.push(prev.i, ear.i, next.i); // cut off the triangle
76482
+
76483
+ removeNode(ear);
76484
+
76485
+ // skipping the next vertex leads to less sliver triangles
76486
+ ear = next.next;
76487
+ stop = next.next;
76488
+ continue;
76489
+ }
76490
+ ear = next;
76491
+
76492
+ // if we looped through the whole remaining polygon and can't find any more ears
76493
+ if (ear === stop) {
76494
+ // try filtering points and slicing again
76495
+ if (!pass) {
76496
+ earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
76497
+
76498
+ // if this didn't work, try curing all small self-intersections locally
76499
+ } else if (pass === 1) {
76500
+ ear = cureLocalIntersections(filterPoints(ear), triangles);
76501
+ earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
76502
+
76503
+ // as a last resort, try splitting the remaining polygon into two
76504
+ } else if (pass === 2) {
76505
+ splitEarcut(ear, triangles, dim, minX, minY, invSize);
76506
+ }
76507
+ break;
76508
+ }
76509
+ }
76510
+ }
76511
+
76512
+ // check whether a polygon node forms a valid ear with adjacent nodes
76513
+ function isEar(ear) {
76514
+ var a = ear.prev,
76515
+ b = ear,
76516
+ c = ear.next;
76517
+ if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
76518
+
76519
+ // now make sure we don't have other points inside the potential ear
76520
+ var ax = a.x,
76521
+ bx = b.x,
76522
+ cx = c.x,
76523
+ ay = a.y,
76524
+ by = b.y,
76525
+ cy = c.y;
76526
+
76527
+ // triangle bbox; min & max are calculated like this for speed
76528
+ var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
76529
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
76530
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
76531
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
76532
+ var p = c.next;
76533
+ while (p !== a) {
76534
+ 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;
76535
+ p = p.next;
76536
+ }
76537
+ return true;
76538
+ }
76539
+ function isEarHashed(ear, minX, minY, invSize) {
76540
+ var a = ear.prev,
76541
+ b = ear,
76542
+ c = ear.next;
76543
+ if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
76544
+
76545
+ var ax = a.x,
76546
+ bx = b.x,
76547
+ cx = c.x,
76548
+ ay = a.y,
76549
+ by = b.y,
76550
+ cy = c.y;
76551
+
76552
+ // triangle bbox; min & max are calculated like this for speed
76553
+ var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
76554
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
76555
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
76556
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
76557
+
76558
+ // z-order range for the current triangle bbox;
76559
+ var minZ = zOrder(x0, y0, minX, minY, invSize),
76560
+ maxZ = zOrder(x1, y1, minX, minY, invSize);
76561
+ var p = ear.prevZ,
76562
+ n = ear.nextZ;
76563
+
76564
+ // look for points inside the triangle in both directions
76565
+ while (p && p.z >= minZ && n && n.z <= maxZ) {
76566
+ 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;
76567
+ p = p.prevZ;
76568
+ 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;
76569
+ n = n.nextZ;
76570
+ }
76571
+
76572
+ // look for remaining points in decreasing z-order
76573
+ while (p && p.z >= minZ) {
76574
+ 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;
76575
+ p = p.prevZ;
76576
+ }
76577
+
76578
+ // look for remaining points in increasing z-order
76579
+ while (n && n.z <= maxZ) {
76580
+ 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;
76581
+ n = n.nextZ;
76582
+ }
76583
+ return true;
76584
+ }
76585
+
76586
+ // go through all polygon nodes and cure small local self-intersections
76587
+ function cureLocalIntersections(start, triangles) {
76588
+ var p = start;
76589
+ do {
76590
+ var a = p.prev,
76591
+ b = p.next.next;
76592
+ if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
76593
+ triangles.push(a.i, p.i, b.i);
76594
+
76595
+ // remove two nodes involved
76596
+ removeNode(p);
76597
+ removeNode(p.next);
76598
+ p = start = b;
76599
+ }
76600
+ p = p.next;
76601
+ } while (p !== start);
76602
+ return filterPoints(p);
76603
+ }
76604
+
76605
+ // try splitting polygon into two and triangulate them independently
76606
+ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
76607
+ // look for a valid diagonal that divides the polygon into two
76608
+ var a = start;
76609
+ do {
76610
+ var b = a.next.next;
76611
+ while (b !== a.prev) {
76612
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
76613
+ // split the polygon in two by the diagonal
76614
+ var c = splitPolygon(a, b);
76615
+
76616
+ // filter colinear points around the cuts
76617
+ a = filterPoints(a, a.next);
76618
+ c = filterPoints(c, c.next);
76619
+
76620
+ // run earcut on each half
76621
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
76622
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
76623
+ return;
76624
+ }
76625
+ b = b.next;
76626
+ }
76627
+ a = a.next;
76628
+ } while (a !== start);
76629
+ }
76630
+
76631
+ // link every hole into the outer loop, producing a single-ring polygon without holes
76632
+ function eliminateHoles(data, holeIndices, outerNode, dim) {
76633
+ var queue = [];
76634
+ for (var i = 0, len = holeIndices.length; i < len; i++) {
76635
+ var start = holeIndices[i] * dim;
76636
+ var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
76637
+ var list = linkedList(data, start, end, dim, false);
76638
+ if (list === list.next) list.steiner = true;
76639
+ queue.push(getLeftmost(list));
76640
+ }
76641
+ queue.sort(compareX);
76642
+
76643
+ // process holes from left to right
76644
+ for (var _i2 = 0; _i2 < queue.length; _i2++) {
76645
+ outerNode = eliminateHole(queue[_i2], outerNode);
76646
+ }
76647
+ return outerNode;
76648
+ }
76649
+ function compareX(a, b) {
76650
+ return a.x - b.x;
76651
+ }
76652
+
76653
+ // find a bridge between vertices that connects hole with an outer ring and and link it
76654
+ function eliminateHole(hole, outerNode) {
76655
+ var bridge = findHoleBridge(hole, outerNode);
76656
+ if (!bridge) {
76657
+ return outerNode;
76658
+ }
76659
+ var bridgeReverse = splitPolygon(bridge, hole);
76660
+
76661
+ // filter collinear points around the cuts
76662
+ filterPoints(bridgeReverse, bridgeReverse.next);
76663
+ return filterPoints(bridge, bridge.next);
76664
+ }
76665
+
76666
+ // David Eberly's algorithm for finding a bridge between hole and outer polygon
76667
+ function findHoleBridge(hole, outerNode) {
76668
+ var p = outerNode;
76669
+ var hx = hole.x;
76670
+ var hy = hole.y;
76671
+ var qx = -Infinity;
76672
+ var m;
76673
+
76674
+ // find a segment intersected by a ray from the hole's leftmost point to the left;
76675
+ // segment's endpoint with lesser x will be potential connection point
76676
+ do {
76677
+ if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
76678
+ var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
76679
+ if (x <= hx && x > qx) {
76680
+ qx = x;
76681
+ m = p.x < p.next.x ? p : p.next;
76682
+ if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
76683
+ }
76684
+ }
76685
+ p = p.next;
76686
+ } while (p !== outerNode);
76687
+ if (!m) return null;
76688
+
76689
+ // look for points inside the triangle of hole point, segment intersection and endpoint;
76690
+ // if there are no points found, we have a valid connection;
76691
+ // otherwise choose the point of the minimum angle with the ray as connection point
76692
+
76693
+ var stop = m;
76694
+ var mx = m.x;
76695
+ var my = m.y;
76696
+ var tanMin = Infinity;
76697
+ p = m;
76698
+ do {
76699
+ 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)) {
76700
+ var tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
76701
+
76702
+ if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
76703
+ m = p;
76704
+ tanMin = tan;
76705
+ }
76706
+ }
76707
+ p = p.next;
76708
+ } while (p !== stop);
76709
+ return m;
76710
+ }
76711
+
76712
+ // whether sector in vertex m contains sector in vertex p in the same coordinates
76713
+ function sectorContainsSector(m, p) {
76714
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
76715
+ }
76716
+
76717
+ // interlink polygon nodes in z-order
76718
+ function indexCurve(start, minX, minY, invSize) {
76719
+ var p = start;
76720
+ do {
76721
+ if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
76722
+ p.prevZ = p.prev;
76723
+ p.nextZ = p.next;
76724
+ p = p.next;
76725
+ } while (p !== start);
76726
+ p.prevZ.nextZ = null;
76727
+ p.prevZ = null;
76728
+ sortLinked(p);
76729
+ }
76730
+
76731
+ // Simon Tatham's linked list merge sort algorithm
76732
+ // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
76733
+ function sortLinked(list) {
76734
+ var numMerges;
76735
+ var inSize = 1;
76736
+ do {
76737
+ var p = list;
76738
+ var e = void 0;
76739
+ list = null;
76740
+ var tail = null;
76741
+ numMerges = 0;
76742
+ while (p) {
76743
+ numMerges++;
76744
+ var q = p;
76745
+ var pSize = 0;
76746
+ for (var i = 0; i < inSize; i++) {
76747
+ pSize++;
76748
+ q = q.nextZ;
76749
+ if (!q) break;
76750
+ }
76751
+ var qSize = inSize;
76752
+ while (pSize > 0 || qSize > 0 && q) {
76753
+ if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
76754
+ e = p;
76755
+ p = p.nextZ;
76756
+ pSize--;
76757
+ } else {
76758
+ e = q;
76759
+ q = q.nextZ;
76760
+ qSize--;
76761
+ }
76762
+ if (tail) tail.nextZ = e;else list = e;
76763
+ e.prevZ = tail;
76764
+ tail = e;
76765
+ }
76766
+ p = q;
76767
+ }
76768
+ tail.nextZ = null;
76769
+ inSize *= 2;
76770
+ } while (numMerges > 1);
76771
+ return list;
76772
+ }
76773
+
76774
+ // z-order of a point given coords and inverse of the longer side of data bbox
76775
+ function zOrder(x, y, minX, minY, invSize) {
76776
+ // coords are transformed into non-negative 15-bit integer range
76777
+ x = (x - minX) * invSize | 0;
76778
+ y = (y - minY) * invSize | 0;
76779
+ x = (x | x << 8) & 0x00FF00FF;
76780
+ x = (x | x << 4) & 0x0F0F0F0F;
76781
+ x = (x | x << 2) & 0x33333333;
76782
+ x = (x | x << 1) & 0x55555555;
76783
+ y = (y | y << 8) & 0x00FF00FF;
76784
+ y = (y | y << 4) & 0x0F0F0F0F;
76785
+ y = (y | y << 2) & 0x33333333;
76786
+ y = (y | y << 1) & 0x55555555;
76787
+ return x | y << 1;
76788
+ }
76789
+
76790
+ // find the leftmost node of a polygon ring
76791
+ function getLeftmost(start) {
76792
+ var p = start,
76793
+ leftmost = start;
76794
+ do {
76795
+ if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;
76796
+ p = p.next;
76797
+ } while (p !== start);
76798
+ return leftmost;
76799
+ }
76800
+
76801
+ // check if a point lies within a convex triangle
76802
+ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
76803
+ 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);
76804
+ }
76805
+
76806
+ // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
76807
+ function isValidDiagonal(a, b) {
76808
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (
76809
+ // dones't intersect other edges
76810
+ locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (
76811
+ // locally visible
76812
+ area(a.prev, a, b.prev) || area(a, b.prev, b)) ||
76813
+ // does not create opposite-facing sectors
76814
+ equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
76815
+ }
76816
+
76817
+ // signed area of a triangle
76818
+ function area(p, q, r) {
76819
+ return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
76820
+ }
76821
+
76822
+ // check if two points are equal
76823
+ function equals(p1, p2) {
76824
+ return p1.x === p2.x && p1.y === p2.y;
76825
+ }
76826
+
76827
+ // check if two segments intersect
76828
+ function intersects(p1, q1, p2, q2) {
76829
+ var o1 = sign(area(p1, q1, p2));
76830
+ var o2 = sign(area(p1, q1, q2));
76831
+ var o3 = sign(area(p2, q2, p1));
76832
+ var o4 = sign(area(p2, q2, q1));
76833
+ if (o1 !== o2 && o3 !== o4) return true; // general case
76834
+
76835
+ if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
76836
+ if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
76837
+ if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
76838
+ if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
76839
+
76840
+ return false;
76841
+ }
76842
+
76843
+ // for collinear points p, q, r, check if point q lies on segment pr
76844
+ function onSegment(p, q, r) {
76845
+ 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);
76846
+ }
76847
+ function sign(num) {
76848
+ return num > 0 ? 1 : num < 0 ? -1 : 0;
76849
+ }
76850
+
76851
+ // check if a polygon diagonal intersects any polygon segments
76852
+ function intersectsPolygon(a, b) {
76853
+ var p = a;
76854
+ do {
76855
+ 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;
76856
+ p = p.next;
76857
+ } while (p !== a);
76858
+ return false;
76859
+ }
76860
+
76861
+ // check if a polygon diagonal is locally inside the polygon
76862
+ function locallyInside(a, b) {
76863
+ 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;
76864
+ }
76865
+
76866
+ // check if the middle point of a polygon diagonal is inside the polygon
76867
+ function middleInside(a, b) {
76868
+ var p = a;
76869
+ var inside = false;
76870
+ var px = (a.x + b.x) / 2;
76871
+ var py = (a.y + b.y) / 2;
76872
+ do {
76873
+ 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;
76874
+ p = p.next;
76875
+ } while (p !== a);
76876
+ return inside;
76877
+ }
76878
+
76879
+ // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
76880
+ // if one belongs to the outer ring and another to a hole, it merges it into a single ring
76881
+ function splitPolygon(a, b) {
76882
+ var a2 = createNode(a.i, a.x, a.y),
76883
+ b2 = createNode(b.i, b.x, b.y),
76884
+ an = a.next,
76885
+ bp = b.prev;
76886
+ a.next = b;
76887
+ b.prev = a;
76888
+ a2.next = an;
76889
+ an.prev = a2;
76890
+ b2.next = a2;
76891
+ a2.prev = b2;
76892
+ bp.next = b2;
76893
+ b2.prev = bp;
76894
+ return b2;
76895
+ }
76896
+
76897
+ // create a node and optionally link it with previous one (in a circular doubly linked list)
76898
+ function insertNode(i, x, y, last) {
76899
+ var p = createNode(i, x, y);
76900
+ if (!last) {
76901
+ p.prev = p;
76902
+ p.next = p;
76903
+ } else {
76904
+ p.next = last.next;
76905
+ p.prev = last;
76906
+ last.next.prev = p;
76907
+ last.next = p;
76908
+ }
76909
+ return p;
76910
+ }
76911
+ function removeNode(p) {
76912
+ p.next.prev = p.prev;
76913
+ p.prev.next = p.next;
76914
+ if (p.prevZ) p.prevZ.nextZ = p.nextZ;
76915
+ if (p.nextZ) p.nextZ.prevZ = p.prevZ;
76916
+ }
76917
+ function createNode(i, x, y) {
76918
+ return {
76919
+ i: i,
76920
+ // vertex index in coordinates array
76921
+ x: x,
76922
+ y: y,
76923
+ // vertex coordinates
76924
+ prev: null,
76925
+ // previous and next vertex nodes in a polygon ring
76926
+ next: null,
76927
+ z: 0,
76928
+ // z-order curve value
76929
+ prevZ: null,
76930
+ // previous and next nodes in z-order
76931
+ nextZ: null,
76932
+ steiner: false // indicates whether this is a steiner point
76933
+ };
76934
+ }
76935
+
76936
+ // return a percentage difference between the polygon area and its triangulation area;
76937
+ // used to verify correctness of triangulation
76938
+ function deviation(data, holeIndices, dim, triangles) {
76939
+ var hasHoles = holeIndices && holeIndices.length;
76940
+ var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
76941
+ var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
76942
+ if (hasHoles) {
76943
+ for (var i = 0, len = holeIndices.length; i < len; i++) {
76944
+ var start = holeIndices[i] * dim;
76945
+ var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
76946
+ polygonArea -= Math.abs(signedArea(data, start, end, dim));
76947
+ }
76948
+ }
76949
+ var trianglesArea = 0;
76950
+ for (var _i3 = 0; _i3 < triangles.length; _i3 += 3) {
76951
+ var a = triangles[_i3] * dim;
76952
+ var b = triangles[_i3 + 1] * dim;
76953
+ var c = triangles[_i3 + 2] * dim;
76954
+ trianglesArea += Math.abs((data[a] - data[c]) * (data[b + 1] - data[a + 1]) - (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
76955
+ }
76956
+ return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);
76957
+ }
76958
+ function signedArea(data, start, end, dim) {
76959
+ var sum = 0;
76960
+ for (var i = start, j = end - dim; i < end; i += dim) {
76961
+ sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
76962
+ j = i;
76963
+ }
76964
+ return sum;
76965
+ }
76966
+
76967
+ // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
76968
+ function flatten(data) {
76969
+ var vertices = [];
76970
+ var holes = [];
76971
+ var dimensions = data[0][0].length;
76972
+ var holeIndex = 0;
76973
+ var prevLen = 0;
76974
+ var _iterator = _createForOfIteratorHelper(data),
76975
+ _step;
76976
+ try {
76977
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
76978
+ var ring = _step.value;
76979
+ var _iterator2 = _createForOfIteratorHelper(ring),
76980
+ _step2;
76981
+ try {
76982
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
76983
+ var p = _step2.value;
76984
+ for (var d = 0; d < dimensions; d++) vertices.push(p[d]);
76985
+ }
76986
+ } catch (err) {
76987
+ _iterator2.e(err);
76988
+ } finally {
76989
+ _iterator2.f();
76990
+ }
76991
+ if (prevLen) {
76992
+ holeIndex += prevLen;
76993
+ holes.push(holeIndex);
76994
+ }
76995
+ prevLen = ring.length;
76996
+ }
76997
+ } catch (err) {
76998
+ _iterator.e(err);
76999
+ } finally {
77000
+ _iterator.f();
77001
+ }
77002
+ return {
77003
+ vertices: vertices,
77004
+ holes: holes,
77005
+ dimensions: dimensions
77006
+ };
77007
+ }
77008
+
77009
+ /***/ }),
77010
+
76387
77011
  /***/ 4279:
76388
77012
  /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
76389
77013
 
@@ -101726,683 +102350,6 @@ function defaultConstrain(transform, extent, translateExtent) {
101726
102350
 
101727
102351
 
101728
102352
 
101729
-
101730
-
101731
- /***/ }),
101732
-
101733
- /***/ 2087:
101734
- /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
101735
-
101736
- "use strict";
101737
- __webpack_require__.r(__webpack_exports__);
101738
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
101739
- /* harmony export */ "default": function() { return /* binding */ earcut; },
101740
- /* harmony export */ deviation: function() { return /* binding */ deviation; },
101741
- /* harmony export */ flatten: function() { return /* binding */ flatten; }
101742
- /* harmony export */ });
101743
-
101744
- function earcut(data, holeIndices, dim = 2) {
101745
-
101746
- const hasHoles = holeIndices && holeIndices.length;
101747
- const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
101748
- let outerNode = linkedList(data, 0, outerLen, dim, true);
101749
- const triangles = [];
101750
-
101751
- if (!outerNode || outerNode.next === outerNode.prev) return triangles;
101752
-
101753
- let minX, minY, invSize;
101754
-
101755
- if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
101756
-
101757
- // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
101758
- if (data.length > 80 * dim) {
101759
- minX = Infinity;
101760
- minY = Infinity;
101761
- let maxX = -Infinity;
101762
- let maxY = -Infinity;
101763
-
101764
- for (let i = dim; i < outerLen; i += dim) {
101765
- const x = data[i];
101766
- const y = data[i + 1];
101767
- if (x < minX) minX = x;
101768
- if (y < minY) minY = y;
101769
- if (x > maxX) maxX = x;
101770
- if (y > maxY) maxY = y;
101771
- }
101772
-
101773
- // minX, minY and invSize are later used to transform coords into integers for z-order calculation
101774
- invSize = Math.max(maxX - minX, maxY - minY);
101775
- invSize = invSize !== 0 ? 32767 / invSize : 0;
101776
- }
101777
-
101778
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
101779
-
101780
- return triangles;
101781
- }
101782
-
101783
- // create a circular doubly linked list from polygon points in the specified winding order
101784
- function linkedList(data, start, end, dim, clockwise) {
101785
- let last;
101786
-
101787
- if (clockwise === (signedArea(data, start, end, dim) > 0)) {
101788
- for (let i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
101789
- } else {
101790
- for (let i = end - dim; i >= start; i -= dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
101791
- }
101792
-
101793
- if (last && equals(last, last.next)) {
101794
- removeNode(last);
101795
- last = last.next;
101796
- }
101797
-
101798
- return last;
101799
- }
101800
-
101801
- // eliminate colinear or duplicate points
101802
- function filterPoints(start, end) {
101803
- if (!start) return start;
101804
- if (!end) end = start;
101805
-
101806
- let p = start,
101807
- again;
101808
- do {
101809
- again = false;
101810
-
101811
- if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
101812
- removeNode(p);
101813
- p = end = p.prev;
101814
- if (p === p.next) break;
101815
- again = true;
101816
-
101817
- } else {
101818
- p = p.next;
101819
- }
101820
- } while (again || p !== end);
101821
-
101822
- return end;
101823
- }
101824
-
101825
- // main ear slicing loop which triangulates a polygon (given as a linked list)
101826
- function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
101827
- if (!ear) return;
101828
-
101829
- // interlink polygon nodes in z-order
101830
- if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
101831
-
101832
- let stop = ear;
101833
-
101834
- // iterate through ears, slicing them one by one
101835
- while (ear.prev !== ear.next) {
101836
- const prev = ear.prev;
101837
- const next = ear.next;
101838
-
101839
- if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
101840
- triangles.push(prev.i, ear.i, next.i); // cut off the triangle
101841
-
101842
- removeNode(ear);
101843
-
101844
- // skipping the next vertex leads to less sliver triangles
101845
- ear = next.next;
101846
- stop = next.next;
101847
-
101848
- continue;
101849
- }
101850
-
101851
- ear = next;
101852
-
101853
- // if we looped through the whole remaining polygon and can't find any more ears
101854
- if (ear === stop) {
101855
- // try filtering points and slicing again
101856
- if (!pass) {
101857
- earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
101858
-
101859
- // if this didn't work, try curing all small self-intersections locally
101860
- } else if (pass === 1) {
101861
- ear = cureLocalIntersections(filterPoints(ear), triangles);
101862
- earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
101863
-
101864
- // as a last resort, try splitting the remaining polygon into two
101865
- } else if (pass === 2) {
101866
- splitEarcut(ear, triangles, dim, minX, minY, invSize);
101867
- }
101868
-
101869
- break;
101870
- }
101871
- }
101872
- }
101873
-
101874
- // check whether a polygon node forms a valid ear with adjacent nodes
101875
- function isEar(ear) {
101876
- const a = ear.prev,
101877
- b = ear,
101878
- c = ear.next;
101879
-
101880
- if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
101881
-
101882
- // now make sure we don't have other points inside the potential ear
101883
- const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
101884
-
101885
- // triangle bbox; min & max are calculated like this for speed
101886
- const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
101887
- y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
101888
- x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
101889
- y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
101890
-
101891
- let p = c.next;
101892
- while (p !== a) {
101893
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
101894
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
101895
- area(p.prev, p, p.next) >= 0) return false;
101896
- p = p.next;
101897
- }
101898
-
101899
- return true;
101900
- }
101901
-
101902
- function isEarHashed(ear, minX, minY, invSize) {
101903
- const a = ear.prev,
101904
- b = ear,
101905
- c = ear.next;
101906
-
101907
- if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
101908
-
101909
- const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
101910
-
101911
- // triangle bbox; min & max are calculated like this for speed
101912
- const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
101913
- y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
101914
- x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
101915
- y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
101916
-
101917
- // z-order range for the current triangle bbox;
101918
- const minZ = zOrder(x0, y0, minX, minY, invSize),
101919
- maxZ = zOrder(x1, y1, minX, minY, invSize);
101920
-
101921
- let p = ear.prevZ,
101922
- n = ear.nextZ;
101923
-
101924
- // look for points inside the triangle in both directions
101925
- while (p && p.z >= minZ && n && n.z <= maxZ) {
101926
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
101927
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
101928
- p = p.prevZ;
101929
-
101930
- if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
101931
- pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
101932
- n = n.nextZ;
101933
- }
101934
-
101935
- // look for remaining points in decreasing z-order
101936
- while (p && p.z >= minZ) {
101937
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
101938
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
101939
- p = p.prevZ;
101940
- }
101941
-
101942
- // look for remaining points in increasing z-order
101943
- while (n && n.z <= maxZ) {
101944
- if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
101945
- pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
101946
- n = n.nextZ;
101947
- }
101948
-
101949
- return true;
101950
- }
101951
-
101952
- // go through all polygon nodes and cure small local self-intersections
101953
- function cureLocalIntersections(start, triangles) {
101954
- let p = start;
101955
- do {
101956
- const a = p.prev,
101957
- b = p.next.next;
101958
-
101959
- if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
101960
-
101961
- triangles.push(a.i, p.i, b.i);
101962
-
101963
- // remove two nodes involved
101964
- removeNode(p);
101965
- removeNode(p.next);
101966
-
101967
- p = start = b;
101968
- }
101969
- p = p.next;
101970
- } while (p !== start);
101971
-
101972
- return filterPoints(p);
101973
- }
101974
-
101975
- // try splitting polygon into two and triangulate them independently
101976
- function splitEarcut(start, triangles, dim, minX, minY, invSize) {
101977
- // look for a valid diagonal that divides the polygon into two
101978
- let a = start;
101979
- do {
101980
- let b = a.next.next;
101981
- while (b !== a.prev) {
101982
- if (a.i !== b.i && isValidDiagonal(a, b)) {
101983
- // split the polygon in two by the diagonal
101984
- let c = splitPolygon(a, b);
101985
-
101986
- // filter colinear points around the cuts
101987
- a = filterPoints(a, a.next);
101988
- c = filterPoints(c, c.next);
101989
-
101990
- // run earcut on each half
101991
- earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
101992
- earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
101993
- return;
101994
- }
101995
- b = b.next;
101996
- }
101997
- a = a.next;
101998
- } while (a !== start);
101999
- }
102000
-
102001
- // link every hole into the outer loop, producing a single-ring polygon without holes
102002
- function eliminateHoles(data, holeIndices, outerNode, dim) {
102003
- const queue = [];
102004
-
102005
- for (let i = 0, len = holeIndices.length; i < len; i++) {
102006
- const start = holeIndices[i] * dim;
102007
- const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
102008
- const list = linkedList(data, start, end, dim, false);
102009
- if (list === list.next) list.steiner = true;
102010
- queue.push(getLeftmost(list));
102011
- }
102012
-
102013
- queue.sort(compareX);
102014
-
102015
- // process holes from left to right
102016
- for (let i = 0; i < queue.length; i++) {
102017
- outerNode = eliminateHole(queue[i], outerNode);
102018
- }
102019
-
102020
- return outerNode;
102021
- }
102022
-
102023
- function compareX(a, b) {
102024
- return a.x - b.x;
102025
- }
102026
-
102027
- // find a bridge between vertices that connects hole with an outer ring and and link it
102028
- function eliminateHole(hole, outerNode) {
102029
- const bridge = findHoleBridge(hole, outerNode);
102030
- if (!bridge) {
102031
- return outerNode;
102032
- }
102033
-
102034
- const bridgeReverse = splitPolygon(bridge, hole);
102035
-
102036
- // filter collinear points around the cuts
102037
- filterPoints(bridgeReverse, bridgeReverse.next);
102038
- return filterPoints(bridge, bridge.next);
102039
- }
102040
-
102041
- // David Eberly's algorithm for finding a bridge between hole and outer polygon
102042
- function findHoleBridge(hole, outerNode) {
102043
- let p = outerNode;
102044
- const hx = hole.x;
102045
- const hy = hole.y;
102046
- let qx = -Infinity;
102047
- let m;
102048
-
102049
- // find a segment intersected by a ray from the hole's leftmost point to the left;
102050
- // segment's endpoint with lesser x will be potential connection point
102051
- do {
102052
- if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
102053
- const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
102054
- if (x <= hx && x > qx) {
102055
- qx = x;
102056
- m = p.x < p.next.x ? p : p.next;
102057
- if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
102058
- }
102059
- }
102060
- p = p.next;
102061
- } while (p !== outerNode);
102062
-
102063
- if (!m) return null;
102064
-
102065
- // look for points inside the triangle of hole point, segment intersection and endpoint;
102066
- // if there are no points found, we have a valid connection;
102067
- // otherwise choose the point of the minimum angle with the ray as connection point
102068
-
102069
- const stop = m;
102070
- const mx = m.x;
102071
- const my = m.y;
102072
- let tanMin = Infinity;
102073
-
102074
- p = m;
102075
-
102076
- do {
102077
- if (hx >= p.x && p.x >= mx && hx !== p.x &&
102078
- pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
102079
-
102080
- const tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
102081
-
102082
- if (locallyInside(p, hole) &&
102083
- (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
102084
- m = p;
102085
- tanMin = tan;
102086
- }
102087
- }
102088
-
102089
- p = p.next;
102090
- } while (p !== stop);
102091
-
102092
- return m;
102093
- }
102094
-
102095
- // whether sector in vertex m contains sector in vertex p in the same coordinates
102096
- function sectorContainsSector(m, p) {
102097
- return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
102098
- }
102099
-
102100
- // interlink polygon nodes in z-order
102101
- function indexCurve(start, minX, minY, invSize) {
102102
- let p = start;
102103
- do {
102104
- if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
102105
- p.prevZ = p.prev;
102106
- p.nextZ = p.next;
102107
- p = p.next;
102108
- } while (p !== start);
102109
-
102110
- p.prevZ.nextZ = null;
102111
- p.prevZ = null;
102112
-
102113
- sortLinked(p);
102114
- }
102115
-
102116
- // Simon Tatham's linked list merge sort algorithm
102117
- // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
102118
- function sortLinked(list) {
102119
- let numMerges;
102120
- let inSize = 1;
102121
-
102122
- do {
102123
- let p = list;
102124
- let e;
102125
- list = null;
102126
- let tail = null;
102127
- numMerges = 0;
102128
-
102129
- while (p) {
102130
- numMerges++;
102131
- let q = p;
102132
- let pSize = 0;
102133
- for (let i = 0; i < inSize; i++) {
102134
- pSize++;
102135
- q = q.nextZ;
102136
- if (!q) break;
102137
- }
102138
- let qSize = inSize;
102139
-
102140
- while (pSize > 0 || (qSize > 0 && q)) {
102141
-
102142
- if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
102143
- e = p;
102144
- p = p.nextZ;
102145
- pSize--;
102146
- } else {
102147
- e = q;
102148
- q = q.nextZ;
102149
- qSize--;
102150
- }
102151
-
102152
- if (tail) tail.nextZ = e;
102153
- else list = e;
102154
-
102155
- e.prevZ = tail;
102156
- tail = e;
102157
- }
102158
-
102159
- p = q;
102160
- }
102161
-
102162
- tail.nextZ = null;
102163
- inSize *= 2;
102164
-
102165
- } while (numMerges > 1);
102166
-
102167
- return list;
102168
- }
102169
-
102170
- // z-order of a point given coords and inverse of the longer side of data bbox
102171
- function zOrder(x, y, minX, minY, invSize) {
102172
- // coords are transformed into non-negative 15-bit integer range
102173
- x = (x - minX) * invSize | 0;
102174
- y = (y - minY) * invSize | 0;
102175
-
102176
- x = (x | (x << 8)) & 0x00FF00FF;
102177
- x = (x | (x << 4)) & 0x0F0F0F0F;
102178
- x = (x | (x << 2)) & 0x33333333;
102179
- x = (x | (x << 1)) & 0x55555555;
102180
-
102181
- y = (y | (y << 8)) & 0x00FF00FF;
102182
- y = (y | (y << 4)) & 0x0F0F0F0F;
102183
- y = (y | (y << 2)) & 0x33333333;
102184
- y = (y | (y << 1)) & 0x55555555;
102185
-
102186
- return x | (y << 1);
102187
- }
102188
-
102189
- // find the leftmost node of a polygon ring
102190
- function getLeftmost(start) {
102191
- let p = start,
102192
- leftmost = start;
102193
- do {
102194
- if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
102195
- p = p.next;
102196
- } while (p !== start);
102197
-
102198
- return leftmost;
102199
- }
102200
-
102201
- // check if a point lies within a convex triangle
102202
- function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
102203
- return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&
102204
- (ax - px) * (by - py) >= (bx - px) * (ay - py) &&
102205
- (bx - px) * (cy - py) >= (cx - px) * (by - py);
102206
- }
102207
-
102208
- // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
102209
- function isValidDiagonal(a, b) {
102210
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
102211
- (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
102212
- (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
102213
- equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
102214
- }
102215
-
102216
- // signed area of a triangle
102217
- function area(p, q, r) {
102218
- return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
102219
- }
102220
-
102221
- // check if two points are equal
102222
- function equals(p1, p2) {
102223
- return p1.x === p2.x && p1.y === p2.y;
102224
- }
102225
-
102226
- // check if two segments intersect
102227
- function intersects(p1, q1, p2, q2) {
102228
- const o1 = sign(area(p1, q1, p2));
102229
- const o2 = sign(area(p1, q1, q2));
102230
- const o3 = sign(area(p2, q2, p1));
102231
- const o4 = sign(area(p2, q2, q1));
102232
-
102233
- if (o1 !== o2 && o3 !== o4) return true; // general case
102234
-
102235
- if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
102236
- if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
102237
- if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
102238
- if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
102239
-
102240
- return false;
102241
- }
102242
-
102243
- // for collinear points p, q, r, check if point q lies on segment pr
102244
- function onSegment(p, q, r) {
102245
- 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);
102246
- }
102247
-
102248
- function sign(num) {
102249
- return num > 0 ? 1 : num < 0 ? -1 : 0;
102250
- }
102251
-
102252
- // check if a polygon diagonal intersects any polygon segments
102253
- function intersectsPolygon(a, b) {
102254
- let p = a;
102255
- do {
102256
- if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
102257
- intersects(p, p.next, a, b)) return true;
102258
- p = p.next;
102259
- } while (p !== a);
102260
-
102261
- return false;
102262
- }
102263
-
102264
- // check if a polygon diagonal is locally inside the polygon
102265
- function locallyInside(a, b) {
102266
- return area(a.prev, a, a.next) < 0 ?
102267
- area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
102268
- area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
102269
- }
102270
-
102271
- // check if the middle point of a polygon diagonal is inside the polygon
102272
- function middleInside(a, b) {
102273
- let p = a;
102274
- let inside = false;
102275
- const px = (a.x + b.x) / 2;
102276
- const py = (a.y + b.y) / 2;
102277
- do {
102278
- if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
102279
- (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
102280
- inside = !inside;
102281
- p = p.next;
102282
- } while (p !== a);
102283
-
102284
- return inside;
102285
- }
102286
-
102287
- // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
102288
- // if one belongs to the outer ring and another to a hole, it merges it into a single ring
102289
- function splitPolygon(a, b) {
102290
- const a2 = createNode(a.i, a.x, a.y),
102291
- b2 = createNode(b.i, b.x, b.y),
102292
- an = a.next,
102293
- bp = b.prev;
102294
-
102295
- a.next = b;
102296
- b.prev = a;
102297
-
102298
- a2.next = an;
102299
- an.prev = a2;
102300
-
102301
- b2.next = a2;
102302
- a2.prev = b2;
102303
-
102304
- bp.next = b2;
102305
- b2.prev = bp;
102306
-
102307
- return b2;
102308
- }
102309
-
102310
- // create a node and optionally link it with previous one (in a circular doubly linked list)
102311
- function insertNode(i, x, y, last) {
102312
- const p = createNode(i, x, y);
102313
-
102314
- if (!last) {
102315
- p.prev = p;
102316
- p.next = p;
102317
-
102318
- } else {
102319
- p.next = last.next;
102320
- p.prev = last;
102321
- last.next.prev = p;
102322
- last.next = p;
102323
- }
102324
- return p;
102325
- }
102326
-
102327
- function removeNode(p) {
102328
- p.next.prev = p.prev;
102329
- p.prev.next = p.next;
102330
-
102331
- if (p.prevZ) p.prevZ.nextZ = p.nextZ;
102332
- if (p.nextZ) p.nextZ.prevZ = p.prevZ;
102333
- }
102334
-
102335
- function createNode(i, x, y) {
102336
- return {
102337
- i, // vertex index in coordinates array
102338
- x, y, // vertex coordinates
102339
- prev: null, // previous and next vertex nodes in a polygon ring
102340
- next: null,
102341
- z: 0, // z-order curve value
102342
- prevZ: null, // previous and next nodes in z-order
102343
- nextZ: null,
102344
- steiner: false // indicates whether this is a steiner point
102345
- };
102346
- }
102347
-
102348
- // return a percentage difference between the polygon area and its triangulation area;
102349
- // used to verify correctness of triangulation
102350
- function deviation(data, holeIndices, dim, triangles) {
102351
- const hasHoles = holeIndices && holeIndices.length;
102352
- const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
102353
-
102354
- let polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
102355
- if (hasHoles) {
102356
- for (let i = 0, len = holeIndices.length; i < len; i++) {
102357
- const start = holeIndices[i] * dim;
102358
- const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
102359
- polygonArea -= Math.abs(signedArea(data, start, end, dim));
102360
- }
102361
- }
102362
-
102363
- let trianglesArea = 0;
102364
- for (let i = 0; i < triangles.length; i += 3) {
102365
- const a = triangles[i] * dim;
102366
- const b = triangles[i + 1] * dim;
102367
- const c = triangles[i + 2] * dim;
102368
- trianglesArea += Math.abs(
102369
- (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
102370
- (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
102371
- }
102372
-
102373
- return polygonArea === 0 && trianglesArea === 0 ? 0 :
102374
- Math.abs((trianglesArea - polygonArea) / polygonArea);
102375
- }
102376
-
102377
- function signedArea(data, start, end, dim) {
102378
- let sum = 0;
102379
- for (let i = start, j = end - dim; i < end; i += dim) {
102380
- sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
102381
- j = i;
102382
- }
102383
- return sum;
102384
- }
102385
-
102386
- // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
102387
- function flatten(data) {
102388
- const vertices = [];
102389
- const holes = [];
102390
- const dimensions = data[0][0].length;
102391
- let holeIndex = 0;
102392
- let prevLen = 0;
102393
-
102394
- for (const ring of data) {
102395
- for (const p of ring) {
102396
- for (let d = 0; d < dimensions; d++) vertices.push(p[d]);
102397
- }
102398
- if (prevLen) {
102399
- holeIndex += prevLen;
102400
- holes.push(holeIndex);
102401
- }
102402
- prevLen = ring.length;
102403
- }
102404
- return {vertices, holes, dimensions};
102405
- }
102406
102353
 
102407
102354
 
102408
102355
  /***/ })