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