@maplat/tin 0.11.0 → 0.11.2
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 +218 -120
- package/README.md +219 -121
- package/dist/constrained-tin.d.ts +29 -0
- package/dist/index.d.ts +17 -196
- package/dist/kinks.d.ts +8 -0
- package/dist/searchutils.d.ts +21 -0
- package/dist/tin.cjs +3 -0
- package/dist/tin.d.ts +100 -0
- package/dist/tin.js +2194 -0
- package/dist/tin.umd.js +3 -0
- package/dist/vertexutils.d.ts +24 -0
- package/package.json +99 -87
- package/src/constrained-tin.ts +23 -17
- package/src/index.ts +36 -929
- package/src/kinks.ts +41 -35
- package/src/searchutils.ts +16 -15
- package/src/tin.ts +1027 -0
- package/src/types/constrainautor.d.ts +2 -2
- package/src/types/kinks.d.ts +49 -0
- package/src/types/tin.d.ts +54 -0
- package/src/vertexutils.ts +34 -27
- package/dist/maplat_tin.cjs +0 -3
- package/dist/maplat_tin.js +0 -3291
- package/dist/maplat_tin.umd.js +0 -3
package/dist/tin.js
ADDED
|
@@ -0,0 +1,2194 @@
|
|
|
1
|
+
var Qe = Object.defineProperty;
|
|
2
|
+
var Ze = (o, t, e) => t in o ? Qe(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var rt = (o, t, e) => Ze(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import ts from "@turf/boolean-point-in-polygon";
|
|
5
|
+
import es from "@turf/centroid";
|
|
6
|
+
import ke from "@turf/convex";
|
|
7
|
+
import { featureCollection as Ot, polygon as me, point as Jt, lineString as xe } from "@turf/helpers";
|
|
8
|
+
import ss from "@turf/line-intersect";
|
|
9
|
+
import ns from "delaunator";
|
|
10
|
+
var is = Object.defineProperty, rs = (o, t, e) => t in o ? is(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, nt = (o, t, e) => rs(o, typeof t != "symbol" ? t + "" : t, e);
|
|
11
|
+
const Tt = 11102230246251565e-32, lt = 134217729, os = (3 + 8 * Tt) * Tt;
|
|
12
|
+
function ae(o, t, e, s, i) {
|
|
13
|
+
let n, r, a, f, c = t[0], u = s[0], h = 0, l = 0;
|
|
14
|
+
u > c == u > -c ? (n = c, c = t[++h]) : (n = u, u = s[++l]);
|
|
15
|
+
let p = 0;
|
|
16
|
+
if (h < o && l < e)
|
|
17
|
+
for (u > c == u > -c ? (r = c + n, a = n - (r - c), c = t[++h]) : (r = u + n, a = n - (r - u), u = s[++l]), n = r, a !== 0 && (i[p++] = a); h < o && l < e; )
|
|
18
|
+
u > c == u > -c ? (r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h]) : (r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l]), n = r, a !== 0 && (i[p++] = a);
|
|
19
|
+
for (; h < o; )
|
|
20
|
+
r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h], n = r, a !== 0 && (i[p++] = a);
|
|
21
|
+
for (; l < e; )
|
|
22
|
+
r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l], n = r, a !== 0 && (i[p++] = a);
|
|
23
|
+
return (n !== 0 || p === 0) && (i[p++] = n), p;
|
|
24
|
+
}
|
|
25
|
+
function as(o, t) {
|
|
26
|
+
let e = t[0];
|
|
27
|
+
for (let s = 1; s < o; s++) e += t[s];
|
|
28
|
+
return e;
|
|
29
|
+
}
|
|
30
|
+
function Ht(o) {
|
|
31
|
+
return new Float64Array(o);
|
|
32
|
+
}
|
|
33
|
+
const hs = (3 + 16 * Tt) * Tt, cs = (2 + 12 * Tt) * Tt, fs = (9 + 64 * Tt) * Tt * Tt, Vt = Ht(4), _e = Ht(8), Me = Ht(12), Se = Ht(16), gt = Ht(4);
|
|
34
|
+
function us(o, t, e, s, i, n, r) {
|
|
35
|
+
let a, f, c, u, h, l, p, y, g, b, w, S, _, v, T, I, N, V;
|
|
36
|
+
const z = o - i, G = e - i, tt = t - n, X = s - n;
|
|
37
|
+
v = z * X, l = lt * z, p = l - (l - z), y = z - p, l = lt * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = tt * G, l = lt * tt, p = l - (l - tt), y = tt - p, l = lt * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, Vt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, Vt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, Vt[2] = S - (V - h) + (w - h), Vt[3] = V;
|
|
38
|
+
let it = as(4, Vt), d = cs * r;
|
|
39
|
+
if (it >= d || -it >= d || (h = o - z, a = o - (z + h) + (h - i), h = e - G, c = e - (G + h) + (h - i), h = t - tt, f = t - (tt + h) + (h - n), h = s - X, u = s - (X + h) + (h - n), a === 0 && f === 0 && c === 0 && u === 0) || (d = fs * r + os * Math.abs(it), it += z * u + X * a - (tt * c + G * f), it >= d || -it >= d)) return it;
|
|
40
|
+
v = a * X, l = lt * a, p = l - (l - a), y = a - p, l = lt * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = f * G, l = lt * f, p = l - (l - f), y = f - p, l = lt * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, gt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, gt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, gt[2] = S - (V - h) + (w - h), gt[3] = V;
|
|
41
|
+
const m = ae(4, Vt, 4, gt, _e);
|
|
42
|
+
v = z * u, l = lt * z, p = l - (l - z), y = z - p, l = lt * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = tt * c, l = lt * tt, p = l - (l - tt), y = tt - p, l = lt * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, gt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, gt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, gt[2] = S - (V - h) + (w - h), gt[3] = V;
|
|
43
|
+
const x = ae(m, _e, 4, gt, Me);
|
|
44
|
+
v = a * u, l = lt * a, p = l - (l - a), y = a - p, l = lt * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = f * c, l = lt * f, p = l - (l - f), y = f - p, l = lt * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, gt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, gt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, gt[2] = S - (V - h) + (w - h), gt[3] = V;
|
|
45
|
+
const A = ae(x, Me, 4, gt, Se);
|
|
46
|
+
return Se[A - 1];
|
|
47
|
+
}
|
|
48
|
+
function ls(o, t, e, s, i, n) {
|
|
49
|
+
const r = (t - n) * (e - i), a = (o - i) * (s - n), f = r - a, c = Math.abs(r + a);
|
|
50
|
+
return Math.abs(f) >= hs * c ? f : -us(o, t, e, s, i, n, c);
|
|
51
|
+
}
|
|
52
|
+
function ds(o, t) {
|
|
53
|
+
var e, s, i = 0, n, r, a, f, c, u, h, l = o[0], p = o[1], y = t.length;
|
|
54
|
+
for (e = 0; e < y; e++) {
|
|
55
|
+
s = 0;
|
|
56
|
+
var g = t[e], b = g.length - 1;
|
|
57
|
+
if (u = g[0], u[0] !== g[b][0] && u[1] !== g[b][1])
|
|
58
|
+
throw new Error("First and last coordinates in a ring must be the same");
|
|
59
|
+
for (r = u[0] - l, a = u[1] - p, s; s < b; s++) {
|
|
60
|
+
if (h = g[s + 1], f = h[0] - l, c = h[1] - p, a === 0 && c === 0) {
|
|
61
|
+
if (f <= 0 && r >= 0 || r <= 0 && f >= 0)
|
|
62
|
+
return 0;
|
|
63
|
+
} else if (c >= 0 && a <= 0 || c <= 0 && a >= 0) {
|
|
64
|
+
if (n = ls(r, f, a, c, 0, 0), n === 0)
|
|
65
|
+
return 0;
|
|
66
|
+
(n > 0 && c > 0 && a <= 0 || n < 0 && c <= 0 && a > 0) && i++;
|
|
67
|
+
}
|
|
68
|
+
u = h, a = c, r = f;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return i % 2 !== 0;
|
|
72
|
+
}
|
|
73
|
+
function Le(o, t, e = {}) {
|
|
74
|
+
const s = { type: "Feature" };
|
|
75
|
+
return (e.id === 0 || e.id) && (s.id = e.id), e.bbox && (s.bbox = e.bbox), s.properties = t || {}, s.geometry = o, s;
|
|
76
|
+
}
|
|
77
|
+
function Yt(o, t, e = {}) {
|
|
78
|
+
if (!o)
|
|
79
|
+
throw new Error("coordinates is required");
|
|
80
|
+
if (!Array.isArray(o))
|
|
81
|
+
throw new Error("coordinates must be an Array");
|
|
82
|
+
if (o.length < 2)
|
|
83
|
+
throw new Error("coordinates must be at least 2 numbers long");
|
|
84
|
+
if (!Ae(o[0]) || !Ae(o[1]))
|
|
85
|
+
throw new Error("coordinates must contain numbers");
|
|
86
|
+
return Le({
|
|
87
|
+
type: "Point",
|
|
88
|
+
coordinates: o
|
|
89
|
+
}, t, e);
|
|
90
|
+
}
|
|
91
|
+
function Ve(o, t, e = {}) {
|
|
92
|
+
for (const s of o) {
|
|
93
|
+
if (s.length < 4)
|
|
94
|
+
throw new Error(
|
|
95
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
96
|
+
);
|
|
97
|
+
if (s[s.length - 1].length !== s[0].length)
|
|
98
|
+
throw new Error("First and last Position are not equivalent.");
|
|
99
|
+
for (let i = 0; i < s[s.length - 1].length; i++)
|
|
100
|
+
if (s[s.length - 1][i] !== s[0][i])
|
|
101
|
+
throw new Error("First and last Position are not equivalent.");
|
|
102
|
+
}
|
|
103
|
+
return Le({
|
|
104
|
+
type: "Polygon",
|
|
105
|
+
coordinates: o
|
|
106
|
+
}, t, e);
|
|
107
|
+
}
|
|
108
|
+
function Lt(o, t = {}) {
|
|
109
|
+
const e = { type: "FeatureCollection" };
|
|
110
|
+
return t.id && (e.id = t.id), t.bbox && (e.bbox = t.bbox), e.features = o, e;
|
|
111
|
+
}
|
|
112
|
+
function Ae(o) {
|
|
113
|
+
return !isNaN(o) && o !== null && !Array.isArray(o);
|
|
114
|
+
}
|
|
115
|
+
function gs(o) {
|
|
116
|
+
if (!o)
|
|
117
|
+
throw new Error("coord is required");
|
|
118
|
+
if (!Array.isArray(o)) {
|
|
119
|
+
if (o.type === "Feature" && o.geometry !== null && o.geometry.type === "Point")
|
|
120
|
+
return [...o.geometry.coordinates];
|
|
121
|
+
if (o.type === "Point")
|
|
122
|
+
return [...o.coordinates];
|
|
123
|
+
}
|
|
124
|
+
if (Array.isArray(o) && o.length >= 2 && !Array.isArray(o[0]) && !Array.isArray(o[1]))
|
|
125
|
+
return [...o];
|
|
126
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
127
|
+
}
|
|
128
|
+
function Ee(o) {
|
|
129
|
+
if (Array.isArray(o))
|
|
130
|
+
return o;
|
|
131
|
+
if (o.type === "Feature") {
|
|
132
|
+
if (o.geometry !== null)
|
|
133
|
+
return o.geometry.coordinates;
|
|
134
|
+
} else if (o.coordinates)
|
|
135
|
+
return o.coordinates;
|
|
136
|
+
throw new Error(
|
|
137
|
+
"coords must be GeoJSON Feature, Geometry Object or an Array"
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function ps(o) {
|
|
141
|
+
return o.type === "Feature" ? o.geometry : o;
|
|
142
|
+
}
|
|
143
|
+
function ws(o, t, e = {}) {
|
|
144
|
+
if (!o)
|
|
145
|
+
throw new Error("point is required");
|
|
146
|
+
if (!t)
|
|
147
|
+
throw new Error("polygon is required");
|
|
148
|
+
const s = gs(o), i = ps(t), n = i.type, r = t.bbox;
|
|
149
|
+
let a = i.coordinates;
|
|
150
|
+
if (r && ms(s, r) === !1)
|
|
151
|
+
return !1;
|
|
152
|
+
n === "Polygon" && (a = [a]);
|
|
153
|
+
let f = !1;
|
|
154
|
+
for (var c = 0; c < a.length; ++c) {
|
|
155
|
+
const u = ds(s, a[c]);
|
|
156
|
+
if (u === 0) return !e.ignoreBoundary;
|
|
157
|
+
u && (f = !0);
|
|
158
|
+
}
|
|
159
|
+
return f;
|
|
160
|
+
}
|
|
161
|
+
function ms(o, t) {
|
|
162
|
+
return t[0] <= o[0] && t[1] <= o[1] && t[2] >= o[0] && t[3] >= o[1];
|
|
163
|
+
}
|
|
164
|
+
var pe = ws;
|
|
165
|
+
function ve(o) {
|
|
166
|
+
const t = o.features;
|
|
167
|
+
for (let e = 0; e < t.length; e++) {
|
|
168
|
+
const s = t[e];
|
|
169
|
+
`${s.properties.a.index}`.substring(0, 1) === "b" && `${s.properties.b.index}`.substring(0, 1) === "b" ? t[e] = {
|
|
170
|
+
geometry: {
|
|
171
|
+
type: "Polygon",
|
|
172
|
+
coordinates: [
|
|
173
|
+
[
|
|
174
|
+
s.geometry.coordinates[0][2],
|
|
175
|
+
s.geometry.coordinates[0][0],
|
|
176
|
+
s.geometry.coordinates[0][1],
|
|
177
|
+
s.geometry.coordinates[0][2]
|
|
178
|
+
]
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
properties: {
|
|
182
|
+
a: {
|
|
183
|
+
geom: s.properties.c.geom,
|
|
184
|
+
index: s.properties.c.index
|
|
185
|
+
},
|
|
186
|
+
b: {
|
|
187
|
+
geom: s.properties.a.geom,
|
|
188
|
+
index: s.properties.a.index
|
|
189
|
+
},
|
|
190
|
+
c: {
|
|
191
|
+
geom: s.properties.b.geom,
|
|
192
|
+
index: s.properties.b.index
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
type: "Feature"
|
|
196
|
+
} : `${s.properties.c.index}`.substring(0, 1) === "b" && `${s.properties.a.index}`.substring(0, 1) === "b" && (t[e] = {
|
|
197
|
+
geometry: {
|
|
198
|
+
type: "Polygon",
|
|
199
|
+
coordinates: [
|
|
200
|
+
[
|
|
201
|
+
s.geometry.coordinates[0][1],
|
|
202
|
+
s.geometry.coordinates[0][2],
|
|
203
|
+
s.geometry.coordinates[0][0],
|
|
204
|
+
s.geometry.coordinates[0][1]
|
|
205
|
+
]
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
properties: {
|
|
209
|
+
a: {
|
|
210
|
+
geom: s.properties.b.geom,
|
|
211
|
+
index: s.properties.b.index
|
|
212
|
+
},
|
|
213
|
+
b: {
|
|
214
|
+
geom: s.properties.c.geom,
|
|
215
|
+
index: s.properties.c.index
|
|
216
|
+
},
|
|
217
|
+
c: {
|
|
218
|
+
geom: s.properties.a.geom,
|
|
219
|
+
index: s.properties.a.index
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
type: "Feature"
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return o;
|
|
226
|
+
}
|
|
227
|
+
function bs(o) {
|
|
228
|
+
const t = ["a", "b", "c", "a"].map(
|
|
229
|
+
(n) => o.properties[n].geom
|
|
230
|
+
), e = o.geometry.coordinates[0], s = o.properties, i = {
|
|
231
|
+
a: { geom: e[0], index: s.a.index },
|
|
232
|
+
b: { geom: e[1], index: s.b.index },
|
|
233
|
+
c: { geom: e[2], index: s.c.index }
|
|
234
|
+
};
|
|
235
|
+
return Ve([t], i);
|
|
236
|
+
}
|
|
237
|
+
function ys(o) {
|
|
238
|
+
const t = [0, 1, 2, 0].map((s) => o[s][0][0]), e = {
|
|
239
|
+
a: { geom: o[0][0][1], index: o[0][1] },
|
|
240
|
+
b: { geom: o[1][0][1], index: o[1][1] },
|
|
241
|
+
c: { geom: o[2][0][1], index: o[2][1] }
|
|
242
|
+
};
|
|
243
|
+
return Ve([t], e);
|
|
244
|
+
}
|
|
245
|
+
function Gt(o, t, e, s, i, n = !1, r) {
|
|
246
|
+
const a = o.map(
|
|
247
|
+
(f) => {
|
|
248
|
+
(!r || r < 2.00703) && (f = We(f));
|
|
249
|
+
const c = isFinite(f) ? t[f] : f === "c" ? s : f === "b0" ? i[0] : f === "b1" ? i[1] : f === "b2" ? i[2] : f === "b3" ? i[3] : function() {
|
|
250
|
+
const u = f.match(/e(\d+)/);
|
|
251
|
+
if (u) {
|
|
252
|
+
const h = parseInt(u[1]);
|
|
253
|
+
return e[h];
|
|
254
|
+
}
|
|
255
|
+
throw "Bad index value for indexesToTri";
|
|
256
|
+
}();
|
|
257
|
+
return n ? [[c[1], c[0]], f] : [[c[0], c[1]], f];
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
return ys(a);
|
|
261
|
+
}
|
|
262
|
+
function We(o) {
|
|
263
|
+
return typeof o == "number" ? o : o.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
|
|
264
|
+
}
|
|
265
|
+
function ze(o, t) {
|
|
266
|
+
return t && t >= 2.00703 || Array.isArray(o[0]) ? o : o.map((e) => [
|
|
267
|
+
e.illstNodes,
|
|
268
|
+
e.mercNodes,
|
|
269
|
+
e.startEnd
|
|
270
|
+
]);
|
|
271
|
+
}
|
|
272
|
+
function Oe(o, t) {
|
|
273
|
+
for (let e = 0; e < t.features.length; e++)
|
|
274
|
+
if (pe(o, t.features[e]))
|
|
275
|
+
return t.features[e];
|
|
276
|
+
}
|
|
277
|
+
function Xe(o, t, e) {
|
|
278
|
+
const s = t.geometry.coordinates[0][0], i = t.geometry.coordinates[0][1], n = t.geometry.coordinates[0][2], r = o.geometry.coordinates, a = t.properties.a.geom, f = t.properties.b.geom, c = t.properties.c.geom, u = [i[0] - s[0], i[1] - s[1]], h = [n[0] - s[0], n[1] - s[1]], l = [r[0] - s[0], r[1] - s[1]], p = [f[0] - a[0], f[1] - a[1]], y = [c[0] - a[0], c[1] - a[1]];
|
|
279
|
+
let g = (h[1] * l[0] - h[0] * l[1]) / (u[0] * h[1] - u[1] * h[0]), b = (u[0] * l[1] - u[1] * l[0]) / (u[0] * h[1] - u[1] * h[0]);
|
|
280
|
+
if (e) {
|
|
281
|
+
const w = e[t.properties.a.index], S = e[t.properties.b.index], _ = e[t.properties.c.index];
|
|
282
|
+
let v;
|
|
283
|
+
if (g < 0 || b < 0 || 1 - g - b < 0) {
|
|
284
|
+
const T = g / (g + b), I = b / (g + b);
|
|
285
|
+
v = g / S / (T / S + I / _), b = b / _ / (T / S + I / _);
|
|
286
|
+
} else
|
|
287
|
+
v = g / S / (g / S + b / _ + (1 - g - b) / w), b = b / _ / (g / S + b / _ + (1 - g - b) / w);
|
|
288
|
+
g = v;
|
|
289
|
+
}
|
|
290
|
+
return [
|
|
291
|
+
g * p[0] + b * y[0] + a[0],
|
|
292
|
+
g * p[1] + b * y[1] + a[1]
|
|
293
|
+
];
|
|
294
|
+
}
|
|
295
|
+
function ks(o, t, e, s) {
|
|
296
|
+
const i = o.geometry.coordinates, n = e.geometry.coordinates, r = Math.atan2(i[0] - n[0], i[1] - n[1]), a = xs(r, t[0]);
|
|
297
|
+
if (a === void 0)
|
|
298
|
+
throw new Error("Unable to determine vertex index");
|
|
299
|
+
const f = t[1][a];
|
|
300
|
+
return Xe(o, f.features[0], s);
|
|
301
|
+
}
|
|
302
|
+
function re(o, t, e, s, i, n, r, a) {
|
|
303
|
+
let f;
|
|
304
|
+
if (r && (f = Oe(o, Lt([r]))), !f) {
|
|
305
|
+
if (e) {
|
|
306
|
+
const c = o.geometry.coordinates, u = e.gridNum, h = e.xOrigin, l = e.yOrigin, p = e.xUnit, y = e.yUnit, g = e.gridCache, b = At(c[0], h, p, u), w = At(c[1], l, y, u), S = g[b] ? g[b][w] ? g[b][w] : [] : [];
|
|
307
|
+
t = Lt(S.map((_) => t.features[_]));
|
|
308
|
+
}
|
|
309
|
+
f = Oe(o, t);
|
|
310
|
+
}
|
|
311
|
+
return a && a(f), f ? Xe(o, f, n) : ks(o, s, i, n);
|
|
312
|
+
}
|
|
313
|
+
function At(o, t, e, s) {
|
|
314
|
+
let i = Math.floor((o - t) / e);
|
|
315
|
+
return i >= s && (i = s - 1), i;
|
|
316
|
+
}
|
|
317
|
+
function xs(o, t) {
|
|
318
|
+
let e = Te(o - t[0]), s = Math.PI * 2, i;
|
|
319
|
+
for (let n = 0; n < t.length; n++) {
|
|
320
|
+
const r = (n + 1) % t.length, a = Te(o - t[r]), f = Math.min(Math.abs(e), Math.abs(a));
|
|
321
|
+
e * a <= 0 && f < s && (s = f, i = n), e = a;
|
|
322
|
+
}
|
|
323
|
+
return i;
|
|
324
|
+
}
|
|
325
|
+
function Te(o, t = !1) {
|
|
326
|
+
const e = t ? function(s) {
|
|
327
|
+
return !(s >= 0 && s < Math.PI * 2);
|
|
328
|
+
} : function(s) {
|
|
329
|
+
return !(s > -1 * Math.PI && s <= Math.PI);
|
|
330
|
+
};
|
|
331
|
+
for (; e(o); )
|
|
332
|
+
o = o + 2 * Math.PI * (o > 0 ? -1 : 1);
|
|
333
|
+
return o;
|
|
334
|
+
}
|
|
335
|
+
const we = 2.00703, kt = class xt {
|
|
336
|
+
constructor() {
|
|
337
|
+
nt(this, "points", []), nt(this, "pointsWeightBuffer"), nt(this, "strict_status"), nt(this, "vertices_params"), nt(this, "centroid"), nt(this, "edgeNodes"), nt(this, "edges"), nt(this, "tins"), nt(this, "kinks"), nt(this, "yaxisMode", xt.YAXIS_INVERT), nt(this, "strictMode", xt.MODE_AUTO), nt(this, "vertexMode", xt.VERTEX_PLAIN), nt(this, "bounds"), nt(this, "boundsPolygon"), nt(this, "wh"), nt(this, "xy"), nt(this, "indexedTins"), nt(this, "stateFull", !1), nt(this, "stateTriangle"), nt(this, "stateBackward");
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* コンパイルされた設定を適用します
|
|
341
|
+
*
|
|
342
|
+
* @param compiled - コンパイルされた設定オブジェクト
|
|
343
|
+
* @returns 変換に必要な主要なオブジェクトのセット
|
|
344
|
+
*
|
|
345
|
+
* 以下の処理を行います:
|
|
346
|
+
* 1. バージョンに応じた設定の解釈
|
|
347
|
+
* 2. 各種パラメータの復元
|
|
348
|
+
* 3. TINネットワークの再構築
|
|
349
|
+
* 4. インデックスの作成
|
|
350
|
+
*/
|
|
351
|
+
setCompiled(t) {
|
|
352
|
+
if (t.version || !t.tins && t.points && t.tins_points) {
|
|
353
|
+
this.points = t.points, this.pointsWeightBuffer = !t.version || t.version < 2.00703 ? ["forw", "bakw"].reduce((s, i) => {
|
|
354
|
+
const n = t.weight_buffer[i];
|
|
355
|
+
return n && (s[i] = Object.keys(n).reduce((r, a) => {
|
|
356
|
+
const f = We(a);
|
|
357
|
+
return r[f] = n[a], r;
|
|
358
|
+
}, {})), s;
|
|
359
|
+
}, {}) : t.weight_buffer, t.strict_status ? this.strict_status = t.strict_status : t.kinks_points ? this.strict_status = xt.STATUS_ERROR : t.tins_points.length == 2 ? this.strict_status = xt.STATUS_LOOSE : this.strict_status = xt.STATUS_STRICT, this.vertices_params = {
|
|
360
|
+
forw: [t.vertices_params[0]],
|
|
361
|
+
bakw: [t.vertices_params[1]]
|
|
362
|
+
}, this.vertices_params.forw[1] = [0, 1, 2, 3].map((s) => {
|
|
363
|
+
const i = (s + 1) % 4, n = Gt(
|
|
364
|
+
["c", `b${s}`, `b${i}`],
|
|
365
|
+
t.points,
|
|
366
|
+
t.edgeNodes || [],
|
|
367
|
+
t.centroid_point,
|
|
368
|
+
t.vertices_points,
|
|
369
|
+
!1,
|
|
370
|
+
we
|
|
371
|
+
);
|
|
372
|
+
return Lt([n]);
|
|
373
|
+
}), this.vertices_params.bakw[1] = [0, 1, 2, 3].map((s) => {
|
|
374
|
+
const i = (s + 1) % 4, n = Gt(
|
|
375
|
+
["c", `b${s}`, `b${i}`],
|
|
376
|
+
t.points,
|
|
377
|
+
t.edgeNodes || [],
|
|
378
|
+
t.centroid_point,
|
|
379
|
+
t.vertices_points,
|
|
380
|
+
!0,
|
|
381
|
+
we
|
|
382
|
+
);
|
|
383
|
+
return Lt([n]);
|
|
384
|
+
}), this.centroid = {
|
|
385
|
+
forw: Yt(t.centroid_point[0], {
|
|
386
|
+
target: {
|
|
387
|
+
geom: t.centroid_point[1],
|
|
388
|
+
index: "c"
|
|
389
|
+
}
|
|
390
|
+
}),
|
|
391
|
+
bakw: Yt(t.centroid_point[1], {
|
|
392
|
+
target: {
|
|
393
|
+
geom: t.centroid_point[0],
|
|
394
|
+
index: "c"
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
}, this.edges = ze(t.edges || []), this.edgeNodes = t.edgeNodes || [];
|
|
398
|
+
const e = t.tins_points.length == 1 ? 0 : 1;
|
|
399
|
+
this.tins = {
|
|
400
|
+
forw: Lt(
|
|
401
|
+
t.tins_points[0].map(
|
|
402
|
+
(s) => Gt(
|
|
403
|
+
s,
|
|
404
|
+
t.points,
|
|
405
|
+
t.edgeNodes || [],
|
|
406
|
+
t.centroid_point,
|
|
407
|
+
t.vertices_points,
|
|
408
|
+
!1,
|
|
409
|
+
t.version
|
|
410
|
+
)
|
|
411
|
+
)
|
|
412
|
+
),
|
|
413
|
+
bakw: Lt(
|
|
414
|
+
t.tins_points[e].map(
|
|
415
|
+
(s) => Gt(
|
|
416
|
+
s,
|
|
417
|
+
t.points,
|
|
418
|
+
t.edgeNodes || [],
|
|
419
|
+
t.centroid_point,
|
|
420
|
+
t.vertices_points,
|
|
421
|
+
!0,
|
|
422
|
+
t.version
|
|
423
|
+
)
|
|
424
|
+
)
|
|
425
|
+
)
|
|
426
|
+
}, this.addIndexedTin(), t.kinks_points && (this.kinks = {
|
|
427
|
+
bakw: Lt(
|
|
428
|
+
t.kinks_points.map((s) => Yt(s))
|
|
429
|
+
)
|
|
430
|
+
}), t.yaxisMode ? this.yaxisMode = t.yaxisMode : this.yaxisMode = xt.YAXIS_INVERT, t.vertexMode && (this.vertexMode = t.vertexMode), t.strictMode && (this.strictMode = t.strictMode), t.bounds ? (this.bounds = t.bounds, this.boundsPolygon = t.boundsPolygon, this.xy = t.xy, this.wh = t.wh) : (this.xy = [0, 0], t.wh && (this.wh = t.wh), this.bounds = void 0, this.boundsPolygon = void 0);
|
|
431
|
+
} else {
|
|
432
|
+
t = JSON.parse(
|
|
433
|
+
JSON.stringify(t).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"')
|
|
434
|
+
), this.tins = t.tins, this.addIndexedTin(), this.strict_status = t.strict_status, this.pointsWeightBuffer = t.weight_buffer, this.vertices_params = t.vertices_params, this.centroid = t.centroid, this.kinks = t.kinks;
|
|
435
|
+
const e = [];
|
|
436
|
+
for (let s = 0; s < this.tins.forw.features.length; s++) {
|
|
437
|
+
const i = this.tins.forw.features[s];
|
|
438
|
+
["a", "b", "c"].map((n, r) => {
|
|
439
|
+
const a = i.geometry.coordinates[0][r], f = i.properties[n].geom, c = i.properties[n].index;
|
|
440
|
+
typeof c == "number" && (e[c] = [a, f]);
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
this.points = e;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* TINネットワークのインデックスを作成します
|
|
448
|
+
*
|
|
449
|
+
* インデックスは変換処理を高速化するために使用されます。
|
|
450
|
+
* グリッド形式のインデックスを作成し、各グリッドに
|
|
451
|
+
* 含まれる三角形を記録します。
|
|
452
|
+
*/
|
|
453
|
+
addIndexedTin() {
|
|
454
|
+
const t = this.tins, e = t.forw, s = t.bakw, i = Math.ceil(Math.sqrt(e.features.length));
|
|
455
|
+
if (i < 3) {
|
|
456
|
+
this.indexedTins = void 0;
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
let n = [], r = [];
|
|
460
|
+
const a = e.features.map((g) => {
|
|
461
|
+
let b = [];
|
|
462
|
+
return Ee(g)[0].map((w) => {
|
|
463
|
+
n.length === 0 ? n = [Array.from(w), Array.from(w)] : (w[0] < n[0][0] && (n[0][0] = w[0]), w[0] > n[1][0] && (n[1][0] = w[0]), w[1] < n[0][1] && (n[0][1] = w[1]), w[1] > n[1][1] && (n[1][1] = w[1])), b.length === 0 ? b = [Array.from(w), Array.from(w)] : (w[0] < b[0][0] && (b[0][0] = w[0]), w[0] > b[1][0] && (b[1][0] = w[0]), w[1] < b[0][1] && (b[0][1] = w[1]), w[1] > b[1][1] && (b[1][1] = w[1]));
|
|
464
|
+
}), b;
|
|
465
|
+
}), f = (n[1][0] - n[0][0]) / i, c = (n[1][1] - n[0][1]) / i, u = a.reduce(
|
|
466
|
+
(g, b, w) => {
|
|
467
|
+
const S = At(
|
|
468
|
+
b[0][0],
|
|
469
|
+
n[0][0],
|
|
470
|
+
f,
|
|
471
|
+
i
|
|
472
|
+
), _ = At(
|
|
473
|
+
b[1][0],
|
|
474
|
+
n[0][0],
|
|
475
|
+
f,
|
|
476
|
+
i
|
|
477
|
+
), v = At(
|
|
478
|
+
b[0][1],
|
|
479
|
+
n[0][1],
|
|
480
|
+
c,
|
|
481
|
+
i
|
|
482
|
+
), T = At(
|
|
483
|
+
b[1][1],
|
|
484
|
+
n[0][1],
|
|
485
|
+
c,
|
|
486
|
+
i
|
|
487
|
+
);
|
|
488
|
+
for (let I = S; I <= _; I++) {
|
|
489
|
+
g[I] || (g[I] = []);
|
|
490
|
+
for (let N = v; N <= T; N++)
|
|
491
|
+
g[I][N] || (g[I][N] = []), g[I][N].push(w);
|
|
492
|
+
}
|
|
493
|
+
return g;
|
|
494
|
+
},
|
|
495
|
+
[]
|
|
496
|
+
), h = s.features.map((g) => {
|
|
497
|
+
let b = [];
|
|
498
|
+
return Ee(g)[0].map((w) => {
|
|
499
|
+
r.length === 0 ? r = [Array.from(w), Array.from(w)] : (w[0] < r[0][0] && (r[0][0] = w[0]), w[0] > r[1][0] && (r[1][0] = w[0]), w[1] < r[0][1] && (r[0][1] = w[1]), w[1] > r[1][1] && (r[1][1] = w[1])), b.length === 0 ? b = [Array.from(w), Array.from(w)] : (w[0] < b[0][0] && (b[0][0] = w[0]), w[0] > b[1][0] && (b[1][0] = w[0]), w[1] < b[0][1] && (b[0][1] = w[1]), w[1] > b[1][1] && (b[1][1] = w[1]));
|
|
500
|
+
}), b;
|
|
501
|
+
}), l = (r[1][0] - r[0][0]) / i, p = (r[1][1] - r[0][1]) / i, y = h.reduce(
|
|
502
|
+
(g, b, w) => {
|
|
503
|
+
const S = At(
|
|
504
|
+
b[0][0],
|
|
505
|
+
r[0][0],
|
|
506
|
+
l,
|
|
507
|
+
i
|
|
508
|
+
), _ = At(
|
|
509
|
+
b[1][0],
|
|
510
|
+
r[0][0],
|
|
511
|
+
l,
|
|
512
|
+
i
|
|
513
|
+
), v = At(
|
|
514
|
+
b[0][1],
|
|
515
|
+
r[0][1],
|
|
516
|
+
p,
|
|
517
|
+
i
|
|
518
|
+
), T = At(
|
|
519
|
+
b[1][1],
|
|
520
|
+
r[0][1],
|
|
521
|
+
p,
|
|
522
|
+
i
|
|
523
|
+
);
|
|
524
|
+
for (let I = S; I <= _; I++) {
|
|
525
|
+
g[I] || (g[I] = []);
|
|
526
|
+
for (let N = v; N <= T; N++)
|
|
527
|
+
g[I][N] || (g[I][N] = []), g[I][N].push(w);
|
|
528
|
+
}
|
|
529
|
+
return g;
|
|
530
|
+
},
|
|
531
|
+
[]
|
|
532
|
+
);
|
|
533
|
+
this.indexedTins = {
|
|
534
|
+
forw: {
|
|
535
|
+
gridNum: i,
|
|
536
|
+
xOrigin: n[0][0],
|
|
537
|
+
yOrigin: n[0][1],
|
|
538
|
+
xUnit: f,
|
|
539
|
+
yUnit: c,
|
|
540
|
+
gridCache: u
|
|
541
|
+
},
|
|
542
|
+
bakw: {
|
|
543
|
+
gridNum: i,
|
|
544
|
+
xOrigin: r[0][0],
|
|
545
|
+
yOrigin: r[0][1],
|
|
546
|
+
xUnit: l,
|
|
547
|
+
yUnit: p,
|
|
548
|
+
gridCache: y
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* 座標変換を実行します
|
|
554
|
+
*
|
|
555
|
+
* @param apoint - 変換する座標
|
|
556
|
+
* @param backward - 逆方向の変換かどうか
|
|
557
|
+
* @param ignoreBounds - 境界チェックを無視するかどうか
|
|
558
|
+
* @returns 変換後の座標、または境界外の場合はfalse
|
|
559
|
+
*
|
|
560
|
+
* @throws {Error} 逆方向変換が許可されていない状態での逆変換時
|
|
561
|
+
*/
|
|
562
|
+
transform(t, e, s) {
|
|
563
|
+
if (e && this.strict_status == xt.STATUS_ERROR)
|
|
564
|
+
throw 'Backward transform is not allowed if strict_status == "strict_error"';
|
|
565
|
+
this.yaxisMode == xt.YAXIS_FOLLOW && e && (t = [t[0], -1 * t[1]]);
|
|
566
|
+
const i = Yt(t);
|
|
567
|
+
if (this.bounds && !e && !s && !pe(i, this.boundsPolygon))
|
|
568
|
+
return !1;
|
|
569
|
+
const n = e ? this.tins.bakw : this.tins.forw, r = e ? this.indexedTins.bakw : this.indexedTins.forw, a = e ? this.vertices_params.bakw : this.vertices_params.forw, f = e ? this.centroid.bakw : this.centroid.forw, c = e ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
|
|
570
|
+
let u, h;
|
|
571
|
+
this.stateFull && (this.stateBackward == e ? u = this.stateTriangle : (this.stateBackward = e, this.stateTriangle = void 0), h = (p) => {
|
|
572
|
+
this.stateTriangle = p;
|
|
573
|
+
});
|
|
574
|
+
let l = re(
|
|
575
|
+
i,
|
|
576
|
+
n,
|
|
577
|
+
r,
|
|
578
|
+
a,
|
|
579
|
+
f,
|
|
580
|
+
c,
|
|
581
|
+
u,
|
|
582
|
+
h
|
|
583
|
+
);
|
|
584
|
+
if (this.bounds && e && !s) {
|
|
585
|
+
const p = Yt(l);
|
|
586
|
+
if (!pe(p, this.boundsPolygon)) return !1;
|
|
587
|
+
} else this.yaxisMode == xt.YAXIS_FOLLOW && !e && (l = [l[0], -1 * l[1]]);
|
|
588
|
+
return l;
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
nt(kt, "VERTEX_PLAIN", "plain"), nt(kt, "VERTEX_BIRDEYE", "birdeye"), nt(kt, "MODE_STRICT", "strict"), nt(kt, "MODE_AUTO", "auto"), nt(kt, "MODE_LOOSE", "loose"), nt(kt, "STATUS_STRICT", "strict"), nt(kt, "STATUS_ERROR", "strict_error"), nt(kt, "STATUS_LOOSE", "loose"), nt(kt, "YAXIS_FOLLOW", "follow"), nt(kt, "YAXIS_INVERT", "invert");
|
|
592
|
+
let _s = kt;
|
|
593
|
+
const dt = 11102230246251565e-32, $ = 134217729, Ye = (3 + 8 * dt) * dt;
|
|
594
|
+
function ct(o, t, e, s, i) {
|
|
595
|
+
let n, r, a, f, c = t[0], u = s[0], h = 0, l = 0;
|
|
596
|
+
u > c == u > -c ? (n = c, c = t[++h]) : (n = u, u = s[++l]);
|
|
597
|
+
let p = 0;
|
|
598
|
+
if (h < o && l < e)
|
|
599
|
+
for (u > c == u > -c ? (r = c + n, a = n - (r - c), c = t[++h]) : (r = u + n, a = n - (r - u), u = s[++l]), n = r, a !== 0 && (i[p++] = a); h < o && l < e; )
|
|
600
|
+
u > c == u > -c ? (r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h]) : (r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l]), n = r, a !== 0 && (i[p++] = a);
|
|
601
|
+
for (; h < o; )
|
|
602
|
+
r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h], n = r, a !== 0 && (i[p++] = a);
|
|
603
|
+
for (; l < e; )
|
|
604
|
+
r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l], n = r, a !== 0 && (i[p++] = a);
|
|
605
|
+
return (n !== 0 || p === 0) && (i[p++] = n), p;
|
|
606
|
+
}
|
|
607
|
+
function yt(o, t, e, s, i, n, r, a) {
|
|
608
|
+
return ct(ct(o, t, e, s, r), r, i, n, a);
|
|
609
|
+
}
|
|
610
|
+
function M(o, t, e, s) {
|
|
611
|
+
let i, n, r, a, f, c, u, h, l, p, y;
|
|
612
|
+
u = $ * e, p = u - (u - e), y = e - p;
|
|
613
|
+
let g = t[0];
|
|
614
|
+
i = g * e, u = $ * g, h = u - (u - g), l = g - h, r = l * y - (i - h * p - l * p - h * y);
|
|
615
|
+
let b = 0;
|
|
616
|
+
r !== 0 && (s[b++] = r);
|
|
617
|
+
for (let w = 1; w < o; w++)
|
|
618
|
+
g = t[w], a = g * e, u = $ * g, h = u - (u - g), l = g - h, f = l * y - (a - h * p - l * p - h * y), n = i + f, c = n - i, r = i - (n - c) + (f - c), r !== 0 && (s[b++] = r), i = a + n, r = n - (i - a), r !== 0 && (s[b++] = r);
|
|
619
|
+
return (i !== 0 || b === 0) && (s[b++] = i), b;
|
|
620
|
+
}
|
|
621
|
+
function Ce(o, t) {
|
|
622
|
+
let e = t[0];
|
|
623
|
+
for (let s = 1; s < o; s++) e += t[s];
|
|
624
|
+
return e;
|
|
625
|
+
}
|
|
626
|
+
function H(o) {
|
|
627
|
+
return new Float64Array(o);
|
|
628
|
+
}
|
|
629
|
+
const Ms = (3 + 16 * dt) * dt, Ss = (2 + 12 * dt) * dt, As = (9 + 64 * dt) * dt * dt, Wt = H(4), Ie = H(8), Pe = H(12), $e = H(16), pt = H(4);
|
|
630
|
+
function Es(o, t, e, s, i, n, r) {
|
|
631
|
+
let a, f, c, u, h, l, p, y, g, b, w, S, _, v, T, I, N, V;
|
|
632
|
+
const z = o - i, G = e - i, tt = t - n, X = s - n;
|
|
633
|
+
v = z * X, l = $ * z, p = l - (l - z), y = z - p, l = $ * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = tt * G, l = $ * tt, p = l - (l - tt), y = tt - p, l = $ * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, Wt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, Wt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, Wt[2] = S - (V - h) + (w - h), Wt[3] = V;
|
|
634
|
+
let it = Ce(4, Wt), d = Ss * r;
|
|
635
|
+
if (it >= d || -it >= d || (h = o - z, a = o - (z + h) + (h - i), h = e - G, c = e - (G + h) + (h - i), h = t - tt, f = t - (tt + h) + (h - n), h = s - X, u = s - (X + h) + (h - n), a === 0 && f === 0 && c === 0 && u === 0) || (d = As * r + Ye * Math.abs(it), it += z * u + X * a - (tt * c + G * f), it >= d || -it >= d)) return it;
|
|
636
|
+
v = a * X, l = $ * a, p = l - (l - a), y = a - p, l = $ * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = f * G, l = $ * f, p = l - (l - f), y = f - p, l = $ * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, pt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, pt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, pt[2] = S - (V - h) + (w - h), pt[3] = V;
|
|
637
|
+
const m = ct(4, Wt, 4, pt, Ie);
|
|
638
|
+
v = z * u, l = $ * z, p = l - (l - z), y = z - p, l = $ * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = tt * c, l = $ * tt, p = l - (l - tt), y = tt - p, l = $ * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, pt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, pt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, pt[2] = S - (V - h) + (w - h), pt[3] = V;
|
|
639
|
+
const x = ct(m, Ie, 4, pt, Pe);
|
|
640
|
+
v = a * u, l = $ * a, p = l - (l - a), y = a - p, l = $ * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = f * c, l = $ * f, p = l - (l - f), y = f - p, l = $ * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, pt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, pt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, pt[2] = S - (V - h) + (w - h), pt[3] = V;
|
|
641
|
+
const A = ct(x, Pe, 4, pt, $e);
|
|
642
|
+
return $e[A - 1];
|
|
643
|
+
}
|
|
644
|
+
function Ct(o, t, e, s, i, n) {
|
|
645
|
+
const r = (t - n) * (e - i), a = (o - i) * (s - n), f = r - a, c = Math.abs(r + a);
|
|
646
|
+
return Math.abs(f) >= Ms * c ? f : -Es(o, t, e, s, i, n, c);
|
|
647
|
+
}
|
|
648
|
+
const vs = (10 + 96 * dt) * dt, Os = (4 + 48 * dt) * dt, Ts = (44 + 576 * dt) * dt * dt, It = H(4), Pt = H(4), $t = H(4), _t = H(4), Mt = H(4), St = H(4), wt = H(4), mt = H(4), he = H(8), ce = H(8), fe = H(8), ue = H(8), le = H(8), de = H(8), Kt = H(8), Qt = H(8), Zt = H(8), Bt = H(4), Dt = H(4), Ft = H(4), U = H(8), L = H(16), et = H(16), st = H(16), Z = H(32), Rt = H(32), ot = H(48), bt = H(64);
|
|
649
|
+
let zt = H(1152), ge = H(1152);
|
|
650
|
+
function at(o, t, e) {
|
|
651
|
+
o = ct(o, zt, t, e, ge);
|
|
652
|
+
const s = zt;
|
|
653
|
+
return zt = ge, ge = s, o;
|
|
654
|
+
}
|
|
655
|
+
function Is(o, t, e, s, i, n, r, a, f) {
|
|
656
|
+
let c, u, h, l, p, y, g, b, w, S, _, v, T, I, N, V, z, G, tt, X, it, d, m, x, A, E, R, k, O, B, P, D, F, W, j;
|
|
657
|
+
const Y = o - r, C = e - r, q = i - r, K = t - a, J = s - a, Q = n - a;
|
|
658
|
+
P = C * Q, m = $ * C, x = m - (m - C), A = C - x, m = $ * Q, E = m - (m - Q), R = Q - E, D = A * R - (P - x * E - A * E - x * R), F = q * J, m = $ * q, x = m - (m - q), A = q - x, m = $ * J, E = m - (m - J), R = J - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, It[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, It[1] = B - (k + d) + (d - F), j = O + k, d = j - O, It[2] = O - (j - d) + (k - d), It[3] = j, P = q * K, m = $ * q, x = m - (m - q), A = q - x, m = $ * K, E = m - (m - K), R = K - E, D = A * R - (P - x * E - A * E - x * R), F = Y * Q, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * Q, E = m - (m - Q), R = Q - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Pt[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Pt[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Pt[2] = O - (j - d) + (k - d), Pt[3] = j, P = Y * J, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * J, E = m - (m - J), R = J - E, D = A * R - (P - x * E - A * E - x * R), F = C * K, m = $ * C, x = m - (m - C), A = C - x, m = $ * K, E = m - (m - K), R = K - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, $t[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, $t[1] = B - (k + d) + (d - F), j = O + k, d = j - O, $t[2] = O - (j - d) + (k - d), $t[3] = j, c = ct(
|
|
659
|
+
ct(
|
|
660
|
+
ct(
|
|
661
|
+
M(M(4, It, Y, U), U, Y, L),
|
|
662
|
+
L,
|
|
663
|
+
M(M(4, It, K, U), U, K, et),
|
|
664
|
+
et,
|
|
665
|
+
Z
|
|
666
|
+
),
|
|
667
|
+
Z,
|
|
668
|
+
ct(
|
|
669
|
+
M(M(4, Pt, C, U), U, C, L),
|
|
670
|
+
L,
|
|
671
|
+
M(M(4, Pt, J, U), U, J, et),
|
|
672
|
+
et,
|
|
673
|
+
Rt
|
|
674
|
+
),
|
|
675
|
+
Rt,
|
|
676
|
+
bt
|
|
677
|
+
),
|
|
678
|
+
bt,
|
|
679
|
+
ct(
|
|
680
|
+
M(M(4, $t, q, U), U, q, L),
|
|
681
|
+
L,
|
|
682
|
+
M(M(4, $t, Q, U), U, Q, et),
|
|
683
|
+
et,
|
|
684
|
+
Z
|
|
685
|
+
),
|
|
686
|
+
Z,
|
|
687
|
+
zt
|
|
688
|
+
);
|
|
689
|
+
let Ut = Ce(c, zt), Xt = Os * f;
|
|
690
|
+
if (Ut >= Xt || -Ut >= Xt || (d = o - Y, u = o - (Y + d) + (d - r), d = t - K, p = t - (K + d) + (d - a), d = e - C, h = e - (C + d) + (d - r), d = s - J, y = s - (J + d) + (d - a), d = i - q, l = i - (q + d) + (d - r), d = n - Q, g = n - (Q + d) + (d - a), u === 0 && h === 0 && l === 0 && p === 0 && y === 0 && g === 0) || (Xt = Ts * f + Ye * Math.abs(Ut), Ut += (Y * Y + K * K) * (C * g + Q * h - (J * l + q * y)) + 2 * (Y * u + K * p) * (C * Q - J * q) + ((C * C + J * J) * (q * p + K * l - (Q * u + Y * g)) + 2 * (C * h + J * y) * (q * K - Q * Y)) + ((q * q + Q * Q) * (Y * y + J * u - (K * h + C * p)) + 2 * (q * l + Q * g) * (Y * J - K * C)), Ut >= Xt || -Ut >= Xt))
|
|
691
|
+
return Ut;
|
|
692
|
+
if ((h !== 0 || y !== 0 || l !== 0 || g !== 0) && (P = Y * Y, m = $ * Y, x = m - (m - Y), A = Y - x, D = A * A - (P - x * x - (x + x) * A), F = K * K, m = $ * K, x = m - (m - K), A = K - x, W = A * A - (F - x * x - (x + x) * A), k = D + W, d = k - D, _t[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, _t[1] = B - (k - d) + (F - d), j = O + k, d = j - O, _t[2] = O - (j - d) + (k - d), _t[3] = j), (l !== 0 || g !== 0 || u !== 0 || p !== 0) && (P = C * C, m = $ * C, x = m - (m - C), A = C - x, D = A * A - (P - x * x - (x + x) * A), F = J * J, m = $ * J, x = m - (m - J), A = J - x, W = A * A - (F - x * x - (x + x) * A), k = D + W, d = k - D, Mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, Mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, Mt[2] = O - (j - d) + (k - d), Mt[3] = j), (u !== 0 || p !== 0 || h !== 0 || y !== 0) && (P = q * q, m = $ * q, x = m - (m - q), A = q - x, D = A * A - (P - x * x - (x + x) * A), F = Q * Q, m = $ * Q, x = m - (m - Q), A = Q - x, W = A * A - (F - x * x - (x + x) * A), k = D + W, d = k - D, St[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, St[1] = B - (k - d) + (F - d), j = O + k, d = j - O, St[2] = O - (j - d) + (k - d), St[3] = j), u !== 0 && (b = M(4, It, u, he), c = at(c, yt(
|
|
693
|
+
M(b, he, 2 * Y, L),
|
|
694
|
+
L,
|
|
695
|
+
M(M(4, St, u, U), U, J, et),
|
|
696
|
+
et,
|
|
697
|
+
M(M(4, Mt, u, U), U, -Q, st),
|
|
698
|
+
st,
|
|
699
|
+
Z,
|
|
700
|
+
ot
|
|
701
|
+
), ot)), p !== 0 && (w = M(4, It, p, ce), c = at(c, yt(
|
|
702
|
+
M(w, ce, 2 * K, L),
|
|
703
|
+
L,
|
|
704
|
+
M(M(4, Mt, p, U), U, q, et),
|
|
705
|
+
et,
|
|
706
|
+
M(M(4, St, p, U), U, -C, st),
|
|
707
|
+
st,
|
|
708
|
+
Z,
|
|
709
|
+
ot
|
|
710
|
+
), ot)), h !== 0 && (S = M(4, Pt, h, fe), c = at(c, yt(
|
|
711
|
+
M(S, fe, 2 * C, L),
|
|
712
|
+
L,
|
|
713
|
+
M(M(4, _t, h, U), U, Q, et),
|
|
714
|
+
et,
|
|
715
|
+
M(M(4, St, h, U), U, -K, st),
|
|
716
|
+
st,
|
|
717
|
+
Z,
|
|
718
|
+
ot
|
|
719
|
+
), ot)), y !== 0 && (_ = M(4, Pt, y, ue), c = at(c, yt(
|
|
720
|
+
M(_, ue, 2 * J, L),
|
|
721
|
+
L,
|
|
722
|
+
M(M(4, St, y, U), U, Y, et),
|
|
723
|
+
et,
|
|
724
|
+
M(M(4, _t, y, U), U, -q, st),
|
|
725
|
+
st,
|
|
726
|
+
Z,
|
|
727
|
+
ot
|
|
728
|
+
), ot)), l !== 0 && (v = M(4, $t, l, le), c = at(c, yt(
|
|
729
|
+
M(v, le, 2 * q, L),
|
|
730
|
+
L,
|
|
731
|
+
M(M(4, Mt, l, U), U, K, et),
|
|
732
|
+
et,
|
|
733
|
+
M(M(4, _t, l, U), U, -J, st),
|
|
734
|
+
st,
|
|
735
|
+
Z,
|
|
736
|
+
ot
|
|
737
|
+
), ot)), g !== 0 && (T = M(4, $t, g, de), c = at(c, yt(
|
|
738
|
+
M(T, de, 2 * Q, L),
|
|
739
|
+
L,
|
|
740
|
+
M(M(4, _t, g, U), U, C, et),
|
|
741
|
+
et,
|
|
742
|
+
M(M(4, Mt, g, U), U, -Y, st),
|
|
743
|
+
st,
|
|
744
|
+
Z,
|
|
745
|
+
ot
|
|
746
|
+
), ot)), u !== 0 || p !== 0) {
|
|
747
|
+
if (h !== 0 || y !== 0 || l !== 0 || g !== 0 ? (P = h * Q, m = $ * h, x = m - (m - h), A = h - x, m = $ * Q, E = m - (m - Q), R = Q - E, D = A * R - (P - x * E - A * E - x * R), F = C * g, m = $ * C, x = m - (m - C), A = C - x, m = $ * g, E = m - (m - g), R = g - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, wt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, wt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, wt[2] = O - (j - d) + (k - d), wt[3] = j, P = l * -J, m = $ * l, x = m - (m - l), A = l - x, m = $ * -J, E = m - (m - -J), R = -J - E, D = A * R - (P - x * E - A * E - x * R), F = q * -y, m = $ * q, x = m - (m - q), A = q - x, m = $ * -y, E = m - (m - -y), R = -y - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, mt[2] = O - (j - d) + (k - d), mt[3] = j, N = ct(4, wt, 4, mt, Qt), P = h * g, m = $ * h, x = m - (m - h), A = h - x, m = $ * g, E = m - (m - g), R = g - E, D = A * R - (P - x * E - A * E - x * R), F = l * y, m = $ * l, x = m - (m - l), A = l - x, m = $ * y, E = m - (m - y), R = y - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Dt[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Dt[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Dt[2] = O - (j - d) + (k - d), Dt[3] = j, G = 4) : (Qt[0] = 0, N = 1, Dt[0] = 0, G = 1), u !== 0) {
|
|
748
|
+
const ft = M(N, Qt, u, st);
|
|
749
|
+
c = at(c, ct(
|
|
750
|
+
M(b, he, u, L),
|
|
751
|
+
L,
|
|
752
|
+
M(ft, st, 2 * Y, Z),
|
|
753
|
+
Z,
|
|
754
|
+
ot
|
|
755
|
+
), ot);
|
|
756
|
+
const ut = M(G, Dt, u, U);
|
|
757
|
+
c = at(c, yt(
|
|
758
|
+
M(ut, U, 2 * Y, L),
|
|
759
|
+
L,
|
|
760
|
+
M(ut, U, u, et),
|
|
761
|
+
et,
|
|
762
|
+
M(ft, st, u, Z),
|
|
763
|
+
Z,
|
|
764
|
+
Rt,
|
|
765
|
+
bt
|
|
766
|
+
), bt), y !== 0 && (c = at(c, M(M(4, St, u, U), U, y, L), L)), g !== 0 && (c = at(c, M(M(4, Mt, -u, U), U, g, L), L));
|
|
767
|
+
}
|
|
768
|
+
if (p !== 0) {
|
|
769
|
+
const ft = M(N, Qt, p, st);
|
|
770
|
+
c = at(c, ct(
|
|
771
|
+
M(w, ce, p, L),
|
|
772
|
+
L,
|
|
773
|
+
M(ft, st, 2 * K, Z),
|
|
774
|
+
Z,
|
|
775
|
+
ot
|
|
776
|
+
), ot);
|
|
777
|
+
const ut = M(G, Dt, p, U);
|
|
778
|
+
c = at(c, yt(
|
|
779
|
+
M(ut, U, 2 * K, L),
|
|
780
|
+
L,
|
|
781
|
+
M(ut, U, p, et),
|
|
782
|
+
et,
|
|
783
|
+
M(ft, st, p, Z),
|
|
784
|
+
Z,
|
|
785
|
+
Rt,
|
|
786
|
+
bt
|
|
787
|
+
), bt);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (h !== 0 || y !== 0) {
|
|
791
|
+
if (l !== 0 || g !== 0 || u !== 0 || p !== 0 ? (P = l * K, m = $ * l, x = m - (m - l), A = l - x, m = $ * K, E = m - (m - K), R = K - E, D = A * R - (P - x * E - A * E - x * R), F = q * p, m = $ * q, x = m - (m - q), A = q - x, m = $ * p, E = m - (m - p), R = p - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, wt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, wt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, wt[2] = O - (j - d) + (k - d), wt[3] = j, X = -Q, it = -g, P = u * X, m = $ * u, x = m - (m - u), A = u - x, m = $ * X, E = m - (m - X), R = X - E, D = A * R - (P - x * E - A * E - x * R), F = Y * it, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * it, E = m - (m - it), R = it - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, mt[2] = O - (j - d) + (k - d), mt[3] = j, V = ct(4, wt, 4, mt, Zt), P = l * p, m = $ * l, x = m - (m - l), A = l - x, m = $ * p, E = m - (m - p), R = p - E, D = A * R - (P - x * E - A * E - x * R), F = u * g, m = $ * u, x = m - (m - u), A = u - x, m = $ * g, E = m - (m - g), R = g - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Ft[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Ft[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Ft[2] = O - (j - d) + (k - d), Ft[3] = j, tt = 4) : (Zt[0] = 0, V = 1, Ft[0] = 0, tt = 1), h !== 0) {
|
|
792
|
+
const ft = M(V, Zt, h, st);
|
|
793
|
+
c = at(c, ct(
|
|
794
|
+
M(S, fe, h, L),
|
|
795
|
+
L,
|
|
796
|
+
M(ft, st, 2 * C, Z),
|
|
797
|
+
Z,
|
|
798
|
+
ot
|
|
799
|
+
), ot);
|
|
800
|
+
const ut = M(tt, Ft, h, U);
|
|
801
|
+
c = at(c, yt(
|
|
802
|
+
M(ut, U, 2 * C, L),
|
|
803
|
+
L,
|
|
804
|
+
M(ut, U, h, et),
|
|
805
|
+
et,
|
|
806
|
+
M(ft, st, h, Z),
|
|
807
|
+
Z,
|
|
808
|
+
Rt,
|
|
809
|
+
bt
|
|
810
|
+
), bt), g !== 0 && (c = at(c, M(M(4, _t, h, U), U, g, L), L)), p !== 0 && (c = at(c, M(M(4, St, -h, U), U, p, L), L));
|
|
811
|
+
}
|
|
812
|
+
if (y !== 0) {
|
|
813
|
+
const ft = M(V, Zt, y, st);
|
|
814
|
+
c = at(c, ct(
|
|
815
|
+
M(_, ue, y, L),
|
|
816
|
+
L,
|
|
817
|
+
M(ft, st, 2 * J, Z),
|
|
818
|
+
Z,
|
|
819
|
+
ot
|
|
820
|
+
), ot);
|
|
821
|
+
const ut = M(tt, Ft, y, U);
|
|
822
|
+
c = at(c, yt(
|
|
823
|
+
M(ut, U, 2 * J, L),
|
|
824
|
+
L,
|
|
825
|
+
M(ut, U, y, et),
|
|
826
|
+
et,
|
|
827
|
+
M(ft, st, y, Z),
|
|
828
|
+
Z,
|
|
829
|
+
Rt,
|
|
830
|
+
bt
|
|
831
|
+
), bt);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (l !== 0 || g !== 0) {
|
|
835
|
+
if (u !== 0 || p !== 0 || h !== 0 || y !== 0 ? (P = u * J, m = $ * u, x = m - (m - u), A = u - x, m = $ * J, E = m - (m - J), R = J - E, D = A * R - (P - x * E - A * E - x * R), F = Y * y, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * y, E = m - (m - y), R = y - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, wt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, wt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, wt[2] = O - (j - d) + (k - d), wt[3] = j, X = -K, it = -p, P = h * X, m = $ * h, x = m - (m - h), A = h - x, m = $ * X, E = m - (m - X), R = X - E, D = A * R - (P - x * E - A * E - x * R), F = C * it, m = $ * C, x = m - (m - C), A = C - x, m = $ * it, E = m - (m - it), R = it - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, mt[2] = O - (j - d) + (k - d), mt[3] = j, I = ct(4, wt, 4, mt, Kt), P = u * y, m = $ * u, x = m - (m - u), A = u - x, m = $ * y, E = m - (m - y), R = y - E, D = A * R - (P - x * E - A * E - x * R), F = h * p, m = $ * h, x = m - (m - h), A = h - x, m = $ * p, E = m - (m - p), R = p - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Bt[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Bt[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Bt[2] = O - (j - d) + (k - d), Bt[3] = j, z = 4) : (Kt[0] = 0, I = 1, Bt[0] = 0, z = 1), l !== 0) {
|
|
836
|
+
const ft = M(I, Kt, l, st);
|
|
837
|
+
c = at(c, ct(
|
|
838
|
+
M(v, le, l, L),
|
|
839
|
+
L,
|
|
840
|
+
M(ft, st, 2 * q, Z),
|
|
841
|
+
Z,
|
|
842
|
+
ot
|
|
843
|
+
), ot);
|
|
844
|
+
const ut = M(z, Bt, l, U);
|
|
845
|
+
c = at(c, yt(
|
|
846
|
+
M(ut, U, 2 * q, L),
|
|
847
|
+
L,
|
|
848
|
+
M(ut, U, l, et),
|
|
849
|
+
et,
|
|
850
|
+
M(ft, st, l, Z),
|
|
851
|
+
Z,
|
|
852
|
+
Rt,
|
|
853
|
+
bt
|
|
854
|
+
), bt), p !== 0 && (c = at(c, M(M(4, Mt, l, U), U, p, L), L)), y !== 0 && (c = at(c, M(M(4, _t, -l, U), U, y, L), L));
|
|
855
|
+
}
|
|
856
|
+
if (g !== 0) {
|
|
857
|
+
const ft = M(I, Kt, g, st);
|
|
858
|
+
c = at(c, ct(
|
|
859
|
+
M(T, de, g, L),
|
|
860
|
+
L,
|
|
861
|
+
M(ft, st, 2 * Q, Z),
|
|
862
|
+
Z,
|
|
863
|
+
ot
|
|
864
|
+
), ot);
|
|
865
|
+
const ut = M(z, Bt, g, U);
|
|
866
|
+
c = at(c, yt(
|
|
867
|
+
M(ut, U, 2 * Q, L),
|
|
868
|
+
L,
|
|
869
|
+
M(ut, U, g, et),
|
|
870
|
+
et,
|
|
871
|
+
M(ft, st, g, Z),
|
|
872
|
+
Z,
|
|
873
|
+
Rt,
|
|
874
|
+
bt
|
|
875
|
+
), bt);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return zt[c - 1];
|
|
879
|
+
}
|
|
880
|
+
function Ps(o, t, e, s, i, n, r, a) {
|
|
881
|
+
const f = o - r, c = e - r, u = i - r, h = t - a, l = s - a, p = n - a, y = c * p, g = u * l, b = f * f + h * h, w = u * h, S = f * p, _ = c * c + l * l, v = f * l, T = c * h, I = u * u + p * p, N = b * (y - g) + _ * (w - S) + I * (v - T), V = (Math.abs(y) + Math.abs(g)) * b + (Math.abs(w) + Math.abs(S)) * _ + (Math.abs(v) + Math.abs(T)) * I, z = vs * V;
|
|
882
|
+
return N > z || -N > z ? N : Is(o, t, e, s, i, n, r, a, V);
|
|
883
|
+
}
|
|
884
|
+
class $s {
|
|
885
|
+
constructor(t, e) {
|
|
886
|
+
this.W = t, this.bs = e;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Add a number to the set.
|
|
890
|
+
*
|
|
891
|
+
* @param idx The number to add. Must be 0 <= idx < len.
|
|
892
|
+
* @return this.
|
|
893
|
+
*/
|
|
894
|
+
add(t) {
|
|
895
|
+
const e = this.W, s = t / e | 0, i = t % e;
|
|
896
|
+
return this.bs[s] |= 1 << i, this;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Delete a number from the set.
|
|
900
|
+
*
|
|
901
|
+
* @param idx The number to delete. Must be 0 <= idx < len.
|
|
902
|
+
* @return this.
|
|
903
|
+
*/
|
|
904
|
+
delete(t) {
|
|
905
|
+
const e = this.W, s = t / e | 0, i = t % e;
|
|
906
|
+
return this.bs[s] &= ~(1 << i), this;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Add or delete a number in the set, depending on the second argument.
|
|
910
|
+
*
|
|
911
|
+
* @param idx The number to add or delete. Must be 0 <= idx < len.
|
|
912
|
+
* @param val If true, add the number, otherwise delete.
|
|
913
|
+
* @return val.
|
|
914
|
+
*/
|
|
915
|
+
set(t, e) {
|
|
916
|
+
const s = this.W, i = t / s | 0, n = t % s, r = 1 << n;
|
|
917
|
+
return this.bs[i] ^= (-e ^ this.bs[i]) & r, e;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Whether the number is in the set.
|
|
921
|
+
*
|
|
922
|
+
* @param idx The number to test. Must be 0 <= idx < len.
|
|
923
|
+
* @return True if the number is in the set.
|
|
924
|
+
*/
|
|
925
|
+
has(t) {
|
|
926
|
+
const e = this.W, s = t / e | 0, i = t % e;
|
|
927
|
+
return !!(this.bs[s] & 1 << i);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Iterate over the numbers that are in the set. The callback is invoked
|
|
931
|
+
* with each number that is set. It is allowed to change the BitSet during
|
|
932
|
+
* iteration. If it deletes a number that has not been iterated over, that
|
|
933
|
+
* number will not show up in a later call. If it adds a number during
|
|
934
|
+
* iteration, that number may or may not show up in a later call.
|
|
935
|
+
*
|
|
936
|
+
* @param fn The function to call for each number.
|
|
937
|
+
* @return this.
|
|
938
|
+
*/
|
|
939
|
+
forEach(t) {
|
|
940
|
+
const e = this.W, s = this.bs, i = s.length;
|
|
941
|
+
for (let n = 0; n < i; n++) {
|
|
942
|
+
let r = 0;
|
|
943
|
+
for (; s[n] && r < e; )
|
|
944
|
+
s[n] & 1 << r && t(n * e + r), r++;
|
|
945
|
+
}
|
|
946
|
+
return this;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
class Re extends $s {
|
|
950
|
+
/**
|
|
951
|
+
* Create a bit set.
|
|
952
|
+
*
|
|
953
|
+
* @param len The length of the bit set, limiting the maximum value that
|
|
954
|
+
* can be stored in it to len - 1.
|
|
955
|
+
*/
|
|
956
|
+
constructor(t) {
|
|
957
|
+
const e = new Uint8Array(Math.ceil(t / 8)).fill(0);
|
|
958
|
+
super(8, e);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function jt(o) {
|
|
962
|
+
return o % 3 === 2 ? o - 2 : o + 1;
|
|
963
|
+
}
|
|
964
|
+
function Et(o) {
|
|
965
|
+
return o % 3 === 0 ? o + 2 : o - 1;
|
|
966
|
+
}
|
|
967
|
+
function qe(o, t, e, s, i, n, r, a) {
|
|
968
|
+
const f = Ct(o, t, i, n, r, a), c = Ct(e, s, i, n, r, a);
|
|
969
|
+
if (f > 0 && c > 0 || f < 0 && c < 0)
|
|
970
|
+
return !1;
|
|
971
|
+
const u = Ct(i, n, o, t, e, s), h = Ct(r, a, o, t, e, s);
|
|
972
|
+
return u > 0 && h > 0 || u < 0 && h < 0 ? !1 : f === 0 && c === 0 && u === 0 && h === 0 ? !(Math.max(i, r) < Math.min(o, e) || Math.max(o, e) < Math.min(i, r) || Math.max(n, a) < Math.min(t, s) || Math.max(t, s) < Math.min(n, a)) : !0;
|
|
973
|
+
}
|
|
974
|
+
class Rs {
|
|
975
|
+
constructor(t) {
|
|
976
|
+
this.del = t;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
const Je = class extends Rs {
|
|
980
|
+
/**
|
|
981
|
+
* Make a Constrain.
|
|
982
|
+
*
|
|
983
|
+
* @param del The triangulation output from Delaunator.
|
|
984
|
+
* @param edges If provided, constrain these edges as by constrainAll.
|
|
985
|
+
*/
|
|
986
|
+
constructor(t, e) {
|
|
987
|
+
if (!t || typeof t != "object" || !t.triangles || !t.halfedges || !t.coords)
|
|
988
|
+
throw new Error("Expected an object with Delaunator output");
|
|
989
|
+
if (t.triangles.length % 3 || t.halfedges.length !== t.triangles.length || t.coords.length % 2)
|
|
990
|
+
throw new Error("Delaunator output appears inconsistent");
|
|
991
|
+
if (t.triangles.length < 3)
|
|
992
|
+
throw new Error("No edges in triangulation");
|
|
993
|
+
super(t);
|
|
994
|
+
const s = 2 ** 32 - 1, i = t.coords.length >> 1, n = t.triangles.length;
|
|
995
|
+
this.vertMap = new Uint32Array(i).fill(s), this.flips = new Re(n), this.consd = new Re(n);
|
|
996
|
+
for (let r = 0; r < n; r++) {
|
|
997
|
+
const a = t.triangles[r];
|
|
998
|
+
this.vertMap[a] === s && this.updateVert(r);
|
|
999
|
+
}
|
|
1000
|
+
e && this.constrainAll(e);
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Constrain the triangulation such that there is an edge between p1 and p2.
|
|
1004
|
+
*/
|
|
1005
|
+
constrainOne(t, e) {
|
|
1006
|
+
const { triangles: s, halfedges: i } = this.del, n = this.vertMap[t];
|
|
1007
|
+
let r = n;
|
|
1008
|
+
do {
|
|
1009
|
+
const c = s[r], u = jt(r);
|
|
1010
|
+
if (c === e)
|
|
1011
|
+
return this.protect(r);
|
|
1012
|
+
const h = Et(r), l = s[h];
|
|
1013
|
+
if (l === e)
|
|
1014
|
+
return this.protect(u), u;
|
|
1015
|
+
if (this.intersectSegments(t, e, l, c)) {
|
|
1016
|
+
r = h;
|
|
1017
|
+
break;
|
|
1018
|
+
}
|
|
1019
|
+
r = i[u];
|
|
1020
|
+
} while (r !== -1 && r !== n);
|
|
1021
|
+
let a = r, f = -1;
|
|
1022
|
+
for (; r !== -1; ) {
|
|
1023
|
+
const c = i[r], u = Et(r), h = Et(c), l = jt(c);
|
|
1024
|
+
if (c === -1)
|
|
1025
|
+
throw new Error("Constraining edge exited the hull");
|
|
1026
|
+
if (this.consd.has(r))
|
|
1027
|
+
throw new Error("Edge intersects already constrained edge");
|
|
1028
|
+
if (this.isCollinear(t, e, s[r]) || this.isCollinear(t, e, s[c]))
|
|
1029
|
+
throw new Error("Constraining edge intersects point");
|
|
1030
|
+
if (!this.intersectSegments(
|
|
1031
|
+
s[r],
|
|
1032
|
+
s[c],
|
|
1033
|
+
s[u],
|
|
1034
|
+
s[h]
|
|
1035
|
+
)) {
|
|
1036
|
+
if (f === -1 && (f = r), s[h] === e) {
|
|
1037
|
+
if (r === f)
|
|
1038
|
+
throw new Error("Infinite loop: non-convex quadrilateral");
|
|
1039
|
+
r = f, f = -1;
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
if (this.intersectSegments(t, e, s[h], s[c]))
|
|
1043
|
+
r = h;
|
|
1044
|
+
else if (this.intersectSegments(t, e, s[l], s[h]))
|
|
1045
|
+
r = l;
|
|
1046
|
+
else if (f === r)
|
|
1047
|
+
throw new Error("Infinite loop: no further intersect after non-convex");
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
if (this.flipDiagonal(r), this.intersectSegments(t, e, s[u], s[h]) && (f === -1 && (f = u), f === u))
|
|
1051
|
+
throw new Error("Infinite loop: flipped diagonal still intersects");
|
|
1052
|
+
s[h] === e ? (a = h, r = f, f = -1) : this.intersectSegments(t, e, s[l], s[h]) && (r = l);
|
|
1053
|
+
}
|
|
1054
|
+
return this.protect(a), this.delaunify(!0), this.findEdge(t, e);
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Fix the Delaunay condition.
|
|
1058
|
+
*/
|
|
1059
|
+
delaunify(t = !1) {
|
|
1060
|
+
const { halfedges: e } = this.del, s = this.flips, i = this.consd, n = e.length;
|
|
1061
|
+
do {
|
|
1062
|
+
var r = 0;
|
|
1063
|
+
for (let a = 0; a < n; a++) {
|
|
1064
|
+
if (i.has(a))
|
|
1065
|
+
continue;
|
|
1066
|
+
s.delete(a);
|
|
1067
|
+
const f = e[a];
|
|
1068
|
+
f !== -1 && (s.delete(f), this.isDelaunay(a) || (this.flipDiagonal(a), r++));
|
|
1069
|
+
}
|
|
1070
|
+
} while (t && r > 0);
|
|
1071
|
+
return this;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Call constrainOne on each edge
|
|
1075
|
+
*/
|
|
1076
|
+
constrainAll(t) {
|
|
1077
|
+
const e = t.length;
|
|
1078
|
+
for (let s = 0; s < e; s++) {
|
|
1079
|
+
const i = t[s];
|
|
1080
|
+
this.constrainOne(i[0], i[1]);
|
|
1081
|
+
}
|
|
1082
|
+
return this;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Whether an edge is constrained
|
|
1086
|
+
*/
|
|
1087
|
+
isConstrained(t) {
|
|
1088
|
+
return this.consd.has(t);
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Find the edge that points from p1 -> p2. If there is only an edge from
|
|
1092
|
+
* p2 -> p1 (i.e. it is on the hull), returns the negative id of it.
|
|
1093
|
+
*/
|
|
1094
|
+
findEdge(t, e) {
|
|
1095
|
+
const s = this.vertMap[e], { triangles: i, halfedges: n } = this.del;
|
|
1096
|
+
let r = s, a = -1;
|
|
1097
|
+
do {
|
|
1098
|
+
if (i[r] === t)
|
|
1099
|
+
return r;
|
|
1100
|
+
a = jt(r), r = n[a];
|
|
1101
|
+
} while (r !== -1 && r !== s);
|
|
1102
|
+
return i[jt(a)] === t ? -a : 1 / 0;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Mark an edge as constrained, i.e. should not be touched by `delaunify`.
|
|
1106
|
+
*/
|
|
1107
|
+
protect(t) {
|
|
1108
|
+
const e = this.del.halfedges[t], s = this.flips, i = this.consd;
|
|
1109
|
+
return s.delete(t), i.add(t), e !== -1 ? (s.delete(e), i.add(e), e) : -t;
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Mark an edge as flipped unless constrained.
|
|
1113
|
+
*/
|
|
1114
|
+
markFlip(t) {
|
|
1115
|
+
const e = this.del.halfedges, s = this.flips;
|
|
1116
|
+
if (this.consd.has(t))
|
|
1117
|
+
return !1;
|
|
1118
|
+
const i = e[t];
|
|
1119
|
+
return i !== -1 && (s.add(t), s.add(i)), !0;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Flip the edge shared by two triangles.
|
|
1123
|
+
*/
|
|
1124
|
+
flipDiagonal(t) {
|
|
1125
|
+
const { triangles: e, halfedges: s } = this.del, i = this.flips, n = this.consd, r = s[t], a = Et(t), f = jt(t), c = Et(r), u = jt(r), h = s[a], l = s[c];
|
|
1126
|
+
if (n.has(t))
|
|
1127
|
+
throw new Error("Trying to flip a constrained edge");
|
|
1128
|
+
return e[t] = e[c], s[t] = l, i.set(t, i.has(c)) || n.set(t, n.has(c)), l !== -1 && (s[l] = t), s[a] = c, e[r] = e[a], s[r] = h, i.set(r, i.has(a)) || n.set(r, n.has(a)), h !== -1 && (s[h] = r), s[c] = a, this.markFlip(t), this.markFlip(f), this.markFlip(r), this.markFlip(u), i.add(a), n.delete(a), i.add(c), n.delete(c), this.updateVert(t), this.updateVert(f), this.updateVert(r), this.updateVert(u), a;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Whether point p1, p2, and p are collinear
|
|
1132
|
+
*/
|
|
1133
|
+
isCollinear(t, e, s) {
|
|
1134
|
+
const i = this.del.coords;
|
|
1135
|
+
return Ct(
|
|
1136
|
+
i[t * 2],
|
|
1137
|
+
i[t * 2 + 1],
|
|
1138
|
+
i[e * 2],
|
|
1139
|
+
i[e * 2 + 1],
|
|
1140
|
+
i[s * 2],
|
|
1141
|
+
i[s * 2 + 1]
|
|
1142
|
+
) === 0;
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Whether px is in the circumcircle of the triangle formed by p1, p2, p3
|
|
1146
|
+
*/
|
|
1147
|
+
inCircle(t, e, s, i) {
|
|
1148
|
+
const n = this.del.coords;
|
|
1149
|
+
return Ps(
|
|
1150
|
+
n[t * 2],
|
|
1151
|
+
n[t * 2 + 1],
|
|
1152
|
+
n[e * 2],
|
|
1153
|
+
n[e * 2 + 1],
|
|
1154
|
+
n[s * 2],
|
|
1155
|
+
n[s * 2 + 1],
|
|
1156
|
+
n[i * 2],
|
|
1157
|
+
n[i * 2 + 1]
|
|
1158
|
+
) < 0;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Whether the triangles sharing edg conform to the Delaunay condition
|
|
1162
|
+
*/
|
|
1163
|
+
isDelaunay(t) {
|
|
1164
|
+
const { triangles: e, halfedges: s } = this.del, i = s[t];
|
|
1165
|
+
if (i === -1)
|
|
1166
|
+
return !0;
|
|
1167
|
+
const n = e[Et(t)], r = e[t], a = e[jt(t)], f = e[Et(i)];
|
|
1168
|
+
return !this.inCircle(n, r, a, f);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Update the vertex -> incoming edge map
|
|
1172
|
+
*/
|
|
1173
|
+
updateVert(t) {
|
|
1174
|
+
const { triangles: e, halfedges: s } = this.del, i = this.vertMap, n = e[t];
|
|
1175
|
+
let r = Et(t), a = s[r];
|
|
1176
|
+
for (; a !== -1 && a !== t; )
|
|
1177
|
+
r = Et(a), a = s[r];
|
|
1178
|
+
return i[n] = r, r;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Whether the segments between vertices intersect
|
|
1182
|
+
*/
|
|
1183
|
+
intersectSegments(t, e, s, i) {
|
|
1184
|
+
const n = this.del.coords;
|
|
1185
|
+
return t === s || t === i || e === s || e === i ? !1 : qe(
|
|
1186
|
+
n[t * 2],
|
|
1187
|
+
n[t * 2 + 1],
|
|
1188
|
+
n[e * 2],
|
|
1189
|
+
n[e * 2 + 1],
|
|
1190
|
+
n[s * 2],
|
|
1191
|
+
n[s * 2 + 1],
|
|
1192
|
+
n[i * 2],
|
|
1193
|
+
n[i * 2 + 1]
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
Je.intersectSegments = qe;
|
|
1198
|
+
let Ns = Je;
|
|
1199
|
+
function te(o, t, e) {
|
|
1200
|
+
if (t || (t = []), typeof o != "object" || o.type !== "FeatureCollection")
|
|
1201
|
+
throw "Argument points must be FeatureCollection";
|
|
1202
|
+
if (!Array.isArray(t)) throw "Argument points must be Array of Array";
|
|
1203
|
+
const s = o.features.map(
|
|
1204
|
+
(f) => f.geometry.coordinates
|
|
1205
|
+
), i = ns.from(s);
|
|
1206
|
+
let n;
|
|
1207
|
+
const r = [];
|
|
1208
|
+
i.triangles.length !== 0 && t.length !== 0 && (n = new Ns(i), n.constrainAll(t));
|
|
1209
|
+
for (let f = 0; f < i.triangles.length; f += 3)
|
|
1210
|
+
r.push([i.triangles[f], i.triangles[f + 1], i.triangles[f + 2]]);
|
|
1211
|
+
const a = ["a", "b", "c"];
|
|
1212
|
+
return Ot(
|
|
1213
|
+
r.map((f) => {
|
|
1214
|
+
const c = {}, u = f.map((h, l) => {
|
|
1215
|
+
const p = o.features[h], y = p.geometry.coordinates, g = [y[0], y[1]];
|
|
1216
|
+
return y.length === 3 ? g[2] = y[2] : c[a[l]] = p.properties[e], g;
|
|
1217
|
+
});
|
|
1218
|
+
return u[3] = u[0], me([u], c);
|
|
1219
|
+
})
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
function Us(o) {
|
|
1223
|
+
const e = new Bs(o).findSegmentIntersections();
|
|
1224
|
+
return Ke(e).reduce(
|
|
1225
|
+
(s, i, n, r) => Array.isArray(s) || (s || (s = {}), s[`${i.x}:${i.y}`] = i, n != r.length - 1) ? s : Object.keys(s).map((a) => Jt([s[a].x, s[a].y])),
|
|
1226
|
+
{}
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
class Bs {
|
|
1230
|
+
/**
|
|
1231
|
+
* 線分群からArcCollectionを初期化
|
|
1232
|
+
* @param coords - 線分群の座標配列
|
|
1233
|
+
*/
|
|
1234
|
+
constructor(t) {
|
|
1235
|
+
/**
|
|
1236
|
+
* 座標データの配列
|
|
1237
|
+
* _xx, _yy: Float64Array形式で座標を保持
|
|
1238
|
+
* _ii: 各線分の開始インデックス
|
|
1239
|
+
* _nn: 各線分の頂点数
|
|
1240
|
+
*/
|
|
1241
|
+
rt(this, "_xx");
|
|
1242
|
+
rt(this, "_yy");
|
|
1243
|
+
// coordinates data
|
|
1244
|
+
rt(this, "_ii");
|
|
1245
|
+
rt(this, "_nn");
|
|
1246
|
+
// indexes, sizes
|
|
1247
|
+
rt(this, "_zz");
|
|
1248
|
+
rt(this, "_zlimit", 0);
|
|
1249
|
+
// simplification
|
|
1250
|
+
rt(this, "_bb");
|
|
1251
|
+
rt(this, "_allBounds");
|
|
1252
|
+
// bounding boxes
|
|
1253
|
+
rt(this, "_arcIter");
|
|
1254
|
+
rt(this, "_filteredArcIter");
|
|
1255
|
+
// path iterators
|
|
1256
|
+
rt(this, "buf");
|
|
1257
|
+
this.initArcs(t);
|
|
1258
|
+
}
|
|
1259
|
+
initArcs(t) {
|
|
1260
|
+
const e = [], s = [], i = t.map((n) => {
|
|
1261
|
+
const r = n ? n.length : 0;
|
|
1262
|
+
for (let a = 0; a < r; a++)
|
|
1263
|
+
e.push(n[a][0]), s.push(n[a][1]);
|
|
1264
|
+
return r;
|
|
1265
|
+
});
|
|
1266
|
+
this.initXYData(i, e, s);
|
|
1267
|
+
}
|
|
1268
|
+
initXYData(t, e, s) {
|
|
1269
|
+
const i = t.length;
|
|
1270
|
+
this._xx = new Float64Array(e), this._yy = new Float64Array(s), this._nn = new Uint32Array(t), this._zz = null, this._zlimit = 0, this._filteredArcIter = null, this._ii = new Uint32Array(i);
|
|
1271
|
+
let n = 0;
|
|
1272
|
+
for (let r = 0; r < i; r++)
|
|
1273
|
+
this._ii[r] = n, n += t[r];
|
|
1274
|
+
(n != this._xx.length || this._xx.length != this._yy.length) && be("ArcCollection#initXYData() Counting error"), this.initBounds(), this._arcIter = new sn(this._xx, this._yy);
|
|
1275
|
+
}
|
|
1276
|
+
initBounds() {
|
|
1277
|
+
const t = this.calcArcBounds_(this._xx, this._yy, this._nn);
|
|
1278
|
+
this._bb = t.bb, this._allBounds = t.bounds;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* データの境界を計算
|
|
1282
|
+
* @returns バウンディングボックス情報
|
|
1283
|
+
*/
|
|
1284
|
+
calcArcBounds_(t, e, s) {
|
|
1285
|
+
const i = s.length, n = new Float64Array(i * 4), r = new oe();
|
|
1286
|
+
let a = 0, f, c, u;
|
|
1287
|
+
for (let h = 0; h < i; h++)
|
|
1288
|
+
f = s[h], f > 0 && (c = h * 4, u = nn(t, e, a, f), n[c++] = u[0], n[c++] = u[1], n[c++] = u[2], n[c] = u[3], a += f, r.mergeBounds(u));
|
|
1289
|
+
return {
|
|
1290
|
+
bb: n,
|
|
1291
|
+
bounds: r
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
getBounds() {
|
|
1295
|
+
return this._allBounds.clone();
|
|
1296
|
+
}
|
|
1297
|
+
// @cb function(i, j, xx, yy)
|
|
1298
|
+
forEachSegment(t) {
|
|
1299
|
+
let e = 0;
|
|
1300
|
+
for (let s = 0, i = this.size(); s < i; s++)
|
|
1301
|
+
e += this.forEachArcSegment(s, t);
|
|
1302
|
+
return e;
|
|
1303
|
+
}
|
|
1304
|
+
size() {
|
|
1305
|
+
return this._ii && this._ii.length || 0;
|
|
1306
|
+
}
|
|
1307
|
+
// @cb function(i, j, xx, yy)
|
|
1308
|
+
forEachArcSegment(t, e) {
|
|
1309
|
+
const s = t >= 0, i = s ? t : ~t, n = this.getRetainedInterval(), r = this._nn[i], a = s ? 1 : -1;
|
|
1310
|
+
let f = s ? this._ii[i] : this._ii[i] + r - 1, c = f, u = 0;
|
|
1311
|
+
for (let h = 1; h < r; h++)
|
|
1312
|
+
c += a, (n === 0 || this._zz[c] >= n) && (e(f, c, this._xx, this._yy), f = c, u++);
|
|
1313
|
+
return u;
|
|
1314
|
+
}
|
|
1315
|
+
getRetainedInterval() {
|
|
1316
|
+
return this._zlimit;
|
|
1317
|
+
}
|
|
1318
|
+
// Give access to raw data arrays...
|
|
1319
|
+
getVertexData() {
|
|
1320
|
+
return {
|
|
1321
|
+
xx: this._xx,
|
|
1322
|
+
yy: this._yy,
|
|
1323
|
+
zz: this._zz,
|
|
1324
|
+
bb: this._bb,
|
|
1325
|
+
nn: this._nn,
|
|
1326
|
+
ii: this._ii
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
getUint32Array(t) {
|
|
1330
|
+
const e = t * 4;
|
|
1331
|
+
return (!this.buf || this.buf.byteLength < e) && (this.buf = new ArrayBuffer(e)), new Uint32Array(this.buf, 0, t);
|
|
1332
|
+
}
|
|
1333
|
+
// Return average magnitudes of dx, dy (with simplification)
|
|
1334
|
+
getAvgSegment2() {
|
|
1335
|
+
let t = 0, e = 0;
|
|
1336
|
+
const s = this.forEachSegment(
|
|
1337
|
+
(i, n, r, a) => {
|
|
1338
|
+
t += Math.abs(r[i] - r[n]), e += Math.abs(a[i] - a[n]);
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
return [t / s || 0, e / s || 0];
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* 交差判定のためのストライプ数を計算
|
|
1345
|
+
* 線分の平均長さに基づいて最適な分割数を決定
|
|
1346
|
+
*/
|
|
1347
|
+
calcSegmentIntersectionStripeCount() {
|
|
1348
|
+
const t = this.getBounds().height(), e = this.getAvgSegment2()[1];
|
|
1349
|
+
let s = 1;
|
|
1350
|
+
return e > 0 && t > 0 && (s = Math.ceil(t / e / 20)), s || 1;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* 線分の交差を検出
|
|
1354
|
+
* ストライプ分割による効率的な判定を実装
|
|
1355
|
+
*
|
|
1356
|
+
* @returns 検出された交差点の配列
|
|
1357
|
+
*/
|
|
1358
|
+
findSegmentIntersections() {
|
|
1359
|
+
const t = this.getBounds(), e = t.ymin, s = t.ymax - e, i = this.calcSegmentIntersectionStripeCount(), n = new Uint32Array(i), r = i > 1 ? (g) => Math.floor((i - 1) * (g - e) / s) : () => 0;
|
|
1360
|
+
let a, f;
|
|
1361
|
+
this.forEachSegment(
|
|
1362
|
+
(g, b, w, S) => {
|
|
1363
|
+
let _ = r(S[g]);
|
|
1364
|
+
const v = r(S[b]);
|
|
1365
|
+
for (; n[_] = n[_] + 2, _ != v; )
|
|
1366
|
+
_ += v > _ ? 1 : -1;
|
|
1367
|
+
}
|
|
1368
|
+
);
|
|
1369
|
+
const c = this.getUint32Array(js(n));
|
|
1370
|
+
let u = 0;
|
|
1371
|
+
const h = [];
|
|
1372
|
+
Ls(n, (g) => {
|
|
1373
|
+
const b = u;
|
|
1374
|
+
u += g, h.push(c.subarray(b, u));
|
|
1375
|
+
}), Vs(n, 0), this.forEachSegment(
|
|
1376
|
+
(g, b, w, S) => {
|
|
1377
|
+
let _ = r(S[g]);
|
|
1378
|
+
const v = r(S[b]);
|
|
1379
|
+
let T, I;
|
|
1380
|
+
for (; T = n[_], n[_] = T + 2, I = h[_], I[T] = g, I[T + 1] = b, _ != v; )
|
|
1381
|
+
_ += v > _ ? 1 : -1;
|
|
1382
|
+
}
|
|
1383
|
+
);
|
|
1384
|
+
const l = this.getVertexData(), p = [];
|
|
1385
|
+
let y;
|
|
1386
|
+
for (a = 0; a < i; a++)
|
|
1387
|
+
for (y = Ws(h[a], l.xx, l.yy), f = 0; f < y.length; f++)
|
|
1388
|
+
p.push(y[f]);
|
|
1389
|
+
return Ke(p);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
function be(...o) {
|
|
1393
|
+
const t = o.join(" ");
|
|
1394
|
+
throw new Error(t);
|
|
1395
|
+
}
|
|
1396
|
+
function ye(o) {
|
|
1397
|
+
return o ? Fs(o) ? !0 : Ds(o) ? !1 : o.length === 0 ? !0 : o.length > 0 : !1;
|
|
1398
|
+
}
|
|
1399
|
+
function Ds(o) {
|
|
1400
|
+
return o != null && o.toString === String.prototype.toString;
|
|
1401
|
+
}
|
|
1402
|
+
function Fs(o) {
|
|
1403
|
+
return Array.isArray(o);
|
|
1404
|
+
}
|
|
1405
|
+
function js(o, t) {
|
|
1406
|
+
ye(o) || be("utils.sum() expects an array, received:", o);
|
|
1407
|
+
let e = 0, s;
|
|
1408
|
+
for (let i = 0, n = o.length; i < n; i++)
|
|
1409
|
+
s = o[i], s && (e += s);
|
|
1410
|
+
return e;
|
|
1411
|
+
}
|
|
1412
|
+
function Ls(o, t, e) {
|
|
1413
|
+
if (!ye(o))
|
|
1414
|
+
throw new Error(`#forEach() takes an array-like argument. ${o}`);
|
|
1415
|
+
for (let s = 0, i = o.length; s < i; s++)
|
|
1416
|
+
t.call(e, o[s], s);
|
|
1417
|
+
}
|
|
1418
|
+
function Vs(o, t) {
|
|
1419
|
+
for (let e = 0, s = o.length; e < s; e++)
|
|
1420
|
+
o[e] = t;
|
|
1421
|
+
return o;
|
|
1422
|
+
}
|
|
1423
|
+
function Ws(o, t, e) {
|
|
1424
|
+
const s = o.length - 2, i = [];
|
|
1425
|
+
let n, r, a, f, c, u, h, l, p, y, g, b, w, S, _, v, T;
|
|
1426
|
+
for (Qs(t, o), v = 0; v < s; ) {
|
|
1427
|
+
for (n = o[v], r = o[v + 1], c = t[n], u = t[r], p = e[n], y = e[r], T = v; T < s && (T += 2, a = o[T], h = t[a], !(u < h)); ) {
|
|
1428
|
+
if (g = e[a], f = o[T + 1], l = t[f], b = e[f], p >= g) {
|
|
1429
|
+
if (p > b && y > g && y > b) continue;
|
|
1430
|
+
} else if (p < b && y < g && y < b) continue;
|
|
1431
|
+
n == a || n == f || r == a || r == f || (w = zs(
|
|
1432
|
+
c,
|
|
1433
|
+
p,
|
|
1434
|
+
u,
|
|
1435
|
+
y,
|
|
1436
|
+
h,
|
|
1437
|
+
g,
|
|
1438
|
+
l,
|
|
1439
|
+
b
|
|
1440
|
+
), w && (S = [n, r], _ = [a, f], i.push(Ue(w, S, _, t, e)), w.length == 4 && i.push(
|
|
1441
|
+
Ue(w.slice(2), S, _, t, e)
|
|
1442
|
+
)));
|
|
1443
|
+
}
|
|
1444
|
+
v += 2;
|
|
1445
|
+
}
|
|
1446
|
+
return i;
|
|
1447
|
+
}
|
|
1448
|
+
function zs(o, t, e, s, i, n, r, a) {
|
|
1449
|
+
const f = Xs(o, t, e, s, i, n, r, a);
|
|
1450
|
+
let c = null;
|
|
1451
|
+
return f && (c = Ys(o, t, e, s, i, n, r, a), c ? Ks(o, t, e, s, i, n, r, a) && (c = null) : c = Gs(o, t, e, s, i, n, r, a)), c;
|
|
1452
|
+
}
|
|
1453
|
+
function Xs(o, t, e, s, i, n, r, a) {
|
|
1454
|
+
return qt(o, t, e, s, i, n) * qt(o, t, e, s, r, a) <= 0 && qt(i, n, r, a, o, t) * qt(i, n, r, a, e, s) <= 0;
|
|
1455
|
+
}
|
|
1456
|
+
function qt(o, t, e, s, i, n) {
|
|
1457
|
+
return He(o - i, t - n, e - i, s - n);
|
|
1458
|
+
}
|
|
1459
|
+
function He(o, t, e, s) {
|
|
1460
|
+
return o * s - t * e;
|
|
1461
|
+
}
|
|
1462
|
+
function Ys(o, t, e, s, i, n, r, a) {
|
|
1463
|
+
let f = ee(o, t, e, s, i, n, r, a), c;
|
|
1464
|
+
return f && (c = qs(f[0], f[1], o, t, e, s, i, n, r, a), c == 1 ? f = ee(e, s, o, t, i, n, r, a) : c == 2 ? f = ee(i, n, r, a, o, t, e, s) : c == 3 && (f = ee(r, a, i, n, o, t, e, s))), f && Hs(f, o, t, e, s, i, n, r, a), f;
|
|
1465
|
+
}
|
|
1466
|
+
function ee(o, t, e, s, i, n, r, a) {
|
|
1467
|
+
const f = He(e - o, s - t, r - i, a - n), c = 1e-18;
|
|
1468
|
+
let u;
|
|
1469
|
+
if (f === 0) return null;
|
|
1470
|
+
const h = qt(i, n, r, a, o, t) / f;
|
|
1471
|
+
return f <= c && f >= -c ? u = Cs(o, t, e, s, i, n, r, a) : u = [o + h * (e - o), t + h * (s - t)], u;
|
|
1472
|
+
}
|
|
1473
|
+
function Cs(o, t, e, s, i, n, r, a) {
|
|
1474
|
+
let f = null;
|
|
1475
|
+
return !vt(o, i, r) && !vt(t, n, a) ? f = [o, t] : !vt(e, i, r) && !vt(s, n, a) ? f = [e, s] : !vt(i, o, e) && !vt(n, t, s) ? f = [i, n] : !vt(r, o, e) && !vt(a, t, s) && (f = [r, a]), f;
|
|
1476
|
+
}
|
|
1477
|
+
function vt(o, t, e) {
|
|
1478
|
+
let s;
|
|
1479
|
+
return t < e ? s = o < t || o > e : t > e ? s = o > t || o < e : s = o != t, s;
|
|
1480
|
+
}
|
|
1481
|
+
function qs(o, t, ...e) {
|
|
1482
|
+
let s = -1, i = 1 / 0, n;
|
|
1483
|
+
for (let r = 0, a = 0, f = e.length; a < f; r++, a += 2)
|
|
1484
|
+
n = Js(o, t, e[a], e[a + 1]), n < i && (i = n, s = r);
|
|
1485
|
+
return s;
|
|
1486
|
+
}
|
|
1487
|
+
function Js(o, t, e, s) {
|
|
1488
|
+
const i = o - e, n = t - s;
|
|
1489
|
+
return i * i + n * n;
|
|
1490
|
+
}
|
|
1491
|
+
function Hs(o, t, e, s, i, n, r, a, f) {
|
|
1492
|
+
let c = o[0], u = o[1];
|
|
1493
|
+
c = se(c, t, s), c = se(c, n, a), u = se(u, e, i), u = se(u, r, f), o[0] = c, o[1] = u;
|
|
1494
|
+
}
|
|
1495
|
+
function se(o, t, e) {
|
|
1496
|
+
let s;
|
|
1497
|
+
return vt(o, t, e) && (s = Math.abs(o - t) < Math.abs(o - e) ? t : e, o = s), o;
|
|
1498
|
+
}
|
|
1499
|
+
function Gs(o, t, e, s, i, n, r, a) {
|
|
1500
|
+
const f = Math.min(o, e, i, r), c = Math.max(o, e, i, r), u = Math.min(t, s, n, a), h = Math.max(t, s, n, a), l = h - u > c - f;
|
|
1501
|
+
let p = [];
|
|
1502
|
+
return (l ? Nt(t, u, h) : Nt(o, f, c)) && p.push(o, t), (l ? Nt(s, u, h) : Nt(e, f, c)) && p.push(e, s), (l ? Nt(n, u, h) : Nt(i, f, c)) && p.push(i, n), (l ? Nt(a, u, h) : Nt(r, f, c)) && p.push(r, a), (p.length != 2 && p.length != 4 || p.length == 4 && p[0] == p[2] && p[1] == p[3]) && (p = null), p;
|
|
1503
|
+
}
|
|
1504
|
+
function Ks(o, t, e, s, i, n, r, a) {
|
|
1505
|
+
return o == i && t == n || o == r && t == a || e == i && s == n || e == r && s == a;
|
|
1506
|
+
}
|
|
1507
|
+
function Nt(o, t, e) {
|
|
1508
|
+
return o > t && o < e;
|
|
1509
|
+
}
|
|
1510
|
+
function Qs(o, t) {
|
|
1511
|
+
Zs(o, t), Ge(o, t, 0, t.length - 2);
|
|
1512
|
+
}
|
|
1513
|
+
function Zs(o, t) {
|
|
1514
|
+
for (let e = 0, s = t.length; e < s; e += 2)
|
|
1515
|
+
o[t[e]] > o[t[e + 1]] && tn(t, e, e + 1);
|
|
1516
|
+
}
|
|
1517
|
+
function tn(o, t, e) {
|
|
1518
|
+
const s = o[t];
|
|
1519
|
+
o[t] = o[e], o[e] = s;
|
|
1520
|
+
}
|
|
1521
|
+
function Ge(o, t, e, s) {
|
|
1522
|
+
let i = e, n = s, r, a;
|
|
1523
|
+
for (; i < s; ) {
|
|
1524
|
+
for (r = o[t[e + s >> 2 << 1]]; i <= n; ) {
|
|
1525
|
+
for (; o[t[i]] < r; ) i += 2;
|
|
1526
|
+
for (; o[t[n]] > r; ) n -= 2;
|
|
1527
|
+
i <= n && (a = t[i], t[i] = t[n], t[n] = a, a = t[i + 1], t[i + 1] = t[n + 1], t[n + 1] = a, i += 2, n -= 2);
|
|
1528
|
+
}
|
|
1529
|
+
if (n - e < 40 ? Ne(o, t, e, n) : Ge(o, t, e, n), s - i < 40) {
|
|
1530
|
+
Ne(o, t, i, s);
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
e = i, n = s;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
function Ne(o, t, e, s) {
|
|
1537
|
+
let i, n;
|
|
1538
|
+
for (let r = e + 2; r <= s; r += 2) {
|
|
1539
|
+
i = t[r], n = t[r + 1];
|
|
1540
|
+
let a;
|
|
1541
|
+
for (a = r - 2; a >= e && o[i] < o[t[a]]; a -= 2)
|
|
1542
|
+
t[a + 2] = t[a], t[a + 3] = t[a + 1];
|
|
1543
|
+
t[a + 2] = i, t[a + 3] = n;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
function Ue(o, t, e, s, i) {
|
|
1547
|
+
const n = o[0], r = o[1];
|
|
1548
|
+
t = Be(n, r, t[0], t[1], s, i), e = Be(n, r, e[0], e[1], s, i);
|
|
1549
|
+
const a = t[0] < e[0] ? t : e, f = a == t ? e : t;
|
|
1550
|
+
return { x: n, y: r, a, b: f };
|
|
1551
|
+
}
|
|
1552
|
+
function Be(o, t, e, s, i, n) {
|
|
1553
|
+
let r = e < s ? e : s, a = r === e ? s : e;
|
|
1554
|
+
return i[r] == o && n[r] == t ? a = r : i[a] == o && n[a] == t && (r = a), [r, a];
|
|
1555
|
+
}
|
|
1556
|
+
function Ke(o) {
|
|
1557
|
+
const t = {};
|
|
1558
|
+
return o.filter((e) => {
|
|
1559
|
+
const s = en(e);
|
|
1560
|
+
return s in t ? !1 : (t[s] = !0, !0);
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
function en(o) {
|
|
1564
|
+
return `${o.a.join(",")};${o.b.join(",")}`;
|
|
1565
|
+
}
|
|
1566
|
+
class sn {
|
|
1567
|
+
constructor(t, e) {
|
|
1568
|
+
rt(this, "_i", 0);
|
|
1569
|
+
rt(this, "_n", 0);
|
|
1570
|
+
rt(this, "_inc", 1);
|
|
1571
|
+
rt(this, "_xx");
|
|
1572
|
+
rt(this, "_yy");
|
|
1573
|
+
rt(this, "i", 0);
|
|
1574
|
+
rt(this, "x", 0);
|
|
1575
|
+
rt(this, "y", 0);
|
|
1576
|
+
this._xx = t, this._yy = e;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
function nn(o, t, e, s) {
|
|
1580
|
+
let i = e | 0;
|
|
1581
|
+
const n = isNaN(s) ? o.length - i : s + i;
|
|
1582
|
+
let r, a, f, c, u, h;
|
|
1583
|
+
if (n > 0)
|
|
1584
|
+
f = u = o[i], c = h = t[i];
|
|
1585
|
+
else return [void 0, void 0, void 0, void 0];
|
|
1586
|
+
for (i++; i < n; i++)
|
|
1587
|
+
r = o[i], a = t[i], r < f && (f = r), r > u && (u = r), a < c && (c = a), a > h && (h = a);
|
|
1588
|
+
return [f, c, u, h];
|
|
1589
|
+
}
|
|
1590
|
+
class oe {
|
|
1591
|
+
constructor(...t) {
|
|
1592
|
+
rt(this, "xmin");
|
|
1593
|
+
rt(this, "ymin");
|
|
1594
|
+
rt(this, "xmax");
|
|
1595
|
+
rt(this, "ymax");
|
|
1596
|
+
t.length > 0 && this.setBounds(t);
|
|
1597
|
+
}
|
|
1598
|
+
// Return a bounding box with the same extent as this one.
|
|
1599
|
+
cloneBounds() {
|
|
1600
|
+
return this.clone();
|
|
1601
|
+
}
|
|
1602
|
+
clone() {
|
|
1603
|
+
return new oe(this.xmin, this.ymin, this.xmax, this.ymax);
|
|
1604
|
+
}
|
|
1605
|
+
width() {
|
|
1606
|
+
return this.xmax - this.xmin || 0;
|
|
1607
|
+
}
|
|
1608
|
+
height() {
|
|
1609
|
+
return this.ymax - this.ymin || 0;
|
|
1610
|
+
}
|
|
1611
|
+
setBounds(t, e, s, i) {
|
|
1612
|
+
return arguments.length == 1 && (ye(t) ? (e = t[1], s = t[2], i = t[3], t = t[0]) : (e = t.ymin, s = t.xmax, i = t.ymax, t = t.xmin)), this.xmin = t, this.ymin = e, this.xmax = s, this.ymax = i, (t > s || e > i) && this.update(), this;
|
|
1613
|
+
}
|
|
1614
|
+
update() {
|
|
1615
|
+
let t;
|
|
1616
|
+
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);
|
|
1617
|
+
}
|
|
1618
|
+
mergeBounds(t, ...e) {
|
|
1619
|
+
let s, i, n, r;
|
|
1620
|
+
return t instanceof oe ? (s = t.xmin, i = t.ymin, n = t.xmax, r = t.ymax) : e.length == 3 ? (s = t, i = e[0], n = e[1], r = e[2]) : t.length == 4 ? (s = t[0], i = t[1], n = t[2], r = t[3]) : be("Bounds#mergeBounds() invalid argument:", t), this.xmin === void 0 ? this.setBounds(s, i, n, r) : (s < this.xmin && (this.xmin = s), i < this.ymin && (this.ymin = i), n > this.xmax && (this.xmax = n), r > this.ymax && (this.ymax = r)), this;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
function De(o) {
|
|
1624
|
+
const t = ["a", "b", "c"].map(
|
|
1625
|
+
(e) => o.properties[e].index
|
|
1626
|
+
);
|
|
1627
|
+
return [
|
|
1628
|
+
[0, 1],
|
|
1629
|
+
[0, 2],
|
|
1630
|
+
[1, 2],
|
|
1631
|
+
[0, 1, 2]
|
|
1632
|
+
].map(
|
|
1633
|
+
(e) => e.map((s) => t[s]).sort().join("-")
|
|
1634
|
+
).sort();
|
|
1635
|
+
}
|
|
1636
|
+
function rn(o, t, e) {
|
|
1637
|
+
const s = De(t.forw), i = De(t.bakw);
|
|
1638
|
+
if (JSON.stringify(s) != JSON.stringify(i))
|
|
1639
|
+
throw `${JSON.stringify(t, null, 2)}
|
|
1640
|
+
${JSON.stringify(
|
|
1641
|
+
s
|
|
1642
|
+
)}
|
|
1643
|
+
${JSON.stringify(i)}`;
|
|
1644
|
+
for (let n = 0; n < s.length; n++) {
|
|
1645
|
+
const r = s[n];
|
|
1646
|
+
o[r] || (o[r] = []), o[r].push(t);
|
|
1647
|
+
}
|
|
1648
|
+
e && (e.forw.features.push(t.forw), e.bakw.features.push(t.bakw));
|
|
1649
|
+
}
|
|
1650
|
+
function ne(o, t, e) {
|
|
1651
|
+
return Jt(o, { target: { geom: t, index: e } });
|
|
1652
|
+
}
|
|
1653
|
+
function ie(o) {
|
|
1654
|
+
return Jt(o.properties.target.geom, {
|
|
1655
|
+
target: {
|
|
1656
|
+
geom: o.geometry.coordinates,
|
|
1657
|
+
index: o.properties.target.index
|
|
1658
|
+
}
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
function Fe(o, t) {
|
|
1662
|
+
const e = t.geometry.coordinates;
|
|
1663
|
+
return [0, 1, 2, 3].map((s) => {
|
|
1664
|
+
const i = (s + 1) % 4, n = o[s], r = o[i], a = n.geometry.coordinates, f = Math.atan2(
|
|
1665
|
+
a[0] - e[0],
|
|
1666
|
+
a[1] - e[1]
|
|
1667
|
+
), c = [t, n, r, t].map(
|
|
1668
|
+
(l) => l.geometry.coordinates
|
|
1669
|
+
), u = {
|
|
1670
|
+
a: {
|
|
1671
|
+
geom: t.properties.target.geom,
|
|
1672
|
+
index: t.properties.target.index
|
|
1673
|
+
},
|
|
1674
|
+
b: {
|
|
1675
|
+
geom: n.properties.target.geom,
|
|
1676
|
+
index: n.properties.target.index
|
|
1677
|
+
},
|
|
1678
|
+
c: {
|
|
1679
|
+
geom: r.properties.target.geom,
|
|
1680
|
+
index: r.properties.target.index
|
|
1681
|
+
}
|
|
1682
|
+
}, h = Ot([
|
|
1683
|
+
me([c], u)
|
|
1684
|
+
]);
|
|
1685
|
+
return [f, h];
|
|
1686
|
+
}).reduce(
|
|
1687
|
+
(s, i) => (s[0].push(i[0]), s[1].push(i[1]), s),
|
|
1688
|
+
[[], []]
|
|
1689
|
+
);
|
|
1690
|
+
}
|
|
1691
|
+
const je = we;
|
|
1692
|
+
class ht extends _s {
|
|
1693
|
+
/**
|
|
1694
|
+
* Tinクラスのインスタンスを生成します
|
|
1695
|
+
* @param options - 初期化オプション
|
|
1696
|
+
*/
|
|
1697
|
+
constructor(e = {}) {
|
|
1698
|
+
super();
|
|
1699
|
+
rt(this, "importance");
|
|
1700
|
+
rt(this, "priority");
|
|
1701
|
+
rt(this, "pointsSet");
|
|
1702
|
+
e.bounds ? this.setBounds(e.bounds) : (this.setWh(e.wh), this.vertexMode = e.vertexMode || ht.VERTEX_PLAIN), this.strictMode = e.strictMode || ht.MODE_AUTO, this.yaxisMode = e.yaxisMode || ht.YAXIS_INVERT, this.importance = e.importance || 0, this.priority = e.priority || 0, this.stateFull = e.stateFull || !1, e.points && this.setPoints(e.points), e.edges && this.setEdges(e.edges);
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* フォーマットバージョンを取得します
|
|
1706
|
+
*/
|
|
1707
|
+
getFormatVersion() {
|
|
1708
|
+
return je;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* 制御点(GCP: Ground Control Points)を設定します
|
|
1712
|
+
*/
|
|
1713
|
+
setPoints(e) {
|
|
1714
|
+
this.yaxisMode === ht.YAXIS_FOLLOW && (e = e.map((s) => [
|
|
1715
|
+
s[0],
|
|
1716
|
+
[s[1][0], -1 * s[1][1]]
|
|
1717
|
+
])), this.points = e, this.tins = void 0, this.indexedTins = void 0;
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* エッジ(制約線)を設定します
|
|
1721
|
+
*/
|
|
1722
|
+
setEdges(e = []) {
|
|
1723
|
+
this.edges = ze(e), this.edgeNodes = void 0, this.tins = void 0, this.indexedTins = void 0;
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* 境界ポリゴンを設定します
|
|
1727
|
+
*/
|
|
1728
|
+
setBounds(e) {
|
|
1729
|
+
this.bounds = e;
|
|
1730
|
+
let s = e[0][0], i = s, n = e[0][1], r = n;
|
|
1731
|
+
const a = [e[0]];
|
|
1732
|
+
for (let f = 1; f < e.length; f++) {
|
|
1733
|
+
const c = e[f];
|
|
1734
|
+
c[0] < s && (s = c[0]), c[0] > i && (i = c[0]), c[1] < n && (n = c[1]), c[1] > r && (r = c[1]), a.push(c);
|
|
1735
|
+
}
|
|
1736
|
+
a.push(e[0]), this.boundsPolygon = me([a]), this.xy = [s, n], this.wh = [i - s, r - n], this.vertexMode = ht.VERTEX_PLAIN, this.tins = void 0, this.indexedTins = void 0;
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* 現在の設定を永続化可能な形式にコンパイルします
|
|
1740
|
+
*/
|
|
1741
|
+
getCompiled() {
|
|
1742
|
+
var i;
|
|
1743
|
+
const e = {};
|
|
1744
|
+
e.version = je, e.points = this.points, e.weight_buffer = this.pointsWeightBuffer, e.centroid_point = [
|
|
1745
|
+
this.centroid.forw.geometry.coordinates,
|
|
1746
|
+
this.centroid.forw.properties.target.geom
|
|
1747
|
+
], e.vertices_params = [
|
|
1748
|
+
this.vertices_params.forw[0],
|
|
1749
|
+
this.vertices_params.bakw[0]
|
|
1750
|
+
], e.vertices_points = [];
|
|
1751
|
+
const s = this.vertices_params.forw[1];
|
|
1752
|
+
return s && [0, 1, 2, 3].map((n) => {
|
|
1753
|
+
const r = s[n].features[0], a = r.geometry.coordinates[0][1], f = r.properties.b.geom;
|
|
1754
|
+
e.vertices_points[n] = [a, f];
|
|
1755
|
+
}), e.strict_status = this.strict_status, e.tins_points = [[]], this.tins.forw.features.map((n) => {
|
|
1756
|
+
e.tins_points[0].push(
|
|
1757
|
+
["a", "b", "c"].map(
|
|
1758
|
+
(r) => n.properties[r].index
|
|
1759
|
+
)
|
|
1760
|
+
);
|
|
1761
|
+
}), this.strict_status === ht.STATUS_LOOSE ? (e.tins_points[1] = [], this.tins.bakw.features.map((n) => {
|
|
1762
|
+
e.tins_points[1].push(
|
|
1763
|
+
["a", "b", "c"].map(
|
|
1764
|
+
(r) => n.properties[r].index
|
|
1765
|
+
)
|
|
1766
|
+
);
|
|
1767
|
+
})) : this.strict_status === ht.STATUS_ERROR && ((i = this.kinks) != null && i.bakw) && (e.kinks_points = this.kinks.bakw.features.map(
|
|
1768
|
+
(n) => n.geometry.coordinates
|
|
1769
|
+
)), e.yaxisMode = this.yaxisMode, e.vertexMode = this.vertexMode, e.strictMode = this.strictMode, this.bounds ? (e.bounds = this.bounds, e.boundsPolygon = this.boundsPolygon, e.xy = this.xy, e.wh = this.wh) : e.wh = this.wh, e.edges = this.edges, e.edgeNodes = this.edgeNodes, e;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* 幅と高さを設定します
|
|
1773
|
+
*/
|
|
1774
|
+
setWh(e) {
|
|
1775
|
+
this.wh = e || [100, 100], this.xy = [0, 0], this.bounds = void 0, this.boundsPolygon = void 0, this.tins = void 0, this.indexedTins = void 0;
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* 頂点モードを設定します
|
|
1779
|
+
*/
|
|
1780
|
+
setVertexMode(e) {
|
|
1781
|
+
this.vertexMode = e, this.tins = void 0, this.indexedTins = void 0;
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* 厳密性モードを設定します
|
|
1785
|
+
*/
|
|
1786
|
+
setStrictMode(e) {
|
|
1787
|
+
this.strictMode = e, this.tins = void 0, this.indexedTins = void 0;
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* 厳密なTINを計算します
|
|
1791
|
+
*/
|
|
1792
|
+
calcurateStrictTin() {
|
|
1793
|
+
const e = this.tins.forw.features.map(
|
|
1794
|
+
(n) => bs(n)
|
|
1795
|
+
);
|
|
1796
|
+
this.tins.bakw = Ot(e);
|
|
1797
|
+
const s = {};
|
|
1798
|
+
this.tins.forw.features.forEach((n, r) => {
|
|
1799
|
+
const a = this.tins.bakw.features[r];
|
|
1800
|
+
rn(s, { forw: n, bakw: a });
|
|
1801
|
+
});
|
|
1802
|
+
const i = ["forw", "bakw"].map((n) => {
|
|
1803
|
+
const r = this.tins[n].features.map(
|
|
1804
|
+
(a) => a.geometry.coordinates[0]
|
|
1805
|
+
);
|
|
1806
|
+
return Us(r);
|
|
1807
|
+
});
|
|
1808
|
+
i[0].length === 0 && i[1].length === 0 ? (this.strict_status = ht.STATUS_STRICT, delete this.kinks) : (this.strict_status = ht.STATUS_ERROR, this.kinks = {}, i[0].length > 0 && (this.kinks.forw = Ot(i[0])), i[1].length > 0 && (this.kinks.bakw = Ot(i[1])));
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* 点群セットを生成します
|
|
1812
|
+
*/
|
|
1813
|
+
generatePointsSet() {
|
|
1814
|
+
const e = {
|
|
1815
|
+
forw: [],
|
|
1816
|
+
bakw: []
|
|
1817
|
+
};
|
|
1818
|
+
for (let n = 0; n < this.points.length; n++) {
|
|
1819
|
+
const r = this.points[n][0], a = this.points[n][1], f = ne(r, a, n);
|
|
1820
|
+
e.forw.push(f), e.bakw.push(ie(f));
|
|
1821
|
+
}
|
|
1822
|
+
const s = [];
|
|
1823
|
+
let i = 0;
|
|
1824
|
+
this.edgeNodes = [], this.edges || (this.edges = []);
|
|
1825
|
+
for (let n = 0; n < this.edges.length; n++) {
|
|
1826
|
+
const r = this.edges[n][2], a = Object.assign([], this.edges[n][0]), f = Object.assign([], this.edges[n][1]);
|
|
1827
|
+
if (a.length === 0 && f.length === 0) {
|
|
1828
|
+
s.push(r);
|
|
1829
|
+
continue;
|
|
1830
|
+
}
|
|
1831
|
+
a.unshift(this.points[r[0]][0]), a.push(this.points[r[1]][0]), f.unshift(this.points[r[0]][1]), f.push(this.points[r[1]][1]);
|
|
1832
|
+
const c = [a, f].map((u) => {
|
|
1833
|
+
const h = u.map((p, y, g) => {
|
|
1834
|
+
if (y === 0) return 0;
|
|
1835
|
+
const b = g[y - 1];
|
|
1836
|
+
return Math.sqrt(
|
|
1837
|
+
Math.pow(p[0] - b[0], 2) + Math.pow(p[1] - b[1], 2)
|
|
1838
|
+
);
|
|
1839
|
+
}), l = h.reduce((p, y, g) => g === 0 ? [0] : (p.push(p[g - 1] + y), p), []);
|
|
1840
|
+
return l.map((p, y, g) => {
|
|
1841
|
+
const b = p / g[g.length - 1];
|
|
1842
|
+
return [u[y], h[y], l[y], b];
|
|
1843
|
+
});
|
|
1844
|
+
});
|
|
1845
|
+
c.map((u, h) => {
|
|
1846
|
+
const l = c[h ? 0 : 1];
|
|
1847
|
+
return u.filter((p, y) => !(y === 0 || y === u.length - 1 || p[4] === "handled")).map((p) => {
|
|
1848
|
+
const y = p[0], g = p[3], b = l.reduce(
|
|
1849
|
+
(w, S, _, v) => {
|
|
1850
|
+
if (w) return w;
|
|
1851
|
+
const T = v[_ + 1];
|
|
1852
|
+
if (S[3] === g)
|
|
1853
|
+
return S[4] = "handled", [S];
|
|
1854
|
+
if (S[3] < g && T && T[3] > g)
|
|
1855
|
+
return [S, T];
|
|
1856
|
+
},
|
|
1857
|
+
void 0
|
|
1858
|
+
);
|
|
1859
|
+
if (b && b.length === 1)
|
|
1860
|
+
return h === 0 ? [y, b[0][0], g] : [b[0][0], y, g];
|
|
1861
|
+
if (b && b.length === 2) {
|
|
1862
|
+
const w = b[0], S = b[1], _ = (g - w[3]) / (S[3] - w[3]), v = [
|
|
1863
|
+
(S[0][0] - w[0][0]) * _ + w[0][0],
|
|
1864
|
+
(S[0][1] - w[0][1]) * _ + w[0][1]
|
|
1865
|
+
];
|
|
1866
|
+
return h === 0 ? [y, v, g] : [v, y, g];
|
|
1867
|
+
}
|
|
1868
|
+
return [];
|
|
1869
|
+
});
|
|
1870
|
+
}).reduce((u, h) => u.concat(h), []).sort((u, h) => u[2] < h[2] ? -1 : 1).map((u, h, l) => {
|
|
1871
|
+
this.edgeNodes[i] = [
|
|
1872
|
+
u[0],
|
|
1873
|
+
u[1]
|
|
1874
|
+
];
|
|
1875
|
+
const p = ne(
|
|
1876
|
+
u[0],
|
|
1877
|
+
u[1],
|
|
1878
|
+
`e${i}`
|
|
1879
|
+
);
|
|
1880
|
+
i++, e.forw.push(p), e.bakw.push(ie(p)), h === 0 ? s.push([r[0], e.forw.length - 1]) : s.push([
|
|
1881
|
+
e.forw.length - 2,
|
|
1882
|
+
e.forw.length - 1
|
|
1883
|
+
]), h === l.length - 1 && s.push([e.forw.length - 1, r[1]]);
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
return {
|
|
1887
|
+
forw: e.forw,
|
|
1888
|
+
bakw: e.bakw,
|
|
1889
|
+
edges: s
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* 入力データの検証と初期データの準備
|
|
1894
|
+
*/
|
|
1895
|
+
validateAndPrepareInputs() {
|
|
1896
|
+
const e = this.xy[0] - 0.05 * this.wh[0], s = this.xy[0] + 1.05 * this.wh[0], i = this.xy[1] - 0.05 * this.wh[1], n = this.xy[1] + 1.05 * this.wh[1];
|
|
1897
|
+
if (!this.points.reduce((f, c) => f && (this.bounds ? ts(c[0], this.boundsPolygon) : c[0][0] >= e && c[0][0] <= s && c[0][1] >= i && c[0][1] <= n), !0))
|
|
1898
|
+
throw "SOME POINTS OUTSIDE";
|
|
1899
|
+
let a = [];
|
|
1900
|
+
return this.wh && (a = [[e, i], [s, i], [e, n], [s, n]]), {
|
|
1901
|
+
pointsSet: this.generatePointsSet(),
|
|
1902
|
+
bbox: a,
|
|
1903
|
+
minx: e,
|
|
1904
|
+
maxx: s,
|
|
1905
|
+
miny: i,
|
|
1906
|
+
maxy: n
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* TINネットワークを更新し、座標変換の準備を行います
|
|
1911
|
+
*/
|
|
1912
|
+
updateTin() {
|
|
1913
|
+
let e = this.strictMode;
|
|
1914
|
+
e !== ht.MODE_STRICT && e !== ht.MODE_LOOSE && (e = ht.MODE_AUTO);
|
|
1915
|
+
const { pointsSet: s, bbox: i, minx: n, maxx: r, miny: a, maxy: f } = this.validateAndPrepareInputs(), c = {
|
|
1916
|
+
forw: Ot(s.forw),
|
|
1917
|
+
bakw: Ot(s.bakw)
|
|
1918
|
+
}, u = te(
|
|
1919
|
+
c.forw,
|
|
1920
|
+
s.edges,
|
|
1921
|
+
"target"
|
|
1922
|
+
), h = te(
|
|
1923
|
+
c.bakw,
|
|
1924
|
+
s.edges,
|
|
1925
|
+
"target"
|
|
1926
|
+
);
|
|
1927
|
+
if (u.features.length === 0 || h.features.length === 0)
|
|
1928
|
+
throw "TOO LINEAR1";
|
|
1929
|
+
const l = es(c.forw), p = ke(c.forw);
|
|
1930
|
+
if (!p) throw "TOO LINEAR2";
|
|
1931
|
+
const y = {}, g = p.geometry.coordinates[0];
|
|
1932
|
+
let b;
|
|
1933
|
+
try {
|
|
1934
|
+
b = g.map((N) => ({
|
|
1935
|
+
forw: N,
|
|
1936
|
+
bakw: re(Jt(N), u)
|
|
1937
|
+
})), b.forEach((N) => {
|
|
1938
|
+
y[`${N.forw[0]}:${N.forw[1]}`] = N;
|
|
1939
|
+
});
|
|
1940
|
+
} catch {
|
|
1941
|
+
throw "TOO LINEAR2";
|
|
1942
|
+
}
|
|
1943
|
+
const w = ke(c.bakw);
|
|
1944
|
+
if (!w) throw "TOO LINEAR2";
|
|
1945
|
+
const S = w.geometry.coordinates[0];
|
|
1946
|
+
try {
|
|
1947
|
+
b = S.map((N) => ({
|
|
1948
|
+
bakw: N,
|
|
1949
|
+
forw: re(Jt(N), h)
|
|
1950
|
+
})), b.forEach((N) => {
|
|
1951
|
+
y[`${N.forw[0]}:${N.forw[1]}`] = N;
|
|
1952
|
+
});
|
|
1953
|
+
} catch {
|
|
1954
|
+
throw "TOO LINEAR2";
|
|
1955
|
+
}
|
|
1956
|
+
const _ = {
|
|
1957
|
+
forw: l.geometry.coordinates,
|
|
1958
|
+
bakw: re(l, u)
|
|
1959
|
+
}, v = ne(_.forw, _.bakw, "c");
|
|
1960
|
+
this.centroid = {
|
|
1961
|
+
forw: v,
|
|
1962
|
+
bakw: ie(v)
|
|
1963
|
+
};
|
|
1964
|
+
const T = this.vertexMode === ht.VERTEX_BIRDEYE ? this.calculateBirdeyeVertices(
|
|
1965
|
+
y,
|
|
1966
|
+
_,
|
|
1967
|
+
i,
|
|
1968
|
+
n,
|
|
1969
|
+
r,
|
|
1970
|
+
a,
|
|
1971
|
+
f
|
|
1972
|
+
) : this.calculatePlainVertices(
|
|
1973
|
+
y,
|
|
1974
|
+
_,
|
|
1975
|
+
i,
|
|
1976
|
+
n,
|
|
1977
|
+
r,
|
|
1978
|
+
a,
|
|
1979
|
+
f
|
|
1980
|
+
), I = {
|
|
1981
|
+
forw: [],
|
|
1982
|
+
bakw: []
|
|
1983
|
+
};
|
|
1984
|
+
for (let N = 0; N < T.length; N++) {
|
|
1985
|
+
const V = T[N].forw, z = T[N].bakw, G = ne(V, z, `b${N}`), tt = ie(G);
|
|
1986
|
+
s.forw.push(G), s.bakw.push(tt), I.forw.push(G), I.bakw.push(tt);
|
|
1987
|
+
}
|
|
1988
|
+
this.pointsSet = {
|
|
1989
|
+
forw: Ot(s.forw),
|
|
1990
|
+
bakw: Ot(s.bakw),
|
|
1991
|
+
edges: []
|
|
1992
|
+
}, this.tins = {
|
|
1993
|
+
forw: ve(
|
|
1994
|
+
te(
|
|
1995
|
+
this.pointsSet.forw,
|
|
1996
|
+
s.edges,
|
|
1997
|
+
"target"
|
|
1998
|
+
)
|
|
1999
|
+
)
|
|
2000
|
+
}, (e === ht.MODE_STRICT || e === ht.MODE_AUTO) && this.calcurateStrictTin(), (e === ht.MODE_LOOSE || e === ht.MODE_AUTO && this.strict_status === ht.STATUS_ERROR) && (this.tins.bakw = ve(
|
|
2001
|
+
te(
|
|
2002
|
+
this.pointsSet.bakw,
|
|
2003
|
+
s.edges,
|
|
2004
|
+
"target"
|
|
2005
|
+
)
|
|
2006
|
+
), delete this.kinks, this.strict_status = ht.STATUS_LOOSE), this.vertices_params = {
|
|
2007
|
+
forw: Fe(I.forw, this.centroid.forw),
|
|
2008
|
+
bakw: Fe(I.bakw, this.centroid.bakw)
|
|
2009
|
+
}, this.addIndexedTin(), this.calculatePointsWeight();
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* 通常の頂点を計算
|
|
2013
|
+
*/
|
|
2014
|
+
calculatePlainVertices(e, s, i, n, r, a, f) {
|
|
2015
|
+
const c = Object.keys(e).reduce((y, g) => {
|
|
2016
|
+
const b = e[g], w = b.forw, S = b.bakw, _ = {
|
|
2017
|
+
forw: [w[0] - s.forw[0], w[1] - s.forw[1]],
|
|
2018
|
+
bakw: [S[0] - s.bakw[0], S[1] - s.bakw[1]]
|
|
2019
|
+
}, v = _.forw[0] === 0 ? 1 / 0 : ((_.forw[0] < 0 ? n : r) - s.forw[0]) / _.forw[0], T = _.forw[1] === 0 ? 1 / 0 : ((_.forw[1] < 0 ? a : f) - s.forw[1]) / _.forw[1];
|
|
2020
|
+
if (Math.abs(v) / Math.abs(T) < 1.1) {
|
|
2021
|
+
const I = {
|
|
2022
|
+
forw: [
|
|
2023
|
+
_.forw[0] * v + s.forw[0],
|
|
2024
|
+
_.forw[1] * v + s.forw[1]
|
|
2025
|
+
],
|
|
2026
|
+
bakw: [
|
|
2027
|
+
_.bakw[0] * v + s.bakw[0],
|
|
2028
|
+
_.bakw[1] * v + s.bakw[1]
|
|
2029
|
+
]
|
|
2030
|
+
};
|
|
2031
|
+
_.forw[0] < 0 ? y[3].push(I) : y[1].push(I);
|
|
2032
|
+
}
|
|
2033
|
+
if (Math.abs(T) / Math.abs(v) < 1.1) {
|
|
2034
|
+
const I = {
|
|
2035
|
+
forw: [
|
|
2036
|
+
_.forw[0] * T + s.forw[0],
|
|
2037
|
+
_.forw[1] * T + s.forw[1]
|
|
2038
|
+
],
|
|
2039
|
+
bakw: [
|
|
2040
|
+
_.bakw[0] * T + s.bakw[0],
|
|
2041
|
+
_.bakw[1] * T + s.bakw[1]
|
|
2042
|
+
]
|
|
2043
|
+
};
|
|
2044
|
+
_.forw[1] < 0 ? y[0].push(I) : y[2].push(I);
|
|
2045
|
+
}
|
|
2046
|
+
return y;
|
|
2047
|
+
}, [[], [], [], []]);
|
|
2048
|
+
let h = Object.keys(e).reduce(
|
|
2049
|
+
(y, g, b, w) => {
|
|
2050
|
+
const S = e[g], _ = S.forw, v = S.bakw, T = {
|
|
2051
|
+
forw: [_[0] - s.forw[0], _[1] - s.forw[1]],
|
|
2052
|
+
bakw: [v[0] - s.bakw[0], s.bakw[1] - v[1]]
|
|
2053
|
+
};
|
|
2054
|
+
if (T.forw[0] === 0 || T.forw[1] === 0) return y;
|
|
2055
|
+
let I = 0;
|
|
2056
|
+
return T.forw[0] > 0 && (I += 1), T.forw[1] > 0 && (I += 2), y[I].push([T.forw, T.bakw]), b === w.length - 1 ? y.map((N) => N.reduce(
|
|
2057
|
+
(V, z, G, tt) => {
|
|
2058
|
+
V || (V = [1 / 0, 0, 0]);
|
|
2059
|
+
let X = Math.sqrt(Math.pow(z[0][0], 2) + Math.pow(z[0][1], 2)) / Math.sqrt(Math.pow(z[1][0], 2) + Math.pow(z[1][1], 2));
|
|
2060
|
+
X = X < V[0] ? X : V[0];
|
|
2061
|
+
const it = Math.atan2(z[0][0], z[0][1]) - Math.atan2(z[1][0], z[1][1]), d = V[1] + Math.cos(it), m = V[2] + Math.sin(it);
|
|
2062
|
+
return G === tt.length - 1 ? [X, Math.atan2(m, d)] : [X, d, m];
|
|
2063
|
+
},
|
|
2064
|
+
null
|
|
2065
|
+
)) : y;
|
|
2066
|
+
},
|
|
2067
|
+
[[], [], [], []]
|
|
2068
|
+
);
|
|
2069
|
+
h.length === 1 && (h = [
|
|
2070
|
+
h[0],
|
|
2071
|
+
h[0],
|
|
2072
|
+
h[0],
|
|
2073
|
+
h[0]
|
|
2074
|
+
]);
|
|
2075
|
+
const l = h.map((y, g) => {
|
|
2076
|
+
const b = i[g], w = [
|
|
2077
|
+
b[0] - s.forw[0],
|
|
2078
|
+
b[1] - s.forw[1]
|
|
2079
|
+
], _ = Math.sqrt(
|
|
2080
|
+
Math.pow(w[0], 2) + Math.pow(w[1], 2)
|
|
2081
|
+
) / y[0], v = Math.atan2(w[0], w[1]) - y[1], T = [
|
|
2082
|
+
s.bakw[0] + _ * Math.sin(v),
|
|
2083
|
+
s.bakw[1] - _ * Math.cos(v)
|
|
2084
|
+
];
|
|
2085
|
+
return { forw: b, bakw: T };
|
|
2086
|
+
}), p = l[2];
|
|
2087
|
+
return l[2] = l[3], l[3] = p, this.checkAndAdjustVertices(l, c, s), l;
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* 鳥瞰図モードの頂点を計算
|
|
2091
|
+
*/
|
|
2092
|
+
calculateBirdeyeVertices(e, s, i, n, r, a, f) {
|
|
2093
|
+
return this.calculatePlainVertices(
|
|
2094
|
+
e,
|
|
2095
|
+
s,
|
|
2096
|
+
i,
|
|
2097
|
+
n,
|
|
2098
|
+
r,
|
|
2099
|
+
a,
|
|
2100
|
+
f
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* 頂点の位置を調整
|
|
2105
|
+
*/
|
|
2106
|
+
checkAndAdjustVertices(e, s, i) {
|
|
2107
|
+
const n = [1, 1, 1, 1];
|
|
2108
|
+
for (let r = 0; r < 4; r++) {
|
|
2109
|
+
const a = (r + 1) % 4, f = xe([e[r].bakw, e[a].bakw]);
|
|
2110
|
+
s[r].map((c) => {
|
|
2111
|
+
const u = xe([i.bakw, c.bakw]), h = ss(f, u);
|
|
2112
|
+
if (h.features.length > 0 && h.features[0].geometry) {
|
|
2113
|
+
const l = h.features[0], p = Math.sqrt(
|
|
2114
|
+
Math.pow(c.bakw[0] - i.bakw[0], 2) + Math.pow(c.bakw[1] - i.bakw[1], 2)
|
|
2115
|
+
), y = Math.sqrt(
|
|
2116
|
+
Math.pow(
|
|
2117
|
+
l.geometry.coordinates[0] - i.bakw[0],
|
|
2118
|
+
2
|
|
2119
|
+
) + Math.pow(
|
|
2120
|
+
l.geometry.coordinates[1] - i.bakw[1],
|
|
2121
|
+
2
|
|
2122
|
+
)
|
|
2123
|
+
), g = p / y;
|
|
2124
|
+
g > n[r] && (n[r] = g), g > n[a] && (n[a] = g);
|
|
2125
|
+
}
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
e.forEach((r, a) => {
|
|
2129
|
+
const f = n[a], c = [
|
|
2130
|
+
(r.bakw[0] - i.bakw[0]) * f + i.bakw[0],
|
|
2131
|
+
(r.bakw[1] - i.bakw[1]) * f + i.bakw[1]
|
|
2132
|
+
];
|
|
2133
|
+
r.bakw = c;
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* 点の重み付けを計算します
|
|
2138
|
+
*/
|
|
2139
|
+
calculatePointsWeight() {
|
|
2140
|
+
const e = ["forw"];
|
|
2141
|
+
this.strict_status === ht.STATUS_LOOSE && e.push("bakw");
|
|
2142
|
+
const s = {};
|
|
2143
|
+
e.forEach((n) => {
|
|
2144
|
+
s[n] = {};
|
|
2145
|
+
const r = {};
|
|
2146
|
+
this.tins[n].features.map((a) => {
|
|
2147
|
+
const f = ["a", "b", "c"];
|
|
2148
|
+
for (let c = 0; c < 3; c++) {
|
|
2149
|
+
const u = (c + 1) % 3, h = f[c], l = f[u], p = a.properties[h].index, y = a.properties[l].index, g = [p, y].sort().join("-");
|
|
2150
|
+
if (!r[g]) {
|
|
2151
|
+
const b = a.geometry.coordinates[0][c], w = a.geometry.coordinates[0][u], S = a.properties[h].geom, _ = a.properties[l].geom;
|
|
2152
|
+
r[g] = 1;
|
|
2153
|
+
const v = Math.sqrt(
|
|
2154
|
+
Math.pow(S[0] - _[0], 2) + Math.pow(S[1] - _[1], 2)
|
|
2155
|
+
) / Math.sqrt(
|
|
2156
|
+
Math.pow(b[0] - w[0], 2) + Math.pow(b[1] - w[1], 2)
|
|
2157
|
+
);
|
|
2158
|
+
s[n] || (s[n] = {});
|
|
2159
|
+
const T = s[n];
|
|
2160
|
+
T[`${p}:${g}`] = v, T[`${y}:${g}`] = v;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
});
|
|
2164
|
+
});
|
|
2165
|
+
const i = {};
|
|
2166
|
+
e.map((n) => {
|
|
2167
|
+
i[n] = {}, this.strict_status === ht.STATUS_STRICT && (i.bakw = {});
|
|
2168
|
+
const r = s[n], a = {};
|
|
2169
|
+
Object.keys(r).forEach((c) => {
|
|
2170
|
+
const [u] = c.split(":");
|
|
2171
|
+
a[u] || (a[u] = []), a[u].push(r[c]);
|
|
2172
|
+
}), Object.keys(a).forEach((c) => {
|
|
2173
|
+
const u = a[c], h = u.reduce((l, p) => l + p, 0) / u.length;
|
|
2174
|
+
i[n] || (i[n] = {}), i[n][c] = h, this.strict_status === ht.STATUS_STRICT && (i.bakw || (i.bakw = {}), i.bakw[c] = 1 / h);
|
|
2175
|
+
});
|
|
2176
|
+
let f = 0;
|
|
2177
|
+
for (let c = 0; c < 4; c++) {
|
|
2178
|
+
const u = `b${c}`, h = i[n][u] || 0;
|
|
2179
|
+
f += h;
|
|
2180
|
+
}
|
|
2181
|
+
i[n].c = f / 4, this.strict_status === ht.STATUS_STRICT && i.bakw && (i.bakw.c = 1 / i[n].c);
|
|
2182
|
+
}), this.pointsWeightBuffer = i;
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
export {
|
|
2186
|
+
ht as Tin,
|
|
2187
|
+
te as constrainedTin,
|
|
2188
|
+
ie as counterPoint,
|
|
2189
|
+
ne as createPoint,
|
|
2190
|
+
Us as findIntersections,
|
|
2191
|
+
we as format_version,
|
|
2192
|
+
rn as insertSearchIndex,
|
|
2193
|
+
Fe as vertexCalc
|
|
2194
|
+
};
|