@nika-js/onlymap 0.10.9 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +15 -3
- package/dist/{basemap-B2VvspL4.js → basemap-Bg73oXUb.js} +2 -2
- package/dist/cartograph/element-base.d.ts +9 -0
- package/dist/cartograph/elements/om-legend.d.ts +4 -0
- package/dist/cartograph.js +517 -495
- package/dist/cartograph.standalone.js +1307 -1285
- package/dist/cluster-index.d.ts +77 -0
- package/dist/cluster-options.d.ts +92 -0
- package/dist/ctx.d.ts +2 -0
- package/dist/elements/om-map.d.ts +6 -0
- package/dist/{geoparquet-BJQC6zwS.js → geoparquet-BASBa9tf.js} +1 -1
- package/dist/{globe-view-C3Gaf--d.js → globe-view-CTkofOiM.js} +1 -1
- package/dist/{hillshade-CNtzlYlz.js → hillshade-DdVEO8lc.js} +1 -1
- package/dist/html-data.d.ts +1 -1
- package/dist/{index-CQdTYZ08.js → index-BCDmJfeb.js} +3 -3
- package/dist/{index-j_Ojvo4x.js → index-BLfj5bIo.js} +1 -1
- package/dist/{index-Cp2kquh5.js → index-BOjo5N6i.js} +1 -1
- package/dist/{index-DPEWcZeV.js → index-C-YAnesV.js} +17527 -16473
- package/dist/{index-CI0vdi2E.js → index-C7CNrOGW.js} +1 -1
- package/dist/{index-a-wOE5hE.js → index-CVAyXg52.js} +1 -1
- package/dist/{index-D2RzlXff.js → index-DbfTOgYl.js} +1 -1
- package/dist/{index-m3UsmxCq.js → index-DsLNa_IB.js} +2 -2
- package/dist/{index-C3S0FWlc.js → index-FtNZZGWv.js} +3 -3
- package/dist/ir-snapshot.d.ts +10 -0
- package/dist/ir.d.ts +9 -0
- package/dist/layer-registry.d.ts +8 -0
- package/dist/layers/cluster-layer.d.ts +111 -0
- package/dist/{lerc-Bv4RLXha.js → lerc-CoNq0xxX.js} +1 -1
- package/dist/onlymap.standalone.js +35944 -34890
- package/dist/onlymapjs.js +1 -1
- package/dist/{post-process-effect-Cpbyy4I3.js → post-process-effect-CrZoIEYa.js} +1 -1
- package/dist/programmatic.d.ts +6 -0
- package/dist/{raster-D_HU2WuR.js → raster-CZMdghdy.js} +3 -3
- package/dist/{raster-pipeline-BmcWLImS.js → raster-pipeline-n2wrLc9r.js} +1 -1
- package/dist/runtime-core.d.ts +24 -0
- package/dist/{text-on-path-ClLwT2eS.js → text-on-path-CHkHjky-.js} +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/{zarr-CCCIYwWt.js → zarr-DRBhsEZZ.js} +2 -2
- package/docs/cartograph.md +13 -7
- package/llms.txt +3 -2
- package/onlymapjs.attributes.json +33 -0
- package/onlymapjs.html-data.json +113 -1
- package/package.json +7 -3
- package/skills/onlymapjs/SKILL.md +3 -2
- package/skills/onlymapjs/references/react.md +1 -0
- package/skills/onlymapjs/references/syntax.md +48 -2
- package/docs/design/arrows.md +0 -182
- package/docs/design/carto-substrate.md +0 -1067
- package/docs/design/cog-v2.md +0 -223
- package/docs/design/extensions.md +0 -250
- package/docs/design/frame-sources.md +0 -229
- package/docs/design/hillshade.md +0 -290
- package/docs/design/paced-flyby.md +0 -42
- package/docs/design/trace-link-failure.md +0 -20
package/dist/cartograph.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
let xt = null,
|
|
1
|
+
let xt = null, Z = null;
|
|
2
2
|
function Pe(r) {
|
|
3
3
|
xt = r;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return
|
|
5
|
+
function dr() {
|
|
6
|
+
return V !== null;
|
|
7
7
|
}
|
|
8
|
-
let
|
|
9
|
-
function
|
|
10
|
-
return
|
|
8
|
+
let V = null;
|
|
9
|
+
function J() {
|
|
10
|
+
return V;
|
|
11
11
|
}
|
|
12
12
|
function Te() {
|
|
13
|
-
return
|
|
14
|
-
throw
|
|
15
|
-
}),
|
|
13
|
+
return V ? Promise.resolve(V) : Z || (xt ? (Z = Promise.resolve(xt()).then((r) => (V = r, V)).catch((r) => {
|
|
14
|
+
throw Z = null, r;
|
|
15
|
+
}), Z) : Promise.reject(
|
|
16
16
|
new Error(
|
|
17
17
|
'[onlymapjs/cartograph] No map runtime loader is configured. Import the cartograph entry ("@nika-js/onlymap/cartograph" or its standalone build) rather than a submodule — the entry installs it.'
|
|
18
18
|
)
|
|
19
19
|
));
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22
22
|
__proto__: null,
|
|
23
|
-
isCoreLoaded:
|
|
23
|
+
isCoreLoaded: dr,
|
|
24
24
|
loadCore: Te,
|
|
25
|
-
peekCore:
|
|
25
|
+
peekCore: J,
|
|
26
26
|
setCoreLoader: Pe
|
|
27
27
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
28
28
|
function Bt(r) {
|
|
@@ -31,20 +31,20 @@ function Bt(r) {
|
|
|
31
31
|
function ft(r) {
|
|
32
32
|
return typeof r?.paintCartograph == "function";
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const K = (r, t) => {
|
|
35
35
|
const e = r.getAttribute(t);
|
|
36
36
|
if (e == null || e.trim() === "") return null;
|
|
37
37
|
const n = Number(e);
|
|
38
38
|
return Number.isFinite(n) ? n : null;
|
|
39
39
|
};
|
|
40
|
-
function
|
|
40
|
+
function S(r) {
|
|
41
41
|
return {
|
|
42
|
-
x:
|
|
43
|
-
y:
|
|
44
|
-
w:
|
|
45
|
-
h:
|
|
46
|
-
rotation:
|
|
47
|
-
z:
|
|
42
|
+
x: K(r, "x") ?? 0,
|
|
43
|
+
y: K(r, "y") ?? 0,
|
|
44
|
+
w: K(r, "w") ?? 0,
|
|
45
|
+
h: K(r, "h") ?? 0,
|
|
46
|
+
rotation: K(r, "rotation") ?? 0,
|
|
47
|
+
z: K(r, "z")
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
function $t(r, t = 0) {
|
|
@@ -52,7 +52,7 @@ function $t(r, t = 0) {
|
|
|
52
52
|
const e = Number.parseFloat(r);
|
|
53
53
|
return Number.isFinite(e) ? e : t;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function F(r) {
|
|
56
56
|
if (!r) return null;
|
|
57
57
|
const t = r.trim().toLowerCase();
|
|
58
58
|
return t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "none" ? null : r;
|
|
@@ -74,7 +74,7 @@ function ht(r, t, e, n) {
|
|
|
74
74
|
return n === "landscape" ? { widthMm: s.heightMm, heightMm: s.widthMm } : { ...s };
|
|
75
75
|
}
|
|
76
76
|
let rt = null;
|
|
77
|
-
function
|
|
77
|
+
function pr(r) {
|
|
78
78
|
if (!rt) {
|
|
79
79
|
rt = new Uint32Array(256);
|
|
80
80
|
for (let e = 0; e < 256; e++) {
|
|
@@ -87,18 +87,18 @@ function dr(r) {
|
|
|
87
87
|
for (let e = 0; e < r.length; e++) t = rt[(t ^ r[e]) & 255] ^ t >>> 8;
|
|
88
88
|
return (t ^ 4294967295) >>> 0;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function gr(r) {
|
|
91
91
|
const t = Math.max(1980, r.getFullYear());
|
|
92
92
|
return {
|
|
93
93
|
time: r.getHours() << 11 | r.getMinutes() << 5 | Math.floor(r.getSeconds() / 2),
|
|
94
94
|
date: t - 1980 << 9 | r.getMonth() + 1 << 5 | r.getDate()
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
async function
|
|
98
|
-
const e = new TextEncoder(), { time: n, date: i } =
|
|
97
|
+
async function br(r, t = /* @__PURE__ */ new Date()) {
|
|
98
|
+
const e = new TextEncoder(), { time: n, date: i } = gr(t), o = [], s = [];
|
|
99
99
|
let a = 0;
|
|
100
100
|
for (const u of r) {
|
|
101
|
-
const m = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), h =
|
|
101
|
+
const m = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), h = pr(m), f = new DataView(new ArrayBuffer(30));
|
|
102
102
|
f.setUint32(0, 67324752, !0), f.setUint16(4, 20, !0), f.setUint16(6, 2048, !0), f.setUint16(8, 0, !0), f.setUint16(10, n, !0), f.setUint16(12, i, !0), f.setUint32(14, h, !0), f.setUint32(18, m.length, !0), f.setUint32(22, m.length, !0), f.setUint16(26, d.length, !0), f.setUint16(28, 0, !0), o.push(new Uint8Array(f.buffer), d, m), s.push({ name: u.name, bytes: m, crc: h, offset: a }), a += 30 + d.length + m.length;
|
|
103
103
|
}
|
|
104
104
|
const l = a;
|
|
@@ -119,19 +119,19 @@ function Dt(r) {
|
|
|
119
119
|
const t = r?.trim().toLowerCase();
|
|
120
120
|
return !t || t === "none" ? null : mt.includes(t) ? t : Le[t] ?? null;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
122
|
+
const yr = ["none", ...mt, ...Object.keys(Le)], zt = {
|
|
123
123
|
protanopia: [0.11238, 0.88762, 0, 0.11238, 0.88762, 0, 401e-5, -401e-5, 1],
|
|
124
124
|
deuteranopia: [0.29275, 0.70725, 0, 0.29275, 0.70725, 0, -0.02234, 0.02234, 1],
|
|
125
125
|
tritanopia: [1, 0.14461, -0.14461, 0, 0.85659, 0.14341, 0, 0.85659, 0.14341],
|
|
126
126
|
achromatopsia: [0.2126, 0.7152, 0.0722, 0.2126, 0.7152, 0.0722, 0.2126, 0.7152, 0.0722]
|
|
127
|
-
},
|
|
127
|
+
}, q = (r) => {
|
|
128
128
|
const t = r / 255;
|
|
129
129
|
return t <= 0.04045 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
|
|
130
130
|
}, ct = (r) => {
|
|
131
131
|
const t = Math.min(1, Math.max(0, r));
|
|
132
132
|
return 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * t ** (1 / 2.4) - 0.055);
|
|
133
133
|
};
|
|
134
|
-
function
|
|
134
|
+
function wr(r) {
|
|
135
135
|
const t = r.trim().toLowerCase(), e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);
|
|
136
136
|
if (e) {
|
|
137
137
|
const i = e[1], o = (s) => parseInt(s.length === 1 ? s + s : s, 16);
|
|
@@ -141,7 +141,7 @@ function br(r) {
|
|
|
141
141
|
return n ? { r: Number(n[1]), g: Number(n[2]), b: Number(n[3]) } : null;
|
|
142
142
|
}
|
|
143
143
|
function Ht(r, t) {
|
|
144
|
-
const e =
|
|
144
|
+
const e = zt[t], [n, i, o] = [q(r.r), q(r.g), q(r.b)];
|
|
145
145
|
return {
|
|
146
146
|
r: ct(e[0] * n + e[1] * i + e[2] * o),
|
|
147
147
|
g: ct(e[3] * n + e[4] * i + e[5] * o),
|
|
@@ -149,28 +149,28 @@ function Ht(r, t) {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
function Yt({ r, g: t, b: e }) {
|
|
152
|
-
const [n, i, o] = [
|
|
152
|
+
const [n, i, o] = [q(r), q(t), q(e)], s = (n * 0.4124564 + i * 0.3575761 + o * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + o * 0.072175, l = (n * 0.0193339 + i * 0.119192 + o * 0.9503041) / 1.08883, c = (h) => h > 216 / 24389 ? Math.cbrt(h) : 841 / 108 * h + 4 / 29, [u, m, d] = [c(s), c(a), c(l)];
|
|
153
153
|
return [116 * m - 16, 500 * (u - m), 200 * (m - d)];
|
|
154
154
|
}
|
|
155
155
|
function Xt(r, t) {
|
|
156
|
-
const [e, n, i] = Yt(r), [o, s, a] = Yt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(s, a)) / 2, m = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, h] = [n * (1 + m), s * (1 + m)], [f, g] = [Math.hypot(d, i), Math.hypot(h, a)], p = (
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
return
|
|
156
|
+
const [e, n, i] = Yt(r), [o, s, a] = Yt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(s, a)) / 2, m = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, h] = [n * (1 + m), s * (1 + m)], [f, g] = [Math.hypot(d, i), Math.hypot(h, a)], p = (L, R) => {
|
|
157
|
+
if (L === 0 && R === 0) return 0;
|
|
158
|
+
const B = Math.atan2(R, L) * c;
|
|
159
|
+
return B >= 0 ? B : B + 360;
|
|
160
160
|
}, [b, w] = [p(d, i), p(h, a)], y = o - e, A = g - f;
|
|
161
161
|
let v = 0;
|
|
162
162
|
f * g !== 0 && (v = w - b, v > 180 ? v -= 360 : v < -180 && (v += 360));
|
|
163
|
-
const
|
|
164
|
-
let
|
|
165
|
-
f * g !== 0 && (Math.abs(b - w) > 180 && (
|
|
166
|
-
const
|
|
167
|
-
return Math.sqrt((y / M) ** 2 + (A /
|
|
168
|
-
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
163
|
+
const $ = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), G = (e + o) / 2, _ = (f + g) / 2;
|
|
164
|
+
let E = b + w;
|
|
165
|
+
f * g !== 0 && (Math.abs(b - w) > 180 && (E += b + w < 360 ? 360 : -360), E /= 2);
|
|
166
|
+
const N = 1 - 0.17 * Math.cos((E - 30) * l) + 0.24 * Math.cos(2 * E * l) + 0.32 * Math.cos((3 * E + 6) * l) - 0.2 * Math.cos((4 * E - 63) * l), M = 1 + 0.015 * (G - 50) ** 2 / Math.sqrt(20 + (G - 50) ** 2), C = 1 + 0.045 * _, P = 1 + 0.015 * _ * N, x = -2 * Math.sqrt(_ ** 7 / (_ ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((E - 275) / 25) ** 2)) * l);
|
|
167
|
+
return Math.sqrt((y / M) ** 2 + (A / C) ** 2 + ($ / P) ** 2 + x * (A / C) * ($ / P));
|
|
168
|
+
}
|
|
169
|
+
const vr = 10;
|
|
170
|
+
function Ar(r, t = vr) {
|
|
171
171
|
const e = /* @__PURE__ */ new Map();
|
|
172
172
|
for (const a of r) {
|
|
173
|
-
const l =
|
|
173
|
+
const l = wr(a.color);
|
|
174
174
|
if (!l) continue;
|
|
175
175
|
const c = a.layer ?? "", u = e.get(c);
|
|
176
176
|
u ? u.push({ entry: a, rgb: l }) : e.set(c, [{ entry: a, rgb: l }]);
|
|
@@ -189,7 +189,7 @@ function wr(r, t = yr) {
|
|
|
189
189
|
l > s && (s = l, o = a);
|
|
190
190
|
return { collapses: n, worstType: o };
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function Mr(r, t, e, n) {
|
|
193
193
|
if (t <= 0 || e <= 0) return !0;
|
|
194
194
|
let i;
|
|
195
195
|
try {
|
|
@@ -198,13 +198,13 @@ function vr(r, t, e, n) {
|
|
|
198
198
|
return !1;
|
|
199
199
|
}
|
|
200
200
|
const o = new Float64Array(256);
|
|
201
|
-
for (let m = 0; m < 256; m++) o[m] =
|
|
201
|
+
for (let m = 0; m < 256; m++) o[m] = q(m);
|
|
202
202
|
const s = 1024, a = new Float64Array(s + 1);
|
|
203
203
|
for (let m = 0; m <= s; m++) a[m] = ct(m / s);
|
|
204
204
|
const l = (m) => {
|
|
205
205
|
const d = Math.min(1, Math.max(0, m)) * s, h = Math.floor(d);
|
|
206
206
|
return h >= s ? a[s] : a[h] + (a[h + 1] - a[h]) * (d - h);
|
|
207
|
-
}, c =
|
|
207
|
+
}, c = zt[n], u = i.data;
|
|
208
208
|
for (let m = 0; m < u.length; m += 4) {
|
|
209
209
|
const d = o[u[m]], h = o[u[m + 1]], f = o[u[m + 2]];
|
|
210
210
|
u[m] = l(c[0] * d + c[1] * h + c[2] * f), u[m + 1] = l(c[3] * d + c[4] * h + c[5] * f), u[m + 2] = l(c[6] * d + c[7] * h + c[8] * f);
|
|
@@ -212,7 +212,7 @@ function vr(r, t, e, n) {
|
|
|
212
212
|
return r.putImageData(i, 0, 0), !0;
|
|
213
213
|
}
|
|
214
214
|
const Re = (r) => `om-carto-cvd-${r}`;
|
|
215
|
-
function
|
|
215
|
+
function Sr(r) {
|
|
216
216
|
if (r.getElementById("om-carto-cvd-filters")) return;
|
|
217
217
|
const t = r.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
218
218
|
t.id = "om-carto-cvd-filters", t.setAttribute("aria-hidden", "true"), t.setAttribute("width", "0"), t.setAttribute("height", "0"), t.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;";
|
|
@@ -221,13 +221,13 @@ function Ar(r) {
|
|
|
221
221
|
n.id = Re(e), n.setAttribute("color-interpolation-filters", "linearRGB");
|
|
222
222
|
const i = r.createElementNS("http://www.w3.org/2000/svg", "feColorMatrix");
|
|
223
223
|
i.setAttribute("type", "matrix");
|
|
224
|
-
const o =
|
|
224
|
+
const o = zt[e];
|
|
225
225
|
i.setAttribute("values", [o[0], o[1], o[2], 0, 0, o[3], o[4], o[5], 0, 0, o[6], o[7], o[8], 0, 0, 0, 0, 0, 1, 0].join(" ")), n.appendChild(i), t.appendChild(n);
|
|
226
226
|
}
|
|
227
227
|
r.body.appendChild(t);
|
|
228
228
|
}
|
|
229
|
-
const
|
|
230
|
-
async function
|
|
229
|
+
const Fe = 16384, Ie = 134217728;
|
|
230
|
+
async function Cr(r) {
|
|
231
231
|
const t = [], e = [...r.querySelectorAll("img")];
|
|
232
232
|
return await Promise.all(
|
|
233
233
|
e.map(async (n) => {
|
|
@@ -240,13 +240,13 @@ async function Mr(r) {
|
|
|
240
240
|
})
|
|
241
241
|
), t;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function Oe(r) {
|
|
244
244
|
return !r.hasAttribute("hidden") && !r.hasAttribute("data-om-carto-screen-only") && !r.hasAttribute("data-om-carto-marks") && !r.hasAttribute("data-om-carto-flattened") && r.tagName.toLowerCase() !== "style" && r.tagName.toLowerCase() !== "script";
|
|
245
245
|
}
|
|
246
|
-
function
|
|
247
|
-
return [...r.children].filter(
|
|
246
|
+
function kr(r) {
|
|
247
|
+
return [...r.children].filter(Oe).map((t, e) => ({ el: t, index: e, z: S(t).z ?? 0 })).sort((t, e) => t.z - e.z || t.index - e.index).map((t) => t.el);
|
|
248
248
|
}
|
|
249
|
-
async function
|
|
249
|
+
async function jt(r, t = {}) {
|
|
250
250
|
const e = r ?? document.querySelector("om-cartograph");
|
|
251
251
|
if (!e) throw new Error("[onlymapjs/cartograph] renderCartograph: no <om-cartograph> to render.");
|
|
252
252
|
const n = [], i = t.dpi ?? (Number(e.getAttribute("dpi")) || 300);
|
|
@@ -256,53 +256,53 @@ async function zt(r, t = {}) {
|
|
|
256
256
|
e.getAttribute("width"),
|
|
257
257
|
e.getAttribute("height"),
|
|
258
258
|
e.getAttribute("orientation")
|
|
259
|
-
), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = o + a * 2, c = s + a * 2, u = t.maxDimension ??
|
|
259
|
+
), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = o + a * 2, c = s + a * 2, u = t.maxDimension ?? Fe, m = t.maxArea ?? Ie;
|
|
260
260
|
let d = i;
|
|
261
261
|
const h = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(m / (l / 25.4 * (c / 25.4))), g = Math.min(h, f);
|
|
262
|
-
d > g && (d = Math.floor(g), n.push(`Requested ${i} dpi exceeds this browser's canvas budget for a ${l.toFixed(0)}×${c.toFixed(0)}mm page; rendered at ${d} dpi instead.`)), n.push(...await
|
|
263
|
-
const p = Bt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y =
|
|
262
|
+
d > g && (d = Math.floor(g), n.push(`Requested ${i} dpi exceeds this browser's canvas budget for a ${l.toFixed(0)}×${c.toFixed(0)}mm page; rendered at ${d} dpi instead.`)), n.push(...await Cr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
|
|
263
|
+
const p = Bt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = kr(e);
|
|
264
264
|
for (const M of y)
|
|
265
265
|
if (!(!ft(M) || !M.prepareCartograph))
|
|
266
266
|
try {
|
|
267
267
|
await M.prepareCartograph(Bt(d));
|
|
268
|
-
} catch (
|
|
269
|
-
M.discardCartograph?.(), n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} could not be captured: ${
|
|
268
|
+
} catch (C) {
|
|
269
|
+
M.discardCartograph?.(), n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} could not be captured: ${C.message}`);
|
|
270
270
|
}
|
|
271
271
|
const A = document.createElement("canvas");
|
|
272
272
|
A.width = b, A.height = w;
|
|
273
273
|
const v = A.getContext("2d");
|
|
274
274
|
if (!v) throw new Error("[onlymapjs/cartograph] renderCartograph: could not get a 2D canvas context.");
|
|
275
|
-
const
|
|
276
|
-
v.fillStyle =
|
|
275
|
+
const $ = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
|
|
276
|
+
v.fillStyle = F($?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
|
|
277
277
|
for (const M of y) {
|
|
278
278
|
if (!ft(M)) continue;
|
|
279
|
-
const
|
|
280
|
-
if (v.save(), v.translate((
|
|
281
|
-
const
|
|
282
|
-
v.translate(
|
|
279
|
+
const C = S(M);
|
|
280
|
+
if (v.save(), v.translate((C.x + a) * p.pxPerMm, (C.y + a) * p.pxPerMm), C.rotation) {
|
|
281
|
+
const P = C.w / 2 * p.pxPerMm, x = C.h / 2 * p.pxPerMm;
|
|
282
|
+
v.translate(P, x), v.rotate(C.rotation * Math.PI / 180), v.translate(-P, -x);
|
|
283
283
|
}
|
|
284
284
|
try {
|
|
285
285
|
M.paintCartograph(v, p);
|
|
286
|
-
} catch (
|
|
287
|
-
n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} failed to render: ${
|
|
286
|
+
} catch (P) {
|
|
287
|
+
n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} failed to render: ${P.message}`);
|
|
288
288
|
}
|
|
289
289
|
v.restore();
|
|
290
290
|
}
|
|
291
|
-
const
|
|
292
|
-
for (const M of
|
|
293
|
-
const
|
|
294
|
-
[
|
|
291
|
+
const G = e.querySelector(":scope > [data-om-carto-marks]");
|
|
292
|
+
for (const M of G?.querySelectorAll("line") ?? []) {
|
|
293
|
+
const C = Number(M.getAttribute("x1")), P = Number(M.getAttribute("y1")), x = Number(M.getAttribute("x2")), L = Number(M.getAttribute("y2"));
|
|
294
|
+
[C, P, x, L].every(Number.isFinite) && (v.save(), v.strokeStyle = M.getAttribute("stroke") || "#000000", v.lineWidth = (Number(M.getAttribute("stroke-width")) || 0.2) * p.pxPerMm, v.beginPath(), v.moveTo((C + a) * p.pxPerMm, (P + a) * p.pxPerMm), v.lineTo((x + a) * p.pxPerMm, (L + a) * p.pxPerMm), v.stroke(), v.restore());
|
|
295
295
|
}
|
|
296
|
-
const
|
|
297
|
-
|
|
296
|
+
const _ = Dt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
|
|
297
|
+
_ && !Mr(v, b, w, _) && n.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
|
|
298
298
|
for (const M of y) ft(M) && M.discardCartograph?.();
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
if (!
|
|
303
|
-
return { blob:
|
|
299
|
+
const E = t.format === "jpeg" ? "image/jpeg" : "image/png";
|
|
300
|
+
E === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
|
|
301
|
+
const N = await new Promise((M) => A.toBlob(M, E, t.quality));
|
|
302
|
+
if (!N) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
|
|
303
|
+
return { blob: N, widthPx: b, heightPx: w, dpi: d, warnings: n };
|
|
304
304
|
}
|
|
305
|
-
async function
|
|
305
|
+
async function _e(r, t = {}) {
|
|
306
306
|
const e = r ?? document.querySelector("om-cartograph");
|
|
307
307
|
if (!e) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: no <om-cartograph> to render.");
|
|
308
308
|
const n = e.querySelector("om-atlas") ?? null;
|
|
@@ -328,7 +328,7 @@ async function Oe(r, t = {}) {
|
|
|
328
328
|
const d = await Jt(e, t, a);
|
|
329
329
|
u = d.dpi, c.push({ name: s[m], data: d.blob }), t.onPage?.(m + 1, i);
|
|
330
330
|
}
|
|
331
|
-
return { blob: await
|
|
331
|
+
return { blob: await br(c), filenames: s, pages: i, dpi: u, warnings: a };
|
|
332
332
|
} finally {
|
|
333
333
|
n.seek(l);
|
|
334
334
|
}
|
|
@@ -336,16 +336,16 @@ async function Oe(r, t = {}) {
|
|
|
336
336
|
async function Jt(r, t, e) {
|
|
337
337
|
for (const i of r.querySelectorAll("om-frame"))
|
|
338
338
|
await i.mapElement?.whenSettled?.({ timeout: 2e4 });
|
|
339
|
-
const n = await
|
|
339
|
+
const n = await jt(r, t);
|
|
340
340
|
return e.push(...n.warnings), n;
|
|
341
341
|
}
|
|
342
|
-
const
|
|
342
|
+
const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
343
343
|
__proto__: null,
|
|
344
|
-
MAX_CANVAS_AREA:
|
|
345
|
-
MAX_CANVAS_DIMENSION:
|
|
346
|
-
paintsInExport:
|
|
347
|
-
renderCartograph:
|
|
348
|
-
renderCartographAtlas:
|
|
344
|
+
MAX_CANVAS_AREA: Ie,
|
|
345
|
+
MAX_CANVAS_DIMENSION: Fe,
|
|
346
|
+
paintsInExport: Oe,
|
|
347
|
+
renderCartograph: jt,
|
|
348
|
+
renderCartographAtlas: _e
|
|
349
349
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
350
350
|
function Zt(r, t, e = {}) {
|
|
351
351
|
const n = URL.createObjectURL(r), i = document.createElement("a");
|
|
@@ -353,8 +353,8 @@ function Zt(r, t, e = {}) {
|
|
|
353
353
|
const o = e.revokeAfterMs ?? 0;
|
|
354
354
|
o > 0 ? setTimeout(() => URL.revokeObjectURL(n), o) : URL.revokeObjectURL(n);
|
|
355
355
|
}
|
|
356
|
-
const
|
|
357
|
-
async function Qt(r, t =
|
|
356
|
+
const $r = 3e4;
|
|
357
|
+
async function Qt(r, t = $r) {
|
|
358
358
|
let e = !1;
|
|
359
359
|
const n = new Promise(
|
|
360
360
|
(o) => setTimeout(() => {
|
|
@@ -374,7 +374,7 @@ async function Qt(r, t = kr) {
|
|
|
374
374
|
})();
|
|
375
375
|
return await Promise.race([i, n]), { timedOut: e };
|
|
376
376
|
}
|
|
377
|
-
async function
|
|
377
|
+
async function Er(r, t = {}) {
|
|
378
378
|
if (!r.hasAttribute("allow-url-actions") || typeof document < "u" && document.documentElement?.dataset?.omHost === "editor") return null;
|
|
379
379
|
const e = t.search ?? (typeof location < "u" ? location.search : "");
|
|
380
380
|
if (!e) return null;
|
|
@@ -390,21 +390,21 @@ async function xr(r, t = {}) {
|
|
|
390
390
|
const d = Number(c);
|
|
391
391
|
if (!Number.isInteger(d) || d < 1) throw new Error(`?page=${c} is not a page number (they start at 1).`);
|
|
392
392
|
m.refresh?.();
|
|
393
|
-
const h = await
|
|
393
|
+
const h = await _e(r, { dpi: a, format: s, page: d - 1 });
|
|
394
394
|
for (const f of h.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
|
|
395
395
|
return Zt(h.blob, h.filenames[0] ?? `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
|
|
396
396
|
}
|
|
397
|
-
const u = await
|
|
397
|
+
const u = await jt(r, { dpi: a, format: s });
|
|
398
398
|
for (const m of u.warnings) console.warn(`[onlymapjs/cartograph] ${m}`);
|
|
399
399
|
return Zt(u.blob, `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
|
|
400
400
|
}
|
|
401
401
|
return n.get("print") === "1" ? (await Qt(r, t.timeoutMs), typeof r.print == "function" ? await r.print({ dpi: Number(n.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function Nr() {
|
|
404
404
|
if (typeof document > "u") return;
|
|
405
405
|
const r = () => {
|
|
406
406
|
for (const t of document.querySelectorAll("om-cartograph[allow-url-actions]"))
|
|
407
|
-
|
|
407
|
+
Er(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
|
|
408
408
|
};
|
|
409
409
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", r, { once: !0 }) : r();
|
|
410
410
|
}
|
|
@@ -413,14 +413,14 @@ const Ue = typeof window < "u" && typeof document < "u" && typeof customElements
|
|
|
413
413
|
function k(r, t) {
|
|
414
414
|
Ue && (customElements.get(r) || customElements.define(r, t));
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function Pr(r) {
|
|
417
417
|
if (typeof DOMParser > "u")
|
|
418
418
|
throw new Error(
|
|
419
419
|
"[onlymapjs] Parsing a manifest string needs a DOM implementation (DOMParser). In node, run under a DOM test environment — e.g. vitest with `environment: 'happy-dom'` (or jsdom) — or pass an already-parsed Element instead of a string."
|
|
420
420
|
);
|
|
421
421
|
return new DOMParser().parseFromString(r, "text/html");
|
|
422
422
|
}
|
|
423
|
-
class
|
|
423
|
+
class O extends De {
|
|
424
424
|
renderQueued = !1;
|
|
425
425
|
connectedCallback() {
|
|
426
426
|
this.scheduleRender();
|
|
@@ -437,6 +437,18 @@ class F extends De {
|
|
|
437
437
|
this.renderQueued = !1, this.isConnected && this.renderNow();
|
|
438
438
|
}));
|
|
439
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Apply an authored colour or font override to the theme property the
|
|
442
|
+
* element's styling reads. Written as the custom property itself — on this
|
|
443
|
+
* element, so it scopes to it — which is what lets one attribute reach the
|
|
444
|
+
* SVG the element draws, its computed style, and so the canvas exporter,
|
|
445
|
+
* which reads computed colour and keeps no second theme table. `alsoColor`
|
|
446
|
+
* writes the element's own `color` too, for painters that read that.
|
|
447
|
+
*/
|
|
448
|
+
applyThemeOverride(t, e, n = !1) {
|
|
449
|
+
const i = this.getAttribute(t)?.trim();
|
|
450
|
+
i ? (this.style.setProperty(e, i), n && (this.style.color = i)) : (this.style.removeProperty(e), n && this.style.removeProperty("color"));
|
|
451
|
+
}
|
|
440
452
|
/** Write the placed-element inline styles from the mm placement attributes. */
|
|
441
453
|
applyPlacement() {
|
|
442
454
|
const t = (l) => {
|
|
@@ -452,23 +464,23 @@ class F extends De {
|
|
|
452
464
|
a != null && Number.isInteger(a) ? this.style.zIndex = String(a) : this.style.removeProperty("z-index");
|
|
453
465
|
}
|
|
454
466
|
}
|
|
455
|
-
const
|
|
467
|
+
const pt = "cartograph/2", Ai = ["default", "dark", "sepia", "blueprint", "minimal"], te = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], Tr = /* @__PURE__ */ new Map([
|
|
456
468
|
["projection", "live frames render Web Mercator (EPSG:3857) only — Globe support is design-only; use a static frame for other projections"]
|
|
457
|
-
]),
|
|
458
|
-
"om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions", "keep-badge"],
|
|
459
|
-
"om-frame": [...
|
|
460
|
-
"om-legend": [...
|
|
469
|
+
]), z = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], T = {
|
|
470
|
+
"om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "bg", "color", "font", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions", "keep-badge"],
|
|
471
|
+
"om-frame": [...z, "src", "mode", "center", "zoom", "bearing", "pitch", "dpi", "crs", "corners", "crs-def", "overview-of", "overview-stroke", "atlas-fit", "atlas-margin", "frame-stroke", "frame-bg"],
|
|
472
|
+
"om-legend": [...z, "for", "title", "columns", "derived", "bg", "color", "stroke", "font-size", "padding"],
|
|
461
473
|
"om-legend-row": ["layer", "match", "label", "hide", "order", "color", "shape"],
|
|
462
474
|
// NOTE: the discriminator on furniture is `kind`, never `style` — `style` is
|
|
463
475
|
// the global HTML attribute the runtime itself writes for mm placement, so
|
|
464
476
|
// `style="double"` would be erased on the first render. `kind` also matches
|
|
465
477
|
// om-text/om-shape, so the whole vocabulary has ONE discriminator word.
|
|
466
|
-
"om-scalebar": [...
|
|
467
|
-
"om-north": [...
|
|
468
|
-
"om-graticule": [...
|
|
469
|
-
"om-text": [...
|
|
470
|
-
"om-shape": [...
|
|
471
|
-
"om-image": [...
|
|
478
|
+
"om-scalebar": [...z, "for", "units", "segments", "segment-length", "kind", "color"],
|
|
479
|
+
"om-north": [...z, "for", "kind", "color"],
|
|
480
|
+
"om-graticule": [...z, "for", "crs", "crs-def", "interval", "interval-x", "interval-y", "kind", "labels", "format", "color"],
|
|
481
|
+
"om-text": [...z, "kind", "font-size", "weight", "align", "font", "color", "bg"],
|
|
482
|
+
"om-shape": [...z, "kind", "fill", "fill-opacity", "stroke", "stroke-width", "radius"],
|
|
483
|
+
"om-image": [...z, "src", "fit"],
|
|
472
484
|
// NOT placed: a source is a child of <om-frame> that says where the frame's
|
|
473
485
|
// picture may come from. Its corners/crs describe THAT source — a capture
|
|
474
486
|
// carries the georeference that was true when it was taken, which is the
|
|
@@ -476,11 +488,11 @@ const gt = "cartograph/2", wi = ["default", "dark", "sepia", "blueprint", "minim
|
|
|
476
488
|
// CRS is therefore unknowable.
|
|
477
489
|
"om-source": ["src", "corners", "crs", "crs-def"],
|
|
478
490
|
"om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name", "pager"]
|
|
479
|
-
},
|
|
480
|
-
function
|
|
481
|
-
return r != null &&
|
|
491
|
+
}, gt = Object.keys(T), Et = "data-om-carto-vector", Lr = ["metric", "imperial", "nautical"], Rr = 0.3048, Fr = 1609.344, Ir = 1852;
|
|
492
|
+
function Or(r) {
|
|
493
|
+
return r != null && Lr.includes(r) ? r : null;
|
|
482
494
|
}
|
|
483
|
-
function
|
|
495
|
+
function ze(r) {
|
|
484
496
|
if (!isFinite(r) || r <= 0) return 0;
|
|
485
497
|
const t = Math.pow(10, Math.floor(Math.log10(r))), e = r / t;
|
|
486
498
|
return (e >= 5 ? 5 : e >= 2 ? 2 : 1) * t;
|
|
@@ -492,12 +504,12 @@ const ee = {
|
|
|
492
504
|
{ metersPerUnit: 1e3, label: "km" }
|
|
493
505
|
],
|
|
494
506
|
imperial: [
|
|
495
|
-
{ metersPerUnit:
|
|
496
|
-
{ metersPerUnit:
|
|
507
|
+
{ metersPerUnit: Rr, label: "ft" },
|
|
508
|
+
{ metersPerUnit: Fr, label: "mi" }
|
|
497
509
|
],
|
|
498
|
-
nautical: [{ metersPerUnit:
|
|
510
|
+
nautical: [{ metersPerUnit: Ir, label: "nmi" }]
|
|
499
511
|
};
|
|
500
|
-
function
|
|
512
|
+
function je({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
|
|
501
513
|
if (!Number.isFinite(r) || r <= 0 || !Number.isFinite(t) || t <= 0) return null;
|
|
502
514
|
const o = Number.isInteger(e) && e > 0 ? e : 4, s = ee[n] ?? ee.metric, a = t / o * r;
|
|
503
515
|
let l, c;
|
|
@@ -505,7 +517,7 @@ function ze({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "
|
|
|
505
517
|
l = i, c = re(s, l);
|
|
506
518
|
else {
|
|
507
519
|
c = re(s, a);
|
|
508
|
-
const f =
|
|
520
|
+
const f = ze(a / c.metersPerUnit);
|
|
509
521
|
if (f <= 0) return null;
|
|
510
522
|
l = f * c.metersPerUnit;
|
|
511
523
|
}
|
|
@@ -524,7 +536,7 @@ function ze({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "
|
|
|
524
536
|
scaleDenominator: r * 1e3
|
|
525
537
|
};
|
|
526
538
|
}
|
|
527
|
-
function
|
|
539
|
+
function _r(r, t, e) {
|
|
528
540
|
const n = Math.min(2.6, Math.max(1.6, e * 0.34)), i = 0.2, o = n * 1.25, s = Math.max(0.6, Math.min(2.2, e - o - 0.4)), a = 0, l = r.segmentMm, c = [], u = [];
|
|
529
541
|
if (t === "single" || t === "double") {
|
|
530
542
|
const p = t === "double" ? 2 : 1, b = s / p;
|
|
@@ -572,12 +584,12 @@ function re(r, t) {
|
|
|
572
584
|
t / n.metersPerUnit >= 1 && (e = n);
|
|
573
585
|
return e;
|
|
574
586
|
}
|
|
575
|
-
const
|
|
576
|
-
function
|
|
577
|
-
return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
587
|
+
const Ur = " ";
|
|
588
|
+
function Dr(r) {
|
|
589
|
+
return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Ur);
|
|
578
590
|
}
|
|
579
591
|
const Ge = /\{\{\s*([\w.]+)\s*\}\}/g;
|
|
580
|
-
function
|
|
592
|
+
function zr(r, t) {
|
|
581
593
|
if (r.startsWith("atlas.")) return t.atlas?.[r.slice(6)];
|
|
582
594
|
if (r.startsWith("frame.")) {
|
|
583
595
|
const e = r.slice(6), n = e.lastIndexOf(".");
|
|
@@ -592,15 +604,15 @@ function Ur(r, t) {
|
|
|
592
604
|
function qe(r, t) {
|
|
593
605
|
const e = [];
|
|
594
606
|
return { text: r.replace(Ge, (i, o) => {
|
|
595
|
-
const s =
|
|
607
|
+
const s = zr(o, t);
|
|
596
608
|
return s === void 0 ? (e.push(o), i) : s;
|
|
597
609
|
}), unresolved: e };
|
|
598
610
|
}
|
|
599
|
-
function
|
|
611
|
+
function jr(r) {
|
|
600
612
|
return [...r.matchAll(Ge)].map((t) => t[1]);
|
|
601
613
|
}
|
|
602
614
|
const ne = /* @__PURE__ */ new WeakMap();
|
|
603
|
-
function
|
|
615
|
+
function Gr(r, t) {
|
|
604
616
|
const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
|
|
605
617
|
if (!n) return e;
|
|
606
618
|
const i = n.createTreeWalker(
|
|
@@ -620,7 +632,7 @@ function jr(r, t) {
|
|
|
620
632
|
}
|
|
621
633
|
return e;
|
|
622
634
|
}
|
|
623
|
-
function
|
|
635
|
+
function qr(r = /* @__PURE__ */ new Date()) {
|
|
624
636
|
return `${r.getFullYear()}-${String(r.getMonth() + 1).padStart(2, "0")}-${String(r.getDate()).padStart(2, "0")}`;
|
|
625
637
|
}
|
|
626
638
|
const Nt = "data-om-carto-unlinked";
|
|
@@ -637,17 +649,17 @@ function Be(r, t) {
|
|
|
637
649
|
function Ke(r) {
|
|
638
650
|
return [...r.querySelectorAll("om-frame")];
|
|
639
651
|
}
|
|
640
|
-
function
|
|
652
|
+
function Wr(r) {
|
|
641
653
|
const t = We(r);
|
|
642
654
|
if (!t) return null;
|
|
643
655
|
const e = Ke(t);
|
|
644
656
|
return e.length === 1 ? e[0] : null;
|
|
645
657
|
}
|
|
646
|
-
function
|
|
658
|
+
function U(r) {
|
|
647
659
|
const t = r.getAttribute("for");
|
|
648
|
-
return t ? Be(r, t) :
|
|
660
|
+
return t ? Be(r, t) : Wr(r);
|
|
649
661
|
}
|
|
650
|
-
function
|
|
662
|
+
function W(r, t) {
|
|
651
663
|
let e = r.querySelector(`:scope > [${Nt}]`);
|
|
652
664
|
if (!e) {
|
|
653
665
|
for (const n of [...r.children])
|
|
@@ -656,11 +668,11 @@ function q(r, t) {
|
|
|
656
668
|
}
|
|
657
669
|
e.textContent !== t && (e.textContent = t);
|
|
658
670
|
}
|
|
659
|
-
function
|
|
671
|
+
function Br(r) {
|
|
660
672
|
r.querySelector(`:scope > [${Nt}]`)?.remove();
|
|
661
673
|
}
|
|
662
|
-
const ie = "data-om-carto-page", se = "data-om-carto-marks", bt = "data-om-carto-credit", Ve = "Built with OnlyMap by NIKA",
|
|
663
|
-
class He extends
|
|
674
|
+
const ie = "data-om-carto-page", se = "data-om-carto-marks", bt = "data-om-carto-credit", Ve = "Built with OnlyMap by NIKA", Kr = `${Ve} · free for non-commercial use`, nt = 2, oe = 1.2, yt = 2.4, ae = 1.5, wt = 1.2, le = 0.3, ce = 0.8, vt = "http://www.w3.org/2000/svg", Vr = 6e4;
|
|
675
|
+
class He extends O {
|
|
664
676
|
static observedAttributes = [...T["om-cartograph"]];
|
|
665
677
|
frameListenerBound = !1;
|
|
666
678
|
/** Fields of the atlas page currently displayed, for {{atlas.<field>}}. */
|
|
@@ -699,14 +711,14 @@ class He extends F {
|
|
|
699
711
|
* runtime's job (issue #41 §9: the om-map carries the key).
|
|
700
712
|
*/
|
|
701
713
|
renderCredit() {
|
|
702
|
-
const t =
|
|
714
|
+
const t = J();
|
|
703
715
|
t && !this.unsubscribeLicense && typeof t.subscribeLicense == "function" && (this.unsubscribeLicense = t.subscribeLicense(() => this.renderCredit()));
|
|
704
716
|
const e = this.creditMode(t, this.hasAttribute("keep-badge")), n = [...this.querySelectorAll("om-text")].some((a) => /onlymap/i.test(a.textContent ?? "")), i = this.querySelector(`:scope > [${bt}]`);
|
|
705
717
|
if (e === "hidden" || n) {
|
|
706
718
|
i?.remove();
|
|
707
719
|
return;
|
|
708
720
|
}
|
|
709
|
-
const o = e === "voluntary" ? Ve :
|
|
721
|
+
const o = e === "voluntary" ? Ve : Kr;
|
|
710
722
|
if (i) {
|
|
711
723
|
i.textContent !== o && (i.textContent = o), this.armCreditPainter(i);
|
|
712
724
|
return;
|
|
@@ -761,12 +773,12 @@ class He extends F {
|
|
|
761
773
|
try {
|
|
762
774
|
window.print();
|
|
763
775
|
} finally {
|
|
764
|
-
o || setTimeout(s,
|
|
776
|
+
o || setTimeout(s, Vr);
|
|
765
777
|
}
|
|
766
778
|
}
|
|
767
779
|
/** Render the whole page to one image, for `flatten`. */
|
|
768
780
|
async buildFlattenedImage(t) {
|
|
769
|
-
const { renderCartograph: e } = await Promise.resolve().then(() =>
|
|
781
|
+
const { renderCartograph: e } = await Promise.resolve().then(() => xr), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
|
|
770
782
|
i.src = URL.createObjectURL(n), i.setAttribute("data-om-carto-flattened", "");
|
|
771
783
|
const o = this.bleedMm;
|
|
772
784
|
return i.style.cssText = `position:absolute;left:${-o}mm;top:${-o}mm;width:calc(100% + ${o * 2}mm);height:calc(100% + ${o * 2}mm);z-index:2147483645;`, await i.decode().catch(() => {
|
|
@@ -791,7 +803,7 @@ class He extends F {
|
|
|
791
803
|
for (const o of e) {
|
|
792
804
|
const s = o.georef, a = s?.groundMetersPerMm() ?? 0;
|
|
793
805
|
t.set(o.id, {
|
|
794
|
-
scale: a > 0 ?
|
|
806
|
+
scale: a > 0 ? Dr(a * 1e3) : void 0,
|
|
795
807
|
crs: s?.crs
|
|
796
808
|
});
|
|
797
809
|
}
|
|
@@ -800,7 +812,7 @@ class He extends F {
|
|
|
800
812
|
page: {
|
|
801
813
|
title: i("title"),
|
|
802
814
|
attribution: i("attribution"),
|
|
803
|
-
date:
|
|
815
|
+
date: qr(),
|
|
804
816
|
notes: i("notes")
|
|
805
817
|
},
|
|
806
818
|
frames: t,
|
|
@@ -817,7 +829,7 @@ class He extends F {
|
|
|
817
829
|
}
|
|
818
830
|
renderNow() {
|
|
819
831
|
const { widthMm: t, heightMm: e } = this.pageSize, n = this.bleedMm;
|
|
820
|
-
this.style.display = "block", this.style.position = "relative", this.style.width = `${t}mm`, this.style.height = `${e}mm`, this.style.margin = n > 0 ? `${n}mm` : "", this.style.overflow = n > 0 ? "visible" : "hidden";
|
|
832
|
+
this.style.display = "block", this.style.position = "relative", this.style.width = `${t}mm`, this.style.height = `${e}mm`, this.style.margin = n > 0 ? `${n}mm` : "", this.style.overflow = n > 0 ? "visible" : "hidden", this.applyThemeOverride("bg", "--om-carto-bg"), this.applyThemeOverride("color", "--om-carto-ink"), this.applyThemeOverride("font", "--om-carto-font");
|
|
821
833
|
let i = this.querySelector(`style[${ie}]`);
|
|
822
834
|
i || (i = document.createElement("style"), i.setAttribute(ie, ""), this.prepend(i));
|
|
823
835
|
const o = t + n * 2, s = e + n * 2;
|
|
@@ -872,11 +884,11 @@ class He extends F {
|
|
|
872
884
|
this.style.removeProperty("filter");
|
|
873
885
|
return;
|
|
874
886
|
}
|
|
875
|
-
|
|
887
|
+
Sr(this.ownerDocument), this.style.filter = `url(#${Re(t)})`;
|
|
876
888
|
}
|
|
877
889
|
}
|
|
878
890
|
k("om-cartograph", He);
|
|
879
|
-
function
|
|
891
|
+
function Hr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
|
|
880
892
|
const o = n > 0 ? n : e * 1.2, s = [];
|
|
881
893
|
for (const c of r.split(/\r?\n/)) {
|
|
882
894
|
const u = c.split(/\s+/).filter((h) => h !== "");
|
|
@@ -906,15 +918,15 @@ function Kr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
|
|
|
906
918
|
c.baselineY = a + u * o, c.width > l && (l = c.width);
|
|
907
919
|
}), { lines: s, lineHeight: o, maxWidth: l };
|
|
908
920
|
}
|
|
909
|
-
function
|
|
921
|
+
function Mi(r) {
|
|
910
922
|
if (typeof document > "u") return null;
|
|
911
923
|
const e = document.createElement("canvas").getContext("2d");
|
|
912
924
|
return e ? (e.font = r, (n) => e.measureText(n).width) : null;
|
|
913
925
|
}
|
|
914
|
-
function
|
|
926
|
+
function Yr(r, t, e) {
|
|
915
927
|
return r === "center" ? (t - e) / 2 : r === "end" || r === "right" ? t - e : 0;
|
|
916
928
|
}
|
|
917
|
-
class Ye extends
|
|
929
|
+
class Ye extends O {
|
|
918
930
|
static observedAttributes = [...T["om-text"]];
|
|
919
931
|
renderNow() {
|
|
920
932
|
this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden";
|
|
@@ -934,18 +946,18 @@ class Ye extends F {
|
|
|
934
946
|
/** Re-run token substitution from the authored templates. */
|
|
935
947
|
resolveTokens() {
|
|
936
948
|
const t = this.closest("om-cartograph");
|
|
937
|
-
t && typeof t.tokenContext == "function" &&
|
|
949
|
+
t && typeof t.tokenContext == "function" && Gr(this, t.tokenContext());
|
|
938
950
|
}
|
|
939
951
|
paintCartograph(t, e) {
|
|
940
|
-
const { w: n, h: i } =
|
|
952
|
+
const { w: n, h: i } = S(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
|
|
941
953
|
if (o <= 0 || s <= 0) return;
|
|
942
|
-
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l =
|
|
954
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
|
|
943
955
|
l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
|
|
944
956
|
const c = (this.textContent ?? "").trim();
|
|
945
957
|
if (c === "") return;
|
|
946
958
|
const u = $t(a?.fontSize, 12), m = a?.lineHeight === "normal" ? u * 1.4 : $t(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", h = a?.fontWeight || "400", f = u * e.scale, g = m * e.scale, p = `${h} ${f}px ${d}`;
|
|
947
|
-
t.save(), t.font = p, t.fillStyle =
|
|
948
|
-
const b =
|
|
959
|
+
t.save(), t.font = p, t.fillStyle = F(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
|
|
960
|
+
const b = Hr({
|
|
949
961
|
text: c,
|
|
950
962
|
maxWidth: o,
|
|
951
963
|
fontSizePx: f,
|
|
@@ -954,34 +966,34 @@ class Ye extends F {
|
|
|
954
966
|
}), w = a?.textAlign || "start";
|
|
955
967
|
for (const y of b.lines) {
|
|
956
968
|
if (y.baselineY > s + g) break;
|
|
957
|
-
t.fillText(y.text,
|
|
969
|
+
t.fillText(y.text, Yr(w, o, y.width), y.baselineY);
|
|
958
970
|
}
|
|
959
971
|
t.restore();
|
|
960
972
|
}
|
|
961
973
|
}
|
|
962
974
|
k("om-text", Ye);
|
|
963
|
-
const
|
|
964
|
-
let
|
|
975
|
+
const Xr = 63710087714e-4;
|
|
976
|
+
let Jr = Xr;
|
|
965
977
|
const it = Math.PI / 180;
|
|
966
|
-
function
|
|
978
|
+
function Zr(r, t, e = Jr) {
|
|
967
979
|
const n = (t[1] - r[1]) * it, i = (t[0] - r[0]) * it, o = r[1] * it, s = t[1] * it, a = Math.sin(n / 2) ** 2 + Math.cos(o) * Math.cos(s) * Math.sin(i / 2) ** 2;
|
|
968
980
|
return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
|
|
969
981
|
}
|
|
970
|
-
const
|
|
982
|
+
const et = 6378137, ue = Math.PI / 180, he = 180 / Math.PI, me = 85.0511287798066, Pt = 2 * Math.PI * et / 360;
|
|
971
983
|
function Gt([r, t]) {
|
|
972
984
|
const e = Math.max(-me, Math.min(me, t));
|
|
973
|
-
return [
|
|
985
|
+
return [et * r * ue, et * Math.log(Math.tan(Math.PI / 4 + e * ue / 2))];
|
|
974
986
|
}
|
|
975
987
|
function dt([r, t]) {
|
|
976
|
-
return [r /
|
|
988
|
+
return [r / et * he, (2 * Math.atan(Math.exp(t / et)) - Math.PI / 2) * he];
|
|
977
989
|
}
|
|
978
|
-
const
|
|
990
|
+
const Qr = {
|
|
979
991
|
code: "EPSG:3857",
|
|
980
992
|
units: "linear",
|
|
981
993
|
metresPerUnit: 1,
|
|
982
994
|
forward: Gt,
|
|
983
995
|
inverse: dt
|
|
984
|
-
},
|
|
996
|
+
}, tn = {
|
|
985
997
|
code: "EPSG:4326",
|
|
986
998
|
units: "degree",
|
|
987
999
|
metresPerUnit: Pt,
|
|
@@ -997,13 +1009,13 @@ function qt(r) {
|
|
|
997
1009
|
}
|
|
998
1010
|
function Xe(r) {
|
|
999
1011
|
const t = qt(r) ?? "EPSG:3857";
|
|
1000
|
-
return t === "EPSG:3857" || t === "EPSG:900913" ?
|
|
1012
|
+
return t === "EPSG:3857" || t === "EPSG:900913" ? Qr : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? tn : null;
|
|
1001
1013
|
}
|
|
1002
1014
|
const Je = /* @__PURE__ */ new Map();
|
|
1003
1015
|
function Tt(r, t) {
|
|
1004
1016
|
return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
|
|
1005
1017
|
}
|
|
1006
|
-
async function
|
|
1018
|
+
async function en(r) {
|
|
1007
1019
|
const t = Je.get(r);
|
|
1008
1020
|
if (typeof t == "string") return t;
|
|
1009
1021
|
const e = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
|
|
@@ -1013,22 +1025,22 @@ async function Qr(r) {
|
|
|
1013
1025
|
const { CRS_DEFS: n } = await import("./crs-BzE_KP4M.js");
|
|
1014
1026
|
return n[e]?.def ?? null;
|
|
1015
1027
|
}
|
|
1016
|
-
function
|
|
1028
|
+
function rn(r) {
|
|
1017
1029
|
if (r.projName === "longlat") return { units: "degree", metresPerUnit: Pt };
|
|
1018
1030
|
if (typeof r.to_meter == "number" && r.to_meter > 0) return { units: "linear", metresPerUnit: r.to_meter };
|
|
1019
1031
|
const t = (r.units ?? "m").toLowerCase();
|
|
1020
1032
|
return t.startsWith("deg") ? { units: "degree", metresPerUnit: Pt } : t.includes("ft") || t.includes("foot") ? { units: "linear", metresPerUnit: 0.3048 } : { units: "linear", metresPerUnit: 1 };
|
|
1021
1033
|
}
|
|
1022
|
-
async function
|
|
1034
|
+
async function nn(r, t) {
|
|
1023
1035
|
const e = qt(r) ?? "EPSG:3857", n = Je.get(e);
|
|
1024
1036
|
if (n && typeof n != "string") return n;
|
|
1025
1037
|
if (!t) {
|
|
1026
1038
|
const u = Xe(e);
|
|
1027
1039
|
if (u) return u;
|
|
1028
1040
|
}
|
|
1029
|
-
const i = t?.trim() || await
|
|
1041
|
+
const i = t?.trim() || await en(e);
|
|
1030
1042
|
if (!i) return null;
|
|
1031
|
-
const o = (await import("./index-CcLC9jE5.js")).default, a = o(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } =
|
|
1043
|
+
const o = (await import("./index-CcLC9jE5.js")).default, a = o(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } = rn(new o.Proj(i));
|
|
1032
1044
|
return {
|
|
1033
1045
|
code: e,
|
|
1034
1046
|
units: l,
|
|
@@ -1037,20 +1049,20 @@ async function en(r, t) {
|
|
|
1037
1049
|
inverse: (u) => a.forward(u)
|
|
1038
1050
|
};
|
|
1039
1051
|
}
|
|
1040
|
-
const de = Math.PI / 180,
|
|
1041
|
-
function
|
|
1042
|
-
const e = Math.max(-
|
|
1052
|
+
const de = Math.PI / 180, sn = 180 / Math.PI, on = { code: "EPSG:3857", forward: Gt, inverse: dt }, Si = Gt, Ci = dt, fe = 6378137, pe = 89.9;
|
|
1053
|
+
function an([r, t]) {
|
|
1054
|
+
const e = Math.max(-pe, Math.min(pe, t));
|
|
1043
1055
|
return [fe * r * de, fe * Math.log(Math.tan(Math.PI / 4 + e * de / 2))];
|
|
1044
1056
|
}
|
|
1045
|
-
const
|
|
1046
|
-
function
|
|
1057
|
+
const ln = { code: "EPSG:3857", forward: an, inverse: dt }, Lt = qt;
|
|
1058
|
+
function Y(r) {
|
|
1047
1059
|
return Xe(r);
|
|
1048
1060
|
}
|
|
1049
1061
|
async function Rt(r, t) {
|
|
1050
|
-
return
|
|
1062
|
+
return nn(r, t);
|
|
1051
1063
|
}
|
|
1052
|
-
const
|
|
1053
|
-
function
|
|
1064
|
+
const ki = Tt;
|
|
1065
|
+
function cn(r, t) {
|
|
1054
1066
|
const e = t.length, n = r.map((i, o) => [...i, t[o]]);
|
|
1055
1067
|
for (let i = 0; i < e; i++) {
|
|
1056
1068
|
let o = i;
|
|
@@ -1066,23 +1078,23 @@ function an(r, t) {
|
|
|
1066
1078
|
}
|
|
1067
1079
|
return n.map((i, o) => i[e] / i[o]);
|
|
1068
1080
|
}
|
|
1069
|
-
function
|
|
1081
|
+
function un(r, t) {
|
|
1070
1082
|
if (r.length !== 4 || t.length !== 4) return null;
|
|
1071
1083
|
const e = r.reduce((m, d) => m + d[0], 0) / 4, n = r.reduce((m, d) => m + d[1], 0) / 4, i = r.reduce((m, d) => m + Math.hypot(d[0] - e, d[1] - n), 0) / 4, o = i > 1e-12 ? Math.SQRT2 / i : 1, s = (m) => [(m[0] - e) * o, (m[1] - n) * o], a = [], l = [];
|
|
1072
1084
|
for (let m = 0; m < 4; m++) {
|
|
1073
1085
|
const [d, h] = s(r[m]), [f, g] = t[m];
|
|
1074
1086
|
a.push([d, h, 1, 0, 0, 0, -d * f, -h * f]), l.push(f), a.push([0, 0, 0, d, h, 1, -d * g, -h * g]), l.push(g);
|
|
1075
1087
|
}
|
|
1076
|
-
const c =
|
|
1088
|
+
const c = cn(a, l);
|
|
1077
1089
|
if (!c || c.some((m) => !Number.isFinite(m))) return null;
|
|
1078
1090
|
const u = (m) => [m[0] / o + e, m[1] / o + n];
|
|
1079
1091
|
return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: s, denormalize: u };
|
|
1080
1092
|
}
|
|
1081
|
-
function
|
|
1093
|
+
function ge(r, [t, e]) {
|
|
1082
1094
|
const n = r[6] * t + r[7] * e + r[8];
|
|
1083
1095
|
return Math.abs(n) < 1e-12 ? null : [(r[0] * t + r[1] * e + r[2]) / n, (r[3] * t + r[4] * e + r[5]) / n];
|
|
1084
1096
|
}
|
|
1085
|
-
function
|
|
1097
|
+
function hn(r) {
|
|
1086
1098
|
const [t, e, n, i, o, s, a, l, c] = r, u = t * (o * c - s * l) - e * (i * c - s * a) + n * (i * l - o * a);
|
|
1087
1099
|
return !Number.isFinite(u) || Math.abs(u) < 1e-15 ? null : [
|
|
1088
1100
|
(o * c - s * l) / u,
|
|
@@ -1096,7 +1108,7 @@ function cn(r) {
|
|
|
1096
1108
|
(t * o - e * i) / u
|
|
1097
1109
|
];
|
|
1098
1110
|
}
|
|
1099
|
-
function
|
|
1111
|
+
function mn(r, t) {
|
|
1100
1112
|
let e = r;
|
|
1101
1113
|
for (; e - t > 180; ) e -= 360;
|
|
1102
1114
|
for (; t - e > 180; ) e += 360;
|
|
@@ -1106,19 +1118,19 @@ const Ze = (r) => {
|
|
|
1106
1118
|
let t = ((r + 180) % 360 + 360) % 360 - 180;
|
|
1107
1119
|
return t === -180 && (t = 180), t;
|
|
1108
1120
|
};
|
|
1109
|
-
function
|
|
1110
|
-
const o = n ?? (i ?
|
|
1121
|
+
function tt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i = !1 }) {
|
|
1122
|
+
const o = n ?? (i ? ln : on), s = r[0][0], a = (b) => i ? b : mn(b, s), l = (b) => i ? b : Ze(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => o.forward(b)), m = [
|
|
1111
1123
|
[0, 0],
|
|
1112
1124
|
[t, 0],
|
|
1113
1125
|
[t, e],
|
|
1114
1126
|
[0, e]
|
|
1115
|
-
], d = t > 0 && e > 0 ?
|
|
1127
|
+
], d = t > 0 && e > 0 ? un(u, m) : null, h = d ? hn(d.matrix) : null, f = !d || !h, g = (b, w = i ? 16 : 1) => {
|
|
1116
1128
|
let y = 0, A = p.unproject(0, b);
|
|
1117
1129
|
if (!A) return null;
|
|
1118
1130
|
for (let v = 1; v <= w; v++) {
|
|
1119
|
-
const
|
|
1120
|
-
if (
|
|
1121
|
-
y +=
|
|
1131
|
+
const $ = p.unproject(t * v / w, b);
|
|
1132
|
+
if (!$) return null;
|
|
1133
|
+
y += Zr(A, $), A = $;
|
|
1122
1134
|
}
|
|
1123
1135
|
return y;
|
|
1124
1136
|
}, p = {
|
|
@@ -1130,12 +1142,12 @@ function Q({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i =
|
|
|
1130
1142
|
continuous: i,
|
|
1131
1143
|
project(b) {
|
|
1132
1144
|
if (!d) return null;
|
|
1133
|
-
const w = o.forward([a(b[0]), b[1]]), y =
|
|
1145
|
+
const w = o.forward([a(b[0]), b[1]]), y = ge(d.matrix, d.normalize(w));
|
|
1134
1146
|
return y && Number.isFinite(y[0]) && Number.isFinite(y[1]) ? { xMm: y[0], yMm: y[1] } : null;
|
|
1135
1147
|
},
|
|
1136
1148
|
unproject(b, w) {
|
|
1137
1149
|
if (!d || !h) return null;
|
|
1138
|
-
const y =
|
|
1150
|
+
const y = ge(h, [b, w]);
|
|
1139
1151
|
if (!y) return null;
|
|
1140
1152
|
const A = o.inverse(d.denormalize(y));
|
|
1141
1153
|
return Number.isFinite(A[0]) && Number.isFinite(A[1]) ? [l(A[0]), A[1]] : null;
|
|
@@ -1149,7 +1161,7 @@ function Q({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i =
|
|
|
1149
1161
|
};
|
|
1150
1162
|
return p;
|
|
1151
1163
|
}
|
|
1152
|
-
function
|
|
1164
|
+
function X(r) {
|
|
1153
1165
|
if (r == null || r.trim() === "") return null;
|
|
1154
1166
|
let t;
|
|
1155
1167
|
try {
|
|
@@ -1184,16 +1196,16 @@ function H(r) {
|
|
|
1184
1196
|
}
|
|
1185
1197
|
return e;
|
|
1186
1198
|
}
|
|
1187
|
-
function
|
|
1199
|
+
function dn(r) {
|
|
1188
1200
|
if (r.degenerate) return null;
|
|
1189
1201
|
const t = r.unproject(r.widthMm / 2, r.heightMm / 2);
|
|
1190
1202
|
if (!t) return null;
|
|
1191
1203
|
const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t), o = r.project(n);
|
|
1192
1204
|
if (!i || !o) return null;
|
|
1193
1205
|
const s = o.xMm - i.xMm, a = o.yMm - i.yMm;
|
|
1194
|
-
return Math.abs(s) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(s, -a) *
|
|
1206
|
+
return Math.abs(s) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(s, -a) * sn % 360 + 360) % 360;
|
|
1195
1207
|
}
|
|
1196
|
-
function
|
|
1208
|
+
function fn(r) {
|
|
1197
1209
|
if (r.degenerate) return null;
|
|
1198
1210
|
const { widthMm: t, heightMm: e } = r, n = [];
|
|
1199
1211
|
for (const s of [0.02, 0.5, 0.98]) {
|
|
@@ -1204,7 +1216,7 @@ function mn(r) {
|
|
|
1204
1216
|
const i = Math.min(...n), o = Math.max(...n);
|
|
1205
1217
|
return i > 0 ? (o - i) / i : null;
|
|
1206
1218
|
}
|
|
1207
|
-
function
|
|
1219
|
+
function xi(r, t, e, n) {
|
|
1208
1220
|
return [
|
|
1209
1221
|
[r, n],
|
|
1210
1222
|
[e, n],
|
|
@@ -1212,8 +1224,8 @@ function Ci(r, t, e, n) {
|
|
|
1212
1224
|
[r, t]
|
|
1213
1225
|
];
|
|
1214
1226
|
}
|
|
1215
|
-
const
|
|
1216
|
-
function
|
|
1227
|
+
const pn = (r) => r.toLowerCase().startsWith("on");
|
|
1228
|
+
function gn(r, t) {
|
|
1217
1229
|
const e = (n) => {
|
|
1218
1230
|
const i = n.tagName.toLowerCase();
|
|
1219
1231
|
if (i === "script") {
|
|
@@ -1224,7 +1236,7 @@ function fn(r, t) {
|
|
|
1224
1236
|
if (i === "style" || i === "link" || i === "iframe" || i === "object" || i === "embed") return null;
|
|
1225
1237
|
const o = t.createElement(i);
|
|
1226
1238
|
for (const s of n.attributes)
|
|
1227
|
-
|
|
1239
|
+
pn(s.name) || /^\s*javascript:/i.test(s.value) || o.setAttribute(s.name, s.value);
|
|
1228
1240
|
for (const s of n.childNodes)
|
|
1229
1241
|
if (s.nodeType === 3) o.appendChild(t.createTextNode(s.textContent ?? ""));
|
|
1230
1242
|
else if (s.nodeType === 1) {
|
|
@@ -1235,12 +1247,12 @@ function fn(r, t) {
|
|
|
1235
1247
|
};
|
|
1236
1248
|
return e(r);
|
|
1237
1249
|
}
|
|
1238
|
-
async function
|
|
1250
|
+
async function bn(r, t = document) {
|
|
1239
1251
|
const e = await fetch(r, { credentials: "same-origin", cache: "no-store" });
|
|
1240
1252
|
if (!e.ok) throw new Error(`fetching ${r} failed with HTTP ${e.status}`);
|
|
1241
1253
|
const n = await e.text(), o = new DOMParser().parseFromString(n, "text/html").querySelector("om-map");
|
|
1242
1254
|
if (!o) throw new Error(`${r} contains no <om-map>`);
|
|
1243
|
-
const s =
|
|
1255
|
+
const s = gn(o, t);
|
|
1244
1256
|
if (!s) throw new Error(`${r} could not be adopted`);
|
|
1245
1257
|
return s;
|
|
1246
1258
|
}
|
|
@@ -1265,8 +1277,8 @@ function ut(r) {
|
|
|
1265
1277
|
pitch: Number(r.getAttribute("pitch")) || 0
|
|
1266
1278
|
};
|
|
1267
1279
|
}
|
|
1268
|
-
function
|
|
1269
|
-
const o = (l) =>
|
|
1280
|
+
function $i(r, t, e, n, i = 60) {
|
|
1281
|
+
const o = (l) => Ft(r, { ...t, pitch: l }, e, n) !== null;
|
|
1270
1282
|
if (o(i)) return i;
|
|
1271
1283
|
if (!o(0)) return 0;
|
|
1272
1284
|
let s = 0, a = i;
|
|
@@ -1276,7 +1288,7 @@ function ki(r, t, e, n, i = 60) {
|
|
|
1276
1288
|
}
|
|
1277
1289
|
return s;
|
|
1278
1290
|
}
|
|
1279
|
-
function
|
|
1291
|
+
function Ft(r, t, e, n) {
|
|
1280
1292
|
if (!(e > 0) || !(n > 0)) return null;
|
|
1281
1293
|
const i = new r.WebMercatorViewport({
|
|
1282
1294
|
width: e,
|
|
@@ -1299,44 +1311,44 @@ function It(r, t, e, n) {
|
|
|
1299
1311
|
}
|
|
1300
1312
|
return s;
|
|
1301
1313
|
}
|
|
1302
|
-
async function
|
|
1314
|
+
async function yn(r, t) {
|
|
1303
1315
|
const e = await Te();
|
|
1304
1316
|
if (t && typeof t != "string") return { core: e, map: t };
|
|
1305
1317
|
if (!t) throw new Error("a live frame needs src= or an inline <om-map> child");
|
|
1306
|
-
const n = await
|
|
1318
|
+
const n = await bn(t, r.ownerDocument);
|
|
1307
1319
|
return { core: e, map: n };
|
|
1308
1320
|
}
|
|
1309
1321
|
function At(r, t) {
|
|
1310
|
-
r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)),
|
|
1322
|
+
r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)), wn(r, t);
|
|
1311
1323
|
}
|
|
1312
|
-
function
|
|
1324
|
+
function wn(r, t) {
|
|
1313
1325
|
const e = r;
|
|
1314
1326
|
typeof e.setViewInternal == "function" ? e.setViewInternal({ longitude: t.center[0], latitude: t.center[1], zoom: t.zoom, pitch: t.pitch, bearing: t.bearing }) : typeof e.flyTo == "function" && e.flyTo(t.center, t.zoom, { duration: 0 });
|
|
1315
1327
|
}
|
|
1316
|
-
const
|
|
1317
|
-
function
|
|
1328
|
+
const vn = [".png", ".jpg", ".jpeg", ".webp", ".avif", ".gif", ".svg"], An = [".html", ".htm"];
|
|
1329
|
+
function It(r) {
|
|
1318
1330
|
const t = r.trim().split(/[?#]/, 1)[0]?.toLowerCase() ?? "";
|
|
1319
|
-
return
|
|
1331
|
+
return An.some((e) => t.endsWith(e)) ? "map" : vn.some((e) => t.endsWith(e)) ? "raster" : null;
|
|
1320
1332
|
}
|
|
1321
|
-
function
|
|
1333
|
+
function Mn(r, t) {
|
|
1322
1334
|
const e = [], n = [...r.children].find(
|
|
1323
1335
|
(s) => s.tagName.toLowerCase() === "om-map" && s !== t
|
|
1324
1336
|
);
|
|
1325
1337
|
n && e.push({ kind: "inline", key: "inline", el: r, map: n });
|
|
1326
1338
|
const i = r.getAttribute("src")?.trim();
|
|
1327
|
-
i && e.push({ kind:
|
|
1339
|
+
i && e.push({ kind: It(i) ?? "map", key: `src:${i}`, el: r, src: i });
|
|
1328
1340
|
let o = 0;
|
|
1329
1341
|
for (const s of r.children) {
|
|
1330
1342
|
if (s.tagName.toLowerCase() !== "om-source") continue;
|
|
1331
1343
|
const a = s.getAttribute("src")?.trim();
|
|
1332
|
-
a && e.push({ kind:
|
|
1344
|
+
a && e.push({ kind: It(a) ?? "map", key: `source:${o++}:${a}`, el: s, src: a });
|
|
1333
1345
|
}
|
|
1334
1346
|
return e;
|
|
1335
1347
|
}
|
|
1336
|
-
function
|
|
1348
|
+
function Sn(r) {
|
|
1337
1349
|
return r.map((t) => t.key).join("|");
|
|
1338
1350
|
}
|
|
1339
|
-
async function
|
|
1351
|
+
async function Cn(r, t, e) {
|
|
1340
1352
|
const n = Math.max(1, Math.round(t.w * e)), i = Math.max(1, Math.round(t.h * e)), o = r.cloneNode(!0);
|
|
1341
1353
|
o.removeAttribute("style"), o.setAttribute("width", String(n)), o.setAttribute("height", String(i)), o.setAttribute("preserveAspectRatio", "none");
|
|
1342
1354
|
const s = new XMLSerializer().serializeToString(o), a = new Image();
|
|
@@ -1349,7 +1361,7 @@ async function Mn(r, t, e) {
|
|
|
1349
1361
|
return a;
|
|
1350
1362
|
}
|
|
1351
1363
|
const Mt = "data-om-carto-placeholder", be = "data-om-carto-source", St = "data-om-carto-capture", Ct = "data-om-carto-overview", ye = "http://www.w3.org/2000/svg", we = 24, ve = 0.25;
|
|
1352
|
-
class Qe extends
|
|
1364
|
+
class Qe extends O {
|
|
1353
1365
|
static observedAttributes = [...T["om-frame"]];
|
|
1354
1366
|
/** Resolved non-builtin CRS planes, so a re-render does not re-await proj4. */
|
|
1355
1367
|
resolvedForward = null;
|
|
@@ -1426,22 +1438,22 @@ class Qe extends F {
|
|
|
1426
1438
|
* than caching it correctly.
|
|
1427
1439
|
*/
|
|
1428
1440
|
get georef() {
|
|
1429
|
-
const { w: t, h: e } =
|
|
1441
|
+
const { w: t, h: e } = S(this);
|
|
1430
1442
|
if (t <= 0 || e <= 0) return null;
|
|
1431
1443
|
if (this.mode === "live" && !this.showingRaster) {
|
|
1432
1444
|
if (!this.liveCorners) return null;
|
|
1433
1445
|
const l = this.liveMap?.projectedCrs?.() ?? null;
|
|
1434
1446
|
if (l) {
|
|
1435
|
-
const c = this.resolvedForwardKey === `${l}|` ? this.resolvedForward :
|
|
1436
|
-
return c ?
|
|
1447
|
+
const c = this.resolvedForwardKey === `${l}|` ? this.resolvedForward : Y(l);
|
|
1448
|
+
return c ? tt({ corners: this.liveCorners, widthMm: t, heightMm: e, crsForward: c }) : (this.ensureLiveCrsForward(l), null);
|
|
1437
1449
|
}
|
|
1438
|
-
return
|
|
1450
|
+
return tt({ corners: this.liveCorners, widthMm: t, heightMm: e, continuous: !0 });
|
|
1439
1451
|
}
|
|
1440
|
-
const n = this.georefHost, i =
|
|
1452
|
+
const n = this.georefHost, i = X(n.getAttribute("corners"));
|
|
1441
1453
|
if (!i) return null;
|
|
1442
1454
|
const o = Lt(n.getAttribute("crs")) ?? "EPSG:3857", s = n.getAttribute("crs-def");
|
|
1443
|
-
let a = s ? null :
|
|
1444
|
-
return !a && this.resolvedForwardKey === `${o}|${s ?? ""}` && (a = this.resolvedForward), a ?
|
|
1455
|
+
let a = s ? null : Y(o);
|
|
1456
|
+
return !a && this.resolvedForwardKey === `${o}|${s ?? ""}` && (a = this.resolvedForward), a ? tt({ corners: i, widthMm: t, heightMm: e, crsForward: a }) : null;
|
|
1445
1457
|
}
|
|
1446
1458
|
/**
|
|
1447
1459
|
* Resolve a live map's CRS through the core's lazy proj4, into the same
|
|
@@ -1517,7 +1529,7 @@ class Qe extends F {
|
|
|
1517
1529
|
const e = t.style;
|
|
1518
1530
|
e.position = "absolute", e.inset = "0", e.width = "100%", e.height = "100%", e.display = "block", t instanceof SVGSVGElement ? t.setAttribute("preserveAspectRatio", "none") : e.objectFit = "fill";
|
|
1519
1531
|
const n = Lt(this.getAttribute("crs")) ?? "EPSG:3857", i = this.getAttribute("crs-def"), o = `${n}|${i ?? ""}`;
|
|
1520
|
-
if ((i != null ||
|
|
1532
|
+
if ((i != null || Y(n) == null) && this.resolvedForwardKey !== o) {
|
|
1521
1533
|
const a = ++this.resolveToken;
|
|
1522
1534
|
this.resolvedForward = null, this.resolvedForwardKey = null, Rt(n, i).then((l) => {
|
|
1523
1535
|
if (a === this.resolveToken) {
|
|
@@ -1532,7 +1544,7 @@ class Qe extends F {
|
|
|
1532
1544
|
});
|
|
1533
1545
|
return;
|
|
1534
1546
|
}
|
|
1535
|
-
if (!
|
|
1547
|
+
if (!X(this.getAttribute("corners"))) {
|
|
1536
1548
|
this.showPlaceholder("bad-corners", 'Static frame needs corners="[[lng,lat] × 4]" (tl, tr, br, bl).');
|
|
1537
1549
|
return;
|
|
1538
1550
|
}
|
|
@@ -1558,7 +1570,7 @@ class Qe extends F {
|
|
|
1558
1570
|
this.showPlaceholder("no-source", "Live frame needs src=, an <om-source> child, or an inline <om-map>.");
|
|
1559
1571
|
return;
|
|
1560
1572
|
}
|
|
1561
|
-
const s =
|
|
1573
|
+
const s = Sn(o);
|
|
1562
1574
|
s !== this.knownSourceList && (this.knownSourceList = s, this.sourceCursor = 0, this.settledSource = null, this.removeAttribute(be));
|
|
1563
1575
|
const a = Math.min(this.sourceCursor, o.length - 1), l = o[a];
|
|
1564
1576
|
if (l.kind === "raster") {
|
|
@@ -1587,7 +1599,7 @@ class Qe extends F {
|
|
|
1587
1599
|
renderCaptureSource(t, e) {
|
|
1588
1600
|
const n = t.src ?? "";
|
|
1589
1601
|
let i = this.querySelector(`:scope > img[${St}]`);
|
|
1590
|
-
if (i || (i = document.createElement("img"), i.setAttribute(St, ""), i.alt = "", this.appendChild(i)), i.getAttribute("src") !== n && i.setAttribute("src", n), i.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:fill;", this.captureImage = i, !
|
|
1602
|
+
if (i || (i = document.createElement("img"), i.setAttribute(St, ""), i.alt = "", this.appendChild(i)), i.getAttribute("src") !== n && i.setAttribute("src", n), i.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:fill;", this.captureImage = i, !X(this.georefHostFor(t).getAttribute("corners"))) {
|
|
1591
1603
|
this.showPlaceholder("bad-corners", 'A capture <om-source> needs corners="[[lng,lat] × 4]" (tl, tr, br, bl).');
|
|
1592
1604
|
return;
|
|
1593
1605
|
}
|
|
@@ -1608,7 +1620,7 @@ class Qe extends F {
|
|
|
1608
1620
|
* inline source on the next render.
|
|
1609
1621
|
*/
|
|
1610
1622
|
sources() {
|
|
1611
|
-
return
|
|
1623
|
+
return Mn(this, this.liveMapOwned ? this.liveMap : null);
|
|
1612
1624
|
}
|
|
1613
1625
|
/**
|
|
1614
1626
|
* Move to the next source, or report that there is none.
|
|
@@ -1677,9 +1689,9 @@ class Qe extends F {
|
|
|
1677
1689
|
}
|
|
1678
1690
|
updateLiveCorners(t = ut(this)) {
|
|
1679
1691
|
if (!t) return;
|
|
1680
|
-
const e =
|
|
1692
|
+
const e = J();
|
|
1681
1693
|
if (!e) return;
|
|
1682
|
-
const { w: n, h: i } =
|
|
1694
|
+
const { w: n, h: i } = S(this), s = this.liveMap?.groundCorners?.(n * D, i * D) ?? Ft(e, t, n * D, i * D), a = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
|
|
1683
1695
|
this.liveCorners = s, a && this.liveMap && this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } })), this.applyReferenceScale(), s ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder("degenerate-view", "This frame's box cannot be georeferenced — give it a positive width and height.");
|
|
1684
1696
|
}
|
|
1685
1697
|
async mountLive(t, e, n) {
|
|
@@ -1687,15 +1699,15 @@ class Qe extends F {
|
|
|
1687
1699
|
this.mounting = !0, this.mountingSource = t.key;
|
|
1688
1700
|
let o = !1;
|
|
1689
1701
|
try {
|
|
1690
|
-
const { core: s, map: a } = await
|
|
1702
|
+
const { core: s, map: a } = await yn(this, t.map ?? t.src);
|
|
1691
1703
|
if (i !== this.mountToken || !this.isConnected || this.mode !== "live") return;
|
|
1692
1704
|
const l = ut(this);
|
|
1693
1705
|
if (!l) return;
|
|
1694
1706
|
this.appliedCameraKey = JSON.stringify(l), At(a, l);
|
|
1695
1707
|
const c = a;
|
|
1696
1708
|
c.style.position = "absolute", c.style.inset = "0", c.style.display = "block", a.setAttribute("data-om-carto-frame", ""), this.liveMapOwned = a.parentElement !== this, this.liveMapOwned && this.appendChild(a), this.liveMap = c, c.addEventListener("om-view-changed", this.onLiveViewSettled), this.mountedSource = t.key, this.sizeLiveMap(), this.clearPlaceholder();
|
|
1697
|
-
const { w: u, h: m } =
|
|
1698
|
-
if (this.liveCorners =
|
|
1709
|
+
const { w: u, h: m } = S(this);
|
|
1710
|
+
if (this.liveCorners = Ft(s, l, u * D, m * D), this.applyReferenceScale(), await c.ready, i !== this.mountToken || (At(a, l), await c.whenSettled?.({ timeout: 2e4 }), i !== this.mountToken)) return;
|
|
1699
1711
|
if (c.hasDrawableContent?.() === !1) {
|
|
1700
1712
|
if (this.advanceSource(n)) return;
|
|
1701
1713
|
console.warn(
|
|
@@ -1748,7 +1760,7 @@ class Qe extends F {
|
|
|
1748
1760
|
e?.remove();
|
|
1749
1761
|
return;
|
|
1750
1762
|
}
|
|
1751
|
-
const { w: s, h: a } =
|
|
1763
|
+
const { w: s, h: a } = S(this), l = [], [c, u, m, d] = o.corners, h = [
|
|
1752
1764
|
[c, u],
|
|
1753
1765
|
[u, m],
|
|
1754
1766
|
[m, d],
|
|
@@ -1756,8 +1768,8 @@ class Qe extends F {
|
|
|
1756
1768
|
];
|
|
1757
1769
|
for (const [b, w] of h)
|
|
1758
1770
|
for (let y = 0; y < we; y++) {
|
|
1759
|
-
const A = y / we, v = [b[0] + (w[0] - b[0]) * A, b[1] + (w[1] - b[1]) * A],
|
|
1760
|
-
|
|
1771
|
+
const A = y / we, v = [b[0] + (w[0] - b[0]) * A, b[1] + (w[1] - b[1]) * A], $ = i.project(v);
|
|
1772
|
+
$ && l.push(`${$.xMm.toFixed(3)},${$.yMm.toFixed(3)}`);
|
|
1761
1773
|
}
|
|
1762
1774
|
if (l.length < 3) {
|
|
1763
1775
|
e?.remove();
|
|
@@ -1855,9 +1867,9 @@ class Qe extends F {
|
|
|
1855
1867
|
* follows from the same source as any authored camera.
|
|
1856
1868
|
*/
|
|
1857
1869
|
fitBounds(t) {
|
|
1858
|
-
const [e, n, i, o] = t, { w: s, h: a } =
|
|
1870
|
+
const [e, n, i, o] = t, { w: s, h: a } = S(this);
|
|
1859
1871
|
if (s <= 0 || a <= 0) return;
|
|
1860
|
-
const l =
|
|
1872
|
+
const l = J();
|
|
1861
1873
|
if (!l) return;
|
|
1862
1874
|
const c = new l.WebMercatorViewport({ width: s * D, height: a * D, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
|
|
1863
1875
|
[e, n],
|
|
@@ -1882,7 +1894,7 @@ class Qe extends F {
|
|
|
1882
1894
|
return;
|
|
1883
1895
|
}
|
|
1884
1896
|
const e = this.vector;
|
|
1885
|
-
e && (this.captureImage = await
|
|
1897
|
+
e && (this.captureImage = await Cn(e, S(this), t.pxPerMm));
|
|
1886
1898
|
}
|
|
1887
1899
|
/** Export hook: forget the capture, so a failed pre-pass never reuses it. */
|
|
1888
1900
|
discardCartograph() {
|
|
@@ -1903,13 +1915,13 @@ class Qe extends F {
|
|
|
1903
1915
|
this.printing = !1, this.querySelector(":scope > img[data-om-carto-print]")?.remove(), this.liveMap && (this.liveMap.hidden = !1);
|
|
1904
1916
|
}
|
|
1905
1917
|
paintCartograph(t, e) {
|
|
1906
|
-
const { w: n, h: i } =
|
|
1918
|
+
const { w: n, h: i } = S(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
|
|
1907
1919
|
if (o <= 0 || s <= 0) return;
|
|
1908
|
-
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l =
|
|
1920
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
|
|
1909
1921
|
l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
|
|
1910
1922
|
const c = this.mode === "static" ? this.vector ? this.captureImage : this.raster : this.captureImage;
|
|
1911
1923
|
c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, o, s), this.paintOverview(t, e);
|
|
1912
|
-
const u = this.getAttribute("frame-stroke") ||
|
|
1924
|
+
const u = this.getAttribute("frame-stroke") || F(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", m = ve * e.pxPerMm;
|
|
1913
1925
|
m > 0 && (t.strokeStyle = u, t.lineWidth = m, t.strokeRect(m / 2, m / 2, o - m, s - m));
|
|
1914
1926
|
}
|
|
1915
1927
|
paintOverview(t, e) {
|
|
@@ -1921,44 +1933,44 @@ class Qe extends F {
|
|
|
1921
1933
|
}
|
|
1922
1934
|
}
|
|
1923
1935
|
k("om-frame", Qe);
|
|
1924
|
-
const st = "http://www.w3.org/2000/svg",
|
|
1925
|
-
class tr extends
|
|
1936
|
+
const st = "http://www.w3.org/2000/svg", kn = ["single", "double", "line", "ticks"];
|
|
1937
|
+
class tr extends O {
|
|
1926
1938
|
static observedAttributes = [...T["om-scalebar"]];
|
|
1927
1939
|
/** The geometry currently drawn — reused by the canvas exporter. */
|
|
1928
1940
|
get drawing() {
|
|
1929
|
-
const e =
|
|
1941
|
+
const e = U(this)?.georef;
|
|
1930
1942
|
if (!e) return null;
|
|
1931
|
-
const { w: n, h: i } =
|
|
1943
|
+
const { w: n, h: i } = S(this), o = je({
|
|
1932
1944
|
groundMetersPerMm: e.groundMetersPerMm(),
|
|
1933
1945
|
maxWidthMm: n,
|
|
1934
1946
|
segments: Number(this.getAttribute("segments")) || void 0,
|
|
1935
1947
|
units: this.unitSystem,
|
|
1936
1948
|
segmentLengthMeters: this.getAttribute("segment-length") ? Number(this.getAttribute("segment-length")) : null
|
|
1937
1949
|
});
|
|
1938
|
-
return o ?
|
|
1950
|
+
return o ? _r(o, this.barStyle, i) : null;
|
|
1939
1951
|
}
|
|
1940
1952
|
get barStyle() {
|
|
1941
1953
|
const t = this.getAttribute("kind");
|
|
1942
|
-
return
|
|
1954
|
+
return kn.includes(t) ? t : "single";
|
|
1943
1955
|
}
|
|
1944
1956
|
get unitSystem() {
|
|
1945
|
-
return
|
|
1957
|
+
return Or(this.getAttribute("units")) ?? "metric";
|
|
1946
1958
|
}
|
|
1947
1959
|
renderNow() {
|
|
1948
|
-
if (this.applyPlacement(), this.style.display = "block", !
|
|
1960
|
+
if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-scalebar-ink", !0), this.style.display = "block", !U(this)) {
|
|
1949
1961
|
const n = this.getAttribute("for");
|
|
1950
|
-
|
|
1962
|
+
W(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
|
|
1951
1963
|
return;
|
|
1952
1964
|
}
|
|
1953
1965
|
const e = this.drawing;
|
|
1954
1966
|
if (!e) {
|
|
1955
|
-
|
|
1967
|
+
W(this, "Scale bar cannot derive a scale from this frame yet.");
|
|
1956
1968
|
return;
|
|
1957
1969
|
}
|
|
1958
1970
|
this.renderSvg(e);
|
|
1959
1971
|
}
|
|
1960
1972
|
renderSvg(t) {
|
|
1961
|
-
const { w: e, h: n } =
|
|
1973
|
+
const { w: e, h: n } = S(this), i = this.ownerDocument, o = i.createElementNS(st, "svg");
|
|
1962
1974
|
o.setAttribute("width", `${e}mm`), o.setAttribute("height", `${n}mm`), o.setAttribute("viewBox", `0 0 ${e} ${n}`), o.setAttribute("part", "scalebar"), o.style.display = "block", o.style.overflow = "visible";
|
|
1963
1975
|
const s = "var(--om-carto-scalebar-ink)";
|
|
1964
1976
|
for (const a of t.bars) {
|
|
@@ -1978,7 +1990,7 @@ class tr extends F {
|
|
|
1978
1990
|
paintCartograph(t, e) {
|
|
1979
1991
|
const n = this.drawing;
|
|
1980
1992
|
if (!n) return;
|
|
1981
|
-
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o =
|
|
1993
|
+
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = F(i?.color) ?? "#000", s = (l) => l * e.pxPerMm;
|
|
1982
1994
|
t.strokeStyle = o, t.fillStyle = o, t.lineWidth = s(n.strokeMm);
|
|
1983
1995
|
for (const l of n.bars)
|
|
1984
1996
|
l.filled && t.fillRect(s(l.x), s(l.y), s(l.w), s(l.h)), t.strokeRect(s(l.x), s(l.y), s(l.w), s(l.h));
|
|
@@ -1993,31 +2005,31 @@ class tr extends F {
|
|
|
1993
2005
|
}
|
|
1994
2006
|
}
|
|
1995
2007
|
k("om-scalebar", tr);
|
|
1996
|
-
const
|
|
1997
|
-
class er extends
|
|
2008
|
+
const Q = "http://www.w3.org/2000/svg";
|
|
2009
|
+
class er extends O {
|
|
1998
2010
|
static observedAttributes = [...T["om-north"]];
|
|
1999
2011
|
/** Degrees clockwise from the page's "up", or null when unknowable. */
|
|
2000
2012
|
get bearing() {
|
|
2001
|
-
const t =
|
|
2002
|
-
return t ?
|
|
2013
|
+
const t = U(this)?.georef;
|
|
2014
|
+
return t ? dn(t) : null;
|
|
2003
2015
|
}
|
|
2004
2016
|
get indicatorKind() {
|
|
2005
2017
|
return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
|
|
2006
2018
|
}
|
|
2007
2019
|
renderNow() {
|
|
2008
|
-
if (this.applyPlacement(), this.style.display = "block", !
|
|
2020
|
+
if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-compass-ink", !0), this.style.display = "block", !U(this)) {
|
|
2009
2021
|
const l = this.getAttribute("for");
|
|
2010
|
-
|
|
2022
|
+
W(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
|
|
2011
2023
|
return;
|
|
2012
2024
|
}
|
|
2013
2025
|
const e = this.bearing;
|
|
2014
2026
|
if (e == null) {
|
|
2015
|
-
|
|
2027
|
+
W(this, "North indicator cannot derive a direction from this frame yet.");
|
|
2016
2028
|
return;
|
|
2017
2029
|
}
|
|
2018
|
-
const { w: n, h: i } =
|
|
2030
|
+
const { w: n, h: i } = S(this), o = this.ownerDocument, s = o.createElementNS(Q, "svg");
|
|
2019
2031
|
s.setAttribute("width", `${n}mm`), s.setAttribute("height", `${i}mm`), s.setAttribute("viewBox", `0 0 ${n} ${i}`), s.style.display = "block";
|
|
2020
|
-
const a = o.createElementNS(
|
|
2032
|
+
const a = o.createElementNS(Q, "g");
|
|
2021
2033
|
a.setAttribute("transform", `rotate(${e.toFixed(3)} ${n / 2} ${i / 2})`);
|
|
2022
2034
|
for (const l of this.buildGeometry(o, n, i)) a.appendChild(l);
|
|
2023
2035
|
s.appendChild(a), this.replaceChildren(s);
|
|
@@ -2025,28 +2037,28 @@ class er extends F {
|
|
|
2025
2037
|
buildGeometry(t, e, n) {
|
|
2026
2038
|
const i = "var(--om-carto-compass-ink)", o = [], s = e / 2, a = Math.min(3, n * 0.24), l = n - a * 1.2;
|
|
2027
2039
|
if (this.indicatorKind === "rose") {
|
|
2028
|
-
const f = Math.min(e, l) / 2, g = t.createElementNS(
|
|
2040
|
+
const f = Math.min(e, l) / 2, g = t.createElementNS(Q, "circle");
|
|
2029
2041
|
g.setAttribute("cx", String(s)), g.setAttribute("cy", String(l / 2)), g.setAttribute("r", String(f)), g.setAttribute("fill", "none"), g.setAttribute("stroke", i), g.setAttribute("stroke-width", "0.2"), o.push(g);
|
|
2030
2042
|
}
|
|
2031
|
-
const c = 0, u = l, m = Math.min(e * 0.3, 4), d = t.createElementNS(
|
|
2043
|
+
const c = 0, u = l, m = Math.min(e * 0.3, 4), d = t.createElementNS(Q, "path");
|
|
2032
2044
|
d.setAttribute("d", `M ${s} ${c} L ${s + m} ${u} L ${s} ${u - m * 0.55} L ${s - m} ${u} Z`), d.setAttribute("fill", i), o.push(d);
|
|
2033
|
-
const h = t.createElementNS(
|
|
2045
|
+
const h = t.createElementNS(Q, "text");
|
|
2034
2046
|
return h.setAttribute("x", String(s)), h.setAttribute("y", String(n)), h.setAttribute("font-size", String(a)), h.setAttribute("text-anchor", "middle"), h.setAttribute("fill", i), h.setAttribute("font-family", "var(--om-carto-font)"), h.textContent = "N", o.push(h), o;
|
|
2035
2047
|
}
|
|
2036
2048
|
paintCartograph(t, e) {
|
|
2037
2049
|
const n = this.bearing;
|
|
2038
2050
|
if (n == null) return;
|
|
2039
|
-
const { w: i, h: o } =
|
|
2051
|
+
const { w: i, h: o } = S(this), s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = F(s?.color) ?? "#000", l = (h) => h * e.pxPerMm, c = Math.min(3, o * 0.24), u = o - c * 1.2, m = i / 2, d = Math.min(i * 0.3, 4);
|
|
2040
2052
|
t.save(), t.translate(l(m), l(o / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(m), -l(o / 2)), t.fillStyle = a, t.strokeStyle = a, this.indicatorKind === "rose" && (t.lineWidth = l(0.2), t.beginPath(), t.arc(l(m), l(u / 2), l(Math.min(i, u) / 2), 0, Math.PI * 2), t.stroke()), t.beginPath(), t.moveTo(l(m), 0), t.lineTo(l(m + d), l(u)), t.lineTo(l(m), l(u - d * 0.55)), t.lineTo(l(m - d), l(u)), t.closePath(), t.fill(), t.font = `${l(c)}px ${s?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(m), l(o)), t.restore();
|
|
2041
2053
|
}
|
|
2042
2054
|
}
|
|
2043
2055
|
k("om-north", er);
|
|
2044
|
-
const ot = "http://www.w3.org/2000/svg",
|
|
2045
|
-
class rr extends
|
|
2056
|
+
const ot = "http://www.w3.org/2000/svg", xn = ["rect", "ellipse", "line", "arrow"];
|
|
2057
|
+
class rr extends O {
|
|
2046
2058
|
static observedAttributes = [...T["om-shape"]];
|
|
2047
2059
|
get kind() {
|
|
2048
2060
|
const t = this.getAttribute("kind");
|
|
2049
|
-
return
|
|
2061
|
+
return xn.includes(t) ? t : "rect";
|
|
2050
2062
|
}
|
|
2051
2063
|
get fill() {
|
|
2052
2064
|
return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
|
|
@@ -2072,7 +2084,7 @@ class rr extends F {
|
|
|
2072
2084
|
}
|
|
2073
2085
|
renderNow() {
|
|
2074
2086
|
this.applyPlacement(), this.style.display = "block";
|
|
2075
|
-
const { w: t, h: e } =
|
|
2087
|
+
const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(ot, "svg");
|
|
2076
2088
|
i.setAttribute("width", `${t}mm`), i.setAttribute("height", `${e}mm`), i.setAttribute("viewBox", `0 0 ${t} ${e}`), i.style.display = "block", i.style.overflow = "visible";
|
|
2077
2089
|
const o = this.strokeWidthMm / 2, s = this.kind;
|
|
2078
2090
|
let a;
|
|
@@ -2086,7 +2098,7 @@ class rr extends F {
|
|
|
2086
2098
|
return `M 0 0 L ${o} ${s} M ${o} ${s} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
|
|
2087
2099
|
}
|
|
2088
2100
|
paintCartograph(t, e) {
|
|
2089
|
-
const { w: n, h: i } =
|
|
2101
|
+
const { w: n, h: i } = S(this);
|
|
2090
2102
|
if (n <= 0 || i <= 0) return;
|
|
2091
2103
|
const o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || o?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || o?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = s(this.strokeWidthMm), u = c / 2, m = this.kind;
|
|
2092
2104
|
if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, m === "ellipse")
|
|
@@ -2104,12 +2116,12 @@ class rr extends F {
|
|
|
2104
2116
|
}
|
|
2105
2117
|
}
|
|
2106
2118
|
k("om-shape", rr);
|
|
2107
|
-
const Ae = "data-om-carto-owned",
|
|
2108
|
-
class nr extends
|
|
2119
|
+
const Ae = "data-om-carto-owned", $n = ["contain", "cover", "fill"];
|
|
2120
|
+
class nr extends O {
|
|
2109
2121
|
static observedAttributes = [...T["om-image"]];
|
|
2110
2122
|
get fit() {
|
|
2111
2123
|
const t = this.getAttribute("fit");
|
|
2112
|
-
return
|
|
2124
|
+
return $n.includes(t ?? "") ? t : "contain";
|
|
2113
2125
|
}
|
|
2114
2126
|
get image() {
|
|
2115
2127
|
return this.querySelector(":scope > img");
|
|
@@ -2123,7 +2135,7 @@ class nr extends F {
|
|
|
2123
2135
|
paintCartograph(t, e) {
|
|
2124
2136
|
const n = this.image;
|
|
2125
2137
|
if (!n || !n.complete || n.naturalWidth === 0) return;
|
|
2126
|
-
const { w: i, h: o } =
|
|
2138
|
+
const { w: i, h: o } = S(this), s = i * e.pxPerMm, a = o * e.pxPerMm;
|
|
2127
2139
|
if (s <= 0 || a <= 0) return;
|
|
2128
2140
|
const l = this.fit;
|
|
2129
2141
|
if (l === "fill") {
|
|
@@ -2135,12 +2147,12 @@ class nr extends F {
|
|
|
2135
2147
|
}
|
|
2136
2148
|
}
|
|
2137
2149
|
k("om-image", nr);
|
|
2138
|
-
const
|
|
2139
|
-
function
|
|
2150
|
+
const En = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), Nn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), Pn = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
|
|
2151
|
+
function Tn(r) {
|
|
2140
2152
|
const t = r.type ?? "";
|
|
2141
|
-
if (
|
|
2142
|
-
if (
|
|
2143
|
-
if (
|
|
2153
|
+
if (Pn.has(t)) return "ramp";
|
|
2154
|
+
if (En.has(t)) return "line";
|
|
2155
|
+
if (Nn.has(t)) return "point";
|
|
2144
2156
|
if (t === "GeoJsonLayer") {
|
|
2145
2157
|
const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
|
|
2146
2158
|
if (n && !i) return "polygon";
|
|
@@ -2148,24 +2160,24 @@ function Nn(r) {
|
|
|
2148
2160
|
}
|
|
2149
2161
|
return "polygon";
|
|
2150
2162
|
}
|
|
2151
|
-
function
|
|
2163
|
+
function Ln(r) {
|
|
2152
2164
|
const t = r.meta?.legend;
|
|
2153
2165
|
return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
|
|
2154
2166
|
}
|
|
2155
2167
|
const kt = 12;
|
|
2156
|
-
function
|
|
2168
|
+
function Rn(r, t = []) {
|
|
2157
2169
|
const e = [];
|
|
2158
2170
|
for (const n of r) {
|
|
2159
2171
|
if (n.props?.visible === !1) continue;
|
|
2160
2172
|
const i = t.filter((a) => a.layer === n.id), o = i.find((a) => a.match == null);
|
|
2161
2173
|
if (o?.hide) continue;
|
|
2162
|
-
const s =
|
|
2174
|
+
const s = Fn(n.meta?.legend);
|
|
2163
2175
|
e.push({
|
|
2164
2176
|
layerId: n.id,
|
|
2165
2177
|
label: o?.label ?? n.meta?.label ?? n.id,
|
|
2166
|
-
color: o?.color ??
|
|
2167
|
-
shape: o?.shape ??
|
|
2168
|
-
legend:
|
|
2178
|
+
color: o?.color ?? Ln(n),
|
|
2179
|
+
shape: o?.shape ?? Tn(n),
|
|
2180
|
+
legend: In(s, i),
|
|
2169
2181
|
order: o?.order
|
|
2170
2182
|
});
|
|
2171
2183
|
}
|
|
@@ -2174,7 +2186,7 @@ function Tn(r, t = []) {
|
|
|
2174
2186
|
return o - s || n.index - i.index;
|
|
2175
2187
|
}).map((n) => n.row);
|
|
2176
2188
|
}
|
|
2177
|
-
function
|
|
2189
|
+
function Fn(r) {
|
|
2178
2190
|
if (!r || r.kind !== "categories" || r.entries.length <= kt) return r;
|
|
2179
2191
|
const t = r.entries.slice(0, kt), e = r.entries.length - kt;
|
|
2180
2192
|
return {
|
|
@@ -2182,7 +2194,7 @@ function Ln(r) {
|
|
|
2182
2194
|
entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
|
|
2183
2195
|
};
|
|
2184
2196
|
}
|
|
2185
|
-
function
|
|
2197
|
+
function In(r, t) {
|
|
2186
2198
|
const e = t.filter((i) => i.match != null);
|
|
2187
2199
|
if (!r || r.kind === "ramp" || e.length === 0) return r;
|
|
2188
2200
|
const n = [];
|
|
@@ -2192,7 +2204,7 @@ function Rn(r, t) {
|
|
|
2192
2204
|
}
|
|
2193
2205
|
return { ...r, entries: n };
|
|
2194
2206
|
}
|
|
2195
|
-
function
|
|
2207
|
+
function On(r) {
|
|
2196
2208
|
const t = [];
|
|
2197
2209
|
for (const e of r.querySelectorAll(":scope > om-legend-row")) {
|
|
2198
2210
|
const n = e.getAttribute("layer");
|
|
@@ -2226,7 +2238,7 @@ function ir(r) {
|
|
|
2226
2238
|
return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
|
|
2227
2239
|
}
|
|
2228
2240
|
const Me = "data-om-carto-legend-rows";
|
|
2229
|
-
class sr extends
|
|
2241
|
+
class sr extends O {
|
|
2230
2242
|
static observedAttributes = [...T["om-legend"]];
|
|
2231
2243
|
get derived() {
|
|
2232
2244
|
return this.getAttribute("derived") !== "false";
|
|
@@ -2234,27 +2246,37 @@ class sr extends F {
|
|
|
2234
2246
|
/** The rows this legend currently shows — recomputed on demand, never stored. */
|
|
2235
2247
|
get rows() {
|
|
2236
2248
|
if (!this.derived) return ir(this);
|
|
2237
|
-
const n =
|
|
2238
|
-
return n ?
|
|
2249
|
+
const n = U(this)?.mapElement?.getLayers?.();
|
|
2250
|
+
return n ? Rn(n, On(this)) : [];
|
|
2251
|
+
}
|
|
2252
|
+
/** Inner padding in mm — authored, else the 2 mm the theme always used. */
|
|
2253
|
+
get paddingMm() {
|
|
2254
|
+
const t = Number(this.getAttribute("padding"));
|
|
2255
|
+
return Number.isFinite(t) && t >= 0 && this.getAttribute("padding") !== null ? t : 2;
|
|
2256
|
+
}
|
|
2257
|
+
/** Row text size in mm — `font-size` is authored in points, like <om-text>. */
|
|
2258
|
+
get fontMm() {
|
|
2259
|
+
const t = Number(this.getAttribute("font-size"));
|
|
2260
|
+
return Number.isFinite(t) && t > 0 ? t * 25.4 / 72 : 2.6;
|
|
2239
2261
|
}
|
|
2240
2262
|
renderNow() {
|
|
2241
|
-
if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !
|
|
2263
|
+
if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.applyThemeOverride("bg", "--om-carto-legend-bg"), this.applyThemeOverride("stroke", "--om-carto-legend-border"), this.applyThemeOverride("color", "--om-carto-legend-title-ink", !0), this.derived && !U(this)) {
|
|
2242
2264
|
const e = this.getAttribute("for");
|
|
2243
|
-
|
|
2265
|
+
W(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
|
|
2244
2266
|
return;
|
|
2245
2267
|
}
|
|
2246
2268
|
const t = this.rows;
|
|
2247
2269
|
if (t.length === 0 && this.derived) {
|
|
2248
|
-
|
|
2270
|
+
W(this, "Legend is waiting for its frame's layers.");
|
|
2249
2271
|
return;
|
|
2250
2272
|
}
|
|
2251
2273
|
this.renderRows(t);
|
|
2252
2274
|
}
|
|
2253
2275
|
renderRows(t) {
|
|
2254
2276
|
const e = this.ownerDocument;
|
|
2255
|
-
this.querySelector(`:scope > [${Me}]`)?.remove(),
|
|
2277
|
+
this.querySelector(`:scope > [${Me}]`)?.remove(), Br(this);
|
|
2256
2278
|
const n = e.createElement("div");
|
|
2257
|
-
n.setAttribute(Me, ""), n.style.cssText =
|
|
2279
|
+
n.setAttribute(Me, ""), n.style.cssText = `padding:${this.paddingMm}mm;font-size:${this.fontMm}mm;line-height:1.35;`;
|
|
2258
2280
|
const i = this.getAttribute("title");
|
|
2259
2281
|
if (i) {
|
|
2260
2282
|
const s = e.createElement("div");
|
|
@@ -2298,36 +2320,36 @@ class sr extends F {
|
|
|
2298
2320
|
return n;
|
|
2299
2321
|
}
|
|
2300
2322
|
paintCartograph(t, e) {
|
|
2301
|
-
const { w: n, h: i } =
|
|
2323
|
+
const { w: n, h: i } = S(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
|
|
2302
2324
|
if (o <= 0 || s <= 0) return;
|
|
2303
|
-
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l =
|
|
2325
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
|
|
2304
2326
|
l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
|
|
2305
|
-
const c =
|
|
2327
|
+
const c = F(a?.borderTopColor), u = $t(a?.borderTopWidth) * e.scale;
|
|
2306
2328
|
c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, o - u, s - u));
|
|
2307
|
-
const m =
|
|
2308
|
-
let
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2311
|
-
const
|
|
2312
|
-
let
|
|
2313
|
-
t.font = `${h(
|
|
2314
|
-
for (const [
|
|
2315
|
-
const
|
|
2316
|
-
if (
|
|
2317
|
-
const
|
|
2318
|
-
if (t.save(), t.font = `${h(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(
|
|
2319
|
-
const
|
|
2320
|
-
|
|
2321
|
-
const
|
|
2322
|
-
t.textAlign = "right", t.fillText(
|
|
2329
|
+
const m = F(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", h = (M) => M * e.pxPerMm, f = this.paddingMm, g = this.fontMm;
|
|
2330
|
+
let p = h(f);
|
|
2331
|
+
const b = this.getAttribute("title");
|
|
2332
|
+
b && (t.fillStyle = m, t.font = `600 ${h(g)}px ${d}`, t.textBaseline = "top", t.fillText(b, h(f), p), p += h(g * 1.55));
|
|
2333
|
+
const w = this.rows, y = Number(this.getAttribute("columns")), A = Math.min(w.length || 1, Number.isFinite(y) && y > 1 ? Math.floor(y) : 1), v = Math.max(1, Math.ceil(w.length / A)), $ = 3, G = Math.max(1, (n - f * 2 - $ * (A - 1)) / A), _ = p;
|
|
2334
|
+
let E = -1, N = f;
|
|
2335
|
+
t.font = `${h(g)}px ${d}`;
|
|
2336
|
+
for (const [M, C] of w.entries()) {
|
|
2337
|
+
const P = Math.min(A - 1, Math.floor(M / v));
|
|
2338
|
+
if (P !== E && (E = P, N = f + E * (G + $), p = E === 0 ? _ : h(f)), p > s || (t.fillStyle = C.color, C.shape === "line" ? t.fillRect(h(N), p + h(1.2), h(3.2), h(0.9)) : C.shape === "point" ? (t.beginPath(), t.arc(h(N + 1.6), p + h(1.6), h(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(h(N), p, h(3.2), h(3.2)), t.fillStyle = m, t.textBaseline = "top", t.fillText(C.label, h(N + 4.7), p + h(0.3)), p += h(g * 1.6), !C.legend)) continue;
|
|
2339
|
+
const x = C.legend;
|
|
2340
|
+
if (t.save(), t.font = `${h(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(x.field, h(N + 2.7), p), t.globalAlpha = 1, p += h(2.8), x.kind === "ramp") {
|
|
2341
|
+
const L = Math.min(24, Math.max(1, G - 2.7)), R = N + 2.7, B = t.createLinearGradient(h(R), 0, h(R + L), 0);
|
|
2342
|
+
x.colors.forEach((hr, mr) => B.addColorStop(x.colors.length === 1 ? 0 : mr / (x.colors.length - 1), hr)), t.fillStyle = B, t.fillRect(h(R), p, h(L), h(2.4)), p += h(3.4), t.fillStyle = m, t.font = `${h(2.1)}px ${d}`, t.fillText(x.domain[0].toLocaleString("en-US"), h(R), p);
|
|
2343
|
+
const ur = x.domain[1].toLocaleString("en-US");
|
|
2344
|
+
t.textAlign = "right", t.fillText(ur, h(R + L), p), t.textAlign = "left", p += h(3.2);
|
|
2323
2345
|
} else {
|
|
2324
|
-
const
|
|
2325
|
-
|
|
2326
|
-
for (const
|
|
2327
|
-
if (
|
|
2328
|
-
t.fillStyle =
|
|
2346
|
+
const L = [...x.entries];
|
|
2347
|
+
x.kind === "categories" && x.defaultColor && L.push({ color: x.defaultColor, label: "other" }), t.font = `${h(2.3)}px ${d}`;
|
|
2348
|
+
for (const R of L) {
|
|
2349
|
+
if (p > s) break;
|
|
2350
|
+
t.fillStyle = R.color, t.fillRect(h(N + 2.7), p, h(2.6), h(2.6)), t.fillStyle = m, t.fillText(R.label, h(N + 6.3), p + h(0.2)), p += h(3.2);
|
|
2329
2351
|
}
|
|
2330
|
-
|
|
2352
|
+
p += h(1);
|
|
2331
2353
|
}
|
|
2332
2354
|
t.restore(), t.font = `${h(2.6)}px ${d}`;
|
|
2333
2355
|
}
|
|
@@ -2338,25 +2360,25 @@ const at = (r, t) => {
|
|
|
2338
2360
|
return e.textContent = t, e;
|
|
2339
2361
|
};
|
|
2340
2362
|
k("om-legend", sr);
|
|
2341
|
-
const Se = 48,
|
|
2363
|
+
const Se = 48, Ot = {
|
|
2342
2364
|
toLngLat: (r, t) => [r, t],
|
|
2343
2365
|
fromLngLat: (r) => [r[0], r[1]]
|
|
2344
2366
|
};
|
|
2345
2367
|
function Ce(r, t = 5) {
|
|
2346
|
-
return !Number.isFinite(r) || r <= 0 ? 0 :
|
|
2368
|
+
return !Number.isFinite(r) || r <= 0 ? 0 : ze(r / Math.max(1, t));
|
|
2347
2369
|
}
|
|
2348
|
-
function
|
|
2370
|
+
function _n({ georef: r, plane: t = Ot, interval: e, intervalX: n, intervalY: i, labels: o = "outside", format: s }) {
|
|
2349
2371
|
if (r.degenerate) return null;
|
|
2350
2372
|
const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
|
|
2351
2373
|
if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
|
|
2352
2374
|
const u = Math.min(...l), m = Math.max(...l), d = Math.min(...c), h = Math.max(...c), f = ke(n ?? e, Ce(m - u)), g = ke(i ?? e, Ce(h - d));
|
|
2353
2375
|
if (f <= 0 || g <= 0 || (m - u) / f > 500 || (h - d) / g > 500) return null;
|
|
2354
|
-
const p = [], b = [], w = s ??
|
|
2376
|
+
const p = [], b = [], w = s ?? Dn;
|
|
2355
2377
|
for (let y = Math.ceil(u / f) * f; y <= m + 1e-9; y += f) {
|
|
2356
2378
|
const A = xe(r, t, y, d, h, "x");
|
|
2357
2379
|
if (A) {
|
|
2358
2380
|
p.push(A);
|
|
2359
|
-
const v = t ===
|
|
2381
|
+
const v = t === Ot ? Ze(y) : y;
|
|
2360
2382
|
o !== "none" && Ee(b, A, r, w(v, "x"), "x", o);
|
|
2361
2383
|
}
|
|
2362
2384
|
}
|
|
@@ -2375,10 +2397,10 @@ function xe(r, t, e, n, i, o) {
|
|
|
2375
2397
|
const m = r.project(u);
|
|
2376
2398
|
m && s.push(m);
|
|
2377
2399
|
}
|
|
2378
|
-
const a =
|
|
2400
|
+
const a = Un(s, r.widthMm, r.heightMm);
|
|
2379
2401
|
return a.length >= 2 ? { points: a, value: e, axis: o } : null;
|
|
2380
2402
|
}
|
|
2381
|
-
function
|
|
2403
|
+
function Un(r, t, e) {
|
|
2382
2404
|
const n = (a) => a.xMm >= -0.01 && a.xMm <= t + 0.01 && a.yMm >= -0.01 && a.yMm <= e + 0.01, i = r.findIndex(n);
|
|
2383
2405
|
if (i === -1) return [];
|
|
2384
2406
|
let o = r.length - 1;
|
|
@@ -2397,24 +2419,24 @@ function Ee(r, t, e, n, i, o) {
|
|
|
2397
2419
|
r.push({ text: n, xMm: o === "outside" ? -1.2 : 1.2, yMm: s.yMm, edge: "left", axis: i });
|
|
2398
2420
|
}
|
|
2399
2421
|
}
|
|
2400
|
-
function
|
|
2422
|
+
function Dn(r, t) {
|
|
2401
2423
|
if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
|
|
2402
2424
|
const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
|
|
2403
2425
|
return `${Number(r.toFixed(e))}°`;
|
|
2404
2426
|
}
|
|
2405
|
-
function
|
|
2427
|
+
function zn(r, t) {
|
|
2406
2428
|
const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), o = (n - i) * 60, s = Math.floor(o), a = Math.round((o - s) * 60), l = a === 60 ? s + 1 : s, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, m = a === 60 ? 0 : a;
|
|
2407
2429
|
return `${c}°${String(u).padStart(2, "0")}′${String(m).padStart(2, "0")}″${e}`;
|
|
2408
2430
|
}
|
|
2409
|
-
const lt = "http://www.w3.org/2000/svg",
|
|
2410
|
-
class or extends
|
|
2431
|
+
const lt = "http://www.w3.org/2000/svg", jn = ["solid", "cross", "markers"], j = 1.4;
|
|
2432
|
+
class or extends O {
|
|
2411
2433
|
static observedAttributes = [...T["om-graticule"]];
|
|
2412
2434
|
resolvedPlane = null;
|
|
2413
2435
|
resolvedPlaneKey = null;
|
|
2414
2436
|
resolveToken = 0;
|
|
2415
2437
|
get kind() {
|
|
2416
2438
|
const t = this.getAttribute("kind");
|
|
2417
|
-
return
|
|
2439
|
+
return jn.includes(t) ? t : "solid";
|
|
2418
2440
|
}
|
|
2419
2441
|
get labelPlacement() {
|
|
2420
2442
|
const t = this.getAttribute("labels");
|
|
@@ -2422,7 +2444,7 @@ class or extends F {
|
|
|
2422
2444
|
}
|
|
2423
2445
|
/** The grid this element currently draws, or null when it cannot yet. */
|
|
2424
2446
|
get graticule() {
|
|
2425
|
-
const t =
|
|
2447
|
+
const t = U(this)?.georef;
|
|
2426
2448
|
if (!t) return null;
|
|
2427
2449
|
const e = this.gridPlane();
|
|
2428
2450
|
if (!e) return null;
|
|
@@ -2430,14 +2452,14 @@ class or extends F {
|
|
|
2430
2452
|
const o = Number(this.getAttribute(i));
|
|
2431
2453
|
return Number.isFinite(o) && o > 0 ? o : null;
|
|
2432
2454
|
};
|
|
2433
|
-
return
|
|
2455
|
+
return _n({
|
|
2434
2456
|
georef: t,
|
|
2435
2457
|
plane: e,
|
|
2436
2458
|
interval: n("interval"),
|
|
2437
2459
|
intervalX: n("interval-x"),
|
|
2438
2460
|
intervalY: n("interval-y"),
|
|
2439
2461
|
labels: this.labelPlacement,
|
|
2440
|
-
format: this.getAttribute("format") === "dms" ?
|
|
2462
|
+
format: this.getAttribute("format") === "dms" ? zn : void 0
|
|
2441
2463
|
});
|
|
2442
2464
|
}
|
|
2443
2465
|
/**
|
|
@@ -2447,10 +2469,10 @@ class or extends F {
|
|
|
2447
2469
|
*/
|
|
2448
2470
|
gridPlane() {
|
|
2449
2471
|
const t = Lt(this.getAttribute("crs"));
|
|
2450
|
-
if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return
|
|
2472
|
+
if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Ot;
|
|
2451
2473
|
const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
|
|
2452
2474
|
if (this.resolvedPlaneKey === e) return this.resolvedPlane;
|
|
2453
|
-
const n =
|
|
2475
|
+
const n = Y(t);
|
|
2454
2476
|
if (n) {
|
|
2455
2477
|
const o = { toLngLat: (s, a) => n.inverse([s, a]), fromLngLat: (s) => n.forward(s) };
|
|
2456
2478
|
return this.resolvedPlane = o, this.resolvedPlaneKey = e, o;
|
|
@@ -2462,9 +2484,9 @@ class or extends F {
|
|
|
2462
2484
|
}), null;
|
|
2463
2485
|
}
|
|
2464
2486
|
renderNow() {
|
|
2465
|
-
if (this.applyPlacement(), this.style.display = "block", this.style.pointerEvents = "none", !
|
|
2487
|
+
if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-graticule-ink", !0), this.style.display = "block", this.style.pointerEvents = "none", !U(this)) {
|
|
2466
2488
|
const n = this.getAttribute("for");
|
|
2467
|
-
|
|
2489
|
+
W(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
|
|
2468
2490
|
return;
|
|
2469
2491
|
}
|
|
2470
2492
|
const e = this.graticule;
|
|
@@ -2475,7 +2497,7 @@ class or extends F {
|
|
|
2475
2497
|
this.renderSvg(e);
|
|
2476
2498
|
}
|
|
2477
2499
|
renderSvg(t) {
|
|
2478
|
-
const { w: e, h: n } =
|
|
2500
|
+
const { w: e, h: n } = S(this), i = this.ownerDocument, o = i.createElementNS(lt, "svg");
|
|
2479
2501
|
o.setAttribute("width", `${e}mm`), o.setAttribute("height", `${n}mm`), o.setAttribute("viewBox", `0 0 ${e} ${n}`), o.style.cssText = "display:block;overflow:visible;";
|
|
2480
2502
|
const s = "var(--om-carto-graticule-ink)", a = this.kind;
|
|
2481
2503
|
for (const l of t.lines)
|
|
@@ -2485,7 +2507,7 @@ class or extends F {
|
|
|
2485
2507
|
} else
|
|
2486
2508
|
for (const c of this.tickPoints(l, a, t)) {
|
|
2487
2509
|
const u = i.createElementNS(lt, "path");
|
|
2488
|
-
u.setAttribute("d", `M ${c.xMm -
|
|
2510
|
+
u.setAttribute("d", `M ${c.xMm - j} ${c.yMm} H ${c.xMm + j} M ${c.xMm} ${c.yMm - j} V ${c.yMm + j}`), u.setAttribute("stroke", s), u.setAttribute("stroke-width", "0.15"), o.appendChild(u);
|
|
2489
2511
|
}
|
|
2490
2512
|
for (const l of t.labels) {
|
|
2491
2513
|
const c = i.createElementNS(lt, "text");
|
|
@@ -2498,7 +2520,7 @@ class or extends F {
|
|
|
2498
2520
|
if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
|
|
2499
2521
|
const i = n.lines.filter((s) => s.axis !== t.axis), o = [];
|
|
2500
2522
|
for (const s of i) {
|
|
2501
|
-
const a =
|
|
2523
|
+
const a = Gn(t.points, s.points);
|
|
2502
2524
|
a && o.push(a);
|
|
2503
2525
|
}
|
|
2504
2526
|
return o;
|
|
@@ -2506,21 +2528,21 @@ class or extends F {
|
|
|
2506
2528
|
paintCartograph(t, e) {
|
|
2507
2529
|
const n = this.graticule;
|
|
2508
2530
|
if (!n) return;
|
|
2509
|
-
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o =
|
|
2531
|
+
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = F(i?.color) ?? "#ffffff", s = (l) => l * e.pxPerMm, a = this.kind;
|
|
2510
2532
|
t.save(), t.strokeStyle = o, t.fillStyle = o, t.lineWidth = s(0.15);
|
|
2511
2533
|
for (const l of n.lines)
|
|
2512
2534
|
if (a === "solid")
|
|
2513
2535
|
t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(s(c.xMm), s(c.yMm)) : t.lineTo(s(c.xMm), s(c.yMm))), t.stroke();
|
|
2514
2536
|
else
|
|
2515
2537
|
for (const c of this.tickPoints(l, a, n))
|
|
2516
|
-
t.beginPath(), t.moveTo(s(c.xMm -
|
|
2538
|
+
t.beginPath(), t.moveTo(s(c.xMm - j), s(c.yMm)), t.lineTo(s(c.xMm + j), s(c.yMm)), t.moveTo(s(c.xMm), s(c.yMm - j)), t.lineTo(s(c.xMm), s(c.yMm + j)), t.stroke();
|
|
2517
2539
|
t.font = `${s(2.2)}px ${i?.fontFamily || "system-ui, sans-serif"}`, t.textBaseline = "alphabetic";
|
|
2518
2540
|
for (const l of n.labels)
|
|
2519
2541
|
t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text, s(l.xMm), s(l.yMm));
|
|
2520
2542
|
t.restore();
|
|
2521
2543
|
}
|
|
2522
2544
|
}
|
|
2523
|
-
function
|
|
2545
|
+
function Gn(r, t) {
|
|
2524
2546
|
let e = null, n = Number.POSITIVE_INFINITY;
|
|
2525
2547
|
for (const i of r)
|
|
2526
2548
|
for (const o of t) {
|
|
@@ -2530,25 +2552,25 @@ function jn(r, t) {
|
|
|
2530
2552
|
return n <= 1 ? e : null;
|
|
2531
2553
|
}
|
|
2532
2554
|
k("om-graticule", or);
|
|
2533
|
-
function
|
|
2555
|
+
function qn(r, t) {
|
|
2534
2556
|
if (r == null || typeof r != "object") return;
|
|
2535
2557
|
const e = r.properties;
|
|
2536
2558
|
return e && t in e ? e[t] : r[t];
|
|
2537
2559
|
}
|
|
2538
|
-
function
|
|
2560
|
+
function _t(r, t) {
|
|
2539
2561
|
if (Array.isArray(r)) {
|
|
2540
2562
|
if (typeof r[0] == "number") {
|
|
2541
2563
|
t.push([r[0], r[1]]);
|
|
2542
2564
|
return;
|
|
2543
2565
|
}
|
|
2544
|
-
for (const e of r)
|
|
2566
|
+
for (const e of r) _t(e, t);
|
|
2545
2567
|
}
|
|
2546
2568
|
}
|
|
2547
|
-
function
|
|
2569
|
+
function Wn(r) {
|
|
2548
2570
|
return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
|
|
2549
2571
|
}
|
|
2550
2572
|
function I(r, t) {
|
|
2551
|
-
return
|
|
2573
|
+
return qn(r, t);
|
|
2552
2574
|
}
|
|
2553
2575
|
function Ut(r) {
|
|
2554
2576
|
const t = {}, e = (i) => {
|
|
@@ -2559,11 +2581,11 @@ function Ut(r) {
|
|
|
2559
2581
|
const n = r.properties;
|
|
2560
2582
|
return n && typeof n == "object" && e(n), t;
|
|
2561
2583
|
}
|
|
2562
|
-
function
|
|
2584
|
+
function Bn(r) {
|
|
2563
2585
|
let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
|
|
2564
2586
|
const o = [], s = r.geometry;
|
|
2565
|
-
if (s?.coordinates != null)
|
|
2566
|
-
else if (Array.isArray(r.coordinates))
|
|
2587
|
+
if (s?.coordinates != null) _t(s.coordinates, o);
|
|
2588
|
+
else if (Array.isArray(r.coordinates)) _t(r.coordinates, o);
|
|
2567
2589
|
else {
|
|
2568
2590
|
const a = Number(I(r, "lng") ?? I(r, "longitude") ?? I(r, "lon") ?? I(r, "x")), l = Number(I(r, "lat") ?? I(r, "latitude") ?? I(r, "y"));
|
|
2569
2591
|
Number.isFinite(a) && Number.isFinite(l) && o.push([a, l]);
|
|
@@ -2572,52 +2594,52 @@ function qn(r) {
|
|
|
2572
2594
|
!Number.isFinite(a) || !Number.isFinite(l) || (t = Math.min(t, a), n = Math.max(n, a), e = Math.min(e, l), i = Math.max(i, l));
|
|
2573
2595
|
return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
|
|
2574
2596
|
}
|
|
2575
|
-
function
|
|
2597
|
+
function Kn(r, t) {
|
|
2576
2598
|
const [e, n, i, o] = r, s = Math.max(i - e, 1e-4), a = Math.max(o - n, 1e-4), l = s * t, c = a * t;
|
|
2577
2599
|
return [e - l, n - c, i + l, o + c];
|
|
2578
2600
|
}
|
|
2579
|
-
const
|
|
2580
|
-
function
|
|
2581
|
-
let n = t ? r.filter((o) =>
|
|
2582
|
-
const i =
|
|
2601
|
+
const Ei = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
|
|
2602
|
+
function Vn({ features: r, filter: t, sort: e }) {
|
|
2603
|
+
let n = t ? r.filter((o) => Hn(t, o)) : [...r];
|
|
2604
|
+
const i = Yn(e);
|
|
2583
2605
|
return i.length > 0 && (n = [...n].sort((o, s) => {
|
|
2584
2606
|
for (const { field: a, descending: l } of i) {
|
|
2585
2607
|
const c = I(o, a), u = I(s, a);
|
|
2586
2608
|
if (c == null && u == null) continue;
|
|
2587
2609
|
if (c == null) return 1;
|
|
2588
2610
|
if (u == null) return -1;
|
|
2589
|
-
const m =
|
|
2611
|
+
const m = Xn(c, u);
|
|
2590
2612
|
if (m !== 0) return l ? -m : m;
|
|
2591
2613
|
}
|
|
2592
2614
|
return 0;
|
|
2593
2615
|
})), n;
|
|
2594
2616
|
}
|
|
2595
|
-
function
|
|
2617
|
+
function Hn(r, t) {
|
|
2596
2618
|
try {
|
|
2597
2619
|
return !!r(t);
|
|
2598
2620
|
} catch {
|
|
2599
2621
|
return !1;
|
|
2600
2622
|
}
|
|
2601
2623
|
}
|
|
2602
|
-
function
|
|
2624
|
+
function Yn(r) {
|
|
2603
2625
|
return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
|
|
2604
2626
|
}
|
|
2605
|
-
function
|
|
2627
|
+
function Xn(r, t) {
|
|
2606
2628
|
return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
|
|
2607
2629
|
}
|
|
2608
|
-
function
|
|
2630
|
+
function Jn(r) {
|
|
2609
2631
|
const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
|
|
2610
2632
|
return t === "" ? "page" : t;
|
|
2611
2633
|
}
|
|
2612
|
-
function
|
|
2634
|
+
function Zn(r, t, e) {
|
|
2613
2635
|
const n = /* @__PURE__ */ new Map();
|
|
2614
2636
|
return t.map((i, o) => {
|
|
2615
|
-
const s = Ut(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, m) => m === "index" ? String(o + 1) : m === "count" ? String(t.length) : s[m] ?? u), l =
|
|
2637
|
+
const s = Ut(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, m) => m === "index" ? String(o + 1) : m === "count" ? String(t.length) : s[m] ?? u), l = Jn(a), c = n.get(l) ?? 0;
|
|
2616
2638
|
return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
|
|
2617
2639
|
});
|
|
2618
2640
|
}
|
|
2619
|
-
const Ne = "data-om-carto-pager",
|
|
2620
|
-
class ar extends
|
|
2641
|
+
const Ne = "data-om-carto-pager", Qn = "data-om-carto-screen-only", ti = "onlymap-cartograph", ei = "onlymap-cartograph-host";
|
|
2642
|
+
class ar extends O {
|
|
2621
2643
|
static observedAttributes = [...T["om-atlas"]];
|
|
2622
2644
|
/**
|
|
2623
2645
|
* Pages are SNAPSHOTTED when iteration first starts. A streaming or polling
|
|
@@ -2667,11 +2689,11 @@ class ar extends F {
|
|
|
2667
2689
|
*/
|
|
2668
2690
|
onHostMessage = (t) => {
|
|
2669
2691
|
const e = t.data;
|
|
2670
|
-
!e || e.source !==
|
|
2692
|
+
!e || e.source !== ei || e.type !== "atlas-seek" || typeof e.index == "number" && Number.isInteger(e.index) && this.seek(e.index);
|
|
2671
2693
|
};
|
|
2672
2694
|
/** The frame whose layer drives the iteration — the same `for=` rule every furniture element follows. */
|
|
2673
2695
|
get frame() {
|
|
2674
|
-
return
|
|
2696
|
+
return U(this);
|
|
2675
2697
|
}
|
|
2676
2698
|
get count() {
|
|
2677
2699
|
return this.ensurePages().length;
|
|
@@ -2688,7 +2710,7 @@ class ar extends F {
|
|
|
2688
2710
|
}
|
|
2689
2711
|
/** Export filenames, one per page, already de-duplicated. */
|
|
2690
2712
|
filenames(t = "png") {
|
|
2691
|
-
return
|
|
2713
|
+
return Zn(this.getAttribute("filename"), this.ensurePages(), t);
|
|
2692
2714
|
}
|
|
2693
2715
|
/** Human page labels, for an editor's stepper and PDF bookmarks. */
|
|
2694
2716
|
pageName(t) {
|
|
@@ -2712,11 +2734,11 @@ class ar extends F {
|
|
|
2712
2734
|
}
|
|
2713
2735
|
ensurePages() {
|
|
2714
2736
|
if (this.pages) return this.pages;
|
|
2715
|
-
const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), o = e ?
|
|
2737
|
+
const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), o = e ? Wn(i) : null;
|
|
2716
2738
|
if (!e || o)
|
|
2717
2739
|
return this.rejection = e ? o : null, this.pages = [];
|
|
2718
2740
|
const s = this.materialize(i);
|
|
2719
|
-
return this.pages =
|
|
2741
|
+
return this.pages = Vn({ features: s, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
|
|
2720
2742
|
}
|
|
2721
2743
|
/**
|
|
2722
2744
|
* Rows from the layer, with the layer's OWN declarative filters applied —
|
|
@@ -2724,7 +2746,7 @@ class ar extends F {
|
|
|
2724
2746
|
* sheets for features the map itself is hiding.
|
|
2725
2747
|
*/
|
|
2726
2748
|
materialize(t) {
|
|
2727
|
-
const e =
|
|
2749
|
+
const e = J(), n = t.data;
|
|
2728
2750
|
if (!n) return [];
|
|
2729
2751
|
const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [], o = [t.filter, t.categoryFilter].filter(Boolean);
|
|
2730
2752
|
return o.length === 0 ? i : i.filter(
|
|
@@ -2743,7 +2765,7 @@ class ar extends F {
|
|
|
2743
2765
|
compileFilter() {
|
|
2744
2766
|
const t = this.getAttribute("filter");
|
|
2745
2767
|
if (!t) return;
|
|
2746
|
-
const e =
|
|
2768
|
+
const e = J();
|
|
2747
2769
|
if (e?.compileExpression)
|
|
2748
2770
|
try {
|
|
2749
2771
|
const n = e.compileExpression(t, { shape: "geojson", paramName: "d" });
|
|
@@ -2767,9 +2789,9 @@ class ar extends F {
|
|
|
2767
2789
|
const e = this.closest("om-cartograph");
|
|
2768
2790
|
for (const o of e?.querySelectorAll("om-frame") ?? []) {
|
|
2769
2791
|
if (o.getAttribute("atlas-fit") !== "feature") continue;
|
|
2770
|
-
const s =
|
|
2792
|
+
const s = Bn(t);
|
|
2771
2793
|
if (!s) continue;
|
|
2772
|
-
const a = Number(o.getAttribute("atlas-margin")), l =
|
|
2794
|
+
const a = Number(o.getAttribute("atlas-margin")), l = Kn(s, Number.isFinite(a) && a > 0 ? a : 0.15);
|
|
2773
2795
|
o.fitBounds?.(l);
|
|
2774
2796
|
}
|
|
2775
2797
|
e?.setAtlasFields({ ...Ut(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture();
|
|
@@ -2781,7 +2803,7 @@ class ar extends F {
|
|
|
2781
2803
|
})
|
|
2782
2804
|
), this.renderPager();
|
|
2783
2805
|
const i = typeof window < "u" ? window.parent : null;
|
|
2784
|
-
i && i !== window && i.postMessage({ source:
|
|
2806
|
+
i && i !== window && i.postMessage({ source: ti, type: "atlas-page", index: this.currentIndex, count: this.count, name: n }, "*");
|
|
2785
2807
|
}
|
|
2786
2808
|
/**
|
|
2787
2809
|
* Draw (or update) the reader's page control on the owning sheet:
|
|
@@ -2799,7 +2821,7 @@ class ar extends F {
|
|
|
2799
2821
|
}
|
|
2800
2822
|
const i = this.ownerDocument, o = e ?? i.createElement("div");
|
|
2801
2823
|
if (!e) {
|
|
2802
|
-
o.setAttribute(Ne, ""), o.setAttribute(
|
|
2824
|
+
o.setAttribute(Ne, ""), o.setAttribute(Qn, ""), o.setAttribute("role", "navigation"), o.setAttribute("aria-label", "Atlas pages"), o.style.cssText = "position:absolute;left:50%;bottom:4mm;transform:translateX(-50%);z-index:2147483000;display:flex;align-items:center;gap:8px;padding:4px 10px;border-radius:999px;background:rgba(20,20,24,.82);color:#fff;font:12px/1.2 system-ui,sans-serif;box-shadow:0 2px 10px rgba(0,0,0,.35);user-select:none;pointer-events:auto;";
|
|
2803
2825
|
for (const [u, m, d] of [
|
|
2804
2826
|
[-1, "‹", "Previous page"],
|
|
2805
2827
|
[1, "›", "Next page"]
|
|
@@ -2832,7 +2854,7 @@ class ar extends F {
|
|
|
2832
2854
|
}
|
|
2833
2855
|
}
|
|
2834
2856
|
k("om-atlas", ar);
|
|
2835
|
-
class
|
|
2857
|
+
class ri extends De {
|
|
2836
2858
|
static observedAttributes = [...T["om-source"]];
|
|
2837
2859
|
connectedCallback() {
|
|
2838
2860
|
this.style.display = "none";
|
|
@@ -2846,21 +2868,21 @@ class ti extends De {
|
|
|
2846
2868
|
this.closest("om-frame")?.scheduleRender?.();
|
|
2847
2869
|
}
|
|
2848
2870
|
}
|
|
2849
|
-
const
|
|
2871
|
+
const ni = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), ii = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), si = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], oi = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), ai = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), li = 0.02, ci = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
|
|
2850
2872
|
function lr(r) {
|
|
2851
2873
|
const t = r.tagName.toLowerCase();
|
|
2852
2874
|
return r.id ? `${t}#${r.id}` : t;
|
|
2853
2875
|
}
|
|
2854
|
-
function
|
|
2876
|
+
function H(r, t) {
|
|
2855
2877
|
const e = r.getAttribute(t);
|
|
2856
2878
|
if (e == null || e.trim() === "") return null;
|
|
2857
2879
|
const n = Number(e);
|
|
2858
2880
|
return Number.isFinite(n) ? n : null;
|
|
2859
2881
|
}
|
|
2860
|
-
function
|
|
2882
|
+
function ui(r, t) {
|
|
2861
2883
|
return r.x < t.x + t.w && t.x < r.x + r.w && r.y < t.y + t.h && t.y < r.y + r.h;
|
|
2862
2884
|
}
|
|
2863
|
-
function
|
|
2885
|
+
function hi(r, t) {
|
|
2864
2886
|
const e = r.getAttribute("style");
|
|
2865
2887
|
if (!e) return null;
|
|
2866
2888
|
const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
|
|
@@ -2872,12 +2894,12 @@ function cr(r) {
|
|
|
2872
2894
|
}, n = [...r.querySelectorAll("om-cartograph")];
|
|
2873
2895
|
if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
|
|
2874
2896
|
return { valid: !0, errors: [], warnings: [] };
|
|
2875
|
-
for (const s of n)
|
|
2897
|
+
for (const s of n) mi(s, e);
|
|
2876
2898
|
const i = t.filter((s) => s.severity === "error"), o = t.filter((s) => s.severity === "warning");
|
|
2877
2899
|
return { valid: i.length === 0, errors: i, warnings: o };
|
|
2878
2900
|
}
|
|
2879
|
-
function
|
|
2880
|
-
const e = r.getAttribute("size"), n =
|
|
2901
|
+
function mi(r, t) {
|
|
2902
|
+
const e = r.getAttribute("size"), n = H(r, "width") != null && H(r, "height") != null;
|
|
2881
2903
|
e && !te.includes(e) && !n && t(
|
|
2882
2904
|
"error",
|
|
2883
2905
|
r,
|
|
@@ -2886,31 +2908,31 @@ function ui(r, t) {
|
|
|
2886
2908
|
"size"
|
|
2887
2909
|
);
|
|
2888
2910
|
const i = r.getAttribute("cvd");
|
|
2889
|
-
i && i.trim().toLowerCase() !== "none" && !Dt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${
|
|
2890
|
-
const o =
|
|
2911
|
+
i && i.trim().toLowerCase() !== "none" && !Dt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${yr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && ci(r) <= 0 && t("warning", r, "crop-marks needs bleed to draw into — trim marks sit outside the page box.", 'Add bleed="3" (mm), or drop crop-marks.', "crop-marks");
|
|
2912
|
+
const o = H(r, "safe-zone");
|
|
2891
2913
|
if (o != null && o > 0) {
|
|
2892
2914
|
const h = ht(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
|
|
2893
2915
|
o * 2 >= Math.min(h.widthMm, h.heightMm) && t("warning", r, `safe-zone=${o}mm leaves no usable area on a ${h.widthMm} × ${h.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
|
|
2894
2916
|
}
|
|
2895
2917
|
const s = r.getAttribute("format");
|
|
2896
|
-
s == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${
|
|
2897
|
-
const { widthMm: a, heightMm: l } = ht(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0,
|
|
2918
|
+
s == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${pt}" so future runtimes can migrate this document.`, "format") : s !== pt && t("warning", r, `Unrecognised document format "${s}".`, `This build understands "${pt}".`, "format");
|
|
2919
|
+
const { widthMm: a, heightMm: l } = ht(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, H(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), m = [...r.querySelectorAll("om-frame")];
|
|
2898
2920
|
for (const h of m)
|
|
2899
2921
|
h.id ? u.add(h.id) : t("error", h, "Frame has no id.", "Give every frame an id so furniture can reference it with for=.", "id");
|
|
2900
2922
|
for (const h of r.children) {
|
|
2901
|
-
if (
|
|
2923
|
+
if (si.some((g) => h.hasAttribute(g))) continue;
|
|
2902
2924
|
const f = h.tagName.toLowerCase();
|
|
2903
|
-
!
|
|
2925
|
+
!gt.includes(f) && !ii.has(f) && t("error", h, `<${f}> is not a cartograph element.`, `Use one of ${gt.join(", ")}, or move this content inside an <om-text>.`);
|
|
2904
2926
|
}
|
|
2905
2927
|
const d = [];
|
|
2906
2928
|
for (const h of [r, ...r.querySelectorAll("*")]) {
|
|
2907
2929
|
const f = h.tagName.toLowerCase();
|
|
2908
|
-
if (
|
|
2909
|
-
if (
|
|
2910
|
-
const g =
|
|
2911
|
-
|
|
2930
|
+
if (gt.includes(f) && !h.closest("om-map")) {
|
|
2931
|
+
if (di(h, f, t), ai.has(f)) {
|
|
2932
|
+
const g = S(h);
|
|
2933
|
+
fi(h, g, a, l, c, t), oi.has(f) && !h.hasAttribute("hidden") && d.push({ el: h, box: g });
|
|
2912
2934
|
}
|
|
2913
|
-
f === "om-frame" &&
|
|
2935
|
+
f === "om-frame" && pi(h, t), f === "om-source" && gi(h, t), f === "om-legend" && bi(h, m, t), f === "om-atlas" && yi(h, m, t), f === "om-scalebar" && wi(h, m, t), f === "om-text" && vi(h, m, t);
|
|
2914
2936
|
for (const g of ["for", "overview-of"]) {
|
|
2915
2937
|
const p = h.getAttribute(g);
|
|
2916
2938
|
p && !u.has(p) && t("error", h, `${g}="${p}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, g);
|
|
@@ -2920,7 +2942,7 @@ function ui(r, t) {
|
|
|
2920
2942
|
for (let h = 0; h < d.length; h++)
|
|
2921
2943
|
for (let f = h + 1; f < d.length; f++) {
|
|
2922
2944
|
const g = d[h], p = d[f];
|
|
2923
|
-
g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 ||
|
|
2945
|
+
g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || ui(g.box, p.box) && t(
|
|
2924
2946
|
"warning",
|
|
2925
2947
|
g.el,
|
|
2926
2948
|
`Overlaps ${lr(p.el)} on the page.`,
|
|
@@ -2928,12 +2950,12 @@ function ui(r, t) {
|
|
|
2928
2950
|
);
|
|
2929
2951
|
}
|
|
2930
2952
|
}
|
|
2931
|
-
function
|
|
2953
|
+
function di(r, t, e) {
|
|
2932
2954
|
const n = new Set(T[t] ?? []);
|
|
2933
2955
|
for (const i of r.attributes) {
|
|
2934
2956
|
const o = i.name.toLowerCase();
|
|
2935
|
-
if (n.has(o) ||
|
|
2936
|
-
const s =
|
|
2957
|
+
if (n.has(o) || ni.has(o) || o.startsWith("data-") || o.startsWith("aria-")) continue;
|
|
2958
|
+
const s = Tr.get(o);
|
|
2937
2959
|
if (s) {
|
|
2938
2960
|
e("warning", r, `Attribute "${o}" has no effect: ${s}`, "Remove it, or use the documented alternative.", o);
|
|
2939
2961
|
continue;
|
|
@@ -2941,7 +2963,7 @@ function hi(r, t, e) {
|
|
|
2941
2963
|
e("warning", r, `Unknown attribute "${o}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, o);
|
|
2942
2964
|
}
|
|
2943
2965
|
}
|
|
2944
|
-
function
|
|
2966
|
+
function fi(r, t, e, n, i, o) {
|
|
2945
2967
|
if (t.w <= 0 || t.h <= 0) {
|
|
2946
2968
|
o("error", r, `Element has no size (w=${t.w}, h=${t.h}).`, "Give w= and h= in millimetres — both greater than zero.", t.w <= 0 ? "w" : "h");
|
|
2947
2969
|
return;
|
|
@@ -2960,7 +2982,7 @@ function mi(r, t, e, n, i, o) {
|
|
|
2960
2982
|
["height", t.h]
|
|
2961
2983
|
];
|
|
2962
2984
|
for (const [u, m] of c) {
|
|
2963
|
-
const d =
|
|
2985
|
+
const d = hi(r, u);
|
|
2964
2986
|
d != null && Math.abs(d - m) > 0.01 && o(
|
|
2965
2987
|
"error",
|
|
2966
2988
|
r,
|
|
@@ -2970,9 +2992,9 @@ function mi(r, t, e, n, i, o) {
|
|
|
2970
2992
|
);
|
|
2971
2993
|
}
|
|
2972
2994
|
}
|
|
2973
|
-
function
|
|
2995
|
+
function pi(r, t) {
|
|
2974
2996
|
if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
|
|
2975
|
-
const n = r.getAttribute("corners"), i =
|
|
2997
|
+
const n = r.getAttribute("corners"), i = X(n);
|
|
2976
2998
|
i || t(
|
|
2977
2999
|
"error",
|
|
2978
3000
|
r,
|
|
@@ -2985,14 +3007,14 @@ function di(r, t) {
|
|
|
2985
3007
|
"Static frame has no <img> or inline <svg> child to place.",
|
|
2986
3008
|
'Add the georeferenced picture as a child — an <img> raster, or the inline <svg> that snapshot({format: "svg"}) produces.'
|
|
2987
3009
|
);
|
|
2988
|
-
const o =
|
|
3010
|
+
const o = S(r), s = Y(r.getAttribute("crs"));
|
|
2989
3011
|
if (i && s && o.w > 0 && o.h > 0) {
|
|
2990
|
-
const a =
|
|
3012
|
+
const a = tt({ corners: i, widthMm: o.w, heightMm: o.h, crsForward: s });
|
|
2991
3013
|
if (a.degenerate)
|
|
2992
3014
|
t("error", r, "Frame corners are degenerate (collinear or coincident) — nothing can be placed on this frame.", "Check the corner order: tl, tr, br, bl.", "corners");
|
|
2993
3015
|
else {
|
|
2994
|
-
const l =
|
|
2995
|
-
l != null && l >
|
|
3016
|
+
const l = fn(a);
|
|
3017
|
+
l != null && l > li && t(
|
|
2996
3018
|
"warning",
|
|
2997
3019
|
r,
|
|
2998
3020
|
`Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
|
|
@@ -3047,7 +3069,7 @@ function di(r, t) {
|
|
|
3047
3069
|
);
|
|
3048
3070
|
}
|
|
3049
3071
|
}
|
|
3050
|
-
function
|
|
3072
|
+
function gi(r, t) {
|
|
3051
3073
|
const e = r.parentElement;
|
|
3052
3074
|
if (e?.tagName.toLowerCase() !== "om-frame") {
|
|
3053
3075
|
t(
|
|
@@ -3063,7 +3085,7 @@ function fi(r, t) {
|
|
|
3063
3085
|
t("error", r, "<om-source> has no src=.", "Give it a map document (.html) or a capture image.", "src");
|
|
3064
3086
|
return;
|
|
3065
3087
|
}
|
|
3066
|
-
const i =
|
|
3088
|
+
const i = It(n);
|
|
3067
3089
|
if (!i) {
|
|
3068
3090
|
t(
|
|
3069
3091
|
"error",
|
|
@@ -3076,7 +3098,7 @@ function fi(r, t) {
|
|
|
3076
3098
|
}
|
|
3077
3099
|
if (i === "raster") {
|
|
3078
3100
|
const o = r.getAttribute("corners");
|
|
3079
|
-
|
|
3101
|
+
X(o) || t(
|
|
3080
3102
|
"error",
|
|
3081
3103
|
r,
|
|
3082
3104
|
o == null ? "A capture <om-source> has no corners=, so nothing on the sheet could be placed against it." : `A capture <om-source> has malformed corners= ("${o}").`,
|
|
@@ -3103,7 +3125,7 @@ function Wt(r, t) {
|
|
|
3103
3125
|
const e = r.getAttribute("for");
|
|
3104
3126
|
return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
|
|
3105
3127
|
}
|
|
3106
|
-
function
|
|
3128
|
+
function bi(r, t, e) {
|
|
3107
3129
|
const n = r.getAttribute("derived") !== "false", i = Wt(r, t);
|
|
3108
3130
|
n && i?.getAttribute("mode") === "static" && e(
|
|
3109
3131
|
"warning",
|
|
@@ -3114,7 +3136,7 @@ function gi(r, t, e) {
|
|
|
3114
3136
|
);
|
|
3115
3137
|
const o = ir(r);
|
|
3116
3138
|
if (o.length < 2) return;
|
|
3117
|
-
const s =
|
|
3139
|
+
const s = Ar(o.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
|
|
3118
3140
|
if (s.collapses.length > 0 && s.worstType) {
|
|
3119
3141
|
const a = s.collapses.filter((c) => c.type === s.worstType), l = a.slice(0, 3).map((c) => `"${c.a.label}"/"${c.b.label}"`).join(", ");
|
|
3120
3142
|
e(
|
|
@@ -3125,7 +3147,7 @@ function gi(r, t, e) {
|
|
|
3125
3147
|
);
|
|
3126
3148
|
}
|
|
3127
3149
|
}
|
|
3128
|
-
function
|
|
3150
|
+
function yi(r, t, e) {
|
|
3129
3151
|
const n = r.getAttribute("pager");
|
|
3130
3152
|
n != null && n !== "auto" && n !== "none" && e("warning", r, `pager="${n}" is not a value; the control is drawn as if "auto".`, 'Use pager="none" to remove the on-screen page control, or omit the attribute.', "pager");
|
|
3131
3153
|
const i = r.getAttribute("layer");
|
|
@@ -3162,17 +3184,17 @@ function pi(r, t, e) {
|
|
|
3162
3184
|
);
|
|
3163
3185
|
}
|
|
3164
3186
|
}
|
|
3165
|
-
function
|
|
3166
|
-
const n =
|
|
3187
|
+
function wi(r, t, e) {
|
|
3188
|
+
const n = H(r, "segment-length");
|
|
3167
3189
|
if (n == null) return;
|
|
3168
3190
|
const i = Wt(r, t);
|
|
3169
3191
|
if (!i) return;
|
|
3170
|
-
const o =
|
|
3192
|
+
const o = X(i.getAttribute("corners")), s = Y(i.getAttribute("crs")), a = S(i);
|
|
3171
3193
|
if (!o || !s || a.w <= 0 || a.h <= 0) return;
|
|
3172
|
-
const l =
|
|
3194
|
+
const l = tt({ corners: o, widthMm: a.w, heightMm: a.h, crsForward: s }), c = S(r), u = je({
|
|
3173
3195
|
groundMetersPerMm: l.groundMetersPerMm(),
|
|
3174
3196
|
maxWidthMm: c.w,
|
|
3175
|
-
segments:
|
|
3197
|
+
segments: H(r, "segments") ?? void 0,
|
|
3176
3198
|
segmentLengthMeters: n
|
|
3177
3199
|
});
|
|
3178
3200
|
u && u.totalMm > c.w + 1e-6 && e(
|
|
@@ -3183,9 +3205,9 @@ function bi(r, t, e) {
|
|
|
3183
3205
|
"segment-length"
|
|
3184
3206
|
);
|
|
3185
3207
|
}
|
|
3186
|
-
function
|
|
3208
|
+
function vi(r, t, e) {
|
|
3187
3209
|
const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), o = new Set(t.map((s) => s.id).filter(Boolean));
|
|
3188
|
-
for (const s of
|
|
3210
|
+
for (const s of jr(n))
|
|
3189
3211
|
if (!s.startsWith("atlas.")) {
|
|
3190
3212
|
if (s.startsWith("frame.")) {
|
|
3191
3213
|
const a = s.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
|
|
@@ -3204,13 +3226,13 @@ function yi(r, t, e) {
|
|
|
3204
3226
|
i.has(s) || e("warning", r, `Unknown token {{${s}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
|
|
3205
3227
|
}
|
|
3206
3228
|
}
|
|
3207
|
-
function
|
|
3208
|
-
return cr(
|
|
3229
|
+
function Ni(r) {
|
|
3230
|
+
return cr(Pr(r));
|
|
3209
3231
|
}
|
|
3210
|
-
async function
|
|
3232
|
+
async function Pi(r) {
|
|
3211
3233
|
const t = cr(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
|
|
3212
3234
|
if (e.length === 0) return t;
|
|
3213
|
-
const { loadCore: n } = await Promise.resolve().then(() =>
|
|
3235
|
+
const { loadCore: n } = await Promise.resolve().then(() => fr), i = await n(), o = [...t.errors], s = [...t.warnings];
|
|
3214
3236
|
for (const a of e) {
|
|
3215
3237
|
const l = a.id ? `om-frame#${a.id}` : "om-frame", c = i.validateManifest(a);
|
|
3216
3238
|
for (const u of c.errors) o.push({ ...u, element: `${l} > ${u.element}` });
|
|
@@ -3218,24 +3240,24 @@ async function Ei(r) {
|
|
|
3218
3240
|
}
|
|
3219
3241
|
return { valid: o.length === 0, errors: o, warnings: s };
|
|
3220
3242
|
}
|
|
3221
|
-
function
|
|
3222
|
-
k("om-cartograph", He), k("om-text", Ye), k("om-frame", Qe), k("om-scalebar", tr), k("om-north", er), k("om-shape", rr), k("om-image", nr), k("om-legend", sr), k("om-graticule", or), k("om-atlas", ar), k("om-source",
|
|
3243
|
+
function Ti() {
|
|
3244
|
+
k("om-cartograph", He), k("om-text", Ye), k("om-frame", Qe), k("om-scalebar", tr), k("om-north", er), k("om-shape", rr), k("om-image", nr), k("om-legend", sr), k("om-graticule", or), k("om-atlas", ar), k("om-source", ri);
|
|
3223
3245
|
}
|
|
3224
3246
|
Pe(() => import("@nika-js/onlymap"));
|
|
3225
|
-
|
|
3247
|
+
Nr();
|
|
3226
3248
|
export {
|
|
3227
3249
|
T as CARTOGRAPH_ELEMENT_ATTRS,
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3250
|
+
pt as CARTOGRAPH_FORMAT,
|
|
3251
|
+
gt as CARTOGRAPH_TAG_NAMES,
|
|
3252
|
+
Ai as CARTOGRAPH_THEMES,
|
|
3253
|
+
vr as COLLAPSE_THRESHOLD,
|
|
3254
|
+
zt as CVD_MATRICES,
|
|
3233
3255
|
mt as CVD_TYPES,
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3256
|
+
yr as CVD_VALUES,
|
|
3257
|
+
Ot as GEOGRAPHIC_PLANE,
|
|
3258
|
+
Tr as INERT_RESERVED_CARTOGRAPH_ATTRS,
|
|
3259
|
+
Ie as MAX_CANVAS_AREA,
|
|
3260
|
+
Fe as MAX_CANVAS_DIMENSION,
|
|
3239
3261
|
kt as MAX_CATEGORY_ENTRIES,
|
|
3240
3262
|
ar as OmAtlasElement,
|
|
3241
3263
|
He as OmCartographElement,
|
|
@@ -3249,82 +3271,82 @@ export {
|
|
|
3249
3271
|
Ye as OmTextElement,
|
|
3250
3272
|
Kt as PAGE_PRESETS,
|
|
3251
3273
|
te as PAGE_SIZE_NAMES,
|
|
3252
|
-
|
|
3274
|
+
z as PLACED_ATTR_NAMES,
|
|
3253
3275
|
D as PX_PER_MM,
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3276
|
+
Ur as SCALE_GROUP_SEPARATOR,
|
|
3277
|
+
$r as URL_ACTION_TIMEOUT_MS,
|
|
3278
|
+
Yr as alignOffset,
|
|
3257
3279
|
Ke as allFrames,
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3280
|
+
Mr as applyCvdToCanvas,
|
|
3281
|
+
Gr as applyTokens,
|
|
3282
|
+
Er as applyUrlActions,
|
|
3261
3283
|
Ut as atlasFields,
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3284
|
+
Ei as boundsArea,
|
|
3285
|
+
S as boxMm,
|
|
3286
|
+
_n as buildGraticule,
|
|
3287
|
+
Vn as buildPages,
|
|
3288
|
+
je as buildScalebar,
|
|
3289
|
+
_r as buildScalebarDrawing,
|
|
3290
|
+
Y as builtinCrsForward,
|
|
3291
|
+
Mi as canvasMeasurer,
|
|
3292
|
+
Br as clearUnlinked,
|
|
3293
|
+
xi as cornersFromBounds,
|
|
3294
|
+
Ft as cornersFromCamera,
|
|
3295
|
+
tt as createFrameGeoref,
|
|
3296
|
+
br as createZip,
|
|
3297
|
+
Ti as defineCartographElements,
|
|
3276
3298
|
Xt as deltaE00,
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3299
|
+
Rn as deriveLegendRows,
|
|
3300
|
+
Sr as ensureCvdFilters,
|
|
3301
|
+
Bn as featureBounds,
|
|
3280
3302
|
I as fieldOf,
|
|
3281
3303
|
Be as findFrame,
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3304
|
+
zn as formatDms,
|
|
3305
|
+
Dr as formatScaleDenominator,
|
|
3306
|
+
Nr as installUrlActions,
|
|
3307
|
+
dr as isCoreLoaded,
|
|
3308
|
+
qr as isoDate,
|
|
3309
|
+
Hr as layoutText,
|
|
3310
|
+
Ar as lintLegendColours,
|
|
3289
3311
|
Te as loadCore,
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3312
|
+
$i as maxGeoreferenceablePitch,
|
|
3313
|
+
Si as mercatorForward,
|
|
3314
|
+
Ci as mercatorInverse,
|
|
3293
3315
|
Ce as niceInterval,
|
|
3294
|
-
|
|
3316
|
+
ze as niceNumberBelow,
|
|
3295
3317
|
Lt as normalizeCrs,
|
|
3296
|
-
|
|
3318
|
+
dn as northBearingDegrees,
|
|
3297
3319
|
We as ownerCartograph,
|
|
3298
|
-
|
|
3320
|
+
Kn as padBounds,
|
|
3299
3321
|
Bt as paintEnvForDpi,
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3322
|
+
wr as parseColor,
|
|
3323
|
+
X as parseCorners,
|
|
3324
|
+
Yn as parseSort,
|
|
3325
|
+
J as peekCore,
|
|
3304
3326
|
ut as readCamera,
|
|
3305
3327
|
ir as readLiteralRows,
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3328
|
+
On as readOverrides,
|
|
3329
|
+
U as referencedFrame,
|
|
3330
|
+
Wn as rejectionFor,
|
|
3331
|
+
jt as renderCartograph,
|
|
3332
|
+
_e as renderCartographAtlas,
|
|
3311
3333
|
Rt as resolveCrsForward,
|
|
3312
3334
|
Dt as resolveCvdType,
|
|
3313
|
-
|
|
3335
|
+
Zn as resolveFilenames,
|
|
3314
3336
|
ht as resolvePageSize,
|
|
3315
|
-
|
|
3337
|
+
zr as resolveToken,
|
|
3316
3338
|
qe as resolveTokens,
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3339
|
+
Ln as rowColorFor,
|
|
3340
|
+
gn as sanitizeAdoptedMap,
|
|
3341
|
+
Jn as sanitizeFilename,
|
|
3342
|
+
fn as scaleVariation,
|
|
3321
3343
|
Pe as setCoreLoader,
|
|
3322
3344
|
Ht as simulate,
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3345
|
+
Tn as swatchShapeFor,
|
|
3346
|
+
jr as tokensIn,
|
|
3347
|
+
ki as utmDef,
|
|
3326
3348
|
cr as validateCartograph,
|
|
3327
|
-
|
|
3328
|
-
|
|
3349
|
+
Pi as validateCartographDeep,
|
|
3350
|
+
Ni as validateCartographString,
|
|
3329
3351
|
Qt as whenPageReady
|
|
3330
3352
|
};
|