@maplat/transform 0.4.1 → 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/LICENSE +224 -224
- package/README.ja.md +340 -170
- package/README.md +341 -171
- package/dist/index.d.ts +218 -1
- package/dist/maplat_transform.js +756 -459
- package/dist/maplat_transform.umd.js +1 -1
- package/package.json +3 -1
- package/src/compiled-state.ts +213 -211
- package/src/constants.ts +8 -0
- package/src/coord-utils.ts +27 -0
- package/src/edgeutils.ts +47 -47
- package/src/geometry.ts +240 -247
- package/src/index.ts +38 -398
- package/src/map-transform.ts +473 -0
- package/src/transform.ts +338 -0
- package/src/triangulation.ts +170 -179
- package/src/types.ts +162 -122
- package/src/viewpoint.ts +104 -0
package/dist/maplat_transform.js
CHANGED
|
@@ -1,234 +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 W(t, e
|
|
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
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
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
|
+
} else
|
|
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;
|
|
195
206
|
}
|
|
196
|
-
return
|
|
207
|
+
return s;
|
|
197
208
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
return
|
|
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;
|
|
201
212
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
for (let
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
return c;
|
|
209
|
-
}
|
|
210
|
-
function Q(t, e = !1) {
|
|
211
|
-
const r = e ? function(n) {
|
|
212
|
-
return !(n >= 0 && n < Math.PI * 2);
|
|
213
|
-
} : function(n) {
|
|
214
|
-
return !(n > -1 * Math.PI && n <= Math.PI);
|
|
215
|
-
};
|
|
216
|
-
for (; r(t); )
|
|
217
|
-
t = t + 2 * Math.PI * (t > 0 ? -1 : 1);
|
|
218
|
-
return t;
|
|
219
|
-
}
|
|
220
|
-
function At(t, e) {
|
|
221
|
-
return e && e >= 2.00703 || Array.isArray(t[0]) ? t : t.map((r) => [
|
|
222
|
-
r.illstNodes,
|
|
223
|
-
r.mercNodes,
|
|
224
|
-
r.startEnd
|
|
225
|
-
]);
|
|
226
|
-
}
|
|
227
|
-
function Ft(t) {
|
|
228
|
-
const e = t.features;
|
|
229
|
-
for (let r = 0; r < e.length; r++) {
|
|
230
|
-
const n = e[r];
|
|
231
|
-
`${n.properties.a.index}`.substring(0, 1) === "b" && `${n.properties.b.index}`.substring(0, 1) === "b" ? e[r] = {
|
|
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] = {
|
|
232
218
|
geometry: {
|
|
233
219
|
type: "Polygon",
|
|
234
220
|
coordinates: [
|
|
@@ -255,7 +241,7 @@ function Ft(t) {
|
|
|
255
241
|
}
|
|
256
242
|
},
|
|
257
243
|
type: "Feature"
|
|
258
|
-
} : `${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] = {
|
|
259
245
|
geometry: {
|
|
260
246
|
type: "Polygon",
|
|
261
247
|
coordinates: [
|
|
@@ -284,404 +270,715 @@ function Ft(t) {
|
|
|
284
270
|
type: "Feature"
|
|
285
271
|
});
|
|
286
272
|
}
|
|
287
|
-
return
|
|
273
|
+
return r;
|
|
288
274
|
}
|
|
289
|
-
function
|
|
290
|
-
const
|
|
291
|
-
(i) =>
|
|
292
|
-
),
|
|
293
|
-
a: { geom:
|
|
294
|
-
b: { geom:
|
|
295
|
-
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 }
|
|
296
282
|
};
|
|
297
|
-
return
|
|
283
|
+
return Y([t], s);
|
|
298
284
|
}
|
|
299
|
-
function
|
|
300
|
-
const
|
|
301
|
-
a: { geom:
|
|
302
|
-
b: { geom:
|
|
303
|
-
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] }
|
|
304
290
|
};
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
(
|
|
310
|
-
(!
|
|
311
|
-
const
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
throw "Bad index value for indexesToTri";
|
|
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])];
|
|
302
|
+
throw new Error("Bad index value for indexesToTri");
|
|
318
303
|
})();
|
|
319
|
-
return i ? [[
|
|
304
|
+
return i ? [[f[1], f[0]], d] : [[f[0], f[1]], d];
|
|
320
305
|
}
|
|
321
306
|
);
|
|
322
|
-
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");
|
|
323
311
|
}
|
|
324
|
-
function
|
|
325
|
-
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
|
+
]);
|
|
326
318
|
}
|
|
327
|
-
const
|
|
328
|
-
function
|
|
329
|
-
return !!(
|
|
319
|
+
const J = 2.00703;
|
|
320
|
+
function Ot(r) {
|
|
321
|
+
return !!(r.version !== void 0 || !r.tins && r.points && r.tins_points);
|
|
330
322
|
}
|
|
331
|
-
function
|
|
323
|
+
function Rt(r) {
|
|
332
324
|
return {
|
|
333
|
-
points:
|
|
334
|
-
pointsWeightBuffer:
|
|
335
|
-
strictStatus:
|
|
336
|
-
verticesParams:
|
|
337
|
-
centroid:
|
|
338
|
-
edges:
|
|
339
|
-
edgeNodes:
|
|
340
|
-
tins:
|
|
341
|
-
kinks:
|
|
342
|
-
yaxisMode:
|
|
343
|
-
strictMode:
|
|
344
|
-
vertexMode:
|
|
345
|
-
bounds:
|
|
346
|
-
boundsPolygon:
|
|
347
|
-
wh:
|
|
348
|
-
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]
|
|
349
341
|
};
|
|
350
342
|
}
|
|
351
|
-
function
|
|
352
|
-
const
|
|
343
|
+
function kt(r) {
|
|
344
|
+
const t = Vt(r), e = t.tins;
|
|
353
345
|
return {
|
|
354
|
-
compiled:
|
|
355
|
-
tins:
|
|
356
|
-
points:
|
|
357
|
-
strictStatus:
|
|
358
|
-
pointsWeightBuffer:
|
|
359
|
-
verticesParams:
|
|
360
|
-
centroid:
|
|
361
|
-
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
|
|
362
354
|
};
|
|
363
355
|
}
|
|
364
|
-
function
|
|
365
|
-
return !
|
|
366
|
-
const n =
|
|
367
|
-
return n && (e
|
|
368
|
-
const
|
|
369
|
-
return
|
|
370
|
-
}, {})),
|
|
371
|
-
}, {}) :
|
|
372
|
-
}
|
|
373
|
-
function
|
|
374
|
-
return
|
|
375
|
-
}
|
|
376
|
-
function
|
|
377
|
-
const
|
|
378
|
-
forw: [
|
|
379
|
-
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]]
|
|
380
372
|
};
|
|
381
|
-
return
|
|
382
|
-
}
|
|
383
|
-
function
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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
|
|
393
386
|
);
|
|
394
|
-
return F([
|
|
387
|
+
return F([o]);
|
|
395
388
|
});
|
|
396
389
|
}
|
|
397
|
-
function
|
|
390
|
+
function Lt(r) {
|
|
398
391
|
return {
|
|
399
|
-
forw: W(
|
|
392
|
+
forw: W(r.centroid_point[0], {
|
|
400
393
|
target: {
|
|
401
|
-
geom:
|
|
394
|
+
geom: r.centroid_point[1],
|
|
402
395
|
index: "c"
|
|
403
396
|
}
|
|
404
397
|
}),
|
|
405
|
-
bakw: W(
|
|
398
|
+
bakw: W(r.centroid_point[1], {
|
|
406
399
|
target: {
|
|
407
|
-
geom:
|
|
400
|
+
geom: r.centroid_point[0],
|
|
408
401
|
index: "c"
|
|
409
402
|
}
|
|
410
403
|
})
|
|
411
404
|
};
|
|
412
405
|
}
|
|
413
|
-
function
|
|
414
|
-
const
|
|
406
|
+
function Ut(r) {
|
|
407
|
+
const t = r.tins_points.length === 1 ? 0 : 1;
|
|
415
408
|
return {
|
|
416
409
|
forw: F(
|
|
417
|
-
|
|
418
|
-
(
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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,
|
|
424
417
|
!1,
|
|
425
|
-
|
|
418
|
+
r.version
|
|
426
419
|
)
|
|
427
420
|
)
|
|
428
421
|
),
|
|
429
422
|
bakw: F(
|
|
430
|
-
|
|
431
|
-
(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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,
|
|
437
430
|
!0,
|
|
438
|
-
|
|
431
|
+
r.version
|
|
439
432
|
)
|
|
440
433
|
)
|
|
441
434
|
)
|
|
442
435
|
};
|
|
443
436
|
}
|
|
444
|
-
function
|
|
445
|
-
if (
|
|
437
|
+
function Ft(r) {
|
|
438
|
+
if (r)
|
|
446
439
|
return {
|
|
447
440
|
bakw: F(
|
|
448
|
-
|
|
441
|
+
r.map((t) => W(t))
|
|
449
442
|
)
|
|
450
443
|
};
|
|
451
444
|
}
|
|
452
|
-
function
|
|
445
|
+
function Vt(r) {
|
|
453
446
|
return JSON.parse(
|
|
454
|
-
JSON.stringify(
|
|
447
|
+
JSON.stringify(r).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"')
|
|
455
448
|
);
|
|
456
449
|
}
|
|
457
|
-
function
|
|
458
|
-
const
|
|
459
|
-
for (let n = 0; n <
|
|
460
|
-
const
|
|
461
|
-
["a", "b", "c"].
|
|
462
|
-
const
|
|
463
|
-
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]);
|
|
464
457
|
});
|
|
465
458
|
}
|
|
466
|
-
return
|
|
459
|
+
return t;
|
|
467
460
|
}
|
|
468
|
-
const
|
|
461
|
+
const Zt = J, E = class E {
|
|
469
462
|
constructor() {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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");
|
|
490
483
|
/**
|
|
491
484
|
* Optional properties for MaplatCore extension
|
|
492
485
|
* These properties allow consuming applications to extend Transform instances
|
|
493
486
|
* with additional metadata without requiring Module Augmentation
|
|
494
487
|
*/
|
|
495
488
|
/** Layer priority for rendering order */
|
|
496
|
-
|
|
489
|
+
w(this, "priority");
|
|
497
490
|
/** Layer importance for display decisions */
|
|
498
|
-
|
|
491
|
+
w(this, "importance");
|
|
499
492
|
/** Bounds in XY (source) coordinate system */
|
|
500
|
-
|
|
493
|
+
w(this, "xyBounds");
|
|
501
494
|
/** Bounds in Mercator (Web Mercator) coordinate system */
|
|
502
|
-
|
|
495
|
+
w(this, "mercBounds");
|
|
503
496
|
}
|
|
504
497
|
/**
|
|
505
498
|
* コンパイルされた設定を適用します
|
|
506
|
-
*
|
|
499
|
+
*
|
|
507
500
|
* @param compiled - コンパイルされた設定オブジェクト
|
|
508
501
|
* @returns 変換に必要な主要なオブジェクトのセット
|
|
509
|
-
*
|
|
502
|
+
*
|
|
510
503
|
* 以下の処理を行います:
|
|
511
504
|
* 1. バージョンに応じた設定の解釈
|
|
512
505
|
* 2. 各種パラメータの復元
|
|
513
506
|
* 3. TINネットワークの再構築
|
|
514
507
|
* 4. インデックスの作成
|
|
515
508
|
*/
|
|
516
|
-
setCompiled(
|
|
517
|
-
if (
|
|
518
|
-
this.applyModernState(
|
|
509
|
+
setCompiled(t) {
|
|
510
|
+
if (Ot(t)) {
|
|
511
|
+
this.applyModernState(Rt(t));
|
|
519
512
|
return;
|
|
520
513
|
}
|
|
521
|
-
this.applyLegacyState(
|
|
514
|
+
this.applyLegacyState(kt(t));
|
|
522
515
|
}
|
|
523
|
-
applyModernState(
|
|
524
|
-
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));
|
|
525
518
|
}
|
|
526
|
-
applyLegacyState(
|
|
527
|
-
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;
|
|
528
521
|
}
|
|
529
522
|
/**
|
|
530
523
|
* TINネットワークのインデックスを作成します
|
|
531
|
-
*
|
|
524
|
+
*
|
|
532
525
|
* インデックスは変換処理を高速化するために使用されます。
|
|
533
526
|
* グリッド形式のインデックスを作成し、各グリッドに
|
|
534
527
|
* 含まれる三角形を記録します。
|
|
535
528
|
*/
|
|
536
529
|
addIndexedTin() {
|
|
537
|
-
const
|
|
538
|
-
if (
|
|
530
|
+
const t = this.tins, e = t.forw, n = t.bakw, s = Math.ceil(Math.sqrt(e.features.length));
|
|
531
|
+
if (s < 3) {
|
|
539
532
|
this.indexedTins = void 0;
|
|
540
533
|
return;
|
|
541
534
|
}
|
|
542
|
-
let i = [],
|
|
543
|
-
const
|
|
544
|
-
let
|
|
545
|
-
return
|
|
546
|
-
i.length === 0 ? i = [Array.from(
|
|
547
|
-
}),
|
|
548
|
-
}),
|
|
549
|
-
(
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
), v = B(
|
|
556
|
-
a[1][0],
|
|
557
|
-
i[0][0],
|
|
558
|
-
h,
|
|
559
|
-
c
|
|
560
|
-
), M = B(
|
|
561
|
-
a[0][1],
|
|
562
|
-
i[0][1],
|
|
563
|
-
l,
|
|
564
|
-
c
|
|
565
|
-
), _ = B(
|
|
566
|
-
a[1][1],
|
|
567
|
-
i[0][1],
|
|
568
|
-
l,
|
|
569
|
-
c
|
|
570
|
-
);
|
|
571
|
-
for (let w = m; w <= v; w++) {
|
|
572
|
-
d[w] || (d[w] = []);
|
|
573
|
-
for (let A = M; A <= _; A++)
|
|
574
|
-
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);
|
|
575
548
|
}
|
|
576
|
-
return
|
|
549
|
+
return y;
|
|
577
550
|
},
|
|
578
551
|
[]
|
|
579
|
-
),
|
|
580
|
-
let
|
|
581
|
-
return
|
|
582
|
-
|
|
583
|
-
}),
|
|
584
|
-
}),
|
|
585
|
-
(
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
), v = B(
|
|
592
|
-
a[1][0],
|
|
593
|
-
f[0][0],
|
|
594
|
-
u,
|
|
595
|
-
c
|
|
596
|
-
), M = B(
|
|
597
|
-
a[0][1],
|
|
598
|
-
f[0][1],
|
|
599
|
-
b,
|
|
600
|
-
c
|
|
601
|
-
), _ = B(
|
|
602
|
-
a[1][1],
|
|
603
|
-
f[0][1],
|
|
604
|
-
b,
|
|
605
|
-
c
|
|
606
|
-
);
|
|
607
|
-
for (let w = m; w <= v; w++) {
|
|
608
|
-
d[w] || (d[w] = []);
|
|
609
|
-
for (let A = M; A <= _; A++)
|
|
610
|
-
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);
|
|
611
564
|
}
|
|
612
|
-
return
|
|
565
|
+
return y;
|
|
613
566
|
},
|
|
614
567
|
[]
|
|
615
568
|
);
|
|
616
569
|
this.indexedTins = {
|
|
617
570
|
forw: {
|
|
618
|
-
gridNum:
|
|
571
|
+
gridNum: s,
|
|
619
572
|
xOrigin: i[0][0],
|
|
620
573
|
yOrigin: i[0][1],
|
|
621
|
-
xUnit:
|
|
622
|
-
yUnit:
|
|
623
|
-
gridCache:
|
|
574
|
+
xUnit: d,
|
|
575
|
+
yUnit: f,
|
|
576
|
+
gridCache: m
|
|
624
577
|
},
|
|
625
578
|
bakw: {
|
|
626
|
-
gridNum:
|
|
627
|
-
xOrigin:
|
|
628
|
-
yOrigin:
|
|
629
|
-
xUnit:
|
|
630
|
-
yUnit:
|
|
631
|
-
gridCache:
|
|
579
|
+
gridNum: s,
|
|
580
|
+
xOrigin: o[0][0],
|
|
581
|
+
yOrigin: o[0][1],
|
|
582
|
+
xUnit: l,
|
|
583
|
+
yUnit: g,
|
|
584
|
+
gridCache: b
|
|
632
585
|
}
|
|
633
586
|
};
|
|
634
587
|
}
|
|
635
588
|
/**
|
|
636
589
|
* 座標変換を実行します
|
|
637
|
-
*
|
|
590
|
+
*
|
|
638
591
|
* @param apoint - 変換する座標
|
|
639
592
|
* @param backward - 逆方向の変換かどうか
|
|
640
593
|
* @param ignoreBounds - 境界チェックを無視するかどうか
|
|
641
594
|
* @returns 変換後の座標、または境界外の場合はfalse
|
|
642
|
-
*
|
|
595
|
+
*
|
|
643
596
|
* @throws {Error} 逆方向変換が許可されていない状態での逆変換時
|
|
644
597
|
*/
|
|
645
|
-
transform(
|
|
646
|
-
if (
|
|
647
|
-
throw
|
|
648
|
-
this.
|
|
649
|
-
|
|
650
|
-
|
|
598
|
+
transform(t, e, n) {
|
|
599
|
+
if (!this.tins)
|
|
600
|
+
throw new Error("setCompiled() must be called before transform()");
|
|
601
|
+
if (e && this.strict_status == E.STATUS_ERROR)
|
|
602
|
+
throw new Error('Backward transform is not allowed if strict_status == "strict_error"');
|
|
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))
|
|
651
606
|
return !1;
|
|
652
|
-
const i =
|
|
653
|
-
let
|
|
654
|
-
this.stateFull && (this.stateBackward ==
|
|
655
|
-
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;
|
|
656
611
|
});
|
|
657
|
-
let
|
|
658
|
-
|
|
612
|
+
let l = St(
|
|
613
|
+
s,
|
|
659
614
|
i,
|
|
615
|
+
o,
|
|
616
|
+
u,
|
|
617
|
+
d,
|
|
660
618
|
f,
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
l,
|
|
664
|
-
y,
|
|
665
|
-
o
|
|
619
|
+
m,
|
|
620
|
+
a
|
|
666
621
|
);
|
|
667
|
-
if (this.bounds &&
|
|
668
|
-
const
|
|
669
|
-
if (!
|
|
670
|
-
} else this.yaxisMode == E.YAXIS_FOLLOW && !
|
|
671
|
-
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;
|
|
672
627
|
}
|
|
673
628
|
};
|
|
674
629
|
/**
|
|
675
630
|
* 各種モードの定数定義
|
|
676
631
|
* すべてreadonlyで、型安全性を確保
|
|
677
632
|
*/
|
|
678
|
-
|
|
679
|
-
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
|
+
}
|
|
680
968
|
export {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
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
|
|
687
984
|
};
|