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