@maplat/tin 0.11.3 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +30 -35
- package/README.md +30 -35
- package/dist/boundary-vertices.d.ts +27 -0
- package/dist/edgebound/base.d.ts +31 -0
- package/dist/edgebound/bitset.d.ts +58 -0
- package/dist/edgebound/constrain.d.ts +68 -0
- package/dist/edgebound/index.d.ts +4 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.html +19 -12
- package/dist/maplat_tin.cjs +5 -0
- package/dist/maplat_tin.js +3243 -0
- package/dist/maplat_tin.umd.js +5 -0
- package/dist/searchutils.d.ts +11 -2
- package/dist/strict-overlap.d.ts +5 -0
- package/dist/tin.d.ts +12 -18
- package/dist/weight-buffer.d.ts +11 -0
- package/package.json +40 -41
- package/src/boundary-vertices.ts +284 -0
- package/src/constrained-tin.ts +1 -1
- package/src/edgebound/base.ts +65 -0
- package/src/edgebound/bitset.ts +109 -0
- package/src/edgebound/constrain.license.txt +15 -0
- package/src/edgebound/constrain.ts +498 -0
- package/src/edgebound/index.ts +10 -0
- package/src/index.ts +1 -0
- package/src/kinks.ts +13 -16
- package/src/searchutils.ts +36 -2
- package/src/strict-overlap.ts +281 -0
- package/src/tin.ts +50 -382
- package/src/weight-buffer.ts +111 -0
- package/dist/tin.cjs +0 -3
- package/dist/tin.js +0 -2194
- package/dist/tin.umd.js +0 -3
|
@@ -0,0 +1,3243 @@
|
|
|
1
|
+
const Ct = 11102230246251565e-32, rt = 134217729, Xn = (3 + 8 * Ct) * Ct;
|
|
2
|
+
function Yt(o, t, e, n, r) {
|
|
3
|
+
let i, s, a, c, h = t[0], u = n[0], f = 0, d = 0;
|
|
4
|
+
u > h == u > -h ? (i = h, h = t[++f]) : (i = u, u = n[++d]);
|
|
5
|
+
let y = 0;
|
|
6
|
+
if (f < o && d < e)
|
|
7
|
+
for (u > h == u > -h ? (s = h + i, a = i - (s - h), h = t[++f]) : (s = u + i, a = i - (s - u), u = n[++d]), i = s, a !== 0 && (r[y++] = a); f < o && d < e; )
|
|
8
|
+
u > h == u > -h ? (s = i + h, c = s - i, a = i - (s - c) + (h - c), h = t[++f]) : (s = i + u, c = s - i, a = i - (s - c) + (u - c), u = n[++d]), i = s, a !== 0 && (r[y++] = a);
|
|
9
|
+
for (; f < o; )
|
|
10
|
+
s = i + h, c = s - i, a = i - (s - c) + (h - c), h = t[++f], i = s, a !== 0 && (r[y++] = a);
|
|
11
|
+
for (; d < e; )
|
|
12
|
+
s = i + u, c = s - i, a = i - (s - c) + (u - c), u = n[++d], i = s, a !== 0 && (r[y++] = a);
|
|
13
|
+
return (i !== 0 || y === 0) && (r[y++] = i), y;
|
|
14
|
+
}
|
|
15
|
+
function Ut(o, t, e, n, r, i, s, a) {
|
|
16
|
+
return Yt(Yt(o, t, e, n, s), s, r, i, a);
|
|
17
|
+
}
|
|
18
|
+
function U(o, t, e, n) {
|
|
19
|
+
let r, i, s, a, c, h, u, f, d, y, E;
|
|
20
|
+
u = rt * e, y = u - (u - e), E = e - y;
|
|
21
|
+
let k = t[0];
|
|
22
|
+
r = k * e, u = rt * k, f = u - (u - k), d = k - f, s = d * E - (r - f * y - d * y - f * E);
|
|
23
|
+
let X = 0;
|
|
24
|
+
s !== 0 && (n[X++] = s);
|
|
25
|
+
for (let C = 1; C < o; C++)
|
|
26
|
+
k = t[C], a = k * e, u = rt * k, f = u - (u - k), d = k - f, c = d * E - (a - f * y - d * y - f * E), i = r + c, h = i - r, s = r - (i - h) + (c - h), s !== 0 && (n[X++] = s), r = a + i, s = i - (r - a), s !== 0 && (n[X++] = s);
|
|
27
|
+
return (r !== 0 || X === 0) && (n[X++] = r), X;
|
|
28
|
+
}
|
|
29
|
+
function Yn(o, t) {
|
|
30
|
+
let e = t[0];
|
|
31
|
+
for (let n = 1; n < o; n++) e += t[n];
|
|
32
|
+
return e;
|
|
33
|
+
}
|
|
34
|
+
function vt(o) {
|
|
35
|
+
return new Float64Array(o);
|
|
36
|
+
}
|
|
37
|
+
const Jn = (3 + 16 * Ct) * Ct, Kn = (2 + 12 * Ct) * Ct, Gn = (9 + 64 * Ct) * Ct * Ct, me = vt(4), cn = vt(8), hn = vt(12), fn = vt(16), Ft = vt(4);
|
|
38
|
+
function Qn(o, t, e, n, r, i, s) {
|
|
39
|
+
let a, c, h, u, f, d, y, E, k, X, C, m, v, l, g, x, A, I;
|
|
40
|
+
const b = o - r, T = e - r, R = t - i, D = n - i;
|
|
41
|
+
l = b * D, d = rt * b, y = d - (d - b), E = b - y, d = rt * D, k = d - (d - D), X = D - k, g = E * X - (l - y * k - E * k - y * X), x = R * T, d = rt * R, y = d - (d - R), E = R - y, d = rt * T, k = d - (d - T), X = T - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, me[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, me[1] = v - (C + f) + (f - x), I = m + C, f = I - m, me[2] = m - (I - f) + (C - f), me[3] = I;
|
|
42
|
+
let Q = Yn(4, me), p = Kn * s;
|
|
43
|
+
if (Q >= p || -Q >= p || (f = o - b, a = o - (b + f) + (f - r), f = e - T, h = e - (T + f) + (f - r), f = t - R, c = t - (R + f) + (f - i), f = n - D, u = n - (D + f) + (f - i), a === 0 && c === 0 && h === 0 && u === 0) || (p = Gn * s + Xn * Math.abs(Q), Q += b * u + D * a - (R * h + T * c), Q >= p || -Q >= p)) return Q;
|
|
44
|
+
l = a * D, d = rt * a, y = d - (d - a), E = a - y, d = rt * D, k = d - (d - D), X = D - k, g = E * X - (l - y * k - E * k - y * X), x = c * T, d = rt * c, y = d - (d - c), E = c - y, d = rt * T, k = d - (d - T), X = T - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, Ft[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, Ft[1] = v - (C + f) + (f - x), I = m + C, f = I - m, Ft[2] = m - (I - f) + (C - f), Ft[3] = I;
|
|
45
|
+
const M = Yt(4, me, 4, Ft, cn);
|
|
46
|
+
l = b * u, d = rt * b, y = d - (d - b), E = b - y, d = rt * u, k = d - (d - u), X = u - k, g = E * X - (l - y * k - E * k - y * X), x = R * h, d = rt * R, y = d - (d - R), E = R - y, d = rt * h, k = d - (d - h), X = h - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, Ft[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, Ft[1] = v - (C + f) + (f - x), I = m + C, f = I - m, Ft[2] = m - (I - f) + (C - f), Ft[3] = I;
|
|
47
|
+
const _ = Yt(M, cn, 4, Ft, hn);
|
|
48
|
+
l = a * u, d = rt * a, y = d - (d - a), E = a - y, d = rt * u, k = d - (d - u), X = u - k, g = E * X - (l - y * k - E * k - y * X), x = c * h, d = rt * c, y = d - (d - c), E = c - y, d = rt * h, k = d - (d - h), X = h - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, Ft[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, Ft[1] = v - (C + f) + (f - x), I = m + C, f = I - m, Ft[2] = m - (I - f) + (C - f), Ft[3] = I;
|
|
49
|
+
const B = Yt(_, hn, 4, Ft, fn);
|
|
50
|
+
return fn[B - 1];
|
|
51
|
+
}
|
|
52
|
+
function te(o, t, e, n, r, i) {
|
|
53
|
+
const s = (t - i) * (e - r), a = (o - r) * (n - i), c = s - a, h = Math.abs(s + a);
|
|
54
|
+
return Math.abs(c) >= Jn * h ? c : -Qn(o, t, e, n, r, i, h);
|
|
55
|
+
}
|
|
56
|
+
const Hn = (10 + 96 * Ct) * Ct, Zn = (4 + 48 * Ct) * Ct, tr = (44 + 576 * Ct) * Ct * Ct, re = vt(4), ie = vt(4), se = vt(4), Qt = vt(4), Ht = vt(4), Zt = vt(4), Lt = vt(4), Dt = vt(4), Ve = vt(8), We = vt(8), Je = vt(8), Ke = vt(8), Ge = vt(8), Qe = vt(8), Ae = vt(8), Pe = vt(8), Be = vt(8), fe = vt(4), ue = vt(4), le = vt(4), ot = vt(8), pt = vt(16), kt = vt(16), St = vt(16), bt = vt(32), oe = vt(32), Ot = vt(48), $t = vt(64);
|
|
57
|
+
let ye = vt(1152), He = vt(1152);
|
|
58
|
+
function It(o, t, e) {
|
|
59
|
+
o = Yt(o, ye, t, e, He);
|
|
60
|
+
const n = ye;
|
|
61
|
+
return ye = He, He = n, o;
|
|
62
|
+
}
|
|
63
|
+
function er(o, t, e, n, r, i, s, a, c) {
|
|
64
|
+
let h, u, f, d, y, E, k, X, C, m, v, l, g, x, A, I, b, T, R, D, Q, p, M, _, B, N, Y, w, O, $, q, V, z, K, j;
|
|
65
|
+
const ct = o - s, ht = e - s, lt = r - s, dt = t - a, gt = n - a, mt = i - a;
|
|
66
|
+
q = ht * mt, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * mt, N = M - (M - mt), Y = mt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = lt * gt, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * gt, N = M - (M - gt), Y = gt - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, re[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, re[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, re[2] = O - (j - p) + (w - p), re[3] = j, q = lt * dt, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * dt, N = M - (M - dt), Y = dt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ct * mt, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * mt, N = M - (M - mt), Y = mt - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, ie[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, ie[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, ie[2] = O - (j - p) + (w - p), ie[3] = j, q = ct * gt, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * gt, N = M - (M - gt), Y = gt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ht * dt, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * dt, N = M - (M - dt), Y = dt - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, se[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, se[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, se[2] = O - (j - p) + (w - p), se[3] = j, h = Yt(
|
|
67
|
+
Yt(
|
|
68
|
+
Yt(
|
|
69
|
+
U(U(4, re, ct, ot), ot, ct, pt),
|
|
70
|
+
pt,
|
|
71
|
+
U(U(4, re, dt, ot), ot, dt, kt),
|
|
72
|
+
kt,
|
|
73
|
+
bt
|
|
74
|
+
),
|
|
75
|
+
bt,
|
|
76
|
+
Yt(
|
|
77
|
+
U(U(4, ie, ht, ot), ot, ht, pt),
|
|
78
|
+
pt,
|
|
79
|
+
U(U(4, ie, gt, ot), ot, gt, kt),
|
|
80
|
+
kt,
|
|
81
|
+
oe
|
|
82
|
+
),
|
|
83
|
+
oe,
|
|
84
|
+
$t
|
|
85
|
+
),
|
|
86
|
+
$t,
|
|
87
|
+
Yt(
|
|
88
|
+
U(U(4, se, lt, ot), ot, lt, pt),
|
|
89
|
+
pt,
|
|
90
|
+
U(U(4, se, mt, ot), ot, mt, kt),
|
|
91
|
+
kt,
|
|
92
|
+
bt
|
|
93
|
+
),
|
|
94
|
+
bt,
|
|
95
|
+
ye
|
|
96
|
+
);
|
|
97
|
+
let Pt = Yn(h, ye), Tt = Zn * c;
|
|
98
|
+
if (Pt >= Tt || -Pt >= Tt || (p = o - ct, u = o - (ct + p) + (p - s), p = t - dt, y = t - (dt + p) + (p - a), p = e - ht, f = e - (ht + p) + (p - s), p = n - gt, E = n - (gt + p) + (p - a), p = r - lt, d = r - (lt + p) + (p - s), p = i - mt, k = i - (mt + p) + (p - a), u === 0 && f === 0 && d === 0 && y === 0 && E === 0 && k === 0) || (Tt = tr * c + Xn * Math.abs(Pt), Pt += (ct * ct + dt * dt) * (ht * k + mt * f - (gt * d + lt * E)) + 2 * (ct * u + dt * y) * (ht * mt - gt * lt) + ((ht * ht + gt * gt) * (lt * y + dt * d - (mt * u + ct * k)) + 2 * (ht * f + gt * E) * (lt * dt - mt * ct)) + ((lt * lt + mt * mt) * (ct * E + gt * u - (dt * f + ht * y)) + 2 * (lt * d + mt * k) * (ct * gt - dt * ht)), Pt >= Tt || -Pt >= Tt))
|
|
99
|
+
return Pt;
|
|
100
|
+
if ((f !== 0 || E !== 0 || d !== 0 || k !== 0) && (q = ct * ct, M = rt * ct, _ = M - (M - ct), B = ct - _, V = B * B - (q - _ * _ - (_ + _) * B), z = dt * dt, M = rt * dt, _ = M - (M - dt), B = dt - _, K = B * B - (z - _ * _ - (_ + _) * B), w = V + K, p = w - V, Qt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Qt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Qt[2] = O - (j - p) + (w - p), Qt[3] = j), (d !== 0 || k !== 0 || u !== 0 || y !== 0) && (q = ht * ht, M = rt * ht, _ = M - (M - ht), B = ht - _, V = B * B - (q - _ * _ - (_ + _) * B), z = gt * gt, M = rt * gt, _ = M - (M - gt), B = gt - _, K = B * B - (z - _ * _ - (_ + _) * B), w = V + K, p = w - V, Ht[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Ht[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Ht[2] = O - (j - p) + (w - p), Ht[3] = j), (u !== 0 || y !== 0 || f !== 0 || E !== 0) && (q = lt * lt, M = rt * lt, _ = M - (M - lt), B = lt - _, V = B * B - (q - _ * _ - (_ + _) * B), z = mt * mt, M = rt * mt, _ = M - (M - mt), B = mt - _, K = B * B - (z - _ * _ - (_ + _) * B), w = V + K, p = w - V, Zt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Zt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Zt[2] = O - (j - p) + (w - p), Zt[3] = j), u !== 0 && (X = U(4, re, u, Ve), h = It(h, Ut(
|
|
101
|
+
U(X, Ve, 2 * ct, pt),
|
|
102
|
+
pt,
|
|
103
|
+
U(U(4, Zt, u, ot), ot, gt, kt),
|
|
104
|
+
kt,
|
|
105
|
+
U(U(4, Ht, u, ot), ot, -mt, St),
|
|
106
|
+
St,
|
|
107
|
+
bt,
|
|
108
|
+
Ot
|
|
109
|
+
), Ot)), y !== 0 && (C = U(4, re, y, We), h = It(h, Ut(
|
|
110
|
+
U(C, We, 2 * dt, pt),
|
|
111
|
+
pt,
|
|
112
|
+
U(U(4, Ht, y, ot), ot, lt, kt),
|
|
113
|
+
kt,
|
|
114
|
+
U(U(4, Zt, y, ot), ot, -ht, St),
|
|
115
|
+
St,
|
|
116
|
+
bt,
|
|
117
|
+
Ot
|
|
118
|
+
), Ot)), f !== 0 && (m = U(4, ie, f, Je), h = It(h, Ut(
|
|
119
|
+
U(m, Je, 2 * ht, pt),
|
|
120
|
+
pt,
|
|
121
|
+
U(U(4, Qt, f, ot), ot, mt, kt),
|
|
122
|
+
kt,
|
|
123
|
+
U(U(4, Zt, f, ot), ot, -dt, St),
|
|
124
|
+
St,
|
|
125
|
+
bt,
|
|
126
|
+
Ot
|
|
127
|
+
), Ot)), E !== 0 && (v = U(4, ie, E, Ke), h = It(h, Ut(
|
|
128
|
+
U(v, Ke, 2 * gt, pt),
|
|
129
|
+
pt,
|
|
130
|
+
U(U(4, Zt, E, ot), ot, ct, kt),
|
|
131
|
+
kt,
|
|
132
|
+
U(U(4, Qt, E, ot), ot, -lt, St),
|
|
133
|
+
St,
|
|
134
|
+
bt,
|
|
135
|
+
Ot
|
|
136
|
+
), Ot)), d !== 0 && (l = U(4, se, d, Ge), h = It(h, Ut(
|
|
137
|
+
U(l, Ge, 2 * lt, pt),
|
|
138
|
+
pt,
|
|
139
|
+
U(U(4, Ht, d, ot), ot, dt, kt),
|
|
140
|
+
kt,
|
|
141
|
+
U(U(4, Qt, d, ot), ot, -gt, St),
|
|
142
|
+
St,
|
|
143
|
+
bt,
|
|
144
|
+
Ot
|
|
145
|
+
), Ot)), k !== 0 && (g = U(4, se, k, Qe), h = It(h, Ut(
|
|
146
|
+
U(g, Qe, 2 * mt, pt),
|
|
147
|
+
pt,
|
|
148
|
+
U(U(4, Qt, k, ot), ot, ht, kt),
|
|
149
|
+
kt,
|
|
150
|
+
U(U(4, Ht, k, ot), ot, -ct, St),
|
|
151
|
+
St,
|
|
152
|
+
bt,
|
|
153
|
+
Ot
|
|
154
|
+
), Ot)), u !== 0 || y !== 0) {
|
|
155
|
+
if (f !== 0 || E !== 0 || d !== 0 || k !== 0 ? (q = f * mt, M = rt * f, _ = M - (M - f), B = f - _, M = rt * mt, N = M - (M - mt), Y = mt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ht * k, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * k, N = M - (M - k), Y = k - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Lt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Lt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Lt[2] = O - (j - p) + (w - p), Lt[3] = j, q = d * -gt, M = rt * d, _ = M - (M - d), B = d - _, M = rt * -gt, N = M - (M - -gt), Y = -gt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = lt * -E, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * -E, N = M - (M - -E), Y = -E - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Dt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Dt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Dt[2] = O - (j - p) + (w - p), Dt[3] = j, A = Yt(4, Lt, 4, Dt, Pe), q = f * k, M = rt * f, _ = M - (M - f), B = f - _, M = rt * k, N = M - (M - k), Y = k - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = d * E, M = rt * d, _ = M - (M - d), B = d - _, M = rt * E, N = M - (M - E), Y = E - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, ue[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, ue[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, ue[2] = O - (j - p) + (w - p), ue[3] = j, T = 4) : (Pe[0] = 0, A = 1, ue[0] = 0, T = 1), u !== 0) {
|
|
156
|
+
const xt = U(A, Pe, u, St);
|
|
157
|
+
h = It(h, Yt(
|
|
158
|
+
U(X, Ve, u, pt),
|
|
159
|
+
pt,
|
|
160
|
+
U(xt, St, 2 * ct, bt),
|
|
161
|
+
bt,
|
|
162
|
+
Ot
|
|
163
|
+
), Ot);
|
|
164
|
+
const Mt = U(T, ue, u, ot);
|
|
165
|
+
h = It(h, Ut(
|
|
166
|
+
U(Mt, ot, 2 * ct, pt),
|
|
167
|
+
pt,
|
|
168
|
+
U(Mt, ot, u, kt),
|
|
169
|
+
kt,
|
|
170
|
+
U(xt, St, u, bt),
|
|
171
|
+
bt,
|
|
172
|
+
oe,
|
|
173
|
+
$t
|
|
174
|
+
), $t), E !== 0 && (h = It(h, U(U(4, Zt, u, ot), ot, E, pt), pt)), k !== 0 && (h = It(h, U(U(4, Ht, -u, ot), ot, k, pt), pt));
|
|
175
|
+
}
|
|
176
|
+
if (y !== 0) {
|
|
177
|
+
const xt = U(A, Pe, y, St);
|
|
178
|
+
h = It(h, Yt(
|
|
179
|
+
U(C, We, y, pt),
|
|
180
|
+
pt,
|
|
181
|
+
U(xt, St, 2 * dt, bt),
|
|
182
|
+
bt,
|
|
183
|
+
Ot
|
|
184
|
+
), Ot);
|
|
185
|
+
const Mt = U(T, ue, y, ot);
|
|
186
|
+
h = It(h, Ut(
|
|
187
|
+
U(Mt, ot, 2 * dt, pt),
|
|
188
|
+
pt,
|
|
189
|
+
U(Mt, ot, y, kt),
|
|
190
|
+
kt,
|
|
191
|
+
U(xt, St, y, bt),
|
|
192
|
+
bt,
|
|
193
|
+
oe,
|
|
194
|
+
$t
|
|
195
|
+
), $t);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (f !== 0 || E !== 0) {
|
|
199
|
+
if (d !== 0 || k !== 0 || u !== 0 || y !== 0 ? (q = d * dt, M = rt * d, _ = M - (M - d), B = d - _, M = rt * dt, N = M - (M - dt), Y = dt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = lt * y, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * y, N = M - (M - y), Y = y - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Lt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Lt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Lt[2] = O - (j - p) + (w - p), Lt[3] = j, D = -mt, Q = -k, q = u * D, M = rt * u, _ = M - (M - u), B = u - _, M = rt * D, N = M - (M - D), Y = D - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ct * Q, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * Q, N = M - (M - Q), Y = Q - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Dt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Dt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Dt[2] = O - (j - p) + (w - p), Dt[3] = j, I = Yt(4, Lt, 4, Dt, Be), q = d * y, M = rt * d, _ = M - (M - d), B = d - _, M = rt * y, N = M - (M - y), Y = y - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = u * k, M = rt * u, _ = M - (M - u), B = u - _, M = rt * k, N = M - (M - k), Y = k - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, le[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, le[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, le[2] = O - (j - p) + (w - p), le[3] = j, R = 4) : (Be[0] = 0, I = 1, le[0] = 0, R = 1), f !== 0) {
|
|
200
|
+
const xt = U(I, Be, f, St);
|
|
201
|
+
h = It(h, Yt(
|
|
202
|
+
U(m, Je, f, pt),
|
|
203
|
+
pt,
|
|
204
|
+
U(xt, St, 2 * ht, bt),
|
|
205
|
+
bt,
|
|
206
|
+
Ot
|
|
207
|
+
), Ot);
|
|
208
|
+
const Mt = U(R, le, f, ot);
|
|
209
|
+
h = It(h, Ut(
|
|
210
|
+
U(Mt, ot, 2 * ht, pt),
|
|
211
|
+
pt,
|
|
212
|
+
U(Mt, ot, f, kt),
|
|
213
|
+
kt,
|
|
214
|
+
U(xt, St, f, bt),
|
|
215
|
+
bt,
|
|
216
|
+
oe,
|
|
217
|
+
$t
|
|
218
|
+
), $t), k !== 0 && (h = It(h, U(U(4, Qt, f, ot), ot, k, pt), pt)), y !== 0 && (h = It(h, U(U(4, Zt, -f, ot), ot, y, pt), pt));
|
|
219
|
+
}
|
|
220
|
+
if (E !== 0) {
|
|
221
|
+
const xt = U(I, Be, E, St);
|
|
222
|
+
h = It(h, Yt(
|
|
223
|
+
U(v, Ke, E, pt),
|
|
224
|
+
pt,
|
|
225
|
+
U(xt, St, 2 * gt, bt),
|
|
226
|
+
bt,
|
|
227
|
+
Ot
|
|
228
|
+
), Ot);
|
|
229
|
+
const Mt = U(R, le, E, ot);
|
|
230
|
+
h = It(h, Ut(
|
|
231
|
+
U(Mt, ot, 2 * gt, pt),
|
|
232
|
+
pt,
|
|
233
|
+
U(Mt, ot, E, kt),
|
|
234
|
+
kt,
|
|
235
|
+
U(xt, St, E, bt),
|
|
236
|
+
bt,
|
|
237
|
+
oe,
|
|
238
|
+
$t
|
|
239
|
+
), $t);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (d !== 0 || k !== 0) {
|
|
243
|
+
if (u !== 0 || y !== 0 || f !== 0 || E !== 0 ? (q = u * gt, M = rt * u, _ = M - (M - u), B = u - _, M = rt * gt, N = M - (M - gt), Y = gt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ct * E, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * E, N = M - (M - E), Y = E - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Lt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Lt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Lt[2] = O - (j - p) + (w - p), Lt[3] = j, D = -dt, Q = -y, q = f * D, M = rt * f, _ = M - (M - f), B = f - _, M = rt * D, N = M - (M - D), Y = D - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ht * Q, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * Q, N = M - (M - Q), Y = Q - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Dt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Dt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Dt[2] = O - (j - p) + (w - p), Dt[3] = j, x = Yt(4, Lt, 4, Dt, Ae), q = u * E, M = rt * u, _ = M - (M - u), B = u - _, M = rt * E, N = M - (M - E), Y = E - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = f * y, M = rt * f, _ = M - (M - f), B = f - _, M = rt * y, N = M - (M - y), Y = y - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, fe[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, fe[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, fe[2] = O - (j - p) + (w - p), fe[3] = j, b = 4) : (Ae[0] = 0, x = 1, fe[0] = 0, b = 1), d !== 0) {
|
|
244
|
+
const xt = U(x, Ae, d, St);
|
|
245
|
+
h = It(h, Yt(
|
|
246
|
+
U(l, Ge, d, pt),
|
|
247
|
+
pt,
|
|
248
|
+
U(xt, St, 2 * lt, bt),
|
|
249
|
+
bt,
|
|
250
|
+
Ot
|
|
251
|
+
), Ot);
|
|
252
|
+
const Mt = U(b, fe, d, ot);
|
|
253
|
+
h = It(h, Ut(
|
|
254
|
+
U(Mt, ot, 2 * lt, pt),
|
|
255
|
+
pt,
|
|
256
|
+
U(Mt, ot, d, kt),
|
|
257
|
+
kt,
|
|
258
|
+
U(xt, St, d, bt),
|
|
259
|
+
bt,
|
|
260
|
+
oe,
|
|
261
|
+
$t
|
|
262
|
+
), $t), y !== 0 && (h = It(h, U(U(4, Ht, d, ot), ot, y, pt), pt)), E !== 0 && (h = It(h, U(U(4, Qt, -d, ot), ot, E, pt), pt));
|
|
263
|
+
}
|
|
264
|
+
if (k !== 0) {
|
|
265
|
+
const xt = U(x, Ae, k, St);
|
|
266
|
+
h = It(h, Yt(
|
|
267
|
+
U(g, Qe, k, pt),
|
|
268
|
+
pt,
|
|
269
|
+
U(xt, St, 2 * mt, bt),
|
|
270
|
+
bt,
|
|
271
|
+
Ot
|
|
272
|
+
), Ot);
|
|
273
|
+
const Mt = U(b, fe, k, ot);
|
|
274
|
+
h = It(h, Ut(
|
|
275
|
+
U(Mt, ot, 2 * mt, pt),
|
|
276
|
+
pt,
|
|
277
|
+
U(Mt, ot, k, kt),
|
|
278
|
+
kt,
|
|
279
|
+
U(xt, St, k, bt),
|
|
280
|
+
bt,
|
|
281
|
+
oe,
|
|
282
|
+
$t
|
|
283
|
+
), $t);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return ye[h - 1];
|
|
287
|
+
}
|
|
288
|
+
function nr(o, t, e, n, r, i, s, a) {
|
|
289
|
+
const c = o - s, h = e - s, u = r - s, f = t - a, d = n - a, y = i - a, E = h * y, k = u * d, X = c * c + f * f, C = u * f, m = c * y, v = h * h + d * d, l = c * d, g = h * f, x = u * u + y * y, A = X * (E - k) + v * (C - m) + x * (l - g), I = (Math.abs(E) + Math.abs(k)) * X + (Math.abs(C) + Math.abs(m)) * v + (Math.abs(l) + Math.abs(g)) * x, b = Hn * I;
|
|
290
|
+
return A > b || -A > b ? A : er(o, t, e, n, r, i, s, a, I);
|
|
291
|
+
}
|
|
292
|
+
function rr(o, t) {
|
|
293
|
+
var e, n, r = 0, i, s, a, c, h, u, f, d = o[0], y = o[1], E = t.length;
|
|
294
|
+
for (e = 0; e < E; e++) {
|
|
295
|
+
n = 0;
|
|
296
|
+
var k = t[e], X = k.length - 1;
|
|
297
|
+
if (u = k[0], u[0] !== k[X][0] && u[1] !== k[X][1])
|
|
298
|
+
throw new Error("First and last coordinates in a ring must be the same");
|
|
299
|
+
for (s = u[0] - d, a = u[1] - y, n; n < X; n++) {
|
|
300
|
+
if (f = k[n + 1], c = f[0] - d, h = f[1] - y, a === 0 && h === 0) {
|
|
301
|
+
if (c <= 0 && s >= 0 || s <= 0 && c >= 0)
|
|
302
|
+
return 0;
|
|
303
|
+
} else if (h >= 0 && a <= 0 || h <= 0 && a >= 0) {
|
|
304
|
+
if (i = te(s, c, a, h, 0, 0), i === 0)
|
|
305
|
+
return 0;
|
|
306
|
+
(i > 0 && h > 0 && a <= 0 || i < 0 && h <= 0 && a > 0) && r++;
|
|
307
|
+
}
|
|
308
|
+
u = f, a = h, s = c;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return r % 2 !== 0;
|
|
312
|
+
}
|
|
313
|
+
function Se(o, t, e = {}) {
|
|
314
|
+
const n = { type: "Feature" };
|
|
315
|
+
return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = o, n;
|
|
316
|
+
}
|
|
317
|
+
function de(o, t, e = {}) {
|
|
318
|
+
if (!o)
|
|
319
|
+
throw new Error("coordinates is required");
|
|
320
|
+
if (!Array.isArray(o))
|
|
321
|
+
throw new Error("coordinates must be an Array");
|
|
322
|
+
if (o.length < 2)
|
|
323
|
+
throw new Error("coordinates must be at least 2 numbers long");
|
|
324
|
+
if (!ln(o[0]) || !ln(o[1]))
|
|
325
|
+
throw new Error("coordinates must contain numbers");
|
|
326
|
+
return Se({
|
|
327
|
+
type: "Point",
|
|
328
|
+
coordinates: o
|
|
329
|
+
}, t, e);
|
|
330
|
+
}
|
|
331
|
+
function Ee(o, t, e = {}) {
|
|
332
|
+
for (const r of o) {
|
|
333
|
+
if (r.length < 4)
|
|
334
|
+
throw new Error(
|
|
335
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
336
|
+
);
|
|
337
|
+
if (r[r.length - 1].length !== r[0].length)
|
|
338
|
+
throw new Error("First and last Position are not equivalent.");
|
|
339
|
+
for (let i = 0; i < r[r.length - 1].length; i++)
|
|
340
|
+
if (r[r.length - 1][i] !== r[0][i])
|
|
341
|
+
throw new Error("First and last Position are not equivalent.");
|
|
342
|
+
}
|
|
343
|
+
return Se({
|
|
344
|
+
type: "Polygon",
|
|
345
|
+
coordinates: o
|
|
346
|
+
}, t, e);
|
|
347
|
+
}
|
|
348
|
+
function un(o, t, e = {}) {
|
|
349
|
+
if (o.length < 2)
|
|
350
|
+
throw new Error("coordinates must be an array of two or more positions");
|
|
351
|
+
return Se({
|
|
352
|
+
type: "LineString",
|
|
353
|
+
coordinates: o
|
|
354
|
+
}, t, e);
|
|
355
|
+
}
|
|
356
|
+
function Kt(o, t = {}) {
|
|
357
|
+
const e = { type: "FeatureCollection" };
|
|
358
|
+
return t.id && (e.id = t.id), t.bbox && (e.bbox = t.bbox), e.features = o, e;
|
|
359
|
+
}
|
|
360
|
+
function ln(o) {
|
|
361
|
+
return !isNaN(o) && o !== null && !Array.isArray(o);
|
|
362
|
+
}
|
|
363
|
+
function ir(o) {
|
|
364
|
+
if (!o)
|
|
365
|
+
throw new Error("coord is required");
|
|
366
|
+
if (!Array.isArray(o)) {
|
|
367
|
+
if (o.type === "Feature" && o.geometry !== null && o.geometry.type === "Point")
|
|
368
|
+
return [...o.geometry.coordinates];
|
|
369
|
+
if (o.type === "Point")
|
|
370
|
+
return [...o.coordinates];
|
|
371
|
+
}
|
|
372
|
+
if (Array.isArray(o) && o.length >= 2 && !Array.isArray(o[0]) && !Array.isArray(o[1]))
|
|
373
|
+
return [...o];
|
|
374
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
375
|
+
}
|
|
376
|
+
function sr(o) {
|
|
377
|
+
return o.type === "Feature" ? o.geometry : o;
|
|
378
|
+
}
|
|
379
|
+
function or(o, t, e = {}) {
|
|
380
|
+
if (!o)
|
|
381
|
+
throw new Error("point is required");
|
|
382
|
+
if (!t)
|
|
383
|
+
throw new Error("polygon is required");
|
|
384
|
+
const n = ir(o), r = sr(t), i = r.type, s = t.bbox;
|
|
385
|
+
let a = r.coordinates;
|
|
386
|
+
if (s && ar(n, s) === !1)
|
|
387
|
+
return !1;
|
|
388
|
+
i === "Polygon" && (a = [a]);
|
|
389
|
+
let c = !1;
|
|
390
|
+
for (var h = 0; h < a.length; ++h) {
|
|
391
|
+
const u = rr(n, a[h]);
|
|
392
|
+
if (u === 0) return !e.ignoreBoundary;
|
|
393
|
+
u && (c = !0);
|
|
394
|
+
}
|
|
395
|
+
return c;
|
|
396
|
+
}
|
|
397
|
+
function ar(o, t) {
|
|
398
|
+
return t[0] <= o[0] && t[1] <= o[1] && t[2] >= o[0] && t[3] >= o[1];
|
|
399
|
+
}
|
|
400
|
+
var cr = or;
|
|
401
|
+
function rn(o, t, e) {
|
|
402
|
+
if (o !== null)
|
|
403
|
+
for (var n, r, i, s, a, c, h, u = 0, f = 0, d, y = o.type, E = y === "FeatureCollection", k = y === "Feature", X = E ? o.features.length : 1, C = 0; C < X; C++) {
|
|
404
|
+
h = E ? o.features[C].geometry : k ? o.geometry : o, d = h ? h.type === "GeometryCollection" : !1, a = d ? h.geometries.length : 1;
|
|
405
|
+
for (var m = 0; m < a; m++) {
|
|
406
|
+
var v = 0, l = 0;
|
|
407
|
+
if (s = d ? h.geometries[m] : h, s !== null) {
|
|
408
|
+
c = s.coordinates;
|
|
409
|
+
var g = s.type;
|
|
410
|
+
switch (u = e && (g === "Polygon" || g === "MultiPolygon") ? 1 : 0, g) {
|
|
411
|
+
case null:
|
|
412
|
+
break;
|
|
413
|
+
case "Point":
|
|
414
|
+
if (t(
|
|
415
|
+
c,
|
|
416
|
+
f,
|
|
417
|
+
C,
|
|
418
|
+
v,
|
|
419
|
+
l
|
|
420
|
+
) === !1)
|
|
421
|
+
return !1;
|
|
422
|
+
f++, v++;
|
|
423
|
+
break;
|
|
424
|
+
case "LineString":
|
|
425
|
+
case "MultiPoint":
|
|
426
|
+
for (n = 0; n < c.length; n++) {
|
|
427
|
+
if (t(
|
|
428
|
+
c[n],
|
|
429
|
+
f,
|
|
430
|
+
C,
|
|
431
|
+
v,
|
|
432
|
+
l
|
|
433
|
+
) === !1)
|
|
434
|
+
return !1;
|
|
435
|
+
f++, g === "MultiPoint" && v++;
|
|
436
|
+
}
|
|
437
|
+
g === "LineString" && v++;
|
|
438
|
+
break;
|
|
439
|
+
case "Polygon":
|
|
440
|
+
case "MultiLineString":
|
|
441
|
+
for (n = 0; n < c.length; n++) {
|
|
442
|
+
for (r = 0; r < c[n].length - u; r++) {
|
|
443
|
+
if (t(
|
|
444
|
+
c[n][r],
|
|
445
|
+
f,
|
|
446
|
+
C,
|
|
447
|
+
v,
|
|
448
|
+
l
|
|
449
|
+
) === !1)
|
|
450
|
+
return !1;
|
|
451
|
+
f++;
|
|
452
|
+
}
|
|
453
|
+
g === "MultiLineString" && v++, g === "Polygon" && l++;
|
|
454
|
+
}
|
|
455
|
+
g === "Polygon" && v++;
|
|
456
|
+
break;
|
|
457
|
+
case "MultiPolygon":
|
|
458
|
+
for (n = 0; n < c.length; n++) {
|
|
459
|
+
for (l = 0, r = 0; r < c[n].length; r++) {
|
|
460
|
+
for (i = 0; i < c[n][r].length - u; i++) {
|
|
461
|
+
if (t(
|
|
462
|
+
c[n][r][i],
|
|
463
|
+
f,
|
|
464
|
+
C,
|
|
465
|
+
v,
|
|
466
|
+
l
|
|
467
|
+
) === !1)
|
|
468
|
+
return !1;
|
|
469
|
+
f++;
|
|
470
|
+
}
|
|
471
|
+
l++;
|
|
472
|
+
}
|
|
473
|
+
v++;
|
|
474
|
+
}
|
|
475
|
+
break;
|
|
476
|
+
case "GeometryCollection":
|
|
477
|
+
for (n = 0; n < s.geometries.length; n++)
|
|
478
|
+
if (rn(s.geometries[n], t, e) === !1)
|
|
479
|
+
return !1;
|
|
480
|
+
break;
|
|
481
|
+
default:
|
|
482
|
+
throw new Error("Unknown Geometry Type");
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function hr(o, t = {}) {
|
|
489
|
+
let e = 0, n = 0, r = 0;
|
|
490
|
+
return rn(
|
|
491
|
+
o,
|
|
492
|
+
function(i) {
|
|
493
|
+
e += i[0], n += i[1], r++;
|
|
494
|
+
},
|
|
495
|
+
!0
|
|
496
|
+
), de([e / r, n / r], t.properties);
|
|
497
|
+
}
|
|
498
|
+
var fr = hr;
|
|
499
|
+
function ur(o) {
|
|
500
|
+
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
501
|
+
}
|
|
502
|
+
function lr(o) {
|
|
503
|
+
if (Object.prototype.hasOwnProperty.call(o, "__esModule")) return o;
|
|
504
|
+
var t = o.default;
|
|
505
|
+
if (typeof t == "function") {
|
|
506
|
+
var e = function n() {
|
|
507
|
+
var r = !1;
|
|
508
|
+
try {
|
|
509
|
+
r = this instanceof n;
|
|
510
|
+
} catch {
|
|
511
|
+
}
|
|
512
|
+
return r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
|
|
513
|
+
};
|
|
514
|
+
e.prototype = t.prototype;
|
|
515
|
+
} else e = {};
|
|
516
|
+
return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(o).forEach(function(n) {
|
|
517
|
+
var r = Object.getOwnPropertyDescriptor(o, n);
|
|
518
|
+
Object.defineProperty(e, n, r.get ? r : {
|
|
519
|
+
enumerable: !0,
|
|
520
|
+
get: function() {
|
|
521
|
+
return o[n];
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}), e;
|
|
525
|
+
}
|
|
526
|
+
var Oe = { exports: {} }, $e = { exports: {} }, pr = $e.exports, pn;
|
|
527
|
+
function dr() {
|
|
528
|
+
return pn || (pn = 1, (function(o, t) {
|
|
529
|
+
(function(e, n) {
|
|
530
|
+
o.exports = n();
|
|
531
|
+
})(pr, function() {
|
|
532
|
+
function e(m, v, l, g, x) {
|
|
533
|
+
(function A(I, b, T, R, D) {
|
|
534
|
+
for (; R > T; ) {
|
|
535
|
+
if (R - T > 600) {
|
|
536
|
+
var Q = R - T + 1, p = b - T + 1, M = Math.log(Q), _ = 0.5 * Math.exp(2 * M / 3), B = 0.5 * Math.sqrt(M * _ * (Q - _) / Q) * (p - Q / 2 < 0 ? -1 : 1), N = Math.max(T, Math.floor(b - p * _ / Q + B)), Y = Math.min(R, Math.floor(b + (Q - p) * _ / Q + B));
|
|
537
|
+
A(I, b, N, Y, D);
|
|
538
|
+
}
|
|
539
|
+
var w = I[b], O = T, $ = R;
|
|
540
|
+
for (n(I, T, b), D(I[R], w) > 0 && n(I, T, R); O < $; ) {
|
|
541
|
+
for (n(I, O, $), O++, $--; D(I[O], w) < 0; ) O++;
|
|
542
|
+
for (; D(I[$], w) > 0; ) $--;
|
|
543
|
+
}
|
|
544
|
+
D(I[T], w) === 0 ? n(I, T, $) : n(I, ++$, R), $ <= b && (T = $ + 1), b <= $ && (R = $ - 1);
|
|
545
|
+
}
|
|
546
|
+
})(m, v, l || 0, g || m.length - 1, x || r);
|
|
547
|
+
}
|
|
548
|
+
function n(m, v, l) {
|
|
549
|
+
var g = m[v];
|
|
550
|
+
m[v] = m[l], m[l] = g;
|
|
551
|
+
}
|
|
552
|
+
function r(m, v) {
|
|
553
|
+
return m < v ? -1 : m > v ? 1 : 0;
|
|
554
|
+
}
|
|
555
|
+
var i = function(m) {
|
|
556
|
+
m === void 0 && (m = 9), this._maxEntries = Math.max(4, m), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
557
|
+
};
|
|
558
|
+
function s(m, v, l) {
|
|
559
|
+
if (!l) return v.indexOf(m);
|
|
560
|
+
for (var g = 0; g < v.length; g++) if (l(m, v[g])) return g;
|
|
561
|
+
return -1;
|
|
562
|
+
}
|
|
563
|
+
function a(m, v) {
|
|
564
|
+
c(m, 0, m.children.length, v, m);
|
|
565
|
+
}
|
|
566
|
+
function c(m, v, l, g, x) {
|
|
567
|
+
x || (x = X(null)), x.minX = 1 / 0, x.minY = 1 / 0, x.maxX = -1 / 0, x.maxY = -1 / 0;
|
|
568
|
+
for (var A = v; A < l; A++) {
|
|
569
|
+
var I = m.children[A];
|
|
570
|
+
h(x, m.leaf ? g(I) : I);
|
|
571
|
+
}
|
|
572
|
+
return x;
|
|
573
|
+
}
|
|
574
|
+
function h(m, v) {
|
|
575
|
+
return m.minX = Math.min(m.minX, v.minX), m.minY = Math.min(m.minY, v.minY), m.maxX = Math.max(m.maxX, v.maxX), m.maxY = Math.max(m.maxY, v.maxY), m;
|
|
576
|
+
}
|
|
577
|
+
function u(m, v) {
|
|
578
|
+
return m.minX - v.minX;
|
|
579
|
+
}
|
|
580
|
+
function f(m, v) {
|
|
581
|
+
return m.minY - v.minY;
|
|
582
|
+
}
|
|
583
|
+
function d(m) {
|
|
584
|
+
return (m.maxX - m.minX) * (m.maxY - m.minY);
|
|
585
|
+
}
|
|
586
|
+
function y(m) {
|
|
587
|
+
return m.maxX - m.minX + (m.maxY - m.minY);
|
|
588
|
+
}
|
|
589
|
+
function E(m, v) {
|
|
590
|
+
return m.minX <= v.minX && m.minY <= v.minY && v.maxX <= m.maxX && v.maxY <= m.maxY;
|
|
591
|
+
}
|
|
592
|
+
function k(m, v) {
|
|
593
|
+
return v.minX <= m.maxX && v.minY <= m.maxY && v.maxX >= m.minX && v.maxY >= m.minY;
|
|
594
|
+
}
|
|
595
|
+
function X(m) {
|
|
596
|
+
return { children: m, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
597
|
+
}
|
|
598
|
+
function C(m, v, l, g, x) {
|
|
599
|
+
for (var A = [v, l]; A.length; ) if (!((l = A.pop()) - (v = A.pop()) <= g)) {
|
|
600
|
+
var I = v + Math.ceil((l - v) / g / 2) * g;
|
|
601
|
+
e(m, I, v, l, x), A.push(v, I, I, l);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
return i.prototype.all = function() {
|
|
605
|
+
return this._all(this.data, []);
|
|
606
|
+
}, i.prototype.search = function(m) {
|
|
607
|
+
var v = this.data, l = [];
|
|
608
|
+
if (!k(m, v)) return l;
|
|
609
|
+
for (var g = this.toBBox, x = []; v; ) {
|
|
610
|
+
for (var A = 0; A < v.children.length; A++) {
|
|
611
|
+
var I = v.children[A], b = v.leaf ? g(I) : I;
|
|
612
|
+
k(m, b) && (v.leaf ? l.push(I) : E(m, b) ? this._all(I, l) : x.push(I));
|
|
613
|
+
}
|
|
614
|
+
v = x.pop();
|
|
615
|
+
}
|
|
616
|
+
return l;
|
|
617
|
+
}, i.prototype.collides = function(m) {
|
|
618
|
+
var v = this.data;
|
|
619
|
+
if (!k(m, v)) return !1;
|
|
620
|
+
for (var l = []; v; ) {
|
|
621
|
+
for (var g = 0; g < v.children.length; g++) {
|
|
622
|
+
var x = v.children[g], A = v.leaf ? this.toBBox(x) : x;
|
|
623
|
+
if (k(m, A)) {
|
|
624
|
+
if (v.leaf || E(m, A)) return !0;
|
|
625
|
+
l.push(x);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
v = l.pop();
|
|
629
|
+
}
|
|
630
|
+
return !1;
|
|
631
|
+
}, i.prototype.load = function(m) {
|
|
632
|
+
if (!m || !m.length) return this;
|
|
633
|
+
if (m.length < this._minEntries) {
|
|
634
|
+
for (var v = 0; v < m.length; v++) this.insert(m[v]);
|
|
635
|
+
return this;
|
|
636
|
+
}
|
|
637
|
+
var l = this._build(m.slice(), 0, m.length - 1, 0);
|
|
638
|
+
if (this.data.children.length) if (this.data.height === l.height) this._splitRoot(this.data, l);
|
|
639
|
+
else {
|
|
640
|
+
if (this.data.height < l.height) {
|
|
641
|
+
var g = this.data;
|
|
642
|
+
this.data = l, l = g;
|
|
643
|
+
}
|
|
644
|
+
this._insert(l, this.data.height - l.height - 1, !0);
|
|
645
|
+
}
|
|
646
|
+
else this.data = l;
|
|
647
|
+
return this;
|
|
648
|
+
}, i.prototype.insert = function(m) {
|
|
649
|
+
return m && this._insert(m, this.data.height - 1), this;
|
|
650
|
+
}, i.prototype.clear = function() {
|
|
651
|
+
return this.data = X([]), this;
|
|
652
|
+
}, i.prototype.remove = function(m, v) {
|
|
653
|
+
if (!m) return this;
|
|
654
|
+
for (var l, g, x, A = this.data, I = this.toBBox(m), b = [], T = []; A || b.length; ) {
|
|
655
|
+
if (A || (A = b.pop(), g = b[b.length - 1], l = T.pop(), x = !0), A.leaf) {
|
|
656
|
+
var R = s(m, A.children, v);
|
|
657
|
+
if (R !== -1) return A.children.splice(R, 1), b.push(A), this._condense(b), this;
|
|
658
|
+
}
|
|
659
|
+
x || A.leaf || !E(A, I) ? g ? (l++, A = g.children[l], x = !1) : A = null : (b.push(A), T.push(l), l = 0, g = A, A = A.children[0]);
|
|
660
|
+
}
|
|
661
|
+
return this;
|
|
662
|
+
}, i.prototype.toBBox = function(m) {
|
|
663
|
+
return m;
|
|
664
|
+
}, i.prototype.compareMinX = function(m, v) {
|
|
665
|
+
return m.minX - v.minX;
|
|
666
|
+
}, i.prototype.compareMinY = function(m, v) {
|
|
667
|
+
return m.minY - v.minY;
|
|
668
|
+
}, i.prototype.toJSON = function() {
|
|
669
|
+
return this.data;
|
|
670
|
+
}, i.prototype.fromJSON = function(m) {
|
|
671
|
+
return this.data = m, this;
|
|
672
|
+
}, i.prototype._all = function(m, v) {
|
|
673
|
+
for (var l = []; m; ) m.leaf ? v.push.apply(v, m.children) : l.push.apply(l, m.children), m = l.pop();
|
|
674
|
+
return v;
|
|
675
|
+
}, i.prototype._build = function(m, v, l, g) {
|
|
676
|
+
var x, A = l - v + 1, I = this._maxEntries;
|
|
677
|
+
if (A <= I) return a(x = X(m.slice(v, l + 1)), this.toBBox), x;
|
|
678
|
+
g || (g = Math.ceil(Math.log(A) / Math.log(I)), I = Math.ceil(A / Math.pow(I, g - 1))), (x = X([])).leaf = !1, x.height = g;
|
|
679
|
+
var b = Math.ceil(A / I), T = b * Math.ceil(Math.sqrt(I));
|
|
680
|
+
C(m, v, l, T, this.compareMinX);
|
|
681
|
+
for (var R = v; R <= l; R += T) {
|
|
682
|
+
var D = Math.min(R + T - 1, l);
|
|
683
|
+
C(m, R, D, b, this.compareMinY);
|
|
684
|
+
for (var Q = R; Q <= D; Q += b) {
|
|
685
|
+
var p = Math.min(Q + b - 1, D);
|
|
686
|
+
x.children.push(this._build(m, Q, p, g - 1));
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return a(x, this.toBBox), x;
|
|
690
|
+
}, i.prototype._chooseSubtree = function(m, v, l, g) {
|
|
691
|
+
for (; g.push(v), !v.leaf && g.length - 1 !== l; ) {
|
|
692
|
+
for (var x = 1 / 0, A = 1 / 0, I = void 0, b = 0; b < v.children.length; b++) {
|
|
693
|
+
var T = v.children[b], R = d(T), D = (Q = m, p = T, (Math.max(p.maxX, Q.maxX) - Math.min(p.minX, Q.minX)) * (Math.max(p.maxY, Q.maxY) - Math.min(p.minY, Q.minY)) - R);
|
|
694
|
+
D < A ? (A = D, x = R < x ? R : x, I = T) : D === A && R < x && (x = R, I = T);
|
|
695
|
+
}
|
|
696
|
+
v = I || v.children[0];
|
|
697
|
+
}
|
|
698
|
+
var Q, p;
|
|
699
|
+
return v;
|
|
700
|
+
}, i.prototype._insert = function(m, v, l) {
|
|
701
|
+
var g = l ? m : this.toBBox(m), x = [], A = this._chooseSubtree(g, this.data, v, x);
|
|
702
|
+
for (A.children.push(m), h(A, g); v >= 0 && x[v].children.length > this._maxEntries; ) this._split(x, v), v--;
|
|
703
|
+
this._adjustParentBBoxes(g, x, v);
|
|
704
|
+
}, i.prototype._split = function(m, v) {
|
|
705
|
+
var l = m[v], g = l.children.length, x = this._minEntries;
|
|
706
|
+
this._chooseSplitAxis(l, x, g);
|
|
707
|
+
var A = this._chooseSplitIndex(l, x, g), I = X(l.children.splice(A, l.children.length - A));
|
|
708
|
+
I.height = l.height, I.leaf = l.leaf, a(l, this.toBBox), a(I, this.toBBox), v ? m[v - 1].children.push(I) : this._splitRoot(l, I);
|
|
709
|
+
}, i.prototype._splitRoot = function(m, v) {
|
|
710
|
+
this.data = X([m, v]), this.data.height = m.height + 1, this.data.leaf = !1, a(this.data, this.toBBox);
|
|
711
|
+
}, i.prototype._chooseSplitIndex = function(m, v, l) {
|
|
712
|
+
for (var g, x, A, I, b, T, R, D = 1 / 0, Q = 1 / 0, p = v; p <= l - v; p++) {
|
|
713
|
+
var M = c(m, 0, p, this.toBBox), _ = c(m, p, l, this.toBBox), B = (x = M, A = _, I = void 0, b = void 0, T = void 0, R = void 0, I = Math.max(x.minX, A.minX), b = Math.max(x.minY, A.minY), T = Math.min(x.maxX, A.maxX), R = Math.min(x.maxY, A.maxY), Math.max(0, T - I) * Math.max(0, R - b)), N = d(M) + d(_);
|
|
714
|
+
B < D ? (D = B, g = p, Q = N < Q ? N : Q) : B === D && N < Q && (Q = N, g = p);
|
|
715
|
+
}
|
|
716
|
+
return g || l - v;
|
|
717
|
+
}, i.prototype._chooseSplitAxis = function(m, v, l) {
|
|
718
|
+
var g = m.leaf ? this.compareMinX : u, x = m.leaf ? this.compareMinY : f;
|
|
719
|
+
this._allDistMargin(m, v, l, g) < this._allDistMargin(m, v, l, x) && m.children.sort(g);
|
|
720
|
+
}, i.prototype._allDistMargin = function(m, v, l, g) {
|
|
721
|
+
m.children.sort(g);
|
|
722
|
+
for (var x = this.toBBox, A = c(m, 0, v, x), I = c(m, l - v, l, x), b = y(A) + y(I), T = v; T < l - v; T++) {
|
|
723
|
+
var R = m.children[T];
|
|
724
|
+
h(A, m.leaf ? x(R) : R), b += y(A);
|
|
725
|
+
}
|
|
726
|
+
for (var D = l - v - 1; D >= v; D--) {
|
|
727
|
+
var Q = m.children[D];
|
|
728
|
+
h(I, m.leaf ? x(Q) : Q), b += y(I);
|
|
729
|
+
}
|
|
730
|
+
return b;
|
|
731
|
+
}, i.prototype._adjustParentBBoxes = function(m, v, l) {
|
|
732
|
+
for (var g = l; g >= 0; g--) h(v[g], m);
|
|
733
|
+
}, i.prototype._condense = function(m) {
|
|
734
|
+
for (var v = m.length - 1, l = void 0; v >= 0; v--) m[v].children.length === 0 ? v > 0 ? (l = m[v - 1].children).splice(l.indexOf(m[v]), 1) : this.clear() : a(m[v], this.toBBox);
|
|
735
|
+
}, i;
|
|
736
|
+
});
|
|
737
|
+
})($e)), $e.exports;
|
|
738
|
+
}
|
|
739
|
+
let mr = class {
|
|
740
|
+
constructor(t = [], e = gr) {
|
|
741
|
+
if (this.data = t, this.length = this.data.length, this.compare = e, this.length > 0)
|
|
742
|
+
for (let n = (this.length >> 1) - 1; n >= 0; n--) this._down(n);
|
|
743
|
+
}
|
|
744
|
+
push(t) {
|
|
745
|
+
this.data.push(t), this.length++, this._up(this.length - 1);
|
|
746
|
+
}
|
|
747
|
+
pop() {
|
|
748
|
+
if (this.length === 0) return;
|
|
749
|
+
const t = this.data[0], e = this.data.pop();
|
|
750
|
+
return this.length--, this.length > 0 && (this.data[0] = e, this._down(0)), t;
|
|
751
|
+
}
|
|
752
|
+
peek() {
|
|
753
|
+
return this.data[0];
|
|
754
|
+
}
|
|
755
|
+
_up(t) {
|
|
756
|
+
const { data: e, compare: n } = this, r = e[t];
|
|
757
|
+
for (; t > 0; ) {
|
|
758
|
+
const i = t - 1 >> 1, s = e[i];
|
|
759
|
+
if (n(r, s) >= 0) break;
|
|
760
|
+
e[t] = s, t = i;
|
|
761
|
+
}
|
|
762
|
+
e[t] = r;
|
|
763
|
+
}
|
|
764
|
+
_down(t) {
|
|
765
|
+
const { data: e, compare: n } = this, r = this.length >> 1, i = e[t];
|
|
766
|
+
for (; t < r; ) {
|
|
767
|
+
let s = (t << 1) + 1, a = e[s];
|
|
768
|
+
const c = s + 1;
|
|
769
|
+
if (c < this.length && n(e[c], a) < 0 && (s = c, a = e[c]), n(a, i) >= 0) break;
|
|
770
|
+
e[t] = a, t = s;
|
|
771
|
+
}
|
|
772
|
+
e[t] = i;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
function gr(o, t) {
|
|
776
|
+
return o < t ? -1 : o > t ? 1 : 0;
|
|
777
|
+
}
|
|
778
|
+
const wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
779
|
+
__proto__: null,
|
|
780
|
+
default: mr
|
|
781
|
+
}, Symbol.toStringTag, { value: "Module" })), yr = /* @__PURE__ */ lr(wr);
|
|
782
|
+
var be = { exports: {} }, Ze, dn;
|
|
783
|
+
function vr() {
|
|
784
|
+
return dn || (dn = 1, Ze = function(t, e, n, r) {
|
|
785
|
+
var i = t[0], s = t[1], a = !1;
|
|
786
|
+
n === void 0 && (n = 0), r === void 0 && (r = e.length);
|
|
787
|
+
for (var c = (r - n) / 2, h = 0, u = c - 1; h < c; u = h++) {
|
|
788
|
+
var f = e[n + h * 2 + 0], d = e[n + h * 2 + 1], y = e[n + u * 2 + 0], E = e[n + u * 2 + 1], k = d > s != E > s && i < (y - f) * (s - d) / (E - d) + f;
|
|
789
|
+
k && (a = !a);
|
|
790
|
+
}
|
|
791
|
+
return a;
|
|
792
|
+
}), Ze;
|
|
793
|
+
}
|
|
794
|
+
var tn, mn;
|
|
795
|
+
function br() {
|
|
796
|
+
return mn || (mn = 1, tn = function(t, e, n, r) {
|
|
797
|
+
var i = t[0], s = t[1], a = !1;
|
|
798
|
+
n === void 0 && (n = 0), r === void 0 && (r = e.length);
|
|
799
|
+
for (var c = r - n, h = 0, u = c - 1; h < c; u = h++) {
|
|
800
|
+
var f = e[h + n][0], d = e[h + n][1], y = e[u + n][0], E = e[u + n][1], k = d > s != E > s && i < (y - f) * (s - d) / (E - d) + f;
|
|
801
|
+
k && (a = !a);
|
|
802
|
+
}
|
|
803
|
+
return a;
|
|
804
|
+
}), tn;
|
|
805
|
+
}
|
|
806
|
+
var gn;
|
|
807
|
+
function _r() {
|
|
808
|
+
if (gn) return be.exports;
|
|
809
|
+
gn = 1;
|
|
810
|
+
var o = vr(), t = br();
|
|
811
|
+
return be.exports = function(n, r, i, s) {
|
|
812
|
+
return r.length > 0 && Array.isArray(r[0]) ? t(n, r, i, s) : o(n, r, i, s);
|
|
813
|
+
}, be.exports.nested = t, be.exports.flat = o, be.exports;
|
|
814
|
+
}
|
|
815
|
+
var xe = { exports: {} }, xr = xe.exports, wn;
|
|
816
|
+
function Mr() {
|
|
817
|
+
return wn || (wn = 1, (function(o, t) {
|
|
818
|
+
(function(e, n) {
|
|
819
|
+
n(t);
|
|
820
|
+
})(xr, function(e) {
|
|
821
|
+
const r = 33306690738754706e-32;
|
|
822
|
+
function i(k, X, C, m, v) {
|
|
823
|
+
let l, g, x, A, I = X[0], b = m[0], T = 0, R = 0;
|
|
824
|
+
b > I == b > -I ? (l = I, I = X[++T]) : (l = b, b = m[++R]);
|
|
825
|
+
let D = 0;
|
|
826
|
+
if (T < k && R < C) for (b > I == b > -I ? (x = l - ((g = I + l) - I), I = X[++T]) : (x = l - ((g = b + l) - b), b = m[++R]), l = g, x !== 0 && (v[D++] = x); T < k && R < C; ) b > I == b > -I ? (x = l - ((g = l + I) - (A = g - l)) + (I - A), I = X[++T]) : (x = l - ((g = l + b) - (A = g - l)) + (b - A), b = m[++R]), l = g, x !== 0 && (v[D++] = x);
|
|
827
|
+
for (; T < k; ) x = l - ((g = l + I) - (A = g - l)) + (I - A), I = X[++T], l = g, x !== 0 && (v[D++] = x);
|
|
828
|
+
for (; R < C; ) x = l - ((g = l + b) - (A = g - l)) + (b - A), b = m[++R], l = g, x !== 0 && (v[D++] = x);
|
|
829
|
+
return l === 0 && D !== 0 || (v[D++] = l), D;
|
|
830
|
+
}
|
|
831
|
+
function s(k) {
|
|
832
|
+
return new Float64Array(k);
|
|
833
|
+
}
|
|
834
|
+
const a = 33306690738754716e-32, c = 22204460492503146e-32, h = 11093356479670487e-47, u = s(4), f = s(8), d = s(12), y = s(16), E = s(4);
|
|
835
|
+
e.orient2d = function(k, X, C, m, v, l) {
|
|
836
|
+
const g = (X - l) * (C - v), x = (k - v) * (m - l), A = g - x;
|
|
837
|
+
if (g === 0 || x === 0 || g > 0 != x > 0) return A;
|
|
838
|
+
const I = Math.abs(g + x);
|
|
839
|
+
return Math.abs(A) >= a * I ? A : -(function(b, T, R, D, Q, p, M) {
|
|
840
|
+
let _, B, N, Y, w, O, $, q, V, z, K, j, ct, ht, lt, dt, gt, mt;
|
|
841
|
+
const Pt = b - Q, Tt = R - Q, xt = T - p, Mt = D - p;
|
|
842
|
+
w = (lt = (q = Pt - ($ = (O = 134217729 * Pt) - (O - Pt))) * (z = Mt - (V = (O = 134217729 * Mt) - (O - Mt))) - ((ht = Pt * Mt) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = xt - ($ = (O = 134217729 * xt) - (O - xt))) * (z = Tt - (V = (O = 134217729 * Tt) - (O - Tt))) - ((dt = xt * Tt) - $ * V - q * V - $ * z))), u[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), u[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, u[2] = j - (mt - w) + (K - w), u[3] = mt;
|
|
843
|
+
let Gt = (function(S, P) {
|
|
844
|
+
let F = P[0];
|
|
845
|
+
for (let L = 1; L < S; L++) F += P[L];
|
|
846
|
+
return F;
|
|
847
|
+
})(4, u), ce = c * M;
|
|
848
|
+
if (Gt >= ce || -Gt >= ce || (_ = b - (Pt + (w = b - Pt)) + (w - Q), N = R - (Tt + (w = R - Tt)) + (w - Q), B = T - (xt + (w = T - xt)) + (w - p), Y = D - (Mt + (w = D - Mt)) + (w - p), _ === 0 && B === 0 && N === 0 && Y === 0) || (ce = h * M + r * Math.abs(Gt), (Gt += Pt * Y + Mt * _ - (xt * N + Tt * B)) >= ce || -Gt >= ce)) return Gt;
|
|
849
|
+
w = (lt = (q = _ - ($ = (O = 134217729 * _) - (O - _))) * (z = Mt - (V = (O = 134217729 * Mt) - (O - Mt))) - ((ht = _ * Mt) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = B - ($ = (O = 134217729 * B) - (O - B))) * (z = Tt - (V = (O = 134217729 * Tt) - (O - Tt))) - ((dt = B * Tt) - $ * V - q * V - $ * z))), E[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), E[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, E[2] = j - (mt - w) + (K - w), E[3] = mt;
|
|
850
|
+
const je = i(4, u, 4, E, f);
|
|
851
|
+
w = (lt = (q = Pt - ($ = (O = 134217729 * Pt) - (O - Pt))) * (z = Y - (V = (O = 134217729 * Y) - (O - Y))) - ((ht = Pt * Y) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = xt - ($ = (O = 134217729 * xt) - (O - xt))) * (z = N - (V = (O = 134217729 * N) - (O - N))) - ((dt = xt * N) - $ * V - q * V - $ * z))), E[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), E[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, E[2] = j - (mt - w) + (K - w), E[3] = mt;
|
|
852
|
+
const ze = i(je, f, 4, E, d);
|
|
853
|
+
w = (lt = (q = _ - ($ = (O = 134217729 * _) - (O - _))) * (z = Y - (V = (O = 134217729 * Y) - (O - Y))) - ((ht = _ * Y) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = B - ($ = (O = 134217729 * B) - (O - B))) * (z = N - (V = (O = 134217729 * N) - (O - N))) - ((dt = B * N) - $ * V - q * V - $ * z))), E[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), E[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, E[2] = j - (mt - w) + (K - w), E[3] = mt;
|
|
854
|
+
const qt = i(ze, d, 4, E, y);
|
|
855
|
+
return y[qt - 1];
|
|
856
|
+
})(k, X, C, m, v, l, I);
|
|
857
|
+
}, e.orient2dfast = function(k, X, C, m, v, l) {
|
|
858
|
+
return (X - l) * (C - v) - (k - v) * (m - l);
|
|
859
|
+
}, Object.defineProperty(e, "__esModule", { value: !0 });
|
|
860
|
+
});
|
|
861
|
+
})(xe, xe.exports)), xe.exports;
|
|
862
|
+
}
|
|
863
|
+
var yn;
|
|
864
|
+
function kr() {
|
|
865
|
+
if (yn) return Oe.exports;
|
|
866
|
+
yn = 1;
|
|
867
|
+
var o = dr(), t = yr, e = _r(), n = Mr().orient2d;
|
|
868
|
+
t.default && (t = t.default), Oe.exports = r, Oe.exports.default = r;
|
|
869
|
+
function r(l, g, x) {
|
|
870
|
+
g = Math.max(0, g === void 0 ? 2 : g), x = x || 0;
|
|
871
|
+
var A = y(l), I = new o(16);
|
|
872
|
+
I.toBBox = function($) {
|
|
873
|
+
return {
|
|
874
|
+
minX: $[0],
|
|
875
|
+
minY: $[1],
|
|
876
|
+
maxX: $[0],
|
|
877
|
+
maxY: $[1]
|
|
878
|
+
};
|
|
879
|
+
}, I.compareMinX = function($, q) {
|
|
880
|
+
return $[0] - q[0];
|
|
881
|
+
}, I.compareMinY = function($, q) {
|
|
882
|
+
return $[1] - q[1];
|
|
883
|
+
}, I.load(l);
|
|
884
|
+
for (var b = [], T = 0, R; T < A.length; T++) {
|
|
885
|
+
var D = A[T];
|
|
886
|
+
I.remove(D), R = E(D, R), b.push(R);
|
|
887
|
+
}
|
|
888
|
+
var Q = new o(16);
|
|
889
|
+
for (T = 0; T < b.length; T++) Q.insert(d(b[T]));
|
|
890
|
+
for (var p = g * g, M = x * x; b.length; ) {
|
|
891
|
+
var _ = b.shift(), B = _.p, N = _.next.p, Y = k(B, N);
|
|
892
|
+
if (!(Y < M)) {
|
|
893
|
+
var w = Y / p;
|
|
894
|
+
D = i(I, _.prev.p, B, N, _.next.next.p, w, Q), D && Math.min(k(D, B), k(D, N)) <= w && (b.push(_), b.push(E(D, _)), I.remove(D), Q.remove(_), Q.insert(d(_)), Q.insert(d(_.next)));
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
_ = R;
|
|
898
|
+
var O = [];
|
|
899
|
+
do
|
|
900
|
+
O.push(_.p), _ = _.next;
|
|
901
|
+
while (_ !== R);
|
|
902
|
+
return O.push(_.p), O;
|
|
903
|
+
}
|
|
904
|
+
function i(l, g, x, A, I, b, T) {
|
|
905
|
+
for (var R = new t([], s), D = l.data; D; ) {
|
|
906
|
+
for (var Q = 0; Q < D.children.length; Q++) {
|
|
907
|
+
var p = D.children[Q], M = D.leaf ? X(p, x, A) : a(x, A, p);
|
|
908
|
+
M > b || R.push({
|
|
909
|
+
node: p,
|
|
910
|
+
dist: M
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
for (; R.length && !R.peek().node.children; ) {
|
|
914
|
+
var _ = R.pop(), B = _.node, N = X(B, g, x), Y = X(B, A, I);
|
|
915
|
+
if (_.dist < N && _.dist < Y && h(x, B, T) && h(A, B, T)) return B;
|
|
916
|
+
}
|
|
917
|
+
D = R.pop(), D && (D = D.node);
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
function s(l, g) {
|
|
922
|
+
return l.dist - g.dist;
|
|
923
|
+
}
|
|
924
|
+
function a(l, g, x) {
|
|
925
|
+
if (c(l, x) || c(g, x)) return 0;
|
|
926
|
+
var A = C(l[0], l[1], g[0], g[1], x.minX, x.minY, x.maxX, x.minY);
|
|
927
|
+
if (A === 0) return 0;
|
|
928
|
+
var I = C(l[0], l[1], g[0], g[1], x.minX, x.minY, x.minX, x.maxY);
|
|
929
|
+
if (I === 0) return 0;
|
|
930
|
+
var b = C(l[0], l[1], g[0], g[1], x.maxX, x.minY, x.maxX, x.maxY);
|
|
931
|
+
if (b === 0) return 0;
|
|
932
|
+
var T = C(l[0], l[1], g[0], g[1], x.minX, x.maxY, x.maxX, x.maxY);
|
|
933
|
+
return T === 0 ? 0 : Math.min(A, I, b, T);
|
|
934
|
+
}
|
|
935
|
+
function c(l, g) {
|
|
936
|
+
return l[0] >= g.minX && l[0] <= g.maxX && l[1] >= g.minY && l[1] <= g.maxY;
|
|
937
|
+
}
|
|
938
|
+
function h(l, g, x) {
|
|
939
|
+
for (var A = Math.min(l[0], g[0]), I = Math.min(l[1], g[1]), b = Math.max(l[0], g[0]), T = Math.max(l[1], g[1]), R = x.search({ minX: A, minY: I, maxX: b, maxY: T }), D = 0; D < R.length; D++)
|
|
940
|
+
if (f(R[D].p, R[D].next.p, l, g)) return !1;
|
|
941
|
+
return !0;
|
|
942
|
+
}
|
|
943
|
+
function u(l, g, x) {
|
|
944
|
+
return n(l[0], l[1], g[0], g[1], x[0], x[1]);
|
|
945
|
+
}
|
|
946
|
+
function f(l, g, x, A) {
|
|
947
|
+
return l !== A && g !== x && u(l, g, x) > 0 != u(l, g, A) > 0 && u(x, A, l) > 0 != u(x, A, g) > 0;
|
|
948
|
+
}
|
|
949
|
+
function d(l) {
|
|
950
|
+
var g = l.p, x = l.next.p;
|
|
951
|
+
return l.minX = Math.min(g[0], x[0]), l.minY = Math.min(g[1], x[1]), l.maxX = Math.max(g[0], x[0]), l.maxY = Math.max(g[1], x[1]), l;
|
|
952
|
+
}
|
|
953
|
+
function y(l) {
|
|
954
|
+
for (var g = l[0], x = l[0], A = l[0], I = l[0], b = 0; b < l.length; b++) {
|
|
955
|
+
var T = l[b];
|
|
956
|
+
T[0] < g[0] && (g = T), T[0] > A[0] && (A = T), T[1] < x[1] && (x = T), T[1] > I[1] && (I = T);
|
|
957
|
+
}
|
|
958
|
+
var R = [g, x, A, I], D = R.slice();
|
|
959
|
+
for (b = 0; b < l.length; b++)
|
|
960
|
+
e(l[b], R) || D.push(l[b]);
|
|
961
|
+
return v(D);
|
|
962
|
+
}
|
|
963
|
+
function E(l, g) {
|
|
964
|
+
var x = {
|
|
965
|
+
p: l,
|
|
966
|
+
prev: null,
|
|
967
|
+
next: null,
|
|
968
|
+
minX: 0,
|
|
969
|
+
minY: 0,
|
|
970
|
+
maxX: 0,
|
|
971
|
+
maxY: 0
|
|
972
|
+
};
|
|
973
|
+
return g ? (x.next = g.next, x.prev = g, g.next.prev = x, g.next = x) : (x.prev = x, x.next = x), x;
|
|
974
|
+
}
|
|
975
|
+
function k(l, g) {
|
|
976
|
+
var x = l[0] - g[0], A = l[1] - g[1];
|
|
977
|
+
return x * x + A * A;
|
|
978
|
+
}
|
|
979
|
+
function X(l, g, x) {
|
|
980
|
+
var A = g[0], I = g[1], b = x[0] - A, T = x[1] - I;
|
|
981
|
+
if (b !== 0 || T !== 0) {
|
|
982
|
+
var R = ((l[0] - A) * b + (l[1] - I) * T) / (b * b + T * T);
|
|
983
|
+
R > 1 ? (A = x[0], I = x[1]) : R > 0 && (A += b * R, I += T * R);
|
|
984
|
+
}
|
|
985
|
+
return b = l[0] - A, T = l[1] - I, b * b + T * T;
|
|
986
|
+
}
|
|
987
|
+
function C(l, g, x, A, I, b, T, R) {
|
|
988
|
+
var D = x - l, Q = A - g, p = T - I, M = R - b, _ = l - I, B = g - b, N = D * D + Q * Q, Y = D * p + Q * M, w = p * p + M * M, O = D * _ + Q * B, $ = p * _ + M * B, q = N * w - Y * Y, V, z, K, j, ct = q, ht = q;
|
|
989
|
+
q === 0 ? (z = 0, ct = 1, j = $, ht = w) : (z = Y * $ - w * O, j = N * $ - Y * O, z < 0 ? (z = 0, j = $, ht = w) : z > ct && (z = ct, j = $ + Y, ht = w)), j < 0 ? (j = 0, -O < 0 ? z = 0 : -O > N ? z = ct : (z = -O, ct = N)) : j > ht && (j = ht, -O + Y < 0 ? z = 0 : -O + Y > N ? z = ct : (z = -O + Y, ct = N)), V = z === 0 ? 0 : z / ct, K = j === 0 ? 0 : j / ht;
|
|
990
|
+
var lt = (1 - V) * l + V * x, dt = (1 - V) * g + V * A, gt = (1 - K) * I + K * T, mt = (1 - K) * b + K * R, Pt = gt - lt, Tt = mt - dt;
|
|
991
|
+
return Pt * Pt + Tt * Tt;
|
|
992
|
+
}
|
|
993
|
+
function m(l, g) {
|
|
994
|
+
return l[0] === g[0] ? l[1] - g[1] : l[0] - g[0];
|
|
995
|
+
}
|
|
996
|
+
function v(l) {
|
|
997
|
+
l.sort(m);
|
|
998
|
+
for (var g = [], x = 0; x < l.length; x++) {
|
|
999
|
+
for (; g.length >= 2 && u(g[g.length - 2], g[g.length - 1], l[x]) <= 0; )
|
|
1000
|
+
g.pop();
|
|
1001
|
+
g.push(l[x]);
|
|
1002
|
+
}
|
|
1003
|
+
for (var A = [], I = l.length - 1; I >= 0; I--) {
|
|
1004
|
+
for (; A.length >= 2 && u(A[A.length - 2], A[A.length - 1], l[I]) <= 0; )
|
|
1005
|
+
A.pop();
|
|
1006
|
+
A.push(l[I]);
|
|
1007
|
+
}
|
|
1008
|
+
return A.pop(), g.pop(), g.concat(A);
|
|
1009
|
+
}
|
|
1010
|
+
return Oe.exports;
|
|
1011
|
+
}
|
|
1012
|
+
var Sr = kr();
|
|
1013
|
+
const Er = /* @__PURE__ */ ur(Sr);
|
|
1014
|
+
function Ar(o, t = {}) {
|
|
1015
|
+
t.concavity = t.concavity || 1 / 0;
|
|
1016
|
+
const e = [];
|
|
1017
|
+
if (rn(o, (r) => {
|
|
1018
|
+
e.push([r[0], r[1]]);
|
|
1019
|
+
}), !e.length)
|
|
1020
|
+
return null;
|
|
1021
|
+
const n = Er(e, t.concavity);
|
|
1022
|
+
return n.length > 3 ? Ee([n]) : null;
|
|
1023
|
+
}
|
|
1024
|
+
var vn = Ar, Me = { exports: {} }, Pr = Me.exports, bn;
|
|
1025
|
+
function Br() {
|
|
1026
|
+
return bn || (bn = 1, (function(o, t) {
|
|
1027
|
+
(function(e, n) {
|
|
1028
|
+
n(t);
|
|
1029
|
+
})(Pr, function(e) {
|
|
1030
|
+
const n = 11102230246251565e-32, r = 134217729, i = (3 + 8 * n) * n;
|
|
1031
|
+
function s(S, P, F, L, tt) {
|
|
1032
|
+
let G, et, st, it, at = P[0], ft = L[0], J = 0, Z = 0;
|
|
1033
|
+
ft > at == ft > -at ? (G = at, at = P[++J]) : (G = ft, ft = L[++Z]);
|
|
1034
|
+
let ut = 0;
|
|
1035
|
+
if (J < S && Z < F) for (ft > at == ft > -at ? (et = at + G, st = G - (et - at), at = P[++J]) : (et = ft + G, st = G - (et - ft), ft = L[++Z]), G = et, st !== 0 && (tt[ut++] = st); J < S && Z < F; ) ft > at == ft > -at ? (et = G + at, it = et - G, st = G - (et - it) + (at - it), at = P[++J]) : (et = G + ft, it = et - G, st = G - (et - it) + (ft - it), ft = L[++Z]), G = et, st !== 0 && (tt[ut++] = st);
|
|
1036
|
+
for (; J < S; ) et = G + at, it = et - G, st = G - (et - it) + (at - it), at = P[++J], G = et, st !== 0 && (tt[ut++] = st);
|
|
1037
|
+
for (; Z < F; ) et = G + ft, it = et - G, st = G - (et - it) + (ft - it), ft = L[++Z], G = et, st !== 0 && (tt[ut++] = st);
|
|
1038
|
+
return (G !== 0 || ut === 0) && (tt[ut++] = G), ut;
|
|
1039
|
+
}
|
|
1040
|
+
function a(S, P) {
|
|
1041
|
+
let F = P[0];
|
|
1042
|
+
for (let L = 1; L < S; L++) F += P[L];
|
|
1043
|
+
return F;
|
|
1044
|
+
}
|
|
1045
|
+
function c(S) {
|
|
1046
|
+
return new Float64Array(S);
|
|
1047
|
+
}
|
|
1048
|
+
const h = (3 + 16 * n) * n, u = (2 + 12 * n) * n, f = (9 + 64 * n) * n * n, d = c(4), y = c(8), E = c(12), k = c(16), X = c(4);
|
|
1049
|
+
function C(S, P, F, L, tt, G, et) {
|
|
1050
|
+
let st, it, at, ft, J, Z, ut, _t, nt, H, W, wt, Et, At, Nt, yt, Bt, Rt;
|
|
1051
|
+
const zt = S - tt, Vt = F - tt, Wt = P - G, Jt = L - G;
|
|
1052
|
+
At = zt * Jt, Z = r * zt, ut = Z - (Z - zt), _t = zt - ut, Z = r * Jt, nt = Z - (Z - Jt), H = Jt - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = Wt * Vt, Z = r * Wt, ut = Z - (Z - Wt), _t = Wt - ut, Z = r * Vt, nt = Z - (Z - Vt), H = Vt - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, d[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, d[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, d[2] = wt - (Rt - J) + (W - J), d[3] = Rt;
|
|
1053
|
+
let he = a(4, d), ve = u * et;
|
|
1054
|
+
if (he >= ve || -he >= ve || (J = S - zt, st = S - (zt + J) + (J - tt), J = F - Vt, at = F - (Vt + J) + (J - tt), J = P - Wt, it = P - (Wt + J) + (J - G), J = L - Jt, ft = L - (Jt + J) + (J - G), st === 0 && it === 0 && at === 0 && ft === 0) || (ve = f * et + i * Math.abs(he), he += zt * ft + Jt * st - (Wt * at + Vt * it), he >= ve || -he >= ve)) return he;
|
|
1055
|
+
At = st * Jt, Z = r * st, ut = Z - (Z - st), _t = st - ut, Z = r * Jt, nt = Z - (Z - Jt), H = Jt - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = it * Vt, Z = r * it, ut = Z - (Z - it), _t = it - ut, Z = r * Vt, nt = Z - (Z - Vt), H = Vt - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, X[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, X[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, X[2] = wt - (Rt - J) + (W - J), X[3] = Rt;
|
|
1056
|
+
const zn = s(4, d, 4, X, y);
|
|
1057
|
+
At = zt * ft, Z = r * zt, ut = Z - (Z - zt), _t = zt - ut, Z = r * ft, nt = Z - (Z - ft), H = ft - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = Wt * at, Z = r * Wt, ut = Z - (Z - Wt), _t = Wt - ut, Z = r * at, nt = Z - (Z - at), H = at - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, X[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, X[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, X[2] = wt - (Rt - J) + (W - J), X[3] = Rt;
|
|
1058
|
+
const Vn = s(zn, y, 4, X, E);
|
|
1059
|
+
At = st * ft, Z = r * st, ut = Z - (Z - st), _t = st - ut, Z = r * ft, nt = Z - (Z - ft), H = ft - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = it * at, Z = r * it, ut = Z - (Z - it), _t = it - ut, Z = r * at, nt = Z - (Z - at), H = at - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, X[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, X[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, X[2] = wt - (Rt - J) + (W - J), X[3] = Rt;
|
|
1060
|
+
const Wn = s(Vn, E, 4, X, k);
|
|
1061
|
+
return k[Wn - 1];
|
|
1062
|
+
}
|
|
1063
|
+
function m(S, P, F, L, tt, G) {
|
|
1064
|
+
const et = (P - G) * (F - tt), st = (S - tt) * (L - G), it = et - st, at = Math.abs(et + st);
|
|
1065
|
+
return Math.abs(it) >= h * at ? it : -C(S, P, F, L, tt, G, at);
|
|
1066
|
+
}
|
|
1067
|
+
function v(S, P) {
|
|
1068
|
+
var F, L, tt = 0, G, et, st, it, at, ft, J, Z = S[0], ut = S[1], _t = P.length;
|
|
1069
|
+
for (F = 0; F < _t; F++) {
|
|
1070
|
+
L = 0;
|
|
1071
|
+
var nt = P[F], H = nt.length - 1;
|
|
1072
|
+
if (ft = nt[0], ft[0] !== nt[H][0] && ft[1] !== nt[H][1]) throw new Error("First and last coordinates in a ring must be the same");
|
|
1073
|
+
for (et = ft[0] - Z, st = ft[1] - ut, L; L < H; L++) {
|
|
1074
|
+
if (J = nt[L + 1], it = J[0] - Z, at = J[1] - ut, st === 0 && at === 0) {
|
|
1075
|
+
if (it <= 0 && et >= 0 || et <= 0 && it >= 0) return 0;
|
|
1076
|
+
} else if (at >= 0 && st <= 0 || at <= 0 && st >= 0) {
|
|
1077
|
+
if (G = m(et, it, st, at, 0, 0), G === 0) return 0;
|
|
1078
|
+
(G > 0 && at > 0 && st <= 0 || G < 0 && at <= 0 && st > 0) && tt++;
|
|
1079
|
+
}
|
|
1080
|
+
ft = J, st = at, et = it;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
return tt % 2 !== 0;
|
|
1084
|
+
}
|
|
1085
|
+
function l(S, P, F = {}) {
|
|
1086
|
+
const L = { type: "Feature" };
|
|
1087
|
+
return (F.id === 0 || F.id) && (L.id = F.id), F.bbox && (L.bbox = F.bbox), L.properties = P || {}, L.geometry = S, L;
|
|
1088
|
+
}
|
|
1089
|
+
function g(S, P, F = {}) {
|
|
1090
|
+
if (!S) throw new Error("coordinates is required");
|
|
1091
|
+
if (!Array.isArray(S)) throw new Error("coordinates must be an Array");
|
|
1092
|
+
if (S.length < 2) throw new Error("coordinates must be at least 2 numbers long");
|
|
1093
|
+
if (!I(S[0]) || !I(S[1])) throw new Error("coordinates must contain numbers");
|
|
1094
|
+
return l({ type: "Point", coordinates: S }, P, F);
|
|
1095
|
+
}
|
|
1096
|
+
function x(S, P, F = {}) {
|
|
1097
|
+
for (const L of S) {
|
|
1098
|
+
if (L.length < 4) throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
|
|
1099
|
+
if (L[L.length - 1].length !== L[0].length) throw new Error("First and last Position are not equivalent.");
|
|
1100
|
+
for (let tt = 0; tt < L[L.length - 1].length; tt++) if (L[L.length - 1][tt] !== L[0][tt]) throw new Error("First and last Position are not equivalent.");
|
|
1101
|
+
}
|
|
1102
|
+
return l({ type: "Polygon", coordinates: S }, P, F);
|
|
1103
|
+
}
|
|
1104
|
+
function A(S, P = {}) {
|
|
1105
|
+
const F = { type: "FeatureCollection" };
|
|
1106
|
+
return P.id && (F.id = P.id), P.bbox && (F.bbox = P.bbox), F.features = S, F;
|
|
1107
|
+
}
|
|
1108
|
+
function I(S) {
|
|
1109
|
+
return !isNaN(S) && S !== null && !Array.isArray(S);
|
|
1110
|
+
}
|
|
1111
|
+
function b(S) {
|
|
1112
|
+
if (!S) throw new Error("coord is required");
|
|
1113
|
+
if (!Array.isArray(S)) {
|
|
1114
|
+
if (S.type === "Feature" && S.geometry !== null && S.geometry.type === "Point") return [...S.geometry.coordinates];
|
|
1115
|
+
if (S.type === "Point") return [...S.coordinates];
|
|
1116
|
+
}
|
|
1117
|
+
if (Array.isArray(S) && S.length >= 2 && !Array.isArray(S[0]) && !Array.isArray(S[1])) return [...S];
|
|
1118
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
1119
|
+
}
|
|
1120
|
+
function T(S) {
|
|
1121
|
+
if (Array.isArray(S)) return S;
|
|
1122
|
+
if (S.type === "Feature") {
|
|
1123
|
+
if (S.geometry !== null) return S.geometry.coordinates;
|
|
1124
|
+
} else if (S.coordinates) return S.coordinates;
|
|
1125
|
+
throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array");
|
|
1126
|
+
}
|
|
1127
|
+
function R(S) {
|
|
1128
|
+
return S.type === "Feature" ? S.geometry : S;
|
|
1129
|
+
}
|
|
1130
|
+
function D(S, P, F = {}) {
|
|
1131
|
+
if (!S) throw new Error("point is required");
|
|
1132
|
+
if (!P) throw new Error("polygon is required");
|
|
1133
|
+
const L = b(S), tt = R(P), G = tt.type, et = P.bbox;
|
|
1134
|
+
let st = tt.coordinates;
|
|
1135
|
+
if (et && Q(L, et) === !1) return !1;
|
|
1136
|
+
G === "Polygon" && (st = [st]);
|
|
1137
|
+
let it = !1;
|
|
1138
|
+
for (var at = 0; at < st.length; ++at) {
|
|
1139
|
+
const ft = v(L, st[at]);
|
|
1140
|
+
if (ft === 0) return !F.ignoreBoundary;
|
|
1141
|
+
ft && (it = !0);
|
|
1142
|
+
}
|
|
1143
|
+
return it;
|
|
1144
|
+
}
|
|
1145
|
+
function Q(S, P) {
|
|
1146
|
+
return P[0] <= S[0] && P[1] <= S[1] && P[2] >= S[0] && P[3] >= S[1];
|
|
1147
|
+
}
|
|
1148
|
+
var p = D;
|
|
1149
|
+
function M(S, P) {
|
|
1150
|
+
for (let F = 0; F < P.features.length; F++) if (p(S, P.features[F])) return P.features[F];
|
|
1151
|
+
}
|
|
1152
|
+
function _(S, P, F) {
|
|
1153
|
+
const L = P.geometry.coordinates[0][0], tt = P.geometry.coordinates[0][1], G = P.geometry.coordinates[0][2], et = S.geometry.coordinates, st = P.properties.a.geom, it = P.properties.b.geom, at = P.properties.c.geom, ft = [tt[0] - L[0], tt[1] - L[1]], J = [G[0] - L[0], G[1] - L[1]], Z = [et[0] - L[0], et[1] - L[1]], ut = [it[0] - st[0], it[1] - st[1]], _t = [at[0] - st[0], at[1] - st[1]];
|
|
1154
|
+
let nt = (J[1] * Z[0] - J[0] * Z[1]) / (ft[0] * J[1] - ft[1] * J[0]), H = (ft[0] * Z[1] - ft[1] * Z[0]) / (ft[0] * J[1] - ft[1] * J[0]);
|
|
1155
|
+
if (F) {
|
|
1156
|
+
const W = F[P.properties.a.index], wt = F[P.properties.b.index], Et = F[P.properties.c.index];
|
|
1157
|
+
let At;
|
|
1158
|
+
if (nt < 0 || H < 0 || 1 - nt - H < 0) {
|
|
1159
|
+
const Nt = nt / (nt + H), yt = H / (nt + H);
|
|
1160
|
+
At = nt / wt / (Nt / wt + yt / Et), H = H / Et / (Nt / wt + yt / Et);
|
|
1161
|
+
} else At = nt / wt / (nt / wt + H / Et + (1 - nt - H) / W), H = H / Et / (nt / wt + H / Et + (1 - nt - H) / W);
|
|
1162
|
+
nt = At;
|
|
1163
|
+
}
|
|
1164
|
+
return [nt * ut[0] + H * _t[0] + st[0], nt * ut[1] + H * _t[1] + st[1]];
|
|
1165
|
+
}
|
|
1166
|
+
function B(S, P, F, L) {
|
|
1167
|
+
const tt = S.geometry.coordinates, G = F.geometry.coordinates, et = Math.atan2(tt[0] - G[0], tt[1] - G[1]), st = w(et, P[0]);
|
|
1168
|
+
if (st === void 0) throw new Error("Unable to determine vertex index");
|
|
1169
|
+
const it = P[1][st];
|
|
1170
|
+
return _(S, it.features[0], L);
|
|
1171
|
+
}
|
|
1172
|
+
function N(S, P, F, L, tt, G, et, st) {
|
|
1173
|
+
let it;
|
|
1174
|
+
if (et && (it = M(S, A([et]))), !it) {
|
|
1175
|
+
if (F) {
|
|
1176
|
+
const at = S.geometry.coordinates, ft = F.gridNum, J = F.xOrigin, Z = F.yOrigin, ut = F.xUnit, _t = F.yUnit, nt = F.gridCache, H = Y(at[0], J, ut, ft), W = Y(at[1], Z, _t, ft), wt = nt[H] ? nt[H][W] ? nt[H][W] : [] : [];
|
|
1177
|
+
P = A(wt.map((Et) => P.features[Et]));
|
|
1178
|
+
}
|
|
1179
|
+
it = M(S, P);
|
|
1180
|
+
}
|
|
1181
|
+
return st && st(it), it ? _(S, it, G) : B(S, L, tt, G);
|
|
1182
|
+
}
|
|
1183
|
+
function Y(S, P, F, L) {
|
|
1184
|
+
let tt = Math.floor((S - P) / F);
|
|
1185
|
+
return tt >= L && (tt = L - 1), tt;
|
|
1186
|
+
}
|
|
1187
|
+
function w(S, P) {
|
|
1188
|
+
let F = O(S - P[0]), L = Math.PI * 2, tt;
|
|
1189
|
+
for (let G = 0; G < P.length; G++) {
|
|
1190
|
+
const et = (G + 1) % P.length, st = O(S - P[et]), it = Math.min(Math.abs(F), Math.abs(st));
|
|
1191
|
+
F * st <= 0 && it < L && (L = it, tt = G), F = st;
|
|
1192
|
+
}
|
|
1193
|
+
return tt;
|
|
1194
|
+
}
|
|
1195
|
+
function O(S, P = !1) {
|
|
1196
|
+
const F = P ? function(L) {
|
|
1197
|
+
return !(L >= 0 && L < Math.PI * 2);
|
|
1198
|
+
} : function(L) {
|
|
1199
|
+
return !(L > -1 * Math.PI && L <= Math.PI);
|
|
1200
|
+
};
|
|
1201
|
+
for (; F(S); ) S = S + 2 * Math.PI * (S > 0 ? -1 : 1);
|
|
1202
|
+
return S;
|
|
1203
|
+
}
|
|
1204
|
+
function $(S, P) {
|
|
1205
|
+
return P && P >= 2.00703 || Array.isArray(S[0]) ? S : S.map((F) => [F.illstNodes, F.mercNodes, F.startEnd]);
|
|
1206
|
+
}
|
|
1207
|
+
function q(S) {
|
|
1208
|
+
const P = S.features;
|
|
1209
|
+
for (let F = 0; F < P.length; F++) {
|
|
1210
|
+
const L = P[F];
|
|
1211
|
+
`${L.properties.a.index}`.substring(0, 1) === "b" && `${L.properties.b.index}`.substring(0, 1) === "b" ? P[F] = { geometry: { type: "Polygon", coordinates: [[L.geometry.coordinates[0][2], L.geometry.coordinates[0][0], L.geometry.coordinates[0][1], L.geometry.coordinates[0][2]]] }, properties: { a: { geom: L.properties.c.geom, index: L.properties.c.index }, b: { geom: L.properties.a.geom, index: L.properties.a.index }, c: { geom: L.properties.b.geom, index: L.properties.b.index } }, type: "Feature" } : `${L.properties.c.index}`.substring(0, 1) === "b" && `${L.properties.a.index}`.substring(0, 1) === "b" && (P[F] = { geometry: { type: "Polygon", coordinates: [[L.geometry.coordinates[0][1], L.geometry.coordinates[0][2], L.geometry.coordinates[0][0], L.geometry.coordinates[0][1]]] }, properties: { a: { geom: L.properties.b.geom, index: L.properties.b.index }, b: { geom: L.properties.c.geom, index: L.properties.c.index }, c: { geom: L.properties.a.geom, index: L.properties.a.index } }, type: "Feature" });
|
|
1212
|
+
}
|
|
1213
|
+
return S;
|
|
1214
|
+
}
|
|
1215
|
+
function V(S) {
|
|
1216
|
+
const P = ["a", "b", "c", "a"].map((G) => S.properties[G].geom), F = S.geometry.coordinates[0], L = S.properties, tt = { a: { geom: F[0], index: L.a.index }, b: { geom: F[1], index: L.b.index }, c: { geom: F[2], index: L.c.index } };
|
|
1217
|
+
return x([P], tt);
|
|
1218
|
+
}
|
|
1219
|
+
function z(S) {
|
|
1220
|
+
const P = [0, 1, 2, 0].map((L) => S[L][0][0]), F = { a: { geom: S[0][0][1], index: S[0][1] }, b: { geom: S[1][0][1], index: S[1][1] }, c: { geom: S[2][0][1], index: S[2][1] } };
|
|
1221
|
+
return x([P], F);
|
|
1222
|
+
}
|
|
1223
|
+
function K(S, P, F, L, tt, G = !1, et) {
|
|
1224
|
+
const st = S.map((it) => {
|
|
1225
|
+
(!et || et < 2.00703) && (it = j(it));
|
|
1226
|
+
const at = isFinite(it) ? P[it] : it === "c" ? L : it === "b0" ? tt[0] : it === "b1" ? tt[1] : it === "b2" ? tt[2] : it === "b3" ? tt[3] : (function() {
|
|
1227
|
+
const ft = it.match(/e(\d+)/);
|
|
1228
|
+
if (ft) {
|
|
1229
|
+
const J = parseInt(ft[1]);
|
|
1230
|
+
return F[J];
|
|
1231
|
+
}
|
|
1232
|
+
throw "Bad index value for indexesToTri";
|
|
1233
|
+
})();
|
|
1234
|
+
return G ? [[at[1], at[0]], it] : [[at[0], at[1]], it];
|
|
1235
|
+
});
|
|
1236
|
+
return z(st);
|
|
1237
|
+
}
|
|
1238
|
+
function j(S) {
|
|
1239
|
+
return typeof S == "number" ? S : S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
|
|
1240
|
+
}
|
|
1241
|
+
const ct = 2.00703;
|
|
1242
|
+
function ht(S) {
|
|
1243
|
+
return !!(S.version || !S.tins && S.points && S.tins_points);
|
|
1244
|
+
}
|
|
1245
|
+
function lt(S) {
|
|
1246
|
+
return { points: S.points, pointsWeightBuffer: gt(S), strictStatus: mt(S), verticesParams: Pt(S), centroid: xt(S), edges: $(S.edges || []), edgeNodes: S.edgeNodes || [], tins: Mt(S), kinks: Gt(S.kinks_points), yaxisMode: S.yaxisMode ?? "invert", strictMode: S.strictMode ?? "auto", vertexMode: S.vertexMode, bounds: S.bounds, boundsPolygon: S.boundsPolygon, wh: S.wh, xy: S.bounds ? S.xy : [0, 0] };
|
|
1247
|
+
}
|
|
1248
|
+
function dt(S) {
|
|
1249
|
+
const P = ce(S), F = P.tins;
|
|
1250
|
+
return { compiled: P, tins: F, points: je(F), strictStatus: P.strict_status, pointsWeightBuffer: P.weight_buffer, verticesParams: P.vertices_params, centroid: P.centroid, kinks: P.kinks };
|
|
1251
|
+
}
|
|
1252
|
+
function gt(S) {
|
|
1253
|
+
return !S.version || S.version < ct ? ["forw", "bakw"].reduce((P, F) => {
|
|
1254
|
+
const L = S.weight_buffer[F];
|
|
1255
|
+
return L && (P[F] = Object.keys(L).reduce((tt, G) => {
|
|
1256
|
+
const et = j(G);
|
|
1257
|
+
return tt[et] = L[G], tt;
|
|
1258
|
+
}, {})), P;
|
|
1259
|
+
}, {}) : S.weight_buffer;
|
|
1260
|
+
}
|
|
1261
|
+
function mt(S) {
|
|
1262
|
+
return S.strict_status ? S.strict_status : S.kinks_points ? "strict_error" : S.tins_points.length === 2 ? "loose" : "strict";
|
|
1263
|
+
}
|
|
1264
|
+
function Pt(S) {
|
|
1265
|
+
const P = { forw: [S.vertices_params[0]], bakw: [S.vertices_params[1]] };
|
|
1266
|
+
return P.forw[1] = Tt(S, !1), P.bakw[1] = Tt(S, !0), P;
|
|
1267
|
+
}
|
|
1268
|
+
function Tt(S, P) {
|
|
1269
|
+
return [0, 1, 2, 3].map((F) => {
|
|
1270
|
+
const L = (F + 1) % 4, tt = K(["c", `b${F}`, `b${L}`], S.points, S.edgeNodes || [], S.centroid_point, S.vertices_points, P, ct);
|
|
1271
|
+
return A([tt]);
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
function xt(S) {
|
|
1275
|
+
return { forw: g(S.centroid_point[0], { target: { geom: S.centroid_point[1], index: "c" } }), bakw: g(S.centroid_point[1], { target: { geom: S.centroid_point[0], index: "c" } }) };
|
|
1276
|
+
}
|
|
1277
|
+
function Mt(S) {
|
|
1278
|
+
const P = S.tins_points.length === 1 ? 0 : 1;
|
|
1279
|
+
return { forw: A(S.tins_points[0].map((F) => K(F, S.points, S.edgeNodes || [], S.centroid_point, S.vertices_points, !1, S.version))), bakw: A(S.tins_points[P].map((F) => K(F, S.points, S.edgeNodes || [], S.centroid_point, S.vertices_points, !0, S.version))) };
|
|
1280
|
+
}
|
|
1281
|
+
function Gt(S) {
|
|
1282
|
+
if (S) return { bakw: A(S.map((P) => g(P))) };
|
|
1283
|
+
}
|
|
1284
|
+
function ce(S) {
|
|
1285
|
+
return JSON.parse(JSON.stringify(S).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"'));
|
|
1286
|
+
}
|
|
1287
|
+
function je(S) {
|
|
1288
|
+
const P = [], F = S.forw.features;
|
|
1289
|
+
for (let L = 0; L < F.length; L++) {
|
|
1290
|
+
const tt = F[L];
|
|
1291
|
+
["a", "b", "c"].map((G, et) => {
|
|
1292
|
+
const st = tt.geometry.coordinates[0][et], it = tt.properties[G].geom, at = tt.properties[G].index;
|
|
1293
|
+
typeof at == "number" && (P[at] = [st, it]);
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
return P;
|
|
1297
|
+
}
|
|
1298
|
+
const ze = ct;
|
|
1299
|
+
class qt {
|
|
1300
|
+
static VERTEX_PLAIN = "plain";
|
|
1301
|
+
static VERTEX_BIRDEYE = "birdeye";
|
|
1302
|
+
static MODE_STRICT = "strict";
|
|
1303
|
+
static MODE_AUTO = "auto";
|
|
1304
|
+
static MODE_LOOSE = "loose";
|
|
1305
|
+
static STATUS_STRICT = "strict";
|
|
1306
|
+
static STATUS_ERROR = "strict_error";
|
|
1307
|
+
static STATUS_LOOSE = "loose";
|
|
1308
|
+
static YAXIS_FOLLOW = "follow";
|
|
1309
|
+
static YAXIS_INVERT = "invert";
|
|
1310
|
+
points = [];
|
|
1311
|
+
pointsWeightBuffer;
|
|
1312
|
+
strict_status;
|
|
1313
|
+
vertices_params;
|
|
1314
|
+
centroid;
|
|
1315
|
+
edgeNodes;
|
|
1316
|
+
edges;
|
|
1317
|
+
tins;
|
|
1318
|
+
kinks;
|
|
1319
|
+
yaxisMode = qt.YAXIS_INVERT;
|
|
1320
|
+
strictMode = qt.MODE_AUTO;
|
|
1321
|
+
vertexMode = qt.VERTEX_PLAIN;
|
|
1322
|
+
bounds;
|
|
1323
|
+
boundsPolygon;
|
|
1324
|
+
wh;
|
|
1325
|
+
xy;
|
|
1326
|
+
indexedTins;
|
|
1327
|
+
stateFull = !1;
|
|
1328
|
+
stateTriangle;
|
|
1329
|
+
stateBackward;
|
|
1330
|
+
constructor() {
|
|
1331
|
+
}
|
|
1332
|
+
setCompiled(P) {
|
|
1333
|
+
if (ht(P)) {
|
|
1334
|
+
this.applyModernState(lt(P));
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
this.applyLegacyState(dt(P));
|
|
1338
|
+
}
|
|
1339
|
+
applyModernState(P) {
|
|
1340
|
+
this.points = P.points, this.pointsWeightBuffer = P.pointsWeightBuffer, this.strict_status = P.strictStatus, this.vertices_params = P.verticesParams, this.centroid = P.centroid, this.edges = P.edges, this.edgeNodes = P.edgeNodes || [], this.tins = P.tins, this.addIndexedTin(), this.kinks = P.kinks, this.yaxisMode = P.yaxisMode ?? qt.YAXIS_INVERT, this.vertexMode = P.vertexMode ?? qt.VERTEX_PLAIN, this.strictMode = P.strictMode ?? qt.MODE_AUTO, P.bounds ? (this.bounds = P.bounds, this.boundsPolygon = P.boundsPolygon, this.xy = P.xy, this.wh = P.wh) : (this.bounds = void 0, this.boundsPolygon = void 0, this.xy = P.xy ?? [0, 0], P.wh && (this.wh = P.wh));
|
|
1341
|
+
}
|
|
1342
|
+
applyLegacyState(P) {
|
|
1343
|
+
this.tins = P.tins, this.addIndexedTin(), this.strict_status = P.strictStatus, this.pointsWeightBuffer = P.pointsWeightBuffer, this.vertices_params = P.verticesParams, this.centroid = P.centroid, this.kinks = P.kinks, this.points = P.points;
|
|
1344
|
+
}
|
|
1345
|
+
addIndexedTin() {
|
|
1346
|
+
const P = this.tins, F = P.forw, L = P.bakw, tt = Math.ceil(Math.sqrt(F.features.length));
|
|
1347
|
+
if (tt < 3) {
|
|
1348
|
+
this.indexedTins = void 0;
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
let G = [], et = [];
|
|
1352
|
+
const st = F.features.map((nt) => {
|
|
1353
|
+
let H = [];
|
|
1354
|
+
return T(nt)[0].map((W) => {
|
|
1355
|
+
G.length === 0 ? G = [Array.from(W), Array.from(W)] : (W[0] < G[0][0] && (G[0][0] = W[0]), W[0] > G[1][0] && (G[1][0] = W[0]), W[1] < G[0][1] && (G[0][1] = W[1]), W[1] > G[1][1] && (G[1][1] = W[1])), H.length === 0 ? H = [Array.from(W), Array.from(W)] : (W[0] < H[0][0] && (H[0][0] = W[0]), W[0] > H[1][0] && (H[1][0] = W[0]), W[1] < H[0][1] && (H[0][1] = W[1]), W[1] > H[1][1] && (H[1][1] = W[1]));
|
|
1356
|
+
}), H;
|
|
1357
|
+
}), it = (G[1][0] - G[0][0]) / tt, at = (G[1][1] - G[0][1]) / tt, ft = st.reduce((nt, H, W) => {
|
|
1358
|
+
const wt = Y(H[0][0], G[0][0], it, tt), Et = Y(H[1][0], G[0][0], it, tt), At = Y(H[0][1], G[0][1], at, tt), Nt = Y(H[1][1], G[0][1], at, tt);
|
|
1359
|
+
for (let yt = wt; yt <= Et; yt++) {
|
|
1360
|
+
nt[yt] || (nt[yt] = []);
|
|
1361
|
+
for (let Bt = At; Bt <= Nt; Bt++) nt[yt][Bt] || (nt[yt][Bt] = []), nt[yt][Bt].push(W);
|
|
1362
|
+
}
|
|
1363
|
+
return nt;
|
|
1364
|
+
}, []), J = L.features.map((nt) => {
|
|
1365
|
+
let H = [];
|
|
1366
|
+
return T(nt)[0].map((W) => {
|
|
1367
|
+
et.length === 0 ? et = [Array.from(W), Array.from(W)] : (W[0] < et[0][0] && (et[0][0] = W[0]), W[0] > et[1][0] && (et[1][0] = W[0]), W[1] < et[0][1] && (et[0][1] = W[1]), W[1] > et[1][1] && (et[1][1] = W[1])), H.length === 0 ? H = [Array.from(W), Array.from(W)] : (W[0] < H[0][0] && (H[0][0] = W[0]), W[0] > H[1][0] && (H[1][0] = W[0]), W[1] < H[0][1] && (H[0][1] = W[1]), W[1] > H[1][1] && (H[1][1] = W[1]));
|
|
1368
|
+
}), H;
|
|
1369
|
+
}), Z = (et[1][0] - et[0][0]) / tt, ut = (et[1][1] - et[0][1]) / tt, _t = J.reduce((nt, H, W) => {
|
|
1370
|
+
const wt = Y(H[0][0], et[0][0], Z, tt), Et = Y(H[1][0], et[0][0], Z, tt), At = Y(H[0][1], et[0][1], ut, tt), Nt = Y(H[1][1], et[0][1], ut, tt);
|
|
1371
|
+
for (let yt = wt; yt <= Et; yt++) {
|
|
1372
|
+
nt[yt] || (nt[yt] = []);
|
|
1373
|
+
for (let Bt = At; Bt <= Nt; Bt++) nt[yt][Bt] || (nt[yt][Bt] = []), nt[yt][Bt].push(W);
|
|
1374
|
+
}
|
|
1375
|
+
return nt;
|
|
1376
|
+
}, []);
|
|
1377
|
+
this.indexedTins = { forw: { gridNum: tt, xOrigin: G[0][0], yOrigin: G[0][1], xUnit: it, yUnit: at, gridCache: ft }, bakw: { gridNum: tt, xOrigin: et[0][0], yOrigin: et[0][1], xUnit: Z, yUnit: ut, gridCache: _t } };
|
|
1378
|
+
}
|
|
1379
|
+
transform(P, F, L) {
|
|
1380
|
+
if (F && this.strict_status == qt.STATUS_ERROR) throw 'Backward transform is not allowed if strict_status == "strict_error"';
|
|
1381
|
+
this.yaxisMode == qt.YAXIS_FOLLOW && F && (P = [P[0], -1 * P[1]]);
|
|
1382
|
+
const tt = g(P);
|
|
1383
|
+
if (this.bounds && !F && !L && !p(tt, this.boundsPolygon)) return !1;
|
|
1384
|
+
const G = F ? this.tins.bakw : this.tins.forw, et = F ? this.indexedTins.bakw : this.indexedTins.forw, st = F ? this.vertices_params.bakw : this.vertices_params.forw, it = F ? this.centroid.bakw : this.centroid.forw, at = F ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
|
|
1385
|
+
let ft, J;
|
|
1386
|
+
this.stateFull && (this.stateBackward == F ? ft = this.stateTriangle : (this.stateBackward = F, this.stateTriangle = void 0), J = (ut) => {
|
|
1387
|
+
this.stateTriangle = ut;
|
|
1388
|
+
});
|
|
1389
|
+
let Z = N(tt, G, et, st, it, at, ft, J);
|
|
1390
|
+
if (this.bounds && F && !L) {
|
|
1391
|
+
const ut = g(Z);
|
|
1392
|
+
if (!p(ut, this.boundsPolygon)) return !1;
|
|
1393
|
+
} else this.yaxisMode == qt.YAXIS_FOLLOW && !F && (Z = [Z[0], -1 * Z[1]]);
|
|
1394
|
+
return Z;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
e.Transform = qt, e.counterTri = V, e.format_version = ze, e.normalizeEdges = $, e.rotateVerticesTriangle = q, e.transformArr = N, Object.defineProperty(e, Symbol.toStringTag, { value: "Module" });
|
|
1398
|
+
});
|
|
1399
|
+
})(Me, Me.exports)), Me.exports;
|
|
1400
|
+
}
|
|
1401
|
+
var jt = Br();
|
|
1402
|
+
const _n = Math.pow(2, -52), Ie = new Uint32Array(512);
|
|
1403
|
+
class sn {
|
|
1404
|
+
static from(t, e = Xr, n = Yr) {
|
|
1405
|
+
const r = t.length, i = new Float64Array(r * 2);
|
|
1406
|
+
for (let s = 0; s < r; s++) {
|
|
1407
|
+
const a = t[s];
|
|
1408
|
+
i[2 * s] = e(a), i[2 * s + 1] = n(a);
|
|
1409
|
+
}
|
|
1410
|
+
return new sn(i);
|
|
1411
|
+
}
|
|
1412
|
+
constructor(t) {
|
|
1413
|
+
const e = t.length >> 1;
|
|
1414
|
+
if (e > 0 && typeof t[0] != "number") throw new Error("Expected coords to contain numbers.");
|
|
1415
|
+
this.coords = t;
|
|
1416
|
+
const n = Math.max(2 * e - 5, 0);
|
|
1417
|
+
this._triangles = new Uint32Array(n * 3), this._halfedges = new Int32Array(n * 3), this._hashSize = Math.ceil(Math.sqrt(e)), this._hullPrev = new Uint32Array(e), this._hullNext = new Uint32Array(e), this._hullTri = new Uint32Array(e), this._hullHash = new Int32Array(this._hashSize), this._ids = new Uint32Array(e), this._dists = new Float64Array(e), this.update();
|
|
1418
|
+
}
|
|
1419
|
+
update() {
|
|
1420
|
+
const { coords: t, _hullPrev: e, _hullNext: n, _hullTri: r, _hullHash: i } = this, s = t.length >> 1;
|
|
1421
|
+
let a = 1 / 0, c = 1 / 0, h = -1 / 0, u = -1 / 0;
|
|
1422
|
+
for (let b = 0; b < s; b++) {
|
|
1423
|
+
const T = t[2 * b], R = t[2 * b + 1];
|
|
1424
|
+
T < a && (a = T), R < c && (c = R), T > h && (h = T), R > u && (u = R), this._ids[b] = b;
|
|
1425
|
+
}
|
|
1426
|
+
const f = (a + h) / 2, d = (c + u) / 2;
|
|
1427
|
+
let y, E, k;
|
|
1428
|
+
for (let b = 0, T = 1 / 0; b < s; b++) {
|
|
1429
|
+
const R = en(f, d, t[2 * b], t[2 * b + 1]);
|
|
1430
|
+
R < T && (y = b, T = R);
|
|
1431
|
+
}
|
|
1432
|
+
const X = t[2 * y], C = t[2 * y + 1];
|
|
1433
|
+
for (let b = 0, T = 1 / 0; b < s; b++) {
|
|
1434
|
+
if (b === y) continue;
|
|
1435
|
+
const R = en(X, C, t[2 * b], t[2 * b + 1]);
|
|
1436
|
+
R < T && R > 0 && (E = b, T = R);
|
|
1437
|
+
}
|
|
1438
|
+
let m = t[2 * E], v = t[2 * E + 1], l = 1 / 0;
|
|
1439
|
+
for (let b = 0; b < s; b++) {
|
|
1440
|
+
if (b === y || b === E) continue;
|
|
1441
|
+
const T = Tr(X, C, m, v, t[2 * b], t[2 * b + 1]);
|
|
1442
|
+
T < l && (k = b, l = T);
|
|
1443
|
+
}
|
|
1444
|
+
let g = t[2 * k], x = t[2 * k + 1];
|
|
1445
|
+
if (l === 1 / 0) {
|
|
1446
|
+
for (let R = 0; R < s; R++)
|
|
1447
|
+
this._dists[R] = t[2 * R] - t[0] || t[2 * R + 1] - t[1];
|
|
1448
|
+
we(this._ids, this._dists, 0, s - 1);
|
|
1449
|
+
const b = new Uint32Array(s);
|
|
1450
|
+
let T = 0;
|
|
1451
|
+
for (let R = 0, D = -1 / 0; R < s; R++) {
|
|
1452
|
+
const Q = this._ids[R], p = this._dists[Q];
|
|
1453
|
+
p > D && (b[T++] = Q, D = p);
|
|
1454
|
+
}
|
|
1455
|
+
this.hull = b.subarray(0, T), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
if (te(X, C, m, v, g, x) < 0) {
|
|
1459
|
+
const b = E, T = m, R = v;
|
|
1460
|
+
E = k, m = g, v = x, k = b, g = T, x = R;
|
|
1461
|
+
}
|
|
1462
|
+
const A = Nr(X, C, m, v, g, x);
|
|
1463
|
+
this._cx = A.x, this._cy = A.y;
|
|
1464
|
+
for (let b = 0; b < s; b++)
|
|
1465
|
+
this._dists[b] = en(t[2 * b], t[2 * b + 1], A.x, A.y);
|
|
1466
|
+
we(this._ids, this._dists, 0, s - 1), this._hullStart = y;
|
|
1467
|
+
let I = 3;
|
|
1468
|
+
n[y] = e[k] = E, n[E] = e[y] = k, n[k] = e[E] = y, r[y] = 0, r[E] = 1, r[k] = 2, i.fill(-1), i[this._hashKey(X, C)] = y, i[this._hashKey(m, v)] = E, i[this._hashKey(g, x)] = k, this.trianglesLen = 0, this._addTriangle(y, E, k, -1, -1, -1);
|
|
1469
|
+
for (let b = 0, T, R; b < this._ids.length; b++) {
|
|
1470
|
+
const D = this._ids[b], Q = t[2 * D], p = t[2 * D + 1];
|
|
1471
|
+
if (b > 0 && Math.abs(Q - T) <= _n && Math.abs(p - R) <= _n || (T = Q, R = p, D === y || D === E || D === k)) continue;
|
|
1472
|
+
let M = 0;
|
|
1473
|
+
for (let w = 0, O = this._hashKey(Q, p); w < this._hashSize && (M = i[(O + w) % this._hashSize], !(M !== -1 && M !== n[M])); w++)
|
|
1474
|
+
;
|
|
1475
|
+
M = e[M];
|
|
1476
|
+
let _ = M, B;
|
|
1477
|
+
for (; B = n[_], te(Q, p, t[2 * _], t[2 * _ + 1], t[2 * B], t[2 * B + 1]) >= 0; )
|
|
1478
|
+
if (_ = B, _ === M) {
|
|
1479
|
+
_ = -1;
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
if (_ === -1) continue;
|
|
1483
|
+
let N = this._addTriangle(_, D, n[_], -1, -1, r[_]);
|
|
1484
|
+
r[D] = this._legalize(N + 2), r[_] = N, I++;
|
|
1485
|
+
let Y = n[_];
|
|
1486
|
+
for (; B = n[Y], te(Q, p, t[2 * Y], t[2 * Y + 1], t[2 * B], t[2 * B + 1]) < 0; )
|
|
1487
|
+
N = this._addTriangle(Y, D, B, r[D], -1, r[Y]), r[D] = this._legalize(N + 2), n[Y] = Y, I--, Y = B;
|
|
1488
|
+
if (_ === M)
|
|
1489
|
+
for (; B = e[_], te(Q, p, t[2 * B], t[2 * B + 1], t[2 * _], t[2 * _ + 1]) < 0; )
|
|
1490
|
+
N = this._addTriangle(B, D, _, -1, r[_], r[B]), this._legalize(N + 2), r[B] = N, n[_] = _, I--, _ = B;
|
|
1491
|
+
this._hullStart = e[D] = _, n[_] = e[Y] = D, n[D] = Y, i[this._hashKey(Q, p)] = D, i[this._hashKey(t[2 * _], t[2 * _ + 1])] = _;
|
|
1492
|
+
}
|
|
1493
|
+
this.hull = new Uint32Array(I);
|
|
1494
|
+
for (let b = 0, T = this._hullStart; b < I; b++)
|
|
1495
|
+
this.hull[b] = T, T = n[T];
|
|
1496
|
+
this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
|
|
1497
|
+
}
|
|
1498
|
+
_hashKey(t, e) {
|
|
1499
|
+
return Math.floor(Or(t - this._cx, e - this._cy) * this._hashSize) % this._hashSize;
|
|
1500
|
+
}
|
|
1501
|
+
_legalize(t) {
|
|
1502
|
+
const { _triangles: e, _halfedges: n, coords: r } = this;
|
|
1503
|
+
let i = 0, s = 0;
|
|
1504
|
+
for (; ; ) {
|
|
1505
|
+
const a = n[t], c = t - t % 3;
|
|
1506
|
+
if (s = c + (t + 2) % 3, a === -1) {
|
|
1507
|
+
if (i === 0) break;
|
|
1508
|
+
t = Ie[--i];
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1511
|
+
const h = a - a % 3, u = c + (t + 1) % 3, f = h + (a + 2) % 3, d = e[s], y = e[t], E = e[u], k = e[f];
|
|
1512
|
+
if (Ir(
|
|
1513
|
+
r[2 * d],
|
|
1514
|
+
r[2 * d + 1],
|
|
1515
|
+
r[2 * y],
|
|
1516
|
+
r[2 * y + 1],
|
|
1517
|
+
r[2 * E],
|
|
1518
|
+
r[2 * E + 1],
|
|
1519
|
+
r[2 * k],
|
|
1520
|
+
r[2 * k + 1]
|
|
1521
|
+
)) {
|
|
1522
|
+
e[t] = k, e[a] = d;
|
|
1523
|
+
const C = n[f];
|
|
1524
|
+
if (C === -1) {
|
|
1525
|
+
let v = this._hullStart;
|
|
1526
|
+
do {
|
|
1527
|
+
if (this._hullTri[v] === f) {
|
|
1528
|
+
this._hullTri[v] = t;
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
v = this._hullPrev[v];
|
|
1532
|
+
} while (v !== this._hullStart);
|
|
1533
|
+
}
|
|
1534
|
+
this._link(t, C), this._link(a, n[s]), this._link(s, f);
|
|
1535
|
+
const m = h + (a + 1) % 3;
|
|
1536
|
+
i < Ie.length && (Ie[i++] = m);
|
|
1537
|
+
} else {
|
|
1538
|
+
if (i === 0) break;
|
|
1539
|
+
t = Ie[--i];
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
return s;
|
|
1543
|
+
}
|
|
1544
|
+
_link(t, e) {
|
|
1545
|
+
this._halfedges[t] = e, e !== -1 && (this._halfedges[e] = t);
|
|
1546
|
+
}
|
|
1547
|
+
// add a new triangle given vertex indices and adjacent half-edge ids
|
|
1548
|
+
_addTriangle(t, e, n, r, i, s) {
|
|
1549
|
+
const a = this.trianglesLen;
|
|
1550
|
+
return this._triangles[a] = t, this._triangles[a + 1] = e, this._triangles[a + 2] = n, this._link(a, r), this._link(a + 1, i), this._link(a + 2, s), this.trianglesLen += 3, a;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
function Or(o, t) {
|
|
1554
|
+
const e = o / (Math.abs(o) + Math.abs(t));
|
|
1555
|
+
return (t > 0 ? 3 - e : 1 + e) / 4;
|
|
1556
|
+
}
|
|
1557
|
+
function en(o, t, e, n) {
|
|
1558
|
+
const r = o - e, i = t - n;
|
|
1559
|
+
return r * r + i * i;
|
|
1560
|
+
}
|
|
1561
|
+
function Ir(o, t, e, n, r, i, s, a) {
|
|
1562
|
+
const c = o - s, h = t - a, u = e - s, f = n - a, d = r - s, y = i - a, E = c * c + h * h, k = u * u + f * f, X = d * d + y * y;
|
|
1563
|
+
return c * (f * X - k * y) - h * (u * X - k * d) + E * (u * y - f * d) < 0;
|
|
1564
|
+
}
|
|
1565
|
+
function Tr(o, t, e, n, r, i) {
|
|
1566
|
+
const s = e - o, a = n - t, c = r - o, h = i - t, u = s * s + a * a, f = c * c + h * h, d = 0.5 / (s * h - a * c), y = (h * u - a * f) * d, E = (s * f - c * u) * d;
|
|
1567
|
+
return y * y + E * E;
|
|
1568
|
+
}
|
|
1569
|
+
function Nr(o, t, e, n, r, i) {
|
|
1570
|
+
const s = e - o, a = n - t, c = r - o, h = i - t, u = s * s + a * a, f = c * c + h * h, d = 0.5 / (s * h - a * c), y = o + (h * u - a * f) * d, E = t + (s * f - c * u) * d;
|
|
1571
|
+
return { x: y, y: E };
|
|
1572
|
+
}
|
|
1573
|
+
function we(o, t, e, n) {
|
|
1574
|
+
if (n - e <= 20)
|
|
1575
|
+
for (let r = e + 1; r <= n; r++) {
|
|
1576
|
+
const i = o[r], s = t[i];
|
|
1577
|
+
let a = r - 1;
|
|
1578
|
+
for (; a >= e && t[o[a]] > s; ) o[a + 1] = o[a--];
|
|
1579
|
+
o[a + 1] = i;
|
|
1580
|
+
}
|
|
1581
|
+
else {
|
|
1582
|
+
const r = e + n >> 1;
|
|
1583
|
+
let i = e + 1, s = n;
|
|
1584
|
+
_e(o, r, i), t[o[e]] > t[o[n]] && _e(o, e, n), t[o[i]] > t[o[n]] && _e(o, i, n), t[o[e]] > t[o[i]] && _e(o, e, i);
|
|
1585
|
+
const a = o[i], c = t[a];
|
|
1586
|
+
for (; ; ) {
|
|
1587
|
+
do
|
|
1588
|
+
i++;
|
|
1589
|
+
while (t[o[i]] < c);
|
|
1590
|
+
do
|
|
1591
|
+
s--;
|
|
1592
|
+
while (t[o[s]] > c);
|
|
1593
|
+
if (s < i) break;
|
|
1594
|
+
_e(o, i, s);
|
|
1595
|
+
}
|
|
1596
|
+
o[e + 1] = o[s], o[s] = a, n - i + 1 >= s - e ? (we(o, t, i, n), we(o, t, e, s - 1)) : (we(o, t, e, s - 1), we(o, t, i, n));
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
function _e(o, t, e) {
|
|
1600
|
+
const n = o[t];
|
|
1601
|
+
o[t] = o[e], o[e] = n;
|
|
1602
|
+
}
|
|
1603
|
+
function Xr(o) {
|
|
1604
|
+
return o[0];
|
|
1605
|
+
}
|
|
1606
|
+
function Yr(o) {
|
|
1607
|
+
return o[1];
|
|
1608
|
+
}
|
|
1609
|
+
class Rr {
|
|
1610
|
+
bs;
|
|
1611
|
+
width;
|
|
1612
|
+
constructor(t, e) {
|
|
1613
|
+
this.width = t, this.bs = e;
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* Add a number to the set.
|
|
1617
|
+
*
|
|
1618
|
+
* @param idx The number to add. Must be 0 <= idx < len.
|
|
1619
|
+
*/
|
|
1620
|
+
add(t) {
|
|
1621
|
+
const e = Math.floor(t / this.width), n = t % this.width;
|
|
1622
|
+
return this.bs[e] |= 1 << n, this;
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Delete a number from the set.
|
|
1626
|
+
*
|
|
1627
|
+
* @param idx The number to delete. Must be 0 <= idx < len.
|
|
1628
|
+
*/
|
|
1629
|
+
delete(t) {
|
|
1630
|
+
const e = Math.floor(t / this.width), n = t % this.width;
|
|
1631
|
+
return this.bs[e] &= ~(1 << n), this;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Add or delete a number in the set, depending on the second argument.
|
|
1635
|
+
*
|
|
1636
|
+
* @param idx The number to add or delete. Must be 0 <= idx < len.
|
|
1637
|
+
* @param val If true, add the number, otherwise delete.
|
|
1638
|
+
*/
|
|
1639
|
+
set(t, e) {
|
|
1640
|
+
const n = Math.floor(t / this.width), i = 1 << t % this.width;
|
|
1641
|
+
return this.bs[n] ^= (-Number(e) ^ this.bs[n]) & i, e;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Whether the number is in the set.
|
|
1645
|
+
*
|
|
1646
|
+
* @param idx The number to test. Must be 0 <= idx < len.
|
|
1647
|
+
*/
|
|
1648
|
+
has(t) {
|
|
1649
|
+
const e = Math.floor(t / this.width), n = t % this.width;
|
|
1650
|
+
return (this.bs[e] & 1 << n) !== 0;
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Iterate over the numbers that are in the set.
|
|
1654
|
+
*/
|
|
1655
|
+
forEach(t) {
|
|
1656
|
+
const e = this.bs.length;
|
|
1657
|
+
for (let n = 0; n < e; n++) {
|
|
1658
|
+
let r = 0;
|
|
1659
|
+
for (; this.bs[n] && r < this.width; )
|
|
1660
|
+
this.bs[n] & 1 << r && t(n * this.width + r), r++;
|
|
1661
|
+
}
|
|
1662
|
+
return this;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
class xn extends Rr {
|
|
1666
|
+
constructor(t) {
|
|
1667
|
+
super(8, new Uint8Array(Math.ceil(t / 8)).fill(0));
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
function pe(o) {
|
|
1671
|
+
return o % 3 === 2 ? o - 2 : o + 1;
|
|
1672
|
+
}
|
|
1673
|
+
function ee(o) {
|
|
1674
|
+
return o % 3 === 0 ? o + 2 : o - 1;
|
|
1675
|
+
}
|
|
1676
|
+
function Mn(o, t, e, n, r, i, s, a) {
|
|
1677
|
+
const c = te(o, t, r, i, s, a), h = te(e, n, r, i, s, a);
|
|
1678
|
+
if (c > 0 && h > 0 || c < 0 && h < 0)
|
|
1679
|
+
return !1;
|
|
1680
|
+
const u = te(r, i, o, t, e, n), f = te(s, a, o, t, e, n);
|
|
1681
|
+
return u > 0 && f > 0 || u < 0 && f < 0 ? !1 : c === 0 && h === 0 && u === 0 && f === 0 ? !(Math.max(r, s) < Math.min(o, e) || Math.max(o, e) < Math.min(r, s) || Math.max(i, a) < Math.min(t, n) || Math.max(t, n) < Math.min(i, a)) : !0;
|
|
1682
|
+
}
|
|
1683
|
+
class Cr {
|
|
1684
|
+
/**
|
|
1685
|
+
* The triangulation object from Delaunator.
|
|
1686
|
+
*/
|
|
1687
|
+
del;
|
|
1688
|
+
constructor(t) {
|
|
1689
|
+
this.del = t;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
class Fr extends Cr {
|
|
1693
|
+
vertMap;
|
|
1694
|
+
flips;
|
|
1695
|
+
consd;
|
|
1696
|
+
/**
|
|
1697
|
+
* Create a Constrain instance.
|
|
1698
|
+
*
|
|
1699
|
+
* @param del The triangulation output from Delaunator.
|
|
1700
|
+
* @param edges If provided, constrain these edges via constrainAll.
|
|
1701
|
+
*/
|
|
1702
|
+
constructor(t, e) {
|
|
1703
|
+
if (!t || typeof t != "object" || !t.triangles || !t.halfedges || !t.coords)
|
|
1704
|
+
throw new Error("Expected an object with Delaunator output");
|
|
1705
|
+
if (t.triangles.length % 3 || t.halfedges.length !== t.triangles.length || t.coords.length % 2)
|
|
1706
|
+
throw new Error("Delaunator output appears inconsistent");
|
|
1707
|
+
if (t.triangles.length < 3)
|
|
1708
|
+
throw new Error("No edges in triangulation");
|
|
1709
|
+
super(t);
|
|
1710
|
+
const n = 2 ** 32 - 1, r = t.coords.length >> 1, i = t.triangles.length;
|
|
1711
|
+
this.vertMap = new Uint32Array(r).fill(n), this.flips = new xn(i), this.consd = new xn(i);
|
|
1712
|
+
for (let s = 0; s < i; s++) {
|
|
1713
|
+
const a = t.triangles[s];
|
|
1714
|
+
this.vertMap[a] === n && this.updateVert(s);
|
|
1715
|
+
}
|
|
1716
|
+
e && this.constrainAll(e);
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Constrain the triangulation such that there is an edge between p1 and p2.
|
|
1720
|
+
*/
|
|
1721
|
+
constrainOne(t, e) {
|
|
1722
|
+
const { triangles: n, halfedges: r } = this.del, i = this.vertMap[t];
|
|
1723
|
+
let s = i;
|
|
1724
|
+
do {
|
|
1725
|
+
const h = n[s], u = pe(s);
|
|
1726
|
+
if (h === e)
|
|
1727
|
+
return this.protect(s);
|
|
1728
|
+
const f = ee(s), d = n[f];
|
|
1729
|
+
if (d === e)
|
|
1730
|
+
return this.protect(u), u;
|
|
1731
|
+
if (this.intersectSegments(t, e, d, h)) {
|
|
1732
|
+
s = f;
|
|
1733
|
+
break;
|
|
1734
|
+
}
|
|
1735
|
+
s = r[u];
|
|
1736
|
+
} while (s !== -1 && s !== i);
|
|
1737
|
+
let a = s, c = -1;
|
|
1738
|
+
for (; s !== -1; ) {
|
|
1739
|
+
const h = r[s], u = ee(s), f = ee(h), d = pe(h);
|
|
1740
|
+
if (h === -1)
|
|
1741
|
+
throw new Error("Constraining edge exited the hull");
|
|
1742
|
+
if (this.consd.has(s))
|
|
1743
|
+
throw new Error("Edge intersects already constrained edge");
|
|
1744
|
+
if (this.isCollinear(t, e, n[s]) || this.isCollinear(t, e, n[h]))
|
|
1745
|
+
throw new Error("Constraining edge intersects point");
|
|
1746
|
+
if (!this.intersectSegments(
|
|
1747
|
+
n[s],
|
|
1748
|
+
n[h],
|
|
1749
|
+
n[u],
|
|
1750
|
+
n[f]
|
|
1751
|
+
)) {
|
|
1752
|
+
if (c === -1 && (c = s), n[f] === e) {
|
|
1753
|
+
if (s === c)
|
|
1754
|
+
throw new Error("Infinite loop: non-convex quadrilateral");
|
|
1755
|
+
s = c, c = -1;
|
|
1756
|
+
continue;
|
|
1757
|
+
}
|
|
1758
|
+
if (this.intersectSegments(
|
|
1759
|
+
t,
|
|
1760
|
+
e,
|
|
1761
|
+
n[f],
|
|
1762
|
+
n[h]
|
|
1763
|
+
))
|
|
1764
|
+
s = f;
|
|
1765
|
+
else if (this.intersectSegments(
|
|
1766
|
+
t,
|
|
1767
|
+
e,
|
|
1768
|
+
n[d],
|
|
1769
|
+
n[f]
|
|
1770
|
+
))
|
|
1771
|
+
s = d;
|
|
1772
|
+
else if (c === s)
|
|
1773
|
+
throw new Error("Infinite loop: no further intersect after non-convex");
|
|
1774
|
+
continue;
|
|
1775
|
+
}
|
|
1776
|
+
if (this.flipDiagonal(s), this.intersectSegments(
|
|
1777
|
+
t,
|
|
1778
|
+
e,
|
|
1779
|
+
n[u],
|
|
1780
|
+
n[f]
|
|
1781
|
+
) && (c === -1 && (c = u), c === u))
|
|
1782
|
+
throw new Error("Infinite loop: flipped diagonal still intersects");
|
|
1783
|
+
n[f] === e ? (a = f, s = c, c = -1) : this.intersectSegments(
|
|
1784
|
+
t,
|
|
1785
|
+
e,
|
|
1786
|
+
n[d],
|
|
1787
|
+
n[f]
|
|
1788
|
+
) && (s = d);
|
|
1789
|
+
}
|
|
1790
|
+
return this.protect(a), this.delaunify(!0), this.findEdge(t, e);
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Fix the Delaunay condition.
|
|
1794
|
+
*/
|
|
1795
|
+
delaunify(t = !1) {
|
|
1796
|
+
const { halfedges: e } = this.del, n = this.flips, r = this.consd, i = e.length;
|
|
1797
|
+
let s;
|
|
1798
|
+
do {
|
|
1799
|
+
s = 0;
|
|
1800
|
+
for (let a = 0; a < i; a++) {
|
|
1801
|
+
if (r.has(a))
|
|
1802
|
+
continue;
|
|
1803
|
+
n.delete(a);
|
|
1804
|
+
const c = e[a];
|
|
1805
|
+
c !== -1 && (n.delete(c), this.isDelaunay(a) || (this.flipDiagonal(a), s++));
|
|
1806
|
+
}
|
|
1807
|
+
} while (t && s > 0);
|
|
1808
|
+
return this;
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Call constrainOne on each edge.
|
|
1812
|
+
*/
|
|
1813
|
+
constrainAll(t) {
|
|
1814
|
+
const e = t.length;
|
|
1815
|
+
for (let n = 0; n < e; n++) {
|
|
1816
|
+
const r = t[n];
|
|
1817
|
+
this.constrainOne(r[0], r[1]);
|
|
1818
|
+
}
|
|
1819
|
+
return this;
|
|
1820
|
+
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Whether an edge is constrained.
|
|
1823
|
+
*/
|
|
1824
|
+
isConstrained(t) {
|
|
1825
|
+
return this.consd.has(t);
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Find the edge that points from p1 -> p2. If there is only an edge from
|
|
1829
|
+
* p2 -> p1 (i.e. it is on the hull), returns the negative id of it.
|
|
1830
|
+
*/
|
|
1831
|
+
findEdge(t, e) {
|
|
1832
|
+
const n = this.vertMap[e], { triangles: r, halfedges: i } = this.del;
|
|
1833
|
+
let s = n, a = -1;
|
|
1834
|
+
do {
|
|
1835
|
+
if (r[s] === t)
|
|
1836
|
+
return s;
|
|
1837
|
+
a = pe(s), s = i[a];
|
|
1838
|
+
} while (s !== -1 && s !== n);
|
|
1839
|
+
return r[pe(a)] === t ? -a : 1 / 0;
|
|
1840
|
+
}
|
|
1841
|
+
/**
|
|
1842
|
+
* Mark an edge as constrained, i.e. should not be touched by `delaunify`.
|
|
1843
|
+
*/
|
|
1844
|
+
protect(t) {
|
|
1845
|
+
const e = this.del.halfedges[t], n = this.flips, r = this.consd;
|
|
1846
|
+
return n.delete(t), r.add(t), e !== -1 ? (n.delete(e), r.add(e), e) : -t;
|
|
1847
|
+
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Mark an edge as flipped unless constrained.
|
|
1850
|
+
*/
|
|
1851
|
+
markFlip(t) {
|
|
1852
|
+
const e = this.del.halfedges, n = this.flips;
|
|
1853
|
+
if (this.consd.has(t))
|
|
1854
|
+
return !1;
|
|
1855
|
+
const i = e[t];
|
|
1856
|
+
return i !== -1 && (n.add(t), n.add(i)), !0;
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Flip the edge shared by two triangles.
|
|
1860
|
+
*/
|
|
1861
|
+
flipDiagonal(t) {
|
|
1862
|
+
const { triangles: e, halfedges: n } = this.del, r = this.flips, i = this.consd, s = n[t], a = ee(t), c = pe(t), h = ee(s), u = pe(s), f = n[a], d = n[h];
|
|
1863
|
+
if (i.has(t))
|
|
1864
|
+
throw new Error("Trying to flip a constrained edge");
|
|
1865
|
+
return e[t] = e[h], n[t] = d, r.set(t, r.has(h)) || i.set(t, i.has(h)), d !== -1 && (n[d] = t), n[a] = h, e[s] = e[a], n[s] = f, r.set(s, r.has(a)) || i.set(s, i.has(a)), f !== -1 && (n[f] = s), n[h] = a, this.markFlip(t), this.markFlip(c), this.markFlip(s), this.markFlip(u), r.add(a), i.delete(a), r.add(h), i.delete(h), this.updateVert(t), this.updateVert(c), this.updateVert(s), this.updateVert(u), a;
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Whether point p1, p2, and p are collinear.
|
|
1869
|
+
*/
|
|
1870
|
+
isCollinear(t, e, n) {
|
|
1871
|
+
const r = this.del.coords;
|
|
1872
|
+
return te(
|
|
1873
|
+
r[t * 2],
|
|
1874
|
+
r[t * 2 + 1],
|
|
1875
|
+
r[e * 2],
|
|
1876
|
+
r[e * 2 + 1],
|
|
1877
|
+
r[n * 2],
|
|
1878
|
+
r[n * 2 + 1]
|
|
1879
|
+
) === 0;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Whether the triangle formed by p1, p2, p3 keeps px outside the circumcircle.
|
|
1883
|
+
*/
|
|
1884
|
+
inCircle(t, e, n, r) {
|
|
1885
|
+
const i = this.del.coords;
|
|
1886
|
+
return nr(
|
|
1887
|
+
i[t * 2],
|
|
1888
|
+
i[t * 2 + 1],
|
|
1889
|
+
i[e * 2],
|
|
1890
|
+
i[e * 2 + 1],
|
|
1891
|
+
i[n * 2],
|
|
1892
|
+
i[n * 2 + 1],
|
|
1893
|
+
i[r * 2],
|
|
1894
|
+
i[r * 2 + 1]
|
|
1895
|
+
) < 0;
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Whether the triangles sharing edg conform to the Delaunay condition.
|
|
1899
|
+
*/
|
|
1900
|
+
isDelaunay(t) {
|
|
1901
|
+
const { triangles: e, halfedges: n } = this.del, r = n[t];
|
|
1902
|
+
if (r === -1)
|
|
1903
|
+
return !0;
|
|
1904
|
+
const i = e[ee(t)], s = e[t], a = e[pe(t)], c = e[ee(r)];
|
|
1905
|
+
return !this.inCircle(i, s, a, c);
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Update the vertex -> incoming edge map.
|
|
1909
|
+
*/
|
|
1910
|
+
updateVert(t) {
|
|
1911
|
+
const { triangles: e, halfedges: n } = this.del, r = this.vertMap, i = e[t];
|
|
1912
|
+
let s = ee(t), a = n[s];
|
|
1913
|
+
for (; a !== -1 && a !== t; )
|
|
1914
|
+
s = ee(a), a = n[s];
|
|
1915
|
+
return r[i] = s, s;
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* Whether the segments between vertices intersect.
|
|
1919
|
+
*/
|
|
1920
|
+
intersectSegments(t, e, n, r) {
|
|
1921
|
+
const i = this.del.coords;
|
|
1922
|
+
return t === n || t === r || e === n || e === r ? !1 : Mn(
|
|
1923
|
+
i[t * 2],
|
|
1924
|
+
i[t * 2 + 1],
|
|
1925
|
+
i[e * 2],
|
|
1926
|
+
i[e * 2 + 1],
|
|
1927
|
+
i[n * 2],
|
|
1928
|
+
i[n * 2 + 1],
|
|
1929
|
+
i[r * 2],
|
|
1930
|
+
i[r * 2 + 1]
|
|
1931
|
+
);
|
|
1932
|
+
}
|
|
1933
|
+
static intersectSegments = Mn;
|
|
1934
|
+
}
|
|
1935
|
+
function Te(o, t, e) {
|
|
1936
|
+
if (t || (t = []), typeof o != "object" || o.type !== "FeatureCollection")
|
|
1937
|
+
throw "Argument points must be FeatureCollection";
|
|
1938
|
+
if (!Array.isArray(t)) throw "Argument points must be Array of Array";
|
|
1939
|
+
const n = o.features.map(
|
|
1940
|
+
(c) => c.geometry.coordinates
|
|
1941
|
+
), r = sn.from(n);
|
|
1942
|
+
let i;
|
|
1943
|
+
const s = [];
|
|
1944
|
+
r.triangles.length !== 0 && t.length !== 0 && (i = new Fr(r), i.constrainAll(t));
|
|
1945
|
+
for (let c = 0; c < r.triangles.length; c += 3)
|
|
1946
|
+
s.push([r.triangles[c], r.triangles[c + 1], r.triangles[c + 2]]);
|
|
1947
|
+
const a = ["a", "b", "c"];
|
|
1948
|
+
return Kt(
|
|
1949
|
+
s.map((c) => {
|
|
1950
|
+
const h = {}, u = c.map((f, d) => {
|
|
1951
|
+
const y = o.features[f], E = y.geometry.coordinates, k = [E[0], E[1]];
|
|
1952
|
+
return E.length === 3 ? k[2] = E[2] : h[a[d]] = y.properties[e], k;
|
|
1953
|
+
});
|
|
1954
|
+
return u[3] = u[0], Ee([u], h);
|
|
1955
|
+
})
|
|
1956
|
+
);
|
|
1957
|
+
}
|
|
1958
|
+
class Rn {
|
|
1959
|
+
constructor(t = [], e = Lr) {
|
|
1960
|
+
if (this.data = t, this.length = this.data.length, this.compare = e, this.length > 0)
|
|
1961
|
+
for (let n = (this.length >> 1) - 1; n >= 0; n--) this._down(n);
|
|
1962
|
+
}
|
|
1963
|
+
push(t) {
|
|
1964
|
+
this.data.push(t), this.length++, this._up(this.length - 1);
|
|
1965
|
+
}
|
|
1966
|
+
pop() {
|
|
1967
|
+
if (this.length === 0) return;
|
|
1968
|
+
const t = this.data[0], e = this.data.pop();
|
|
1969
|
+
return this.length--, this.length > 0 && (this.data[0] = e, this._down(0)), t;
|
|
1970
|
+
}
|
|
1971
|
+
peek() {
|
|
1972
|
+
return this.data[0];
|
|
1973
|
+
}
|
|
1974
|
+
_up(t) {
|
|
1975
|
+
const { data: e, compare: n } = this, r = e[t];
|
|
1976
|
+
for (; t > 0; ) {
|
|
1977
|
+
const i = t - 1 >> 1, s = e[i];
|
|
1978
|
+
if (n(r, s) >= 0) break;
|
|
1979
|
+
e[t] = s, t = i;
|
|
1980
|
+
}
|
|
1981
|
+
e[t] = r;
|
|
1982
|
+
}
|
|
1983
|
+
_down(t) {
|
|
1984
|
+
const { data: e, compare: n } = this, r = this.length >> 1, i = e[t];
|
|
1985
|
+
for (; t < r; ) {
|
|
1986
|
+
let s = (t << 1) + 1, a = e[s];
|
|
1987
|
+
const c = s + 1;
|
|
1988
|
+
if (c < this.length && n(e[c], a) < 0 && (s = c, a = e[c]), n(a, i) >= 0) break;
|
|
1989
|
+
e[t] = a, t = s;
|
|
1990
|
+
}
|
|
1991
|
+
e[t] = i;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
function Lr(o, t) {
|
|
1995
|
+
return o < t ? -1 : o > t ? 1 : 0;
|
|
1996
|
+
}
|
|
1997
|
+
function Cn(o, t) {
|
|
1998
|
+
return o.p.x > t.p.x ? 1 : o.p.x < t.p.x ? -1 : o.p.y !== t.p.y ? o.p.y > t.p.y ? 1 : -1 : 1;
|
|
1999
|
+
}
|
|
2000
|
+
function Dr(o, t) {
|
|
2001
|
+
return o.rightSweepEvent.p.x > t.rightSweepEvent.p.x ? 1 : o.rightSweepEvent.p.x < t.rightSweepEvent.p.x ? -1 : o.rightSweepEvent.p.y !== t.rightSweepEvent.p.y ? o.rightSweepEvent.p.y < t.rightSweepEvent.p.y ? 1 : -1 : 1;
|
|
2002
|
+
}
|
|
2003
|
+
class kn {
|
|
2004
|
+
constructor(t, e, n, r) {
|
|
2005
|
+
this.p = {
|
|
2006
|
+
x: t[0],
|
|
2007
|
+
y: t[1]
|
|
2008
|
+
}, this.featureId = e, this.ringId = n, this.eventId = r, this.otherEvent = null, this.isLeftEndpoint = null;
|
|
2009
|
+
}
|
|
2010
|
+
isSamePoint(t) {
|
|
2011
|
+
return this.p.x === t.p.x && this.p.y === t.p.y;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
function $r(o, t) {
|
|
2015
|
+
if (o.type === "FeatureCollection") {
|
|
2016
|
+
const e = o.features;
|
|
2017
|
+
for (let n = 0; n < e.length; n++)
|
|
2018
|
+
Sn(e[n], t);
|
|
2019
|
+
} else
|
|
2020
|
+
Sn(o, t);
|
|
2021
|
+
}
|
|
2022
|
+
let Ne = 0, Xe = 0, Ye = 0;
|
|
2023
|
+
function Sn(o, t) {
|
|
2024
|
+
const e = o.type === "Feature" ? o.geometry : o;
|
|
2025
|
+
let n = e.coordinates;
|
|
2026
|
+
(e.type === "Polygon" || e.type === "MultiLineString") && (n = [n]), e.type === "LineString" && (n = [[n]]);
|
|
2027
|
+
for (let r = 0; r < n.length; r++)
|
|
2028
|
+
for (let i = 0; i < n[r].length; i++) {
|
|
2029
|
+
let s = n[r][i][0], a = null;
|
|
2030
|
+
Xe = Xe + 1;
|
|
2031
|
+
for (let c = 0; c < n[r][i].length - 1; c++) {
|
|
2032
|
+
a = n[r][i][c + 1];
|
|
2033
|
+
const h = new kn(s, Ne, Xe, Ye), u = new kn(a, Ne, Xe, Ye + 1);
|
|
2034
|
+
h.otherEvent = u, u.otherEvent = h, Cn(h, u) > 0 ? (u.isLeftEndpoint = !0, h.isLeftEndpoint = !1) : (h.isLeftEndpoint = !0, u.isLeftEndpoint = !1), t.push(h), t.push(u), s = a, Ye = Ye + 1;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
Ne = Ne + 1;
|
|
2038
|
+
}
|
|
2039
|
+
class qr {
|
|
2040
|
+
constructor(t) {
|
|
2041
|
+
this.leftSweepEvent = t, this.rightSweepEvent = t.otherEvent;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
function Ur(o, t) {
|
|
2045
|
+
if (o === null || t === null || o.leftSweepEvent.ringId === t.leftSweepEvent.ringId && (o.rightSweepEvent.isSamePoint(t.leftSweepEvent) || o.rightSweepEvent.isSamePoint(t.leftSweepEvent) || o.rightSweepEvent.isSamePoint(t.rightSweepEvent) || o.leftSweepEvent.isSamePoint(t.leftSweepEvent) || o.leftSweepEvent.isSamePoint(t.rightSweepEvent))) return !1;
|
|
2046
|
+
const e = o.leftSweepEvent.p.x, n = o.leftSweepEvent.p.y, r = o.rightSweepEvent.p.x, i = o.rightSweepEvent.p.y, s = t.leftSweepEvent.p.x, a = t.leftSweepEvent.p.y, c = t.rightSweepEvent.p.x, h = t.rightSweepEvent.p.y, u = (h - a) * (r - e) - (c - s) * (i - n), f = (c - s) * (n - a) - (h - a) * (e - s), d = (r - e) * (n - a) - (i - n) * (e - s);
|
|
2047
|
+
if (u === 0)
|
|
2048
|
+
return !1;
|
|
2049
|
+
const y = f / u, E = d / u;
|
|
2050
|
+
if (y >= 0 && y <= 1 && E >= 0 && E <= 1) {
|
|
2051
|
+
const k = e + y * (r - e), X = n + y * (i - n);
|
|
2052
|
+
return [k, X];
|
|
2053
|
+
}
|
|
2054
|
+
return !1;
|
|
2055
|
+
}
|
|
2056
|
+
function jr(o, t) {
|
|
2057
|
+
t = t || !1;
|
|
2058
|
+
const e = [], n = new Rn([], Dr);
|
|
2059
|
+
for (; o.length; ) {
|
|
2060
|
+
const r = o.pop();
|
|
2061
|
+
if (r.isLeftEndpoint) {
|
|
2062
|
+
const i = new qr(r);
|
|
2063
|
+
for (let s = 0; s < n.data.length; s++) {
|
|
2064
|
+
const a = n.data[s];
|
|
2065
|
+
if (t && a.leftSweepEvent.featureId === r.featureId)
|
|
2066
|
+
continue;
|
|
2067
|
+
const c = Ur(i, a);
|
|
2068
|
+
c !== !1 && e.push(c);
|
|
2069
|
+
}
|
|
2070
|
+
n.push(i);
|
|
2071
|
+
} else r.isLeftEndpoint === !1 && n.pop();
|
|
2072
|
+
}
|
|
2073
|
+
return e;
|
|
2074
|
+
}
|
|
2075
|
+
function zr(o, t) {
|
|
2076
|
+
const e = new Rn([], Cn);
|
|
2077
|
+
return $r(o, e), jr(e, t);
|
|
2078
|
+
}
|
|
2079
|
+
var Vr = zr;
|
|
2080
|
+
function Wr(o, t, e = {}) {
|
|
2081
|
+
const { removeDuplicates: n = !0, ignoreSelfIntersections: r = !0 } = e;
|
|
2082
|
+
let i = [];
|
|
2083
|
+
o.type === "FeatureCollection" ? i = i.concat(o.features) : o.type === "Feature" ? i.push(o) : (o.type === "LineString" || o.type === "Polygon" || o.type === "MultiLineString" || o.type === "MultiPolygon") && i.push(Se(o)), t.type === "FeatureCollection" ? i = i.concat(t.features) : t.type === "Feature" ? i.push(t) : (t.type === "LineString" || t.type === "Polygon" || t.type === "MultiLineString" || t.type === "MultiPolygon") && i.push(Se(t));
|
|
2084
|
+
const s = Vr(
|
|
2085
|
+
Kt(i),
|
|
2086
|
+
r
|
|
2087
|
+
);
|
|
2088
|
+
let a = [];
|
|
2089
|
+
if (n) {
|
|
2090
|
+
const c = {};
|
|
2091
|
+
s.forEach((h) => {
|
|
2092
|
+
const u = h.join(",");
|
|
2093
|
+
c[u] || (c[u] = !0, a.push(h));
|
|
2094
|
+
});
|
|
2095
|
+
} else
|
|
2096
|
+
a = s;
|
|
2097
|
+
return Kt(a.map((c) => de(c)));
|
|
2098
|
+
}
|
|
2099
|
+
var Jr = Wr;
|
|
2100
|
+
function Fn(o, t, e, n, r, i) {
|
|
2101
|
+
return Object.keys(o).reduce((s, a) => {
|
|
2102
|
+
const c = o[a], h = c.forw, u = c.bakw, f = {
|
|
2103
|
+
forw: [h[0] - t.forw[0], h[1] - t.forw[1]],
|
|
2104
|
+
bakw: [u[0] - t.bakw[0], u[1] - t.bakw[1]]
|
|
2105
|
+
}, d = f.forw[0] === 0 ? 1 / 0 : ((f.forw[0] < 0 ? e : n) - t.forw[0]) / f.forw[0], y = f.forw[1] === 0 ? 1 / 0 : ((f.forw[1] < 0 ? r : i) - t.forw[1]) / f.forw[1];
|
|
2106
|
+
if (Math.abs(d) / Math.abs(y) < 1.1) {
|
|
2107
|
+
const E = {
|
|
2108
|
+
forw: [
|
|
2109
|
+
f.forw[0] * d + t.forw[0],
|
|
2110
|
+
f.forw[1] * d + t.forw[1]
|
|
2111
|
+
],
|
|
2112
|
+
bakw: [
|
|
2113
|
+
f.bakw[0] * d + t.bakw[0],
|
|
2114
|
+
f.bakw[1] * d + t.bakw[1]
|
|
2115
|
+
]
|
|
2116
|
+
};
|
|
2117
|
+
f.forw[0] < 0 ? s[3].push(E) : s[1].push(E);
|
|
2118
|
+
}
|
|
2119
|
+
if (Math.abs(y) / Math.abs(d) < 1.1) {
|
|
2120
|
+
const E = {
|
|
2121
|
+
forw: [
|
|
2122
|
+
f.forw[0] * y + t.forw[0],
|
|
2123
|
+
f.forw[1] * y + t.forw[1]
|
|
2124
|
+
],
|
|
2125
|
+
bakw: [
|
|
2126
|
+
f.bakw[0] * y + t.bakw[0],
|
|
2127
|
+
f.bakw[1] * y + t.bakw[1]
|
|
2128
|
+
]
|
|
2129
|
+
};
|
|
2130
|
+
f.forw[1] < 0 ? s[0].push(E) : s[2].push(E);
|
|
2131
|
+
}
|
|
2132
|
+
return s;
|
|
2133
|
+
}, [[], [], [], []]);
|
|
2134
|
+
}
|
|
2135
|
+
function Kr(o, t) {
|
|
2136
|
+
const e = [[], [], [], []], n = [];
|
|
2137
|
+
return Object.keys(o).forEach((r) => {
|
|
2138
|
+
const i = o[r], s = i.forw, a = i.bakw, c = [
|
|
2139
|
+
s[0] - t.forw[0],
|
|
2140
|
+
s[1] - t.forw[1]
|
|
2141
|
+
], h = [
|
|
2142
|
+
a[0] - t.bakw[0],
|
|
2143
|
+
t.bakw[1] - a[1]
|
|
2144
|
+
], u = { forw: c, bakw: h };
|
|
2145
|
+
if (n.push(u), c[0] === 0 || c[1] === 0)
|
|
2146
|
+
return;
|
|
2147
|
+
let f = 0;
|
|
2148
|
+
c[0] > 0 && (f += 1), c[1] > 0 && (f += 2), e[f].push(u);
|
|
2149
|
+
}), { perQuad: e, aggregate: n };
|
|
2150
|
+
}
|
|
2151
|
+
function Gr(o) {
|
|
2152
|
+
let t = 1 / 0, e = 0, n = 0;
|
|
2153
|
+
return o.forEach((r) => {
|
|
2154
|
+
const { forw: i, bakw: s } = r, a = Math.hypot(i[0], i[1]), c = Math.hypot(s[0], s[1]);
|
|
2155
|
+
if (c === 0) return;
|
|
2156
|
+
const h = a / c, u = Math.atan2(i[0], i[1]) - Math.atan2(s[0], s[1]);
|
|
2157
|
+
t = Math.min(t, h), e += Math.cos(u), n += Math.sin(u);
|
|
2158
|
+
}), isFinite(t) ? [t, Math.atan2(n, e)] : [1, 0];
|
|
2159
|
+
}
|
|
2160
|
+
function Ln(o, t, e) {
|
|
2161
|
+
const { perQuad: n, aggregate: r } = Kr(o, t), i = n.every((c) => c.length > 0), a = (e === "birdeye" ? i ? n : [r] : [r]).map((c) => Gr(c));
|
|
2162
|
+
return a.length === 1 ? [a[0], a[0], a[0], a[0]] : a;
|
|
2163
|
+
}
|
|
2164
|
+
function Qr(o, t, e) {
|
|
2165
|
+
const n = [1, 1, 1, 1];
|
|
2166
|
+
for (let r = 0; r < 4; r++) {
|
|
2167
|
+
const i = (r + 1) % 4, s = un([o[r].bakw, o[i].bakw]);
|
|
2168
|
+
t[r].map((a) => {
|
|
2169
|
+
const c = un([e.bakw, a.bakw]), h = Jr(s, c);
|
|
2170
|
+
if (h.features.length > 0 && h.features[0].geometry) {
|
|
2171
|
+
const u = h.features[0], f = Math.sqrt(
|
|
2172
|
+
Math.pow(a.bakw[0] - e.bakw[0], 2) + Math.pow(a.bakw[1] - e.bakw[1], 2)
|
|
2173
|
+
), d = Math.sqrt(
|
|
2174
|
+
Math.pow(
|
|
2175
|
+
u.geometry.coordinates[0] - e.bakw[0],
|
|
2176
|
+
2
|
|
2177
|
+
) + Math.pow(
|
|
2178
|
+
u.geometry.coordinates[1] - e.bakw[1],
|
|
2179
|
+
2
|
|
2180
|
+
)
|
|
2181
|
+
), y = f / d;
|
|
2182
|
+
y > n[r] && (n[r] = y), y > n[i] && (n[i] = y);
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
o.forEach((r, i) => {
|
|
2187
|
+
const s = n[i], a = [
|
|
2188
|
+
(r.bakw[0] - e.bakw[0]) * s + e.bakw[0],
|
|
2189
|
+
(r.bakw[1] - e.bakw[1]) * s + e.bakw[1]
|
|
2190
|
+
];
|
|
2191
|
+
r.bakw = a;
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
function Dn(o, t, e, n) {
|
|
2195
|
+
const r = o.map((s, a) => {
|
|
2196
|
+
const c = t[a], h = [
|
|
2197
|
+
c[0] - e.forw[0],
|
|
2198
|
+
c[1] - e.forw[1]
|
|
2199
|
+
], f = Math.sqrt(
|
|
2200
|
+
Math.pow(h[0], 2) + Math.pow(h[1], 2)
|
|
2201
|
+
) / s[0], d = Math.atan2(h[0], h[1]) - s[1], y = [
|
|
2202
|
+
e.bakw[0] + f * Math.sin(d),
|
|
2203
|
+
e.bakw[1] - f * Math.cos(d)
|
|
2204
|
+
];
|
|
2205
|
+
return { forw: c, bakw: y };
|
|
2206
|
+
}), i = r[2];
|
|
2207
|
+
return r[2] = r[3], r[3] = i, Qr(r, n, e), r;
|
|
2208
|
+
}
|
|
2209
|
+
function Hr(o) {
|
|
2210
|
+
const { convexBuf: t, centroid: e, bbox: n, minx: r, maxx: i, miny: s, maxy: a } = o, c = Fn(t, e, r, i, s, a), h = Ln(t, e, "plain");
|
|
2211
|
+
return Dn(h, n, e, c);
|
|
2212
|
+
}
|
|
2213
|
+
function Zr(o) {
|
|
2214
|
+
const { convexBuf: t, centroid: e, bbox: n, minx: r, maxx: i, miny: s, maxy: a } = o, c = Fn(t, e, r, i, s, a), h = Ln(t, e, "birdeye");
|
|
2215
|
+
return Dn(h, n, e, c);
|
|
2216
|
+
}
|
|
2217
|
+
function ti(o) {
|
|
2218
|
+
const e = new ei(o).findSegmentIntersections(), n = Un(e), r = /* @__PURE__ */ new Map();
|
|
2219
|
+
return n.forEach((i) => {
|
|
2220
|
+
r.set(`${i.x}:${i.y}`, i);
|
|
2221
|
+
}), Array.from(r.values()).map(
|
|
2222
|
+
(i) => de([i.x, i.y])
|
|
2223
|
+
);
|
|
2224
|
+
}
|
|
2225
|
+
class ei {
|
|
2226
|
+
/**
|
|
2227
|
+
* 座標データの配列
|
|
2228
|
+
* _xx, _yy: Float64Array形式で座標を保持
|
|
2229
|
+
* _ii: 各線分の開始インデックス
|
|
2230
|
+
* _nn: 各線分の頂点数
|
|
2231
|
+
*/
|
|
2232
|
+
_xx;
|
|
2233
|
+
_yy;
|
|
2234
|
+
// coordinates data
|
|
2235
|
+
_ii;
|
|
2236
|
+
_nn;
|
|
2237
|
+
// indexes, sizes
|
|
2238
|
+
_zz;
|
|
2239
|
+
_zlimit = 0;
|
|
2240
|
+
// simplification
|
|
2241
|
+
_bb;
|
|
2242
|
+
_allBounds;
|
|
2243
|
+
// bounding boxes
|
|
2244
|
+
_arcIter;
|
|
2245
|
+
_filteredArcIter;
|
|
2246
|
+
// path iterators
|
|
2247
|
+
buf;
|
|
2248
|
+
/**
|
|
2249
|
+
* 線分群からArcCollectionを初期化
|
|
2250
|
+
* @param coords - 線分群の座標配列
|
|
2251
|
+
*/
|
|
2252
|
+
constructor(t) {
|
|
2253
|
+
this.initArcs(t);
|
|
2254
|
+
}
|
|
2255
|
+
initArcs(t) {
|
|
2256
|
+
const e = [], n = [], r = t.map((i) => {
|
|
2257
|
+
const s = i ? i.length : 0;
|
|
2258
|
+
for (let a = 0; a < s; a++)
|
|
2259
|
+
e.push(i[a][0]), n.push(i[a][1]);
|
|
2260
|
+
return s;
|
|
2261
|
+
});
|
|
2262
|
+
this.initXYData(r, e, n);
|
|
2263
|
+
}
|
|
2264
|
+
initXYData(t, e, n) {
|
|
2265
|
+
const r = t.length;
|
|
2266
|
+
this._xx = new Float64Array(e), this._yy = new Float64Array(n), this._nn = new Uint32Array(t), this._zz = null, this._zlimit = 0, this._filteredArcIter = null, this._ii = new Uint32Array(r);
|
|
2267
|
+
let i = 0;
|
|
2268
|
+
for (let s = 0; s < r; s++)
|
|
2269
|
+
this._ii[s] = i, i += t[s];
|
|
2270
|
+
(i != this._xx.length || this._xx.length != this._yy.length) && on("ArcCollection#initXYData() Counting error"), this.initBounds(), this._arcIter = new _i(this._xx, this._yy);
|
|
2271
|
+
}
|
|
2272
|
+
initBounds() {
|
|
2273
|
+
const t = this.calcArcBounds_(this._xx, this._yy, this._nn);
|
|
2274
|
+
this._bb = t.bb, this._allBounds = t.bounds;
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* データの境界を計算
|
|
2278
|
+
* @returns バウンディングボックス情報
|
|
2279
|
+
*/
|
|
2280
|
+
calcArcBounds_(t, e, n) {
|
|
2281
|
+
const r = n.length, i = new Float64Array(r * 4), s = new qe();
|
|
2282
|
+
let a = 0, c, h, u;
|
|
2283
|
+
for (let f = 0; f < r; f++)
|
|
2284
|
+
c = n[f], c > 0 && (h = f * 4, u = xi(t, e, a, c), i[h++] = u[0], i[h++] = u[1], i[h++] = u[2], i[h] = u[3], a += c, s.mergeBounds(u));
|
|
2285
|
+
return {
|
|
2286
|
+
bb: i,
|
|
2287
|
+
bounds: s
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
getBounds() {
|
|
2291
|
+
return this._allBounds.clone();
|
|
2292
|
+
}
|
|
2293
|
+
// @cb function(i, j, xx, yy)
|
|
2294
|
+
forEachSegment(t) {
|
|
2295
|
+
let e = 0;
|
|
2296
|
+
for (let n = 0, r = this.size(); n < r; n++)
|
|
2297
|
+
e += this.forEachArcSegment(n, t);
|
|
2298
|
+
return e;
|
|
2299
|
+
}
|
|
2300
|
+
size() {
|
|
2301
|
+
return this._ii && this._ii.length || 0;
|
|
2302
|
+
}
|
|
2303
|
+
// @cb function(i, j, xx, yy)
|
|
2304
|
+
forEachArcSegment(t, e) {
|
|
2305
|
+
const n = t >= 0, r = n ? t : ~t, i = this.getRetainedInterval(), s = this._nn[r], a = n ? 1 : -1;
|
|
2306
|
+
let c = n ? this._ii[r] : this._ii[r] + s - 1, h = c, u = 0;
|
|
2307
|
+
for (let f = 1; f < s; f++)
|
|
2308
|
+
h += a, (i === 0 || this._zz[h] >= i) && (e(c, h, this._xx, this._yy), c = h, u++);
|
|
2309
|
+
return u;
|
|
2310
|
+
}
|
|
2311
|
+
getRetainedInterval() {
|
|
2312
|
+
return this._zlimit;
|
|
2313
|
+
}
|
|
2314
|
+
// Give access to raw data arrays...
|
|
2315
|
+
getVertexData() {
|
|
2316
|
+
return {
|
|
2317
|
+
xx: this._xx,
|
|
2318
|
+
yy: this._yy,
|
|
2319
|
+
zz: this._zz,
|
|
2320
|
+
bb: this._bb,
|
|
2321
|
+
nn: this._nn,
|
|
2322
|
+
ii: this._ii
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
getUint32Array(t) {
|
|
2326
|
+
const e = t * 4;
|
|
2327
|
+
return (!this.buf || this.buf.byteLength < e) && (this.buf = new ArrayBuffer(e)), new Uint32Array(this.buf, 0, t);
|
|
2328
|
+
}
|
|
2329
|
+
// Return average magnitudes of dx, dy (with simplification)
|
|
2330
|
+
getAvgSegment2() {
|
|
2331
|
+
let t = 0, e = 0;
|
|
2332
|
+
const n = this.forEachSegment(
|
|
2333
|
+
(r, i, s, a) => {
|
|
2334
|
+
t += Math.abs(s[r] - s[i]), e += Math.abs(a[r] - a[i]);
|
|
2335
|
+
}
|
|
2336
|
+
);
|
|
2337
|
+
return [t / n || 0, e / n || 0];
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* 交差判定のためのストライプ数を計算
|
|
2341
|
+
* 線分の平均長さに基づいて最適な分割数を決定
|
|
2342
|
+
*/
|
|
2343
|
+
calcSegmentIntersectionStripeCount() {
|
|
2344
|
+
const t = this.getBounds().height(), e = this.getAvgSegment2()[1];
|
|
2345
|
+
let n = 1;
|
|
2346
|
+
return e > 0 && t > 0 && (n = Math.ceil(t / e / 20)), n || 1;
|
|
2347
|
+
}
|
|
2348
|
+
/**
|
|
2349
|
+
* 線分の交差を検出
|
|
2350
|
+
* ストライプ分割による効率的な判定を実装
|
|
2351
|
+
*
|
|
2352
|
+
* @returns 検出された交差点の配列
|
|
2353
|
+
*/
|
|
2354
|
+
findSegmentIntersections() {
|
|
2355
|
+
const t = this.getBounds(), e = t.ymin, n = t.ymax - e, r = this.calcSegmentIntersectionStripeCount(), i = new Uint32Array(r), s = r > 1 ? (k) => Math.floor((r - 1) * (k - e) / n) : () => 0;
|
|
2356
|
+
let a, c;
|
|
2357
|
+
this.forEachSegment(
|
|
2358
|
+
(k, X, C, m) => {
|
|
2359
|
+
let v = s(m[k]);
|
|
2360
|
+
const l = s(m[X]);
|
|
2361
|
+
for (; i[v] = i[v] + 2, v != l; )
|
|
2362
|
+
v += l > v ? 1 : -1;
|
|
2363
|
+
}
|
|
2364
|
+
);
|
|
2365
|
+
const h = this.getUint32Array(ii(i));
|
|
2366
|
+
let u = 0;
|
|
2367
|
+
const f = [];
|
|
2368
|
+
si(i, (k) => {
|
|
2369
|
+
const X = u;
|
|
2370
|
+
u += k, f.push(h.subarray(X, u));
|
|
2371
|
+
}), oi(i, 0), this.forEachSegment(
|
|
2372
|
+
(k, X, C, m) => {
|
|
2373
|
+
let v = s(m[k]);
|
|
2374
|
+
const l = s(m[X]);
|
|
2375
|
+
let g, x;
|
|
2376
|
+
for (; g = i[v], i[v] = g + 2, x = f[v], x[g] = k, x[g + 1] = X, v != l; )
|
|
2377
|
+
v += l > v ? 1 : -1;
|
|
2378
|
+
}
|
|
2379
|
+
);
|
|
2380
|
+
const d = this.getVertexData(), y = [];
|
|
2381
|
+
let E;
|
|
2382
|
+
for (a = 0; a < r; a++)
|
|
2383
|
+
for (E = ai(f[a], d.xx, d.yy), c = 0; c < E.length; c++)
|
|
2384
|
+
y.push(E[c]);
|
|
2385
|
+
return Un(y);
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
function on(...o) {
|
|
2389
|
+
const t = o.join(" ");
|
|
2390
|
+
throw new Error(t);
|
|
2391
|
+
}
|
|
2392
|
+
function an(o) {
|
|
2393
|
+
return o ? ri(o) ? !0 : ni(o) ? !1 : o.length === 0 ? !0 : o.length > 0 : !1;
|
|
2394
|
+
}
|
|
2395
|
+
function ni(o) {
|
|
2396
|
+
return o != null && o.toString === String.prototype.toString;
|
|
2397
|
+
}
|
|
2398
|
+
function ri(o) {
|
|
2399
|
+
return Array.isArray(o);
|
|
2400
|
+
}
|
|
2401
|
+
function ii(o, t) {
|
|
2402
|
+
an(o) || on("utils.sum() expects an array, received:", o);
|
|
2403
|
+
let e = 0, n;
|
|
2404
|
+
for (let r = 0, i = o.length; r < i; r++)
|
|
2405
|
+
n = o[r], n && (e += n);
|
|
2406
|
+
return e;
|
|
2407
|
+
}
|
|
2408
|
+
function si(o, t, e) {
|
|
2409
|
+
if (!an(o))
|
|
2410
|
+
throw new Error(`#forEach() takes an array-like argument. ${o}`);
|
|
2411
|
+
for (let n = 0, r = o.length; n < r; n++)
|
|
2412
|
+
t.call(e, o[n], n);
|
|
2413
|
+
}
|
|
2414
|
+
function oi(o, t) {
|
|
2415
|
+
for (let e = 0, n = o.length; e < n; e++)
|
|
2416
|
+
o[e] = t;
|
|
2417
|
+
return o;
|
|
2418
|
+
}
|
|
2419
|
+
function ai(o, t, e) {
|
|
2420
|
+
const n = o.length - 2, r = [];
|
|
2421
|
+
let i, s, a, c, h, u, f, d, y, E, k, X, C, m, v, l, g;
|
|
2422
|
+
for (wi(t, o), l = 0; l < n; ) {
|
|
2423
|
+
for (i = o[l], s = o[l + 1], h = t[i], u = t[s], y = e[i], E = e[s], g = l; g < n && (g += 2, a = o[g], f = t[a], !(u < f)); ) {
|
|
2424
|
+
if (k = e[a], c = o[g + 1], d = t[c], X = e[c], y >= k) {
|
|
2425
|
+
if (y > X && E > k && E > X) continue;
|
|
2426
|
+
} else if (y < X && E < k && E < X) continue;
|
|
2427
|
+
i == a || i == c || s == a || s == c || (C = ci(
|
|
2428
|
+
h,
|
|
2429
|
+
y,
|
|
2430
|
+
u,
|
|
2431
|
+
E,
|
|
2432
|
+
f,
|
|
2433
|
+
k,
|
|
2434
|
+
d,
|
|
2435
|
+
X
|
|
2436
|
+
), C && (m = [i, s], v = [a, c], r.push(An(C, m, v, t, e)), C.length == 4 && r.push(
|
|
2437
|
+
An(C.slice(2), m, v, t, e)
|
|
2438
|
+
)));
|
|
2439
|
+
}
|
|
2440
|
+
l += 2;
|
|
2441
|
+
}
|
|
2442
|
+
return r;
|
|
2443
|
+
}
|
|
2444
|
+
function ci(o, t, e, n, r, i, s, a) {
|
|
2445
|
+
const c = hi(o, t, e, n, r, i, s, a);
|
|
2446
|
+
let h = null;
|
|
2447
|
+
return c && (h = fi(o, t, e, n, r, i, s, a), h ? gi(o, t, e, n, r, i, s, a) && (h = null) : h = mi(o, t, e, n, r, i, s, a)), h;
|
|
2448
|
+
}
|
|
2449
|
+
function hi(o, t, e, n, r, i, s, a) {
|
|
2450
|
+
return ke(o, t, e, n, r, i) * ke(o, t, e, n, s, a) <= 0 && ke(r, i, s, a, o, t) * ke(r, i, s, a, e, n) <= 0;
|
|
2451
|
+
}
|
|
2452
|
+
function ke(o, t, e, n, r, i) {
|
|
2453
|
+
return $n(o - r, t - i, e - r, n - i);
|
|
2454
|
+
}
|
|
2455
|
+
function $n(o, t, e, n) {
|
|
2456
|
+
return o * n - t * e;
|
|
2457
|
+
}
|
|
2458
|
+
function fi(o, t, e, n, r, i, s, a) {
|
|
2459
|
+
let c = Re(o, t, e, n, r, i, s, a), h;
|
|
2460
|
+
return c && (h = li(c[0], c[1], o, t, e, n, r, i, s, a), h == 1 ? c = Re(e, n, o, t, r, i, s, a) : h == 2 ? c = Re(r, i, s, a, o, t, e, n) : h == 3 && (c = Re(s, a, r, i, o, t, e, n))), c && di(c, o, t, e, n, r, i, s, a), c;
|
|
2461
|
+
}
|
|
2462
|
+
function Re(o, t, e, n, r, i, s, a) {
|
|
2463
|
+
const c = $n(e - o, n - t, s - r, a - i), h = 1e-18;
|
|
2464
|
+
let u;
|
|
2465
|
+
if (c === 0) return null;
|
|
2466
|
+
const f = ke(r, i, s, a, o, t) / c;
|
|
2467
|
+
return c <= h && c >= -h ? u = ui(o, t, e, n, r, i, s, a) : u = [o + f * (e - o), t + f * (n - t)], u;
|
|
2468
|
+
}
|
|
2469
|
+
function ui(o, t, e, n, r, i, s, a) {
|
|
2470
|
+
let c = null;
|
|
2471
|
+
return !ne(o, r, s) && !ne(t, i, a) ? c = [o, t] : !ne(e, r, s) && !ne(n, i, a) ? c = [e, n] : !ne(r, o, e) && !ne(i, t, n) ? c = [r, i] : !ne(s, o, e) && !ne(a, t, n) && (c = [s, a]), c;
|
|
2472
|
+
}
|
|
2473
|
+
function ne(o, t, e) {
|
|
2474
|
+
let n;
|
|
2475
|
+
return t < e ? n = o < t || o > e : t > e ? n = o > t || o < e : n = o != t, n;
|
|
2476
|
+
}
|
|
2477
|
+
function li(o, t, ...e) {
|
|
2478
|
+
let n = -1, r = 1 / 0, i;
|
|
2479
|
+
for (let s = 0, a = 0, c = e.length; a < c; s++, a += 2)
|
|
2480
|
+
i = pi(o, t, e[a], e[a + 1]), i < r && (r = i, n = s);
|
|
2481
|
+
return n;
|
|
2482
|
+
}
|
|
2483
|
+
function pi(o, t, e, n) {
|
|
2484
|
+
const r = o - e, i = t - n;
|
|
2485
|
+
return r * r + i * i;
|
|
2486
|
+
}
|
|
2487
|
+
function di(o, t, e, n, r, i, s, a, c) {
|
|
2488
|
+
let h = o[0], u = o[1];
|
|
2489
|
+
h = Ce(h, t, n), h = Ce(h, i, a), u = Ce(u, e, r), u = Ce(u, s, c), o[0] = h, o[1] = u;
|
|
2490
|
+
}
|
|
2491
|
+
function Ce(o, t, e) {
|
|
2492
|
+
let n;
|
|
2493
|
+
return ne(o, t, e) && (n = Math.abs(o - t) < Math.abs(o - e) ? t : e, o = n), o;
|
|
2494
|
+
}
|
|
2495
|
+
function mi(o, t, e, n, r, i, s, a) {
|
|
2496
|
+
const c = Math.min(o, e, r, s), h = Math.max(o, e, r, s), u = Math.min(t, n, i, a), f = Math.max(t, n, i, a), d = f - u > h - c;
|
|
2497
|
+
let y = [];
|
|
2498
|
+
return (d ? ae(t, u, f) : ae(o, c, h)) && y.push(o, t), (d ? ae(n, u, f) : ae(e, c, h)) && y.push(e, n), (d ? ae(i, u, f) : ae(r, c, h)) && y.push(r, i), (d ? ae(a, u, f) : ae(s, c, h)) && y.push(s, a), (y.length != 2 && y.length != 4 || y.length == 4 && y[0] == y[2] && y[1] == y[3]) && (y = null), y;
|
|
2499
|
+
}
|
|
2500
|
+
function gi(o, t, e, n, r, i, s, a) {
|
|
2501
|
+
return o == r && t == i || o == s && t == a || e == r && n == i || e == s && n == a;
|
|
2502
|
+
}
|
|
2503
|
+
function ae(o, t, e) {
|
|
2504
|
+
return o > t && o < e;
|
|
2505
|
+
}
|
|
2506
|
+
function wi(o, t) {
|
|
2507
|
+
yi(o, t), qn(o, t, 0, t.length - 2);
|
|
2508
|
+
}
|
|
2509
|
+
function yi(o, t) {
|
|
2510
|
+
for (let e = 0, n = t.length; e < n; e += 2)
|
|
2511
|
+
o[t[e]] > o[t[e + 1]] && vi(t, e, e + 1);
|
|
2512
|
+
}
|
|
2513
|
+
function vi(o, t, e) {
|
|
2514
|
+
const n = o[t];
|
|
2515
|
+
o[t] = o[e], o[e] = n;
|
|
2516
|
+
}
|
|
2517
|
+
function qn(o, t, e, n) {
|
|
2518
|
+
let r = e, i = n, s, a;
|
|
2519
|
+
for (; r < n; ) {
|
|
2520
|
+
for (s = o[t[e + n >> 2 << 1]]; r <= i; ) {
|
|
2521
|
+
for (; o[t[r]] < s; ) r += 2;
|
|
2522
|
+
for (; o[t[i]] > s; ) i -= 2;
|
|
2523
|
+
r <= i && (a = t[r], t[r] = t[i], t[i] = a, a = t[r + 1], t[r + 1] = t[i + 1], t[i + 1] = a, r += 2, i -= 2);
|
|
2524
|
+
}
|
|
2525
|
+
if (i - e < 40 ? En(o, t, e, i) : qn(o, t, e, i), n - r < 40) {
|
|
2526
|
+
En(o, t, r, n);
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2529
|
+
e = r, i = n;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
function En(o, t, e, n) {
|
|
2533
|
+
let r, i;
|
|
2534
|
+
for (let s = e + 2; s <= n; s += 2) {
|
|
2535
|
+
r = t[s], i = t[s + 1];
|
|
2536
|
+
let a;
|
|
2537
|
+
for (a = s - 2; a >= e && o[r] < o[t[a]]; a -= 2)
|
|
2538
|
+
t[a + 2] = t[a], t[a + 3] = t[a + 1];
|
|
2539
|
+
t[a + 2] = r, t[a + 3] = i;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
function An(o, t, e, n, r) {
|
|
2543
|
+
const i = o[0], s = o[1];
|
|
2544
|
+
t = Pn(i, s, t[0], t[1], n, r), e = Pn(i, s, e[0], e[1], n, r);
|
|
2545
|
+
const a = t[0] < e[0] ? t : e, c = a == t ? e : t;
|
|
2546
|
+
return { x: i, y: s, a, b: c };
|
|
2547
|
+
}
|
|
2548
|
+
function Pn(o, t, e, n, r, i) {
|
|
2549
|
+
let s = e < n ? e : n, a = s === e ? n : e;
|
|
2550
|
+
return r[s] == o && i[s] == t ? a = s : r[a] == o && i[a] == t && (s = a), [s, a];
|
|
2551
|
+
}
|
|
2552
|
+
function Un(o) {
|
|
2553
|
+
const t = {};
|
|
2554
|
+
return o.filter((e) => {
|
|
2555
|
+
const n = bi(e);
|
|
2556
|
+
return n in t ? !1 : (t[n] = !0, !0);
|
|
2557
|
+
});
|
|
2558
|
+
}
|
|
2559
|
+
function bi(o) {
|
|
2560
|
+
return `${o.a.join(",")};${o.b.join(",")}`;
|
|
2561
|
+
}
|
|
2562
|
+
class _i {
|
|
2563
|
+
_i = 0;
|
|
2564
|
+
_n = 0;
|
|
2565
|
+
_inc = 1;
|
|
2566
|
+
_xx;
|
|
2567
|
+
_yy;
|
|
2568
|
+
i = 0;
|
|
2569
|
+
x = 0;
|
|
2570
|
+
y = 0;
|
|
2571
|
+
constructor(t, e) {
|
|
2572
|
+
this._xx = t, this._yy = e;
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
function xi(o, t, e, n) {
|
|
2576
|
+
let r = e | 0;
|
|
2577
|
+
const i = isNaN(n) ? o.length - r : n + r;
|
|
2578
|
+
let s, a, c, h, u, f;
|
|
2579
|
+
if (i > 0)
|
|
2580
|
+
c = u = o[r], h = f = t[r];
|
|
2581
|
+
else return [void 0, void 0, void 0, void 0];
|
|
2582
|
+
for (r++; r < i; r++)
|
|
2583
|
+
s = o[r], a = t[r], s < c && (c = s), s > u && (u = s), a < h && (h = a), a > f && (f = a);
|
|
2584
|
+
return [c, h, u, f];
|
|
2585
|
+
}
|
|
2586
|
+
class qe {
|
|
2587
|
+
xmin;
|
|
2588
|
+
ymin;
|
|
2589
|
+
xmax;
|
|
2590
|
+
ymax;
|
|
2591
|
+
constructor(...t) {
|
|
2592
|
+
t.length > 0 && this.setBounds(t);
|
|
2593
|
+
}
|
|
2594
|
+
// Return a bounding box with the same extent as this one.
|
|
2595
|
+
cloneBounds() {
|
|
2596
|
+
return this.clone();
|
|
2597
|
+
}
|
|
2598
|
+
clone() {
|
|
2599
|
+
return new qe(this.xmin, this.ymin, this.xmax, this.ymax);
|
|
2600
|
+
}
|
|
2601
|
+
width() {
|
|
2602
|
+
return this.xmax - this.xmin || 0;
|
|
2603
|
+
}
|
|
2604
|
+
height() {
|
|
2605
|
+
return this.ymax - this.ymin || 0;
|
|
2606
|
+
}
|
|
2607
|
+
setBounds(t, e, n, r) {
|
|
2608
|
+
return arguments.length == 1 && (an(t) ? (e = t[1], n = t[2], r = t[3], t = t[0]) : (e = t.ymin, n = t.xmax, r = t.ymax, t = t.xmin)), this.xmin = t, this.ymin = e, this.xmax = n, this.ymax = r, (t > n || e > r) && this.update(), this;
|
|
2609
|
+
}
|
|
2610
|
+
update() {
|
|
2611
|
+
let t;
|
|
2612
|
+
this.xmin > this.xmax && (t = this.xmin, this.xmin = this.xmax, this.xmax = t), this.ymin > this.ymax && (t = this.ymin, this.ymin = this.ymax, this.ymax = t);
|
|
2613
|
+
}
|
|
2614
|
+
mergeBounds(t, ...e) {
|
|
2615
|
+
let n, r, i, s;
|
|
2616
|
+
return t instanceof qe ? (n = t.xmin, r = t.ymin, i = t.xmax, s = t.ymax) : e.length == 3 ? (n = t, r = e[0], i = e[1], s = e[2]) : t.length == 4 ? (n = t[0], r = t[1], i = t[2], s = t[3]) : on("Bounds#mergeBounds() invalid argument:", t), this.xmin === void 0 ? this.setBounds(n, r, i, s) : (n < this.xmin && (this.xmin = n), r < this.ymin && (this.ymin = r), i > this.xmax && (this.xmax = i), s > this.ymax && (this.ymax = s)), this;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
function Ue(o) {
|
|
2620
|
+
const t = ["a", "b", "c"].map(
|
|
2621
|
+
(e) => o.properties[e].index
|
|
2622
|
+
);
|
|
2623
|
+
return [
|
|
2624
|
+
[0, 1],
|
|
2625
|
+
[0, 2],
|
|
2626
|
+
[1, 2],
|
|
2627
|
+
[0, 1, 2]
|
|
2628
|
+
].map(
|
|
2629
|
+
(e) => e.map((n) => t[n]).sort().join("-")
|
|
2630
|
+
).sort();
|
|
2631
|
+
}
|
|
2632
|
+
function jn(o, t, e) {
|
|
2633
|
+
const n = Ue(t.forw), r = Ue(t.bakw);
|
|
2634
|
+
if (JSON.stringify(n) != JSON.stringify(r))
|
|
2635
|
+
throw `${JSON.stringify(t, null, 2)}
|
|
2636
|
+
${JSON.stringify(
|
|
2637
|
+
n
|
|
2638
|
+
)}
|
|
2639
|
+
${JSON.stringify(r)}`;
|
|
2640
|
+
for (let i = 0; i < n.length; i++) {
|
|
2641
|
+
const s = n[i];
|
|
2642
|
+
o[s] || (o[s] = []), o[s].push(t);
|
|
2643
|
+
}
|
|
2644
|
+
e && (e.forw.features.push(t.forw), e.bakw.features.push(t.bakw));
|
|
2645
|
+
}
|
|
2646
|
+
function Bn(o, t, e) {
|
|
2647
|
+
const n = Ue(t.forw), r = Ue(t.bakw);
|
|
2648
|
+
if (JSON.stringify(n) != JSON.stringify(r))
|
|
2649
|
+
throw `${JSON.stringify(t, null, 2)}
|
|
2650
|
+
${JSON.stringify(n)}
|
|
2651
|
+
${JSON.stringify(r)}`;
|
|
2652
|
+
if (n.forEach((i) => {
|
|
2653
|
+
const s = o[i];
|
|
2654
|
+
if (!s) return;
|
|
2655
|
+
const a = s.filter((c) => c !== t);
|
|
2656
|
+
a.length === 0 ? delete o[i] : o[i] = a;
|
|
2657
|
+
}), e) {
|
|
2658
|
+
const i = (s, a) => {
|
|
2659
|
+
!s || !a || (s.features = s.features.filter((c) => c !== a));
|
|
2660
|
+
};
|
|
2661
|
+
i(e.forw, t.forw), i(e.bakw, t.bakw);
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
function Fe(o, t, e) {
|
|
2665
|
+
return de(o, { target: { geom: t, index: e } });
|
|
2666
|
+
}
|
|
2667
|
+
function Le(o) {
|
|
2668
|
+
return de(o.properties.target.geom, {
|
|
2669
|
+
target: {
|
|
2670
|
+
geom: o.geometry.coordinates,
|
|
2671
|
+
index: o.properties.target.index
|
|
2672
|
+
}
|
|
2673
|
+
});
|
|
2674
|
+
}
|
|
2675
|
+
function On(o, t) {
|
|
2676
|
+
const e = t.geometry.coordinates;
|
|
2677
|
+
return [0, 1, 2, 3].map((n) => {
|
|
2678
|
+
const r = (n + 1) % 4, i = o[n], s = o[r], a = i.geometry.coordinates, c = Math.atan2(
|
|
2679
|
+
a[0] - e[0],
|
|
2680
|
+
a[1] - e[1]
|
|
2681
|
+
), h = [t, i, s, t].map(
|
|
2682
|
+
(d) => d.geometry.coordinates
|
|
2683
|
+
), u = {
|
|
2684
|
+
a: {
|
|
2685
|
+
geom: t.properties.target.geom,
|
|
2686
|
+
index: t.properties.target.index
|
|
2687
|
+
},
|
|
2688
|
+
b: {
|
|
2689
|
+
geom: i.properties.target.geom,
|
|
2690
|
+
index: i.properties.target.index
|
|
2691
|
+
},
|
|
2692
|
+
c: {
|
|
2693
|
+
geom: s.properties.target.geom,
|
|
2694
|
+
index: s.properties.target.index
|
|
2695
|
+
}
|
|
2696
|
+
}, f = Kt([
|
|
2697
|
+
Ee([h], u)
|
|
2698
|
+
]);
|
|
2699
|
+
return [c, f];
|
|
2700
|
+
}).reduce(
|
|
2701
|
+
(n, r) => (n[0].push(r[0]), n[1].push(r[1]), n),
|
|
2702
|
+
[[], []]
|
|
2703
|
+
);
|
|
2704
|
+
}
|
|
2705
|
+
function Mi(o) {
|
|
2706
|
+
const { tins: t, targets: e, includeReciprocals: n } = o, r = {};
|
|
2707
|
+
e.forEach((s) => {
|
|
2708
|
+
const a = t[s];
|
|
2709
|
+
if (!a || !a.features) return;
|
|
2710
|
+
r[s] = {};
|
|
2711
|
+
const c = {};
|
|
2712
|
+
a.features.forEach((h) => {
|
|
2713
|
+
const u = ["a", "b", "c"];
|
|
2714
|
+
for (let f = 0; f < 3; f++) {
|
|
2715
|
+
const d = (f + 1) % 3, y = u[f], E = u[d], k = h.properties[y].index, X = h.properties[E].index, C = [k, X].sort().join("-");
|
|
2716
|
+
if (c[C]) continue;
|
|
2717
|
+
c[C] = !0;
|
|
2718
|
+
const m = h.geometry.coordinates[0][f], v = h.geometry.coordinates[0][d], l = h.properties[y].geom, g = h.properties[E].geom, x = Math.sqrt(
|
|
2719
|
+
Math.pow(l[0] - g[0], 2) + Math.pow(l[1] - g[1], 2)
|
|
2720
|
+
) / Math.sqrt(
|
|
2721
|
+
Math.pow(m[0] - v[0], 2) + Math.pow(m[1] - v[1], 2)
|
|
2722
|
+
), A = r[s];
|
|
2723
|
+
A[`${k}:${C}`] = x, A[`${X}:${C}`] = x;
|
|
2724
|
+
}
|
|
2725
|
+
});
|
|
2726
|
+
});
|
|
2727
|
+
const i = {};
|
|
2728
|
+
return n && (i.bakw = {}), e.forEach((s) => {
|
|
2729
|
+
const a = r[s];
|
|
2730
|
+
if (i[s] = {}, !a)
|
|
2731
|
+
return;
|
|
2732
|
+
const c = {};
|
|
2733
|
+
Object.keys(a).forEach((u) => {
|
|
2734
|
+
const [f] = u.split(":");
|
|
2735
|
+
c[f] || (c[f] = []), c[f].push(a[u]);
|
|
2736
|
+
}), Object.keys(c).forEach((u) => {
|
|
2737
|
+
const f = c[u], d = f.reduce((y, E) => y + E, 0) / f.length;
|
|
2738
|
+
i[s][u] = d, n && i.bakw && (i.bakw[u] = 1 / d);
|
|
2739
|
+
});
|
|
2740
|
+
let h = 0;
|
|
2741
|
+
for (let u = 0; u < 4; u++) {
|
|
2742
|
+
const f = `b${u}`, d = i[s][f] || 0;
|
|
2743
|
+
h += d;
|
|
2744
|
+
}
|
|
2745
|
+
i[s].c = h / 4, n && i.bakw && (i.bakw.c = 1 / i[s].c);
|
|
2746
|
+
}), i;
|
|
2747
|
+
}
|
|
2748
|
+
function ki(o, t) {
|
|
2749
|
+
const e = o.split("-");
|
|
2750
|
+
if (e.length !== 2 || !e.every((i) => /^-?\d+$/.test(i))) return !1;
|
|
2751
|
+
const [n, r] = e.map((i) => parseInt(i, 10)).sort((i, s) => i - s);
|
|
2752
|
+
return t.some((i) => {
|
|
2753
|
+
if (i.length !== 2) return !1;
|
|
2754
|
+
const s = i.map((c) => parseInt(`${c}`, 10));
|
|
2755
|
+
if (s.some((c) => Number.isNaN(c))) return !1;
|
|
2756
|
+
const a = s.sort((c, h) => c - h);
|
|
2757
|
+
return a[0] === n && a[1] === r;
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
function De(o) {
|
|
2761
|
+
return ["a", "b", "c"].map((t, e) => ({
|
|
2762
|
+
prop: o.properties[t],
|
|
2763
|
+
geom: o.geometry.coordinates[0][e]
|
|
2764
|
+
}));
|
|
2765
|
+
}
|
|
2766
|
+
function Si(o, t, e) {
|
|
2767
|
+
const n = /* @__PURE__ */ new Set();
|
|
2768
|
+
let r = !1;
|
|
2769
|
+
const i = Object.keys(t);
|
|
2770
|
+
for (const s of i) {
|
|
2771
|
+
if (n.has(s)) continue;
|
|
2772
|
+
n.add(s);
|
|
2773
|
+
const a = t[s];
|
|
2774
|
+
if (!a || a.length < 2) continue;
|
|
2775
|
+
const c = s.split("-");
|
|
2776
|
+
if (c.length !== 2 || ki(s, e)) continue;
|
|
2777
|
+
const h = De(a[0].bakw), u = De(a[1].bakw), f = De(a[0].forw), d = De(a[1].forw), y = c.map(
|
|
2778
|
+
(b) => h.find((T) => `${T.prop.index}` === b) || u.find((T) => `${T.prop.index}` === b)
|
|
2779
|
+
), E = c.map(
|
|
2780
|
+
(b) => f.find((T) => `${T.prop.index}` === b) || d.find((T) => `${T.prop.index}` === b)
|
|
2781
|
+
);
|
|
2782
|
+
if (y.some((b) => !b) || E.some((b) => !b))
|
|
2783
|
+
continue;
|
|
2784
|
+
const k = [h, u].map(
|
|
2785
|
+
(b) => b.find((T) => !c.includes(`${T.prop.index}`))
|
|
2786
|
+
), X = [f, d].map(
|
|
2787
|
+
(b) => b.find((T) => !c.includes(`${T.prop.index}`))
|
|
2788
|
+
);
|
|
2789
|
+
if (k.some((b) => !b) || X.some((b) => !b))
|
|
2790
|
+
continue;
|
|
2791
|
+
const C = a[0].bakw.geometry.coordinates[0].slice(0, 3).map((b) => ge(b)), m = a[1].bakw.geometry.coordinates[0].slice(0, 3).map((b) => ge(b));
|
|
2792
|
+
if (!(In(
|
|
2793
|
+
ge(k[0].geom),
|
|
2794
|
+
m
|
|
2795
|
+
) || In(
|
|
2796
|
+
ge(k[1].geom),
|
|
2797
|
+
C
|
|
2798
|
+
)))
|
|
2799
|
+
continue;
|
|
2800
|
+
const l = E.map(
|
|
2801
|
+
(b) => ge(b.geom)
|
|
2802
|
+
), g = X.map(
|
|
2803
|
+
(b) => ge(b.geom)
|
|
2804
|
+
), x = Ei([
|
|
2805
|
+
...l,
|
|
2806
|
+
...g
|
|
2807
|
+
]), A = Ai(x), I = Tn(
|
|
2808
|
+
l[0],
|
|
2809
|
+
l[1],
|
|
2810
|
+
g[0]
|
|
2811
|
+
) + Tn(
|
|
2812
|
+
l[0],
|
|
2813
|
+
l[1],
|
|
2814
|
+
g[1]
|
|
2815
|
+
);
|
|
2816
|
+
nn(A, I) && (Bn(t, a[0], o), Bn(t, a[1], o), y.forEach((b) => {
|
|
2817
|
+
if (!b) return;
|
|
2818
|
+
const T = [
|
|
2819
|
+
b.geom,
|
|
2820
|
+
k[0].geom,
|
|
2821
|
+
k[1].geom,
|
|
2822
|
+
b.geom
|
|
2823
|
+
], R = {
|
|
2824
|
+
a: b.prop,
|
|
2825
|
+
b: k[0].prop,
|
|
2826
|
+
c: k[1].prop
|
|
2827
|
+
}, D = Ee([T], R), Q = jt.counterTri(D);
|
|
2828
|
+
jn(t, {
|
|
2829
|
+
forw: Q,
|
|
2830
|
+
bakw: D
|
|
2831
|
+
}, o);
|
|
2832
|
+
}), r = !0);
|
|
2833
|
+
}
|
|
2834
|
+
return r;
|
|
2835
|
+
}
|
|
2836
|
+
function ge(o) {
|
|
2837
|
+
return [o[0], o[1]];
|
|
2838
|
+
}
|
|
2839
|
+
function In(o, t) {
|
|
2840
|
+
const [e, n] = t[0], [r, i] = t[1], [s, a] = t[2], c = s - e, h = a - n, u = r - e, f = i - n, d = o[0] - e, y = o[1] - n, E = c * c + h * h, k = c * u + h * f, X = c * d + h * y, C = u * u + f * f, m = u * d + f * y, v = E * C - k * k;
|
|
2841
|
+
if (v === 0) return !1;
|
|
2842
|
+
const l = 1 / v, g = (C * X - k * m) * l, x = (E * m - k * X) * l, A = 1e-9;
|
|
2843
|
+
return g >= -A && x >= -A && g + x <= 1 + A;
|
|
2844
|
+
}
|
|
2845
|
+
function Ei(o) {
|
|
2846
|
+
const t = o.map((s) => s.slice()).filter(
|
|
2847
|
+
(s, a, c) => c.findIndex(
|
|
2848
|
+
(h) => nn(h[0], s[0]) && nn(h[1], s[1])
|
|
2849
|
+
) === a
|
|
2850
|
+
);
|
|
2851
|
+
if (t.length <= 1) return t;
|
|
2852
|
+
const e = t.sort(
|
|
2853
|
+
(s, a) => s[0] === a[0] ? s[1] - a[1] : s[0] - a[0]
|
|
2854
|
+
), n = (s, a, c) => (a[0] - s[0]) * (c[1] - s[1]) - (a[1] - s[1]) * (c[0] - s[0]), r = [];
|
|
2855
|
+
for (const s of e) {
|
|
2856
|
+
for (; r.length >= 2 && n(
|
|
2857
|
+
r[r.length - 2],
|
|
2858
|
+
r[r.length - 1],
|
|
2859
|
+
s
|
|
2860
|
+
) <= 0; )
|
|
2861
|
+
r.pop();
|
|
2862
|
+
r.push(s);
|
|
2863
|
+
}
|
|
2864
|
+
const i = [];
|
|
2865
|
+
for (let s = e.length - 1; s >= 0; s--) {
|
|
2866
|
+
const a = e[s];
|
|
2867
|
+
for (; i.length >= 2 && n(
|
|
2868
|
+
i[i.length - 2],
|
|
2869
|
+
i[i.length - 1],
|
|
2870
|
+
a
|
|
2871
|
+
) <= 0; )
|
|
2872
|
+
i.pop();
|
|
2873
|
+
i.push(a);
|
|
2874
|
+
}
|
|
2875
|
+
return i.pop(), r.pop(), r.concat(i);
|
|
2876
|
+
}
|
|
2877
|
+
function Ai(o) {
|
|
2878
|
+
if (o.length < 3) return 0;
|
|
2879
|
+
let t = 0;
|
|
2880
|
+
for (let e = 0; e < o.length; e++) {
|
|
2881
|
+
const [n, r] = o[e], [i, s] = o[(e + 1) % o.length];
|
|
2882
|
+
t += n * s - i * r;
|
|
2883
|
+
}
|
|
2884
|
+
return Math.abs(t) / 2;
|
|
2885
|
+
}
|
|
2886
|
+
function Tn(o, t, e) {
|
|
2887
|
+
return Math.abs(
|
|
2888
|
+
(o[0] * (t[1] - e[1]) + t[0] * (e[1] - o[1]) + e[0] * (o[1] - t[1])) / 2
|
|
2889
|
+
);
|
|
2890
|
+
}
|
|
2891
|
+
function nn(o, t, e = 1e-9) {
|
|
2892
|
+
return Math.abs(o - t) <= e;
|
|
2893
|
+
}
|
|
2894
|
+
const Pi = 2.00703, Nn = typeof jt.format_version < "u" ? jt.format_version : Pi;
|
|
2895
|
+
class Xt extends jt.Transform {
|
|
2896
|
+
importance;
|
|
2897
|
+
priority;
|
|
2898
|
+
pointsSet;
|
|
2899
|
+
/**
|
|
2900
|
+
* Tinクラスのインスタンスを生成します
|
|
2901
|
+
* @param options - 初期化オプション
|
|
2902
|
+
*/
|
|
2903
|
+
constructor(t = {}) {
|
|
2904
|
+
super(), t.bounds ? this.setBounds(t.bounds) : (this.setWh(t.wh), this.vertexMode = t.vertexMode || Xt.VERTEX_PLAIN), this.strictMode = t.strictMode || Xt.MODE_AUTO, this.yaxisMode = t.yaxisMode || Xt.YAXIS_INVERT, this.importance = t.importance || 0, this.priority = t.priority || 0, this.stateFull = t.stateFull || !1, t.points && this.setPoints(t.points), t.edges && this.setEdges(t.edges);
|
|
2905
|
+
}
|
|
2906
|
+
/**
|
|
2907
|
+
* フォーマットバージョンを取得します
|
|
2908
|
+
*/
|
|
2909
|
+
getFormatVersion() {
|
|
2910
|
+
return Nn;
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* 制御点(GCP: Ground Control Points)を設定します。
|
|
2914
|
+
* 指定した点群に合わせて内部のTINキャッシュをリセットします。
|
|
2915
|
+
*/
|
|
2916
|
+
setPoints(t) {
|
|
2917
|
+
this.yaxisMode === Xt.YAXIS_FOLLOW && (t = t.map((e) => [
|
|
2918
|
+
e[0],
|
|
2919
|
+
[e[1][0], -1 * e[1][1]]
|
|
2920
|
+
])), this.points = t, this.tins = void 0, this.indexedTins = void 0;
|
|
2921
|
+
}
|
|
2922
|
+
/**
|
|
2923
|
+
* エッジ(制約線)を設定します。
|
|
2924
|
+
* 制約線を正規化した上で、依存するキャッシュをリセットします。
|
|
2925
|
+
*/
|
|
2926
|
+
setEdges(t = []) {
|
|
2927
|
+
this.edges = jt.normalizeEdges(t), this.edgeNodes = void 0, this.tins = void 0, this.indexedTins = void 0;
|
|
2928
|
+
}
|
|
2929
|
+
/**
|
|
2930
|
+
* 境界ポリゴンを設定します
|
|
2931
|
+
*/
|
|
2932
|
+
setBounds(t) {
|
|
2933
|
+
this.bounds = t;
|
|
2934
|
+
let e = t[0][0], n = e, r = t[0][1], i = r;
|
|
2935
|
+
const s = [t[0]];
|
|
2936
|
+
for (let a = 1; a < t.length; a++) {
|
|
2937
|
+
const c = t[a];
|
|
2938
|
+
c[0] < e && (e = c[0]), c[0] > n && (n = c[0]), c[1] < r && (r = c[1]), c[1] > i && (i = c[1]), s.push(c);
|
|
2939
|
+
}
|
|
2940
|
+
s.push(t[0]), this.boundsPolygon = Ee([s]), this.xy = [e, r], this.wh = [n - e, i - r], this.vertexMode = Xt.VERTEX_PLAIN, this.tins = void 0, this.indexedTins = void 0;
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2943
|
+
* 現在の設定を永続化可能な形式にコンパイルします
|
|
2944
|
+
*/
|
|
2945
|
+
getCompiled() {
|
|
2946
|
+
const t = {};
|
|
2947
|
+
t.version = Nn, t.points = this.points, t.weight_buffer = this.pointsWeightBuffer, t.centroid_point = [
|
|
2948
|
+
this.centroid.forw.geometry.coordinates,
|
|
2949
|
+
this.centroid.forw.properties.target.geom
|
|
2950
|
+
], t.vertices_params = [
|
|
2951
|
+
this.vertices_params.forw[0],
|
|
2952
|
+
this.vertices_params.bakw[0]
|
|
2953
|
+
], t.vertices_points = [];
|
|
2954
|
+
const e = this.vertices_params.forw[1];
|
|
2955
|
+
return e && [0, 1, 2, 3].map((n) => {
|
|
2956
|
+
const r = e[n].features[0], i = r.geometry.coordinates[0][1], s = r.properties.b.geom;
|
|
2957
|
+
t.vertices_points[n] = [i, s];
|
|
2958
|
+
}), t.strict_status = this.strict_status, t.tins_points = [[]], this.tins.forw.features.map((n) => {
|
|
2959
|
+
t.tins_points[0].push(
|
|
2960
|
+
["a", "b", "c"].map(
|
|
2961
|
+
(r) => n.properties[r].index
|
|
2962
|
+
)
|
|
2963
|
+
);
|
|
2964
|
+
}), this.strict_status === Xt.STATUS_LOOSE ? (t.tins_points[1] = [], this.tins.bakw.features.map((n) => {
|
|
2965
|
+
t.tins_points[1].push(
|
|
2966
|
+
["a", "b", "c"].map(
|
|
2967
|
+
(r) => n.properties[r].index
|
|
2968
|
+
)
|
|
2969
|
+
);
|
|
2970
|
+
})) : this.strict_status === Xt.STATUS_ERROR && this.kinks?.bakw && (t.kinks_points = this.kinks.bakw.features.map(
|
|
2971
|
+
(n) => n.geometry.coordinates
|
|
2972
|
+
)), t.yaxisMode = this.yaxisMode, t.vertexMode = this.vertexMode, t.strictMode = this.strictMode, this.bounds ? (t.bounds = this.bounds, t.boundsPolygon = this.boundsPolygon, t.xy = this.xy, t.wh = this.wh) : t.wh = this.wh, t.edges = this.edges, t.edgeNodes = this.edgeNodes, t;
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* 幅と高さを設定します
|
|
2976
|
+
*/
|
|
2977
|
+
setWh(t) {
|
|
2978
|
+
this.wh = t || [100, 100], this.xy = [0, 0], this.bounds = void 0, this.boundsPolygon = void 0, this.tins = void 0, this.indexedTins = void 0;
|
|
2979
|
+
}
|
|
2980
|
+
/**
|
|
2981
|
+
* 頂点モードを設定します
|
|
2982
|
+
*/
|
|
2983
|
+
setVertexMode(t) {
|
|
2984
|
+
this.vertexMode = t, this.tins = void 0, this.indexedTins = void 0;
|
|
2985
|
+
}
|
|
2986
|
+
/**
|
|
2987
|
+
* 厳密性モードを設定します
|
|
2988
|
+
*/
|
|
2989
|
+
setStrictMode(t) {
|
|
2990
|
+
this.strictMode = t, this.tins = void 0, this.indexedTins = void 0;
|
|
2991
|
+
}
|
|
2992
|
+
/**
|
|
2993
|
+
* 厳密なTINを計算します
|
|
2994
|
+
*/
|
|
2995
|
+
calcurateStrictTin() {
|
|
2996
|
+
const t = this.tins.forw.features.map(
|
|
2997
|
+
(r) => jt.counterTri(r)
|
|
2998
|
+
);
|
|
2999
|
+
this.tins.bakw = Kt(t);
|
|
3000
|
+
const e = {};
|
|
3001
|
+
this.tins.forw.features.forEach((r, i) => {
|
|
3002
|
+
const s = this.tins.bakw.features[i];
|
|
3003
|
+
jn(e, { forw: r, bakw: s });
|
|
3004
|
+
}), Si(
|
|
3005
|
+
this.tins,
|
|
3006
|
+
e,
|
|
3007
|
+
this.pointsSet?.edges || []
|
|
3008
|
+
);
|
|
3009
|
+
const n = ["forw", "bakw"].map((r) => {
|
|
3010
|
+
const i = this.tins[r].features.map(
|
|
3011
|
+
(s) => s.geometry.coordinates[0]
|
|
3012
|
+
);
|
|
3013
|
+
return ti(i);
|
|
3014
|
+
});
|
|
3015
|
+
n[0].length === 0 && n[1].length === 0 ? (this.strict_status = Xt.STATUS_STRICT, delete this.kinks) : (this.strict_status = Xt.STATUS_ERROR, this.kinks = {
|
|
3016
|
+
forw: Kt(n[0]),
|
|
3017
|
+
bakw: Kt(n[1])
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* 点群セットを生成します。
|
|
3022
|
+
* GCP と中間エッジノードを GeoJSON Point に変換し、後続の三角分割に備えます。
|
|
3023
|
+
*/
|
|
3024
|
+
generatePointsSet() {
|
|
3025
|
+
const t = {
|
|
3026
|
+
forw: [],
|
|
3027
|
+
bakw: []
|
|
3028
|
+
};
|
|
3029
|
+
for (let r = 0; r < this.points.length; r++) {
|
|
3030
|
+
const i = this.points[r][0], s = this.points[r][1], a = Fe(i, s, r);
|
|
3031
|
+
t.forw.push(a), t.bakw.push(Le(a));
|
|
3032
|
+
}
|
|
3033
|
+
const e = [];
|
|
3034
|
+
let n = 0;
|
|
3035
|
+
this.edgeNodes = [], this.edges || (this.edges = []);
|
|
3036
|
+
for (let r = 0; r < this.edges.length; r++) {
|
|
3037
|
+
const i = this.edges[r][2], s = Object.assign([], this.edges[r][0]), a = Object.assign([], this.edges[r][1]);
|
|
3038
|
+
if (s.length === 0 && a.length === 0) {
|
|
3039
|
+
e.push(i);
|
|
3040
|
+
continue;
|
|
3041
|
+
}
|
|
3042
|
+
s.unshift(this.points[i[0]][0]), s.push(this.points[i[1]][0]), a.unshift(this.points[i[0]][1]), a.push(this.points[i[1]][1]);
|
|
3043
|
+
const c = [s, a].map((h) => {
|
|
3044
|
+
const u = h.map((d, y, E) => {
|
|
3045
|
+
if (y === 0) return 0;
|
|
3046
|
+
const k = E[y - 1];
|
|
3047
|
+
return Math.sqrt(
|
|
3048
|
+
Math.pow(d[0] - k[0], 2) + Math.pow(d[1] - k[1], 2)
|
|
3049
|
+
);
|
|
3050
|
+
}), f = u.reduce((d, y, E) => E === 0 ? [0] : (d.push(d[E - 1] + y), d), []);
|
|
3051
|
+
return f.map((d, y, E) => {
|
|
3052
|
+
const k = d / E[E.length - 1];
|
|
3053
|
+
return [h[y], u[y], f[y], k];
|
|
3054
|
+
});
|
|
3055
|
+
});
|
|
3056
|
+
c.map((h, u) => {
|
|
3057
|
+
const f = c[u ? 0 : 1];
|
|
3058
|
+
return h.filter((d, y) => !(y === 0 || y === h.length - 1 || d[4] === "handled")).map((d) => {
|
|
3059
|
+
const y = d[0], E = d[3], k = f.reduce(
|
|
3060
|
+
(X, C, m, v) => {
|
|
3061
|
+
if (X) return X;
|
|
3062
|
+
const l = v[m + 1];
|
|
3063
|
+
if (C[3] === E)
|
|
3064
|
+
return C[4] = "handled", [C];
|
|
3065
|
+
if (C[3] < E && l && l[3] > E)
|
|
3066
|
+
return [C, l];
|
|
3067
|
+
},
|
|
3068
|
+
void 0
|
|
3069
|
+
);
|
|
3070
|
+
if (k && k.length === 1)
|
|
3071
|
+
return u === 0 ? [y, k[0][0], E] : [k[0][0], y, E];
|
|
3072
|
+
if (k && k.length === 2) {
|
|
3073
|
+
const X = k[0], C = k[1], m = (E - X[3]) / (C[3] - X[3]), v = [
|
|
3074
|
+
(C[0][0] - X[0][0]) * m + X[0][0],
|
|
3075
|
+
(C[0][1] - X[0][1]) * m + X[0][1]
|
|
3076
|
+
];
|
|
3077
|
+
return u === 0 ? [y, v, E] : [v, y, E];
|
|
3078
|
+
}
|
|
3079
|
+
return [];
|
|
3080
|
+
});
|
|
3081
|
+
}).reduce((h, u) => h.concat(u), []).sort((h, u) => h[2] < u[2] ? -1 : 1).map((h, u, f) => {
|
|
3082
|
+
this.edgeNodes[n] = [
|
|
3083
|
+
h[0],
|
|
3084
|
+
h[1]
|
|
3085
|
+
];
|
|
3086
|
+
const d = Fe(
|
|
3087
|
+
h[0],
|
|
3088
|
+
h[1],
|
|
3089
|
+
`e${n}`
|
|
3090
|
+
);
|
|
3091
|
+
n++, t.forw.push(d), t.bakw.push(Le(d)), u === 0 ? e.push([i[0], t.forw.length - 1]) : e.push([
|
|
3092
|
+
t.forw.length - 2,
|
|
3093
|
+
t.forw.length - 1
|
|
3094
|
+
]), u === f.length - 1 && e.push([t.forw.length - 1, i[1]]);
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
return {
|
|
3098
|
+
forw: t.forw,
|
|
3099
|
+
bakw: t.bakw,
|
|
3100
|
+
edges: e
|
|
3101
|
+
};
|
|
3102
|
+
}
|
|
3103
|
+
/**
|
|
3104
|
+
* 入力データの検証と初期データの準備
|
|
3105
|
+
*/
|
|
3106
|
+
validateAndPrepareInputs() {
|
|
3107
|
+
const t = this.xy[0] - 0.05 * this.wh[0], e = this.xy[0] + 1.05 * this.wh[0], n = this.xy[1] - 0.05 * this.wh[1], r = this.xy[1] + 1.05 * this.wh[1];
|
|
3108
|
+
if (!this.points.reduce((a, c) => a && (this.bounds ? cr(c[0], this.boundsPolygon) : c[0][0] >= t && c[0][0] <= e && c[0][1] >= n && c[0][1] <= r), !0))
|
|
3109
|
+
throw "SOME POINTS OUTSIDE";
|
|
3110
|
+
let s = [];
|
|
3111
|
+
return this.wh && (s = [[t, n], [e, n], [t, r], [e, r]]), {
|
|
3112
|
+
pointsSet: this.generatePointsSet(),
|
|
3113
|
+
bbox: s,
|
|
3114
|
+
minx: t,
|
|
3115
|
+
maxx: e,
|
|
3116
|
+
miny: n,
|
|
3117
|
+
maxy: r
|
|
3118
|
+
};
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* TINネットワークを同期的に更新し、座標変換の準備を行います。
|
|
3122
|
+
* 重めの計算を伴うため、呼び出し側が非同期制御を行いたい場合は
|
|
3123
|
+
* {@link updateTinAsync} を利用してください。
|
|
3124
|
+
*/
|
|
3125
|
+
updateTin() {
|
|
3126
|
+
let t = this.strictMode;
|
|
3127
|
+
t !== Xt.MODE_STRICT && t !== Xt.MODE_LOOSE && (t = Xt.MODE_AUTO);
|
|
3128
|
+
const { pointsSet: e, bbox: n, minx: r, maxx: i, miny: s, maxy: a } = this.validateAndPrepareInputs(), c = {
|
|
3129
|
+
forw: Kt(e.forw),
|
|
3130
|
+
bakw: Kt(e.bakw)
|
|
3131
|
+
}, h = Te(
|
|
3132
|
+
c.forw,
|
|
3133
|
+
e.edges,
|
|
3134
|
+
"target"
|
|
3135
|
+
), u = Te(
|
|
3136
|
+
c.bakw,
|
|
3137
|
+
e.edges,
|
|
3138
|
+
"target"
|
|
3139
|
+
);
|
|
3140
|
+
if (h.features.length === 0 || u.features.length === 0)
|
|
3141
|
+
throw "TOO LINEAR1";
|
|
3142
|
+
const f = fr(c.forw), d = vn(c.forw);
|
|
3143
|
+
if (!d) throw "TOO LINEAR2";
|
|
3144
|
+
const y = {}, E = d.geometry.coordinates[0];
|
|
3145
|
+
let k;
|
|
3146
|
+
try {
|
|
3147
|
+
k = E.map((b) => ({
|
|
3148
|
+
forw: b,
|
|
3149
|
+
bakw: jt.transformArr(de(b), h)
|
|
3150
|
+
})), k.forEach((b) => {
|
|
3151
|
+
y[`${b.forw[0]}:${b.forw[1]}`] = b;
|
|
3152
|
+
});
|
|
3153
|
+
} catch {
|
|
3154
|
+
throw "TOO LINEAR2";
|
|
3155
|
+
}
|
|
3156
|
+
const X = vn(c.bakw);
|
|
3157
|
+
if (!X) throw "TOO LINEAR2";
|
|
3158
|
+
const C = X.geometry.coordinates[0];
|
|
3159
|
+
try {
|
|
3160
|
+
k = C.map((b) => ({
|
|
3161
|
+
bakw: b,
|
|
3162
|
+
forw: jt.transformArr(de(b), u)
|
|
3163
|
+
})), k.forEach((b) => {
|
|
3164
|
+
y[`${b.forw[0]}:${b.forw[1]}`] = b;
|
|
3165
|
+
});
|
|
3166
|
+
} catch {
|
|
3167
|
+
throw "TOO LINEAR2";
|
|
3168
|
+
}
|
|
3169
|
+
const m = {
|
|
3170
|
+
forw: f.geometry.coordinates,
|
|
3171
|
+
bakw: jt.transformArr(f, h)
|
|
3172
|
+
}, v = Fe(m.forw, m.bakw, "c");
|
|
3173
|
+
this.centroid = {
|
|
3174
|
+
forw: v,
|
|
3175
|
+
bakw: Le(v)
|
|
3176
|
+
};
|
|
3177
|
+
const l = {
|
|
3178
|
+
convexBuf: y,
|
|
3179
|
+
centroid: m,
|
|
3180
|
+
bbox: n,
|
|
3181
|
+
minx: r,
|
|
3182
|
+
maxx: i,
|
|
3183
|
+
miny: s,
|
|
3184
|
+
maxy: a
|
|
3185
|
+
}, g = this.vertexMode === Xt.VERTEX_BIRDEYE ? Zr(l) : Hr(l), x = {
|
|
3186
|
+
forw: [],
|
|
3187
|
+
bakw: []
|
|
3188
|
+
};
|
|
3189
|
+
for (let b = 0; b < g.length; b++) {
|
|
3190
|
+
const T = g[b].forw, R = g[b].bakw, D = Fe(T, R, `b${b}`), Q = Le(D);
|
|
3191
|
+
e.forw.push(D), e.bakw.push(Q), x.forw.push(D), x.bakw.push(Q);
|
|
3192
|
+
}
|
|
3193
|
+
this.pointsSet = {
|
|
3194
|
+
forw: Kt(e.forw),
|
|
3195
|
+
bakw: Kt(e.bakw),
|
|
3196
|
+
edges: e.edges
|
|
3197
|
+
}, this.tins = {
|
|
3198
|
+
forw: jt.rotateVerticesTriangle(
|
|
3199
|
+
Te(
|
|
3200
|
+
this.pointsSet.forw,
|
|
3201
|
+
e.edges,
|
|
3202
|
+
"target"
|
|
3203
|
+
)
|
|
3204
|
+
)
|
|
3205
|
+
}, (t === Xt.MODE_STRICT || t === Xt.MODE_AUTO) && this.calcurateStrictTin(), (t === Xt.MODE_LOOSE || t === Xt.MODE_AUTO && this.strict_status === Xt.STATUS_ERROR) && (this.tins.bakw = jt.rotateVerticesTriangle(
|
|
3206
|
+
Te(
|
|
3207
|
+
this.pointsSet.bakw,
|
|
3208
|
+
e.edges,
|
|
3209
|
+
"target"
|
|
3210
|
+
)
|
|
3211
|
+
), delete this.kinks, this.strict_status = Xt.STATUS_LOOSE), this.vertices_params = {
|
|
3212
|
+
forw: On(x.forw, this.centroid.forw),
|
|
3213
|
+
bakw: On(x.bakw, this.centroid.bakw)
|
|
3214
|
+
}, this.addIndexedTin();
|
|
3215
|
+
const A = ["forw"];
|
|
3216
|
+
this.strict_status === Xt.STATUS_LOOSE && A.push("bakw");
|
|
3217
|
+
const I = this.strict_status === Xt.STATUS_STRICT;
|
|
3218
|
+
this.pointsWeightBuffer = Mi({
|
|
3219
|
+
tins: this.tins,
|
|
3220
|
+
targets: A,
|
|
3221
|
+
includeReciprocals: I
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
3224
|
+
/**
|
|
3225
|
+
* 非同期ラッパーを提供します。
|
|
3226
|
+
* 互換性のために Promise ベースの API を維持しますが、内部処理は同期的です。
|
|
3227
|
+
*/
|
|
3228
|
+
async updateTinAsync() {
|
|
3229
|
+
this.updateTin();
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
const Oi = jt.format_version;
|
|
3233
|
+
export {
|
|
3234
|
+
Xt as Tin,
|
|
3235
|
+
Te as constrainedTin,
|
|
3236
|
+
Le as counterPoint,
|
|
3237
|
+
Fe as createPoint,
|
|
3238
|
+
Xt as default,
|
|
3239
|
+
ti as findIntersections,
|
|
3240
|
+
Oi as format_version,
|
|
3241
|
+
jn as insertSearchIndex,
|
|
3242
|
+
On as vertexCalc
|
|
3243
|
+
};
|