@maplat/transform 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +162 -0
- package/README.md +162 -0
- package/dist/index.d.ts +217 -0
- package/dist/maplat_transform.js +774 -468
- package/dist/maplat_transform.umd.js +1 -1
- package/package.json +7 -5
- package/src/constants.ts +8 -0
- package/src/coord-utils.ts +27 -0
- package/src/index.ts +17 -379
- package/src/map-transform.ts +473 -0
- package/src/transform.ts +338 -0
- package/src/types.ts +40 -0
- package/src/viewpoint.ts +104 -0
package/dist/maplat_transform.js
CHANGED
|
@@ -1,227 +1,217 @@
|
|
|
1
|
-
|
|
2
|
-
var ct = (t, e, r) => e in t ? at(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
-
var x = (t, e, r) => ct(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
function tt(t, e, r = {}) {
|
|
1
|
+
function ot(r, t, e = {}) {
|
|
5
2
|
const n = { type: "Feature" };
|
|
6
|
-
return (
|
|
3
|
+
return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = r, n;
|
|
7
4
|
}
|
|
8
|
-
function X(t, e
|
|
9
|
-
if (!
|
|
5
|
+
function X(r, t, e = {}) {
|
|
6
|
+
if (!r)
|
|
10
7
|
throw new Error("coordinates is required");
|
|
11
|
-
if (!Array.isArray(
|
|
8
|
+
if (!Array.isArray(r))
|
|
12
9
|
throw new Error("coordinates must be an Array");
|
|
13
|
-
if (
|
|
10
|
+
if (r.length < 2)
|
|
14
11
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
15
|
-
if (!
|
|
12
|
+
if (!j(r[0]) || !j(r[1]))
|
|
16
13
|
throw new Error("coordinates must contain numbers");
|
|
17
|
-
return
|
|
14
|
+
return ot({
|
|
18
15
|
type: "Point",
|
|
19
|
-
coordinates:
|
|
20
|
-
},
|
|
16
|
+
coordinates: r
|
|
17
|
+
}, t, e);
|
|
21
18
|
}
|
|
22
|
-
function
|
|
23
|
-
for (const
|
|
24
|
-
if (
|
|
19
|
+
function D(r, t, e = {}) {
|
|
20
|
+
for (const s of r) {
|
|
21
|
+
if (s.length < 4)
|
|
25
22
|
throw new Error(
|
|
26
23
|
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
27
24
|
);
|
|
28
|
-
if (
|
|
25
|
+
if (s[s.length - 1].length !== s[0].length)
|
|
29
26
|
throw new Error("First and last Position are not equivalent.");
|
|
30
|
-
for (let i = 0; i <
|
|
31
|
-
if (
|
|
27
|
+
for (let i = 0; i < s[s.length - 1].length; i++)
|
|
28
|
+
if (s[s.length - 1][i] !== s[0][i])
|
|
32
29
|
throw new Error("First and last Position are not equivalent.");
|
|
33
30
|
}
|
|
34
|
-
return
|
|
31
|
+
return ot({
|
|
35
32
|
type: "Polygon",
|
|
36
|
-
coordinates:
|
|
37
|
-
},
|
|
33
|
+
coordinates: r
|
|
34
|
+
}, t, e);
|
|
38
35
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
return
|
|
36
|
+
function U(r, t = {}) {
|
|
37
|
+
const e = { type: "FeatureCollection" };
|
|
38
|
+
return t.id && (e.id = t.id), t.bbox && (e.bbox = t.bbox), e.features = r, e;
|
|
42
39
|
}
|
|
43
|
-
function
|
|
44
|
-
return !isNaN(
|
|
40
|
+
function j(r) {
|
|
41
|
+
return !isNaN(r) && r !== null && !Array.isArray(r);
|
|
45
42
|
}
|
|
46
|
-
function
|
|
47
|
-
if (!
|
|
43
|
+
function lt(r) {
|
|
44
|
+
if (!r)
|
|
48
45
|
throw new Error("coord is required");
|
|
49
|
-
if (!Array.isArray(
|
|
50
|
-
if (
|
|
51
|
-
return [...
|
|
52
|
-
if (
|
|
53
|
-
return [...
|
|
54
|
-
}
|
|
55
|
-
if (Array.isArray(
|
|
56
|
-
return [...
|
|
46
|
+
if (!Array.isArray(r)) {
|
|
47
|
+
if (r.type === "Feature" && r.geometry !== null && r.geometry.type === "Point")
|
|
48
|
+
return [...r.geometry.coordinates];
|
|
49
|
+
if (r.type === "Point")
|
|
50
|
+
return [...r.coordinates];
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(r) && r.length >= 2 && !Array.isArray(r[0]) && !Array.isArray(r[1]))
|
|
53
|
+
return [...r];
|
|
57
54
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
58
55
|
}
|
|
59
|
-
function
|
|
60
|
-
if (Array.isArray(
|
|
61
|
-
return
|
|
62
|
-
if (
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
65
|
-
} else if (
|
|
66
|
-
return
|
|
56
|
+
function J(r) {
|
|
57
|
+
if (Array.isArray(r))
|
|
58
|
+
return r;
|
|
59
|
+
if (r.type === "Feature") {
|
|
60
|
+
if (r.geometry !== null)
|
|
61
|
+
return r.geometry.coordinates;
|
|
62
|
+
} else if (r.coordinates)
|
|
63
|
+
return r.coordinates;
|
|
67
64
|
throw new Error(
|
|
68
65
|
"coords must be GeoJSON Feature, Geometry Object or an Array"
|
|
69
66
|
);
|
|
70
67
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
const
|
|
75
|
-
function
|
|
76
|
-
let i,
|
|
77
|
-
|
|
78
|
-
let
|
|
79
|
-
if (
|
|
80
|
-
for (
|
|
81
|
-
|
|
82
|
-
for (;
|
|
83
|
-
|
|
84
|
-
for (;
|
|
85
|
-
|
|
86
|
-
return (i !== 0 ||
|
|
87
|
-
}
|
|
88
|
-
function
|
|
89
|
-
let
|
|
90
|
-
for (let n = 1; n <
|
|
91
|
-
return
|
|
68
|
+
function dt(r) {
|
|
69
|
+
return r.type === "Feature" ? r.geometry : r;
|
|
70
|
+
}
|
|
71
|
+
const N = 11102230246251565e-32, E = 134217729, yt = (3 + 8 * N) * N;
|
|
72
|
+
function Y(r, t, e, n, s) {
|
|
73
|
+
let i, o, u, d, f = t[0], m = n[0], a = 0, l = 0;
|
|
74
|
+
m > f == m > -f ? (i = f, f = t[++a]) : (i = m, m = n[++l]);
|
|
75
|
+
let g = 0;
|
|
76
|
+
if (a < r && l < e)
|
|
77
|
+
for (m > f == m > -f ? (o = f + i, u = i - (o - f), f = t[++a]) : (o = m + i, u = i - (o - m), m = n[++l]), i = o, u !== 0 && (s[g++] = u); a < r && l < e; )
|
|
78
|
+
m > f == m > -f ? (o = i + f, d = o - i, u = i - (o - d) + (f - d), f = t[++a]) : (o = i + m, d = o - i, u = i - (o - d) + (m - d), m = n[++l]), i = o, u !== 0 && (s[g++] = u);
|
|
79
|
+
for (; a < r; )
|
|
80
|
+
o = i + f, d = o - i, u = i - (o - d) + (f - d), f = t[++a], i = o, u !== 0 && (s[g++] = u);
|
|
81
|
+
for (; l < e; )
|
|
82
|
+
o = i + m, d = o - i, u = i - (o - d) + (m - d), m = n[++l], i = o, u !== 0 && (s[g++] = u);
|
|
83
|
+
return (i !== 0 || g === 0) && (s[g++] = i), g;
|
|
84
|
+
}
|
|
85
|
+
function mt(r, t) {
|
|
86
|
+
let e = t[0];
|
|
87
|
+
for (let n = 1; n < r; n++) e += t[n];
|
|
88
|
+
return e;
|
|
92
89
|
}
|
|
93
|
-
function
|
|
94
|
-
return new Float64Array(
|
|
95
|
-
}
|
|
96
|
-
const gt = (3 + 16 *
|
|
97
|
-
function
|
|
98
|
-
let
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
let
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
function
|
|
112
|
-
const
|
|
113
|
-
return Math.abs(
|
|
114
|
-
}
|
|
115
|
-
function
|
|
116
|
-
var
|
|
117
|
-
for (
|
|
90
|
+
function V(r) {
|
|
91
|
+
return new Float64Array(r);
|
|
92
|
+
}
|
|
93
|
+
const gt = (3 + 16 * N) * N, bt = (2 + 12 * N) * N, xt = (9 + 64 * N) * N * N, W = V(4), K = V(8), Q = V(12), H = V(16), A = V(4);
|
|
94
|
+
function pt(r, t, e, n, s, i, o) {
|
|
95
|
+
let u, d, f, m, a, l, g, b, y, h, c, x, w, M, v, p, _, T;
|
|
96
|
+
const S = r - s, B = e - s, C = t - i, P = n - i;
|
|
97
|
+
M = S * P, l = E * S, g = l - (l - S), b = S - g, l = E * P, y = l - (l - P), h = P - y, v = b * h - (M - g * y - b * y - g * h), p = C * B, l = E * C, g = l - (l - C), b = C - g, l = E * B, y = l - (l - B), h = B - y, _ = b * h - (p - g * y - b * y - g * h), c = v - _, a = v - c, W[0] = v - (c + a) + (a - _), x = M + c, a = x - M, w = M - (x - a) + (c - a), c = w - p, a = w - c, W[1] = w - (c + a) + (a - p), T = x + c, a = T - x, W[2] = x - (T - a) + (c - a), W[3] = T;
|
|
98
|
+
let k = mt(4, W), F = bt * o;
|
|
99
|
+
if (k >= F || -k >= F || (a = r - S, u = r - (S + a) + (a - s), a = e - B, f = e - (B + a) + (a - s), a = t - C, d = t - (C + a) + (a - i), a = n - P, m = n - (P + a) + (a - i), u === 0 && d === 0 && f === 0 && m === 0) || (F = xt * o + yt * Math.abs(k), k += S * m + P * u - (C * f + B * d), k >= F || -k >= F)) return k;
|
|
100
|
+
M = u * P, l = E * u, g = l - (l - u), b = u - g, l = E * P, y = l - (l - P), h = P - y, v = b * h - (M - g * y - b * y - g * h), p = d * B, l = E * d, g = l - (l - d), b = d - g, l = E * B, y = l - (l - B), h = B - y, _ = b * h - (p - g * y - b * y - g * h), c = v - _, a = v - c, A[0] = v - (c + a) + (a - _), x = M + c, a = x - M, w = M - (x - a) + (c - a), c = w - p, a = w - c, A[1] = w - (c + a) + (a - p), T = x + c, a = T - x, A[2] = x - (T - a) + (c - a), A[3] = T;
|
|
101
|
+
const ut = Y(4, W, 4, A, K);
|
|
102
|
+
M = S * m, l = E * S, g = l - (l - S), b = S - g, l = E * m, y = l - (l - m), h = m - y, v = b * h - (M - g * y - b * y - g * h), p = C * f, l = E * C, g = l - (l - C), b = C - g, l = E * f, y = l - (l - f), h = f - y, _ = b * h - (p - g * y - b * y - g * h), c = v - _, a = v - c, A[0] = v - (c + a) + (a - _), x = M + c, a = x - M, w = M - (x - a) + (c - a), c = w - p, a = w - c, A[1] = w - (c + a) + (a - p), T = x + c, a = T - x, A[2] = x - (T - a) + (c - a), A[3] = T;
|
|
103
|
+
const ft = Y(ut, K, 4, A, Q);
|
|
104
|
+
M = u * m, l = E * u, g = l - (l - u), b = u - g, l = E * m, y = l - (l - m), h = m - y, v = b * h - (M - g * y - b * y - g * h), p = d * f, l = E * d, g = l - (l - d), b = d - g, l = E * f, y = l - (l - f), h = f - y, _ = b * h - (p - g * y - b * y - g * h), c = v - _, a = v - c, A[0] = v - (c + a) + (a - _), x = M + c, a = x - M, w = M - (x - a) + (c - a), c = w - p, a = w - c, A[1] = w - (c + a) + (a - p), T = x + c, a = T - x, A[2] = x - (T - a) + (c - a), A[3] = T;
|
|
105
|
+
const ht = Y(ft, Q, 4, A, H);
|
|
106
|
+
return H[ht - 1];
|
|
107
|
+
}
|
|
108
|
+
function wt(r, t, e, n, s, i) {
|
|
109
|
+
const o = (t - i) * (e - s), u = (r - s) * (n - i), d = o - u, f = Math.abs(o + u);
|
|
110
|
+
return Math.abs(d) >= gt * f ? d : -pt(r, t, e, n, s, i, f);
|
|
111
|
+
}
|
|
112
|
+
function Mt(r, t) {
|
|
113
|
+
var e, n, s = 0, i, o, u, d, f, m, a, l = r[0], g = r[1], b = t.length;
|
|
114
|
+
for (e = 0; e < b; e++) {
|
|
118
115
|
n = 0;
|
|
119
|
-
var
|
|
120
|
-
if (
|
|
116
|
+
var y = t[e], h = y.length - 1;
|
|
117
|
+
if (m = y[0], m[0] !== y[h][0] && m[1] !== y[h][1])
|
|
121
118
|
throw new Error("First and last coordinates in a ring must be the same");
|
|
122
|
-
for (
|
|
123
|
-
if (
|
|
124
|
-
if (
|
|
119
|
+
for (o = m[0] - l, u = m[1] - g, n; n < h; n++) {
|
|
120
|
+
if (a = y[n + 1], d = a[0] - l, f = a[1] - g, u === 0 && f === 0) {
|
|
121
|
+
if (d <= 0 && o >= 0 || o <= 0 && d >= 0)
|
|
125
122
|
return 0;
|
|
126
|
-
} else if (
|
|
127
|
-
if (i =
|
|
123
|
+
} else if (f >= 0 && u <= 0 || f <= 0 && u >= 0) {
|
|
124
|
+
if (i = wt(o, d, u, f, 0, 0), i === 0)
|
|
128
125
|
return 0;
|
|
129
|
-
(i > 0 &&
|
|
126
|
+
(i > 0 && f > 0 && u <= 0 || i < 0 && f <= 0 && u > 0) && s++;
|
|
130
127
|
}
|
|
131
|
-
|
|
128
|
+
m = a, u = f, o = d;
|
|
132
129
|
}
|
|
133
130
|
}
|
|
134
|
-
return
|
|
131
|
+
return s % 2 !== 0;
|
|
135
132
|
}
|
|
136
|
-
function
|
|
137
|
-
if (!
|
|
133
|
+
function L(r, t, e = {}) {
|
|
134
|
+
if (!r)
|
|
138
135
|
throw new Error("point is required");
|
|
139
|
-
if (!
|
|
136
|
+
if (!t)
|
|
140
137
|
throw new Error("polygon is required");
|
|
141
|
-
const n =
|
|
142
|
-
let
|
|
143
|
-
if (
|
|
138
|
+
const n = lt(r), s = dt(t), i = s.type, o = t.bbox;
|
|
139
|
+
let u = s.coordinates;
|
|
140
|
+
if (o && _t(n, o) === !1)
|
|
144
141
|
return !1;
|
|
145
|
-
i === "Polygon" && (
|
|
146
|
-
let
|
|
147
|
-
for (var
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
function
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
function
|
|
158
|
-
for (let
|
|
159
|
-
if (
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
function
|
|
163
|
-
const n =
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
let
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
142
|
+
i === "Polygon" && (u = [u]);
|
|
143
|
+
let d = !1;
|
|
144
|
+
for (var f = 0; f < u.length; ++f) {
|
|
145
|
+
const m = Mt(n, u[f]);
|
|
146
|
+
if (m === 0) return !e.ignoreBoundary;
|
|
147
|
+
m && (d = !0);
|
|
148
|
+
}
|
|
149
|
+
return d;
|
|
150
|
+
}
|
|
151
|
+
function _t(r, t) {
|
|
152
|
+
return t[0] <= r[0] && t[1] <= r[1] && t[2] >= r[0] && t[3] >= r[1];
|
|
153
|
+
}
|
|
154
|
+
function $(r, t) {
|
|
155
|
+
for (let e = 0; e < t.features.length; e++)
|
|
156
|
+
if (L(r, t.features[e]))
|
|
157
|
+
return t.features[e];
|
|
158
|
+
}
|
|
159
|
+
function it(r, t, e) {
|
|
160
|
+
const n = t.geometry.coordinates[0][0], s = t.geometry.coordinates[0][1], i = t.geometry.coordinates[0][2], o = r.geometry.coordinates, u = t.properties.a.geom, d = t.properties.b.geom, f = t.properties.c.geom, m = [s[0] - n[0], s[1] - n[1]], a = [i[0] - n[0], i[1] - n[1]], l = [o[0] - n[0], o[1] - n[1]], g = [d[0] - u[0], d[1] - u[1]], b = [f[0] - u[0], f[1] - u[1]];
|
|
161
|
+
let y = (a[1] * l[0] - a[0] * l[1]) / (m[0] * a[1] - m[1] * a[0]), h = (m[0] * l[1] - m[1] * l[0]) / (m[0] * a[1] - m[1] * a[0]);
|
|
162
|
+
if (e) {
|
|
163
|
+
const c = e[t.properties.a.index], x = e[t.properties.b.index], w = e[t.properties.c.index];
|
|
164
|
+
let M;
|
|
165
|
+
if (y < 0 || h < 0 || 1 - y - h < 0) {
|
|
166
|
+
const v = y / (y + h), p = h / (y + h);
|
|
167
|
+
M = y / x / (v / x + p / w), h = h / w / (v / x + p / w);
|
|
171
168
|
} else
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
M = y / x / (y / x + h / w + (1 - y - h) / c), h = h / w / (y / x + h / w + (1 - y - h) / c);
|
|
170
|
+
y = M;
|
|
174
171
|
}
|
|
175
172
|
return [
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
y * g[0] + h * b[0] + u[0],
|
|
174
|
+
y * g[1] + h * b[1] + u[1]
|
|
178
175
|
];
|
|
179
176
|
}
|
|
180
|
-
function
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
177
|
+
function vt(r, t, e, n) {
|
|
178
|
+
const s = r.geometry.coordinates, i = e.geometry.coordinates, o = Math.atan2(s[0] - i[0], s[1] - i[1]), u = Et(o, t[0]);
|
|
179
|
+
if (u === void 0)
|
|
183
180
|
throw new Error("Unable to determine vertex index");
|
|
184
|
-
const
|
|
185
|
-
return
|
|
186
|
-
}
|
|
187
|
-
function
|
|
188
|
-
let
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
|
|
181
|
+
const d = t[1][u];
|
|
182
|
+
return it(r, d.features[0], n);
|
|
183
|
+
}
|
|
184
|
+
function Tt(r, t, e, n, s, i, o, u) {
|
|
185
|
+
let d;
|
|
186
|
+
if (o && (d = $(r, U([o]))), !d)
|
|
187
|
+
if (e) {
|
|
188
|
+
const f = r.geometry.coordinates, m = e.gridNum, a = e.xOrigin, l = e.yOrigin, g = e.xUnit, b = e.yUnit, y = e.gridCache, h = O(f[0], a, g, m), c = O(f[1], l, b, m), x = y[h] ? y[h][c] ? y[h][c] : [] : [], w = U(x.map((M) => t.features[M]));
|
|
189
|
+
d = $(r, w);
|
|
193
190
|
} else
|
|
194
|
-
|
|
195
|
-
return
|
|
196
|
-
}
|
|
197
|
-
function
|
|
198
|
-
let
|
|
199
|
-
return
|
|
200
|
-
}
|
|
201
|
-
function
|
|
202
|
-
let
|
|
203
|
-
for (let i = 0; i <
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
return
|
|
208
|
-
}
|
|
209
|
-
function
|
|
210
|
-
const
|
|
211
|
-
return
|
|
212
|
-
}
|
|
213
|
-
function At(t, e) {
|
|
214
|
-
return e && e >= 2.00703 || Array.isArray(t[0]) ? t : t.map((r) => [
|
|
215
|
-
r.illstNodes,
|
|
216
|
-
r.mercNodes,
|
|
217
|
-
r.startEnd
|
|
218
|
-
]);
|
|
191
|
+
d = $(r, t);
|
|
192
|
+
return u && u(d), d ? it(r, d, i) : vt(r, n, s, i);
|
|
193
|
+
}
|
|
194
|
+
function O(r, t, e, n) {
|
|
195
|
+
let s = Math.floor((r - t) / e);
|
|
196
|
+
return s < 0 && (s = 0), s >= n && (s = n - 1), s;
|
|
197
|
+
}
|
|
198
|
+
function Et(r, t) {
|
|
199
|
+
let e = tt(r - t[0]), n = Math.PI * 2, s;
|
|
200
|
+
for (let i = 0; i < t.length; i++) {
|
|
201
|
+
const o = (i + 1) % t.length, u = tt(r - t[o]), d = Math.min(Math.abs(e), Math.abs(u));
|
|
202
|
+
e * u <= 0 && d < n && (n = d, s = i), e = u;
|
|
203
|
+
}
|
|
204
|
+
return s;
|
|
205
|
+
}
|
|
206
|
+
function tt(r, t = !1) {
|
|
207
|
+
const e = 2 * Math.PI, n = r - Math.floor(r / e) * e;
|
|
208
|
+
return t ? n : n > Math.PI ? n - e : n;
|
|
219
209
|
}
|
|
220
|
-
function
|
|
221
|
-
const
|
|
222
|
-
for (let
|
|
223
|
-
const n = e
|
|
224
|
-
`${n.properties.a.index}`.substring(0, 1) === "b" && `${n.properties.b.index}`.substring(0, 1) === "b" ? e
|
|
210
|
+
function Vt(r) {
|
|
211
|
+
const t = r.features;
|
|
212
|
+
for (let e = 0; e < t.length; e++) {
|
|
213
|
+
const n = t[e];
|
|
214
|
+
`${n.properties.a.index}`.substring(0, 1) === "b" && `${n.properties.b.index}`.substring(0, 1) === "b" ? t[e] = {
|
|
225
215
|
geometry: {
|
|
226
216
|
type: "Polygon",
|
|
227
217
|
coordinates: [
|
|
@@ -248,7 +238,7 @@ function Ft(t) {
|
|
|
248
238
|
}
|
|
249
239
|
},
|
|
250
240
|
type: "Feature"
|
|
251
|
-
} : `${n.properties.c.index}`.substring(0, 1) === "b" && `${n.properties.a.index}`.substring(0, 1) === "b" && (e
|
|
241
|
+
} : `${n.properties.c.index}`.substring(0, 1) === "b" && `${n.properties.a.index}`.substring(0, 1) === "b" && (t[e] = {
|
|
252
242
|
geometry: {
|
|
253
243
|
type: "Polygon",
|
|
254
244
|
coordinates: [
|
|
@@ -277,406 +267,722 @@ function Ft(t) {
|
|
|
277
267
|
type: "Feature"
|
|
278
268
|
});
|
|
279
269
|
}
|
|
280
|
-
return
|
|
270
|
+
return r;
|
|
281
271
|
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
284
|
-
(i) =>
|
|
285
|
-
),
|
|
286
|
-
a: { geom:
|
|
287
|
-
b: { geom:
|
|
288
|
-
c: { geom:
|
|
272
|
+
function Dt(r) {
|
|
273
|
+
const t = ["a", "b", "c", "a"].map(
|
|
274
|
+
(i) => r.properties[i].geom
|
|
275
|
+
), e = r.geometry.coordinates[0], n = r.properties, s = {
|
|
276
|
+
a: { geom: e[0], index: n.a.index },
|
|
277
|
+
b: { geom: e[1], index: n.b.index },
|
|
278
|
+
c: { geom: e[2], index: n.c.index }
|
|
289
279
|
};
|
|
290
|
-
return
|
|
280
|
+
return D([t], s);
|
|
291
281
|
}
|
|
292
|
-
function
|
|
293
|
-
const
|
|
294
|
-
a: { geom:
|
|
295
|
-
b: { geom:
|
|
296
|
-
c: { geom:
|
|
282
|
+
function At(r) {
|
|
283
|
+
const t = [0, 1, 2, 0].map((n) => r[n][0][0]), e = {
|
|
284
|
+
a: { geom: r[0][0][1], index: r[0][1] },
|
|
285
|
+
b: { geom: r[1][0][1], index: r[1][1] },
|
|
286
|
+
c: { geom: r[2][0][1], index: r[2][1] }
|
|
297
287
|
};
|
|
298
|
-
return
|
|
299
|
-
}
|
|
300
|
-
function
|
|
301
|
-
const
|
|
302
|
-
(
|
|
303
|
-
(!
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
288
|
+
return D([t], e);
|
|
289
|
+
}
|
|
290
|
+
function G(r, t, e, n, s, i = !1, o) {
|
|
291
|
+
const u = r.map(
|
|
292
|
+
(d) => {
|
|
293
|
+
(!o || o < 2.00703) && (d = at(d));
|
|
294
|
+
const f = isFinite(d) ? t[d] : d === "c" ? n : (function() {
|
|
295
|
+
const m = d.match(/^b(\d+)$/);
|
|
296
|
+
if (m) return s[parseInt(m[1])];
|
|
297
|
+
const a = d.match(/^e(\d+)$/);
|
|
298
|
+
if (a) return e[parseInt(a[1])];
|
|
309
299
|
throw new Error("Bad index value for indexesToTri");
|
|
310
300
|
})();
|
|
311
|
-
return i ? [[
|
|
301
|
+
return i ? [[f[1], f[0]], d] : [[f[0], f[1]], d];
|
|
312
302
|
}
|
|
313
303
|
);
|
|
314
|
-
return
|
|
304
|
+
return At(u);
|
|
305
|
+
}
|
|
306
|
+
function at(r) {
|
|
307
|
+
return typeof r == "number" ? r : r.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
|
|
315
308
|
}
|
|
316
|
-
function
|
|
317
|
-
return
|
|
309
|
+
function It(r, t) {
|
|
310
|
+
return t && t >= 2.00703 || Array.isArray(r[0]) ? r : r.map((e) => [
|
|
311
|
+
e.illstNodes,
|
|
312
|
+
e.mercNodes,
|
|
313
|
+
e.startEnd
|
|
314
|
+
]);
|
|
318
315
|
}
|
|
319
|
-
const
|
|
320
|
-
function
|
|
321
|
-
return !!(
|
|
316
|
+
const Z = 2.00703;
|
|
317
|
+
function St(r) {
|
|
318
|
+
return !!(r.version !== void 0 || !r.tins && r.points && r.tins_points);
|
|
322
319
|
}
|
|
323
|
-
function
|
|
320
|
+
function Bt(r) {
|
|
324
321
|
return {
|
|
325
|
-
points:
|
|
326
|
-
pointsWeightBuffer:
|
|
327
|
-
strictStatus:
|
|
328
|
-
verticesParams:
|
|
329
|
-
centroid:
|
|
330
|
-
edges:
|
|
331
|
-
edgeNodes:
|
|
332
|
-
tins: Nt(
|
|
333
|
-
kinks:
|
|
334
|
-
yaxisMode:
|
|
335
|
-
strictMode:
|
|
336
|
-
vertexMode:
|
|
337
|
-
bounds:
|
|
338
|
-
boundsPolygon:
|
|
339
|
-
wh:
|
|
340
|
-
xy:
|
|
322
|
+
points: r.points,
|
|
323
|
+
pointsWeightBuffer: Pt(r),
|
|
324
|
+
strictStatus: Ot(r),
|
|
325
|
+
verticesParams: Rt(r),
|
|
326
|
+
centroid: kt(r),
|
|
327
|
+
edges: It(r.edges || []),
|
|
328
|
+
edgeNodes: r.edgeNodes || [],
|
|
329
|
+
tins: Nt(r),
|
|
330
|
+
kinks: Xt(r.kinks_points),
|
|
331
|
+
yaxisMode: r.yaxisMode ?? "invert",
|
|
332
|
+
strictMode: r.strictMode ?? "auto",
|
|
333
|
+
vertexMode: r.vertexMode,
|
|
334
|
+
bounds: r.bounds,
|
|
335
|
+
boundsPolygon: r.boundsPolygon,
|
|
336
|
+
wh: r.wh,
|
|
337
|
+
xy: r.xy ?? [0, 0]
|
|
341
338
|
};
|
|
342
339
|
}
|
|
343
|
-
function
|
|
344
|
-
const
|
|
340
|
+
function Ct(r) {
|
|
341
|
+
const t = Wt(r), e = t.tins;
|
|
345
342
|
return {
|
|
346
|
-
compiled:
|
|
347
|
-
tins:
|
|
348
|
-
points:
|
|
349
|
-
strictStatus:
|
|
350
|
-
pointsWeightBuffer:
|
|
351
|
-
verticesParams:
|
|
352
|
-
centroid:
|
|
353
|
-
kinks:
|
|
343
|
+
compiled: t,
|
|
344
|
+
tins: e,
|
|
345
|
+
points: Lt(e),
|
|
346
|
+
strictStatus: t.strict_status,
|
|
347
|
+
pointsWeightBuffer: t.weight_buffer,
|
|
348
|
+
verticesParams: t.vertices_params,
|
|
349
|
+
centroid: t.centroid,
|
|
350
|
+
kinks: t.kinks
|
|
354
351
|
};
|
|
355
352
|
}
|
|
356
|
-
function
|
|
357
|
-
return !
|
|
358
|
-
const n =
|
|
359
|
-
return n && (e
|
|
360
|
-
const
|
|
361
|
-
return
|
|
362
|
-
}, {})),
|
|
363
|
-
}, {}) :
|
|
364
|
-
}
|
|
365
|
-
function
|
|
366
|
-
return
|
|
367
|
-
}
|
|
368
|
-
function
|
|
369
|
-
const
|
|
370
|
-
forw: [
|
|
371
|
-
bakw: [
|
|
353
|
+
function Pt(r) {
|
|
354
|
+
return !r.version || r.version < Z ? ["forw", "bakw"].reduce((t, e) => {
|
|
355
|
+
const n = r.weight_buffer[e];
|
|
356
|
+
return n && (t[e] = Object.keys(n).reduce((s, i) => {
|
|
357
|
+
const o = at(i);
|
|
358
|
+
return s[o] = n[i], s;
|
|
359
|
+
}, {})), t;
|
|
360
|
+
}, {}) : r.weight_buffer;
|
|
361
|
+
}
|
|
362
|
+
function Ot(r) {
|
|
363
|
+
return r.strict_status ? r.strict_status : r.kinks_points ? "strict_error" : r.tins_points.length === 2 ? "loose" : "strict";
|
|
364
|
+
}
|
|
365
|
+
function Rt(r) {
|
|
366
|
+
const t = {
|
|
367
|
+
forw: [r.vertices_params[0]],
|
|
368
|
+
bakw: [r.vertices_params[1]]
|
|
372
369
|
};
|
|
373
|
-
return
|
|
374
|
-
}
|
|
375
|
-
function
|
|
376
|
-
const
|
|
377
|
-
return Array.from({ length:
|
|
378
|
-
const i = (
|
|
379
|
-
["c", `b${
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
370
|
+
return t.forw[1] = rt(r, !1), t.bakw[1] = rt(r, !0), t;
|
|
371
|
+
}
|
|
372
|
+
function rt(r, t) {
|
|
373
|
+
const e = r.vertices_points.length;
|
|
374
|
+
return Array.from({ length: e }, (n, s) => {
|
|
375
|
+
const i = (s + 1) % e, o = G(
|
|
376
|
+
["c", `b${s}`, `b${i}`],
|
|
377
|
+
r.points,
|
|
378
|
+
r.edgeNodes || [],
|
|
379
|
+
r.centroid_point,
|
|
380
|
+
r.vertices_points,
|
|
381
|
+
t,
|
|
382
|
+
Z
|
|
386
383
|
);
|
|
387
|
-
return
|
|
384
|
+
return U([o]);
|
|
388
385
|
});
|
|
389
386
|
}
|
|
390
|
-
function
|
|
387
|
+
function kt(r) {
|
|
391
388
|
return {
|
|
392
|
-
forw: X(
|
|
389
|
+
forw: X(r.centroid_point[0], {
|
|
393
390
|
target: {
|
|
394
|
-
geom:
|
|
391
|
+
geom: r.centroid_point[1],
|
|
395
392
|
index: "c"
|
|
396
393
|
}
|
|
397
394
|
}),
|
|
398
|
-
bakw: X(
|
|
395
|
+
bakw: X(r.centroid_point[1], {
|
|
399
396
|
target: {
|
|
400
|
-
geom:
|
|
397
|
+
geom: r.centroid_point[0],
|
|
401
398
|
index: "c"
|
|
402
399
|
}
|
|
403
400
|
})
|
|
404
401
|
};
|
|
405
402
|
}
|
|
406
|
-
function Nt(
|
|
407
|
-
const
|
|
403
|
+
function Nt(r) {
|
|
404
|
+
const t = r.tins_points.length === 1 ? 0 : 1;
|
|
408
405
|
return {
|
|
409
|
-
forw:
|
|
410
|
-
|
|
411
|
-
(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
406
|
+
forw: U(
|
|
407
|
+
r.tins_points[0].map(
|
|
408
|
+
(e) => G(
|
|
409
|
+
e,
|
|
410
|
+
r.points,
|
|
411
|
+
r.edgeNodes || [],
|
|
412
|
+
r.centroid_point,
|
|
413
|
+
r.vertices_points,
|
|
417
414
|
!1,
|
|
418
|
-
|
|
415
|
+
r.version
|
|
419
416
|
)
|
|
420
417
|
)
|
|
421
418
|
),
|
|
422
|
-
bakw:
|
|
423
|
-
|
|
424
|
-
(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
419
|
+
bakw: U(
|
|
420
|
+
r.tins_points[t].map(
|
|
421
|
+
(e) => G(
|
|
422
|
+
e,
|
|
423
|
+
r.points,
|
|
424
|
+
r.edgeNodes || [],
|
|
425
|
+
r.centroid_point,
|
|
426
|
+
r.vertices_points,
|
|
430
427
|
!0,
|
|
431
|
-
|
|
428
|
+
r.version
|
|
432
429
|
)
|
|
433
430
|
)
|
|
434
431
|
)
|
|
435
432
|
};
|
|
436
433
|
}
|
|
437
|
-
function
|
|
438
|
-
if (
|
|
434
|
+
function Xt(r) {
|
|
435
|
+
if (r)
|
|
439
436
|
return {
|
|
440
|
-
bakw:
|
|
441
|
-
|
|
437
|
+
bakw: U(
|
|
438
|
+
r.map((t) => X(t))
|
|
442
439
|
)
|
|
443
440
|
};
|
|
444
441
|
}
|
|
445
|
-
function
|
|
442
|
+
function Wt(r) {
|
|
446
443
|
return JSON.parse(
|
|
447
|
-
JSON.stringify(
|
|
444
|
+
JSON.stringify(r).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"')
|
|
448
445
|
);
|
|
449
446
|
}
|
|
450
|
-
function
|
|
451
|
-
const
|
|
452
|
-
for (let n = 0; n <
|
|
453
|
-
const
|
|
454
|
-
["a", "b", "c"].forEach((i,
|
|
455
|
-
const
|
|
456
|
-
typeof
|
|
447
|
+
function Lt(r) {
|
|
448
|
+
const t = [], e = r.forw.features;
|
|
449
|
+
for (let n = 0; n < e.length; n++) {
|
|
450
|
+
const s = e[n];
|
|
451
|
+
["a", "b", "c"].forEach((i, o) => {
|
|
452
|
+
const u = s.geometry.coordinates[0][o], d = s.properties[i].geom, f = s.properties[i].index;
|
|
453
|
+
typeof f == "number" && (t[f] = [u, d]);
|
|
457
454
|
});
|
|
458
455
|
}
|
|
459
|
-
return
|
|
456
|
+
return t;
|
|
460
457
|
}
|
|
461
|
-
const
|
|
458
|
+
const Yt = Z;
|
|
459
|
+
class I {
|
|
460
|
+
/**
|
|
461
|
+
* 各種モードの定数定義
|
|
462
|
+
* すべてreadonlyで、型安全性を確保
|
|
463
|
+
*/
|
|
464
|
+
static VERTEX_PLAIN = "plain";
|
|
465
|
+
static VERTEX_BIRDEYE = "birdeye";
|
|
466
|
+
static MODE_STRICT = "strict";
|
|
467
|
+
static MODE_AUTO = "auto";
|
|
468
|
+
static MODE_LOOSE = "loose";
|
|
469
|
+
static STATUS_STRICT = "strict";
|
|
470
|
+
static STATUS_ERROR = "strict_error";
|
|
471
|
+
static STATUS_LOOSE = "loose";
|
|
472
|
+
static YAXIS_FOLLOW = "follow";
|
|
473
|
+
static YAXIS_INVERT = "invert";
|
|
474
|
+
points = [];
|
|
475
|
+
pointsWeightBuffer;
|
|
476
|
+
strict_status;
|
|
477
|
+
vertices_params;
|
|
478
|
+
centroid;
|
|
479
|
+
edgeNodes;
|
|
480
|
+
edges;
|
|
481
|
+
tins;
|
|
482
|
+
kinks;
|
|
483
|
+
yaxisMode = I.YAXIS_INVERT;
|
|
484
|
+
strictMode = I.MODE_AUTO;
|
|
485
|
+
vertexMode = I.VERTEX_PLAIN;
|
|
486
|
+
bounds;
|
|
487
|
+
boundsPolygon;
|
|
488
|
+
wh;
|
|
489
|
+
xy;
|
|
490
|
+
indexedTins;
|
|
491
|
+
stateFull = !1;
|
|
492
|
+
stateTriangle;
|
|
493
|
+
stateBackward;
|
|
494
|
+
/**
|
|
495
|
+
* Optional properties for MaplatCore extension
|
|
496
|
+
* These properties allow consuming applications to extend Transform instances
|
|
497
|
+
* with additional metadata without requiring Module Augmentation
|
|
498
|
+
*/
|
|
499
|
+
/** Layer priority for rendering order */
|
|
500
|
+
priority;
|
|
501
|
+
/** Layer importance for display decisions */
|
|
502
|
+
importance;
|
|
503
|
+
/** Bounds in XY (source) coordinate system */
|
|
504
|
+
xyBounds;
|
|
505
|
+
/** Bounds in Mercator (Web Mercator) coordinate system */
|
|
506
|
+
mercBounds;
|
|
462
507
|
constructor() {
|
|
463
|
-
x(this, "points", []);
|
|
464
|
-
x(this, "pointsWeightBuffer");
|
|
465
|
-
x(this, "strict_status");
|
|
466
|
-
x(this, "vertices_params");
|
|
467
|
-
x(this, "centroid");
|
|
468
|
-
x(this, "edgeNodes");
|
|
469
|
-
x(this, "edges");
|
|
470
|
-
x(this, "tins");
|
|
471
|
-
x(this, "kinks");
|
|
472
|
-
x(this, "yaxisMode", E.YAXIS_INVERT);
|
|
473
|
-
x(this, "strictMode", E.MODE_AUTO);
|
|
474
|
-
x(this, "vertexMode", E.VERTEX_PLAIN);
|
|
475
|
-
x(this, "bounds");
|
|
476
|
-
x(this, "boundsPolygon");
|
|
477
|
-
x(this, "wh");
|
|
478
|
-
x(this, "xy");
|
|
479
|
-
x(this, "indexedTins");
|
|
480
|
-
x(this, "stateFull", !1);
|
|
481
|
-
x(this, "stateTriangle");
|
|
482
|
-
x(this, "stateBackward");
|
|
483
|
-
/**
|
|
484
|
-
* Optional properties for MaplatCore extension
|
|
485
|
-
* These properties allow consuming applications to extend Transform instances
|
|
486
|
-
* with additional metadata without requiring Module Augmentation
|
|
487
|
-
*/
|
|
488
|
-
/** Layer priority for rendering order */
|
|
489
|
-
x(this, "priority");
|
|
490
|
-
/** Layer importance for display decisions */
|
|
491
|
-
x(this, "importance");
|
|
492
|
-
/** Bounds in XY (source) coordinate system */
|
|
493
|
-
x(this, "xyBounds");
|
|
494
|
-
/** Bounds in Mercator (Web Mercator) coordinate system */
|
|
495
|
-
x(this, "mercBounds");
|
|
496
508
|
}
|
|
497
509
|
/**
|
|
498
510
|
* コンパイルされた設定を適用します
|
|
499
|
-
*
|
|
511
|
+
*
|
|
500
512
|
* @param compiled - コンパイルされた設定オブジェクト
|
|
501
513
|
* @returns 変換に必要な主要なオブジェクトのセット
|
|
502
|
-
*
|
|
514
|
+
*
|
|
503
515
|
* 以下の処理を行います:
|
|
504
516
|
* 1. バージョンに応じた設定の解釈
|
|
505
517
|
* 2. 各種パラメータの復元
|
|
506
518
|
* 3. TINネットワークの再構築
|
|
507
519
|
* 4. インデックスの作成
|
|
508
520
|
*/
|
|
509
|
-
setCompiled(
|
|
510
|
-
if (
|
|
511
|
-
this.applyModernState(
|
|
521
|
+
setCompiled(t) {
|
|
522
|
+
if (St(t)) {
|
|
523
|
+
this.applyModernState(Bt(t));
|
|
512
524
|
return;
|
|
513
525
|
}
|
|
514
|
-
this.applyLegacyState(
|
|
526
|
+
this.applyLegacyState(Ct(t));
|
|
515
527
|
}
|
|
516
|
-
applyModernState(
|
|
517
|
-
this.points =
|
|
528
|
+
applyModernState(t) {
|
|
529
|
+
this.points = t.points, this.pointsWeightBuffer = t.pointsWeightBuffer, this.strict_status = t.strictStatus, this.vertices_params = t.verticesParams, this.centroid = t.centroid, this.edges = t.edges, this.edgeNodes = t.edgeNodes || [], this.tins = t.tins, this.addIndexedTin(), this.kinks = t.kinks, this.yaxisMode = t.yaxisMode ?? I.YAXIS_INVERT, this.vertexMode = t.vertexMode ?? I.VERTEX_PLAIN, this.strictMode = t.strictMode ?? I.MODE_AUTO, t.bounds ? (this.bounds = t.bounds, this.boundsPolygon = t.boundsPolygon, this.xy = t.xy, this.wh = t.wh) : (this.bounds = void 0, this.boundsPolygon = void 0, this.xy = t.xy ?? [0, 0], t.wh && (this.wh = t.wh));
|
|
518
530
|
}
|
|
519
|
-
applyLegacyState(
|
|
520
|
-
this.tins =
|
|
531
|
+
applyLegacyState(t) {
|
|
532
|
+
this.tins = t.tins, this.addIndexedTin(), this.strict_status = t.strictStatus, this.pointsWeightBuffer = t.pointsWeightBuffer, this.vertices_params = t.verticesParams, this.centroid = t.centroid, this.kinks = t.kinks, this.points = t.points;
|
|
521
533
|
}
|
|
522
534
|
/**
|
|
523
535
|
* TINネットワークのインデックスを作成します
|
|
524
|
-
*
|
|
536
|
+
*
|
|
525
537
|
* インデックスは変換処理を高速化するために使用されます。
|
|
526
538
|
* グリッド形式のインデックスを作成し、各グリッドに
|
|
527
539
|
* 含まれる三角形を記録します。
|
|
528
540
|
*/
|
|
529
541
|
addIndexedTin() {
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
542
|
+
const t = this.tins, e = t.forw, n = t.bakw, s = Math.ceil(Math.sqrt(e.features.length));
|
|
543
|
+
if (s < 3) {
|
|
532
544
|
this.indexedTins = void 0;
|
|
533
545
|
return;
|
|
534
546
|
}
|
|
535
|
-
let i = [],
|
|
536
|
-
const
|
|
537
|
-
let
|
|
538
|
-
return
|
|
539
|
-
i.length === 0 ? i = [Array.from(
|
|
540
|
-
}),
|
|
541
|
-
}),
|
|
542
|
-
(
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
), M = B(
|
|
549
|
-
a[1][0],
|
|
550
|
-
i[0][0],
|
|
551
|
-
h,
|
|
552
|
-
c
|
|
553
|
-
), v = B(
|
|
554
|
-
a[0][1],
|
|
555
|
-
i[0][1],
|
|
556
|
-
l,
|
|
557
|
-
c
|
|
558
|
-
), _ = B(
|
|
559
|
-
a[1][1],
|
|
560
|
-
i[0][1],
|
|
561
|
-
l,
|
|
562
|
-
c
|
|
563
|
-
);
|
|
564
|
-
for (let w = m; w <= M; w++) {
|
|
565
|
-
d[w] || (d[w] = []);
|
|
566
|
-
for (let A = v; A <= _; A++)
|
|
567
|
-
d[w][A] || (d[w][A] = []), d[w][A].push(s);
|
|
547
|
+
let i = [], o = [];
|
|
548
|
+
const u = e.features.map((y) => {
|
|
549
|
+
let h = [];
|
|
550
|
+
return J(y)[0].map((c) => {
|
|
551
|
+
i.length === 0 ? i = [Array.from(c), Array.from(c)] : (c[0] < i[0][0] && (i[0][0] = c[0]), c[0] > i[1][0] && (i[1][0] = c[0]), c[1] < i[0][1] && (i[0][1] = c[1]), c[1] > i[1][1] && (i[1][1] = c[1])), h.length === 0 ? h = [Array.from(c), Array.from(c)] : (c[0] < h[0][0] && (h[0][0] = c[0]), c[0] > h[1][0] && (h[1][0] = c[0]), c[1] < h[0][1] && (h[0][1] = c[1]), c[1] > h[1][1] && (h[1][1] = c[1]));
|
|
552
|
+
}), h;
|
|
553
|
+
}), d = (i[1][0] - i[0][0]) / s, f = (i[1][1] - i[0][1]) / s, m = u.reduce(
|
|
554
|
+
(y, h, c) => {
|
|
555
|
+
const x = O(h[0][0], i[0][0], d, s), w = O(h[1][0], i[0][0], d, s), M = O(h[0][1], i[0][1], f, s), v = O(h[1][1], i[0][1], f, s);
|
|
556
|
+
for (let p = x; p <= w; p++) {
|
|
557
|
+
y[p] || (y[p] = []);
|
|
558
|
+
for (let _ = M; _ <= v; _++)
|
|
559
|
+
y[p][_] || (y[p][_] = []), y[p][_].push(c);
|
|
568
560
|
}
|
|
569
|
-
return
|
|
561
|
+
return y;
|
|
570
562
|
},
|
|
571
563
|
[]
|
|
572
|
-
),
|
|
573
|
-
let
|
|
574
|
-
return
|
|
575
|
-
|
|
576
|
-
}),
|
|
577
|
-
}),
|
|
578
|
-
(
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
), M = B(
|
|
585
|
-
a[1][0],
|
|
586
|
-
u[0][0],
|
|
587
|
-
f,
|
|
588
|
-
c
|
|
589
|
-
), v = B(
|
|
590
|
-
a[0][1],
|
|
591
|
-
u[0][1],
|
|
592
|
-
b,
|
|
593
|
-
c
|
|
594
|
-
), _ = B(
|
|
595
|
-
a[1][1],
|
|
596
|
-
u[0][1],
|
|
597
|
-
b,
|
|
598
|
-
c
|
|
599
|
-
);
|
|
600
|
-
for (let w = m; w <= M; w++) {
|
|
601
|
-
d[w] || (d[w] = []);
|
|
602
|
-
for (let A = v; A <= _; A++)
|
|
603
|
-
d[w][A] || (d[w][A] = []), d[w][A].push(s);
|
|
564
|
+
), a = n.features.map((y) => {
|
|
565
|
+
let h = [];
|
|
566
|
+
return J(y)[0].map((c) => {
|
|
567
|
+
o.length === 0 ? o = [Array.from(c), Array.from(c)] : (c[0] < o[0][0] && (o[0][0] = c[0]), c[0] > o[1][0] && (o[1][0] = c[0]), c[1] < o[0][1] && (o[0][1] = c[1]), c[1] > o[1][1] && (o[1][1] = c[1])), h.length === 0 ? h = [Array.from(c), Array.from(c)] : (c[0] < h[0][0] && (h[0][0] = c[0]), c[0] > h[1][0] && (h[1][0] = c[0]), c[1] < h[0][1] && (h[0][1] = c[1]), c[1] > h[1][1] && (h[1][1] = c[1]));
|
|
568
|
+
}), h;
|
|
569
|
+
}), l = (o[1][0] - o[0][0]) / s, g = (o[1][1] - o[0][1]) / s, b = a.reduce(
|
|
570
|
+
(y, h, c) => {
|
|
571
|
+
const x = O(h[0][0], o[0][0], l, s), w = O(h[1][0], o[0][0], l, s), M = O(h[0][1], o[0][1], g, s), v = O(h[1][1], o[0][1], g, s);
|
|
572
|
+
for (let p = x; p <= w; p++) {
|
|
573
|
+
y[p] || (y[p] = []);
|
|
574
|
+
for (let _ = M; _ <= v; _++)
|
|
575
|
+
y[p][_] || (y[p][_] = []), y[p][_].push(c);
|
|
604
576
|
}
|
|
605
|
-
return
|
|
577
|
+
return y;
|
|
606
578
|
},
|
|
607
579
|
[]
|
|
608
580
|
);
|
|
609
581
|
this.indexedTins = {
|
|
610
582
|
forw: {
|
|
611
|
-
gridNum:
|
|
583
|
+
gridNum: s,
|
|
612
584
|
xOrigin: i[0][0],
|
|
613
585
|
yOrigin: i[0][1],
|
|
614
|
-
xUnit:
|
|
615
|
-
yUnit:
|
|
616
|
-
gridCache:
|
|
586
|
+
xUnit: d,
|
|
587
|
+
yUnit: f,
|
|
588
|
+
gridCache: m
|
|
617
589
|
},
|
|
618
590
|
bakw: {
|
|
619
|
-
gridNum:
|
|
620
|
-
xOrigin:
|
|
621
|
-
yOrigin:
|
|
622
|
-
xUnit:
|
|
623
|
-
yUnit:
|
|
624
|
-
gridCache:
|
|
591
|
+
gridNum: s,
|
|
592
|
+
xOrigin: o[0][0],
|
|
593
|
+
yOrigin: o[0][1],
|
|
594
|
+
xUnit: l,
|
|
595
|
+
yUnit: g,
|
|
596
|
+
gridCache: b
|
|
625
597
|
}
|
|
626
598
|
};
|
|
627
599
|
}
|
|
628
600
|
/**
|
|
629
601
|
* 座標変換を実行します
|
|
630
|
-
*
|
|
602
|
+
*
|
|
631
603
|
* @param apoint - 変換する座標
|
|
632
604
|
* @param backward - 逆方向の変換かどうか
|
|
633
605
|
* @param ignoreBounds - 境界チェックを無視するかどうか
|
|
634
606
|
* @returns 変換後の座標、または境界外の場合はfalse
|
|
635
|
-
*
|
|
607
|
+
*
|
|
636
608
|
* @throws {Error} 逆方向変換が許可されていない状態での逆変換時
|
|
637
609
|
*/
|
|
638
|
-
transform(
|
|
610
|
+
transform(t, e, n) {
|
|
639
611
|
if (!this.tins)
|
|
640
612
|
throw new Error("setCompiled() must be called before transform()");
|
|
641
|
-
if (
|
|
613
|
+
if (e && this.strict_status == I.STATUS_ERROR)
|
|
642
614
|
throw new Error('Backward transform is not allowed if strict_status == "strict_error"');
|
|
643
|
-
this.yaxisMode ==
|
|
644
|
-
const
|
|
645
|
-
if (this.bounds && !
|
|
615
|
+
this.yaxisMode == I.YAXIS_FOLLOW && e && (t = [t[0], -1 * t[1]]);
|
|
616
|
+
const s = X(t);
|
|
617
|
+
if (this.bounds && !e && !n && !L(s, this.boundsPolygon))
|
|
646
618
|
return !1;
|
|
647
|
-
const i =
|
|
648
|
-
let
|
|
649
|
-
this.stateFull && (this.stateBackward ==
|
|
650
|
-
this.stateTriangle =
|
|
619
|
+
const i = e ? this.tins.bakw : this.tins.forw, o = e ? this.indexedTins.bakw : this.indexedTins.forw, u = e ? this.vertices_params.bakw : this.vertices_params.forw, d = e ? this.centroid.bakw : this.centroid.forw, f = e ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
|
|
620
|
+
let m, a;
|
|
621
|
+
this.stateFull && (this.stateBackward == e ? m = this.stateTriangle : (this.stateBackward = e, this.stateTriangle = void 0), a = (g) => {
|
|
622
|
+
this.stateTriangle = g;
|
|
651
623
|
});
|
|
652
|
-
let
|
|
653
|
-
|
|
624
|
+
let l = Tt(
|
|
625
|
+
s,
|
|
654
626
|
i,
|
|
627
|
+
o,
|
|
655
628
|
u,
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
o
|
|
629
|
+
d,
|
|
630
|
+
f,
|
|
631
|
+
m,
|
|
632
|
+
a
|
|
661
633
|
);
|
|
662
|
-
if (this.bounds &&
|
|
663
|
-
const
|
|
664
|
-
if (
|
|
665
|
-
} else this.yaxisMode ==
|
|
666
|
-
return
|
|
634
|
+
if (this.bounds && e && !n) {
|
|
635
|
+
const g = X(l);
|
|
636
|
+
if (!L(g, this.boundsPolygon)) return !1;
|
|
637
|
+
} else this.yaxisMode == I.YAXIS_FOLLOW && !e && (l = [l[0], -1 * l[1]]);
|
|
638
|
+
return l;
|
|
667
639
|
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
640
|
+
}
|
|
641
|
+
const R = 20037508342789244e-9, Ut = [
|
|
642
|
+
[0, 0],
|
|
643
|
+
[0, 1],
|
|
644
|
+
[1, 0],
|
|
645
|
+
[0, -1],
|
|
646
|
+
[-1, 0]
|
|
647
|
+
];
|
|
648
|
+
function ct(r, t) {
|
|
649
|
+
return Math.floor(Math.min(r[0], r[1]) / 4) * R / 128 / Math.pow(2, t);
|
|
650
|
+
}
|
|
651
|
+
function Ft(r, t) {
|
|
652
|
+
const e = [];
|
|
653
|
+
for (let n = 0; n < r.length; n++) {
|
|
654
|
+
const s = r[n], i = s[0] * Math.cos(t) - s[1] * Math.sin(t), o = s[0] * Math.sin(t) + s[1] * Math.cos(t);
|
|
655
|
+
e.push([i, o]);
|
|
656
|
+
}
|
|
657
|
+
return e;
|
|
658
|
+
}
|
|
659
|
+
function et(r, t, e, n) {
|
|
660
|
+
const s = ct(n, t);
|
|
661
|
+
return Ft(Ut, e).map((u) => [
|
|
662
|
+
u[0] * s + r[0],
|
|
663
|
+
u[1] * s + r[1]
|
|
664
|
+
]);
|
|
665
|
+
}
|
|
666
|
+
function nt(r, t) {
|
|
667
|
+
const e = r[0], s = r.slice(1, 5).map((g) => [
|
|
668
|
+
g[0] - e[0],
|
|
669
|
+
g[1] - e[1]
|
|
670
|
+
]), i = [
|
|
671
|
+
[0, 1],
|
|
672
|
+
[1, 0],
|
|
673
|
+
[0, -1],
|
|
674
|
+
[-1, 0]
|
|
675
|
+
];
|
|
676
|
+
let o = 0, u = 0, d = 0;
|
|
677
|
+
for (let g = 0; g < 4; g++) {
|
|
678
|
+
const b = s[g], y = i[g], h = Math.sqrt(Math.pow(b[0], 2) + Math.pow(b[1], 2));
|
|
679
|
+
o += h;
|
|
680
|
+
const c = b[0] * y[1] - b[1] * y[0], x = Math.acos(
|
|
681
|
+
(b[0] * y[0] + b[1] * y[1]) / h
|
|
682
|
+
), w = c > 0 ? -1 * x : x;
|
|
683
|
+
u += Math.cos(w), d += Math.sin(w);
|
|
684
|
+
}
|
|
685
|
+
const f = o / 4, m = Math.atan2(d, u), a = Math.floor(Math.min(t[0], t[1]) / 4), l = Math.log(a * R / 128 / f) / Math.log(2);
|
|
686
|
+
return { center: e, zoom: l, rotation: m };
|
|
687
|
+
}
|
|
688
|
+
function q(r, t) {
|
|
689
|
+
const e = r[0] * (2 * R) / t - R, n = -1 * (r[1] * (2 * R) / t - R);
|
|
690
|
+
return [e, n];
|
|
691
|
+
}
|
|
692
|
+
function st(r, t) {
|
|
693
|
+
const e = (r[0] + R) * t / (2 * R), n = (-r[1] + R) * t / (2 * R);
|
|
694
|
+
return [e, n];
|
|
695
|
+
}
|
|
696
|
+
const z = 256;
|
|
697
|
+
class $t {
|
|
698
|
+
mainTin = null;
|
|
699
|
+
subTins = [];
|
|
700
|
+
_maxxy = 0;
|
|
701
|
+
// ─── 初期化 ────────────────────────────────────────────────────────────────
|
|
702
|
+
/**
|
|
703
|
+
* 地図データ(コンパイル済み TIN + sub_maps)をロードする
|
|
704
|
+
*
|
|
705
|
+
* @param mapData - メイン TIN と sub_maps の情報
|
|
706
|
+
*/
|
|
707
|
+
setMapData(t) {
|
|
708
|
+
const e = new I();
|
|
709
|
+
if (e.setCompiled(t.compiled), this.mainTin = e, t.maxZoom !== void 0)
|
|
710
|
+
this._maxxy = Math.pow(2, t.maxZoom) * z;
|
|
711
|
+
else if (t.compiled.wh) {
|
|
712
|
+
const n = Math.max(t.compiled.wh[0], t.compiled.wh[1]), s = Math.ceil(Math.log2(n / z));
|
|
713
|
+
this._maxxy = Math.pow(2, s) * z;
|
|
714
|
+
}
|
|
715
|
+
if (this.subTins = [], t.sub_maps)
|
|
716
|
+
for (const n of t.sub_maps) {
|
|
717
|
+
const s = new I();
|
|
718
|
+
s.setCompiled(n.compiled);
|
|
719
|
+
const i = n.bounds ?? n.compiled.bounds;
|
|
720
|
+
if (!i)
|
|
721
|
+
throw new Error(
|
|
722
|
+
"SubMapData must have bounds or compiled.bounds to create xyBounds polygon"
|
|
723
|
+
);
|
|
724
|
+
const o = [...i, i[0]], u = o.map((d) => {
|
|
725
|
+
const f = s.transform(d, !1);
|
|
726
|
+
if (!f) throw new Error("Failed to transform sub-map bounds to mercator");
|
|
727
|
+
return f;
|
|
728
|
+
});
|
|
729
|
+
this.subTins.push({
|
|
730
|
+
tin: s,
|
|
731
|
+
priority: n.priority,
|
|
732
|
+
importance: n.importance,
|
|
733
|
+
xyBounds: D([o]),
|
|
734
|
+
mercBounds: D([u])
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
// ─── 処理2: submap TIN 選択付き変換 ───────────────────────────────────────
|
|
739
|
+
/**
|
|
740
|
+
* ピクセル座標 → メルカトル座標(最適レイヤー選択)
|
|
741
|
+
*
|
|
742
|
+
* @param xy - ピクセル座標 [x, y]
|
|
743
|
+
* @returns メルカトル座標、または範囲外の場合は false
|
|
744
|
+
*/
|
|
745
|
+
xy2Merc(t) {
|
|
746
|
+
const e = this.xy2MercWithLayer(t);
|
|
747
|
+
return e ? e[1] : !1;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* メルカトル座標 → ピクセル座標(最適レイヤー選択)
|
|
751
|
+
*
|
|
752
|
+
* @param merc - メルカトル座標 [x, y]
|
|
753
|
+
* @returns ピクセル座標、または範囲外の場合は false
|
|
754
|
+
*/
|
|
755
|
+
merc2Xy(t) {
|
|
756
|
+
const e = this.merc2XyWithLayer(t), n = e[0] || e[1];
|
|
757
|
+
return n ? n[1] : !1;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* ピクセル座標 → メルカトル座標(レイヤーID付き)
|
|
761
|
+
* histmap_tin.ts xy2MercAsync_returnLayer() の同期版
|
|
762
|
+
*
|
|
763
|
+
* @param xy - ピクセル座標 [x, y]
|
|
764
|
+
* @returns [レイヤーインデックス, メルカトル座標] または false
|
|
765
|
+
*/
|
|
766
|
+
xy2MercWithLayer(t) {
|
|
767
|
+
this._assertMapData();
|
|
768
|
+
const e = this._getTinsSortedByPriority();
|
|
769
|
+
for (let n = 0; n < e.length; n++) {
|
|
770
|
+
const { index: s, isMain: i } = e[n];
|
|
771
|
+
if (i || L(X(t), this.subTins[s - 1].xyBounds)) {
|
|
772
|
+
const o = this._transformByIndex(t, s, !1);
|
|
773
|
+
if (o === !1) continue;
|
|
774
|
+
return [s, o];
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return !1;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* メルカトル座標 → ピクセル座標(複数レイヤー結果)
|
|
781
|
+
* histmap_tin.ts merc2XyAsync_returnLayer() の同期版
|
|
782
|
+
*
|
|
783
|
+
* 現在は MaplatCore の仕様に合わせ、最大2レイヤーまで返す。
|
|
784
|
+
* 3レイヤー以上返したい場合は、下記の .slice(0, 2) および .filter(i < 2) の
|
|
785
|
+
* 上限値を増やすか、引数で上限を指定できるようにすること。
|
|
786
|
+
*
|
|
787
|
+
* @param merc - メルカトル座標 [x, y]
|
|
788
|
+
* @returns 最大2要素の配列。各要素は [レイヤーインデックス, ピクセル座標] または undefined
|
|
789
|
+
*/
|
|
790
|
+
merc2XyWithLayer(t) {
|
|
791
|
+
return this._assertMapData(), this._getAllTinsWithIndex().map(({ index: o, tin: u, isMain: d }) => {
|
|
792
|
+
const f = this._transformByIndex(t, o, !0);
|
|
793
|
+
return f === !1 ? [u, o] : d || L(X(f), this.subTins[o - 1].xyBounds) ? [u, o, f] : [u, o];
|
|
794
|
+
}).sort((o, u) => {
|
|
795
|
+
const d = o[0].priority ?? 0, f = u[0].priority ?? 0;
|
|
796
|
+
return d < f ? 1 : -1;
|
|
797
|
+
}).reduce(
|
|
798
|
+
(o, u, d, f) => {
|
|
799
|
+
const m = u[0], a = u[1], l = u[2];
|
|
800
|
+
if (!l) return o;
|
|
801
|
+
for (let g = 0; g < d; g++) {
|
|
802
|
+
const b = f[g][1], y = b === 0;
|
|
803
|
+
if (f[g][2] && (y || L(X(l), this.subTins[b - 1].xyBounds)))
|
|
804
|
+
if (o.length) {
|
|
805
|
+
const h = !o[0], c = h ? o[1][2] : o[0][2], x = m.importance ?? 0, w = c.importance ?? 0;
|
|
806
|
+
return h ? x < w ? o : [void 0, [a, l, m]] : [...o.filter(
|
|
807
|
+
(p) => p !== void 0
|
|
808
|
+
), [a, l, m]].sort(
|
|
809
|
+
(p, _) => (p[2].importance ?? 0) < (_[2].importance ?? 0) ? 1 : -1
|
|
810
|
+
).slice(0, 2);
|
|
811
|
+
} else
|
|
812
|
+
return [[a, l, m]];
|
|
813
|
+
}
|
|
814
|
+
return !o.length || !o[0] ? [[a, l, m]] : (o.push([a, l, m]), o.sort((g, b) => {
|
|
815
|
+
const y = g[2].importance ?? 0, h = b[2].importance ?? 0;
|
|
816
|
+
return y < h ? 1 : -1;
|
|
817
|
+
}).filter((g, b) => b < 2));
|
|
818
|
+
},
|
|
819
|
+
[]
|
|
820
|
+
).map((o) => {
|
|
821
|
+
if (o)
|
|
822
|
+
return [o[0], o[1]];
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* メルカトル5点 → システム座標(複数レイヤー)
|
|
827
|
+
* histmap_tin.ts mercs2SysCoordsAsync_multiLayer() の同期版
|
|
828
|
+
*
|
|
829
|
+
* @param mercs - 5点のメルカトル座標配列(中心+上下左右)
|
|
830
|
+
* @returns 各レイヤーのシステム座標配列(または undefined)
|
|
831
|
+
*/
|
|
832
|
+
mercs2SysCoords(t) {
|
|
833
|
+
this._assertMapData();
|
|
834
|
+
const e = this.merc2XyWithLayer(t[0]);
|
|
835
|
+
let n = !1;
|
|
836
|
+
return e.map((s, i) => {
|
|
837
|
+
if (!s) {
|
|
838
|
+
n = !0;
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
const o = s[0], u = s[1];
|
|
842
|
+
return i !== 0 && !n ? [this.xy2SysCoordInternal(u)] : t.map((f, m) => m === 0 ? u : this._transformByIndex(f, o, !0)).map((f) => this.xy2SysCoordInternal(f));
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
// ─── 処理3: ビューポート変換 ───────────────────────────────────────────────
|
|
846
|
+
/**
|
|
847
|
+
* ビューポート → TIN 適用後メルカトル5点
|
|
848
|
+
* histmap_tin.ts viewpoint2MercsAsync() の同期版
|
|
849
|
+
*
|
|
850
|
+
* @param viewpoint - ビューポート(center, zoom, rotation)
|
|
851
|
+
* @param size - 画面サイズ [width, height]
|
|
852
|
+
* @returns TIN 変換後のメルカトル5点
|
|
853
|
+
*/
|
|
854
|
+
viewpoint2Mercs(t, e) {
|
|
855
|
+
this._assertMapData(), this._assertMaxxy();
|
|
856
|
+
const s = et(t.center, t.zoom, t.rotation, e).map((f) => st(f, this._maxxy)), i = this.xy2MercWithLayer(s[0]);
|
|
857
|
+
if (!i) throw new Error("viewpoint2Mercs: center point is out of bounds");
|
|
858
|
+
const o = i[0], u = i[1];
|
|
859
|
+
return s.map((f, m) => {
|
|
860
|
+
if (m === 0) return u;
|
|
861
|
+
const a = this._transformByIndex(f, o, !1);
|
|
862
|
+
if (a === !1) throw new Error(`viewpoint2Mercs: point ${m} is out of bounds`);
|
|
863
|
+
return a;
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* TIN 適用後メルカトル5点 → ビューポート
|
|
868
|
+
* histmap_tin.ts mercs2ViewpointAsync() の同期版
|
|
869
|
+
*
|
|
870
|
+
* @param mercs - TIN 変換後のメルカトル5点
|
|
871
|
+
* @param size - 画面サイズ [width, height]
|
|
872
|
+
* @returns ビューポート(center, zoom, rotation)
|
|
873
|
+
*/
|
|
874
|
+
mercs2Viewpoint(t, e) {
|
|
875
|
+
this._assertMapData(), this._assertMaxxy();
|
|
876
|
+
const n = this.merc2XyWithLayer(t[0]), s = n[0] || n[1];
|
|
877
|
+
if (!s) throw new Error("mercs2Viewpoint: center point is out of bounds");
|
|
878
|
+
const i = s[0], o = s[1], d = t.map((f, m) => {
|
|
879
|
+
if (m === 0) return o;
|
|
880
|
+
const a = this._transformByIndex(f, i, !0);
|
|
881
|
+
if (a === !1) throw new Error(`mercs2Viewpoint: point ${m} is out of bounds`);
|
|
882
|
+
return a;
|
|
883
|
+
}).map((f) => q(f, this._maxxy));
|
|
884
|
+
return nt(d, e);
|
|
885
|
+
}
|
|
886
|
+
// ─── ユーティリティ(静的メソッド)────────────────────────────────────────
|
|
887
|
+
/** zoom2Radius の静的ラッパー */
|
|
888
|
+
static zoom2Radius(t, e) {
|
|
889
|
+
return ct(t, e);
|
|
890
|
+
}
|
|
891
|
+
/** mercViewpoint2Mercs の静的ラッパー */
|
|
892
|
+
static mercViewpoint2Mercs(t, e, n, s) {
|
|
893
|
+
return et(t, e, n, s);
|
|
894
|
+
}
|
|
895
|
+
/** mercs2MercViewpoint の静的ラッパー */
|
|
896
|
+
static mercs2MercViewpoint(t, e) {
|
|
897
|
+
return nt(t, e);
|
|
898
|
+
}
|
|
899
|
+
/** xy2SysCoord の静的ラッパー */
|
|
900
|
+
static xy2SysCoord(t, e) {
|
|
901
|
+
return q(t, e);
|
|
902
|
+
}
|
|
903
|
+
/** sysCoord2Xy の静的ラッパー */
|
|
904
|
+
static sysCoord2Xy(t, e) {
|
|
905
|
+
return st(t, e);
|
|
906
|
+
}
|
|
907
|
+
// ─── 内部ヘルパー ──────────────────────────────────────────────────────────
|
|
908
|
+
_assertMapData() {
|
|
909
|
+
if (!this.mainTin)
|
|
910
|
+
throw new Error("setMapData() must be called before transformation");
|
|
911
|
+
}
|
|
912
|
+
_assertMaxxy() {
|
|
913
|
+
if (this._maxxy === 0)
|
|
914
|
+
throw new Error(
|
|
915
|
+
"MapData.maxZoom or compiled.wh must be set for viewpoint conversion (xy2SysCoord / sysCoord2Xy)"
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* レイヤーインデックスに対応する Transform インスタンスを返す(三角網描画などの用途)
|
|
920
|
+
*
|
|
921
|
+
* @param idx - 0 = メイン TIN、1以上 = sub_maps[idx-1]
|
|
922
|
+
* @returns 対応する Transform、または範囲外の場合は null
|
|
923
|
+
*/
|
|
924
|
+
getLayerTransform(t) {
|
|
925
|
+
if (t === 0) return this.mainTin;
|
|
926
|
+
const e = this.subTins[t - 1];
|
|
927
|
+
return e ? e.tin : null;
|
|
928
|
+
}
|
|
929
|
+
/** レイヤー数を返す(メイン + sub 数) */
|
|
930
|
+
get layerCount() {
|
|
931
|
+
return 1 + this.subTins.length;
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* viewpoint 変換に使用する最大ピクセル幅(2^maxZoom × 256)
|
|
935
|
+
* stateToViewpoint / viewpointToState で zoom ↔ scale 変換に使用する
|
|
936
|
+
* zoom = log2(scale × maxxy / 256) の関係
|
|
937
|
+
*/
|
|
938
|
+
get maxxy() {
|
|
939
|
+
return this._maxxy;
|
|
940
|
+
}
|
|
941
|
+
/** priority 降順でソートした [index, tin, isMain] の配列を返す */
|
|
942
|
+
_getTinsSortedByPriority() {
|
|
943
|
+
return this._getAllTinsWithIndex().sort((e, n) => {
|
|
944
|
+
const s = e.tin.priority ?? 0, i = n.tin.priority ?? 0;
|
|
945
|
+
return s < i ? 1 : -1;
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
/** メイン TIN + 全 sub TIN を index 付きで返す */
|
|
949
|
+
_getAllTinsWithIndex() {
|
|
950
|
+
const t = [
|
|
951
|
+
{ index: 0, tin: this.mainTin, isMain: !0 }
|
|
952
|
+
];
|
|
953
|
+
return this.subTins.forEach((e, n) => {
|
|
954
|
+
e.tin.priority = e.priority, e.tin.importance = e.importance, t.push({ index: n + 1, tin: e.tin, isMain: !1 });
|
|
955
|
+
}), t;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* 指定レイヤーインデックスで TIN 変換を実行する
|
|
959
|
+
* index 0 → mainTin, index 1..n → subTins[index-1]
|
|
960
|
+
*/
|
|
961
|
+
_transformByIndex(t, e, n) {
|
|
962
|
+
if (e === 0)
|
|
963
|
+
return this.mainTin.transform(t, n);
|
|
964
|
+
const s = this.subTins[e - 1];
|
|
965
|
+
return s ? s.tin.transform(t, n, !0) : !1;
|
|
966
|
+
}
|
|
967
|
+
/** 内部用 xy2SysCoord(_maxxy を使用) */
|
|
968
|
+
xy2SysCoordInternal(t) {
|
|
969
|
+
return q(t, this._maxxy);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
675
972
|
export {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
973
|
+
Ut as MERC_CROSSMATRIX,
|
|
974
|
+
R as MERC_MAX,
|
|
975
|
+
$t as MapTransform,
|
|
976
|
+
I as Transform,
|
|
977
|
+
Dt as counterTri,
|
|
978
|
+
Yt as format_version,
|
|
979
|
+
et as mercViewpoint2Mercs,
|
|
980
|
+
nt as mercs2MercViewpoint,
|
|
981
|
+
It as normalizeEdges,
|
|
982
|
+
Ft as rotateMatrix,
|
|
983
|
+
Vt as rotateVerticesTriangle,
|
|
984
|
+
st as sysCoord2Xy,
|
|
985
|
+
Tt as transformArr,
|
|
986
|
+
q as xy2SysCoord,
|
|
987
|
+
ct as zoom2Radius
|
|
682
988
|
};
|