@maplat/transform 0.4.1 → 0.5.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 +178 -170
- package/README.md +179 -171
- package/dist/index.d.ts +1 -1
- package/dist/maplat_transform.js +130 -135
- package/dist/maplat_transform.umd.js +1 -1
- package/package.json +1 -1
- package/src/compiled-state.ts +213 -211
- package/src/edgeutils.ts +47 -47
- package/src/geometry.ts +240 -247
- package/src/index.ts +400 -398
- package/src/triangulation.ts +170 -179
- package/src/types.ts +122 -122
package/dist/maplat_transform.js
CHANGED
|
@@ -5,14 +5,14 @@ function tt(t, e, r = {}) {
|
|
|
5
5
|
const n = { type: "Feature" };
|
|
6
6
|
return (r.id === 0 || r.id) && (n.id = r.id), r.bbox && (n.bbox = r.bbox), n.properties = e || {}, n.geometry = t, n;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function X(t, e, r = {}) {
|
|
9
9
|
if (!t)
|
|
10
10
|
throw new Error("coordinates is required");
|
|
11
11
|
if (!Array.isArray(t))
|
|
12
12
|
throw new Error("coordinates must be an Array");
|
|
13
13
|
if (t.length < 2)
|
|
14
14
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
15
|
-
if (!
|
|
15
|
+
if (!z(t[0]) || !z(t[1]))
|
|
16
16
|
throw new Error("coordinates must contain numbers");
|
|
17
17
|
return tt({
|
|
18
18
|
type: "Point",
|
|
@@ -40,7 +40,7 @@ function F(t, e = {}) {
|
|
|
40
40
|
const r = { type: "FeatureCollection" };
|
|
41
41
|
return e.id && (r.id = e.id), e.bbox && (r.bbox = e.bbox), r.features = t, r;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function z(t) {
|
|
44
44
|
return !isNaN(t) && t !== null && !Array.isArray(t);
|
|
45
45
|
}
|
|
46
46
|
function ut(t) {
|
|
@@ -56,7 +56,7 @@ function ut(t) {
|
|
|
56
56
|
return [...t];
|
|
57
57
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function G(t) {
|
|
60
60
|
if (Array.isArray(t))
|
|
61
61
|
return t;
|
|
62
62
|
if (t.type === "Feature") {
|
|
@@ -71,18 +71,18 @@ function z(t) {
|
|
|
71
71
|
function ft(t) {
|
|
72
72
|
return t.type === "Feature" ? t.geometry : t;
|
|
73
73
|
}
|
|
74
|
-
const R = 11102230246251565e-32,
|
|
74
|
+
const R = 11102230246251565e-32, P = 134217729, dt = (3 + 8 * R) * R;
|
|
75
75
|
function V(t, e, r, n, c) {
|
|
76
|
-
let i,
|
|
77
|
-
y > l == y > -l ? (i = l, l = e[++o]) : (i = y, y = n[++
|
|
76
|
+
let i, u, g, h, l = e[0], y = n[0], o = 0, f = 0;
|
|
77
|
+
y > l == y > -l ? (i = l, l = e[++o]) : (i = y, y = n[++f]);
|
|
78
78
|
let b = 0;
|
|
79
|
-
if (o < t &&
|
|
80
|
-
for (y > l == y > -l ? (
|
|
81
|
-
y > l == y > -l ? (
|
|
79
|
+
if (o < t && f < r)
|
|
80
|
+
for (y > l == y > -l ? (u = l + i, g = i - (u - l), l = e[++o]) : (u = y + i, g = i - (u - y), y = n[++f]), i = u, g !== 0 && (c[b++] = g); o < t && f < r; )
|
|
81
|
+
y > l == y > -l ? (u = i + l, h = u - i, g = i - (u - h) + (l - h), l = e[++o]) : (u = i + y, h = u - i, g = i - (u - h) + (y - h), y = n[++f]), i = u, g !== 0 && (c[b++] = g);
|
|
82
82
|
for (; o < t; )
|
|
83
|
-
|
|
84
|
-
for (;
|
|
85
|
-
|
|
83
|
+
u = i + l, h = u - i, g = i - (u - h) + (l - h), l = e[++o], i = u, g !== 0 && (c[b++] = g);
|
|
84
|
+
for (; f < r; )
|
|
85
|
+
u = i + y, h = u - i, g = i - (u - h) + (y - h), y = n[++f], i = u, g !== 0 && (c[b++] = g);
|
|
86
86
|
return (i !== 0 || b === 0) && (c[b++] = i), b;
|
|
87
87
|
}
|
|
88
88
|
function ht(t, e) {
|
|
@@ -93,54 +93,54 @@ function ht(t, e) {
|
|
|
93
93
|
function Y(t) {
|
|
94
94
|
return new Float64Array(t);
|
|
95
95
|
}
|
|
96
|
-
const gt = (3 + 16 * R) * R, lt = (2 + 12 * R) * R, yt = (9 + 64 * R) * R * R, U = Y(4),
|
|
97
|
-
function bt(t, e, r, n, c, i,
|
|
98
|
-
let g, h, l, y, o,
|
|
99
|
-
const k = t - c,
|
|
100
|
-
|
|
101
|
-
let C = ht(4, U),
|
|
102
|
-
if (C >=
|
|
103
|
-
|
|
104
|
-
const it = V(4, U, 4, S,
|
|
105
|
-
|
|
106
|
-
const st = V(it,
|
|
107
|
-
|
|
108
|
-
const ot = V(st,
|
|
109
|
-
return
|
|
96
|
+
const gt = (3 + 16 * R) * R, lt = (2 + 12 * R) * R, yt = (9 + 64 * R) * R * R, U = Y(4), j = Y(8), J = Y(12), K = Y(16), S = Y(4);
|
|
97
|
+
function bt(t, e, r, n, c, i, u) {
|
|
98
|
+
let g, h, l, y, o, f, b, p, d, a, s, m, M, v, _, w, A, O;
|
|
99
|
+
const k = t - c, T = r - c, I = e - i, N = n - i;
|
|
100
|
+
v = k * N, f = P * k, b = f - (f - k), p = k - b, f = P * N, d = f - (f - N), a = N - d, _ = p * a - (v - b * d - p * d - b * a), w = I * T, f = P * I, b = f - (f - I), p = I - b, f = P * T, d = f - (f - T), a = T - d, A = p * a - (w - b * d - p * d - b * a), s = _ - A, o = _ - s, U[0] = _ - (s + o) + (o - A), m = v + s, o = m - v, M = v - (m - o) + (s - o), s = M - w, o = M - s, U[1] = M - (s + o) + (o - w), O = m + s, o = O - m, U[2] = m - (O - o) + (s - o), U[3] = O;
|
|
101
|
+
let C = ht(4, U), W = lt * u;
|
|
102
|
+
if (C >= W || -C >= W || (o = t - k, g = t - (k + o) + (o - c), o = r - T, l = r - (T + o) + (o - c), o = e - I, h = e - (I + o) + (o - i), o = n - N, y = n - (N + o) + (o - i), g === 0 && h === 0 && l === 0 && y === 0) || (W = yt * u + dt * Math.abs(C), C += k * y + N * g - (I * l + T * h), C >= W || -C >= W)) return C;
|
|
103
|
+
v = g * N, f = P * g, b = f - (f - g), p = g - b, f = P * N, d = f - (f - N), a = N - d, _ = p * a - (v - b * d - p * d - b * a), w = h * T, f = P * h, b = f - (f - h), p = h - b, f = P * T, d = f - (f - T), a = T - d, A = p * a - (w - b * d - p * d - b * a), s = _ - A, o = _ - s, S[0] = _ - (s + o) + (o - A), m = v + s, o = m - v, M = v - (m - o) + (s - o), s = M - w, o = M - s, S[1] = M - (s + o) + (o - w), O = m + s, o = O - m, S[2] = m - (O - o) + (s - o), S[3] = O;
|
|
104
|
+
const it = V(4, U, 4, S, j);
|
|
105
|
+
v = k * y, f = P * k, b = f - (f - k), p = k - b, f = P * y, d = f - (f - y), a = y - d, _ = p * a - (v - b * d - p * d - b * a), w = I * l, f = P * I, b = f - (f - I), p = I - b, f = P * l, d = f - (f - 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 = v + s, o = m - v, M = v - (m - o) + (s - o), s = M - w, o = M - s, S[1] = M - (s + o) + (o - w), O = m + s, o = O - m, S[2] = m - (O - o) + (s - o), S[3] = O;
|
|
106
|
+
const st = V(it, j, 4, S, J);
|
|
107
|
+
v = g * y, f = P * g, b = f - (f - g), p = g - b, f = P * y, d = f - (f - y), a = y - d, _ = p * a - (v - b * d - p * d - b * a), w = h * l, f = P * h, b = f - (f - h), p = h - b, f = P * l, d = f - (f - 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 = v + s, o = m - v, M = v - (m - o) + (s - o), s = M - w, o = M - s, S[1] = M - (s + o) + (o - w), O = m + s, o = O - m, S[2] = m - (O - o) + (s - o), S[3] = O;
|
|
108
|
+
const ot = V(st, J, 4, S, K);
|
|
109
|
+
return K[ot - 1];
|
|
110
110
|
}
|
|
111
111
|
function mt(t, e, r, n, c, i) {
|
|
112
|
-
const
|
|
112
|
+
const u = (e - i) * (r - c), g = (t - c) * (n - i), h = u - g, l = Math.abs(u + g);
|
|
113
113
|
return Math.abs(h) >= gt * l ? h : -bt(t, e, r, n, c, i, l);
|
|
114
114
|
}
|
|
115
115
|
function wt(t, e) {
|
|
116
|
-
var r, n, c = 0, i,
|
|
116
|
+
var r, n, c = 0, i, u, g, h, l, y, o, f = t[0], b = t[1], p = e.length;
|
|
117
117
|
for (r = 0; r < p; r++) {
|
|
118
118
|
n = 0;
|
|
119
119
|
var d = e[r], a = d.length - 1;
|
|
120
120
|
if (y = d[0], y[0] !== d[a][0] && y[1] !== d[a][1])
|
|
121
121
|
throw new Error("First and last coordinates in a ring must be the same");
|
|
122
|
-
for (
|
|
123
|
-
if (o = d[n + 1], h = o[0] -
|
|
124
|
-
if (h <= 0 &&
|
|
122
|
+
for (u = y[0] - f, g = y[1] - b, n; n < a; n++) {
|
|
123
|
+
if (o = d[n + 1], h = o[0] - f, l = o[1] - b, g === 0 && l === 0) {
|
|
124
|
+
if (h <= 0 && u >= 0 || u <= 0 && h >= 0)
|
|
125
125
|
return 0;
|
|
126
126
|
} else if (l >= 0 && g <= 0 || l <= 0 && g >= 0) {
|
|
127
|
-
if (i = mt(
|
|
127
|
+
if (i = mt(u, h, g, l, 0, 0), i === 0)
|
|
128
128
|
return 0;
|
|
129
129
|
(i > 0 && l > 0 && g <= 0 || i < 0 && l <= 0 && g > 0) && c++;
|
|
130
130
|
}
|
|
131
|
-
y = o, g = l,
|
|
131
|
+
y = o, g = l, u = h;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
return c % 2 !== 0;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function $(t, e, r = {}) {
|
|
137
137
|
if (!t)
|
|
138
138
|
throw new Error("point is required");
|
|
139
139
|
if (!e)
|
|
140
140
|
throw new Error("polygon is required");
|
|
141
|
-
const n = ut(t), c = ft(e), i = c.type,
|
|
141
|
+
const n = ut(t), c = ft(e), i = c.type, u = e.bbox;
|
|
142
142
|
let g = c.coordinates;
|
|
143
|
-
if (
|
|
143
|
+
if (u && xt(n, u) === !1)
|
|
144
144
|
return !1;
|
|
145
145
|
i === "Polygon" && (g = [g]);
|
|
146
146
|
let h = !1;
|
|
@@ -154,23 +154,23 @@ function L(t, e, r = {}) {
|
|
|
154
154
|
function xt(t, e) {
|
|
155
155
|
return e[0] <= t[0] && e[1] <= t[1] && e[2] >= t[0] && e[3] >= t[1];
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function L(t, e) {
|
|
158
158
|
for (let r = 0; r < e.features.length; r++)
|
|
159
|
-
if (
|
|
159
|
+
if ($(t, e.features[r]))
|
|
160
160
|
return e.features[r];
|
|
161
161
|
}
|
|
162
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],
|
|
164
|
-
let d = (o[1] *
|
|
163
|
+
const n = e.geometry.coordinates[0][0], c = e.geometry.coordinates[0][1], i = e.geometry.coordinates[0][2], u = 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]], f = [u[0] - n[0], u[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] * f[0] - o[0] * f[1]) / (y[0] * o[1] - y[1] * o[0]), a = (y[0] * f[1] - y[1] * f[0]) / (y[0] * o[1] - y[1] * o[0]);
|
|
165
165
|
if (r) {
|
|
166
|
-
const s = r[e.properties.a.index], m = r[e.properties.b.index],
|
|
167
|
-
let
|
|
166
|
+
const s = r[e.properties.a.index], m = r[e.properties.b.index], M = r[e.properties.c.index];
|
|
167
|
+
let v;
|
|
168
168
|
if (d < 0 || a < 0 || 1 - d - a < 0) {
|
|
169
169
|
const _ = d / (d + a), w = a / (d + a);
|
|
170
|
-
|
|
170
|
+
v = d / m / (_ / m + w / M), a = a / M / (_ / m + w / M);
|
|
171
171
|
} else
|
|
172
|
-
|
|
173
|
-
d =
|
|
172
|
+
v = d / m / (d / m + a / M + (1 - d - a) / s), a = a / M / (d / m + a / M + (1 - d - a) / s);
|
|
173
|
+
d = v;
|
|
174
174
|
}
|
|
175
175
|
return [
|
|
176
176
|
d * b[0] + a * p[0] + g[0],
|
|
@@ -178,44 +178,37 @@ function rt(t, e, r) {
|
|
|
178
178
|
];
|
|
179
179
|
}
|
|
180
180
|
function pt(t, e, r, n) {
|
|
181
|
-
const c = t.geometry.coordinates, i = r.geometry.coordinates,
|
|
181
|
+
const c = t.geometry.coordinates, i = r.geometry.coordinates, u = Math.atan2(c[0] - i[0], c[1] - i[1]), g = Mt(u, e[0]);
|
|
182
182
|
if (g === void 0)
|
|
183
183
|
throw new Error("Unable to determine vertex index");
|
|
184
184
|
const h = e[1][g];
|
|
185
185
|
return rt(t, h.features[0], n);
|
|
186
186
|
}
|
|
187
|
-
function vt(t, e, r, n, c, i,
|
|
187
|
+
function vt(t, e, r, n, c, i, u, g) {
|
|
188
188
|
let h;
|
|
189
|
-
if (
|
|
189
|
+
if (u && (h = L(t, F([u]))), !h)
|
|
190
190
|
if (r) {
|
|
191
|
-
const l = t.geometry.coordinates, y = r.gridNum, o = r.xOrigin,
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
}
|
|
191
|
+
const l = t.geometry.coordinates, y = r.gridNum, o = r.xOrigin, f = r.yOrigin, b = r.xUnit, p = r.yUnit, d = r.gridCache, a = B(l[0], o, b, y), s = B(l[1], f, p, y), m = d[a] ? d[a][s] ? d[a][s] : [] : [], M = F(m.map((v) => e.features[v]));
|
|
192
|
+
h = L(t, M);
|
|
193
|
+
} else
|
|
194
|
+
h = L(t, e);
|
|
196
195
|
return g && g(h), h ? rt(t, h, i) : pt(t, n, c, i);
|
|
197
196
|
}
|
|
198
197
|
function B(t, e, r, n) {
|
|
199
198
|
let c = Math.floor((t - e) / r);
|
|
200
|
-
return c >= n && (c = n - 1), c;
|
|
199
|
+
return c < 0 && (c = 0), c >= n && (c = n - 1), c;
|
|
201
200
|
}
|
|
202
201
|
function Mt(t, e) {
|
|
203
202
|
let r = Q(t - e[0]), n = Math.PI * 2, c;
|
|
204
203
|
for (let i = 0; i < e.length; i++) {
|
|
205
|
-
const
|
|
204
|
+
const u = (i + 1) % e.length, g = Q(t - e[u]), h = Math.min(Math.abs(r), Math.abs(g));
|
|
206
205
|
r * g <= 0 && h < n && (n = h, c = i), r = g;
|
|
207
206
|
}
|
|
208
207
|
return c;
|
|
209
208
|
}
|
|
210
209
|
function Q(t, e = !1) {
|
|
211
|
-
const r =
|
|
212
|
-
|
|
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;
|
|
210
|
+
const r = 2 * Math.PI, n = t - Math.floor(t / r) * r;
|
|
211
|
+
return e ? n : n > Math.PI ? n - r : n;
|
|
219
212
|
}
|
|
220
213
|
function At(t, e) {
|
|
221
214
|
return e && e >= 2.00703 || Array.isArray(t[0]) ? t : t.map((r) => [
|
|
@@ -286,7 +279,7 @@ function Ft(t) {
|
|
|
286
279
|
}
|
|
287
280
|
return t;
|
|
288
281
|
}
|
|
289
|
-
function
|
|
282
|
+
function Wt(t) {
|
|
290
283
|
const e = ["a", "b", "c", "a"].map(
|
|
291
284
|
(i) => t.properties[i].geom
|
|
292
285
|
), r = t.geometry.coordinates[0], n = t.properties, c = {
|
|
@@ -304,17 +297,16 @@ function _t(t) {
|
|
|
304
297
|
};
|
|
305
298
|
return et([e], r);
|
|
306
299
|
}
|
|
307
|
-
function
|
|
300
|
+
function D(t, e, r, n, c, i = !1, u) {
|
|
308
301
|
const g = t.map(
|
|
309
302
|
(h) => {
|
|
310
|
-
(!
|
|
311
|
-
const l = isFinite(h) ? e[h] : h === "c" ? n :
|
|
312
|
-
const y = h.match(
|
|
313
|
-
if (y)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
throw "Bad index value for indexesToTri";
|
|
303
|
+
(!u || u < 2.00703) && (h = nt(h));
|
|
304
|
+
const l = isFinite(h) ? e[h] : h === "c" ? n : (function() {
|
|
305
|
+
const y = h.match(/^b(\d+)$/);
|
|
306
|
+
if (y) return c[parseInt(y[1])];
|
|
307
|
+
const o = h.match(/^e(\d+)$/);
|
|
308
|
+
if (o) return r[parseInt(o[1])];
|
|
309
|
+
throw new Error("Bad index value for indexesToTri");
|
|
318
310
|
})();
|
|
319
311
|
return i ? [[l[1], l[0]], h] : [[l[0], l[1]], h];
|
|
320
312
|
}
|
|
@@ -324,17 +316,17 @@ function $(t, e, r, n, c, i = !1, f) {
|
|
|
324
316
|
function nt(t) {
|
|
325
317
|
return typeof t == "number" ? t : t.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
|
|
326
318
|
}
|
|
327
|
-
const
|
|
319
|
+
const q = 2.00703;
|
|
328
320
|
function Et(t) {
|
|
329
|
-
return !!(t.version || !t.tins && t.points && t.tins_points);
|
|
321
|
+
return !!(t.version !== void 0 || !t.tins && t.points && t.tins_points);
|
|
330
322
|
}
|
|
331
|
-
function
|
|
323
|
+
function Ot(t) {
|
|
332
324
|
return {
|
|
333
325
|
points: t.points,
|
|
334
326
|
pointsWeightBuffer: St(t),
|
|
335
327
|
strictStatus: kt(t),
|
|
336
|
-
verticesParams:
|
|
337
|
-
centroid:
|
|
328
|
+
verticesParams: Tt(t),
|
|
329
|
+
centroid: It(t),
|
|
338
330
|
edges: At(t.edges || []),
|
|
339
331
|
edgeNodes: t.edgeNodes || [],
|
|
340
332
|
tins: Nt(t),
|
|
@@ -345,10 +337,10 @@ function Pt(t) {
|
|
|
345
337
|
bounds: t.bounds,
|
|
346
338
|
boundsPolygon: t.boundsPolygon,
|
|
347
339
|
wh: t.wh,
|
|
348
|
-
xy: t.
|
|
340
|
+
xy: t.xy ?? [0, 0]
|
|
349
341
|
};
|
|
350
342
|
}
|
|
351
|
-
function
|
|
343
|
+
function Pt(t) {
|
|
352
344
|
const e = Ct(t), r = e.tins;
|
|
353
345
|
return {
|
|
354
346
|
compiled: e,
|
|
@@ -362,18 +354,18 @@ function Ot(t) {
|
|
|
362
354
|
};
|
|
363
355
|
}
|
|
364
356
|
function St(t) {
|
|
365
|
-
return !t.version || t.version <
|
|
357
|
+
return !t.version || t.version < q ? ["forw", "bakw"].reduce((e, r) => {
|
|
366
358
|
const n = t.weight_buffer[r];
|
|
367
359
|
return n && (e[r] = Object.keys(n).reduce((c, i) => {
|
|
368
|
-
const
|
|
369
|
-
return c[
|
|
360
|
+
const u = nt(i);
|
|
361
|
+
return c[u] = n[i], c;
|
|
370
362
|
}, {})), e;
|
|
371
363
|
}, {}) : t.weight_buffer;
|
|
372
364
|
}
|
|
373
365
|
function kt(t) {
|
|
374
366
|
return t.strict_status ? t.strict_status : t.kinks_points ? "strict_error" : t.tins_points.length === 2 ? "loose" : "strict";
|
|
375
367
|
}
|
|
376
|
-
function
|
|
368
|
+
function Tt(t) {
|
|
377
369
|
const e = {
|
|
378
370
|
forw: [t.vertices_params[0]],
|
|
379
371
|
bakw: [t.vertices_params[1]]
|
|
@@ -381,28 +373,29 @@ function It(t) {
|
|
|
381
373
|
return e.forw[1] = H(t, !1), e.bakw[1] = H(t, !0), e;
|
|
382
374
|
}
|
|
383
375
|
function H(t, e) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
376
|
+
const r = t.vertices_points.length;
|
|
377
|
+
return Array.from({ length: r }, (n, c) => {
|
|
378
|
+
const i = (c + 1) % r, u = D(
|
|
379
|
+
["c", `b${c}`, `b${i}`],
|
|
387
380
|
t.points,
|
|
388
381
|
t.edgeNodes || [],
|
|
389
382
|
t.centroid_point,
|
|
390
383
|
t.vertices_points,
|
|
391
384
|
e,
|
|
392
|
-
|
|
385
|
+
q
|
|
393
386
|
);
|
|
394
|
-
return F([
|
|
387
|
+
return F([u]);
|
|
395
388
|
});
|
|
396
389
|
}
|
|
397
|
-
function
|
|
390
|
+
function It(t) {
|
|
398
391
|
return {
|
|
399
|
-
forw:
|
|
392
|
+
forw: X(t.centroid_point[0], {
|
|
400
393
|
target: {
|
|
401
394
|
geom: t.centroid_point[1],
|
|
402
395
|
index: "c"
|
|
403
396
|
}
|
|
404
397
|
}),
|
|
405
|
-
bakw:
|
|
398
|
+
bakw: X(t.centroid_point[1], {
|
|
406
399
|
target: {
|
|
407
400
|
geom: t.centroid_point[0],
|
|
408
401
|
index: "c"
|
|
@@ -415,7 +408,7 @@ function Nt(t) {
|
|
|
415
408
|
return {
|
|
416
409
|
forw: F(
|
|
417
410
|
t.tins_points[0].map(
|
|
418
|
-
(r) =>
|
|
411
|
+
(r) => D(
|
|
419
412
|
r,
|
|
420
413
|
t.points,
|
|
421
414
|
t.edgeNodes || [],
|
|
@@ -428,7 +421,7 @@ function Nt(t) {
|
|
|
428
421
|
),
|
|
429
422
|
bakw: F(
|
|
430
423
|
t.tins_points[e].map(
|
|
431
|
-
(r) =>
|
|
424
|
+
(r) => D(
|
|
432
425
|
r,
|
|
433
426
|
t.points,
|
|
434
427
|
t.edgeNodes || [],
|
|
@@ -445,7 +438,7 @@ function Bt(t) {
|
|
|
445
438
|
if (t)
|
|
446
439
|
return {
|
|
447
440
|
bakw: F(
|
|
448
|
-
t.map((e) =>
|
|
441
|
+
t.map((e) => X(e))
|
|
449
442
|
)
|
|
450
443
|
};
|
|
451
444
|
}
|
|
@@ -458,14 +451,14 @@ function Rt(t) {
|
|
|
458
451
|
const e = [], r = t.forw.features;
|
|
459
452
|
for (let n = 0; n < r.length; n++) {
|
|
460
453
|
const c = r[n];
|
|
461
|
-
["a", "b", "c"].
|
|
462
|
-
const g = c.geometry.coordinates[0][
|
|
454
|
+
["a", "b", "c"].forEach((i, u) => {
|
|
455
|
+
const g = c.geometry.coordinates[0][u], h = c.properties[i].geom, l = c.properties[i].index;
|
|
463
456
|
typeof l == "number" && (e[l] = [g, h]);
|
|
464
457
|
});
|
|
465
458
|
}
|
|
466
459
|
return e;
|
|
467
460
|
}
|
|
468
|
-
const
|
|
461
|
+
const Xt = q, E = class E {
|
|
469
462
|
constructor() {
|
|
470
463
|
x(this, "points", []);
|
|
471
464
|
x(this, "pointsWeightBuffer");
|
|
@@ -515,10 +508,10 @@ const Wt = D, E = class E {
|
|
|
515
508
|
*/
|
|
516
509
|
setCompiled(e) {
|
|
517
510
|
if (Et(e)) {
|
|
518
|
-
this.applyModernState(
|
|
511
|
+
this.applyModernState(Ot(e));
|
|
519
512
|
return;
|
|
520
513
|
}
|
|
521
|
-
this.applyLegacyState(
|
|
514
|
+
this.applyLegacyState(Pt(e));
|
|
522
515
|
}
|
|
523
516
|
applyModernState(e) {
|
|
524
517
|
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));
|
|
@@ -539,10 +532,10 @@ const Wt = D, E = class E {
|
|
|
539
532
|
this.indexedTins = void 0;
|
|
540
533
|
return;
|
|
541
534
|
}
|
|
542
|
-
let i = [],
|
|
535
|
+
let i = [], u = [];
|
|
543
536
|
const g = r.features.map((d) => {
|
|
544
537
|
let a = [];
|
|
545
|
-
return
|
|
538
|
+
return G(d)[0].map((s) => {
|
|
546
539
|
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
540
|
}), a;
|
|
548
541
|
}), h = (i[1][0] - i[0][0]) / c, l = (i[1][1] - i[0][1]) / c, y = g.reduce(
|
|
@@ -552,12 +545,12 @@ const Wt = D, E = class E {
|
|
|
552
545
|
i[0][0],
|
|
553
546
|
h,
|
|
554
547
|
c
|
|
555
|
-
),
|
|
548
|
+
), M = B(
|
|
556
549
|
a[1][0],
|
|
557
550
|
i[0][0],
|
|
558
551
|
h,
|
|
559
552
|
c
|
|
560
|
-
),
|
|
553
|
+
), v = B(
|
|
561
554
|
a[0][1],
|
|
562
555
|
i[0][1],
|
|
563
556
|
l,
|
|
@@ -568,9 +561,9 @@ const Wt = D, E = class E {
|
|
|
568
561
|
l,
|
|
569
562
|
c
|
|
570
563
|
);
|
|
571
|
-
for (let w = m; w <=
|
|
564
|
+
for (let w = m; w <= M; w++) {
|
|
572
565
|
d[w] || (d[w] = []);
|
|
573
|
-
for (let A =
|
|
566
|
+
for (let A = v; A <= _; A++)
|
|
574
567
|
d[w][A] || (d[w][A] = []), d[w][A].push(s);
|
|
575
568
|
}
|
|
576
569
|
return d;
|
|
@@ -578,35 +571,35 @@ const Wt = D, E = class E {
|
|
|
578
571
|
[]
|
|
579
572
|
), o = n.features.map((d) => {
|
|
580
573
|
let a = [];
|
|
581
|
-
return
|
|
582
|
-
|
|
574
|
+
return G(d)[0].map((s) => {
|
|
575
|
+
u.length === 0 ? u = [Array.from(s), Array.from(s)] : (s[0] < u[0][0] && (u[0][0] = s[0]), s[0] > u[1][0] && (u[1][0] = s[0]), s[1] < u[0][1] && (u[0][1] = s[1]), s[1] > u[1][1] && (u[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
576
|
}), a;
|
|
584
|
-
}),
|
|
577
|
+
}), f = (u[1][0] - u[0][0]) / c, b = (u[1][1] - u[0][1]) / c, p = o.reduce(
|
|
585
578
|
(d, a, s) => {
|
|
586
579
|
const m = B(
|
|
587
580
|
a[0][0],
|
|
588
|
-
|
|
589
|
-
|
|
581
|
+
u[0][0],
|
|
582
|
+
f,
|
|
590
583
|
c
|
|
591
|
-
),
|
|
584
|
+
), M = B(
|
|
592
585
|
a[1][0],
|
|
593
|
-
|
|
594
|
-
|
|
586
|
+
u[0][0],
|
|
587
|
+
f,
|
|
595
588
|
c
|
|
596
|
-
),
|
|
589
|
+
), v = B(
|
|
597
590
|
a[0][1],
|
|
598
|
-
|
|
591
|
+
u[0][1],
|
|
599
592
|
b,
|
|
600
593
|
c
|
|
601
594
|
), _ = B(
|
|
602
595
|
a[1][1],
|
|
603
|
-
|
|
596
|
+
u[0][1],
|
|
604
597
|
b,
|
|
605
598
|
c
|
|
606
599
|
);
|
|
607
|
-
for (let w = m; w <=
|
|
600
|
+
for (let w = m; w <= M; w++) {
|
|
608
601
|
d[w] || (d[w] = []);
|
|
609
|
-
for (let A =
|
|
602
|
+
for (let A = v; A <= _; A++)
|
|
610
603
|
d[w][A] || (d[w][A] = []), d[w][A].push(s);
|
|
611
604
|
}
|
|
612
605
|
return d;
|
|
@@ -624,9 +617,9 @@ const Wt = D, E = class E {
|
|
|
624
617
|
},
|
|
625
618
|
bakw: {
|
|
626
619
|
gridNum: c,
|
|
627
|
-
xOrigin:
|
|
628
|
-
yOrigin:
|
|
629
|
-
xUnit:
|
|
620
|
+
xOrigin: u[0][0],
|
|
621
|
+
yOrigin: u[0][1],
|
|
622
|
+
xUnit: f,
|
|
630
623
|
yUnit: b,
|
|
631
624
|
gridCache: p
|
|
632
625
|
}
|
|
@@ -643,21 +636,23 @@ const Wt = D, E = class E {
|
|
|
643
636
|
* @throws {Error} 逆方向変換が許可されていない状態での逆変換時
|
|
644
637
|
*/
|
|
645
638
|
transform(e, r, n) {
|
|
639
|
+
if (!this.tins)
|
|
640
|
+
throw new Error("setCompiled() must be called before transform()");
|
|
646
641
|
if (r && this.strict_status == E.STATUS_ERROR)
|
|
647
|
-
throw 'Backward transform is not allowed if strict_status == "strict_error"';
|
|
642
|
+
throw new Error('Backward transform is not allowed if strict_status == "strict_error"');
|
|
648
643
|
this.yaxisMode == E.YAXIS_FOLLOW && r && (e = [e[0], -1 * e[1]]);
|
|
649
|
-
const c =
|
|
650
|
-
if (this.bounds && !r && !n &&
|
|
644
|
+
const c = X(e);
|
|
645
|
+
if (this.bounds && !r && !n && !$(c, this.boundsPolygon))
|
|
651
646
|
return !1;
|
|
652
|
-
const i = r ? this.tins.bakw : this.tins.forw,
|
|
647
|
+
const i = r ? this.tins.bakw : this.tins.forw, u = 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;
|
|
653
648
|
let y, o;
|
|
654
649
|
this.stateFull && (this.stateBackward == r ? y = this.stateTriangle : (this.stateBackward = r, this.stateTriangle = void 0), o = (b) => {
|
|
655
650
|
this.stateTriangle = b;
|
|
656
651
|
});
|
|
657
|
-
let
|
|
652
|
+
let f = vt(
|
|
658
653
|
c,
|
|
659
654
|
i,
|
|
660
|
-
|
|
655
|
+
u,
|
|
661
656
|
g,
|
|
662
657
|
h,
|
|
663
658
|
l,
|
|
@@ -665,10 +660,10 @@ const Wt = D, E = class E {
|
|
|
665
660
|
o
|
|
666
661
|
);
|
|
667
662
|
if (this.bounds && r && !n) {
|
|
668
|
-
const b =
|
|
669
|
-
if (
|
|
670
|
-
} else this.yaxisMode == E.YAXIS_FOLLOW && !r && (
|
|
671
|
-
return
|
|
663
|
+
const b = X(f);
|
|
664
|
+
if (!$(b, this.boundsPolygon)) return !1;
|
|
665
|
+
} else this.yaxisMode == E.YAXIS_FOLLOW && !r && (f = [f[0], -1 * f[1]]);
|
|
666
|
+
return f;
|
|
672
667
|
}
|
|
673
668
|
};
|
|
674
669
|
/**
|
|
@@ -679,8 +674,8 @@ x(E, "VERTEX_PLAIN", "plain"), x(E, "VERTEX_BIRDEYE", "birdeye"), x(E, "MODE_STR
|
|
|
679
674
|
let Z = E;
|
|
680
675
|
export {
|
|
681
676
|
Z as Transform,
|
|
682
|
-
|
|
683
|
-
|
|
677
|
+
Wt as counterTri,
|
|
678
|
+
Xt as format_version,
|
|
684
679
|
At as normalizeEdges,
|
|
685
680
|
Ft as rotateVerticesTriangle,
|
|
686
681
|
vt as transformArr
|