@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.
@@ -1,352 +1,505 @@
1
- var ot = Object.defineProperty;
2
- var at = (e, t, s) => t in e ? ot(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var _ = (e, t, s) => at(e, typeof t != "symbol" ? t + "" : t, s);
4
- const R = 11102230246251565e-32, I = 134217729, ft = (3 + 8 * R) * R;
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 < 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])
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 (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)
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 && d <= 0 || l <= 0 && d >= 0) {
57
- if (n = lt(c, g, d, l, 0, 0), n === 0)
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
- (n > 0 && l > 0 && d <= 0 || n < 0 && l <= 0 && d > 0) && a++;
56
+ (i > 0 && l > 0 && g <= 0 || i < 0 && l <= 0 && g > 0) && c++;
60
57
  }
61
- y = o, d = l, c = g;
58
+ y = o, g = l, f = h;
62
59
  }
63
60
  }
64
- return a % 2 !== 0;
61
+ return c % 2 !== 0;
65
62
  }
66
- function Z(e, t, s = {}) {
67
- const r = { type: "Feature" };
68
- return (s.id === 0 || s.id) && (r.id = s.id), s.bbox && (r.bbox = s.bbox), r.properties = t || {}, r.geometry = e, r;
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 Y(e, t, s = {}) {
71
- if (!e)
67
+ function X(t, e, r = {}) {
68
+ if (!t)
72
69
  throw new Error("coordinates is required");
73
- if (!Array.isArray(e))
70
+ if (!Array.isArray(t))
74
71
  throw new Error("coordinates must be an Array");
75
- if (e.length < 2)
72
+ if (t.length < 2)
76
73
  throw new Error("coordinates must be at least 2 numbers long");
77
- if (!j(e[0]) || !j(e[1]))
74
+ if (!G(t[0]) || !G(t[1]))
78
75
  throw new Error("coordinates must contain numbers");
79
- return Z({
76
+ return H({
80
77
  type: "Point",
81
- coordinates: e
82
- }, t, s);
78
+ coordinates: t
79
+ }, e, r);
83
80
  }
84
- function tt(e, t, s = {}) {
85
- for (const a of e) {
86
- if (a.length < 4)
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 (a[a.length - 1].length !== a[0].length)
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 n = 0; n < a[a.length - 1].length; n++)
93
- if (a[a.length - 1][n] !== a[0][n])
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 Z({
93
+ return H({
97
94
  type: "Polygon",
98
- coordinates: e
99
- }, t, s);
95
+ coordinates: t
96
+ }, e, r);
100
97
  }
101
- function B(e, t = {}) {
102
- const s = { type: "FeatureCollection" };
103
- return t.id && (s.id = t.id), t.bbox && (s.bbox = t.bbox), s.features = e, s;
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 j(e) {
106
- return !isNaN(e) && e !== null && !Array.isArray(e);
102
+ function G(t) {
103
+ return !isNaN(t) && t !== null && !Array.isArray(t);
107
104
  }
108
- function bt(e) {
109
- if (!e)
105
+ function gt(t) {
106
+ if (!t)
110
107
  throw new Error("coord is required");
111
- if (!Array.isArray(e)) {
112
- if (e.type === "Feature" && e.geometry !== null && e.geometry.type === "Point")
113
- return [...e.geometry.coordinates];
114
- if (e.type === "Point")
115
- return [...e.coordinates];
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(e) && e.length >= 2 && !Array.isArray(e[0]) && !Array.isArray(e[1]))
118
- return [...e];
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 J(e) {
122
- if (Array.isArray(e))
123
- return e;
124
- if (e.type === "Feature") {
125
- if (e.geometry !== null)
126
- return e.geometry.coordinates;
127
- } else if (e.coordinates)
128
- return e.coordinates;
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 wt(e) {
134
- return e.type === "Feature" ? e.geometry : e;
130
+ function lt(t) {
131
+ return t.type === "Feature" ? t.geometry : t;
135
132
  }
136
- function mt(e, t, s = {}) {
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 r = bt(e), a = wt(t), n = a.type, c = t.bbox;
142
- let d = a.coordinates;
143
- if (c && xt(r, c) === !1)
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
- n === "Polygon" && (d = [d]);
146
- let g = !1;
147
- for (var l = 0; l < d.length; ++l) {
148
- const y = yt(r, d[l]);
149
- if (y === 0) return !s.ignoreBoundary;
150
- y && (g = !0);
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 xt(e, t) {
155
- return t[0] <= e[0] && t[1] <= e[1] && t[2] >= e[0] && t[3] >= e[1];
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
- var D = mt;
158
- function Tt(e) {
159
- const t = e.features;
160
- for (let s = 0; s < t.length; s++) {
161
- const r = t[s];
162
- `${r.properties.a.index}`.substring(0, 1) === "b" && `${r.properties.b.index}`.substring(0, 1) === "b" ? t[s] = {
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
- r.geometry.coordinates[0][2],
168
- r.geometry.coordinates[0][0],
169
- r.geometry.coordinates[0][1],
170
- r.geometry.coordinates[0][2]
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: r.properties.c.geom,
177
- index: r.properties.c.index
243
+ geom: n.properties.c.geom,
244
+ index: n.properties.c.index
178
245
  },
179
246
  b: {
180
- geom: r.properties.a.geom,
181
- index: r.properties.a.index
247
+ geom: n.properties.a.geom,
248
+ index: n.properties.a.index
182
249
  },
183
250
  c: {
184
- geom: r.properties.b.geom,
185
- index: r.properties.b.index
251
+ geom: n.properties.b.geom,
252
+ index: n.properties.b.index
186
253
  }
187
254
  },
188
255
  type: "Feature"
189
- } : `${r.properties.c.index}`.substring(0, 1) === "b" && `${r.properties.a.index}`.substring(0, 1) === "b" && (t[s] = {
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
- r.geometry.coordinates[0][1],
195
- r.geometry.coordinates[0][2],
196
- r.geometry.coordinates[0][0],
197
- r.geometry.coordinates[0][1]
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: r.properties.b.geom,
204
- index: r.properties.b.index
270
+ geom: n.properties.b.geom,
271
+ index: n.properties.b.index
205
272
  },
206
273
  b: {
207
- geom: r.properties.c.geom,
208
- index: r.properties.c.index
274
+ geom: n.properties.c.geom,
275
+ index: n.properties.c.index
209
276
  },
210
277
  c: {
211
- geom: r.properties.a.geom,
212
- index: r.properties.a.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 e;
285
+ return t;
219
286
  }
220
- function It(e) {
221
- const t = ["a", "b", "c", "a"].map(
222
- (n) => e.properties[n].geom
223
- ), s = e.geometry.coordinates[0], r = e.properties, a = {
224
- a: { geom: s[0], index: r.a.index },
225
- b: { geom: s[1], index: r.b.index },
226
- c: { geom: s[2], index: r.c.index }
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 tt([t], a);
295
+ return Z([e], c);
229
296
  }
230
- function _t(e) {
231
- const t = [0, 1, 2, 0].map((r) => e[r][0][0]), s = {
232
- a: { geom: e[0][0][1], index: e[0][1] },
233
- b: { geom: e[1][0][1], index: e[1][1] },
234
- c: { geom: e[2][0][1], index: e[2][1] }
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 tt([t], s);
237
- }
238
- function W(e, t, s, r, a, n = !1, c) {
239
- const d = e.map(
240
- (g) => {
241
- (!c || c < 2.00703) && (g = et(g));
242
- const l = isFinite(g) ? t[g] : g === "c" ? r : g === "b0" ? a[0] : g === "b1" ? a[1] : g === "b2" ? a[2] : g === "b3" ? a[3] : function() {
243
- const y = g.match(/e(\d+)/);
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 s[o];
313
+ return r[o];
247
314
  }
248
315
  throw "Bad index value for indexesToTri";
249
316
  }();
250
- return n ? [[l[1], l[0]], g] : [[l[0], l[1]], g];
317
+ return i ? [[l[1], l[0]], h] : [[l[0], l[1]], h];
251
318
  }
252
319
  );
253
- return _t(d);
320
+ return pt(g);
254
321
  }
255
- function et(e) {
256
- return typeof e == "number" ? e : e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
322
+ function et(t) {
323
+ return typeof t == "number" ? t : t.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
257
324
  }
258
- function At(e, t) {
259
- return t && t >= 2.00703 || Array.isArray(e[0]) ? e : e.map((s) => [
260
- s.illstNodes,
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 z(e, t) {
266
- for (let s = 0; s < t.features.length; s++)
267
- if (D(e, t.features[s]))
268
- return t.features[s];
269
- }
270
- function rt(e, t, s) {
271
- const r = t.geometry.coordinates[0][0], a = t.geometry.coordinates[0][1], n = t.geometry.coordinates[0][2], c = e.geometry.coordinates, d = t.properties.a.geom, g = t.properties.b.geom, l = t.properties.c.geom, y = [a[0] - r[0], a[1] - r[1]], o = [n[0] - r[0], n[1] - r[1]], u = [c[0] - r[0], c[1] - r[1]], b = [g[0] - d[0], g[1] - d[1]], x = [l[0] - d[0], l[1] - d[1]];
272
- let h = (o[1] * u[0] - o[0] * u[1]) / (y[0] * o[1] - y[1] * o[0]), f = (y[0] * u[1] - y[1] * u[0]) / (y[0] * o[1] - y[1] * o[0]);
273
- if (s) {
274
- const i = s[t.properties.a.index], w = s[t.properties.b.index], A = s[t.properties.c.index];
275
- let v;
276
- if (h < 0 || f < 0 || 1 - h - f < 0) {
277
- const E = h / (h + f), m = f / (h + f);
278
- v = h / w / (E / w + m / A), f = f / A / (E / w + m / A);
279
- } else
280
- v = h / w / (h / w + f / A + (1 - h - f) / i), f = f / A / (h / w + f / A + (1 - h - f) / i);
281
- h = v;
282
- }
283
- return [
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 vt(e, t, s, r) {
289
- const a = e.geometry.coordinates, n = s.geometry.coordinates, c = Math.atan2(a[0] - n[0], a[1] - n[1]), d = Et(c, t[0]);
290
- if (d === void 0)
291
- throw new Error("Unable to determine vertex index");
292
- const g = t[1][d];
293
- return rt(e, g.features[0], r);
294
- }
295
- function Mt(e, t, s, r, a, n, c, d) {
296
- let g;
297
- if (c && (g = z(e, B([c]))), !g) {
298
- if (s) {
299
- const l = e.geometry.coordinates, y = s.gridNum, o = s.xOrigin, u = s.yOrigin, b = s.xUnit, x = s.yUnit, h = s.gridCache, f = C(l[0], o, b, y), i = C(l[1], u, x, y), w = h[f] ? h[f][i] ? h[f][i] : [] : [];
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 C(e, t, s, r) {
307
- let a = Math.floor((e - t) / s);
308
- return a >= r && (a = r - 1), a;
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 Et(e, t) {
311
- let s = K(e - t[0]), r = Math.PI * 2, a;
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 K(e, t = !1) {
319
- const s = t ? function(r) {
320
- return !(r >= 0 && r < Math.PI * 2);
321
- } : function(r) {
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
- for (; s(e); )
325
- e = e + 2 * Math.PI * (e > 0 ? -1 : 1);
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 Q = 2.00703, O = class O {
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(t) {
364
- if (t.version || !t.tins && t.points && t.tins_points) {
365
- this.points = t.points, this.pointsWeightBuffer = !t.version || t.version < 2.00703 ? ["forw", "bakw"].reduce((r, a) => {
366
- const n = t.weight_buffer[a];
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 t = this.tins, s = t.forw, r = t.bakw, a = Math.ceil(Math.sqrt(s.features.length));
467
- if (a < 3) {
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 n = [], c = [];
472
- const d = s.features.map((h) => {
473
- let f = [];
474
- return J(h)[0].map((i) => {
475
- n.length === 0 ? n = [Array.from(i), Array.from(i)] : (i[0] < n[0][0] && (n[0][0] = i[0]), i[0] > n[1][0] && (n[1][0] = i[0]), i[1] < n[0][1] && (n[0][1] = i[1]), i[1] > n[1][1] && (n[1][1] = i[1])), f.length === 0 ? f = [Array.from(i), Array.from(i)] : (i[0] < f[0][0] && (f[0][0] = i[0]), i[0] > f[1][0] && (f[1][0] = i[0]), i[1] < f[0][1] && (f[0][1] = i[1]), i[1] > f[1][1] && (f[1][1] = i[1]));
476
- }), f;
477
- }), g = (n[1][0] - n[0][0]) / a, l = (n[1][1] - n[0][1]) / a, y = d.reduce(
478
- (h, f, i) => {
479
- const w = C(
480
- f[0][0],
481
- n[0][0],
482
- g,
483
- a
484
- ), A = C(
485
- f[1][0],
486
- n[0][0],
487
- g,
488
- a
489
- ), v = C(
490
- f[0][1],
491
- n[0][1],
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
- a
494
- ), E = C(
495
- f[1][1],
496
- n[0][1],
564
+ c
565
+ ), M = N(
566
+ a[1][1],
567
+ i[0][1],
497
568
  l,
498
- a
569
+ c
499
570
  );
500
- for (let m = w; m <= A; m++) {
501
- h[m] || (h[m] = []);
502
- for (let M = v; M <= E; M++)
503
- h[m][M] || (h[m][M] = []), h[m][M].push(i);
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 h;
576
+ return d;
506
577
  },
507
578
  []
508
- ), o = r.features.map((h) => {
509
- let f = [];
510
- return J(h)[0].map((i) => {
511
- c.length === 0 ? c = [Array.from(i), Array.from(i)] : (i[0] < c[0][0] && (c[0][0] = i[0]), i[0] > c[1][0] && (c[1][0] = i[0]), i[1] < c[0][1] && (c[0][1] = i[1]), i[1] > c[1][1] && (c[1][1] = i[1])), f.length === 0 ? f = [Array.from(i), Array.from(i)] : (i[0] < f[0][0] && (f[0][0] = i[0]), i[0] > f[1][0] && (f[1][0] = i[0]), i[1] < f[0][1] && (f[0][1] = i[1]), i[1] > f[1][1] && (f[1][1] = i[1]));
512
- }), f;
513
- }), u = (c[1][0] - c[0][0]) / a, b = (c[1][1] - c[0][1]) / a, x = o.reduce(
514
- (h, f, i) => {
515
- const w = C(
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
- a
520
- ), A = C(
521
- f[1][0],
522
- c[0][0],
590
+ c
591
+ ), _ = N(
592
+ a[1][0],
593
+ f[0][0],
523
594
  u,
524
- a
525
- ), v = C(
595
+ c
596
+ ), p = N(
597
+ a[0][1],
526
598
  f[0][1],
527
- c[0][1],
528
599
  b,
529
- a
530
- ), E = C(
531
- f[1][1],
532
- c[0][1],
600
+ c
601
+ ), M = N(
602
+ a[1][1],
603
+ f[0][1],
533
604
  b,
534
- a
605
+ c
535
606
  );
536
- for (let m = w; m <= A; m++) {
537
- h[m] || (h[m] = []);
538
- for (let M = v; M <= E; M++)
539
- h[m][M] || (h[m][M] = []), h[m][M].push(i);
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 h;
612
+ return d;
542
613
  },
543
614
  []
544
615
  );
545
616
  this.indexedTins = {
546
617
  forw: {
547
- gridNum: a,
548
- xOrigin: n[0][0],
549
- yOrigin: n[0][1],
550
- xUnit: g,
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: a,
556
- xOrigin: c[0][0],
557
- yOrigin: c[0][1],
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(t, s, r) {
575
- if (s && this.strict_status == O.STATUS_ERROR)
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 == O.YAXIS_FOLLOW && s && (t = [t[0], -1 * t[1]]);
578
- const a = Y(t);
579
- if (this.bounds && !s && !r && !D(a, this.boundsPolygon))
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 n = s ? this.tins.bakw : this.tins.forw, c = s ? this.indexedTins.bakw : this.indexedTins.forw, d = s ? this.vertices_params.bakw : this.vertices_params.forw, g = s ? this.centroid.bakw : this.centroid.forw, l = s ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
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 == s ? y = this.stateTriangle : (this.stateBackward = s, this.stateTriangle = void 0), o = (b) => {
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 = Mt(
587
- a,
588
- n,
657
+ let u = wt(
589
658
  c,
590
- d,
659
+ i,
660
+ f,
591
661
  g,
662
+ h,
592
663
  l,
593
664
  y,
594
665
  o
595
666
  );
596
- if (this.bounds && s && !r) {
597
- const b = Y(u);
598
- if (!D(b, this.boundsPolygon)) return !1;
599
- } else this.yaxisMode == O.YAXIS_FOLLOW && !s && (u = [u[0], -1 * u[1]]);
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
- H as Transform,
611
- It as counterTri,
612
- Q as format_version,
613
- At as normalizeEdges,
614
- Tt as rotateVerticesTriangle,
615
- Mt as transformArr
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
  };