123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- import {
- a
- } from "./chunk-QOV6ITMI.js";
- import {
- n5 as n
- } from "./chunk-Y3WMVFTW.js";
- import {
- q,
- v2 as v,
- y2 as y
- } from "./chunk-GZT4BVFP.js";
- // node_modules/@arcgis/core/core/libs/rbush/PooledRBush.js
- var h = class {
- constructor(t = 9, i) {
- this.compareMinX = l, this.compareMinY = c, this._toBBox = (t2) => t2, this._maxEntries = Math.max(4, t || 9), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), i && (typeof i == "function" ? this._toBBox = i : this._initFormat(i)), this.clear();
- }
- destroy() {
- this.clear(), g.prune(), M.prune(), X.prune(), Y.prune();
- }
- all(t) {
- this._all(this.data, t);
- }
- search(t, i) {
- let n2 = this.data;
- const e = this._toBBox;
- if (p(t, n2))
- for (g.clear(); n2; ) {
- for (let s = 0, h2 = n2.children.length; s < h2; s++) {
- const h3 = n2.children[s], a3 = n2.leaf ? e(h3) : h3;
- p(t, a3) && (n2.leaf ? i(h3) : f(t, a3) ? this._all(h3, i) : g.push(h3));
- }
- n2 = g.pop();
- }
- }
- collides(t) {
- let i = this.data;
- const n2 = this._toBBox;
- if (!p(t, i))
- return false;
- for (g.clear(); i; ) {
- for (let e = 0, s = i.children.length; e < s; e++) {
- const s2 = i.children[e], h2 = i.leaf ? n2(s2) : s2;
- if (p(t, h2)) {
- if (i.leaf || f(t, h2))
- return true;
- g.push(s2);
- }
- }
- i = g.pop();
- }
- return false;
- }
- load(t) {
- if (!t.length)
- return this;
- if (t.length < this._minEntries) {
- for (let i2 = 0, n2 = t.length; i2 < n2; i2++)
- this.insert(t[i2]);
- return this;
- }
- let i = this._build(t.slice(0, t.length), 0, t.length - 1, 0);
- if (this.data.children.length)
- if (this.data.height === i.height)
- this._splitRoot(this.data, i);
- else {
- if (this.data.height < i.height) {
- const t2 = this.data;
- this.data = i, i = t2;
- }
- this._insert(i, this.data.height - i.height - 1, true);
- }
- else
- this.data = i;
- return this;
- }
- insert(t) {
- return t && this._insert(t, this.data.height - 1), this;
- }
- clear() {
- return this.data = new b([]), this;
- }
- remove(i) {
- if (!i)
- return this;
- let e, s = this.data, h2 = null, a3 = 0, r2 = false;
- const o2 = this._toBBox(i);
- for (X.clear(), Y.clear(); s || X.length > 0; ) {
- if (s || (s = q(X.pop()), h2 = X.data[X.length - 1], a3 = Y.pop() ?? 0, r2 = true), s.leaf && (e = v(s.children, i, s.children.length, s.indexHint), e !== -1))
- return s.children.splice(e, 1), X.push(s), this._condense(X), this;
- r2 || s.leaf || !f(s, o2) ? h2 ? (a3++, s = h2.children[a3], r2 = false) : s = null : (X.push(s), Y.push(a3), a3 = 0, h2 = s, s = s.children[0]);
- }
- return this;
- }
- toJSON() {
- return this.data;
- }
- fromJSON(t) {
- return this.data = t, this;
- }
- _all(t, i) {
- let n2 = t;
- for (M.clear(); n2; ) {
- if (n2.leaf === true)
- for (const t2 of n2.children)
- i(t2);
- else
- M.pushArray(n2.children);
- n2 = M.pop() ?? null;
- }
- }
- _build(t, i, n2, e) {
- const s = n2 - i + 1;
- let h2 = this._maxEntries;
- if (s <= h2) {
- const e2 = new b(t.slice(i, n2 + 1));
- return a2(e2, this._toBBox), e2;
- }
- e || (e = Math.ceil(Math.log(s) / Math.log(h2)), h2 = Math.ceil(s / h2 ** (e - 1)));
- const r2 = new j([]);
- r2.height = e;
- const o2 = Math.ceil(s / h2), l2 = o2 * Math.ceil(Math.sqrt(h2));
- _(t, i, n2, l2, this.compareMinX);
- for (let a3 = i; a3 <= n2; a3 += l2) {
- const i2 = Math.min(a3 + l2 - 1, n2);
- _(t, a3, i2, o2, this.compareMinY);
- for (let n3 = a3; n3 <= i2; n3 += o2) {
- const s2 = Math.min(n3 + o2 - 1, i2);
- r2.children.push(this._build(t, n3, s2, e - 1));
- }
- }
- return a2(r2, this._toBBox), r2;
- }
- _chooseSubtree(t, i, n2, e) {
- for (; e.push(i), i.leaf !== true && e.length - 1 !== n2; ) {
- let n3, e2 = 1 / 0, s = 1 / 0;
- for (let h2 = 0, a3 = i.children.length; h2 < a3; h2++) {
- const a4 = i.children[h2], r2 = m(a4), o2 = u(t, a4) - r2;
- o2 < s ? (s = o2, e2 = r2 < e2 ? r2 : e2, n3 = a4) : o2 === s && r2 < e2 && (e2 = r2, n3 = a4);
- }
- i = n3 || i.children[0];
- }
- return i;
- }
- _insert(t, i, n2) {
- const e = this._toBBox, s = n2 ? t : e(t);
- X.clear();
- const h2 = this._chooseSubtree(s, this.data, i, X);
- for (h2.children.push(t), o(h2, s); i >= 0 && X.data[i].children.length > this._maxEntries; )
- this._split(X, i), i--;
- this._adjustParentBBoxes(s, X, i);
- }
- _split(t, i) {
- const n2 = t.data[i], e = n2.children.length, s = this._minEntries;
- this._chooseSplitAxis(n2, s, e);
- const h2 = this._chooseSplitIndex(n2, s, e);
- if (!h2)
- return void console.log(" Error: assertion failed at PooledRBush._split: no valid split index");
- const r2 = n2.children.splice(h2, n2.children.length - h2), o2 = n2.leaf ? new b(r2) : new j(r2);
- o2.height = n2.height, a2(n2, this._toBBox), a2(o2, this._toBBox), i ? t.data[i - 1].children.push(o2) : this._splitRoot(n2, o2);
- }
- _splitRoot(t, i) {
- this.data = new j([t, i]), this.data.height = t.height + 1, a2(this.data, this._toBBox);
- }
- _chooseSplitIndex(t, i, n2) {
- let e, s, h2;
- e = s = 1 / 0;
- for (let a3 = i; a3 <= n2 - i; a3++) {
- const i2 = r(t, 0, a3, this._toBBox), o2 = r(t, a3, n2, this._toBBox), l2 = x(i2, o2), c2 = m(i2) + m(o2);
- l2 < e ? (e = l2, h2 = a3, s = c2 < s ? c2 : s) : l2 === e && c2 < s && (s = c2, h2 = a3);
- }
- return h2;
- }
- _chooseSplitAxis(t, i, n2) {
- const e = t.leaf ? this.compareMinX : l, s = t.leaf ? this.compareMinY : c;
- this._allDistMargin(t, i, n2, e) < this._allDistMargin(t, i, n2, s) && t.children.sort(e);
- }
- _allDistMargin(t, i, n2, e) {
- t.children.sort(e);
- const s = this._toBBox, h2 = r(t, 0, i, s), a3 = r(t, n2 - i, n2, s);
- let l2 = d(h2) + d(a3);
- for (let r2 = i; r2 < n2 - i; r2++) {
- const i2 = t.children[r2];
- o(h2, t.leaf ? s(i2) : i2), l2 += d(h2);
- }
- for (let r2 = n2 - i - 1; r2 >= i; r2--) {
- const i2 = t.children[r2];
- o(a3, t.leaf ? s(i2) : i2), l2 += d(a3);
- }
- return l2;
- }
- _adjustParentBBoxes(t, i, n2) {
- for (let e = n2; e >= 0; e--)
- o(i.data[e], t);
- }
- _condense(i) {
- for (let n2 = i.length - 1; n2 >= 0; n2--) {
- const e = i.data[n2];
- if (e.children.length === 0)
- if (n2 > 0) {
- const s = i.data[n2 - 1], h2 = s.children;
- h2.splice(v(h2, e, h2.length, s.indexHint), 1);
- } else
- this.clear();
- else
- a2(e, this._toBBox);
- }
- }
- _initFormat(t) {
- const i = ["return a", " - b", ";"];
- this.compareMinX = new Function("a", "b", i.join(t[0])), this.compareMinY = new Function("a", "b", i.join(t[1])), this._toBBox = new Function("a", "return {minX: a" + t[0] + ", minY: a" + t[1] + ", maxX: a" + t[2] + ", maxY: a" + t[3] + "};");
- }
- };
- function a2(t, i) {
- r(t, 0, t.children.length, i, t);
- }
- function r(t, i, n2, e, s) {
- s || (s = new b([])), s.minX = 1 / 0, s.minY = 1 / 0, s.maxX = -1 / 0, s.maxY = -1 / 0;
- for (let h2, a3 = i; a3 < n2; a3++)
- h2 = t.children[a3], o(s, t.leaf ? e(h2) : h2);
- return s;
- }
- function o(t, i) {
- t.minX = Math.min(t.minX, i.minX), t.minY = Math.min(t.minY, i.minY), t.maxX = Math.max(t.maxX, i.maxX), t.maxY = Math.max(t.maxY, i.maxY);
- }
- function l(t, i) {
- return t.minX - i.minX;
- }
- function c(t, i) {
- return t.minY - i.minY;
- }
- function m(t) {
- return (t.maxX - t.minX) * (t.maxY - t.minY);
- }
- function d(t) {
- return t.maxX - t.minX + (t.maxY - t.minY);
- }
- function u(t, i) {
- return (Math.max(i.maxX, t.maxX) - Math.min(i.minX, t.minX)) * (Math.max(i.maxY, t.maxY) - Math.min(i.minY, t.minY));
- }
- function x(t, i) {
- const n2 = Math.max(t.minX, i.minX), e = Math.max(t.minY, i.minY), s = Math.min(t.maxX, i.maxX), h2 = Math.min(t.maxY, i.maxY);
- return Math.max(0, s - n2) * Math.max(0, h2 - e);
- }
- function f(t, i) {
- return t.minX <= i.minX && t.minY <= i.minY && i.maxX <= t.maxX && i.maxY <= t.maxY;
- }
- function p(t, i) {
- return i.minX <= t.maxX && i.minY <= t.maxY && i.maxX >= t.minX && i.maxY >= t.minY;
- }
- function _(t, i, e, h2, a3) {
- const r2 = [i, e];
- for (; r2.length; ) {
- const i2 = q(r2.pop()), e2 = q(r2.pop());
- if (i2 - e2 <= h2)
- continue;
- const o2 = e2 + Math.ceil((i2 - e2) / h2 / 2) * h2;
- a(t, o2, e2, i2, a3), r2.push(e2, o2, o2, i2);
- }
- }
- var g = new n();
- var M = new n();
- var X = new n();
- var Y = new n({ deallocator: void 0 });
- var B = class {
- constructor() {
- this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0;
- }
- };
- var w = class extends B {
- constructor() {
- super(...arguments), this.height = 1, this.indexHint = new y();
- }
- };
- var b = class extends w {
- constructor(t) {
- super(), this.children = t, this.leaf = true;
- }
- };
- var j = class extends w {
- constructor(t) {
- super(), this.children = t, this.leaf = false;
- }
- };
- export {
- h
- };
- //# sourceMappingURL=chunk-4GGRJYTB.js.map
|