@maplat/transform 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +224 -224
- package/README.ja.md +68 -68
- package/README.md +143 -143
- package/dist/index.d.ts +28 -23
- package/dist/maplat_transform.js +515 -444
- package/dist/maplat_transform.umd.js +1 -1
- package/package.json +40 -44
- package/src/compiled-state.ts +211 -0
- package/src/edgeutils.ts +47 -47
- package/src/geometry.ts +247 -248
- package/src/index.ts +398 -567
- package/src/triangulation.ts +179 -179
- package/src/types.ts +122 -0
- package/dist/index.html +0 -39
- package/dist/maplat_transform.cjs +0 -1
package/dist/maplat_transform.js
CHANGED
|
@@ -1,352 +1,505 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
y > l == y > -l ? (n = l, l = t[++o]) : (n = y, y = r[++u]);
|
|
8
|
-
let b = 0;
|
|
9
|
-
if (o < e && u < s)
|
|
10
|
-
for (y > l == y > -l ? (c = l + n, d = n - (c - l), l = t[++o]) : (c = y + n, d = n - (c - y), y = r[++u]), n = c, d !== 0 && (a[b++] = d); o < e && u < s; )
|
|
11
|
-
y > l == y > -l ? (c = n + l, g = c - n, d = n - (c - g) + (l - g), l = t[++o]) : (c = n + y, g = c - n, d = n - (c - g) + (y - g), y = r[++u]), n = c, d !== 0 && (a[b++] = d);
|
|
12
|
-
for (; o < e; )
|
|
13
|
-
c = n + l, g = c - n, d = n - (c - g) + (l - g), l = t[++o], n = c, d !== 0 && (a[b++] = d);
|
|
14
|
-
for (; u < s; )
|
|
15
|
-
c = n + y, g = c - n, d = n - (c - g) + (y - g), y = r[++u], n = c, d !== 0 && (a[b++] = d);
|
|
16
|
-
return (n !== 0 || b === 0) && (a[b++] = n), b;
|
|
17
|
-
}
|
|
18
|
-
function ct(e, t) {
|
|
19
|
-
let s = t[0];
|
|
20
|
-
for (let r = 1; r < e; r++) s += t[r];
|
|
21
|
-
return s;
|
|
22
|
-
}
|
|
23
|
-
function $(e) {
|
|
24
|
-
return new Float64Array(e);
|
|
25
|
-
}
|
|
26
|
-
const ut = (3 + 16 * R) * R, ht = (2 + 12 * R) * R, gt = (9 + 64 * R) * R * R, F = $(4), q = $(8), L = $(12), G = $(16), P = $(4);
|
|
27
|
-
function dt(e, t, s, r, a, n, c) {
|
|
28
|
-
let d, g, l, y, o, u, b, x, h, f, i, w, A, v, E, m, M, T;
|
|
29
|
-
const S = e - a, p = s - a, k = t - n, N = r - n;
|
|
30
|
-
v = S * N, u = I * S, b = u - (u - S), x = S - b, u = I * N, h = u - (u - N), f = N - h, E = x * f - (v - b * h - x * h - b * f), m = k * p, u = I * k, b = u - (u - k), x = k - b, u = I * p, h = u - (u - p), f = p - h, M = x * f - (m - b * h - x * h - b * f), i = E - M, o = E - i, F[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, F[1] = A - (i + o) + (o - m), T = w + i, o = T - w, F[2] = w - (T - o) + (i - o), F[3] = T;
|
|
31
|
-
let U = ct(4, F), X = ht * c;
|
|
32
|
-
if (U >= X || -U >= X || (o = e - S, d = e - (S + o) + (o - a), o = s - p, l = s - (p + o) + (o - a), o = t - k, g = t - (k + o) + (o - n), o = r - N, y = r - (N + o) + (o - n), d === 0 && g === 0 && l === 0 && y === 0) || (X = gt * c + ft * Math.abs(U), U += S * y + N * d - (k * l + p * g), U >= X || -U >= X)) return U;
|
|
33
|
-
v = d * N, u = I * d, b = u - (u - d), x = d - b, u = I * N, h = u - (u - N), f = N - h, E = x * f - (v - b * h - x * h - b * f), m = g * p, u = I * g, b = u - (u - g), x = g - b, u = I * p, h = u - (u - p), f = p - h, M = x * f - (m - b * h - x * h - b * f), i = E - M, o = E - i, P[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, P[1] = A - (i + o) + (o - m), T = w + i, o = T - w, P[2] = w - (T - o) + (i - o), P[3] = T;
|
|
34
|
-
const st = V(4, F, 4, P, q);
|
|
35
|
-
v = S * y, u = I * S, b = u - (u - S), x = S - b, u = I * y, h = u - (u - y), f = y - h, E = x * f - (v - b * h - x * h - b * f), m = k * l, u = I * k, b = u - (u - k), x = k - b, u = I * l, h = u - (u - l), f = l - h, M = x * f - (m - b * h - x * h - b * f), i = E - M, o = E - i, P[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, P[1] = A - (i + o) + (o - m), T = w + i, o = T - w, P[2] = w - (T - o) + (i - o), P[3] = T;
|
|
36
|
-
const nt = V(st, q, 4, P, L);
|
|
37
|
-
v = d * y, u = I * d, b = u - (u - d), x = d - b, u = I * y, h = u - (u - y), f = y - h, E = x * f - (v - b * h - x * h - b * f), m = g * l, u = I * g, b = u - (u - g), x = g - b, u = I * l, h = u - (u - l), f = l - h, M = x * f - (m - b * h - x * h - b * f), i = E - M, o = E - i, P[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, P[1] = A - (i + o) + (o - m), T = w + i, o = T - w, P[2] = w - (T - o) + (i - o), P[3] = T;
|
|
38
|
-
const it = V(nt, L, 4, P, G);
|
|
39
|
-
return G[it - 1];
|
|
40
|
-
}
|
|
41
|
-
function lt(e, t, s, r, a, n) {
|
|
42
|
-
const c = (t - n) * (s - a), d = (e - a) * (r - n), g = c - d, l = Math.abs(c + d);
|
|
43
|
-
return Math.abs(g) >= ut * l ? g : -dt(e, t, s, r, a, n, l);
|
|
44
|
-
}
|
|
45
|
-
function yt(e, t) {
|
|
46
|
-
var s, r, a = 0, n, c, d, g, l, y, o, u = e[0], b = e[1], x = t.length;
|
|
47
|
-
for (s = 0; s < x; s++) {
|
|
48
|
-
r = 0;
|
|
49
|
-
var h = t[s], f = h.length - 1;
|
|
50
|
-
if (y = h[0], y[0] !== h[f][0] && y[1] !== h[f][1])
|
|
51
|
-
throw new Error("First and last coordinates in a ring must be the same");
|
|
52
|
-
for (c = y[0] - u, d = y[1] - b, r; r < f; r++) {
|
|
53
|
-
if (o = h[r + 1], g = o[0] - u, l = o[1] - b, d === 0 && l === 0) {
|
|
54
|
-
if (g <= 0 && c >= 0 || c <= 0 && g >= 0)
|
|
55
|
-
return 0;
|
|
56
|
-
} else if (l >= 0 && d <= 0 || l <= 0 && d >= 0) {
|
|
57
|
-
if (n = lt(c, g, d, l, 0, 0), n === 0)
|
|
58
|
-
return 0;
|
|
59
|
-
(n > 0 && l > 0 && d <= 0 || n < 0 && l <= 0 && d > 0) && a++;
|
|
60
|
-
}
|
|
61
|
-
y = o, d = l, c = g;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return a % 2 !== 0;
|
|
1
|
+
var at = Object.defineProperty;
|
|
2
|
+
var ct = (t, e, r) => e in t ? at(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var x = (t, e, r) => ct(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
function tt(t, e, r = {}) {
|
|
5
|
+
const n = { type: "Feature" };
|
|
6
|
+
return (r.id === 0 || r.id) && (n.id = r.id), r.bbox && (n.bbox = r.bbox), n.properties = e || {}, n.geometry = t, n;
|
|
65
7
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
return (s.id === 0 || s.id) && (r.id = s.id), s.bbox && (r.bbox = s.bbox), r.properties = t || {}, r.geometry = e, r;
|
|
69
|
-
}
|
|
70
|
-
function Y(e, t, s = {}) {
|
|
71
|
-
if (!e)
|
|
8
|
+
function W(t, e, r = {}) {
|
|
9
|
+
if (!t)
|
|
72
10
|
throw new Error("coordinates is required");
|
|
73
|
-
if (!Array.isArray(
|
|
11
|
+
if (!Array.isArray(t))
|
|
74
12
|
throw new Error("coordinates must be an Array");
|
|
75
|
-
if (
|
|
13
|
+
if (t.length < 2)
|
|
76
14
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
77
|
-
if (!
|
|
15
|
+
if (!q(t[0]) || !q(t[1]))
|
|
78
16
|
throw new Error("coordinates must contain numbers");
|
|
79
|
-
return
|
|
17
|
+
return tt({
|
|
80
18
|
type: "Point",
|
|
81
|
-
coordinates:
|
|
82
|
-
},
|
|
19
|
+
coordinates: t
|
|
20
|
+
}, e, r);
|
|
83
21
|
}
|
|
84
|
-
function
|
|
85
|
-
for (const
|
|
86
|
-
if (
|
|
22
|
+
function et(t, e, r = {}) {
|
|
23
|
+
for (const c of t) {
|
|
24
|
+
if (c.length < 4)
|
|
87
25
|
throw new Error(
|
|
88
26
|
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
89
27
|
);
|
|
90
|
-
if (
|
|
28
|
+
if (c[c.length - 1].length !== c[0].length)
|
|
91
29
|
throw new Error("First and last Position are not equivalent.");
|
|
92
|
-
for (let
|
|
93
|
-
if (
|
|
30
|
+
for (let i = 0; i < c[c.length - 1].length; i++)
|
|
31
|
+
if (c[c.length - 1][i] !== c[0][i])
|
|
94
32
|
throw new Error("First and last Position are not equivalent.");
|
|
95
33
|
}
|
|
96
|
-
return
|
|
34
|
+
return tt({
|
|
97
35
|
type: "Polygon",
|
|
98
|
-
coordinates:
|
|
99
|
-
},
|
|
36
|
+
coordinates: t
|
|
37
|
+
}, e, r);
|
|
100
38
|
}
|
|
101
|
-
function
|
|
102
|
-
const
|
|
103
|
-
return
|
|
39
|
+
function F(t, e = {}) {
|
|
40
|
+
const r = { type: "FeatureCollection" };
|
|
41
|
+
return e.id && (r.id = e.id), e.bbox && (r.bbox = e.bbox), r.features = t, r;
|
|
104
42
|
}
|
|
105
|
-
function
|
|
106
|
-
return !isNaN(
|
|
43
|
+
function q(t) {
|
|
44
|
+
return !isNaN(t) && t !== null && !Array.isArray(t);
|
|
107
45
|
}
|
|
108
|
-
function
|
|
109
|
-
if (!
|
|
46
|
+
function ut(t) {
|
|
47
|
+
if (!t)
|
|
110
48
|
throw new Error("coord is required");
|
|
111
|
-
if (!Array.isArray(
|
|
112
|
-
if (
|
|
113
|
-
return [...
|
|
114
|
-
if (
|
|
115
|
-
return [...
|
|
49
|
+
if (!Array.isArray(t)) {
|
|
50
|
+
if (t.type === "Feature" && t.geometry !== null && t.geometry.type === "Point")
|
|
51
|
+
return [...t.geometry.coordinates];
|
|
52
|
+
if (t.type === "Point")
|
|
53
|
+
return [...t.coordinates];
|
|
116
54
|
}
|
|
117
|
-
if (Array.isArray(
|
|
118
|
-
return [...
|
|
55
|
+
if (Array.isArray(t) && t.length >= 2 && !Array.isArray(t[0]) && !Array.isArray(t[1]))
|
|
56
|
+
return [...t];
|
|
119
57
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
120
58
|
}
|
|
121
|
-
function
|
|
122
|
-
if (Array.isArray(
|
|
123
|
-
return
|
|
124
|
-
if (
|
|
125
|
-
if (
|
|
126
|
-
return
|
|
127
|
-
} else if (
|
|
128
|
-
return
|
|
59
|
+
function z(t) {
|
|
60
|
+
if (Array.isArray(t))
|
|
61
|
+
return t;
|
|
62
|
+
if (t.type === "Feature") {
|
|
63
|
+
if (t.geometry !== null)
|
|
64
|
+
return t.geometry.coordinates;
|
|
65
|
+
} else if (t.coordinates)
|
|
66
|
+
return t.coordinates;
|
|
129
67
|
throw new Error(
|
|
130
68
|
"coords must be GeoJSON Feature, Geometry Object or an Array"
|
|
131
69
|
);
|
|
132
70
|
}
|
|
133
|
-
function
|
|
134
|
-
return
|
|
71
|
+
function ft(t) {
|
|
72
|
+
return t.type === "Feature" ? t.geometry : t;
|
|
135
73
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
74
|
+
const R = 11102230246251565e-32, O = 134217729, dt = (3 + 8 * R) * R;
|
|
75
|
+
function V(t, e, r, n, c) {
|
|
76
|
+
let i, f, g, h, l = e[0], y = n[0], o = 0, u = 0;
|
|
77
|
+
y > l == y > -l ? (i = l, l = e[++o]) : (i = y, y = n[++u]);
|
|
78
|
+
let b = 0;
|
|
79
|
+
if (o < t && u < r)
|
|
80
|
+
for (y > l == y > -l ? (f = l + i, g = i - (f - l), l = e[++o]) : (f = y + i, g = i - (f - y), y = n[++u]), i = f, g !== 0 && (c[b++] = g); o < t && u < r; )
|
|
81
|
+
y > l == y > -l ? (f = i + l, h = f - i, g = i - (f - h) + (l - h), l = e[++o]) : (f = i + y, h = f - i, g = i - (f - h) + (y - h), y = n[++u]), i = f, g !== 0 && (c[b++] = g);
|
|
82
|
+
for (; o < t; )
|
|
83
|
+
f = i + l, h = f - i, g = i - (f - h) + (l - h), l = e[++o], i = f, g !== 0 && (c[b++] = g);
|
|
84
|
+
for (; u < r; )
|
|
85
|
+
f = i + y, h = f - i, g = i - (f - h) + (y - h), y = n[++u], i = f, g !== 0 && (c[b++] = g);
|
|
86
|
+
return (i !== 0 || b === 0) && (c[b++] = i), b;
|
|
87
|
+
}
|
|
88
|
+
function ht(t, e) {
|
|
89
|
+
let r = e[0];
|
|
90
|
+
for (let n = 1; n < t; n++) r += e[n];
|
|
91
|
+
return r;
|
|
92
|
+
}
|
|
93
|
+
function Y(t) {
|
|
94
|
+
return new Float64Array(t);
|
|
95
|
+
}
|
|
96
|
+
const gt = (3 + 16 * R) * R, lt = (2 + 12 * R) * R, yt = (9 + 64 * R) * R * R, U = Y(4), G = Y(8), j = Y(12), J = Y(16), S = Y(4);
|
|
97
|
+
function bt(t, e, r, n, c, i, f) {
|
|
98
|
+
let g, h, l, y, o, u, b, p, d, a, s, m, v, M, _, w, A, P;
|
|
99
|
+
const k = t - c, I = r - c, T = e - i, N = n - i;
|
|
100
|
+
M = k * N, u = O * k, b = u - (u - k), p = k - b, u = O * N, d = u - (u - N), a = N - d, _ = p * a - (M - b * d - p * d - b * a), w = T * I, u = O * T, b = u - (u - T), p = T - b, u = O * I, d = u - (u - I), a = I - d, A = p * a - (w - b * d - p * d - b * a), s = _ - A, o = _ - s, U[0] = _ - (s + o) + (o - A), m = M + s, o = m - M, v = M - (m - o) + (s - o), s = v - w, o = v - s, U[1] = v - (s + o) + (o - w), P = m + s, o = P - m, U[2] = m - (P - o) + (s - o), U[3] = P;
|
|
101
|
+
let C = ht(4, U), X = lt * f;
|
|
102
|
+
if (C >= X || -C >= X || (o = t - k, g = t - (k + o) + (o - c), o = r - I, l = r - (I + o) + (o - c), o = e - T, h = e - (T + o) + (o - i), o = n - N, y = n - (N + o) + (o - i), g === 0 && h === 0 && l === 0 && y === 0) || (X = yt * f + dt * Math.abs(C), C += k * y + N * g - (T * l + I * h), C >= X || -C >= X)) return C;
|
|
103
|
+
M = g * N, u = O * g, b = u - (u - g), p = g - b, u = O * N, d = u - (u - N), a = N - d, _ = p * a - (M - b * d - p * d - b * a), w = h * I, u = O * h, b = u - (u - h), p = h - b, u = O * I, d = u - (u - I), a = I - d, A = p * a - (w - b * d - p * d - b * a), s = _ - A, o = _ - s, S[0] = _ - (s + o) + (o - A), m = M + s, o = m - M, v = M - (m - o) + (s - o), s = v - w, o = v - s, S[1] = v - (s + o) + (o - w), P = m + s, o = P - m, S[2] = m - (P - o) + (s - o), S[3] = P;
|
|
104
|
+
const it = V(4, U, 4, S, G);
|
|
105
|
+
M = k * y, u = O * k, b = u - (u - k), p = k - b, u = O * y, d = u - (u - y), a = y - d, _ = p * a - (M - b * d - p * d - b * a), w = T * l, u = O * T, b = u - (u - T), p = T - b, u = O * l, d = u - (u - l), a = l - d, A = p * a - (w - b * d - p * d - b * a), s = _ - A, o = _ - s, S[0] = _ - (s + o) + (o - A), m = M + s, o = m - M, v = M - (m - o) + (s - o), s = v - w, o = v - s, S[1] = v - (s + o) + (o - w), P = m + s, o = P - m, S[2] = m - (P - o) + (s - o), S[3] = P;
|
|
106
|
+
const st = V(it, G, 4, S, j);
|
|
107
|
+
M = g * y, u = O * g, b = u - (u - g), p = g - b, u = O * y, d = u - (u - y), a = y - d, _ = p * a - (M - b * d - p * d - b * a), w = h * l, u = O * h, b = u - (u - h), p = h - b, u = O * l, d = u - (u - l), a = l - d, A = p * a - (w - b * d - p * d - b * a), s = _ - A, o = _ - s, S[0] = _ - (s + o) + (o - A), m = M + s, o = m - M, v = M - (m - o) + (s - o), s = v - w, o = v - s, S[1] = v - (s + o) + (o - w), P = m + s, o = P - m, S[2] = m - (P - o) + (s - o), S[3] = P;
|
|
108
|
+
const ot = V(st, j, 4, S, J);
|
|
109
|
+
return J[ot - 1];
|
|
110
|
+
}
|
|
111
|
+
function mt(t, e, r, n, c, i) {
|
|
112
|
+
const f = (e - i) * (r - c), g = (t - c) * (n - i), h = f - g, l = Math.abs(f + g);
|
|
113
|
+
return Math.abs(h) >= gt * l ? h : -bt(t, e, r, n, c, i, l);
|
|
114
|
+
}
|
|
115
|
+
function wt(t, e) {
|
|
116
|
+
var r, n, c = 0, i, f, g, h, l, y, o, u = t[0], b = t[1], p = e.length;
|
|
117
|
+
for (r = 0; r < p; r++) {
|
|
118
|
+
n = 0;
|
|
119
|
+
var d = e[r], a = d.length - 1;
|
|
120
|
+
if (y = d[0], y[0] !== d[a][0] && y[1] !== d[a][1])
|
|
121
|
+
throw new Error("First and last coordinates in a ring must be the same");
|
|
122
|
+
for (f = y[0] - u, g = y[1] - b, n; n < a; n++) {
|
|
123
|
+
if (o = d[n + 1], h = o[0] - u, l = o[1] - b, g === 0 && l === 0) {
|
|
124
|
+
if (h <= 0 && f >= 0 || f <= 0 && h >= 0)
|
|
125
|
+
return 0;
|
|
126
|
+
} else if (l >= 0 && g <= 0 || l <= 0 && g >= 0) {
|
|
127
|
+
if (i = mt(f, h, g, l, 0, 0), i === 0)
|
|
128
|
+
return 0;
|
|
129
|
+
(i > 0 && l > 0 && g <= 0 || i < 0 && l <= 0 && g > 0) && c++;
|
|
130
|
+
}
|
|
131
|
+
y = o, g = l, f = h;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return c % 2 !== 0;
|
|
135
|
+
}
|
|
136
|
+
function L(t, e, r = {}) {
|
|
139
137
|
if (!t)
|
|
138
|
+
throw new Error("point is required");
|
|
139
|
+
if (!e)
|
|
140
140
|
throw new Error("polygon is required");
|
|
141
|
-
const
|
|
142
|
-
let
|
|
143
|
-
if (
|
|
141
|
+
const n = ut(t), c = ft(e), i = c.type, f = e.bbox;
|
|
142
|
+
let g = c.coordinates;
|
|
143
|
+
if (f && xt(n, f) === !1)
|
|
144
144
|
return !1;
|
|
145
|
-
|
|
146
|
-
let
|
|
147
|
-
for (var l = 0; l <
|
|
148
|
-
const y =
|
|
149
|
-
if (y === 0) return !
|
|
150
|
-
y && (
|
|
145
|
+
i === "Polygon" && (g = [g]);
|
|
146
|
+
let h = !1;
|
|
147
|
+
for (var l = 0; l < g.length; ++l) {
|
|
148
|
+
const y = wt(n, g[l]);
|
|
149
|
+
if (y === 0) return !r.ignoreBoundary;
|
|
150
|
+
y && (h = !0);
|
|
151
|
+
}
|
|
152
|
+
return h;
|
|
153
|
+
}
|
|
154
|
+
function xt(t, e) {
|
|
155
|
+
return e[0] <= t[0] && e[1] <= t[1] && e[2] >= t[0] && e[3] >= t[1];
|
|
156
|
+
}
|
|
157
|
+
function K(t, e) {
|
|
158
|
+
for (let r = 0; r < e.features.length; r++)
|
|
159
|
+
if (L(t, e.features[r]))
|
|
160
|
+
return e.features[r];
|
|
161
|
+
}
|
|
162
|
+
function rt(t, e, r) {
|
|
163
|
+
const n = e.geometry.coordinates[0][0], c = e.geometry.coordinates[0][1], i = e.geometry.coordinates[0][2], f = t.geometry.coordinates, g = e.properties.a.geom, h = e.properties.b.geom, l = e.properties.c.geom, y = [c[0] - n[0], c[1] - n[1]], o = [i[0] - n[0], i[1] - n[1]], u = [f[0] - n[0], f[1] - n[1]], b = [h[0] - g[0], h[1] - g[1]], p = [l[0] - g[0], l[1] - g[1]];
|
|
164
|
+
let d = (o[1] * u[0] - o[0] * u[1]) / (y[0] * o[1] - y[1] * o[0]), a = (y[0] * u[1] - y[1] * u[0]) / (y[0] * o[1] - y[1] * o[0]);
|
|
165
|
+
if (r) {
|
|
166
|
+
const s = r[e.properties.a.index], m = r[e.properties.b.index], v = r[e.properties.c.index];
|
|
167
|
+
let M;
|
|
168
|
+
if (d < 0 || a < 0 || 1 - d - a < 0) {
|
|
169
|
+
const _ = d / (d + a), w = a / (d + a);
|
|
170
|
+
M = d / m / (_ / m + w / v), a = a / v / (_ / m + w / v);
|
|
171
|
+
} else
|
|
172
|
+
M = d / m / (d / m + a / v + (1 - d - a) / s), a = a / v / (d / m + a / v + (1 - d - a) / s);
|
|
173
|
+
d = M;
|
|
174
|
+
}
|
|
175
|
+
return [
|
|
176
|
+
d * b[0] + a * p[0] + g[0],
|
|
177
|
+
d * b[1] + a * p[1] + g[1]
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
function pt(t, e, r, n) {
|
|
181
|
+
const c = t.geometry.coordinates, i = r.geometry.coordinates, f = Math.atan2(c[0] - i[0], c[1] - i[1]), g = Mt(f, e[0]);
|
|
182
|
+
if (g === void 0)
|
|
183
|
+
throw new Error("Unable to determine vertex index");
|
|
184
|
+
const h = e[1][g];
|
|
185
|
+
return rt(t, h.features[0], n);
|
|
186
|
+
}
|
|
187
|
+
function vt(t, e, r, n, c, i, f, g) {
|
|
188
|
+
let h;
|
|
189
|
+
if (f && (h = K(t, F([f]))), !h) {
|
|
190
|
+
if (r) {
|
|
191
|
+
const l = t.geometry.coordinates, y = r.gridNum, o = r.xOrigin, u = r.yOrigin, b = r.xUnit, p = r.yUnit, d = r.gridCache, a = B(l[0], o, b, y), s = B(l[1], u, p, y), m = d[a] ? d[a][s] ? d[a][s] : [] : [];
|
|
192
|
+
e = F(m.map((v) => e.features[v]));
|
|
193
|
+
}
|
|
194
|
+
h = K(t, e);
|
|
151
195
|
}
|
|
152
|
-
return g;
|
|
196
|
+
return g && g(h), h ? rt(t, h, i) : pt(t, n, c, i);
|
|
153
197
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
198
|
+
function B(t, e, r, n) {
|
|
199
|
+
let c = Math.floor((t - e) / r);
|
|
200
|
+
return c >= n && (c = n - 1), c;
|
|
156
201
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
202
|
+
function Mt(t, e) {
|
|
203
|
+
let r = Q(t - e[0]), n = Math.PI * 2, c;
|
|
204
|
+
for (let i = 0; i < e.length; i++) {
|
|
205
|
+
const f = (i + 1) % e.length, g = Q(t - e[f]), h = Math.min(Math.abs(r), Math.abs(g));
|
|
206
|
+
r * g <= 0 && h < n && (n = h, c = i), r = g;
|
|
207
|
+
}
|
|
208
|
+
return c;
|
|
209
|
+
}
|
|
210
|
+
function Q(t, e = !1) {
|
|
211
|
+
const r = e ? function(n) {
|
|
212
|
+
return !(n >= 0 && n < Math.PI * 2);
|
|
213
|
+
} : function(n) {
|
|
214
|
+
return !(n > -1 * Math.PI && n <= Math.PI);
|
|
215
|
+
};
|
|
216
|
+
for (; r(t); )
|
|
217
|
+
t = t + 2 * Math.PI * (t > 0 ? -1 : 1);
|
|
218
|
+
return t;
|
|
219
|
+
}
|
|
220
|
+
function At(t, e) {
|
|
221
|
+
return e && e >= 2.00703 || Array.isArray(t[0]) ? t : t.map((r) => [
|
|
222
|
+
r.illstNodes,
|
|
223
|
+
r.mercNodes,
|
|
224
|
+
r.startEnd
|
|
225
|
+
]);
|
|
226
|
+
}
|
|
227
|
+
function Ft(t) {
|
|
228
|
+
const e = t.features;
|
|
229
|
+
for (let r = 0; r < e.length; r++) {
|
|
230
|
+
const n = e[r];
|
|
231
|
+
`${n.properties.a.index}`.substring(0, 1) === "b" && `${n.properties.b.index}`.substring(0, 1) === "b" ? e[r] = {
|
|
163
232
|
geometry: {
|
|
164
233
|
type: "Polygon",
|
|
165
234
|
coordinates: [
|
|
166
235
|
[
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
236
|
+
n.geometry.coordinates[0][2],
|
|
237
|
+
n.geometry.coordinates[0][0],
|
|
238
|
+
n.geometry.coordinates[0][1],
|
|
239
|
+
n.geometry.coordinates[0][2]
|
|
171
240
|
]
|
|
172
241
|
]
|
|
173
242
|
},
|
|
174
243
|
properties: {
|
|
175
244
|
a: {
|
|
176
|
-
geom:
|
|
177
|
-
index:
|
|
245
|
+
geom: n.properties.c.geom,
|
|
246
|
+
index: n.properties.c.index
|
|
178
247
|
},
|
|
179
248
|
b: {
|
|
180
|
-
geom:
|
|
181
|
-
index:
|
|
249
|
+
geom: n.properties.a.geom,
|
|
250
|
+
index: n.properties.a.index
|
|
182
251
|
},
|
|
183
252
|
c: {
|
|
184
|
-
geom:
|
|
185
|
-
index:
|
|
253
|
+
geom: n.properties.b.geom,
|
|
254
|
+
index: n.properties.b.index
|
|
186
255
|
}
|
|
187
256
|
},
|
|
188
257
|
type: "Feature"
|
|
189
|
-
} : `${
|
|
258
|
+
} : `${n.properties.c.index}`.substring(0, 1) === "b" && `${n.properties.a.index}`.substring(0, 1) === "b" && (e[r] = {
|
|
190
259
|
geometry: {
|
|
191
260
|
type: "Polygon",
|
|
192
261
|
coordinates: [
|
|
193
262
|
[
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
263
|
+
n.geometry.coordinates[0][1],
|
|
264
|
+
n.geometry.coordinates[0][2],
|
|
265
|
+
n.geometry.coordinates[0][0],
|
|
266
|
+
n.geometry.coordinates[0][1]
|
|
198
267
|
]
|
|
199
268
|
]
|
|
200
269
|
},
|
|
201
270
|
properties: {
|
|
202
271
|
a: {
|
|
203
|
-
geom:
|
|
204
|
-
index:
|
|
272
|
+
geom: n.properties.b.geom,
|
|
273
|
+
index: n.properties.b.index
|
|
205
274
|
},
|
|
206
275
|
b: {
|
|
207
|
-
geom:
|
|
208
|
-
index:
|
|
276
|
+
geom: n.properties.c.geom,
|
|
277
|
+
index: n.properties.c.index
|
|
209
278
|
},
|
|
210
279
|
c: {
|
|
211
|
-
geom:
|
|
212
|
-
index:
|
|
280
|
+
geom: n.properties.a.geom,
|
|
281
|
+
index: n.properties.a.index
|
|
213
282
|
}
|
|
214
283
|
},
|
|
215
284
|
type: "Feature"
|
|
216
285
|
});
|
|
217
286
|
}
|
|
218
|
-
return
|
|
287
|
+
return t;
|
|
219
288
|
}
|
|
220
|
-
function
|
|
221
|
-
const
|
|
222
|
-
(
|
|
223
|
-
),
|
|
224
|
-
a: { geom:
|
|
225
|
-
b: { geom:
|
|
226
|
-
c: { geom:
|
|
289
|
+
function Xt(t) {
|
|
290
|
+
const e = ["a", "b", "c", "a"].map(
|
|
291
|
+
(i) => t.properties[i].geom
|
|
292
|
+
), r = t.geometry.coordinates[0], n = t.properties, c = {
|
|
293
|
+
a: { geom: r[0], index: n.a.index },
|
|
294
|
+
b: { geom: r[1], index: n.b.index },
|
|
295
|
+
c: { geom: r[2], index: n.c.index }
|
|
227
296
|
};
|
|
228
|
-
return
|
|
297
|
+
return et([e], c);
|
|
229
298
|
}
|
|
230
|
-
function _t(
|
|
231
|
-
const
|
|
232
|
-
a: { geom:
|
|
233
|
-
b: { geom:
|
|
234
|
-
c: { geom:
|
|
299
|
+
function _t(t) {
|
|
300
|
+
const e = [0, 1, 2, 0].map((n) => t[n][0][0]), r = {
|
|
301
|
+
a: { geom: t[0][0][1], index: t[0][1] },
|
|
302
|
+
b: { geom: t[1][0][1], index: t[1][1] },
|
|
303
|
+
c: { geom: t[2][0][1], index: t[2][1] }
|
|
235
304
|
};
|
|
236
|
-
return
|
|
237
|
-
}
|
|
238
|
-
function
|
|
239
|
-
const
|
|
240
|
-
(
|
|
241
|
-
(!
|
|
242
|
-
const l = isFinite(
|
|
243
|
-
const y =
|
|
305
|
+
return et([e], r);
|
|
306
|
+
}
|
|
307
|
+
function $(t, e, r, n, c, i = !1, f) {
|
|
308
|
+
const g = t.map(
|
|
309
|
+
(h) => {
|
|
310
|
+
(!f || f < 2.00703) && (h = nt(h));
|
|
311
|
+
const l = isFinite(h) ? e[h] : h === "c" ? n : h === "b0" ? c[0] : h === "b1" ? c[1] : h === "b2" ? c[2] : h === "b3" ? c[3] : (function() {
|
|
312
|
+
const y = h.match(/e(\d+)/);
|
|
244
313
|
if (y) {
|
|
245
314
|
const o = parseInt(y[1]);
|
|
246
|
-
return
|
|
315
|
+
return r[o];
|
|
247
316
|
}
|
|
248
317
|
throw "Bad index value for indexesToTri";
|
|
249
|
-
}();
|
|
250
|
-
return
|
|
318
|
+
})();
|
|
319
|
+
return i ? [[l[1], l[0]], h] : [[l[0], l[1]], h];
|
|
251
320
|
}
|
|
252
321
|
);
|
|
253
|
-
return _t(
|
|
322
|
+
return _t(g);
|
|
254
323
|
}
|
|
255
|
-
function
|
|
256
|
-
return typeof
|
|
324
|
+
function nt(t) {
|
|
325
|
+
return typeof t == "number" ? t : t.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
|
|
257
326
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
s.mercNodes,
|
|
262
|
-
s.startEnd
|
|
263
|
-
]);
|
|
327
|
+
const D = 2.00703;
|
|
328
|
+
function Et(t) {
|
|
329
|
+
return !!(t.version || !t.tins && t.points && t.tins_points);
|
|
264
330
|
}
|
|
265
|
-
function
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
h * b[0] + f * x[0] + d[0],
|
|
285
|
-
h * b[1] + f * x[1] + d[1]
|
|
286
|
-
];
|
|
331
|
+
function Pt(t) {
|
|
332
|
+
return {
|
|
333
|
+
points: t.points,
|
|
334
|
+
pointsWeightBuffer: St(t),
|
|
335
|
+
strictStatus: kt(t),
|
|
336
|
+
verticesParams: It(t),
|
|
337
|
+
centroid: Tt(t),
|
|
338
|
+
edges: At(t.edges || []),
|
|
339
|
+
edgeNodes: t.edgeNodes || [],
|
|
340
|
+
tins: Nt(t),
|
|
341
|
+
kinks: Bt(t.kinks_points),
|
|
342
|
+
yaxisMode: t.yaxisMode ?? "invert",
|
|
343
|
+
strictMode: t.strictMode ?? "auto",
|
|
344
|
+
vertexMode: t.vertexMode,
|
|
345
|
+
bounds: t.bounds,
|
|
346
|
+
boundsPolygon: t.boundsPolygon,
|
|
347
|
+
wh: t.wh,
|
|
348
|
+
xy: t.bounds ? t.xy : [0, 0]
|
|
349
|
+
};
|
|
287
350
|
}
|
|
288
|
-
function
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
t = B(w.map((A) => t.features[A]));
|
|
301
|
-
}
|
|
302
|
-
g = z(e, t);
|
|
303
|
-
}
|
|
304
|
-
return d && d(g), g ? rt(e, g, n) : vt(e, r, a, n);
|
|
351
|
+
function Ot(t) {
|
|
352
|
+
const e = Ct(t), r = e.tins;
|
|
353
|
+
return {
|
|
354
|
+
compiled: e,
|
|
355
|
+
tins: r,
|
|
356
|
+
points: Rt(r),
|
|
357
|
+
strictStatus: e.strict_status,
|
|
358
|
+
pointsWeightBuffer: e.weight_buffer,
|
|
359
|
+
verticesParams: e.vertices_params,
|
|
360
|
+
centroid: e.centroid,
|
|
361
|
+
kinks: e.kinks
|
|
362
|
+
};
|
|
305
363
|
}
|
|
306
|
-
function
|
|
307
|
-
|
|
308
|
-
|
|
364
|
+
function St(t) {
|
|
365
|
+
return !t.version || t.version < D ? ["forw", "bakw"].reduce((e, r) => {
|
|
366
|
+
const n = t.weight_buffer[r];
|
|
367
|
+
return n && (e[r] = Object.keys(n).reduce((c, i) => {
|
|
368
|
+
const f = nt(i);
|
|
369
|
+
return c[f] = n[i], c;
|
|
370
|
+
}, {})), e;
|
|
371
|
+
}, {}) : t.weight_buffer;
|
|
309
372
|
}
|
|
310
|
-
function
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
373
|
+
function kt(t) {
|
|
374
|
+
return t.strict_status ? t.strict_status : t.kinks_points ? "strict_error" : t.tins_points.length === 2 ? "loose" : "strict";
|
|
375
|
+
}
|
|
376
|
+
function It(t) {
|
|
377
|
+
const e = {
|
|
378
|
+
forw: [t.vertices_params[0]],
|
|
379
|
+
bakw: [t.vertices_params[1]]
|
|
380
|
+
};
|
|
381
|
+
return e.forw[1] = H(t, !1), e.bakw[1] = H(t, !0), e;
|
|
317
382
|
}
|
|
318
|
-
function
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
383
|
+
function H(t, e) {
|
|
384
|
+
return [0, 1, 2, 3].map((r) => {
|
|
385
|
+
const n = (r + 1) % 4, c = $(
|
|
386
|
+
["c", `b${r}`, `b${n}`],
|
|
387
|
+
t.points,
|
|
388
|
+
t.edgeNodes || [],
|
|
389
|
+
t.centroid_point,
|
|
390
|
+
t.vertices_points,
|
|
391
|
+
e,
|
|
392
|
+
D
|
|
393
|
+
);
|
|
394
|
+
return F([c]);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function Tt(t) {
|
|
398
|
+
return {
|
|
399
|
+
forw: W(t.centroid_point[0], {
|
|
400
|
+
target: {
|
|
401
|
+
geom: t.centroid_point[1],
|
|
402
|
+
index: "c"
|
|
403
|
+
}
|
|
404
|
+
}),
|
|
405
|
+
bakw: W(t.centroid_point[1], {
|
|
406
|
+
target: {
|
|
407
|
+
geom: t.centroid_point[0],
|
|
408
|
+
index: "c"
|
|
409
|
+
}
|
|
410
|
+
})
|
|
323
411
|
};
|
|
324
|
-
|
|
325
|
-
|
|
412
|
+
}
|
|
413
|
+
function Nt(t) {
|
|
414
|
+
const e = t.tins_points.length === 1 ? 0 : 1;
|
|
415
|
+
return {
|
|
416
|
+
forw: F(
|
|
417
|
+
t.tins_points[0].map(
|
|
418
|
+
(r) => $(
|
|
419
|
+
r,
|
|
420
|
+
t.points,
|
|
421
|
+
t.edgeNodes || [],
|
|
422
|
+
t.centroid_point,
|
|
423
|
+
t.vertices_points,
|
|
424
|
+
!1,
|
|
425
|
+
t.version
|
|
426
|
+
)
|
|
427
|
+
)
|
|
428
|
+
),
|
|
429
|
+
bakw: F(
|
|
430
|
+
t.tins_points[e].map(
|
|
431
|
+
(r) => $(
|
|
432
|
+
r,
|
|
433
|
+
t.points,
|
|
434
|
+
t.edgeNodes || [],
|
|
435
|
+
t.centroid_point,
|
|
436
|
+
t.vertices_points,
|
|
437
|
+
!0,
|
|
438
|
+
t.version
|
|
439
|
+
)
|
|
440
|
+
)
|
|
441
|
+
)
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function Bt(t) {
|
|
445
|
+
if (t)
|
|
446
|
+
return {
|
|
447
|
+
bakw: F(
|
|
448
|
+
t.map((e) => W(e))
|
|
449
|
+
)
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function Ct(t) {
|
|
453
|
+
return JSON.parse(
|
|
454
|
+
JSON.stringify(t).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"')
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
function Rt(t) {
|
|
458
|
+
const e = [], r = t.forw.features;
|
|
459
|
+
for (let n = 0; n < r.length; n++) {
|
|
460
|
+
const c = r[n];
|
|
461
|
+
["a", "b", "c"].map((i, f) => {
|
|
462
|
+
const g = c.geometry.coordinates[0][f], h = c.properties[i].geom, l = c.properties[i].index;
|
|
463
|
+
typeof l == "number" && (e[l] = [g, h]);
|
|
464
|
+
});
|
|
465
|
+
}
|
|
326
466
|
return e;
|
|
327
467
|
}
|
|
328
|
-
const
|
|
468
|
+
const Wt = D, E = class E {
|
|
329
469
|
constructor() {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
470
|
+
x(this, "points", []);
|
|
471
|
+
x(this, "pointsWeightBuffer");
|
|
472
|
+
x(this, "strict_status");
|
|
473
|
+
x(this, "vertices_params");
|
|
474
|
+
x(this, "centroid");
|
|
475
|
+
x(this, "edgeNodes");
|
|
476
|
+
x(this, "edges");
|
|
477
|
+
x(this, "tins");
|
|
478
|
+
x(this, "kinks");
|
|
479
|
+
x(this, "yaxisMode", E.YAXIS_INVERT);
|
|
480
|
+
x(this, "strictMode", E.MODE_AUTO);
|
|
481
|
+
x(this, "vertexMode", E.VERTEX_PLAIN);
|
|
482
|
+
x(this, "bounds");
|
|
483
|
+
x(this, "boundsPolygon");
|
|
484
|
+
x(this, "wh");
|
|
485
|
+
x(this, "xy");
|
|
486
|
+
x(this, "indexedTins");
|
|
487
|
+
x(this, "stateFull", !1);
|
|
488
|
+
x(this, "stateTriangle");
|
|
489
|
+
x(this, "stateBackward");
|
|
490
|
+
/**
|
|
491
|
+
* Optional properties for MaplatCore extension
|
|
492
|
+
* These properties allow consuming applications to extend Transform instances
|
|
493
|
+
* with additional metadata without requiring Module Augmentation
|
|
494
|
+
*/
|
|
495
|
+
/** Layer priority for rendering order */
|
|
496
|
+
x(this, "priority");
|
|
497
|
+
/** Layer importance for display decisions */
|
|
498
|
+
x(this, "importance");
|
|
499
|
+
/** Bounds in XY (source) coordinate system */
|
|
500
|
+
x(this, "xyBounds");
|
|
501
|
+
/** Bounds in Mercator (Web Mercator) coordinate system */
|
|
502
|
+
x(this, "mercBounds");
|
|
350
503
|
}
|
|
351
504
|
/**
|
|
352
505
|
* コンパイルされた設定を適用します
|
|
@@ -360,100 +513,18 @@ const Q = 2.00703, O = class O {
|
|
|
360
513
|
* 3. TINネットワークの再構築
|
|
361
514
|
* 4. インデックスの作成
|
|
362
515
|
*/
|
|
363
|
-
setCompiled(
|
|
364
|
-
if (
|
|
365
|
-
this.
|
|
366
|
-
|
|
367
|
-
return n && (r[a] = Object.keys(n).reduce((c, d) => {
|
|
368
|
-
const g = et(d);
|
|
369
|
-
return c[g] = n[d], c;
|
|
370
|
-
}, {})), r;
|
|
371
|
-
}, {}) : t.weight_buffer, t.strict_status ? this.strict_status = t.strict_status : t.kinks_points ? this.strict_status = O.STATUS_ERROR : t.tins_points.length == 2 ? this.strict_status = O.STATUS_LOOSE : this.strict_status = O.STATUS_STRICT, this.vertices_params = {
|
|
372
|
-
forw: [t.vertices_params[0]],
|
|
373
|
-
bakw: [t.vertices_params[1]]
|
|
374
|
-
}, this.vertices_params.forw[1] = [0, 1, 2, 3].map((r) => {
|
|
375
|
-
const a = (r + 1) % 4, n = W(
|
|
376
|
-
["c", `b${r}`, `b${a}`],
|
|
377
|
-
t.points,
|
|
378
|
-
t.edgeNodes || [],
|
|
379
|
-
t.centroid_point,
|
|
380
|
-
t.vertices_points,
|
|
381
|
-
!1,
|
|
382
|
-
Q
|
|
383
|
-
);
|
|
384
|
-
return B([n]);
|
|
385
|
-
}), this.vertices_params.bakw[1] = [0, 1, 2, 3].map((r) => {
|
|
386
|
-
const a = (r + 1) % 4, n = W(
|
|
387
|
-
["c", `b${r}`, `b${a}`],
|
|
388
|
-
t.points,
|
|
389
|
-
t.edgeNodes || [],
|
|
390
|
-
t.centroid_point,
|
|
391
|
-
t.vertices_points,
|
|
392
|
-
!0,
|
|
393
|
-
Q
|
|
394
|
-
);
|
|
395
|
-
return B([n]);
|
|
396
|
-
}), this.centroid = {
|
|
397
|
-
forw: Y(t.centroid_point[0], {
|
|
398
|
-
target: {
|
|
399
|
-
geom: t.centroid_point[1],
|
|
400
|
-
index: "c"
|
|
401
|
-
}
|
|
402
|
-
}),
|
|
403
|
-
bakw: Y(t.centroid_point[1], {
|
|
404
|
-
target: {
|
|
405
|
-
geom: t.centroid_point[0],
|
|
406
|
-
index: "c"
|
|
407
|
-
}
|
|
408
|
-
})
|
|
409
|
-
}, this.edges = At(t.edges || []), this.edgeNodes = t.edgeNodes || [];
|
|
410
|
-
const s = t.tins_points.length == 1 ? 0 : 1;
|
|
411
|
-
this.tins = {
|
|
412
|
-
forw: B(
|
|
413
|
-
t.tins_points[0].map(
|
|
414
|
-
(r) => W(
|
|
415
|
-
r,
|
|
416
|
-
t.points,
|
|
417
|
-
t.edgeNodes || [],
|
|
418
|
-
t.centroid_point,
|
|
419
|
-
t.vertices_points,
|
|
420
|
-
!1,
|
|
421
|
-
t.version
|
|
422
|
-
)
|
|
423
|
-
)
|
|
424
|
-
),
|
|
425
|
-
bakw: B(
|
|
426
|
-
t.tins_points[s].map(
|
|
427
|
-
(r) => W(
|
|
428
|
-
r,
|
|
429
|
-
t.points,
|
|
430
|
-
t.edgeNodes || [],
|
|
431
|
-
t.centroid_point,
|
|
432
|
-
t.vertices_points,
|
|
433
|
-
!0,
|
|
434
|
-
t.version
|
|
435
|
-
)
|
|
436
|
-
)
|
|
437
|
-
)
|
|
438
|
-
}, this.addIndexedTin(), t.kinks_points && (this.kinks = {
|
|
439
|
-
bakw: B(
|
|
440
|
-
t.kinks_points.map((r) => Y(r))
|
|
441
|
-
)
|
|
442
|
-
}), t.yaxisMode ? this.yaxisMode = t.yaxisMode : this.yaxisMode = O.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);
|
|
443
|
-
} else {
|
|
444
|
-
t = JSON.parse(
|
|
445
|
-
JSON.stringify(t).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"')
|
|
446
|
-
), 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;
|
|
447
|
-
const s = [];
|
|
448
|
-
for (let r = 0; r < this.tins.forw.features.length; r++) {
|
|
449
|
-
const a = this.tins.forw.features[r];
|
|
450
|
-
["a", "b", "c"].map((n, c) => {
|
|
451
|
-
const d = a.geometry.coordinates[0][c], g = a.properties[n].geom, l = a.properties[n].index;
|
|
452
|
-
typeof l == "number" && (s[l] = [d, g]);
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
this.points = s;
|
|
516
|
+
setCompiled(e) {
|
|
517
|
+
if (Et(e)) {
|
|
518
|
+
this.applyModernState(Pt(e));
|
|
519
|
+
return;
|
|
456
520
|
}
|
|
521
|
+
this.applyLegacyState(Ot(e));
|
|
522
|
+
}
|
|
523
|
+
applyModernState(e) {
|
|
524
|
+
this.points = e.points, this.pointsWeightBuffer = e.pointsWeightBuffer, this.strict_status = e.strictStatus, this.vertices_params = e.verticesParams, this.centroid = e.centroid, this.edges = e.edges, this.edgeNodes = e.edgeNodes || [], this.tins = e.tins, this.addIndexedTin(), this.kinks = e.kinks, this.yaxisMode = e.yaxisMode ?? E.YAXIS_INVERT, this.vertexMode = e.vertexMode ?? E.VERTEX_PLAIN, this.strictMode = e.strictMode ?? E.MODE_AUTO, e.bounds ? (this.bounds = e.bounds, this.boundsPolygon = e.boundsPolygon, this.xy = e.xy, this.wh = e.wh) : (this.bounds = void 0, this.boundsPolygon = void 0, this.xy = e.xy ?? [0, 0], e.wh && (this.wh = e.wh));
|
|
525
|
+
}
|
|
526
|
+
applyLegacyState(e) {
|
|
527
|
+
this.tins = e.tins, this.addIndexedTin(), this.strict_status = e.strictStatus, this.pointsWeightBuffer = e.pointsWeightBuffer, this.vertices_params = e.verticesParams, this.centroid = e.centroid, this.kinks = e.kinks, this.points = e.points;
|
|
457
528
|
}
|
|
458
529
|
/**
|
|
459
530
|
* TINネットワークのインデックスを作成します
|
|
@@ -463,101 +534,101 @@ const Q = 2.00703, O = class O {
|
|
|
463
534
|
* 含まれる三角形を記録します。
|
|
464
535
|
*/
|
|
465
536
|
addIndexedTin() {
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
537
|
+
const e = this.tins, r = e.forw, n = e.bakw, c = Math.ceil(Math.sqrt(r.features.length));
|
|
538
|
+
if (c < 3) {
|
|
468
539
|
this.indexedTins = void 0;
|
|
469
540
|
return;
|
|
470
541
|
}
|
|
471
|
-
let
|
|
472
|
-
const
|
|
473
|
-
let
|
|
474
|
-
return
|
|
475
|
-
|
|
476
|
-
}),
|
|
477
|
-
}),
|
|
478
|
-
(
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
),
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
),
|
|
490
|
-
|
|
491
|
-
|
|
542
|
+
let i = [], f = [];
|
|
543
|
+
const g = r.features.map((d) => {
|
|
544
|
+
let a = [];
|
|
545
|
+
return z(d)[0].map((s) => {
|
|
546
|
+
i.length === 0 ? i = [Array.from(s), Array.from(s)] : (s[0] < i[0][0] && (i[0][0] = s[0]), s[0] > i[1][0] && (i[1][0] = s[0]), s[1] < i[0][1] && (i[0][1] = s[1]), s[1] > i[1][1] && (i[1][1] = s[1])), a.length === 0 ? a = [Array.from(s), Array.from(s)] : (s[0] < a[0][0] && (a[0][0] = s[0]), s[0] > a[1][0] && (a[1][0] = s[0]), s[1] < a[0][1] && (a[0][1] = s[1]), s[1] > a[1][1] && (a[1][1] = s[1]));
|
|
547
|
+
}), a;
|
|
548
|
+
}), h = (i[1][0] - i[0][0]) / c, l = (i[1][1] - i[0][1]) / c, y = g.reduce(
|
|
549
|
+
(d, a, s) => {
|
|
550
|
+
const m = B(
|
|
551
|
+
a[0][0],
|
|
552
|
+
i[0][0],
|
|
553
|
+
h,
|
|
554
|
+
c
|
|
555
|
+
), v = B(
|
|
556
|
+
a[1][0],
|
|
557
|
+
i[0][0],
|
|
558
|
+
h,
|
|
559
|
+
c
|
|
560
|
+
), M = B(
|
|
561
|
+
a[0][1],
|
|
562
|
+
i[0][1],
|
|
492
563
|
l,
|
|
493
|
-
|
|
494
|
-
),
|
|
495
|
-
|
|
496
|
-
|
|
564
|
+
c
|
|
565
|
+
), _ = B(
|
|
566
|
+
a[1][1],
|
|
567
|
+
i[0][1],
|
|
497
568
|
l,
|
|
498
|
-
|
|
569
|
+
c
|
|
499
570
|
);
|
|
500
|
-
for (let
|
|
501
|
-
|
|
502
|
-
for (let
|
|
503
|
-
|
|
571
|
+
for (let w = m; w <= v; w++) {
|
|
572
|
+
d[w] || (d[w] = []);
|
|
573
|
+
for (let A = M; A <= _; A++)
|
|
574
|
+
d[w][A] || (d[w][A] = []), d[w][A].push(s);
|
|
504
575
|
}
|
|
505
|
-
return
|
|
576
|
+
return d;
|
|
506
577
|
},
|
|
507
578
|
[]
|
|
508
|
-
), o =
|
|
509
|
-
let
|
|
510
|
-
return
|
|
511
|
-
|
|
512
|
-
}),
|
|
513
|
-
}), u = (
|
|
514
|
-
(
|
|
515
|
-
const
|
|
579
|
+
), o = n.features.map((d) => {
|
|
580
|
+
let a = [];
|
|
581
|
+
return z(d)[0].map((s) => {
|
|
582
|
+
f.length === 0 ? f = [Array.from(s), Array.from(s)] : (s[0] < f[0][0] && (f[0][0] = s[0]), s[0] > f[1][0] && (f[1][0] = s[0]), s[1] < f[0][1] && (f[0][1] = s[1]), s[1] > f[1][1] && (f[1][1] = s[1])), a.length === 0 ? a = [Array.from(s), Array.from(s)] : (s[0] < a[0][0] && (a[0][0] = s[0]), s[0] > a[1][0] && (a[1][0] = s[0]), s[1] < a[0][1] && (a[0][1] = s[1]), s[1] > a[1][1] && (a[1][1] = s[1]));
|
|
583
|
+
}), a;
|
|
584
|
+
}), u = (f[1][0] - f[0][0]) / c, b = (f[1][1] - f[0][1]) / c, p = o.reduce(
|
|
585
|
+
(d, a, s) => {
|
|
586
|
+
const m = B(
|
|
587
|
+
a[0][0],
|
|
516
588
|
f[0][0],
|
|
517
|
-
c[0][0],
|
|
518
589
|
u,
|
|
519
|
-
|
|
520
|
-
),
|
|
521
|
-
|
|
522
|
-
|
|
590
|
+
c
|
|
591
|
+
), v = B(
|
|
592
|
+
a[1][0],
|
|
593
|
+
f[0][0],
|
|
523
594
|
u,
|
|
524
|
-
|
|
525
|
-
),
|
|
595
|
+
c
|
|
596
|
+
), M = B(
|
|
597
|
+
a[0][1],
|
|
526
598
|
f[0][1],
|
|
527
|
-
c[0][1],
|
|
528
599
|
b,
|
|
529
|
-
|
|
530
|
-
),
|
|
531
|
-
|
|
532
|
-
|
|
600
|
+
c
|
|
601
|
+
), _ = B(
|
|
602
|
+
a[1][1],
|
|
603
|
+
f[0][1],
|
|
533
604
|
b,
|
|
534
|
-
|
|
605
|
+
c
|
|
535
606
|
);
|
|
536
|
-
for (let
|
|
537
|
-
|
|
538
|
-
for (let
|
|
539
|
-
|
|
607
|
+
for (let w = m; w <= v; w++) {
|
|
608
|
+
d[w] || (d[w] = []);
|
|
609
|
+
for (let A = M; A <= _; A++)
|
|
610
|
+
d[w][A] || (d[w][A] = []), d[w][A].push(s);
|
|
540
611
|
}
|
|
541
|
-
return
|
|
612
|
+
return d;
|
|
542
613
|
},
|
|
543
614
|
[]
|
|
544
615
|
);
|
|
545
616
|
this.indexedTins = {
|
|
546
617
|
forw: {
|
|
547
|
-
gridNum:
|
|
548
|
-
xOrigin:
|
|
549
|
-
yOrigin:
|
|
550
|
-
xUnit:
|
|
618
|
+
gridNum: c,
|
|
619
|
+
xOrigin: i[0][0],
|
|
620
|
+
yOrigin: i[0][1],
|
|
621
|
+
xUnit: h,
|
|
551
622
|
yUnit: l,
|
|
552
623
|
gridCache: y
|
|
553
624
|
},
|
|
554
625
|
bakw: {
|
|
555
|
-
gridNum:
|
|
556
|
-
xOrigin:
|
|
557
|
-
yOrigin:
|
|
626
|
+
gridNum: c,
|
|
627
|
+
xOrigin: f[0][0],
|
|
628
|
+
yOrigin: f[0][1],
|
|
558
629
|
xUnit: u,
|
|
559
630
|
yUnit: b,
|
|
560
|
-
gridCache:
|
|
631
|
+
gridCache: p
|
|
561
632
|
}
|
|
562
633
|
};
|
|
563
634
|
}
|
|
@@ -571,32 +642,32 @@ const Q = 2.00703, O = class O {
|
|
|
571
642
|
*
|
|
572
643
|
* @throws {Error} 逆方向変換が許可されていない状態での逆変換時
|
|
573
644
|
*/
|
|
574
|
-
transform(
|
|
575
|
-
if (
|
|
645
|
+
transform(e, r, n) {
|
|
646
|
+
if (r && this.strict_status == E.STATUS_ERROR)
|
|
576
647
|
throw 'Backward transform is not allowed if strict_status == "strict_error"';
|
|
577
|
-
this.yaxisMode ==
|
|
578
|
-
const
|
|
579
|
-
if (this.bounds && !
|
|
648
|
+
this.yaxisMode == E.YAXIS_FOLLOW && r && (e = [e[0], -1 * e[1]]);
|
|
649
|
+
const c = W(e);
|
|
650
|
+
if (this.bounds && !r && !n && !L(c, this.boundsPolygon))
|
|
580
651
|
return !1;
|
|
581
|
-
const
|
|
652
|
+
const i = r ? this.tins.bakw : this.tins.forw, f = r ? this.indexedTins.bakw : this.indexedTins.forw, g = r ? this.vertices_params.bakw : this.vertices_params.forw, h = r ? this.centroid.bakw : this.centroid.forw, l = r ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
|
|
582
653
|
let y, o;
|
|
583
|
-
this.stateFull && (this.stateBackward ==
|
|
654
|
+
this.stateFull && (this.stateBackward == r ? y = this.stateTriangle : (this.stateBackward = r, this.stateTriangle = void 0), o = (b) => {
|
|
584
655
|
this.stateTriangle = b;
|
|
585
656
|
});
|
|
586
|
-
let u =
|
|
587
|
-
a,
|
|
588
|
-
n,
|
|
657
|
+
let u = vt(
|
|
589
658
|
c,
|
|
590
|
-
|
|
659
|
+
i,
|
|
660
|
+
f,
|
|
591
661
|
g,
|
|
662
|
+
h,
|
|
592
663
|
l,
|
|
593
664
|
y,
|
|
594
665
|
o
|
|
595
666
|
);
|
|
596
|
-
if (this.bounds &&
|
|
597
|
-
const b =
|
|
598
|
-
if (!
|
|
599
|
-
} else this.yaxisMode ==
|
|
667
|
+
if (this.bounds && r && !n) {
|
|
668
|
+
const b = W(u);
|
|
669
|
+
if (!L(b, this.boundsPolygon)) return !1;
|
|
670
|
+
} else this.yaxisMode == E.YAXIS_FOLLOW && !r && (u = [u[0], -1 * u[1]]);
|
|
600
671
|
return u;
|
|
601
672
|
}
|
|
602
673
|
};
|
|
@@ -604,13 +675,13 @@ const Q = 2.00703, O = class O {
|
|
|
604
675
|
* 各種モードの定数定義
|
|
605
676
|
* すべてreadonlyで、型安全性を確保
|
|
606
677
|
*/
|
|
607
|
-
|
|
608
|
-
let
|
|
678
|
+
x(E, "VERTEX_PLAIN", "plain"), x(E, "VERTEX_BIRDEYE", "birdeye"), x(E, "MODE_STRICT", "strict"), x(E, "MODE_AUTO", "auto"), x(E, "MODE_LOOSE", "loose"), x(E, "STATUS_STRICT", "strict"), x(E, "STATUS_ERROR", "strict_error"), x(E, "STATUS_LOOSE", "loose"), x(E, "YAXIS_FOLLOW", "follow"), x(E, "YAXIS_INVERT", "invert");
|
|
679
|
+
let Z = E;
|
|
609
680
|
export {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
681
|
+
Z as Transform,
|
|
682
|
+
Xt as counterTri,
|
|
683
|
+
Wt as format_version,
|
|
613
684
|
At as normalizeEdges,
|
|
614
|
-
|
|
615
|
-
|
|
685
|
+
Ft as rotateVerticesTriangle,
|
|
686
|
+
vt as transformArr
|
|
616
687
|
};
|