@nika-js/onlymap 0.11.1 → 0.11.3
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 +15 -0
- package/README.md +3 -3
- package/dist/attribution.d.ts +27 -0
- package/dist/{basemap-CHFwxaRT.js → basemap-C6Ehu6fw.js} +923 -878
- package/dist/basemap.d.ts +11 -0
- package/dist/cartograph/elements/om-cartograph.d.ts +22 -0
- package/dist/cartograph/elements/om-frame.d.ts +8 -0
- package/dist/cartograph.js +1139 -1058
- package/dist/cartograph.standalone.js +1595 -1514
- package/dist/cluster-options.d.ts +11 -0
- package/dist/elements/om-map.d.ts +6 -0
- package/dist/{geoparquet-DBzSJJz_.js → geoparquet-3V4KrvQN.js} +1 -1
- package/dist/{globe-view-D0eDmIGO.js → globe-view-D4Tlyff-.js} +1 -1
- package/dist/{hillshade-DodGS9DL.js → hillshade-BC8QiJRP.js} +1 -1
- package/dist/{index-CrnprTab.js → index-BPCIxI1b.js} +1 -1
- package/dist/{index-Ca5y3OLs.js → index-BUE-VzWx.js} +1 -1
- package/dist/{index-BGvTOkkE.js → index-BqFwoWp9.js} +1 -1
- package/dist/{index-em-_HmNV.js → index-C1f14saD.js} +3 -3
- package/dist/{index-DH1_IQmW.js → index-DgutJ5y2.js} +3 -3
- package/dist/{index-C7Tpf_BA.js → index-DpUl6z5-.js} +1 -1
- package/dist/{index-5iFHs_bW.js → index-iwTA46AA.js} +1 -1
- package/dist/{index-wRR0a71N.js → index-p5XXAoNa.js} +2 -2
- package/dist/{index-D04CeeYu.js → index-pu3BNjzA.js} +11202 -11134
- package/dist/layers/cluster-layer.d.ts +7 -0
- package/dist/{lerc-KZgSVKKQ.js → lerc-DWtJKNQk.js} +1 -1
- package/dist/onlymap.standalone.js +19242 -19130
- package/dist/onlymapjs.js +1 -1
- package/dist/{post-process-effect-eJXo3MSl.js → post-process-effect-mQdMaWQE.js} +1 -1
- package/dist/{raster-CHuauCiR.js → raster-DtUDOXfy.js} +3 -3
- package/dist/{raster-pipeline-Coou2lF-.js → raster-pipeline-hQh5cG3e.js} +1 -1
- package/dist/runtime-core.d.ts +22 -0
- package/dist/{text-on-path-DUfdTGzX.js → text-on-path-CcfoZqXD.js} +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/{zarr-BYLzFMeQ.js → zarr-Qo4A_t7d.js} +2 -2
- package/docs/cartograph.md +27 -3
- package/llms.txt +3 -3
- package/onlymapjs.attributes.json +12 -0
- package/onlymapjs.html-data.json +20 -0
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +1 -1
- package/skills/onlymapjs/references/syntax.md +9 -6
package/dist/cartograph.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
let
|
|
2
|
-
function
|
|
3
|
-
|
|
1
|
+
let Pt = null, Z = null;
|
|
2
|
+
function Re(r) {
|
|
3
|
+
Pt = r;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function br() {
|
|
6
6
|
return V !== null;
|
|
7
7
|
}
|
|
8
8
|
let V = null;
|
|
9
9
|
function J() {
|
|
10
10
|
return V;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return V ? Promise.resolve(V) : Z || (
|
|
12
|
+
function Ie() {
|
|
13
|
+
return V ? Promise.resolve(V) : Z || (Pt ? (Z = Promise.resolve(Pt()).then((r) => (V = r, V)).catch((r) => {
|
|
14
14
|
throw Z = null, r;
|
|
15
15
|
}), Z) : Promise.reject(
|
|
16
16
|
new Error(
|
|
@@ -18,17 +18,17 @@ function Te() {
|
|
|
18
18
|
)
|
|
19
19
|
));
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22
22
|
__proto__: null,
|
|
23
|
-
isCoreLoaded:
|
|
24
|
-
loadCore:
|
|
23
|
+
isCoreLoaded: br,
|
|
24
|
+
loadCore: Ie,
|
|
25
25
|
peekCore: J,
|
|
26
|
-
setCoreLoader:
|
|
26
|
+
setCoreLoader: Re
|
|
27
27
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
28
|
-
function
|
|
28
|
+
function Xt(r) {
|
|
29
29
|
return { scale: r / 96, pxPerMm: r / 25.4 };
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function gt(r) {
|
|
32
32
|
return typeof r?.paintCartograph == "function";
|
|
33
33
|
}
|
|
34
34
|
const K = (r, t) => {
|
|
@@ -47,17 +47,17 @@ function S(r) {
|
|
|
47
47
|
z: K(r, "z")
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Tt(r, t = 0) {
|
|
51
51
|
if (!r) return t;
|
|
52
52
|
const e = Number.parseFloat(r);
|
|
53
53
|
return Number.isFinite(e) ? e : t;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function I(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;
|
|
59
59
|
}
|
|
60
|
-
const D = 96 / 25.4,
|
|
60
|
+
const D = 96 / 25.4, Jt = {
|
|
61
61
|
A0: { widthMm: 841, heightMm: 1189 },
|
|
62
62
|
A1: { widthMm: 594, heightMm: 841 },
|
|
63
63
|
A2: { widthMm: 420, heightMm: 594 },
|
|
@@ -66,15 +66,15 @@ const D = 96 / 25.4, Kt = {
|
|
|
66
66
|
A5: { widthMm: 148, heightMm: 210 },
|
|
67
67
|
Letter: { widthMm: 215.9, heightMm: 279.4 },
|
|
68
68
|
Legal: { widthMm: 215.9, heightMm: 355.6 }
|
|
69
|
-
},
|
|
70
|
-
function
|
|
71
|
-
const i = t != null ? Number(t) : NaN,
|
|
72
|
-
if (Number.isFinite(i) && i > 0 && Number.isFinite(
|
|
73
|
-
const
|
|
74
|
-
return n === "landscape" ? { widthMm:
|
|
69
|
+
}, Zt = "A4";
|
|
70
|
+
function dt(r, t, e, n) {
|
|
71
|
+
const i = t != null ? Number(t) : NaN, s = e != null ? Number(e) : NaN;
|
|
72
|
+
if (Number.isFinite(i) && i > 0 && Number.isFinite(s) && s > 0) return { widthMm: i, heightMm: s };
|
|
73
|
+
const o = Jt[r ?? Zt] ?? Jt[Zt];
|
|
74
|
+
return n === "landscape" ? { widthMm: o.heightMm, heightMm: o.widthMm } : { ...o };
|
|
75
75
|
}
|
|
76
76
|
let rt = null;
|
|
77
|
-
function
|
|
77
|
+
function wr(r) {
|
|
78
78
|
if (!rt) {
|
|
79
79
|
rt = new Uint32Array(256);
|
|
80
80
|
for (let e = 0; e < 256; e++) {
|
|
@@ -87,39 +87,39 @@ function pr(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 vr(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 Ar(r, t = /* @__PURE__ */ new Date()) {
|
|
98
|
+
const e = new TextEncoder(), { time: n, date: i } = vr(t), s = [], o = [];
|
|
99
99
|
let a = 0;
|
|
100
100
|
for (const u of r) {
|
|
101
|
-
const
|
|
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,
|
|
101
|
+
const h = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), m = wr(h), f = new DataView(new ArrayBuffer(30));
|
|
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, m, !0), f.setUint32(18, h.length, !0), f.setUint32(22, h.length, !0), f.setUint16(26, d.length, !0), f.setUint16(28, 0, !0), s.push(new Uint8Array(f.buffer), d, h), o.push({ name: u.name, bytes: h, crc: m, offset: a }), a += 30 + d.length + h.length;
|
|
103
103
|
}
|
|
104
104
|
const l = a;
|
|
105
|
-
for (const u of
|
|
106
|
-
const
|
|
107
|
-
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, 2048, !0), d.setUint16(10, 0, !0), d.setUint16(12, n, !0), d.setUint16(14, i, !0), d.setUint32(16, u.crc, !0), d.setUint32(20, u.bytes.length, !0), d.setUint32(24, u.bytes.length, !0), d.setUint16(28,
|
|
105
|
+
for (const u of o) {
|
|
106
|
+
const h = e.encode(u.name), d = new DataView(new ArrayBuffer(46));
|
|
107
|
+
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, 2048, !0), d.setUint16(10, 0, !0), d.setUint16(12, n, !0), d.setUint16(14, i, !0), d.setUint32(16, u.crc, !0), d.setUint32(20, u.bytes.length, !0), d.setUint32(24, u.bytes.length, !0), d.setUint16(28, h.length, !0), d.setUint16(30, 0, !0), d.setUint16(32, 0, !0), d.setUint16(34, 0, !0), d.setUint16(36, 0, !0), d.setUint32(38, 0, !0), d.setUint32(42, u.offset, !0), s.push(new Uint8Array(d.buffer), h), a += 46 + h.length;
|
|
108
108
|
}
|
|
109
109
|
const c = new DataView(new ArrayBuffer(22));
|
|
110
|
-
return c.setUint32(0, 101010256, !0), c.setUint16(4, 0, !0), c.setUint16(6, 0, !0), c.setUint16(8,
|
|
110
|
+
return c.setUint32(0, 101010256, !0), c.setUint16(4, 0, !0), c.setUint16(6, 0, !0), c.setUint16(8, o.length, !0), c.setUint16(10, o.length, !0), c.setUint32(12, a - l, !0), c.setUint32(16, l, !0), c.setUint16(20, 0, !0), s.push(new Uint8Array(c.buffer)), new Blob(s, { type: "application/zip" });
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const ft = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Fe = {
|
|
113
113
|
protan: "protanopia",
|
|
114
114
|
deutan: "deuteranopia",
|
|
115
115
|
tritan: "tritanopia",
|
|
116
116
|
achroma: "achromatopsia"
|
|
117
117
|
};
|
|
118
|
-
function
|
|
118
|
+
function qt(r) {
|
|
119
119
|
const t = r?.trim().toLowerCase();
|
|
120
|
-
return !t || t === "none" ? null :
|
|
120
|
+
return !t || t === "none" ? null : ft.includes(t) ? t : Fe[t] ?? null;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
122
|
+
const Mr = ["none", ...ft, ...Object.keys(Fe)], Wt = {
|
|
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],
|
|
@@ -127,69 +127,69 @@ const yr = ["none", ...mt, ...Object.keys(Le)], zt = {
|
|
|
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
|
+
}, ht = (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 Sr(r) {
|
|
135
135
|
const t = r.trim().toLowerCase(), e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);
|
|
136
136
|
if (e) {
|
|
137
|
-
const i = e[1],
|
|
138
|
-
return i.length === 3 ? { r:
|
|
137
|
+
const i = e[1], s = (o) => parseInt(o.length === 1 ? o + o : o, 16);
|
|
138
|
+
return i.length === 3 ? { r: s(i[0]), g: s(i[1]), b: s(i[2]) } : { r: s(i.slice(0, 2)), g: s(i.slice(2, 4)), b: s(i.slice(4, 6)) };
|
|
139
139
|
}
|
|
140
140
|
const n = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(t);
|
|
141
141
|
return n ? { r: Number(n[1]), g: Number(n[2]), b: Number(n[3]) } : null;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
const e =
|
|
143
|
+
function Qt(r, t) {
|
|
144
|
+
const e = Wt[t], [n, i, s] = [q(r.r), q(r.g), q(r.b)];
|
|
145
145
|
return {
|
|
146
|
-
r:
|
|
147
|
-
g:
|
|
148
|
-
b:
|
|
146
|
+
r: ht(e[0] * n + e[1] * i + e[2] * s),
|
|
147
|
+
g: ht(e[3] * n + e[4] * i + e[5] * s),
|
|
148
|
+
b: ht(e[6] * n + e[7] * i + e[8] * s)
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const [n, i,
|
|
153
|
-
return [116 *
|
|
151
|
+
function te({ r, g: t, b: e }) {
|
|
152
|
+
const [n, i, s] = [q(r), q(t), q(e)], o = (n * 0.4124564 + i * 0.3575761 + s * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + s * 0.072175, l = (n * 0.0193339 + i * 0.119192 + s * 0.9503041) / 1.08883, c = (m) => m > 216 / 24389 ? Math.cbrt(m) : 841 / 108 * m + 4 / 29, [u, h, d] = [c(o), c(a), c(l)];
|
|
153
|
+
return [116 * h - 16, 500 * (u - h), 200 * (h - d)];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
const [e, n, i] =
|
|
155
|
+
function ee(r, t) {
|
|
156
|
+
const [e, n, i] = te(r), [s, o, a] = te(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(o, a)) / 2, h = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, m] = [n * (1 + h), o * (1 + h)], [f, g] = [Math.hypot(d, i), Math.hypot(m, a)], p = (L, R) => {
|
|
157
157
|
if (L === 0 && R === 0) return 0;
|
|
158
158
|
const B = Math.atan2(R, L) * c;
|
|
159
159
|
return B >= 0 ? B : B + 360;
|
|
160
|
-
}, [b, w] = [p(d, i), p(
|
|
160
|
+
}, [b, w] = [p(d, i), p(m, a)], y = s - 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 $ = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), G = (e +
|
|
163
|
+
const $ = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), G = (e + s) / 2, _ = (f + g) / 2;
|
|
164
164
|
let E = b + w;
|
|
165
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,
|
|
167
|
-
return Math.sqrt((y / M) ** 2 + (A / C) ** 2 + ($ / P) ** 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, k = -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 + k * (A / C) * ($ / P));
|
|
168
168
|
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
169
|
+
const Cr = 10;
|
|
170
|
+
function xr(r, t = Cr) {
|
|
171
171
|
const e = /* @__PURE__ */ new Map();
|
|
172
172
|
for (const a of r) {
|
|
173
|
-
const l =
|
|
173
|
+
const l = Sr(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 }]);
|
|
177
177
|
}
|
|
178
178
|
const n = [], i = /* @__PURE__ */ new Map();
|
|
179
|
-
for (const a of
|
|
179
|
+
for (const a of ft)
|
|
180
180
|
for (const l of e.values())
|
|
181
181
|
for (let c = 0; c < l.length; c++)
|
|
182
182
|
for (let u = c + 1; u < l.length; u++) {
|
|
183
|
-
if (
|
|
184
|
-
const d =
|
|
183
|
+
if (ee(l[c].rgb, l[u].rgb) < t) continue;
|
|
184
|
+
const d = ee(Qt(l[c].rgb, a), Qt(l[u].rgb, a));
|
|
185
185
|
d < t && (n.push({ type: a, a: l[c].entry, b: l[u].entry, distance: d }), i.set(a, (i.get(a) ?? 0) + 1));
|
|
186
186
|
}
|
|
187
|
-
let
|
|
187
|
+
let s = null, o = 0;
|
|
188
188
|
for (const [a, l] of i)
|
|
189
|
-
l >
|
|
190
|
-
return { collapses: n, worstType:
|
|
189
|
+
l > o && (o = l, s = a);
|
|
190
|
+
return { collapses: n, worstType: s };
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function kr(r, t, e, n) {
|
|
193
193
|
if (t <= 0 || e <= 0) return !0;
|
|
194
194
|
let i;
|
|
195
195
|
try {
|
|
@@ -197,37 +197,37 @@ function Mr(r, t, e, n) {
|
|
|
197
197
|
} catch {
|
|
198
198
|
return !1;
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
for (let
|
|
202
|
-
const
|
|
203
|
-
for (let
|
|
204
|
-
const l = (
|
|
205
|
-
const d = Math.min(1, Math.max(0,
|
|
206
|
-
return
|
|
207
|
-
}, c =
|
|
208
|
-
for (let
|
|
209
|
-
const d =
|
|
210
|
-
u[
|
|
200
|
+
const s = new Float64Array(256);
|
|
201
|
+
for (let h = 0; h < 256; h++) s[h] = q(h);
|
|
202
|
+
const o = 1024, a = new Float64Array(o + 1);
|
|
203
|
+
for (let h = 0; h <= o; h++) a[h] = ht(h / o);
|
|
204
|
+
const l = (h) => {
|
|
205
|
+
const d = Math.min(1, Math.max(0, h)) * o, m = Math.floor(d);
|
|
206
|
+
return m >= o ? a[o] : a[m] + (a[m + 1] - a[m]) * (d - m);
|
|
207
|
+
}, c = Wt[n], u = i.data;
|
|
208
|
+
for (let h = 0; h < u.length; h += 4) {
|
|
209
|
+
const d = s[u[h]], m = s[u[h + 1]], f = s[u[h + 2]];
|
|
210
|
+
u[h] = l(c[0] * d + c[1] * m + c[2] * f), u[h + 1] = l(c[3] * d + c[4] * m + c[5] * f), u[h + 2] = l(c[6] * d + c[7] * m + c[8] * f);
|
|
211
211
|
}
|
|
212
212
|
return r.putImageData(i, 0, 0), !0;
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
function
|
|
214
|
+
const Oe = (r) => `om-carto-cvd-${r}`;
|
|
215
|
+
function $r(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;";
|
|
219
|
-
for (const e of
|
|
219
|
+
for (const e of ft) {
|
|
220
220
|
const n = r.createElementNS("http://www.w3.org/2000/svg", "filter");
|
|
221
|
-
n.id =
|
|
221
|
+
n.id = Oe(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
|
|
225
|
-
i.setAttribute("values", [
|
|
224
|
+
const s = Wt[e];
|
|
225
|
+
i.setAttribute("values", [s[0], s[1], s[2], 0, 0, s[3], s[4], s[5], 0, 0, s[6], s[7], s[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 _e = 16384, Ue = 134217728;
|
|
230
|
+
async function Er(r) {
|
|
231
231
|
const t = [], e = [...r.querySelectorAll("img")];
|
|
232
232
|
return await Promise.all(
|
|
233
233
|
e.map(async (n) => {
|
|
@@ -240,31 +240,31 @@ async function Cr(r) {
|
|
|
240
240
|
})
|
|
241
241
|
), t;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function De(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 Nr(r) {
|
|
247
|
+
return [...r.children].filter(De).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 Bt(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);
|
|
253
253
|
if (!Number.isFinite(i) || i <= 0) throw new Error(`[onlymapjs/cartograph] renderCartograph: invalid dpi ${t.dpi}.`);
|
|
254
|
-
const { widthMm:
|
|
254
|
+
const { widthMm: s, heightMm: o } = dt(
|
|
255
255
|
e.getAttribute("size"),
|
|
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 =
|
|
259
|
+
), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = s + a * 2, c = o + a * 2, u = t.maxDimension ?? _e, h = t.maxArea ?? Ue;
|
|
260
260
|
let d = i;
|
|
261
|
-
const
|
|
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 =
|
|
261
|
+
const m = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(h / (l / 25.4 * (c / 25.4))), g = Math.min(m, 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 Er(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
|
|
263
|
+
const p = Xt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = Nr(e);
|
|
264
264
|
for (const M of y)
|
|
265
|
-
if (!(!
|
|
265
|
+
if (!(!gt(M) || !M.prepareCartograph))
|
|
266
266
|
try {
|
|
267
|
-
await M.prepareCartograph(
|
|
267
|
+
await M.prepareCartograph(Xt(d));
|
|
268
268
|
} catch (C) {
|
|
269
269
|
M.discardCartograph?.(), n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} could not be captured: ${C.message}`);
|
|
270
270
|
}
|
|
@@ -273,13 +273,13 @@ async function jt(r, t = {}) {
|
|
|
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
275
|
const $ = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
|
|
276
|
-
v.fillStyle =
|
|
276
|
+
v.fillStyle = I($?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
|
|
277
277
|
for (const M of y) {
|
|
278
|
-
if (!
|
|
278
|
+
if (!gt(M)) continue;
|
|
279
279
|
const C = S(M);
|
|
280
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,
|
|
282
|
-
v.translate(P,
|
|
281
|
+
const P = C.w / 2 * p.pxPerMm, k = C.h / 2 * p.pxPerMm;
|
|
282
|
+
v.translate(P, k), v.rotate(C.rotation * Math.PI / 180), v.translate(-P, -k);
|
|
283
283
|
}
|
|
284
284
|
try {
|
|
285
285
|
M.paintCartograph(v, p);
|
|
@@ -290,19 +290,19 @@ async function jt(r, t = {}) {
|
|
|
290
290
|
}
|
|
291
291
|
const G = e.querySelector(":scope > [data-om-carto-marks]");
|
|
292
292
|
for (const M of G?.querySelectorAll("line") ?? []) {
|
|
293
|
-
const C = Number(M.getAttribute("x1")), P = Number(M.getAttribute("y1")),
|
|
294
|
-
[C, P,
|
|
293
|
+
const C = Number(M.getAttribute("x1")), P = Number(M.getAttribute("y1")), k = Number(M.getAttribute("x2")), L = Number(M.getAttribute("y2"));
|
|
294
|
+
[C, P, k, 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((k + a) * p.pxPerMm, (L + a) * p.pxPerMm), v.stroke(), v.restore());
|
|
295
295
|
}
|
|
296
|
-
const _ =
|
|
297
|
-
_ && !
|
|
298
|
-
for (const M of y)
|
|
296
|
+
const _ = qt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
|
|
297
|
+
_ && !kr(v, b, w, _) && n.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
|
|
298
|
+
for (const M of y) gt(M) && M.discardCartograph?.();
|
|
299
299
|
const E = t.format === "jpeg" ? "image/jpeg" : "image/png";
|
|
300
300
|
E === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
|
|
301
301
|
const N = await new Promise((M) => A.toBlob(M, E, t.quality));
|
|
302
302
|
if (!N) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
|
|
303
303
|
return { blob: N, widthPx: b, heightPx: w, dpi: d, warnings: n };
|
|
304
304
|
}
|
|
305
|
-
async function
|
|
305
|
+
async function ze(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;
|
|
@@ -311,61 +311,61 @@ async function _e(r, t = {}) {
|
|
|
311
311
|
throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: the atlas layer cannot drive pages (${n.problem}).`);
|
|
312
312
|
const i = n.count;
|
|
313
313
|
if (i === 0) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: the atlas layer produced no features.");
|
|
314
|
-
const
|
|
314
|
+
const s = t.format === "jpeg" ? "jpg" : "png", o = n.filenames(s), a = [], l = n.index;
|
|
315
315
|
try {
|
|
316
316
|
if (t.page != null) {
|
|
317
|
-
const
|
|
318
|
-
if (!Number.isInteger(
|
|
317
|
+
const h = Math.trunc(t.page);
|
|
318
|
+
if (!Number.isInteger(h) || h < 0 || h >= i)
|
|
319
319
|
throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: page ${t.page} is out of range (this atlas has ${i}).`);
|
|
320
|
-
n.seek(
|
|
321
|
-
const d = await
|
|
322
|
-
return { blob: d.blob, filenames: [
|
|
320
|
+
n.seek(h);
|
|
321
|
+
const d = await re(e, t, a);
|
|
322
|
+
return { blob: d.blob, filenames: [o[h]], pages: 1, dpi: d.dpi, warnings: a };
|
|
323
323
|
}
|
|
324
324
|
const c = [];
|
|
325
325
|
let u = t.dpi ?? 300;
|
|
326
|
-
for (let
|
|
327
|
-
n.seek(
|
|
328
|
-
const d = await
|
|
329
|
-
u = d.dpi, c.push({ name:
|
|
326
|
+
for (let h = 0; h < i; h++) {
|
|
327
|
+
n.seek(h);
|
|
328
|
+
const d = await re(e, t, a);
|
|
329
|
+
u = d.dpi, c.push({ name: o[h], data: d.blob }), t.onPage?.(h + 1, i);
|
|
330
330
|
}
|
|
331
|
-
return { blob: await
|
|
331
|
+
return { blob: await Ar(c), filenames: o, pages: i, dpi: u, warnings: a };
|
|
332
332
|
} finally {
|
|
333
333
|
n.seek(l);
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
async function
|
|
336
|
+
async function re(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 Bt(r, t);
|
|
340
340
|
return e.push(...n.warnings), n;
|
|
341
341
|
}
|
|
342
|
-
const
|
|
342
|
+
const Pr = /* @__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: Ue,
|
|
345
|
+
MAX_CANVAS_DIMENSION: _e,
|
|
346
|
+
paintsInExport: De,
|
|
347
|
+
renderCartograph: Bt,
|
|
348
|
+
renderCartographAtlas: ze
|
|
349
349
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
350
|
-
function
|
|
350
|
+
function ne(r, t, e = {}) {
|
|
351
351
|
const n = URL.createObjectURL(r), i = document.createElement("a");
|
|
352
352
|
i.href = n, i.download = t, document.body.appendChild(i), i.click(), i.remove();
|
|
353
|
-
const
|
|
354
|
-
|
|
353
|
+
const s = e.revokeAfterMs ?? 0;
|
|
354
|
+
s > 0 ? setTimeout(() => URL.revokeObjectURL(n), s) : URL.revokeObjectURL(n);
|
|
355
355
|
}
|
|
356
|
-
const
|
|
357
|
-
async function
|
|
356
|
+
const Tr = 3e4;
|
|
357
|
+
async function ie(r, t = Tr) {
|
|
358
358
|
let e = !1;
|
|
359
359
|
const n = new Promise(
|
|
360
|
-
(
|
|
361
|
-
e = !0,
|
|
360
|
+
(s) => setTimeout(() => {
|
|
361
|
+
e = !0, s();
|
|
362
362
|
}, t)
|
|
363
363
|
), i = (async () => {
|
|
364
|
-
const
|
|
365
|
-
await Promise.all(
|
|
366
|
-
const
|
|
364
|
+
const s = [...r.querySelectorAll("om-frame")];
|
|
365
|
+
await Promise.all(s.map((a) => a.ready ?? Promise.resolve()));
|
|
366
|
+
const o = [...r.querySelectorAll("img")];
|
|
367
367
|
await Promise.all(
|
|
368
|
-
|
|
368
|
+
o.map(async (a) => {
|
|
369
369
|
a.complete || await new Promise((l) => {
|
|
370
370
|
a.addEventListener("load", () => l(), { once: !0 }), a.addEventListener("error", () => l(), { once: !0 });
|
|
371
371
|
});
|
|
@@ -374,53 +374,81 @@ async function Qt(r, t = $r) {
|
|
|
374
374
|
})();
|
|
375
375
|
return await Promise.race([i, n]), { timedOut: e };
|
|
376
376
|
}
|
|
377
|
-
async function
|
|
377
|
+
async function Lr(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;
|
|
381
381
|
const n = new URLSearchParams(e), i = n.get("cvd");
|
|
382
382
|
i && r.setAttribute("cvd", i);
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
await
|
|
386
|
-
const
|
|
383
|
+
const s = n.get("export");
|
|
384
|
+
if (s) {
|
|
385
|
+
await ie(r, t.timeoutMs);
|
|
386
|
+
const o = s === "jpeg" ? "jpeg" : "png", a = Number(n.get("dpi")) || void 0, l = r.getAttribute("cartograph-id") || "cartograph", c = n.get("page");
|
|
387
387
|
if (c != null) {
|
|
388
|
-
const
|
|
389
|
-
if (!
|
|
388
|
+
const h = r.querySelector("om-atlas");
|
|
389
|
+
if (!h) throw new Error(`?page=${c} needs an <om-atlas>; this cartograph is a single sheet.`);
|
|
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
|
-
|
|
393
|
-
const
|
|
394
|
-
for (const f of
|
|
395
|
-
return
|
|
392
|
+
h.refresh?.();
|
|
393
|
+
const m = await ze(r, { dpi: a, format: o, page: d - 1 });
|
|
394
|
+
for (const f of m.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
|
|
395
|
+
return ne(m.blob, m.filenames[0] ?? `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
|
|
396
396
|
}
|
|
397
|
-
const u = await
|
|
398
|
-
for (const
|
|
399
|
-
return
|
|
397
|
+
const u = await Bt(r, { dpi: a, format: o });
|
|
398
|
+
for (const h of u.warnings) console.warn(`[onlymapjs/cartograph] ${h}`);
|
|
399
|
+
return ne(u.blob, `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
|
|
400
400
|
}
|
|
401
|
-
return n.get("print") === "1" ? (await
|
|
401
|
+
return n.get("print") === "1" ? (await ie(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 Rr() {
|
|
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
|
+
Lr(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
|
}
|
|
411
|
-
const
|
|
411
|
+
const je = typeof window < "u" && typeof document < "u" && typeof customElements < "u", Ge = je ? HTMLElement : class {
|
|
412
412
|
};
|
|
413
|
-
function
|
|
414
|
-
|
|
413
|
+
function x(r, t) {
|
|
414
|
+
je && (customElements.get(r) || customElements.define(r, t));
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function Ir(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
|
-
|
|
423
|
+
const Kt = " · ", Fr = {
|
|
424
|
+
copy: "©",
|
|
425
|
+
reg: "®",
|
|
426
|
+
amp: "&",
|
|
427
|
+
lt: "<",
|
|
428
|
+
gt: ">",
|
|
429
|
+
quot: '"',
|
|
430
|
+
apos: "'",
|
|
431
|
+
nbsp: " "
|
|
432
|
+
};
|
|
433
|
+
function Or(r) {
|
|
434
|
+
return r.replace(/<[^>]*>/g, " ").replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (t, e) => {
|
|
435
|
+
if (e.startsWith("#")) {
|
|
436
|
+
const n = e[1].toLowerCase() === "x" ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
|
|
437
|
+
return Number.isInteger(n) && n > 0 && n <= 1114111 ? String.fromCodePoint(n) : t;
|
|
438
|
+
}
|
|
439
|
+
return Fr[e.toLowerCase()] ?? t;
|
|
440
|
+
}).replace(/\s+/g, " ").trim();
|
|
441
|
+
}
|
|
442
|
+
function qe(r) {
|
|
443
|
+
const t = [...new Set(r.filter((e) => typeof e == "string").map(Or))].filter(
|
|
444
|
+
(e) => e.length > 0
|
|
445
|
+
);
|
|
446
|
+
return t.filter((e) => !t.some((n) => n !== e && n.includes(e)));
|
|
447
|
+
}
|
|
448
|
+
function _r(r) {
|
|
449
|
+
return qe((r ?? "").split(Kt.trim()));
|
|
450
|
+
}
|
|
451
|
+
class O extends Ge {
|
|
424
452
|
renderQueued = !1;
|
|
425
453
|
connectedCallback() {
|
|
426
454
|
this.scheduleRender();
|
|
@@ -456,19 +484,19 @@ class O extends De {
|
|
|
456
484
|
if (c == null || c === "") return null;
|
|
457
485
|
const u = Number(c);
|
|
458
486
|
return Number.isFinite(u) ? u : null;
|
|
459
|
-
}, e = t("x"), n = t("y"), i = t("w"),
|
|
460
|
-
this.style.position = "absolute", e != null && (this.style.left = `${e}mm`), n != null && (this.style.top = `${n}mm`), i != null && (this.style.width = `${i}mm`),
|
|
461
|
-
const
|
|
462
|
-
|
|
487
|
+
}, e = t("x"), n = t("y"), i = t("w"), s = t("h");
|
|
488
|
+
this.style.position = "absolute", e != null && (this.style.left = `${e}mm`), n != null && (this.style.top = `${n}mm`), i != null && (this.style.width = `${i}mm`), s != null && (this.style.height = `${s}mm`);
|
|
489
|
+
const o = t("rotation");
|
|
490
|
+
o != null && o !== 0 ? (this.style.transform = `rotate(${o}deg)`, this.style.transformOrigin = "center") : this.style.removeProperty("transform");
|
|
463
491
|
const a = t("z");
|
|
464
492
|
a != null && Number.isInteger(a) ? this.style.zIndex = String(a) : this.style.removeProperty("z-index");
|
|
465
493
|
}
|
|
466
494
|
}
|
|
467
|
-
const
|
|
495
|
+
const bt = "cartograph/2", Ei = ["default", "dark", "sepia", "blueprint", "minimal"], se = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], Ur = /* @__PURE__ */ new Map([
|
|
468
496
|
["projection", "live frames render Web Mercator (EPSG:3857) only — Globe support is design-only; use a static frame for other projections"]
|
|
469
497
|
]), z = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], T = {
|
|
470
498
|
"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"],
|
|
499
|
+
"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", "attribution"],
|
|
472
500
|
"om-legend": [...z, "for", "title", "columns", "derived", "bg", "color", "stroke", "font-size", "padding"],
|
|
473
501
|
"om-legend-row": ["layer", "match", "label", "hide", "order", "color", "shape"],
|
|
474
502
|
// NOTE: the discriminator on furniture is `kind`, never `style` — `style` is
|
|
@@ -488,58 +516,58 @@ const pt = "cartograph/2", Ai = ["default", "dark", "sepia", "blueprint", "minim
|
|
|
488
516
|
// CRS is therefore unknowable.
|
|
489
517
|
"om-source": ["src", "corners", "crs", "crs-def"],
|
|
490
518
|
"om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name", "pager"]
|
|
491
|
-
},
|
|
492
|
-
function
|
|
493
|
-
return r != null &&
|
|
519
|
+
}, yt = Object.keys(T), Lt = "data-om-carto-vector", Dr = ["metric", "imperial", "nautical"], zr = 0.3048, jr = 1609.344, Gr = 1852;
|
|
520
|
+
function qr(r) {
|
|
521
|
+
return r != null && Dr.includes(r) ? r : null;
|
|
494
522
|
}
|
|
495
|
-
function
|
|
523
|
+
function We(r) {
|
|
496
524
|
if (!isFinite(r) || r <= 0) return 0;
|
|
497
525
|
const t = Math.pow(10, Math.floor(Math.log10(r))), e = r / t;
|
|
498
526
|
return (e >= 5 ? 5 : e >= 2 ? 2 : 1) * t;
|
|
499
527
|
}
|
|
500
|
-
const
|
|
528
|
+
const oe = {
|
|
501
529
|
// Finest first; the largest tier whose snapped length is ≥ 1 unit wins.
|
|
502
530
|
metric: [
|
|
503
531
|
{ metersPerUnit: 1, label: "m" },
|
|
504
532
|
{ metersPerUnit: 1e3, label: "km" }
|
|
505
533
|
],
|
|
506
534
|
imperial: [
|
|
507
|
-
{ metersPerUnit:
|
|
508
|
-
{ metersPerUnit:
|
|
535
|
+
{ metersPerUnit: zr, label: "ft" },
|
|
536
|
+
{ metersPerUnit: jr, label: "mi" }
|
|
509
537
|
],
|
|
510
|
-
nautical: [{ metersPerUnit:
|
|
538
|
+
nautical: [{ metersPerUnit: Gr, label: "nmi" }]
|
|
511
539
|
};
|
|
512
|
-
function
|
|
540
|
+
function Be({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
|
|
513
541
|
if (!Number.isFinite(r) || r <= 0 || !Number.isFinite(t) || t <= 0) return null;
|
|
514
|
-
const
|
|
542
|
+
const s = Number.isInteger(e) && e > 0 ? e : 4, o = oe[n] ?? oe.metric, a = t / s * r;
|
|
515
543
|
let l, c;
|
|
516
544
|
if (i != null && Number.isFinite(i) && i > 0)
|
|
517
|
-
l = i, c =
|
|
545
|
+
l = i, c = ae(o, l);
|
|
518
546
|
else {
|
|
519
|
-
c =
|
|
520
|
-
const f =
|
|
547
|
+
c = ae(o, a);
|
|
548
|
+
const f = We(a / c.metersPerUnit);
|
|
521
549
|
if (f <= 0) return null;
|
|
522
550
|
l = f * c.metersPerUnit;
|
|
523
551
|
}
|
|
524
552
|
const u = l / r;
|
|
525
553
|
if (!Number.isFinite(u) || u <= 0) return null;
|
|
526
|
-
const
|
|
554
|
+
const h = l / c.metersPerUnit, d = h < 1 ? 2 : h < 10 && !Number.isInteger(h) ? 1 : 0, m = Array.from({ length: s + 1 }, (f, g) => (g * h).toFixed(d));
|
|
527
555
|
return {
|
|
528
556
|
segmentMeters: l,
|
|
529
557
|
segmentMm: u,
|
|
530
|
-
segments:
|
|
531
|
-
totalMm: u *
|
|
532
|
-
labels:
|
|
558
|
+
segments: s,
|
|
559
|
+
totalMm: u * s,
|
|
560
|
+
labels: m,
|
|
533
561
|
unitLabel: c.label,
|
|
534
562
|
// 1 mm on the page is groundMetersPerMm metres on the ground; the RF is
|
|
535
563
|
// that ratio in consistent units (mm : mm).
|
|
536
564
|
scaleDenominator: r * 1e3
|
|
537
565
|
};
|
|
538
566
|
}
|
|
539
|
-
function
|
|
540
|
-
const n = Math.min(2.6, Math.max(1.6, e * 0.34)), i = 0.2,
|
|
567
|
+
function Wr(r, t, e) {
|
|
568
|
+
const n = Math.min(2.6, Math.max(1.6, e * 0.34)), i = 0.2, s = n * 1.25, o = Math.max(0.6, Math.min(2.2, e - s - 0.4)), a = 0, l = r.segmentMm, c = [], u = [];
|
|
541
569
|
if (t === "single" || t === "double") {
|
|
542
|
-
const p = t === "double" ? 2 : 1, b =
|
|
570
|
+
const p = t === "double" ? 2 : 1, b = o / p;
|
|
543
571
|
for (let w = 0; w < p; w++)
|
|
544
572
|
for (let y = 0; y < r.segments; y++)
|
|
545
573
|
c.push({
|
|
@@ -551,45 +579,45 @@ function _r(r, t, e) {
|
|
|
551
579
|
filled: (y + w) % 2 === 0
|
|
552
580
|
});
|
|
553
581
|
} else {
|
|
554
|
-
u.push({ x1: 0, y1: a +
|
|
582
|
+
u.push({ x1: 0, y1: a + o, x2: r.totalMm, y2: a + o });
|
|
555
583
|
const p = t === "ticks" ? r.segments : 1;
|
|
556
584
|
for (let b = 0; b <= p; b++) {
|
|
557
585
|
const w = b / p * r.totalMm;
|
|
558
|
-
u.push({ x1: w, y1: a, x2: w, y2: a +
|
|
586
|
+
u.push({ x1: w, y1: a, x2: w, y2: a + o });
|
|
559
587
|
}
|
|
560
588
|
}
|
|
561
|
-
const
|
|
589
|
+
const h = r.labels.length - 1, d = r.labels.map((p, b) => ({
|
|
562
590
|
// The end label carries the unit so the bar reads "0 2 4 6 8 km".
|
|
563
|
-
text: b ===
|
|
591
|
+
text: b === h ? `${p} ${r.unitLabel}` : p,
|
|
564
592
|
// Keep the end label inside the drawn width rather than hanging off it.
|
|
565
|
-
x: b ===
|
|
566
|
-
y: a +
|
|
567
|
-
anchor: b === 0 ? "start" : b ===
|
|
593
|
+
x: b === h ? r.totalMm : b * l,
|
|
594
|
+
y: a + o + n,
|
|
595
|
+
anchor: b === 0 ? "start" : b === h ? "end" : "middle",
|
|
568
596
|
index: b
|
|
569
|
-
})),
|
|
597
|
+
})), m = (p) => p.length * n * 0.62, f = [];
|
|
570
598
|
let g = -1 / 0;
|
|
571
599
|
for (const p of d) {
|
|
572
|
-
const b =
|
|
573
|
-
if (!(!(p.index === 0 || p.index ===
|
|
574
|
-
if (p.index ===
|
|
575
|
-
for (; f.length > 1 && f[f.length - 1].x +
|
|
600
|
+
const b = m(p.text) / 2, w = p.anchor === "start" ? p.x : p.anchor === "end" ? p.x - b * 2 : p.x - b, y = w + m(p.text);
|
|
601
|
+
if (!(!(p.index === 0 || p.index === h) && w < g + n * 0.4)) {
|
|
602
|
+
if (p.index === h && w < g + n * 0.4)
|
|
603
|
+
for (; f.length > 1 && f[f.length - 1].x + m(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
|
|
576
604
|
f.push({ text: p.text, x: p.x, y: p.y, anchor: p.anchor }), g = y;
|
|
577
605
|
}
|
|
578
606
|
}
|
|
579
607
|
return { bars: c, strokes: u, labels: f, fontMm: n, strokeMm: i, segmentMeters: r.segmentMeters, unitLabel: r.unitLabel, scaleDenominator: r.scaleDenominator };
|
|
580
608
|
}
|
|
581
|
-
function
|
|
609
|
+
function ae(r, t) {
|
|
582
610
|
let e = r[0];
|
|
583
611
|
for (const n of r)
|
|
584
612
|
t / n.metersPerUnit >= 1 && (e = n);
|
|
585
613
|
return e;
|
|
586
614
|
}
|
|
587
|
-
const
|
|
588
|
-
function
|
|
589
|
-
return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
615
|
+
const Br = " ";
|
|
616
|
+
function Kr(r) {
|
|
617
|
+
return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Br);
|
|
590
618
|
}
|
|
591
|
-
const
|
|
592
|
-
function
|
|
619
|
+
const Ke = /\{\{\s*([\w.]+)\s*\}\}/g;
|
|
620
|
+
function Vr(r, t) {
|
|
593
621
|
if (r.startsWith("atlas.")) return t.atlas?.[r.slice(6)];
|
|
594
622
|
if (r.startsWith("frame.")) {
|
|
595
623
|
const e = r.slice(6), n = e.lastIndexOf(".");
|
|
@@ -601,78 +629,81 @@ function zr(r, t) {
|
|
|
601
629
|
}
|
|
602
630
|
return t.page[r];
|
|
603
631
|
}
|
|
604
|
-
function
|
|
632
|
+
function Ve(r, t) {
|
|
605
633
|
const e = [];
|
|
606
|
-
return { text: r.replace(
|
|
607
|
-
const
|
|
608
|
-
return
|
|
634
|
+
return { text: r.replace(Ke, (i, s) => {
|
|
635
|
+
const o = Vr(s, t);
|
|
636
|
+
return o === void 0 ? (e.push(s), i) : o;
|
|
609
637
|
}), unresolved: e };
|
|
610
638
|
}
|
|
611
|
-
function
|
|
612
|
-
return [...r.matchAll(
|
|
639
|
+
function Hr(r) {
|
|
640
|
+
return [...r.matchAll(Ke)].map((t) => t[1]);
|
|
613
641
|
}
|
|
614
|
-
const
|
|
615
|
-
function
|
|
642
|
+
const le = /* @__PURE__ */ new WeakMap();
|
|
643
|
+
function Yr(r, t) {
|
|
616
644
|
const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
|
|
617
645
|
if (!n) return e;
|
|
618
646
|
const i = n.createTreeWalker(
|
|
619
647
|
r,
|
|
620
648
|
4
|
|
621
649
|
/* NodeFilter.SHOW_TEXT */
|
|
622
|
-
),
|
|
623
|
-
for (let
|
|
624
|
-
for (const
|
|
625
|
-
let a =
|
|
650
|
+
), s = [];
|
|
651
|
+
for (let o = i.nextNode(); o; o = i.nextNode()) s.push(o);
|
|
652
|
+
for (const o of s) {
|
|
653
|
+
let a = le.get(o);
|
|
626
654
|
if (a === void 0) {
|
|
627
|
-
if (a =
|
|
628
|
-
|
|
655
|
+
if (a = o.data, !a.includes("{{")) continue;
|
|
656
|
+
le.set(o, a);
|
|
629
657
|
}
|
|
630
|
-
const l =
|
|
631
|
-
|
|
658
|
+
const l = Ve(a, t);
|
|
659
|
+
o.data !== l.text && (o.data = l.text), e.push(...l.unresolved);
|
|
632
660
|
}
|
|
633
661
|
return e;
|
|
634
662
|
}
|
|
635
|
-
function
|
|
663
|
+
function Xr(r = /* @__PURE__ */ new Date()) {
|
|
636
664
|
return `${r.getFullYear()}-${String(r.getMonth() + 1).padStart(2, "0")}-${String(r.getDate()).padStart(2, "0")}`;
|
|
637
665
|
}
|
|
638
|
-
const
|
|
639
|
-
function
|
|
666
|
+
const Rt = "data-om-carto-unlinked";
|
|
667
|
+
function He(r) {
|
|
640
668
|
return r.closest("om-cartograph");
|
|
641
669
|
}
|
|
642
|
-
function
|
|
643
|
-
const e =
|
|
670
|
+
function Ye(r, t) {
|
|
671
|
+
const e = He(r);
|
|
644
672
|
if (!e || !t) return null;
|
|
645
673
|
for (const n of e.querySelectorAll("om-frame"))
|
|
646
674
|
if (n.id === t) return n;
|
|
647
675
|
return null;
|
|
648
676
|
}
|
|
649
|
-
function
|
|
677
|
+
function Xe(r) {
|
|
650
678
|
return [...r.querySelectorAll("om-frame")];
|
|
651
679
|
}
|
|
652
|
-
function
|
|
653
|
-
const t =
|
|
680
|
+
function Jr(r) {
|
|
681
|
+
const t = He(r);
|
|
654
682
|
if (!t) return null;
|
|
655
|
-
const e =
|
|
683
|
+
const e = Xe(t);
|
|
656
684
|
return e.length === 1 ? e[0] : null;
|
|
657
685
|
}
|
|
658
686
|
function U(r) {
|
|
659
687
|
const t = r.getAttribute("for");
|
|
660
|
-
return t ?
|
|
688
|
+
return t ? Ye(r, t) : Jr(r);
|
|
661
689
|
}
|
|
662
690
|
function W(r, t) {
|
|
663
|
-
let e = r.querySelector(`:scope > [${
|
|
691
|
+
let e = r.querySelector(`:scope > [${Rt}]`);
|
|
664
692
|
if (!e) {
|
|
665
693
|
for (const n of [...r.children])
|
|
666
694
|
n.tagName.toLowerCase() !== "om-legend-row" && n.remove();
|
|
667
|
-
e = r.ownerDocument.createElement("div"), e.setAttribute(
|
|
695
|
+
e = r.ownerDocument.createElement("div"), e.setAttribute(Rt, ""), e.style.cssText = "font:italic 2.6mm/1.3 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.7;", r.appendChild(e);
|
|
668
696
|
}
|
|
669
697
|
e.textContent !== t && (e.textContent = t);
|
|
670
698
|
}
|
|
671
|
-
function
|
|
672
|
-
r.querySelector(`:scope > [${
|
|
699
|
+
function Zr(r) {
|
|
700
|
+
r.querySelector(`:scope > [${Rt}]`)?.remove();
|
|
701
|
+
}
|
|
702
|
+
const ce = "data-om-carto-page", ue = "data-om-carto-marks", wt = "data-om-carto-credit", he = "data-om-carto-attribution", Je = "Built with OnlyMap by NIKA", Qr = `${Je} · free for non-commercial use`, nt = 2, vt = 1.2, it = 2.4, At = 1.5, st = 1.2, Mt = 0.3, St = 0.8, Ct = "http://www.w3.org/2000/svg", tn = 6e4;
|
|
703
|
+
function me(r) {
|
|
704
|
+
return r.replace(/©|\(c\)/gi, " ").replace(/\s+/g, " ").trim().toLowerCase();
|
|
673
705
|
}
|
|
674
|
-
|
|
675
|
-
class He extends O {
|
|
706
|
+
class Ze extends O {
|
|
676
707
|
static observedAttributes = [...T["om-cartograph"]];
|
|
677
708
|
frameListenerBound = !1;
|
|
678
709
|
/** Fields of the atlas page currently displayed, for {{atlas.<field>}}. */
|
|
@@ -681,7 +712,7 @@ class He extends O {
|
|
|
681
712
|
unsubscribeLicense = null;
|
|
682
713
|
/** The resolved page box, mm — furniture and export read this, never the attributes. */
|
|
683
714
|
get pageSize() {
|
|
684
|
-
return
|
|
715
|
+
return dt(this.getAttribute("size"), this.getAttribute("width"), this.getAttribute("height"), this.getAttribute("orientation"));
|
|
685
716
|
}
|
|
686
717
|
/** Bleed in mm (0 when unset) — extends the printed sheet past the trim. */
|
|
687
718
|
get bleedMm() {
|
|
@@ -690,11 +721,11 @@ class He extends O {
|
|
|
690
721
|
}
|
|
691
722
|
connectedCallback() {
|
|
692
723
|
super.connectedCallback(), this.frameListenerBound || (this.frameListenerBound = !0, this.addEventListener("om-frame-ready", () => {
|
|
693
|
-
this.atlas?.refresh(), this.refreshTokens(), this.refreshFurniture(), this.renderCredit();
|
|
694
|
-
}), this.addEventListener("om-frame-view", () => {
|
|
724
|
+
this.atlas?.refresh(), this.refreshTokens(), this.refreshFurniture(), this.renderCredit(), this.renderAttribution();
|
|
725
|
+
}), this.addEventListener("om-attributions-changed", () => this.renderAttribution()), this.addEventListener("om-frame-view", () => {
|
|
695
726
|
this.refreshTokens(), this.refreshFurniture();
|
|
696
727
|
})), !this.creditObserver && typeof MutationObserver < "u" && (this.creditObserver = new MutationObserver(() => {
|
|
697
|
-
this.querySelector(`:scope > [${
|
|
728
|
+
this.querySelector(`:scope > [${wt}]`) || this.renderCredit(), this.renderAttribution();
|
|
698
729
|
}), this.creditObserver.observe(this, { childList: !0 }));
|
|
699
730
|
}
|
|
700
731
|
disconnectedCallback() {
|
|
@@ -713,18 +744,47 @@ class He extends O {
|
|
|
713
744
|
renderCredit() {
|
|
714
745
|
const t = J();
|
|
715
746
|
t && !this.unsubscribeLicense && typeof t.subscribeLicense == "function" && (this.unsubscribeLicense = t.subscribeLicense(() => this.renderCredit()));
|
|
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 > [${
|
|
747
|
+
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 > [${wt}]`);
|
|
717
748
|
if (e === "hidden" || n) {
|
|
718
749
|
i?.remove();
|
|
719
750
|
return;
|
|
720
751
|
}
|
|
721
|
-
const
|
|
752
|
+
const s = e === "voluntary" ? Je : Qr;
|
|
722
753
|
if (i) {
|
|
723
|
-
i.textContent !==
|
|
754
|
+
i.textContent !== s && (i.textContent = s), this.armCreditPainter(i);
|
|
724
755
|
return;
|
|
725
756
|
}
|
|
726
|
-
const
|
|
727
|
-
|
|
757
|
+
const o = this.ownerDocument.createElement("div");
|
|
758
|
+
o.setAttribute(wt, ""), o.setAttribute("z", "2147483644"), o.textContent = s, o.style.cssText = `position:absolute;left:${nt}mm;bottom:${vt}mm;z-index:2147483644;font:${it}mm/${At} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${Mt}mm ${st}mm;border-radius:${St}mm;pointer-events:none;`, this.armCreditPainter(o), this.appendChild(o);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Basemap attribution, moved off the maps and onto the sheet.
|
|
762
|
+
*
|
|
763
|
+
* A frame's map draws no attribution of its own — the same rule as the
|
|
764
|
+
* badge, and for the same reasons: the sheet is the published artefact, a
|
|
765
|
+
* line per frame credits one provider several times, and on a small inset
|
|
766
|
+
* the control covers the map it credits. So the page prints every frame's
|
|
767
|
+
* providers once, bottom-right (the credit has bottom-left).
|
|
768
|
+
*
|
|
769
|
+
* A provider the author already credits in their own text is left out:
|
|
770
|
+
* the obligation is the credit, not this element. Static frames contribute
|
|
771
|
+
* through their `attribution` attribute, so a page that never loads the
|
|
772
|
+
* runtime still credits the tiles in its pictures.
|
|
773
|
+
*/
|
|
774
|
+
renderAttribution() {
|
|
775
|
+
const t = [...this.querySelectorAll("om-frame")], e = qe(t.flatMap((l) => l.attributions?.() ?? [])), n = [...this.querySelectorAll("om-text")].map((l) => me(l.textContent ?? "")).join(`
|
|
776
|
+
`), i = e.filter((l) => !n.includes(me(l))), s = this.querySelector(`:scope > [${he}]`);
|
|
777
|
+
if (i.length === 0) {
|
|
778
|
+
s?.remove();
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const o = i.join(Kt);
|
|
782
|
+
if (s) {
|
|
783
|
+
s.textContent !== o && (s.textContent = o);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
const a = this.ownerDocument.createElement("div");
|
|
787
|
+
a.setAttribute(he, ""), a.setAttribute("z", "2147483644"), a.textContent = o, a.style.cssText = `position:absolute;right:${nt}mm;bottom:${vt}mm;z-index:2147483644;max-width:60%;text-align:right;font:${it}mm/${At} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${Mt}mm ${st}mm;border-radius:${St}mm;pointer-events:none;`, this.armFootPainter(a, "right"), this.appendChild(a);
|
|
728
788
|
}
|
|
729
789
|
/**
|
|
730
790
|
* Which credit this sheet carries, from the core's own predicate so the
|
|
@@ -740,11 +800,20 @@ class He extends O {
|
|
|
740
800
|
}
|
|
741
801
|
/** Give the runtime-owned DOM credit the same canvas paint contract as authored furniture. */
|
|
742
802
|
armCreditPainter(t) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
803
|
+
this.armFootPainter(t, "left");
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* The canvas twin of a runtime-owned foot line — the credit (left) or the
|
|
807
|
+
* basemap attribution (right) — so the exported raster carries what the
|
|
808
|
+
* screen and the printed page carry. One painter for both, so the two lines
|
|
809
|
+
* cannot drift apart in size, ground or inset.
|
|
810
|
+
*/
|
|
811
|
+
armFootPainter(t, e) {
|
|
812
|
+
t.paintCartograph = (n, i) => {
|
|
813
|
+
const s = (d) => d * i.pxPerMm, o = t.textContent ?? "", l = it * At + Mt * 2, c = this.pageSize.heightMm - vt - l;
|
|
814
|
+
n.save(), n.font = `${s(it)}px system-ui, sans-serif`;
|
|
815
|
+
const u = n.measureText(o).width / i.pxPerMm + st * 2, h = e === "left" ? nt : this.pageSize.widthMm - nt - u;
|
|
816
|
+
n.fillStyle = "rgba(255,255,255,.72)", n.beginPath(), typeof n.roundRect == "function" ? n.roundRect(s(h), s(c), s(u), s(l), s(St)) : n.rect(s(h), s(c), s(u), s(l)), n.fill(), n.fillStyle = "#374151", n.textAlign = "left", n.textBaseline = "middle", n.fillText(o, s(h + st), s(c + l / 2)), n.restore();
|
|
748
817
|
};
|
|
749
818
|
}
|
|
750
819
|
/**
|
|
@@ -761,27 +830,27 @@ class He extends O {
|
|
|
761
830
|
const e = t.dpi ?? (Number(this.getAttribute("dpi")) || 300), n = [...this.querySelectorAll("om-frame")];
|
|
762
831
|
let i = null;
|
|
763
832
|
if (this.hasAttribute("flatten") && (i = await this.buildFlattenedImage(e).catch(() => null), i && this.appendChild(i)), !i) for (const a of n) await a.enterPrintMode?.(e);
|
|
764
|
-
let
|
|
765
|
-
const
|
|
766
|
-
if (!
|
|
767
|
-
|
|
833
|
+
let s = !1;
|
|
834
|
+
const o = () => {
|
|
835
|
+
if (!s) {
|
|
836
|
+
s = !0, i && URL.revokeObjectURL(i.src), i?.remove(), i = null;
|
|
768
837
|
for (const a of n) a.exitPrintMode?.();
|
|
769
|
-
window.removeEventListener("afterprint",
|
|
838
|
+
window.removeEventListener("afterprint", o);
|
|
770
839
|
}
|
|
771
840
|
};
|
|
772
|
-
window.addEventListener("afterprint",
|
|
841
|
+
window.addEventListener("afterprint", o);
|
|
773
842
|
try {
|
|
774
843
|
window.print();
|
|
775
844
|
} finally {
|
|
776
|
-
|
|
845
|
+
s || setTimeout(o, tn);
|
|
777
846
|
}
|
|
778
847
|
}
|
|
779
848
|
/** Render the whole page to one image, for `flatten`. */
|
|
780
849
|
async buildFlattenedImage(t) {
|
|
781
|
-
const { renderCartograph: e } = await Promise.resolve().then(() =>
|
|
850
|
+
const { renderCartograph: e } = await Promise.resolve().then(() => Pr), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
|
|
782
851
|
i.src = URL.createObjectURL(n), i.setAttribute("data-om-carto-flattened", "");
|
|
783
|
-
const
|
|
784
|
-
return i.style.cssText = `position:absolute;left:${-
|
|
852
|
+
const s = this.bleedMm;
|
|
853
|
+
return i.style.cssText = `position:absolute;left:${-s}mm;top:${-s}mm;width:calc(100% + ${s * 2}mm);height:calc(100% + ${s * 2}mm);z-index:2147483645;`, await i.decode().catch(() => {
|
|
785
854
|
}), i;
|
|
786
855
|
}
|
|
787
856
|
/** The page's atlas controller, if it has one. */
|
|
@@ -799,20 +868,20 @@ class He extends O {
|
|
|
799
868
|
}
|
|
800
869
|
/** Values every `{{token}}` on this page resolves against. */
|
|
801
870
|
tokenContext() {
|
|
802
|
-
const t = /* @__PURE__ */ new Map(), e =
|
|
803
|
-
for (const
|
|
804
|
-
const
|
|
805
|
-
t.set(
|
|
806
|
-
scale: a > 0 ?
|
|
807
|
-
crs:
|
|
871
|
+
const t = /* @__PURE__ */ new Map(), e = Xe(this);
|
|
872
|
+
for (const s of e) {
|
|
873
|
+
const o = s.georef, a = o?.groundMetersPerMm() ?? 0;
|
|
874
|
+
t.set(s.id, {
|
|
875
|
+
scale: a > 0 ? Kr(a * 1e3) : void 0,
|
|
876
|
+
crs: o?.crs
|
|
808
877
|
});
|
|
809
878
|
}
|
|
810
|
-
const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (
|
|
879
|
+
const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (s) => Ve(this.getAttribute(s) ?? "", n).text;
|
|
811
880
|
return {
|
|
812
881
|
page: {
|
|
813
882
|
title: i("title"),
|
|
814
883
|
attribution: i("attribution"),
|
|
815
|
-
date:
|
|
884
|
+
date: Xr(),
|
|
816
885
|
notes: i("notes")
|
|
817
886
|
},
|
|
818
887
|
frames: t,
|
|
@@ -830,11 +899,11 @@ class He extends O {
|
|
|
830
899
|
renderNow() {
|
|
831
900
|
const { widthMm: t, heightMm: e } = this.pageSize, n = this.bleedMm;
|
|
832
901
|
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");
|
|
833
|
-
let i = this.querySelector(`style[${
|
|
834
|
-
i || (i = document.createElement("style"), i.setAttribute(
|
|
835
|
-
const
|
|
836
|
-
i.textContent = `@page { size: ${
|
|
837
|
-
@media print { html, body { margin: 0; padding: 0; } om-cartograph { break-after: page; } }`, this.renderPrintMarks(t, e, n), this.applyCvd(), this.refreshTokens(), this.renderCredit();
|
|
902
|
+
let i = this.querySelector(`style[${ce}]`);
|
|
903
|
+
i || (i = document.createElement("style"), i.setAttribute(ce, ""), this.prepend(i));
|
|
904
|
+
const s = t + n * 2, o = e + n * 2;
|
|
905
|
+
i.textContent = `@page { size: ${s}mm ${o}mm; margin: 0; }
|
|
906
|
+
@media print { html, body { margin: 0; padding: 0; } om-cartograph { break-after: page; } }`, this.renderPrintMarks(t, e, n), this.applyCvd(), this.refreshTokens(), this.renderCredit(), this.renderAttribution();
|
|
838
907
|
}
|
|
839
908
|
/**
|
|
840
909
|
* Crop marks and the safe-zone guide.
|
|
@@ -846,27 +915,27 @@ class He extends O {
|
|
|
846
915
|
* worse than no guide.
|
|
847
916
|
*/
|
|
848
917
|
renderPrintMarks(t, e, n) {
|
|
849
|
-
const i = this.hasAttribute("crop-marks") && n > 0,
|
|
850
|
-
if (!i && !
|
|
918
|
+
const i = this.hasAttribute("crop-marks") && n > 0, s = Number(this.getAttribute("safe-zone")), o = Number.isFinite(s) && s > 0, a = this.querySelector(`:scope > [${ue}]`);
|
|
919
|
+
if (!i && !o) {
|
|
851
920
|
a?.remove();
|
|
852
921
|
return;
|
|
853
922
|
}
|
|
854
|
-
const l = this.ownerDocument, c = a ?? l.createElementNS(
|
|
855
|
-
if (c.setAttribute(
|
|
856
|
-
const u = Math.min(n, 4),
|
|
857
|
-
for (const
|
|
923
|
+
const l = this.ownerDocument, c = a ?? l.createElementNS(Ct, "svg");
|
|
924
|
+
if (c.setAttribute(ue, ""), c.setAttribute("viewBox", `${-n} ${-n} ${t + n * 2} ${e + n * 2}`), c.setAttribute("width", `${t + n * 2}mm`), c.setAttribute("height", `${e + n * 2}mm`), c.style.cssText = `position:absolute;left:${-n}mm;top:${-n}mm;pointer-events:none;z-index:2147483646;`, c.replaceChildren(), i) {
|
|
925
|
+
const u = Math.min(n, 4), h = Math.min(n * 0.35, 1.5), d = [];
|
|
926
|
+
for (const m of [0, t])
|
|
858
927
|
for (const f of [0, e]) {
|
|
859
|
-
const g =
|
|
860
|
-
d.push([
|
|
928
|
+
const g = m === 0 ? -1 : 1, p = f === 0 ? -1 : 1;
|
|
929
|
+
d.push([m + g * h, f, m + g * (h + u), f]), d.push([m, f + p * h, m, f + p * (h + u)]);
|
|
861
930
|
}
|
|
862
|
-
for (const [
|
|
863
|
-
const b = l.createElementNS(
|
|
864
|
-
b.setAttribute("x1", String(
|
|
931
|
+
for (const [m, f, g, p] of d) {
|
|
932
|
+
const b = l.createElementNS(Ct, "line");
|
|
933
|
+
b.setAttribute("x1", String(m)), b.setAttribute("y1", String(f)), b.setAttribute("x2", String(g)), b.setAttribute("y2", String(p)), b.setAttribute("stroke", "#000"), b.setAttribute("stroke-width", "0.15"), c.appendChild(b);
|
|
865
934
|
}
|
|
866
935
|
}
|
|
867
|
-
if (
|
|
868
|
-
const u = l.createElementNS(
|
|
869
|
-
u.setAttribute("x", String(
|
|
936
|
+
if (o) {
|
|
937
|
+
const u = l.createElementNS(Ct, "rect");
|
|
938
|
+
u.setAttribute("x", String(s)), u.setAttribute("y", String(s)), u.setAttribute("width", String(Math.max(0, t - s * 2))), u.setAttribute("height", String(Math.max(0, e - s * 2))), u.setAttribute("fill", "none"), u.setAttribute("stroke", "#22aaff"), u.setAttribute("stroke-width", "0.2"), u.setAttribute("stroke-dasharray", "2 1.5"), u.setAttribute("data-om-carto-screen-only", ""), c.appendChild(u);
|
|
870
939
|
}
|
|
871
940
|
a || this.appendChild(c);
|
|
872
941
|
}
|
|
@@ -879,54 +948,54 @@ class He extends O {
|
|
|
879
948
|
* injected only when a page actually asks for one.
|
|
880
949
|
*/
|
|
881
950
|
applyCvd() {
|
|
882
|
-
const t =
|
|
951
|
+
const t = qt(this.getAttribute("cvd"));
|
|
883
952
|
if (!t) {
|
|
884
953
|
this.style.removeProperty("filter");
|
|
885
954
|
return;
|
|
886
955
|
}
|
|
887
|
-
|
|
956
|
+
$r(this.ownerDocument), this.style.filter = `url(#${Oe(t)})`;
|
|
888
957
|
}
|
|
889
958
|
}
|
|
890
|
-
|
|
891
|
-
function
|
|
892
|
-
const
|
|
959
|
+
x("om-cartograph", Ze);
|
|
960
|
+
function en({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
|
|
961
|
+
const s = n > 0 ? n : e * 1.2, o = [];
|
|
893
962
|
for (const c of r.split(/\r?\n/)) {
|
|
894
|
-
const u = c.split(/\s+/).filter((
|
|
963
|
+
const u = c.split(/\s+/).filter((m) => m !== "");
|
|
895
964
|
if (u.length === 0) {
|
|
896
|
-
|
|
965
|
+
o.push({ text: "", baselineY: 0, width: 0 });
|
|
897
966
|
continue;
|
|
898
967
|
}
|
|
899
|
-
const
|
|
900
|
-
let f =
|
|
968
|
+
const h = (m) => {
|
|
969
|
+
let f = m;
|
|
901
970
|
for (; i(f) > t && f.length > 1; ) {
|
|
902
971
|
let g = f.length - 1;
|
|
903
972
|
for (; g > 1 && i(f.slice(0, g)) > t; ) g--;
|
|
904
|
-
|
|
973
|
+
o.push({ text: f.slice(0, g), baselineY: 0, width: i(f.slice(0, g)) }), f = f.slice(g);
|
|
905
974
|
}
|
|
906
975
|
return f;
|
|
907
976
|
};
|
|
908
977
|
let d = "";
|
|
909
|
-
for (const
|
|
910
|
-
const f = d === "" ?
|
|
911
|
-
d === "" ? d = m
|
|
978
|
+
for (const m of u) {
|
|
979
|
+
const f = d === "" ? m : `${d} ${m}`;
|
|
980
|
+
d === "" ? d = h(m) : i(f) > t ? (o.push({ text: d, baselineY: 0, width: i(d) }), d = h(m)) : d = f;
|
|
912
981
|
}
|
|
913
|
-
|
|
982
|
+
o.push({ text: d, baselineY: 0, width: i(d) });
|
|
914
983
|
}
|
|
915
984
|
const a = e * 0.8;
|
|
916
985
|
let l = 0;
|
|
917
|
-
return
|
|
918
|
-
c.baselineY = a + u *
|
|
919
|
-
}), { lines:
|
|
986
|
+
return o.forEach((c, u) => {
|
|
987
|
+
c.baselineY = a + u * s, c.width > l && (l = c.width);
|
|
988
|
+
}), { lines: o, lineHeight: s, maxWidth: l };
|
|
920
989
|
}
|
|
921
|
-
function
|
|
990
|
+
function Ni(r) {
|
|
922
991
|
if (typeof document > "u") return null;
|
|
923
992
|
const e = document.createElement("canvas").getContext("2d");
|
|
924
993
|
return e ? (e.font = r, (n) => e.measureText(n).width) : null;
|
|
925
994
|
}
|
|
926
|
-
function
|
|
995
|
+
function rn(r, t, e) {
|
|
927
996
|
return r === "center" ? (t - e) / 2 : r === "end" || r === "right" ? t - e : 0;
|
|
928
997
|
}
|
|
929
|
-
class
|
|
998
|
+
class Qe extends O {
|
|
930
999
|
static observedAttributes = [...T["om-text"]];
|
|
931
1000
|
renderNow() {
|
|
932
1001
|
this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden";
|
|
@@ -938,109 +1007,109 @@ class Ye extends O {
|
|
|
938
1007
|
n === "start" || n === "center" || n === "end" ? this.style.textAlign = n : this.style.removeProperty("text-align");
|
|
939
1008
|
const i = this.getAttribute("font");
|
|
940
1009
|
i ? this.style.fontFamily = i : this.style.removeProperty("font-family");
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
const
|
|
944
|
-
|
|
1010
|
+
const s = this.getAttribute("color");
|
|
1011
|
+
s ? this.style.color = s : this.style.removeProperty("color");
|
|
1012
|
+
const o = this.getAttribute("bg");
|
|
1013
|
+
o ? this.style.background = o : this.style.removeProperty("background"), this.resolveTokens();
|
|
945
1014
|
}
|
|
946
1015
|
/** Re-run token substitution from the authored templates. */
|
|
947
1016
|
resolveTokens() {
|
|
948
1017
|
const t = this.closest("om-cartograph");
|
|
949
|
-
t && typeof t.tokenContext == "function" &&
|
|
1018
|
+
t && typeof t.tokenContext == "function" && Yr(this, t.tokenContext());
|
|
950
1019
|
}
|
|
951
1020
|
paintCartograph(t, e) {
|
|
952
|
-
const { w: n, h: i } = S(this),
|
|
953
|
-
if (
|
|
954
|
-
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l =
|
|
955
|
-
l && (t.fillStyle = l, t.fillRect(0, 0,
|
|
1021
|
+
const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
|
|
1022
|
+
if (s <= 0 || o <= 0) return;
|
|
1023
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = I(a?.backgroundColor);
|
|
1024
|
+
l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
|
|
956
1025
|
const c = (this.textContent ?? "").trim();
|
|
957
1026
|
if (c === "") return;
|
|
958
|
-
const u =
|
|
959
|
-
t.save(), t.font = p, t.fillStyle =
|
|
960
|
-
const b =
|
|
1027
|
+
const u = Tt(a?.fontSize, 12), h = a?.lineHeight === "normal" ? u * 1.4 : Tt(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", m = a?.fontWeight || "400", f = u * e.scale, g = h * e.scale, p = `${m} ${f}px ${d}`;
|
|
1028
|
+
t.save(), t.font = p, t.fillStyle = I(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
|
|
1029
|
+
const b = en({
|
|
961
1030
|
text: c,
|
|
962
|
-
maxWidth:
|
|
1031
|
+
maxWidth: s,
|
|
963
1032
|
fontSizePx: f,
|
|
964
1033
|
lineHeightPx: g,
|
|
965
1034
|
measure: (y) => t.measureText(y).width
|
|
966
1035
|
}), w = a?.textAlign || "start";
|
|
967
1036
|
for (const y of b.lines) {
|
|
968
|
-
if (y.baselineY >
|
|
969
|
-
t.fillText(y.text,
|
|
1037
|
+
if (y.baselineY > o + g) break;
|
|
1038
|
+
t.fillText(y.text, rn(w, s, y.width), y.baselineY);
|
|
970
1039
|
}
|
|
971
1040
|
t.restore();
|
|
972
1041
|
}
|
|
973
1042
|
}
|
|
974
|
-
|
|
975
|
-
const
|
|
976
|
-
let
|
|
977
|
-
const
|
|
978
|
-
function
|
|
979
|
-
const n = (t[1] - r[1]) *
|
|
1043
|
+
x("om-text", Qe);
|
|
1044
|
+
const nn = 63710087714e-4;
|
|
1045
|
+
let sn = nn;
|
|
1046
|
+
const ot = Math.PI / 180;
|
|
1047
|
+
function on(r, t, e = sn) {
|
|
1048
|
+
const n = (t[1] - r[1]) * ot, i = (t[0] - r[0]) * ot, s = r[1] * ot, o = t[1] * ot, a = Math.sin(n / 2) ** 2 + Math.cos(s) * Math.cos(o) * Math.sin(i / 2) ** 2;
|
|
980
1049
|
return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
|
|
981
1050
|
}
|
|
982
|
-
const et = 6378137,
|
|
983
|
-
function
|
|
984
|
-
const e = Math.max(-
|
|
985
|
-
return [et * r *
|
|
1051
|
+
const et = 6378137, de = Math.PI / 180, fe = 180 / Math.PI, pe = 85.0511287798066, It = 2 * Math.PI * et / 360;
|
|
1052
|
+
function Vt([r, t]) {
|
|
1053
|
+
const e = Math.max(-pe, Math.min(pe, t));
|
|
1054
|
+
return [et * r * de, et * Math.log(Math.tan(Math.PI / 4 + e * de / 2))];
|
|
986
1055
|
}
|
|
987
|
-
function
|
|
988
|
-
return [r / et *
|
|
1056
|
+
function pt([r, t]) {
|
|
1057
|
+
return [r / et * fe, (2 * Math.atan(Math.exp(t / et)) - Math.PI / 2) * fe];
|
|
989
1058
|
}
|
|
990
|
-
const
|
|
1059
|
+
const an = {
|
|
991
1060
|
code: "EPSG:3857",
|
|
992
1061
|
units: "linear",
|
|
993
1062
|
metresPerUnit: 1,
|
|
994
|
-
forward:
|
|
995
|
-
inverse:
|
|
996
|
-
},
|
|
1063
|
+
forward: Vt,
|
|
1064
|
+
inverse: pt
|
|
1065
|
+
}, ln = {
|
|
997
1066
|
code: "EPSG:4326",
|
|
998
1067
|
units: "degree",
|
|
999
|
-
metresPerUnit:
|
|
1068
|
+
metresPerUnit: It,
|
|
1000
1069
|
forward: ([r, t]) => [r, t],
|
|
1001
1070
|
inverse: ([r, t]) => [r, t]
|
|
1002
1071
|
};
|
|
1003
|
-
function
|
|
1072
|
+
function Ht(r) {
|
|
1004
1073
|
if (r == null) return null;
|
|
1005
1074
|
const t = r.trim();
|
|
1006
1075
|
if (t === "") return null;
|
|
1007
1076
|
const e = /^(?:epsg:{1,2})?(\d{4,6})$/i.exec(t);
|
|
1008
1077
|
return e ? `EPSG:${e[1]}` : t.toUpperCase();
|
|
1009
1078
|
}
|
|
1010
|
-
function
|
|
1011
|
-
const t =
|
|
1012
|
-
return t === "EPSG:3857" || t === "EPSG:900913" ?
|
|
1079
|
+
function tr(r) {
|
|
1080
|
+
const t = Ht(r) ?? "EPSG:3857";
|
|
1081
|
+
return t === "EPSG:3857" || t === "EPSG:900913" ? an : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? ln : null;
|
|
1013
1082
|
}
|
|
1014
|
-
const
|
|
1015
|
-
function
|
|
1083
|
+
const er = /* @__PURE__ */ new Map();
|
|
1084
|
+
function Ft(r, t) {
|
|
1016
1085
|
return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
|
|
1017
1086
|
}
|
|
1018
|
-
async function
|
|
1019
|
-
const t =
|
|
1087
|
+
async function cn(r) {
|
|
1088
|
+
const t = er.get(r);
|
|
1020
1089
|
if (typeof t == "string") return t;
|
|
1021
1090
|
const e = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
|
|
1022
1091
|
if (!Number.isFinite(e)) return null;
|
|
1023
|
-
if (e >= 32601 && e <= 32660) return
|
|
1024
|
-
if (e >= 32701 && e <= 32760) return
|
|
1092
|
+
if (e >= 32601 && e <= 32660) return Ft(e - 32600, "N");
|
|
1093
|
+
if (e >= 32701 && e <= 32760) return Ft(e - 32700, "S");
|
|
1025
1094
|
const { CRS_DEFS: n } = await import("./crs-BzE_KP4M.js");
|
|
1026
1095
|
return n[e]?.def ?? null;
|
|
1027
1096
|
}
|
|
1028
|
-
function
|
|
1029
|
-
if (r.projName === "longlat") return { units: "degree", metresPerUnit:
|
|
1097
|
+
function un(r) {
|
|
1098
|
+
if (r.projName === "longlat") return { units: "degree", metresPerUnit: It };
|
|
1030
1099
|
if (typeof r.to_meter == "number" && r.to_meter > 0) return { units: "linear", metresPerUnit: r.to_meter };
|
|
1031
1100
|
const t = (r.units ?? "m").toLowerCase();
|
|
1032
|
-
return t.startsWith("deg") ? { units: "degree", metresPerUnit:
|
|
1101
|
+
return t.startsWith("deg") ? { units: "degree", metresPerUnit: It } : t.includes("ft") || t.includes("foot") ? { units: "linear", metresPerUnit: 0.3048 } : { units: "linear", metresPerUnit: 1 };
|
|
1033
1102
|
}
|
|
1034
|
-
async function
|
|
1035
|
-
const e =
|
|
1103
|
+
async function hn(r, t) {
|
|
1104
|
+
const e = Ht(r) ?? "EPSG:3857", n = er.get(e);
|
|
1036
1105
|
if (n && typeof n != "string") return n;
|
|
1037
1106
|
if (!t) {
|
|
1038
|
-
const u =
|
|
1107
|
+
const u = tr(e);
|
|
1039
1108
|
if (u) return u;
|
|
1040
1109
|
}
|
|
1041
|
-
const i = t?.trim() || await
|
|
1110
|
+
const i = t?.trim() || await cn(e);
|
|
1042
1111
|
if (!i) return null;
|
|
1043
|
-
const
|
|
1112
|
+
const s = (await import("./index-CcLC9jE5.js")).default, a = s(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } = un(new s.Proj(i));
|
|
1044
1113
|
return {
|
|
1045
1114
|
code: e,
|
|
1046
1115
|
units: l,
|
|
@@ -1049,92 +1118,92 @@ async function nn(r, t) {
|
|
|
1049
1118
|
inverse: (u) => a.forward(u)
|
|
1050
1119
|
};
|
|
1051
1120
|
}
|
|
1052
|
-
const
|
|
1053
|
-
function
|
|
1054
|
-
const e = Math.max(-
|
|
1055
|
-
return [
|
|
1121
|
+
const ge = Math.PI / 180, mn = 180 / Math.PI, dn = { code: "EPSG:3857", forward: Vt, inverse: pt }, Pi = Vt, Ti = pt, be = 6378137, ye = 89.9;
|
|
1122
|
+
function fn([r, t]) {
|
|
1123
|
+
const e = Math.max(-ye, Math.min(ye, t));
|
|
1124
|
+
return [be * r * ge, be * Math.log(Math.tan(Math.PI / 4 + e * ge / 2))];
|
|
1056
1125
|
}
|
|
1057
|
-
const
|
|
1126
|
+
const pn = { code: "EPSG:3857", forward: fn, inverse: pt }, Ot = Ht;
|
|
1058
1127
|
function Y(r) {
|
|
1059
|
-
return
|
|
1128
|
+
return tr(r);
|
|
1060
1129
|
}
|
|
1061
|
-
async function
|
|
1062
|
-
return
|
|
1130
|
+
async function _t(r, t) {
|
|
1131
|
+
return hn(r, t);
|
|
1063
1132
|
}
|
|
1064
|
-
const
|
|
1065
|
-
function
|
|
1066
|
-
const e = t.length, n = r.map((i,
|
|
1133
|
+
const Li = Ft;
|
|
1134
|
+
function gn(r, t) {
|
|
1135
|
+
const e = t.length, n = r.map((i, s) => [...i, t[s]]);
|
|
1067
1136
|
for (let i = 0; i < e; i++) {
|
|
1068
|
-
let
|
|
1069
|
-
for (let
|
|
1070
|
-
if (Math.abs(n[
|
|
1071
|
-
[n[i], n[
|
|
1072
|
-
for (let
|
|
1073
|
-
if (
|
|
1074
|
-
const a = n[
|
|
1137
|
+
let s = i;
|
|
1138
|
+
for (let o = i + 1; o < e; o++) Math.abs(n[o][i]) > Math.abs(n[s][i]) && (s = o);
|
|
1139
|
+
if (Math.abs(n[s][i]) < 1e-12) return null;
|
|
1140
|
+
[n[i], n[s]] = [n[s], n[i]];
|
|
1141
|
+
for (let o = 0; o < e; o++) {
|
|
1142
|
+
if (o === i) continue;
|
|
1143
|
+
const a = n[o][i] / n[i][i];
|
|
1075
1144
|
if (a !== 0)
|
|
1076
|
-
for (let l = i; l <= e; l++) n[
|
|
1145
|
+
for (let l = i; l <= e; l++) n[o][l] -= a * n[i][l];
|
|
1077
1146
|
}
|
|
1078
1147
|
}
|
|
1079
|
-
return n.map((i,
|
|
1148
|
+
return n.map((i, s) => i[e] / i[s]);
|
|
1080
1149
|
}
|
|
1081
|
-
function
|
|
1150
|
+
function bn(r, t) {
|
|
1082
1151
|
if (r.length !== 4 || t.length !== 4) return null;
|
|
1083
|
-
const e = r.reduce((
|
|
1084
|
-
for (let
|
|
1085
|
-
const [d,
|
|
1086
|
-
a.push([d,
|
|
1152
|
+
const e = r.reduce((h, d) => h + d[0], 0) / 4, n = r.reduce((h, d) => h + d[1], 0) / 4, i = r.reduce((h, d) => h + Math.hypot(d[0] - e, d[1] - n), 0) / 4, s = i > 1e-12 ? Math.SQRT2 / i : 1, o = (h) => [(h[0] - e) * s, (h[1] - n) * s], a = [], l = [];
|
|
1153
|
+
for (let h = 0; h < 4; h++) {
|
|
1154
|
+
const [d, m] = o(r[h]), [f, g] = t[h];
|
|
1155
|
+
a.push([d, m, 1, 0, 0, 0, -d * f, -m * f]), l.push(f), a.push([0, 0, 0, d, m, 1, -d * g, -m * g]), l.push(g);
|
|
1087
1156
|
}
|
|
1088
|
-
const c =
|
|
1089
|
-
if (!c || c.some((
|
|
1090
|
-
const u = (
|
|
1091
|
-
return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize:
|
|
1157
|
+
const c = gn(a, l);
|
|
1158
|
+
if (!c || c.some((h) => !Number.isFinite(h))) return null;
|
|
1159
|
+
const u = (h) => [h[0] / s + e, h[1] / s + n];
|
|
1160
|
+
return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: o, denormalize: u };
|
|
1092
1161
|
}
|
|
1093
|
-
function
|
|
1162
|
+
function we(r, [t, e]) {
|
|
1094
1163
|
const n = r[6] * t + r[7] * e + r[8];
|
|
1095
1164
|
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];
|
|
1096
1165
|
}
|
|
1097
|
-
function
|
|
1098
|
-
const [t, e, n, i,
|
|
1166
|
+
function yn(r) {
|
|
1167
|
+
const [t, e, n, i, s, o, a, l, c] = r, u = t * (s * c - o * l) - e * (i * c - o * a) + n * (i * l - s * a);
|
|
1099
1168
|
return !Number.isFinite(u) || Math.abs(u) < 1e-15 ? null : [
|
|
1100
|
-
(
|
|
1169
|
+
(s * c - o * l) / u,
|
|
1101
1170
|
(n * l - e * c) / u,
|
|
1102
|
-
(e *
|
|
1103
|
-
(
|
|
1171
|
+
(e * o - n * s) / u,
|
|
1172
|
+
(o * a - i * c) / u,
|
|
1104
1173
|
(t * c - n * a) / u,
|
|
1105
|
-
(n * i - t *
|
|
1106
|
-
(i * l -
|
|
1174
|
+
(n * i - t * o) / u,
|
|
1175
|
+
(i * l - s * a) / u,
|
|
1107
1176
|
(e * a - t * l) / u,
|
|
1108
|
-
(t *
|
|
1177
|
+
(t * s - e * i) / u
|
|
1109
1178
|
];
|
|
1110
1179
|
}
|
|
1111
|
-
function
|
|
1180
|
+
function wn(r, t) {
|
|
1112
1181
|
let e = r;
|
|
1113
1182
|
for (; e - t > 180; ) e -= 360;
|
|
1114
1183
|
for (; t - e > 180; ) e += 360;
|
|
1115
1184
|
return e;
|
|
1116
1185
|
}
|
|
1117
|
-
const
|
|
1186
|
+
const rr = (r) => {
|
|
1118
1187
|
let t = ((r + 180) % 360 + 360) % 360 - 180;
|
|
1119
1188
|
return t === -180 && (t = 180), t;
|
|
1120
1189
|
};
|
|
1121
1190
|
function tt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i = !1 }) {
|
|
1122
|
-
const
|
|
1191
|
+
const s = n ?? (i ? pn : dn), o = r[0][0], a = (b) => i ? b : wn(b, o), l = (b) => i ? b : rr(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => s.forward(b)), h = [
|
|
1123
1192
|
[0, 0],
|
|
1124
1193
|
[t, 0],
|
|
1125
1194
|
[t, e],
|
|
1126
1195
|
[0, e]
|
|
1127
|
-
], d = t > 0 && e > 0 ?
|
|
1196
|
+
], d = t > 0 && e > 0 ? bn(u, h) : null, m = d ? yn(d.matrix) : null, f = !d || !m, g = (b, w = i ? 16 : 1) => {
|
|
1128
1197
|
let y = 0, A = p.unproject(0, b);
|
|
1129
1198
|
if (!A) return null;
|
|
1130
1199
|
for (let v = 1; v <= w; v++) {
|
|
1131
1200
|
const $ = p.unproject(t * v / w, b);
|
|
1132
1201
|
if (!$) return null;
|
|
1133
|
-
y +=
|
|
1202
|
+
y += on(A, $), A = $;
|
|
1134
1203
|
}
|
|
1135
1204
|
return y;
|
|
1136
1205
|
}, p = {
|
|
1137
|
-
crs:
|
|
1206
|
+
crs: s.code,
|
|
1138
1207
|
corners: c,
|
|
1139
1208
|
widthMm: t,
|
|
1140
1209
|
heightMm: e,
|
|
@@ -1142,14 +1211,14 @@ function tt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i
|
|
|
1142
1211
|
continuous: i,
|
|
1143
1212
|
project(b) {
|
|
1144
1213
|
if (!d) return null;
|
|
1145
|
-
const w =
|
|
1214
|
+
const w = s.forward([a(b[0]), b[1]]), y = we(d.matrix, d.normalize(w));
|
|
1146
1215
|
return y && Number.isFinite(y[0]) && Number.isFinite(y[1]) ? { xMm: y[0], yMm: y[1] } : null;
|
|
1147
1216
|
},
|
|
1148
1217
|
unproject(b, w) {
|
|
1149
|
-
if (!d || !
|
|
1150
|
-
const y =
|
|
1218
|
+
if (!d || !m) return null;
|
|
1219
|
+
const y = we(m, [b, w]);
|
|
1151
1220
|
if (!y) return null;
|
|
1152
|
-
const A =
|
|
1221
|
+
const A = s.inverse(d.denormalize(y));
|
|
1153
1222
|
return Number.isFinite(A[0]) && Number.isFinite(A[1]) ? [l(A[0]), A[1]] : null;
|
|
1154
1223
|
},
|
|
1155
1224
|
groundMetersPerMm() {
|
|
@@ -1190,33 +1259,33 @@ function X(r) {
|
|
|
1190
1259
|
const e = [];
|
|
1191
1260
|
for (const n of t) {
|
|
1192
1261
|
if (!Array.isArray(n) || n.length < 2) return null;
|
|
1193
|
-
const [i,
|
|
1194
|
-
if (typeof i != "number" || typeof
|
|
1195
|
-
e.push([i,
|
|
1262
|
+
const [i, s] = n;
|
|
1263
|
+
if (typeof i != "number" || typeof s != "number" || !Number.isFinite(i) || !Number.isFinite(s) || s < -90 || s > 90) return null;
|
|
1264
|
+
e.push([i, s]);
|
|
1196
1265
|
}
|
|
1197
1266
|
return e;
|
|
1198
1267
|
}
|
|
1199
|
-
function
|
|
1268
|
+
function vn(r) {
|
|
1200
1269
|
if (r.degenerate) return null;
|
|
1201
1270
|
const t = r.unproject(r.widthMm / 2, r.heightMm / 2);
|
|
1202
1271
|
if (!t) return null;
|
|
1203
|
-
const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t),
|
|
1204
|
-
if (!i || !
|
|
1205
|
-
const
|
|
1206
|
-
return Math.abs(
|
|
1272
|
+
const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t), s = r.project(n);
|
|
1273
|
+
if (!i || !s) return null;
|
|
1274
|
+
const o = s.xMm - i.xMm, a = s.yMm - i.yMm;
|
|
1275
|
+
return Math.abs(o) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(o, -a) * mn % 360 + 360) % 360;
|
|
1207
1276
|
}
|
|
1208
|
-
function
|
|
1277
|
+
function An(r) {
|
|
1209
1278
|
if (r.degenerate) return null;
|
|
1210
1279
|
const { widthMm: t, heightMm: e } = r, n = [];
|
|
1211
|
-
for (const
|
|
1212
|
-
const a = r.rowGroundMeters(e *
|
|
1280
|
+
for (const o of [0.02, 0.5, 0.98]) {
|
|
1281
|
+
const a = r.rowGroundMeters(e * o);
|
|
1213
1282
|
if (a == null || !(a > 0)) return null;
|
|
1214
1283
|
n.push(a / t);
|
|
1215
1284
|
}
|
|
1216
|
-
const i = Math.min(...n),
|
|
1217
|
-
return i > 0 ? (
|
|
1285
|
+
const i = Math.min(...n), s = Math.max(...n);
|
|
1286
|
+
return i > 0 ? (s - i) / i : null;
|
|
1218
1287
|
}
|
|
1219
|
-
function
|
|
1288
|
+
function Ri(r, t, e, n) {
|
|
1220
1289
|
return [
|
|
1221
1290
|
[r, n],
|
|
1222
1291
|
[e, n],
|
|
@@ -1224,8 +1293,8 @@ function xi(r, t, e, n) {
|
|
|
1224
1293
|
[r, t]
|
|
1225
1294
|
];
|
|
1226
1295
|
}
|
|
1227
|
-
const
|
|
1228
|
-
function
|
|
1296
|
+
const Mn = (r) => r.toLowerCase().startsWith("on");
|
|
1297
|
+
function Sn(r, t) {
|
|
1229
1298
|
const e = (n) => {
|
|
1230
1299
|
const i = n.tagName.toLowerCase();
|
|
1231
1300
|
if (i === "script") {
|
|
@@ -1234,29 +1303,29 @@ function gn(r, t) {
|
|
|
1234
1303
|
return a.setAttribute("type", "application/json"), a.textContent = n.textContent, a;
|
|
1235
1304
|
}
|
|
1236
1305
|
if (i === "style" || i === "link" || i === "iframe" || i === "object" || i === "embed") return null;
|
|
1237
|
-
const
|
|
1238
|
-
for (const
|
|
1239
|
-
|
|
1240
|
-
for (const
|
|
1241
|
-
if (
|
|
1242
|
-
else if (
|
|
1243
|
-
const a = e(
|
|
1244
|
-
a &&
|
|
1306
|
+
const s = t.createElement(i);
|
|
1307
|
+
for (const o of n.attributes)
|
|
1308
|
+
Mn(o.name) || /^\s*javascript:/i.test(o.value) || s.setAttribute(o.name, o.value);
|
|
1309
|
+
for (const o of n.childNodes)
|
|
1310
|
+
if (o.nodeType === 3) s.appendChild(t.createTextNode(o.textContent ?? ""));
|
|
1311
|
+
else if (o.nodeType === 1) {
|
|
1312
|
+
const a = e(o);
|
|
1313
|
+
a && s.appendChild(a);
|
|
1245
1314
|
}
|
|
1246
|
-
return
|
|
1315
|
+
return s;
|
|
1247
1316
|
};
|
|
1248
1317
|
return e(r);
|
|
1249
1318
|
}
|
|
1250
|
-
async function
|
|
1319
|
+
async function Cn(r, t = document) {
|
|
1251
1320
|
const e = await fetch(r, { credentials: "same-origin", cache: "no-store" });
|
|
1252
1321
|
if (!e.ok) throw new Error(`fetching ${r} failed with HTTP ${e.status}`);
|
|
1253
|
-
const n = await e.text(),
|
|
1254
|
-
if (!
|
|
1255
|
-
const
|
|
1256
|
-
if (!
|
|
1257
|
-
return
|
|
1322
|
+
const n = await e.text(), s = new DOMParser().parseFromString(n, "text/html").querySelector("om-map");
|
|
1323
|
+
if (!s) throw new Error(`${r} contains no <om-map>`);
|
|
1324
|
+
const o = Sn(s, t);
|
|
1325
|
+
if (!o) throw new Error(`${r} could not be adopted`);
|
|
1326
|
+
return o;
|
|
1258
1327
|
}
|
|
1259
|
-
function
|
|
1328
|
+
function mt(r) {
|
|
1260
1329
|
const t = r.getAttribute("center"), e = r.getAttribute("zoom");
|
|
1261
1330
|
if (!t || e == null || e.trim() === "") return null;
|
|
1262
1331
|
const n = Number(e);
|
|
@@ -1269,26 +1338,26 @@ function ut(r) {
|
|
|
1269
1338
|
i = a.length === 2 ? a : null;
|
|
1270
1339
|
}
|
|
1271
1340
|
if (!Array.isArray(i) || i.length < 2) return null;
|
|
1272
|
-
const [
|
|
1273
|
-
return !Number.isFinite(
|
|
1274
|
-
center: [
|
|
1341
|
+
const [s, o] = i;
|
|
1342
|
+
return !Number.isFinite(s) || !Number.isFinite(o) ? null : {
|
|
1343
|
+
center: [s, o],
|
|
1275
1344
|
zoom: n,
|
|
1276
1345
|
bearing: Number(r.getAttribute("bearing")) || 0,
|
|
1277
1346
|
pitch: Number(r.getAttribute("pitch")) || 0
|
|
1278
1347
|
};
|
|
1279
1348
|
}
|
|
1280
|
-
function
|
|
1281
|
-
const
|
|
1282
|
-
if (
|
|
1283
|
-
if (!
|
|
1284
|
-
let
|
|
1285
|
-
for (; a -
|
|
1286
|
-
const l = Math.floor((
|
|
1287
|
-
|
|
1349
|
+
function Ii(r, t, e, n, i = 60) {
|
|
1350
|
+
const s = (l) => Ut(r, { ...t, pitch: l }, e, n) !== null;
|
|
1351
|
+
if (s(i)) return i;
|
|
1352
|
+
if (!s(0)) return 0;
|
|
1353
|
+
let o = 0, a = i;
|
|
1354
|
+
for (; a - o > 1; ) {
|
|
1355
|
+
const l = Math.floor((o + a) / 2);
|
|
1356
|
+
s(l) ? o = l : a = l;
|
|
1288
1357
|
}
|
|
1289
|
-
return
|
|
1358
|
+
return o;
|
|
1290
1359
|
}
|
|
1291
|
-
function
|
|
1360
|
+
function Ut(r, t, e, n) {
|
|
1292
1361
|
if (!(e > 0) || !(n > 0)) return null;
|
|
1293
1362
|
const i = new r.WebMercatorViewport({
|
|
1294
1363
|
width: e,
|
|
@@ -1298,61 +1367,61 @@ function Ft(r, t, e, n) {
|
|
|
1298
1367
|
zoom: t.zoom,
|
|
1299
1368
|
bearing: t.bearing,
|
|
1300
1369
|
pitch: t.pitch
|
|
1301
|
-
}),
|
|
1370
|
+
}), s = [
|
|
1302
1371
|
[0, 0],
|
|
1303
1372
|
[e, 0],
|
|
1304
1373
|
[e, n],
|
|
1305
1374
|
[0, n]
|
|
1306
|
-
],
|
|
1307
|
-
for (const a of
|
|
1375
|
+
], o = [];
|
|
1376
|
+
for (const a of s) {
|
|
1308
1377
|
const l = i.unproject(a);
|
|
1309
1378
|
if (!l || !Number.isFinite(l[0]) || !Number.isFinite(l[1])) return null;
|
|
1310
|
-
|
|
1379
|
+
o.push([l[0], l[1]]);
|
|
1311
1380
|
}
|
|
1312
|
-
return
|
|
1381
|
+
return o;
|
|
1313
1382
|
}
|
|
1314
|
-
async function
|
|
1315
|
-
const e = await
|
|
1383
|
+
async function xn(r, t) {
|
|
1384
|
+
const e = await Ie();
|
|
1316
1385
|
if (t && typeof t != "string") return { core: e, map: t };
|
|
1317
1386
|
if (!t) throw new Error("a live frame needs src= or an inline <om-map> child");
|
|
1318
|
-
const n = await
|
|
1387
|
+
const n = await Cn(t, r.ownerDocument);
|
|
1319
1388
|
return { core: e, map: n };
|
|
1320
1389
|
}
|
|
1321
|
-
function
|
|
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)),
|
|
1390
|
+
function xt(r, t) {
|
|
1391
|
+
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)), kn(r, t);
|
|
1323
1392
|
}
|
|
1324
|
-
function
|
|
1393
|
+
function kn(r, t) {
|
|
1325
1394
|
const e = r;
|
|
1326
1395
|
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 });
|
|
1327
1396
|
}
|
|
1328
|
-
const
|
|
1329
|
-
function
|
|
1397
|
+
const $n = [".png", ".jpg", ".jpeg", ".webp", ".avif", ".gif", ".svg"], En = [".html", ".htm"];
|
|
1398
|
+
function Dt(r) {
|
|
1330
1399
|
const t = r.trim().split(/[?#]/, 1)[0]?.toLowerCase() ?? "";
|
|
1331
|
-
return
|
|
1400
|
+
return En.some((e) => t.endsWith(e)) ? "map" : $n.some((e) => t.endsWith(e)) ? "raster" : null;
|
|
1332
1401
|
}
|
|
1333
|
-
function
|
|
1402
|
+
function Nn(r, t) {
|
|
1334
1403
|
const e = [], n = [...r.children].find(
|
|
1335
|
-
(
|
|
1404
|
+
(o) => o.tagName.toLowerCase() === "om-map" && o !== t
|
|
1336
1405
|
);
|
|
1337
1406
|
n && e.push({ kind: "inline", key: "inline", el: r, map: n });
|
|
1338
1407
|
const i = r.getAttribute("src")?.trim();
|
|
1339
|
-
i && e.push({ kind:
|
|
1340
|
-
let
|
|
1341
|
-
for (const
|
|
1342
|
-
if (
|
|
1343
|
-
const a =
|
|
1344
|
-
a && e.push({ kind:
|
|
1408
|
+
i && e.push({ kind: Dt(i) ?? "map", key: `src:${i}`, el: r, src: i });
|
|
1409
|
+
let s = 0;
|
|
1410
|
+
for (const o of r.children) {
|
|
1411
|
+
if (o.tagName.toLowerCase() !== "om-source") continue;
|
|
1412
|
+
const a = o.getAttribute("src")?.trim();
|
|
1413
|
+
a && e.push({ kind: Dt(a) ?? "map", key: `source:${s++}:${a}`, el: o, src: a });
|
|
1345
1414
|
}
|
|
1346
1415
|
return e;
|
|
1347
1416
|
}
|
|
1348
|
-
function
|
|
1417
|
+
function Pn(r) {
|
|
1349
1418
|
return r.map((t) => t.key).join("|");
|
|
1350
1419
|
}
|
|
1351
|
-
async function
|
|
1352
|
-
const n = Math.max(1, Math.round(t.w * e)), i = Math.max(1, Math.round(t.h * e)),
|
|
1353
|
-
|
|
1354
|
-
const
|
|
1355
|
-
a.decoding = "sync", a.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
|
|
1420
|
+
async function Tn(r, t, e) {
|
|
1421
|
+
const n = Math.max(1, Math.round(t.w * e)), i = Math.max(1, Math.round(t.h * e)), s = r.cloneNode(!0);
|
|
1422
|
+
s.removeAttribute("style"), s.setAttribute("width", String(n)), s.setAttribute("height", String(i)), s.setAttribute("preserveAspectRatio", "none");
|
|
1423
|
+
const o = new XMLSerializer().serializeToString(s), a = new Image();
|
|
1424
|
+
a.decoding = "sync", a.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`;
|
|
1356
1425
|
try {
|
|
1357
1426
|
await a.decode();
|
|
1358
1427
|
} catch {
|
|
@@ -1360,8 +1429,8 @@ async function Cn(r, t, e) {
|
|
|
1360
1429
|
}
|
|
1361
1430
|
return a;
|
|
1362
1431
|
}
|
|
1363
|
-
const
|
|
1364
|
-
class
|
|
1432
|
+
const kt = "data-om-carto-placeholder", ve = "data-om-carto-source", $t = "data-om-carto-capture", Et = "data-om-carto-overview", Ae = "http://www.w3.org/2000/svg", Me = 24, Se = 0.25;
|
|
1433
|
+
class nr extends O {
|
|
1365
1434
|
static observedAttributes = [...T["om-frame"]];
|
|
1366
1435
|
/** Resolved non-builtin CRS planes, so a re-render does not re-await proj4. */
|
|
1367
1436
|
resolvedForward = null;
|
|
@@ -1451,9 +1520,9 @@ class Qe extends O {
|
|
|
1451
1520
|
}
|
|
1452
1521
|
const n = this.georefHost, i = X(n.getAttribute("corners"));
|
|
1453
1522
|
if (!i) return null;
|
|
1454
|
-
const
|
|
1455
|
-
let a =
|
|
1456
|
-
return !a && this.resolvedForwardKey === `${
|
|
1523
|
+
const s = Ot(n.getAttribute("crs")) ?? "EPSG:3857", o = n.getAttribute("crs-def");
|
|
1524
|
+
let a = o ? null : Y(s);
|
|
1525
|
+
return !a && this.resolvedForwardKey === `${s}|${o ?? ""}` && (a = this.resolvedForward), a ? tt({ corners: i, widthMm: t, heightMm: e, crsForward: a }) : null;
|
|
1457
1526
|
}
|
|
1458
1527
|
/**
|
|
1459
1528
|
* Resolve a live map's CRS through the core's lazy proj4, into the same
|
|
@@ -1466,7 +1535,7 @@ class Qe extends O {
|
|
|
1466
1535
|
if (this.resolvedForwardKey === e || this.pendingLiveCrs === e) return;
|
|
1467
1536
|
this.pendingLiveCrs = e;
|
|
1468
1537
|
const n = ++this.resolveToken;
|
|
1469
|
-
|
|
1538
|
+
_t(t, null).then((i) => {
|
|
1470
1539
|
if (n === this.resolveToken) {
|
|
1471
1540
|
if (this.pendingLiveCrs = null, !i) {
|
|
1472
1541
|
this.showPlaceholder("unknown-crs", `The map in this frame is projected to "${t}", which could not be resolved.`);
|
|
@@ -1492,7 +1561,7 @@ class Qe extends O {
|
|
|
1492
1561
|
* showing its own overview polygon instead of the map.
|
|
1493
1562
|
*/
|
|
1494
1563
|
get vector() {
|
|
1495
|
-
return this.querySelector(`:scope > svg[${
|
|
1564
|
+
return this.querySelector(`:scope > svg[${Lt}]`);
|
|
1496
1565
|
}
|
|
1497
1566
|
/** What a static frame actually shows — vector first, because a frozen sheet that has both was frozen twice and the newer one is the vector. */
|
|
1498
1567
|
get staticSource() {
|
|
@@ -1513,7 +1582,7 @@ class Qe extends O {
|
|
|
1513
1582
|
renderNow() {
|
|
1514
1583
|
this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden", this.style.boxSizing = "border-box";
|
|
1515
1584
|
const t = this.getAttribute("frame-stroke");
|
|
1516
|
-
this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${
|
|
1585
|
+
this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${Se}mm ${t || "var(--om-carto-frame-stroke)"}`;
|
|
1517
1586
|
const e = this.getAttribute("frame-bg");
|
|
1518
1587
|
this.style.background = e || "var(--om-carto-frame-bg)", this.mode === "static" ? (this.suspendLiveMode(), this.renderStatic()) : this.renderLive(), this.renderOverview();
|
|
1519
1588
|
}
|
|
@@ -1528,16 +1597,16 @@ class Qe extends O {
|
|
|
1528
1597
|
}
|
|
1529
1598
|
const e = t.style;
|
|
1530
1599
|
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";
|
|
1531
|
-
const n =
|
|
1532
|
-
if ((i != null || Y(n) == null) && this.resolvedForwardKey !==
|
|
1600
|
+
const n = Ot(this.getAttribute("crs")) ?? "EPSG:3857", i = this.getAttribute("crs-def"), s = `${n}|${i ?? ""}`;
|
|
1601
|
+
if ((i != null || Y(n) == null) && this.resolvedForwardKey !== s) {
|
|
1533
1602
|
const a = ++this.resolveToken;
|
|
1534
|
-
this.resolvedForward = null, this.resolvedForwardKey = null,
|
|
1603
|
+
this.resolvedForward = null, this.resolvedForwardKey = null, _t(n, i).then((l) => {
|
|
1535
1604
|
if (a === this.resolveToken) {
|
|
1536
1605
|
if (!l) {
|
|
1537
1606
|
this.showPlaceholder("unknown-crs", `Unknown CRS "${n}" — supply crs-def="+proj=…".`);
|
|
1538
1607
|
return;
|
|
1539
1608
|
}
|
|
1540
|
-
this.resolvedForward = l, this.resolvedForwardKey =
|
|
1609
|
+
this.resolvedForward = l, this.resolvedForwardKey = s, this.scheduleRender();
|
|
1541
1610
|
}
|
|
1542
1611
|
}).catch(() => {
|
|
1543
1612
|
a === this.resolveToken && this.showPlaceholder("unknown-crs", `Could not resolve CRS "${n}".`);
|
|
@@ -1558,21 +1627,21 @@ class Qe extends O {
|
|
|
1558
1627
|
c.tagName.toLowerCase() === "om-map" && c.setAttribute("data-om-carto-frame", "");
|
|
1559
1628
|
const t = this.staticSource;
|
|
1560
1629
|
t && (t.style.display = "none");
|
|
1561
|
-
const e =
|
|
1630
|
+
const e = mt(this);
|
|
1562
1631
|
if (!e) {
|
|
1563
1632
|
this.showPlaceholder("no-camera", 'Live frame needs its own camera — center="[lng, lat]" and zoom=.');
|
|
1564
1633
|
return;
|
|
1565
1634
|
}
|
|
1566
1635
|
const n = JSON.stringify(e), i = n !== this.appliedCameraKey;
|
|
1567
1636
|
this.appliedCameraKey = n, this.updateLiveCorners(i ? e : this.liveCamera() ?? e);
|
|
1568
|
-
const
|
|
1569
|
-
if (
|
|
1637
|
+
const s = this.sources();
|
|
1638
|
+
if (s.length === 0) {
|
|
1570
1639
|
this.showPlaceholder("no-source", "Live frame needs src=, an <om-source> child, or an inline <om-map>.");
|
|
1571
1640
|
return;
|
|
1572
1641
|
}
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
const a = Math.min(this.sourceCursor,
|
|
1642
|
+
const o = Pn(s);
|
|
1643
|
+
o !== this.knownSourceList && (this.knownSourceList = o, this.sourceCursor = 0, this.settledSource = null, this.removeAttribute(ve));
|
|
1644
|
+
const a = Math.min(this.sourceCursor, s.length - 1), l = s[a];
|
|
1576
1645
|
if (l.kind === "raster") {
|
|
1577
1646
|
this.suspendLiveMode(), this.renderCaptureSource(l, a);
|
|
1578
1647
|
return;
|
|
@@ -1581,14 +1650,14 @@ class Qe extends O {
|
|
|
1581
1650
|
if (this.mountedSource !== l.key)
|
|
1582
1651
|
this.releaseLiveMap();
|
|
1583
1652
|
else {
|
|
1584
|
-
|
|
1653
|
+
xt(this.liveMap, e), this.sizeLiveMap();
|
|
1585
1654
|
return;
|
|
1586
1655
|
}
|
|
1587
1656
|
if (this.mounting) {
|
|
1588
1657
|
if (this.mountingSource === l.key) return;
|
|
1589
1658
|
this.abandonMount();
|
|
1590
1659
|
}
|
|
1591
|
-
this.mountLive(l, a,
|
|
1660
|
+
this.mountLive(l, a, s);
|
|
1592
1661
|
}
|
|
1593
1662
|
/**
|
|
1594
1663
|
* Draw a CAPTURE source — a georeferenced picture, placed exactly like a
|
|
@@ -1598,8 +1667,8 @@ class Qe extends O {
|
|
|
1598
1667
|
*/
|
|
1599
1668
|
renderCaptureSource(t, e) {
|
|
1600
1669
|
const n = t.src ?? "";
|
|
1601
|
-
let i = this.querySelector(`:scope > img[${
|
|
1602
|
-
if (i || (i = document.createElement("img"), i.setAttribute(
|
|
1670
|
+
let i = this.querySelector(`:scope > img[${$t}]`);
|
|
1671
|
+
if (i || (i = document.createElement("img"), i.setAttribute($t, ""), 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"))) {
|
|
1603
1672
|
this.showPlaceholder("bad-corners", 'A capture <om-source> needs corners="[[lng,lat] × 4]" (tl, tr, br, bl).');
|
|
1604
1673
|
return;
|
|
1605
1674
|
}
|
|
@@ -1611,7 +1680,7 @@ class Qe extends O {
|
|
|
1611
1680
|
}
|
|
1612
1681
|
/** A capture left over from an earlier source must not sit under a live map. */
|
|
1613
1682
|
hideCaptureImage() {
|
|
1614
|
-
const t = this.querySelector(`:scope > img[${
|
|
1683
|
+
const t = this.querySelector(`:scope > img[${$t}]`);
|
|
1615
1684
|
t && (t.style.display = "none");
|
|
1616
1685
|
}
|
|
1617
1686
|
/**
|
|
@@ -1620,7 +1689,7 @@ class Qe extends O {
|
|
|
1620
1689
|
* inline source on the next render.
|
|
1621
1690
|
*/
|
|
1622
1691
|
sources() {
|
|
1623
|
-
return
|
|
1692
|
+
return Nn(this, this.liveMapOwned ? this.liveMap : null);
|
|
1624
1693
|
}
|
|
1625
1694
|
/**
|
|
1626
1695
|
* Move to the next source, or report that there is none.
|
|
@@ -1645,7 +1714,7 @@ class Qe extends O {
|
|
|
1645
1714
|
*/
|
|
1646
1715
|
settleSource(t, e) {
|
|
1647
1716
|
if (this.settledSource?.key === t.key) return;
|
|
1648
|
-
this.settledSource = t, this.sourceCursor = e, this.setAttribute(
|
|
1717
|
+
this.settledSource = t, this.sourceCursor = e, this.setAttribute(ve, String(e));
|
|
1649
1718
|
const n = { id: this.id, index: e, kind: t.kind, src: t.src ?? null };
|
|
1650
1719
|
this.dispatchEvent(new CustomEvent("om-frame-source", { bubbles: !0, detail: n })), this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } }));
|
|
1651
1720
|
}
|
|
@@ -1687,38 +1756,38 @@ class Qe extends O {
|
|
|
1687
1756
|
const e = `${Number(t.toFixed(6))}m`;
|
|
1688
1757
|
this.liveMap.getAttribute("reference-scale") !== e && this.liveMap.setAttribute("reference-scale", e);
|
|
1689
1758
|
}
|
|
1690
|
-
updateLiveCorners(t =
|
|
1759
|
+
updateLiveCorners(t = mt(this)) {
|
|
1691
1760
|
if (!t) return;
|
|
1692
1761
|
const e = J();
|
|
1693
1762
|
if (!e) return;
|
|
1694
|
-
const { w: n, h: i } = S(this),
|
|
1695
|
-
this.liveCorners =
|
|
1763
|
+
const { w: n, h: i } = S(this), o = this.liveMap?.groundCorners?.(n * D, i * D) ?? Ut(e, t, n * D, i * D), a = JSON.stringify(o) !== JSON.stringify(this.liveCorners);
|
|
1764
|
+
this.liveCorners = o, a && this.liveMap && this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } })), this.applyReferenceScale(), o ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder("degenerate-view", "This frame's box cannot be georeferenced — give it a positive width and height.");
|
|
1696
1765
|
}
|
|
1697
1766
|
async mountLive(t, e, n) {
|
|
1698
1767
|
const i = ++this.mountToken;
|
|
1699
1768
|
this.mounting = !0, this.mountingSource = t.key;
|
|
1700
|
-
let
|
|
1769
|
+
let s = !1;
|
|
1701
1770
|
try {
|
|
1702
|
-
const { core:
|
|
1771
|
+
const { core: o, map: a } = await xn(this, t.map ?? t.src);
|
|
1703
1772
|
if (i !== this.mountToken || !this.isConnected || this.mode !== "live") return;
|
|
1704
|
-
const l =
|
|
1773
|
+
const l = mt(this);
|
|
1705
1774
|
if (!l) return;
|
|
1706
|
-
this.appliedCameraKey = JSON.stringify(l),
|
|
1775
|
+
this.appliedCameraKey = JSON.stringify(l), xt(a, l);
|
|
1707
1776
|
const c = a;
|
|
1708
1777
|
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();
|
|
1709
|
-
const { w: u, h
|
|
1710
|
-
if (this.liveCorners =
|
|
1778
|
+
const { w: u, h } = S(this);
|
|
1779
|
+
if (this.liveCorners = Ut(o, l, u * D, h * D), this.applyReferenceScale(), await c.ready, i !== this.mountToken || (xt(a, l), await c.whenSettled?.({ timeout: 2e4 }), i !== this.mountToken)) return;
|
|
1711
1780
|
if (c.hasDrawableContent?.() === !1) {
|
|
1712
1781
|
if (this.advanceSource(n)) return;
|
|
1713
1782
|
console.warn(
|
|
1714
1783
|
`[onlymapjs] <om-frame id="${this.id}"> source ${e} (${t.src ?? "inline"}) drew nothing, and it is the last source.`
|
|
1715
1784
|
);
|
|
1716
1785
|
}
|
|
1717
|
-
|
|
1718
|
-
} catch (
|
|
1786
|
+
s = !0, this.settleSource(t, e), this.signalReady();
|
|
1787
|
+
} catch (o) {
|
|
1719
1788
|
if (i !== this.mountToken) return;
|
|
1720
|
-
const a =
|
|
1721
|
-
if (
|
|
1789
|
+
const a = o.message ?? String(o);
|
|
1790
|
+
if (s) {
|
|
1722
1791
|
console.error(`[onlymapjs] <om-frame id="${this.id}"> rendered, then failed while reporting it: ${a}`);
|
|
1723
1792
|
return;
|
|
1724
1793
|
}
|
|
@@ -1750,34 +1819,34 @@ class Qe extends O {
|
|
|
1750
1819
|
* segments would visibly cut the corners on a wide-extent inset.
|
|
1751
1820
|
*/
|
|
1752
1821
|
renderOverview() {
|
|
1753
|
-
const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${
|
|
1822
|
+
const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${Et}]`);
|
|
1754
1823
|
if (!t) {
|
|
1755
1824
|
e?.remove();
|
|
1756
1825
|
return;
|
|
1757
1826
|
}
|
|
1758
|
-
const n =
|
|
1759
|
-
if (!n || !i || !
|
|
1827
|
+
const n = Ye(this, t), i = this.georef, s = n?.georef;
|
|
1828
|
+
if (!n || !i || !s) {
|
|
1760
1829
|
e?.remove();
|
|
1761
1830
|
return;
|
|
1762
1831
|
}
|
|
1763
|
-
const { w:
|
|
1832
|
+
const { w: o, h: a } = S(this), l = [], [c, u, h, d] = s.corners, m = [
|
|
1764
1833
|
[c, u],
|
|
1765
|
-
[u,
|
|
1766
|
-
[
|
|
1834
|
+
[u, h],
|
|
1835
|
+
[h, d],
|
|
1767
1836
|
[d, c]
|
|
1768
1837
|
];
|
|
1769
|
-
for (const [b, w] of
|
|
1770
|
-
for (let y = 0; y <
|
|
1771
|
-
const A = y /
|
|
1838
|
+
for (const [b, w] of m)
|
|
1839
|
+
for (let y = 0; y < Me; y++) {
|
|
1840
|
+
const A = y / Me, v = [b[0] + (w[0] - b[0]) * A, b[1] + (w[1] - b[1]) * A], $ = i.project(v);
|
|
1772
1841
|
$ && l.push(`${$.xMm.toFixed(3)},${$.yMm.toFixed(3)}`);
|
|
1773
1842
|
}
|
|
1774
1843
|
if (l.length < 3) {
|
|
1775
1844
|
e?.remove();
|
|
1776
1845
|
return;
|
|
1777
1846
|
}
|
|
1778
|
-
const f = this.ownerDocument, g = e ?? f.createElementNS(
|
|
1779
|
-
g.setAttribute(
|
|
1780
|
-
const p = f.createElementNS(
|
|
1847
|
+
const f = this.ownerDocument, g = e ?? f.createElementNS(Ae, "svg");
|
|
1848
|
+
g.setAttribute(Et, ""), g.setAttribute("width", `${o}mm`), g.setAttribute("height", `${a}mm`), g.setAttribute("viewBox", `0 0 ${o} ${a}`), g.style.cssText = "position:absolute;inset:0;pointer-events:none;", g.replaceChildren();
|
|
1849
|
+
const p = f.createElementNS(Ae, "polygon");
|
|
1781
1850
|
p.setAttribute("points", l.join(" ")), p.setAttribute("fill", "none"), p.setAttribute("stroke", this.getAttribute("overview-stroke") || "#e63946"), p.setAttribute("stroke-width", "0.4"), g.appendChild(p), e || this.appendChild(g);
|
|
1782
1851
|
}
|
|
1783
1852
|
// -------------------------------------------------------------------------
|
|
@@ -1801,11 +1870,11 @@ class Qe extends O {
|
|
|
1801
1870
|
* the worst outcome — it looks like a design choice.
|
|
1802
1871
|
*/
|
|
1803
1872
|
showPlaceholder(t, e) {
|
|
1804
|
-
let n = this.querySelector(`:scope > [${
|
|
1805
|
-
n || (n = document.createElement("div"), n.setAttribute(
|
|
1873
|
+
let n = this.querySelector(`:scope > [${kt}]`);
|
|
1874
|
+
n || (n = document.createElement("div"), n.setAttribute(kt, ""), n.style.cssText = "position:absolute;inset:0;display:grid;place-content:center;padding:4mm;text-align:center;font:italic 3mm/1.4 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.75;", this.appendChild(n)), n.textContent !== e && (n.textContent = e), this.lastError !== t && (this.lastError = t, this.settleReady(), this.dispatchEvent(new CustomEvent("om-frame-error", { bubbles: !0, detail: { id: this.id, reason: t, message: e } })));
|
|
1806
1875
|
}
|
|
1807
1876
|
clearPlaceholder() {
|
|
1808
|
-
this.querySelector(`:scope > [${
|
|
1877
|
+
this.querySelector(`:scope > [${kt}]`)?.remove(), this.lastError = null;
|
|
1809
1878
|
}
|
|
1810
1879
|
// -------------------------------------------------------------------------
|
|
1811
1880
|
// Capture, export and print
|
|
@@ -1846,18 +1915,30 @@ class Qe extends O {
|
|
|
1846
1915
|
if (this.mode !== "live" || !this.liveMap) return !1;
|
|
1847
1916
|
const n = this.georef?.corners;
|
|
1848
1917
|
if (!n) return !1;
|
|
1849
|
-
const i = t.format ?? "svg",
|
|
1918
|
+
const i = t.format ?? "svg", s = this.liveMap.projectedCrs?.() ?? null;
|
|
1850
1919
|
if (i === "svg") {
|
|
1851
|
-
const
|
|
1852
|
-
if (
|
|
1853
|
-
const
|
|
1854
|
-
|
|
1920
|
+
const a = await this.liveMap.snapshot({ format: "svg", effectDpi: t.effectDpi }), c = new DOMParser().parseFromString(a, "image/svg+xml").documentElement;
|
|
1921
|
+
if (c.nodeName !== "svg") return !1;
|
|
1922
|
+
const u = document.importNode(c, !0);
|
|
1923
|
+
u.setAttribute(Lt, ""), this.vector?.remove(), this.raster?.remove(), this.appendChild(u);
|
|
1855
1924
|
} else {
|
|
1856
|
-
const
|
|
1857
|
-
if (!
|
|
1858
|
-
this.vector?.remove(), this.raster?.remove(), this.appendChild(
|
|
1925
|
+
const a = await this.captureAt(t.scale ?? 3.125);
|
|
1926
|
+
if (!a) return !1;
|
|
1927
|
+
this.vector?.remove(), this.raster?.remove(), this.appendChild(a);
|
|
1859
1928
|
}
|
|
1860
|
-
|
|
1929
|
+
this.setAttribute("corners", JSON.stringify(n.map(([a, l]) => [Number(a.toFixed(8)), Number(l.toFixed(8))]))), s && s !== "EPSG:3857" ? this.setAttribute("crs", s) : this.removeAttribute("crs");
|
|
1930
|
+
const o = this.liveMap?.attributions?.() ?? [];
|
|
1931
|
+
return o.length > 0 ? this.setAttribute("attribution", o.join(Kt)) : this.removeAttribute("attribution"), this.setAttribute("mode", "static"), this.scheduleRender(), this.dispatchEvent(new CustomEvent("om-attributions-changed", { bubbles: !0 })), !0;
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* The basemap attribution this frame owes the sheet, as text.
|
|
1935
|
+
*
|
|
1936
|
+
* A live frame asks its map. A static one reads `attribution`, which
|
|
1937
|
+
* `freeze()` writes and an author may write by hand for a placed raster —
|
|
1938
|
+
* the only source a page without the runtime has.
|
|
1939
|
+
*/
|
|
1940
|
+
attributions() {
|
|
1941
|
+
return this.mode === "live" ? this.liveMap?.attributions?.() ?? [] : _r(this.getAttribute("attribution"));
|
|
1861
1942
|
}
|
|
1862
1943
|
/**
|
|
1863
1944
|
* Point this frame's camera at a lon/lat box — the atlas's per-page refit.
|
|
@@ -1867,13 +1948,13 @@ class Qe extends O {
|
|
|
1867
1948
|
* follows from the same source as any authored camera.
|
|
1868
1949
|
*/
|
|
1869
1950
|
fitBounds(t) {
|
|
1870
|
-
const [e, n, i,
|
|
1871
|
-
if (
|
|
1951
|
+
const [e, n, i, s] = t, { w: o, h: a } = S(this);
|
|
1952
|
+
if (o <= 0 || a <= 0) return;
|
|
1872
1953
|
const l = J();
|
|
1873
1954
|
if (!l) return;
|
|
1874
|
-
const c = new l.WebMercatorViewport({ width:
|
|
1955
|
+
const c = new l.WebMercatorViewport({ width: o * D, height: a * D, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
|
|
1875
1956
|
[e, n],
|
|
1876
|
-
[i,
|
|
1957
|
+
[i, s]
|
|
1877
1958
|
]);
|
|
1878
1959
|
[c.longitude, c.latitude, c.zoom].every(Number.isFinite) && (this.setAttribute("center", JSON.stringify([Number(c.longitude.toFixed(8)), Number(c.latitude.toFixed(8))])), this.setAttribute("zoom", String(Number(c.zoom.toFixed(4)))), this.updateLiveCorners());
|
|
1879
1960
|
}
|
|
@@ -1894,7 +1975,7 @@ class Qe extends O {
|
|
|
1894
1975
|
return;
|
|
1895
1976
|
}
|
|
1896
1977
|
const e = this.vector;
|
|
1897
|
-
e && (this.captureImage = await
|
|
1978
|
+
e && (this.captureImage = await Tn(e, S(this), t.pxPerMm));
|
|
1898
1979
|
}
|
|
1899
1980
|
/** Export hook: forget the capture, so a failed pre-pass never reuses it. */
|
|
1900
1981
|
discardCartograph() {
|
|
@@ -1915,46 +1996,46 @@ class Qe extends O {
|
|
|
1915
1996
|
this.printing = !1, this.querySelector(":scope > img[data-om-carto-print]")?.remove(), this.liveMap && (this.liveMap.hidden = !1);
|
|
1916
1997
|
}
|
|
1917
1998
|
paintCartograph(t, e) {
|
|
1918
|
-
const { w: n, h: i } = S(this),
|
|
1919
|
-
if (
|
|
1920
|
-
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l =
|
|
1921
|
-
l && (t.fillStyle = l, t.fillRect(0, 0,
|
|
1999
|
+
const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
|
|
2000
|
+
if (s <= 0 || o <= 0) return;
|
|
2001
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = I(a?.backgroundColor);
|
|
2002
|
+
l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
|
|
1922
2003
|
const c = this.mode === "static" ? this.vector ? this.captureImage : this.raster : this.captureImage;
|
|
1923
|
-
c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0,
|
|
1924
|
-
const u = this.getAttribute("frame-stroke") ||
|
|
1925
|
-
|
|
2004
|
+
c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, s, o), this.paintOverview(t, e);
|
|
2005
|
+
const u = this.getAttribute("frame-stroke") || I(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = Se * e.pxPerMm;
|
|
2006
|
+
h > 0 && (t.strokeStyle = u, t.lineWidth = h, t.strokeRect(h / 2, h / 2, s - h, o - h));
|
|
1926
2007
|
}
|
|
1927
2008
|
paintOverview(t, e) {
|
|
1928
|
-
const n = this.querySelector(`:scope > [${
|
|
1929
|
-
i && (t.save(), t.strokeStyle = n.getAttribute("stroke") || "#e63946", t.lineWidth = Number(n.getAttribute("stroke-width") || 0.4) * e.pxPerMm, t.beginPath(), i.split(/\s+/).forEach((
|
|
1930
|
-
const [a, l] =
|
|
1931
|
-
!Number.isFinite(a) || !Number.isFinite(l) || (
|
|
2009
|
+
const n = this.querySelector(`:scope > [${Et}] polygon`), i = n?.getAttribute("points");
|
|
2010
|
+
i && (t.save(), t.strokeStyle = n.getAttribute("stroke") || "#e63946", t.lineWidth = Number(n.getAttribute("stroke-width") || 0.4) * e.pxPerMm, t.beginPath(), i.split(/\s+/).forEach((s, o) => {
|
|
2011
|
+
const [a, l] = s.split(",").map(Number);
|
|
2012
|
+
!Number.isFinite(a) || !Number.isFinite(l) || (o === 0 ? t.moveTo(a * e.pxPerMm, l * e.pxPerMm) : t.lineTo(a * e.pxPerMm, l * e.pxPerMm));
|
|
1932
2013
|
}), t.closePath(), t.stroke(), t.restore());
|
|
1933
2014
|
}
|
|
1934
2015
|
}
|
|
1935
|
-
|
|
1936
|
-
const
|
|
1937
|
-
class
|
|
2016
|
+
x("om-frame", nr);
|
|
2017
|
+
const at = "http://www.w3.org/2000/svg", Ln = ["single", "double", "line", "ticks"];
|
|
2018
|
+
class ir extends O {
|
|
1938
2019
|
static observedAttributes = [...T["om-scalebar"]];
|
|
1939
2020
|
/** The geometry currently drawn — reused by the canvas exporter. */
|
|
1940
2021
|
get drawing() {
|
|
1941
2022
|
const e = U(this)?.georef;
|
|
1942
2023
|
if (!e) return null;
|
|
1943
|
-
const { w: n, h: i } = S(this),
|
|
2024
|
+
const { w: n, h: i } = S(this), s = Be({
|
|
1944
2025
|
groundMetersPerMm: e.groundMetersPerMm(),
|
|
1945
2026
|
maxWidthMm: n,
|
|
1946
2027
|
segments: Number(this.getAttribute("segments")) || void 0,
|
|
1947
2028
|
units: this.unitSystem,
|
|
1948
2029
|
segmentLengthMeters: this.getAttribute("segment-length") ? Number(this.getAttribute("segment-length")) : null
|
|
1949
2030
|
});
|
|
1950
|
-
return
|
|
2031
|
+
return s ? Wr(s, this.barStyle, i) : null;
|
|
1951
2032
|
}
|
|
1952
2033
|
get barStyle() {
|
|
1953
2034
|
const t = this.getAttribute("kind");
|
|
1954
|
-
return
|
|
2035
|
+
return Ln.includes(t) ? t : "single";
|
|
1955
2036
|
}
|
|
1956
2037
|
get unitSystem() {
|
|
1957
|
-
return
|
|
2038
|
+
return qr(this.getAttribute("units")) ?? "metric";
|
|
1958
2039
|
}
|
|
1959
2040
|
renderNow() {
|
|
1960
2041
|
if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-scalebar-ink", !0), this.style.display = "block", !U(this)) {
|
|
@@ -1970,48 +2051,48 @@ class tr extends O {
|
|
|
1970
2051
|
this.renderSvg(e);
|
|
1971
2052
|
}
|
|
1972
2053
|
renderSvg(t) {
|
|
1973
|
-
const { w: e, h: n } = S(this), i = this.ownerDocument,
|
|
1974
|
-
|
|
1975
|
-
const
|
|
2054
|
+
const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(at, "svg");
|
|
2055
|
+
s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.setAttribute("part", "scalebar"), s.style.display = "block", s.style.overflow = "visible";
|
|
2056
|
+
const o = "var(--om-carto-scalebar-ink)";
|
|
1976
2057
|
for (const a of t.bars) {
|
|
1977
|
-
const l = i.createElementNS(
|
|
1978
|
-
l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("width", String(a.w)), l.setAttribute("height", String(a.h)), l.setAttribute("fill", a.filled ?
|
|
2058
|
+
const l = i.createElementNS(at, "rect");
|
|
2059
|
+
l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("width", String(a.w)), l.setAttribute("height", String(a.h)), l.setAttribute("fill", a.filled ? o : "none"), l.setAttribute("stroke", o), l.setAttribute("stroke-width", String(t.strokeMm)), s.appendChild(l);
|
|
1979
2060
|
}
|
|
1980
2061
|
for (const a of t.strokes) {
|
|
1981
|
-
const l = i.createElementNS(
|
|
1982
|
-
l.setAttribute("x1", String(a.x1)), l.setAttribute("y1", String(a.y1)), l.setAttribute("x2", String(a.x2)), l.setAttribute("y2", String(a.y2)), l.setAttribute("stroke",
|
|
2062
|
+
const l = i.createElementNS(at, "line");
|
|
2063
|
+
l.setAttribute("x1", String(a.x1)), l.setAttribute("y1", String(a.y1)), l.setAttribute("x2", String(a.x2)), l.setAttribute("y2", String(a.y2)), l.setAttribute("stroke", o), l.setAttribute("stroke-width", String(t.strokeMm)), s.appendChild(l);
|
|
1983
2064
|
}
|
|
1984
2065
|
for (const a of t.labels) {
|
|
1985
|
-
const l = i.createElementNS(
|
|
1986
|
-
l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("font-size", String(t.fontMm)), l.setAttribute("fill",
|
|
2066
|
+
const l = i.createElementNS(at, "text");
|
|
2067
|
+
l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("font-size", String(t.fontMm)), l.setAttribute("fill", o), l.setAttribute("text-anchor", a.anchor), l.setAttribute("font-family", "var(--om-carto-font)"), l.textContent = a.text, s.appendChild(l);
|
|
1987
2068
|
}
|
|
1988
|
-
this.replaceChildren(
|
|
2069
|
+
this.replaceChildren(s);
|
|
1989
2070
|
}
|
|
1990
2071
|
paintCartograph(t, e) {
|
|
1991
2072
|
const n = this.drawing;
|
|
1992
2073
|
if (!n) return;
|
|
1993
|
-
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null,
|
|
1994
|
-
t.strokeStyle =
|
|
2074
|
+
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = I(i?.color) ?? "#000", o = (l) => l * e.pxPerMm;
|
|
2075
|
+
t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(n.strokeMm);
|
|
1995
2076
|
for (const l of n.bars)
|
|
1996
|
-
l.filled && t.fillRect(
|
|
2077
|
+
l.filled && t.fillRect(o(l.x), o(l.y), o(l.w), o(l.h)), t.strokeRect(o(l.x), o(l.y), o(l.w), o(l.h));
|
|
1997
2078
|
t.beginPath();
|
|
1998
2079
|
for (const l of n.strokes)
|
|
1999
|
-
t.moveTo(
|
|
2080
|
+
t.moveTo(o(l.x1), o(l.y1)), t.lineTo(o(l.x2), o(l.y2));
|
|
2000
2081
|
t.stroke();
|
|
2001
2082
|
const a = i?.fontFamily || "system-ui, sans-serif";
|
|
2002
|
-
t.font = `${
|
|
2083
|
+
t.font = `${o(n.fontMm)}px ${a}`, t.textBaseline = "alphabetic";
|
|
2003
2084
|
for (const l of n.labels)
|
|
2004
|
-
t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text,
|
|
2085
|
+
t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text, o(l.x), o(l.y));
|
|
2005
2086
|
}
|
|
2006
2087
|
}
|
|
2007
|
-
|
|
2088
|
+
x("om-scalebar", ir);
|
|
2008
2089
|
const Q = "http://www.w3.org/2000/svg";
|
|
2009
|
-
class
|
|
2090
|
+
class sr extends O {
|
|
2010
2091
|
static observedAttributes = [...T["om-north"]];
|
|
2011
2092
|
/** Degrees clockwise from the page's "up", or null when unknowable. */
|
|
2012
2093
|
get bearing() {
|
|
2013
2094
|
const t = U(this)?.georef;
|
|
2014
|
-
return t ?
|
|
2095
|
+
return t ? vn(t) : null;
|
|
2015
2096
|
}
|
|
2016
2097
|
get indicatorKind() {
|
|
2017
2098
|
return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
|
|
@@ -2027,38 +2108,38 @@ class er extends O {
|
|
|
2027
2108
|
W(this, "North indicator cannot derive a direction from this frame yet.");
|
|
2028
2109
|
return;
|
|
2029
2110
|
}
|
|
2030
|
-
const { w: n, h: i } = S(this),
|
|
2031
|
-
|
|
2032
|
-
const a =
|
|
2111
|
+
const { w: n, h: i } = S(this), s = this.ownerDocument, o = s.createElementNS(Q, "svg");
|
|
2112
|
+
o.setAttribute("width", `${n}mm`), o.setAttribute("height", `${i}mm`), o.setAttribute("viewBox", `0 0 ${n} ${i}`), o.style.display = "block";
|
|
2113
|
+
const a = s.createElementNS(Q, "g");
|
|
2033
2114
|
a.setAttribute("transform", `rotate(${e.toFixed(3)} ${n / 2} ${i / 2})`);
|
|
2034
|
-
for (const l of this.buildGeometry(
|
|
2035
|
-
|
|
2115
|
+
for (const l of this.buildGeometry(s, n, i)) a.appendChild(l);
|
|
2116
|
+
o.appendChild(a), this.replaceChildren(o);
|
|
2036
2117
|
}
|
|
2037
2118
|
buildGeometry(t, e, n) {
|
|
2038
|
-
const i = "var(--om-carto-compass-ink)",
|
|
2119
|
+
const i = "var(--om-carto-compass-ink)", s = [], o = e / 2, a = Math.min(3, n * 0.24), l = n - a * 1.2;
|
|
2039
2120
|
if (this.indicatorKind === "rose") {
|
|
2040
2121
|
const f = Math.min(e, l) / 2, g = t.createElementNS(Q, "circle");
|
|
2041
|
-
g.setAttribute("cx", String(
|
|
2122
|
+
g.setAttribute("cx", String(o)), 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"), s.push(g);
|
|
2042
2123
|
}
|
|
2043
|
-
const c = 0, u = l,
|
|
2044
|
-
d.setAttribute("d", `M ${
|
|
2045
|
-
const
|
|
2046
|
-
return
|
|
2124
|
+
const c = 0, u = l, h = Math.min(e * 0.3, 4), d = t.createElementNS(Q, "path");
|
|
2125
|
+
d.setAttribute("d", `M ${o} ${c} L ${o + h} ${u} L ${o} ${u - h * 0.55} L ${o - h} ${u} Z`), d.setAttribute("fill", i), s.push(d);
|
|
2126
|
+
const m = t.createElementNS(Q, "text");
|
|
2127
|
+
return m.setAttribute("x", String(o)), m.setAttribute("y", String(n)), m.setAttribute("font-size", String(a)), m.setAttribute("text-anchor", "middle"), m.setAttribute("fill", i), m.setAttribute("font-family", "var(--om-carto-font)"), m.textContent = "N", s.push(m), s;
|
|
2047
2128
|
}
|
|
2048
2129
|
paintCartograph(t, e) {
|
|
2049
2130
|
const n = this.bearing;
|
|
2050
2131
|
if (n == null) return;
|
|
2051
|
-
const { w: i, h:
|
|
2052
|
-
t.save(), t.translate(l(
|
|
2132
|
+
const { w: i, h: s } = S(this), o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = I(o?.color) ?? "#000", l = (m) => m * e.pxPerMm, c = Math.min(3, s * 0.24), u = s - c * 1.2, h = i / 2, d = Math.min(i * 0.3, 4);
|
|
2133
|
+
t.save(), t.translate(l(h), l(s / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(h), -l(s / 2)), t.fillStyle = a, t.strokeStyle = a, this.indicatorKind === "rose" && (t.lineWidth = l(0.2), t.beginPath(), t.arc(l(h), l(u / 2), l(Math.min(i, u) / 2), 0, Math.PI * 2), t.stroke()), t.beginPath(), t.moveTo(l(h), 0), t.lineTo(l(h + d), l(u)), t.lineTo(l(h), l(u - d * 0.55)), t.lineTo(l(h - d), l(u)), t.closePath(), t.fill(), t.font = `${l(c)}px ${o?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(h), l(s)), t.restore();
|
|
2053
2134
|
}
|
|
2054
2135
|
}
|
|
2055
|
-
|
|
2056
|
-
const
|
|
2057
|
-
class
|
|
2136
|
+
x("om-north", sr);
|
|
2137
|
+
const lt = "http://www.w3.org/2000/svg", Rn = ["rect", "ellipse", "line", "arrow"];
|
|
2138
|
+
class or extends O {
|
|
2058
2139
|
static observedAttributes = [...T["om-shape"]];
|
|
2059
2140
|
get kind() {
|
|
2060
2141
|
const t = this.getAttribute("kind");
|
|
2061
|
-
return
|
|
2142
|
+
return Rn.includes(t) ? t : "rect";
|
|
2062
2143
|
}
|
|
2063
2144
|
get fill() {
|
|
2064
2145
|
return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
|
|
@@ -2084,44 +2165,44 @@ class rr extends O {
|
|
|
2084
2165
|
}
|
|
2085
2166
|
renderNow() {
|
|
2086
2167
|
this.applyPlacement(), this.style.display = "block";
|
|
2087
|
-
const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(
|
|
2168
|
+
const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(lt, "svg");
|
|
2088
2169
|
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";
|
|
2089
|
-
const
|
|
2170
|
+
const s = this.strokeWidthMm / 2, o = this.kind;
|
|
2090
2171
|
let a;
|
|
2091
|
-
|
|
2092
|
-
const l =
|
|
2172
|
+
o === "ellipse" ? (a = n.createElementNS(lt, "ellipse"), a.setAttribute("cx", String(t / 2)), a.setAttribute("cy", String(e / 2)), a.setAttribute("rx", String(Math.max(0, t / 2 - s))), a.setAttribute("ry", String(Math.max(0, e / 2 - s)))) : o === "line" || o === "arrow" ? (a = n.createElementNS(lt, "path"), a.setAttribute("d", o === "arrow" ? this.arrowPath(t, e) : `M 0 0 L ${t} ${e}`)) : (a = n.createElementNS(lt, "rect"), a.setAttribute("x", String(s)), a.setAttribute("y", String(s)), a.setAttribute("width", String(Math.max(0, t - this.strokeWidthMm))), a.setAttribute("height", String(Math.max(0, e - this.strokeWidthMm))), this.radiusMm > 0 && a.setAttribute("rx", String(this.radiusMm)));
|
|
2173
|
+
const l = o === "rect" || o === "ellipse" || o === "arrow";
|
|
2093
2174
|
a.setAttribute("fill", l ? this.fill : "none"), l && a.setAttribute("fill-opacity", String(this.fillOpacity)), a.setAttribute("stroke", this.stroke), a.setAttribute("stroke-width", String(this.strokeWidthMm)), i.appendChild(a), this.replaceChildren(i);
|
|
2094
2175
|
}
|
|
2095
2176
|
/** A line from the box's top-left to its bottom-right, with a solid head. */
|
|
2096
2177
|
arrowPath(t, e) {
|
|
2097
|
-
const n = Math.min(t, e) * 0.28, i = Math.atan2(e, t),
|
|
2098
|
-
return `M 0 0 L ${
|
|
2178
|
+
const n = Math.min(t, e) * 0.28, i = Math.atan2(e, t), s = t, o = e, a = { x: s - n * Math.cos(i - 0.4), y: o - n * Math.sin(i - 0.4) }, l = { x: s - n * Math.cos(i + 0.4), y: o - n * Math.sin(i + 0.4) };
|
|
2179
|
+
return `M 0 0 L ${s} ${o} M ${s} ${o} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
|
|
2099
2180
|
}
|
|
2100
2181
|
paintCartograph(t, e) {
|
|
2101
2182
|
const { w: n, h: i } = S(this);
|
|
2102
2183
|
if (n <= 0 || i <= 0) return;
|
|
2103
|
-
const
|
|
2104
|
-
if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c,
|
|
2105
|
-
t.beginPath(), t.ellipse(
|
|
2106
|
-
else if (
|
|
2107
|
-
if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(
|
|
2108
|
-
const d = Math.min(
|
|
2109
|
-
t.beginPath(), t.moveTo(
|
|
2184
|
+
const s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || s?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || s?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = o(this.strokeWidthMm), u = c / 2, h = this.kind;
|
|
2185
|
+
if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, h === "ellipse")
|
|
2186
|
+
t.beginPath(), t.ellipse(o(n / 2), o(i / 2), Math.max(0, o(n / 2) - u), Math.max(0, o(i / 2) - u), 0, 0, Math.PI * 2), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
|
|
2187
|
+
else if (h === "line" || h === "arrow") {
|
|
2188
|
+
if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(o(n), o(i)), c > 0 && t.stroke(), h === "arrow") {
|
|
2189
|
+
const d = Math.min(o(n), o(i)) * 0.28, m = Math.atan2(o(i), o(n));
|
|
2190
|
+
t.beginPath(), t.moveTo(o(n), o(i)), t.lineTo(o(n) - d * Math.cos(m - 0.4), o(i) - d * Math.sin(m - 0.4)), t.lineTo(o(n) - d * Math.cos(m + 0.4), o(i) - d * Math.sin(m + 0.4)), t.closePath(), t.fillStyle = l, t.fill();
|
|
2110
2191
|
}
|
|
2111
2192
|
} else {
|
|
2112
|
-
const d =
|
|
2113
|
-
t.beginPath(), d > 0 && typeof t.roundRect == "function" ? t.roundRect(u, u,
|
|
2193
|
+
const d = o(this.radiusMm);
|
|
2194
|
+
t.beginPath(), d > 0 && typeof t.roundRect == "function" ? t.roundRect(u, u, o(n) - c, o(i) - c, d) : t.rect(u, u, o(n) - c, o(i) - c), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
|
|
2114
2195
|
}
|
|
2115
2196
|
t.restore();
|
|
2116
2197
|
}
|
|
2117
2198
|
}
|
|
2118
|
-
|
|
2119
|
-
const
|
|
2120
|
-
class
|
|
2199
|
+
x("om-shape", or);
|
|
2200
|
+
const Ce = "data-om-carto-owned", In = ["contain", "cover", "fill"];
|
|
2201
|
+
class ar extends O {
|
|
2121
2202
|
static observedAttributes = [...T["om-image"]];
|
|
2122
2203
|
get fit() {
|
|
2123
2204
|
const t = this.getAttribute("fit");
|
|
2124
|
-
return
|
|
2205
|
+
return In.includes(t ?? "") ? t : "contain";
|
|
2125
2206
|
}
|
|
2126
2207
|
get image() {
|
|
2127
2208
|
return this.querySelector(":scope > img");
|
|
@@ -2130,29 +2211,29 @@ class nr extends O {
|
|
|
2130
2211
|
this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden";
|
|
2131
2212
|
const t = this.getAttribute("src");
|
|
2132
2213
|
let e = this.image;
|
|
2133
|
-
!e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(
|
|
2214
|
+
!e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(Ce, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(Ce) && e.getAttribute("src") !== t && e.setAttribute("src", t), e.style.width = "100%", e.style.height = "100%", e.style.objectFit = this.fit, e.style.display = "block");
|
|
2134
2215
|
}
|
|
2135
2216
|
paintCartograph(t, e) {
|
|
2136
2217
|
const n = this.image;
|
|
2137
2218
|
if (!n || !n.complete || n.naturalWidth === 0) return;
|
|
2138
|
-
const { w: i, h:
|
|
2139
|
-
if (
|
|
2219
|
+
const { w: i, h: s } = S(this), o = i * e.pxPerMm, a = s * e.pxPerMm;
|
|
2220
|
+
if (o <= 0 || a <= 0) return;
|
|
2140
2221
|
const l = this.fit;
|
|
2141
2222
|
if (l === "fill") {
|
|
2142
|
-
t.drawImage(n, 0, 0,
|
|
2223
|
+
t.drawImage(n, 0, 0, o, a);
|
|
2143
2224
|
return;
|
|
2144
2225
|
}
|
|
2145
|
-
const c = n.naturalWidth / n.naturalHeight, u =
|
|
2146
|
-
l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0,
|
|
2226
|
+
const c = n.naturalWidth / n.naturalHeight, u = o / a, h = l === "contain" ? c > u : c < u, d = h ? o : a * c, m = h ? o / c : a;
|
|
2227
|
+
l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, o, a), t.clip()), t.drawImage(n, (o - d) / 2, (a - m) / 2, d, m), l === "cover" && t.restore();
|
|
2147
2228
|
}
|
|
2148
2229
|
}
|
|
2149
|
-
|
|
2150
|
-
const
|
|
2151
|
-
function
|
|
2230
|
+
x("om-image", ar);
|
|
2231
|
+
const Fn = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), On = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), _n = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
|
|
2232
|
+
function Un(r) {
|
|
2152
2233
|
const t = r.type ?? "";
|
|
2153
|
-
if (
|
|
2154
|
-
if (
|
|
2155
|
-
if (
|
|
2234
|
+
if (_n.has(t)) return "ramp";
|
|
2235
|
+
if (Fn.has(t)) return "line";
|
|
2236
|
+
if (On.has(t)) return "point";
|
|
2156
2237
|
if (t === "GeoJsonLayer") {
|
|
2157
2238
|
const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
|
|
2158
2239
|
if (n && !i) return "polygon";
|
|
@@ -2160,69 +2241,69 @@ function Tn(r) {
|
|
|
2160
2241
|
}
|
|
2161
2242
|
return "polygon";
|
|
2162
2243
|
}
|
|
2163
|
-
function
|
|
2244
|
+
function Dn(r) {
|
|
2164
2245
|
const t = r.meta?.legend;
|
|
2165
2246
|
return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
|
|
2166
2247
|
}
|
|
2167
|
-
const
|
|
2168
|
-
function
|
|
2248
|
+
const Nt = 12;
|
|
2249
|
+
function zn(r, t = []) {
|
|
2169
2250
|
const e = [];
|
|
2170
2251
|
for (const n of r) {
|
|
2171
2252
|
if (n.props?.visible === !1) continue;
|
|
2172
|
-
const i = t.filter((a) => a.layer === n.id),
|
|
2173
|
-
if (
|
|
2174
|
-
const
|
|
2253
|
+
const i = t.filter((a) => a.layer === n.id), s = i.find((a) => a.match == null);
|
|
2254
|
+
if (s?.hide) continue;
|
|
2255
|
+
const o = jn(n.meta?.legend);
|
|
2175
2256
|
e.push({
|
|
2176
2257
|
layerId: n.id,
|
|
2177
|
-
label:
|
|
2178
|
-
color:
|
|
2179
|
-
shape:
|
|
2180
|
-
legend:
|
|
2181
|
-
order:
|
|
2258
|
+
label: s?.label ?? n.meta?.label ?? n.id,
|
|
2259
|
+
color: s?.color ?? Dn(n),
|
|
2260
|
+
shape: s?.shape ?? Un(n),
|
|
2261
|
+
legend: Gn(o, i),
|
|
2262
|
+
order: s?.order
|
|
2182
2263
|
});
|
|
2183
2264
|
}
|
|
2184
2265
|
return e.map((n, i) => ({ row: n, index: i })).sort((n, i) => {
|
|
2185
|
-
const
|
|
2186
|
-
return
|
|
2266
|
+
const s = n.row.order ?? Number.POSITIVE_INFINITY, o = i.row.order ?? Number.POSITIVE_INFINITY;
|
|
2267
|
+
return s - o || n.index - i.index;
|
|
2187
2268
|
}).map((n) => n.row);
|
|
2188
2269
|
}
|
|
2189
|
-
function
|
|
2190
|
-
if (!r || r.kind !== "categories" || r.entries.length <=
|
|
2191
|
-
const t = r.entries.slice(0,
|
|
2270
|
+
function jn(r) {
|
|
2271
|
+
if (!r || r.kind !== "categories" || r.entries.length <= Nt) return r;
|
|
2272
|
+
const t = r.entries.slice(0, Nt), e = r.entries.length - Nt;
|
|
2192
2273
|
return {
|
|
2193
2274
|
...r,
|
|
2194
2275
|
entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
|
|
2195
2276
|
};
|
|
2196
2277
|
}
|
|
2197
|
-
function
|
|
2278
|
+
function Gn(r, t) {
|
|
2198
2279
|
const e = t.filter((i) => i.match != null);
|
|
2199
2280
|
if (!r || r.kind === "ramp" || e.length === 0) return r;
|
|
2200
2281
|
const n = [];
|
|
2201
2282
|
for (const i of r.entries) {
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2283
|
+
const s = e.find((o) => o.match === i.label);
|
|
2284
|
+
s?.hide || n.push({ color: s?.color ?? i.color, label: s?.label ?? i.label });
|
|
2204
2285
|
}
|
|
2205
2286
|
return { ...r, entries: n };
|
|
2206
2287
|
}
|
|
2207
|
-
function
|
|
2288
|
+
function qn(r) {
|
|
2208
2289
|
const t = [];
|
|
2209
2290
|
for (const e of r.querySelectorAll(":scope > om-legend-row")) {
|
|
2210
2291
|
const n = e.getAttribute("layer");
|
|
2211
2292
|
if (!n) continue;
|
|
2212
|
-
const i = e.getAttribute("order"),
|
|
2293
|
+
const i = e.getAttribute("order"), s = i == null || i.trim() === "" ? void 0 : Number(i);
|
|
2213
2294
|
t.push({
|
|
2214
2295
|
layer: n,
|
|
2215
2296
|
match: e.getAttribute("match") ?? void 0,
|
|
2216
2297
|
label: e.getAttribute("label") ?? void 0,
|
|
2217
2298
|
hide: e.hasAttribute("hide"),
|
|
2218
|
-
order:
|
|
2299
|
+
order: s != null && Number.isFinite(s) ? s : void 0,
|
|
2219
2300
|
color: e.getAttribute("color") ?? void 0,
|
|
2220
2301
|
shape: e.getAttribute("shape") ?? void 0
|
|
2221
2302
|
});
|
|
2222
2303
|
}
|
|
2223
2304
|
return t;
|
|
2224
2305
|
}
|
|
2225
|
-
function
|
|
2306
|
+
function lr(r) {
|
|
2226
2307
|
const t = [];
|
|
2227
2308
|
for (const e of r.querySelectorAll(":scope > om-legend-row")) {
|
|
2228
2309
|
if (e.hasAttribute("hide")) continue;
|
|
@@ -2237,17 +2318,17 @@ function ir(r) {
|
|
|
2237
2318
|
}
|
|
2238
2319
|
return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
|
|
2239
2320
|
}
|
|
2240
|
-
const
|
|
2241
|
-
class
|
|
2321
|
+
const xe = "data-om-carto-legend-rows";
|
|
2322
|
+
class cr extends O {
|
|
2242
2323
|
static observedAttributes = [...T["om-legend"]];
|
|
2243
2324
|
get derived() {
|
|
2244
2325
|
return this.getAttribute("derived") !== "false";
|
|
2245
2326
|
}
|
|
2246
2327
|
/** The rows this legend currently shows — recomputed on demand, never stored. */
|
|
2247
2328
|
get rows() {
|
|
2248
|
-
if (!this.derived) return
|
|
2329
|
+
if (!this.derived) return lr(this);
|
|
2249
2330
|
const n = U(this)?.mapElement?.getLayers?.();
|
|
2250
|
-
return n ?
|
|
2331
|
+
return n ? zn(n, qn(this)) : [];
|
|
2251
2332
|
}
|
|
2252
2333
|
/** Inner padding in mm — authored, else the 2 mm the theme always used. */
|
|
2253
2334
|
get paddingMm() {
|
|
@@ -2274,18 +2355,18 @@ class sr extends O {
|
|
|
2274
2355
|
}
|
|
2275
2356
|
renderRows(t) {
|
|
2276
2357
|
const e = this.ownerDocument;
|
|
2277
|
-
this.querySelector(`:scope > [${
|
|
2358
|
+
this.querySelector(`:scope > [${xe}]`)?.remove(), Zr(this);
|
|
2278
2359
|
const n = e.createElement("div");
|
|
2279
|
-
n.setAttribute(
|
|
2360
|
+
n.setAttribute(xe, ""), n.style.cssText = `padding:${this.paddingMm}mm;font-size:${this.fontMm}mm;line-height:1.35;`;
|
|
2280
2361
|
const i = this.getAttribute("title");
|
|
2281
2362
|
if (i) {
|
|
2282
|
-
const
|
|
2283
|
-
|
|
2363
|
+
const o = e.createElement("div");
|
|
2364
|
+
o.textContent = i, o.style.cssText = "font-weight:600;margin-bottom:1.2mm;color:var(--om-carto-legend-title-ink);", n.appendChild(o);
|
|
2284
2365
|
}
|
|
2285
|
-
const
|
|
2286
|
-
Number.isFinite(
|
|
2287
|
-
for (const
|
|
2288
|
-
n.appendChild(this.buildRow(e,
|
|
2366
|
+
const s = Number(this.getAttribute("columns"));
|
|
2367
|
+
Number.isFinite(s) && s > 1 && (n.style.columnCount = String(Math.floor(s)), n.style.columnGap = "3mm");
|
|
2368
|
+
for (const o of t)
|
|
2369
|
+
n.appendChild(this.buildRow(e, o)), o.legend && n.appendChild(this.buildSymbology(e, o));
|
|
2289
2370
|
this.appendChild(n);
|
|
2290
2371
|
}
|
|
2291
2372
|
buildRow(t, e) {
|
|
@@ -2296,147 +2377,147 @@ class sr extends O {
|
|
|
2296
2377
|
}
|
|
2297
2378
|
/** The swatch geometry carries meaning: an area, a line and a point read differently. */
|
|
2298
2379
|
buildSwatch(t, e, n) {
|
|
2299
|
-
const i = t.createElement("span"),
|
|
2300
|
-
return n === "line" ? i.style.cssText = `${
|
|
2380
|
+
const i = t.createElement("span"), s = "display:inline-block;flex:none;width:3.2mm;height:3.2mm;";
|
|
2381
|
+
return n === "line" ? i.style.cssText = `${s}height:0.9mm;background:${e};` : n === "point" ? i.style.cssText = `${s}border-radius:50%;background:${e};` : n === "ramp" ? i.style.cssText = `${s}width:6mm;background:linear-gradient(to right, ${e}, transparent);` : i.style.cssText = `${s}background:${e};border:0.15mm solid rgba(0,0,0,.35);`, i;
|
|
2301
2382
|
}
|
|
2302
2383
|
buildSymbology(t, e) {
|
|
2303
2384
|
const n = t.createElement("div");
|
|
2304
2385
|
n.style.cssText = "margin:0.4mm 0 1.6mm 4.7mm;break-inside:avoid;";
|
|
2305
|
-
const i = e.legend,
|
|
2306
|
-
if (
|
|
2307
|
-
const
|
|
2308
|
-
|
|
2386
|
+
const i = e.legend, s = t.createElement("div");
|
|
2387
|
+
if (s.textContent = i.field, s.style.cssText = "font-size:2.1mm;opacity:.7;margin-bottom:0.5mm;", n.appendChild(s), i.kind === "ramp") {
|
|
2388
|
+
const o = t.createElement("div");
|
|
2389
|
+
o.style.cssText = `height:2.4mm;background:linear-gradient(to right, ${i.colors.join(", ")});border:0.15mm solid rgba(0,0,0,.25);`, n.appendChild(o);
|
|
2309
2390
|
const a = t.createElement("div");
|
|
2310
|
-
return a.style.cssText = "display:flex;justify-content:space-between;font-size:2.1mm;opacity:.75;", a.append(
|
|
2391
|
+
return a.style.cssText = "display:flex;justify-content:space-between;font-size:2.1mm;opacity:.75;", a.append(ct(t, i.domain[0].toLocaleString("en-US")), ct(t, i.domain[1].toLocaleString("en-US"))), n.appendChild(a), n;
|
|
2311
2392
|
}
|
|
2312
|
-
for (const
|
|
2393
|
+
for (const o of i.entries) {
|
|
2313
2394
|
const a = t.createElement("div");
|
|
2314
|
-
a.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", a.appendChild(this.buildSwatch(t,
|
|
2395
|
+
a.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", a.appendChild(this.buildSwatch(t, o.color, "polygon")), a.appendChild(ct(t, o.label)), n.appendChild(a);
|
|
2315
2396
|
}
|
|
2316
2397
|
if (i.kind === "categories" && i.defaultColor) {
|
|
2317
|
-
const
|
|
2318
|
-
|
|
2398
|
+
const o = t.createElement("div");
|
|
2399
|
+
o.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", o.appendChild(this.buildSwatch(t, i.defaultColor, "polygon")), o.appendChild(ct(t, "other")), n.appendChild(o);
|
|
2319
2400
|
}
|
|
2320
2401
|
return n;
|
|
2321
2402
|
}
|
|
2322
2403
|
paintCartograph(t, e) {
|
|
2323
|
-
const { w: n, h: i } = S(this),
|
|
2324
|
-
if (
|
|
2325
|
-
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l =
|
|
2326
|
-
l && (t.fillStyle = l, t.fillRect(0, 0,
|
|
2327
|
-
const c =
|
|
2328
|
-
c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2,
|
|
2329
|
-
const
|
|
2330
|
-
let p =
|
|
2404
|
+
const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
|
|
2405
|
+
if (s <= 0 || o <= 0) return;
|
|
2406
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = I(a?.backgroundColor);
|
|
2407
|
+
l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
|
|
2408
|
+
const c = I(a?.borderTopColor), u = Tt(a?.borderTopWidth) * e.scale;
|
|
2409
|
+
c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, s - u, o - u));
|
|
2410
|
+
const h = I(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", m = (M) => M * e.pxPerMm, f = this.paddingMm, g = this.fontMm;
|
|
2411
|
+
let p = m(f);
|
|
2331
2412
|
const b = this.getAttribute("title");
|
|
2332
|
-
b && (t.fillStyle =
|
|
2413
|
+
b && (t.fillStyle = h, t.font = `600 ${m(g)}px ${d}`, t.textBaseline = "top", t.fillText(b, m(f), p), p += m(g * 1.55));
|
|
2333
2414
|
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
2415
|
let E = -1, N = f;
|
|
2335
|
-
t.font = `${
|
|
2416
|
+
t.font = `${m(g)}px ${d}`;
|
|
2336
2417
|
for (const [M, C] of w.entries()) {
|
|
2337
2418
|
const P = Math.min(A - 1, Math.floor(M / v));
|
|
2338
|
-
if (P !== E && (E = P, N = f + E * (G + $), p = E === 0 ? _ :
|
|
2339
|
-
const
|
|
2340
|
-
if (t.save(), t.font = `${
|
|
2341
|
-
const L = Math.min(24, Math.max(1, G - 2.7)), R = N + 2.7, B = t.createLinearGradient(
|
|
2342
|
-
|
|
2343
|
-
const
|
|
2344
|
-
t.textAlign = "right", t.fillText(
|
|
2419
|
+
if (P !== E && (E = P, N = f + E * (G + $), p = E === 0 ? _ : m(f)), p > o || (t.fillStyle = C.color, C.shape === "line" ? t.fillRect(m(N), p + m(1.2), m(3.2), m(0.9)) : C.shape === "point" ? (t.beginPath(), t.arc(m(N + 1.6), p + m(1.6), m(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(m(N), p, m(3.2), m(3.2)), t.fillStyle = h, t.textBaseline = "top", t.fillText(C.label, m(N + 4.7), p + m(0.3)), p += m(g * 1.6), !C.legend)) continue;
|
|
2420
|
+
const k = C.legend;
|
|
2421
|
+
if (t.save(), t.font = `${m(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(k.field, m(N + 2.7), p), t.globalAlpha = 1, p += m(2.8), k.kind === "ramp") {
|
|
2422
|
+
const L = Math.min(24, Math.max(1, G - 2.7)), R = N + 2.7, B = t.createLinearGradient(m(R), 0, m(R + L), 0);
|
|
2423
|
+
k.colors.forEach((pr, gr) => B.addColorStop(k.colors.length === 1 ? 0 : gr / (k.colors.length - 1), pr)), t.fillStyle = B, t.fillRect(m(R), p, m(L), m(2.4)), p += m(3.4), t.fillStyle = h, t.font = `${m(2.1)}px ${d}`, t.fillText(k.domain[0].toLocaleString("en-US"), m(R), p);
|
|
2424
|
+
const fr = k.domain[1].toLocaleString("en-US");
|
|
2425
|
+
t.textAlign = "right", t.fillText(fr, m(R + L), p), t.textAlign = "left", p += m(3.2);
|
|
2345
2426
|
} else {
|
|
2346
|
-
const L = [...
|
|
2347
|
-
|
|
2427
|
+
const L = [...k.entries];
|
|
2428
|
+
k.kind === "categories" && k.defaultColor && L.push({ color: k.defaultColor, label: "other" }), t.font = `${m(2.3)}px ${d}`;
|
|
2348
2429
|
for (const R of L) {
|
|
2349
|
-
if (p >
|
|
2350
|
-
t.fillStyle = R.color, t.fillRect(
|
|
2430
|
+
if (p > o) break;
|
|
2431
|
+
t.fillStyle = R.color, t.fillRect(m(N + 2.7), p, m(2.6), m(2.6)), t.fillStyle = h, t.fillText(R.label, m(N + 6.3), p + m(0.2)), p += m(3.2);
|
|
2351
2432
|
}
|
|
2352
|
-
p +=
|
|
2433
|
+
p += m(1);
|
|
2353
2434
|
}
|
|
2354
|
-
t.restore(), t.font = `${
|
|
2435
|
+
t.restore(), t.font = `${m(2.6)}px ${d}`;
|
|
2355
2436
|
}
|
|
2356
2437
|
}
|
|
2357
2438
|
}
|
|
2358
|
-
const
|
|
2439
|
+
const ct = (r, t) => {
|
|
2359
2440
|
const e = r.createElement("span");
|
|
2360
2441
|
return e.textContent = t, e;
|
|
2361
2442
|
};
|
|
2362
|
-
|
|
2363
|
-
const
|
|
2443
|
+
x("om-legend", cr);
|
|
2444
|
+
const ke = 48, zt = {
|
|
2364
2445
|
toLngLat: (r, t) => [r, t],
|
|
2365
2446
|
fromLngLat: (r) => [r[0], r[1]]
|
|
2366
2447
|
};
|
|
2367
|
-
function
|
|
2368
|
-
return !Number.isFinite(r) || r <= 0 ? 0 :
|
|
2448
|
+
function $e(r, t = 5) {
|
|
2449
|
+
return !Number.isFinite(r) || r <= 0 ? 0 : We(r / Math.max(1, t));
|
|
2369
2450
|
}
|
|
2370
|
-
function
|
|
2451
|
+
function Wn({ georef: r, plane: t = zt, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
|
|
2371
2452
|
if (r.degenerate) return null;
|
|
2372
2453
|
const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
|
|
2373
2454
|
if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
|
|
2374
|
-
const u = Math.min(...l),
|
|
2375
|
-
if (f <= 0 || g <= 0 || (
|
|
2376
|
-
const p = [], b = [], w =
|
|
2377
|
-
for (let y = Math.ceil(u / f) * f; y <=
|
|
2378
|
-
const A =
|
|
2455
|
+
const u = Math.min(...l), h = Math.max(...l), d = Math.min(...c), m = Math.max(...c), f = Ee(n ?? e, $e(h - u)), g = Ee(i ?? e, $e(m - d));
|
|
2456
|
+
if (f <= 0 || g <= 0 || (h - u) / f > 500 || (m - d) / g > 500) return null;
|
|
2457
|
+
const p = [], b = [], w = o ?? Kn;
|
|
2458
|
+
for (let y = Math.ceil(u / f) * f; y <= h + 1e-9; y += f) {
|
|
2459
|
+
const A = Ne(r, t, y, d, m, "x");
|
|
2379
2460
|
if (A) {
|
|
2380
2461
|
p.push(A);
|
|
2381
|
-
const v = t ===
|
|
2382
|
-
|
|
2462
|
+
const v = t === zt ? rr(y) : y;
|
|
2463
|
+
s !== "none" && Te(b, A, r, w(v, "x"), "x", s);
|
|
2383
2464
|
}
|
|
2384
2465
|
}
|
|
2385
|
-
for (let y = Math.ceil(d / g) * g; y <=
|
|
2386
|
-
const A =
|
|
2387
|
-
A && (p.push(A),
|
|
2466
|
+
for (let y = Math.ceil(d / g) * g; y <= m + 1e-9; y += g) {
|
|
2467
|
+
const A = Ne(r, t, y, u, h, "y");
|
|
2468
|
+
A && (p.push(A), s !== "none" && Te(b, A, r, w(y, "y"), "y", s));
|
|
2388
2469
|
}
|
|
2389
2470
|
return { lines: p, labels: b, intervalX: f, intervalY: g };
|
|
2390
2471
|
}
|
|
2391
|
-
const
|
|
2392
|
-
function
|
|
2393
|
-
const
|
|
2394
|
-
for (let l = 0; l <=
|
|
2395
|
-
const c = n + (i - n) * l /
|
|
2472
|
+
const Ee = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
|
|
2473
|
+
function Ne(r, t, e, n, i, s) {
|
|
2474
|
+
const o = [];
|
|
2475
|
+
for (let l = 0; l <= ke; l++) {
|
|
2476
|
+
const c = n + (i - n) * l / ke, u = s === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
|
|
2396
2477
|
if (!Number.isFinite(u[0]) || !Number.isFinite(u[1])) continue;
|
|
2397
|
-
const
|
|
2398
|
-
|
|
2478
|
+
const h = r.project(u);
|
|
2479
|
+
h && o.push(h);
|
|
2399
2480
|
}
|
|
2400
|
-
const a =
|
|
2401
|
-
return a.length >= 2 ? { points: a, value: e, axis:
|
|
2481
|
+
const a = Bn(o, r.widthMm, r.heightMm);
|
|
2482
|
+
return a.length >= 2 ? { points: a, value: e, axis: s } : null;
|
|
2402
2483
|
}
|
|
2403
|
-
function
|
|
2484
|
+
function Bn(r, t, e) {
|
|
2404
2485
|
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);
|
|
2405
2486
|
if (i === -1) return [];
|
|
2406
|
-
let
|
|
2407
|
-
for (;
|
|
2408
|
-
return r.slice(Math.max(0, i - 1), Math.min(r.length,
|
|
2487
|
+
let s = r.length - 1;
|
|
2488
|
+
for (; s > i && !n(r[s]); ) s--;
|
|
2489
|
+
return r.slice(Math.max(0, i - 1), Math.min(r.length, s + 2)).map((a) => ({ xMm: Pe(a.xMm, 0, t), yMm: Pe(a.yMm, 0, e) }));
|
|
2409
2490
|
}
|
|
2410
|
-
const
|
|
2411
|
-
function
|
|
2491
|
+
const Pe = (r, t, e) => Math.min(e, Math.max(t, r));
|
|
2492
|
+
function Te(r, t, e, n, i, s) {
|
|
2412
2493
|
if (i === "x") {
|
|
2413
|
-
const
|
|
2414
|
-
if (Math.abs(
|
|
2415
|
-
r.push({ text: n, xMm:
|
|
2494
|
+
const o = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
|
|
2495
|
+
if (Math.abs(o.yMm - e.heightMm) > 0.5) return;
|
|
2496
|
+
r.push({ text: n, xMm: o.xMm, yMm: e.heightMm + (s === "outside" ? 3 : -1), edge: "bottom", axis: i });
|
|
2416
2497
|
} else {
|
|
2417
|
-
const
|
|
2418
|
-
if (Math.abs(
|
|
2419
|
-
r.push({ text: n, xMm:
|
|
2498
|
+
const o = t.points.reduce((a, l) => l.xMm < a.xMm ? l : a);
|
|
2499
|
+
if (Math.abs(o.xMm) > 0.5) return;
|
|
2500
|
+
r.push({ text: n, xMm: s === "outside" ? -1.2 : 1.2, yMm: o.yMm, edge: "left", axis: i });
|
|
2420
2501
|
}
|
|
2421
2502
|
}
|
|
2422
|
-
function
|
|
2503
|
+
function Kn(r, t) {
|
|
2423
2504
|
if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
|
|
2424
2505
|
const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
|
|
2425
2506
|
return `${Number(r.toFixed(e))}°`;
|
|
2426
2507
|
}
|
|
2427
|
-
function
|
|
2428
|
-
const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n),
|
|
2429
|
-
return `${c}°${String(u).padStart(2, "0")}′${String(
|
|
2508
|
+
function Vn(r, t) {
|
|
2509
|
+
const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), s = (n - i) * 60, o = Math.floor(s), a = Math.round((s - o) * 60), l = a === 60 ? o + 1 : o, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, h = a === 60 ? 0 : a;
|
|
2510
|
+
return `${c}°${String(u).padStart(2, "0")}′${String(h).padStart(2, "0")}″${e}`;
|
|
2430
2511
|
}
|
|
2431
|
-
const
|
|
2432
|
-
class
|
|
2512
|
+
const ut = "http://www.w3.org/2000/svg", Hn = ["solid", "cross", "markers"], j = 1.4;
|
|
2513
|
+
class ur extends O {
|
|
2433
2514
|
static observedAttributes = [...T["om-graticule"]];
|
|
2434
2515
|
resolvedPlane = null;
|
|
2435
2516
|
resolvedPlaneKey = null;
|
|
2436
2517
|
resolveToken = 0;
|
|
2437
2518
|
get kind() {
|
|
2438
2519
|
const t = this.getAttribute("kind");
|
|
2439
|
-
return
|
|
2520
|
+
return Hn.includes(t) ? t : "solid";
|
|
2440
2521
|
}
|
|
2441
2522
|
get labelPlacement() {
|
|
2442
2523
|
const t = this.getAttribute("labels");
|
|
@@ -2449,17 +2530,17 @@ class or extends O {
|
|
|
2449
2530
|
const e = this.gridPlane();
|
|
2450
2531
|
if (!e) return null;
|
|
2451
2532
|
const n = (i) => {
|
|
2452
|
-
const
|
|
2453
|
-
return Number.isFinite(
|
|
2533
|
+
const s = Number(this.getAttribute(i));
|
|
2534
|
+
return Number.isFinite(s) && s > 0 ? s : null;
|
|
2454
2535
|
};
|
|
2455
|
-
return
|
|
2536
|
+
return Wn({
|
|
2456
2537
|
georef: t,
|
|
2457
2538
|
plane: e,
|
|
2458
2539
|
interval: n("interval"),
|
|
2459
2540
|
intervalX: n("interval-x"),
|
|
2460
2541
|
intervalY: n("interval-y"),
|
|
2461
2542
|
labels: this.labelPlacement,
|
|
2462
|
-
format: this.getAttribute("format") === "dms" ?
|
|
2543
|
+
format: this.getAttribute("format") === "dms" ? Vn : void 0
|
|
2463
2544
|
});
|
|
2464
2545
|
}
|
|
2465
2546
|
/**
|
|
@@ -2468,18 +2549,18 @@ class or extends O {
|
|
|
2468
2549
|
* a re-render when it lands.
|
|
2469
2550
|
*/
|
|
2470
2551
|
gridPlane() {
|
|
2471
|
-
const t =
|
|
2472
|
-
if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return
|
|
2552
|
+
const t = Ot(this.getAttribute("crs"));
|
|
2553
|
+
if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return zt;
|
|
2473
2554
|
const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
|
|
2474
2555
|
if (this.resolvedPlaneKey === e) return this.resolvedPlane;
|
|
2475
2556
|
const n = Y(t);
|
|
2476
2557
|
if (n) {
|
|
2477
|
-
const
|
|
2478
|
-
return this.resolvedPlane =
|
|
2558
|
+
const s = { toLngLat: (o, a) => n.inverse([o, a]), fromLngLat: (o) => n.forward(o) };
|
|
2559
|
+
return this.resolvedPlane = s, this.resolvedPlaneKey = e, s;
|
|
2479
2560
|
}
|
|
2480
2561
|
const i = ++this.resolveToken;
|
|
2481
|
-
return
|
|
2482
|
-
i !== this.resolveToken || !
|
|
2562
|
+
return _t(t, this.getAttribute("crs-def")).then((s) => {
|
|
2563
|
+
i !== this.resolveToken || !s || (this.resolvedPlane = { toLngLat: (o, a) => s.inverse([o, a]), fromLngLat: (o) => s.forward(o) }, this.resolvedPlaneKey = e, this.scheduleRender());
|
|
2483
2564
|
}).catch(() => {
|
|
2484
2565
|
}), null;
|
|
2485
2566
|
}
|
|
@@ -2497,149 +2578,149 @@ class or extends O {
|
|
|
2497
2578
|
this.renderSvg(e);
|
|
2498
2579
|
}
|
|
2499
2580
|
renderSvg(t) {
|
|
2500
|
-
const { w: e, h: n } = S(this), i = this.ownerDocument,
|
|
2501
|
-
|
|
2502
|
-
const
|
|
2581
|
+
const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(ut, "svg");
|
|
2582
|
+
s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.style.cssText = "display:block;overflow:visible;";
|
|
2583
|
+
const o = "var(--om-carto-graticule-ink)", a = this.kind;
|
|
2503
2584
|
for (const l of t.lines)
|
|
2504
2585
|
if (a === "solid") {
|
|
2505
|
-
const c = i.createElementNS(
|
|
2506
|
-
c.setAttribute("points", l.points.map((u) => `${u.xMm.toFixed(3)},${u.yMm.toFixed(3)}`).join(" ")), c.setAttribute("fill", "none"), c.setAttribute("stroke",
|
|
2586
|
+
const c = i.createElementNS(ut, "polyline");
|
|
2587
|
+
c.setAttribute("points", l.points.map((u) => `${u.xMm.toFixed(3)},${u.yMm.toFixed(3)}`).join(" ")), c.setAttribute("fill", "none"), c.setAttribute("stroke", o), c.setAttribute("stroke-width", "0.15"), s.appendChild(c);
|
|
2507
2588
|
} else
|
|
2508
2589
|
for (const c of this.tickPoints(l, a, t)) {
|
|
2509
|
-
const u = i.createElementNS(
|
|
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",
|
|
2590
|
+
const u = i.createElementNS(ut, "path");
|
|
2591
|
+
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", o), u.setAttribute("stroke-width", "0.15"), s.appendChild(u);
|
|
2511
2592
|
}
|
|
2512
2593
|
for (const l of t.labels) {
|
|
2513
|
-
const c = i.createElementNS(
|
|
2514
|
-
c.setAttribute("x", String(l.xMm)), c.setAttribute("y", String(l.yMm)), c.setAttribute("font-size", "2.2"), c.setAttribute("fill",
|
|
2594
|
+
const c = i.createElementNS(ut, "text");
|
|
2595
|
+
c.setAttribute("x", String(l.xMm)), c.setAttribute("y", String(l.yMm)), c.setAttribute("font-size", "2.2"), c.setAttribute("fill", o), c.setAttribute("font-family", "var(--om-carto-font)"), c.setAttribute("text-anchor", l.edge === "left" ? "end" : "middle"), c.textContent = l.text, s.appendChild(c);
|
|
2515
2596
|
}
|
|
2516
|
-
this.replaceChildren(
|
|
2597
|
+
this.replaceChildren(s);
|
|
2517
2598
|
}
|
|
2518
2599
|
/** Intersections of this line with the perpendicular family. */
|
|
2519
2600
|
tickPoints(t, e, n) {
|
|
2520
2601
|
if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
|
|
2521
|
-
const i = n.lines.filter((
|
|
2522
|
-
for (const
|
|
2523
|
-
const a =
|
|
2524
|
-
a &&
|
|
2602
|
+
const i = n.lines.filter((o) => o.axis !== t.axis), s = [];
|
|
2603
|
+
for (const o of i) {
|
|
2604
|
+
const a = Yn(t.points, o.points);
|
|
2605
|
+
a && s.push(a);
|
|
2525
2606
|
}
|
|
2526
|
-
return
|
|
2607
|
+
return s;
|
|
2527
2608
|
}
|
|
2528
2609
|
paintCartograph(t, e) {
|
|
2529
2610
|
const n = this.graticule;
|
|
2530
2611
|
if (!n) return;
|
|
2531
|
-
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null,
|
|
2532
|
-
t.save(), t.strokeStyle =
|
|
2612
|
+
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = I(i?.color) ?? "#ffffff", o = (l) => l * e.pxPerMm, a = this.kind;
|
|
2613
|
+
t.save(), t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(0.15);
|
|
2533
2614
|
for (const l of n.lines)
|
|
2534
2615
|
if (a === "solid")
|
|
2535
|
-
t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(
|
|
2616
|
+
t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(o(c.xMm), o(c.yMm)) : t.lineTo(o(c.xMm), o(c.yMm))), t.stroke();
|
|
2536
2617
|
else
|
|
2537
2618
|
for (const c of this.tickPoints(l, a, n))
|
|
2538
|
-
t.beginPath(), t.moveTo(
|
|
2539
|
-
t.font = `${
|
|
2619
|
+
t.beginPath(), t.moveTo(o(c.xMm - j), o(c.yMm)), t.lineTo(o(c.xMm + j), o(c.yMm)), t.moveTo(o(c.xMm), o(c.yMm - j)), t.lineTo(o(c.xMm), o(c.yMm + j)), t.stroke();
|
|
2620
|
+
t.font = `${o(2.2)}px ${i?.fontFamily || "system-ui, sans-serif"}`, t.textBaseline = "alphabetic";
|
|
2540
2621
|
for (const l of n.labels)
|
|
2541
|
-
t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text,
|
|
2622
|
+
t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text, o(l.xMm), o(l.yMm));
|
|
2542
2623
|
t.restore();
|
|
2543
2624
|
}
|
|
2544
2625
|
}
|
|
2545
|
-
function
|
|
2626
|
+
function Yn(r, t) {
|
|
2546
2627
|
let e = null, n = Number.POSITIVE_INFINITY;
|
|
2547
2628
|
for (const i of r)
|
|
2548
|
-
for (const
|
|
2549
|
-
const
|
|
2550
|
-
|
|
2629
|
+
for (const s of t) {
|
|
2630
|
+
const o = (i.xMm - s.xMm) ** 2 + (i.yMm - s.yMm) ** 2;
|
|
2631
|
+
o < n && (n = o, e = i);
|
|
2551
2632
|
}
|
|
2552
2633
|
return n <= 1 ? e : null;
|
|
2553
2634
|
}
|
|
2554
|
-
|
|
2555
|
-
function
|
|
2635
|
+
x("om-graticule", ur);
|
|
2636
|
+
function Xn(r, t) {
|
|
2556
2637
|
if (r == null || typeof r != "object") return;
|
|
2557
2638
|
const e = r.properties;
|
|
2558
2639
|
return e && t in e ? e[t] : r[t];
|
|
2559
2640
|
}
|
|
2560
|
-
function
|
|
2641
|
+
function jt(r, t) {
|
|
2561
2642
|
if (Array.isArray(r)) {
|
|
2562
2643
|
if (typeof r[0] == "number") {
|
|
2563
2644
|
t.push([r[0], r[1]]);
|
|
2564
2645
|
return;
|
|
2565
2646
|
}
|
|
2566
|
-
for (const e of r)
|
|
2647
|
+
for (const e of r) jt(e, t);
|
|
2567
2648
|
}
|
|
2568
2649
|
}
|
|
2569
|
-
function
|
|
2650
|
+
function Jn(r) {
|
|
2570
2651
|
return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
|
|
2571
2652
|
}
|
|
2572
|
-
function
|
|
2573
|
-
return
|
|
2653
|
+
function F(r, t) {
|
|
2654
|
+
return Xn(r, t);
|
|
2574
2655
|
}
|
|
2575
|
-
function
|
|
2656
|
+
function Gt(r) {
|
|
2576
2657
|
const t = {}, e = (i) => {
|
|
2577
|
-
for (const [
|
|
2578
|
-
|
|
2658
|
+
for (const [s, o] of Object.entries(i))
|
|
2659
|
+
o == null || typeof o == "object" || (t[s] = String(o));
|
|
2579
2660
|
};
|
|
2580
2661
|
e(r);
|
|
2581
2662
|
const n = r.properties;
|
|
2582
2663
|
return n && typeof n == "object" && e(n), t;
|
|
2583
2664
|
}
|
|
2584
|
-
function
|
|
2665
|
+
function Zn(r) {
|
|
2585
2666
|
let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
|
|
2586
|
-
const
|
|
2587
|
-
if (
|
|
2588
|
-
else if (Array.isArray(r.coordinates))
|
|
2667
|
+
const s = [], o = r.geometry;
|
|
2668
|
+
if (o?.coordinates != null) jt(o.coordinates, s);
|
|
2669
|
+
else if (Array.isArray(r.coordinates)) jt(r.coordinates, s);
|
|
2589
2670
|
else {
|
|
2590
|
-
const a = Number(
|
|
2591
|
-
Number.isFinite(a) && Number.isFinite(l) &&
|
|
2671
|
+
const a = Number(F(r, "lng") ?? F(r, "longitude") ?? F(r, "lon") ?? F(r, "x")), l = Number(F(r, "lat") ?? F(r, "latitude") ?? F(r, "y"));
|
|
2672
|
+
Number.isFinite(a) && Number.isFinite(l) && s.push([a, l]);
|
|
2592
2673
|
}
|
|
2593
|
-
for (const [a, l] of
|
|
2674
|
+
for (const [a, l] of s)
|
|
2594
2675
|
!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));
|
|
2595
2676
|
return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
|
|
2596
2677
|
}
|
|
2597
|
-
function
|
|
2598
|
-
const [e, n, i,
|
|
2599
|
-
return [e - l, n - c, i + l,
|
|
2600
|
-
}
|
|
2601
|
-
const
|
|
2602
|
-
function
|
|
2603
|
-
let n = t ? r.filter((
|
|
2604
|
-
const i =
|
|
2605
|
-
return i.length > 0 && (n = [...n].sort((
|
|
2678
|
+
function Qn(r, t) {
|
|
2679
|
+
const [e, n, i, s] = r, o = Math.max(i - e, 1e-4), a = Math.max(s - n, 1e-4), l = o * t, c = a * t;
|
|
2680
|
+
return [e - l, n - c, i + l, s + c];
|
|
2681
|
+
}
|
|
2682
|
+
const Fi = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
|
|
2683
|
+
function ti({ features: r, filter: t, sort: e }) {
|
|
2684
|
+
let n = t ? r.filter((s) => ei(t, s)) : [...r];
|
|
2685
|
+
const i = ri(e);
|
|
2686
|
+
return i.length > 0 && (n = [...n].sort((s, o) => {
|
|
2606
2687
|
for (const { field: a, descending: l } of i) {
|
|
2607
|
-
const c =
|
|
2688
|
+
const c = F(s, a), u = F(o, a);
|
|
2608
2689
|
if (c == null && u == null) continue;
|
|
2609
2690
|
if (c == null) return 1;
|
|
2610
2691
|
if (u == null) return -1;
|
|
2611
|
-
const
|
|
2612
|
-
if (
|
|
2692
|
+
const h = ni(c, u);
|
|
2693
|
+
if (h !== 0) return l ? -h : h;
|
|
2613
2694
|
}
|
|
2614
2695
|
return 0;
|
|
2615
2696
|
})), n;
|
|
2616
2697
|
}
|
|
2617
|
-
function
|
|
2698
|
+
function ei(r, t) {
|
|
2618
2699
|
try {
|
|
2619
2700
|
return !!r(t);
|
|
2620
2701
|
} catch {
|
|
2621
2702
|
return !1;
|
|
2622
2703
|
}
|
|
2623
2704
|
}
|
|
2624
|
-
function
|
|
2705
|
+
function ri(r) {
|
|
2625
2706
|
return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
|
|
2626
2707
|
}
|
|
2627
|
-
function
|
|
2708
|
+
function ni(r, t) {
|
|
2628
2709
|
return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
|
|
2629
2710
|
}
|
|
2630
|
-
function
|
|
2711
|
+
function ii(r) {
|
|
2631
2712
|
const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
|
|
2632
2713
|
return t === "" ? "page" : t;
|
|
2633
2714
|
}
|
|
2634
|
-
function
|
|
2715
|
+
function si(r, t, e) {
|
|
2635
2716
|
const n = /* @__PURE__ */ new Map();
|
|
2636
|
-
return t.map((i,
|
|
2637
|
-
const
|
|
2717
|
+
return t.map((i, s) => {
|
|
2718
|
+
const o = Gt(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, h) => h === "index" ? String(s + 1) : h === "count" ? String(t.length) : o[h] ?? u), l = ii(a), c = n.get(l) ?? 0;
|
|
2638
2719
|
return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
|
|
2639
2720
|
});
|
|
2640
2721
|
}
|
|
2641
|
-
const
|
|
2642
|
-
class
|
|
2722
|
+
const Le = "data-om-carto-pager", oi = "data-om-carto-screen-only", ai = "onlymap-cartograph", li = "onlymap-cartograph-host";
|
|
2723
|
+
class hr extends O {
|
|
2643
2724
|
static observedAttributes = [...T["om-atlas"]];
|
|
2644
2725
|
/**
|
|
2645
2726
|
* Pages are SNAPSHOTTED when iteration first starts. A streaming or polling
|
|
@@ -2689,7 +2770,7 @@ class ar extends O {
|
|
|
2689
2770
|
*/
|
|
2690
2771
|
onHostMessage = (t) => {
|
|
2691
2772
|
const e = t.data;
|
|
2692
|
-
!e || e.source !==
|
|
2773
|
+
!e || e.source !== li || e.type !== "atlas-seek" || typeof e.index == "number" && Number.isInteger(e.index) && this.seek(e.index);
|
|
2693
2774
|
};
|
|
2694
2775
|
/** The frame whose layer drives the iteration — the same `for=` rule every furniture element follows. */
|
|
2695
2776
|
get frame() {
|
|
@@ -2710,16 +2791,16 @@ class ar extends O {
|
|
|
2710
2791
|
}
|
|
2711
2792
|
/** Export filenames, one per page, already de-duplicated. */
|
|
2712
2793
|
filenames(t = "png") {
|
|
2713
|
-
return
|
|
2794
|
+
return si(this.getAttribute("filename"), this.ensurePages(), t);
|
|
2714
2795
|
}
|
|
2715
2796
|
/** Human page labels, for an editor's stepper and PDF bookmarks. */
|
|
2716
2797
|
pageName(t) {
|
|
2717
2798
|
const e = this.ensurePages()[t];
|
|
2718
2799
|
if (!e) return `Page ${t + 1}`;
|
|
2719
|
-
const n =
|
|
2800
|
+
const n = Gt(e), i = this.getAttribute("page-name");
|
|
2720
2801
|
return i ? i.replace(
|
|
2721
2802
|
/\{\{\s*atlas\.([\w]+)\s*\}\}/g,
|
|
2722
|
-
(
|
|
2803
|
+
(s, o) => o === "index" ? String(t + 1) : o === "count" ? String(this.count) : n[o] ?? s
|
|
2723
2804
|
) : n.name ?? n.title ?? `Page ${t + 1}`;
|
|
2724
2805
|
}
|
|
2725
2806
|
/**
|
|
@@ -2734,11 +2815,11 @@ class ar extends O {
|
|
|
2734
2815
|
}
|
|
2735
2816
|
ensurePages() {
|
|
2736
2817
|
if (this.pages) return this.pages;
|
|
2737
|
-
const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n),
|
|
2738
|
-
if (!e ||
|
|
2739
|
-
return this.rejection = e ?
|
|
2740
|
-
const
|
|
2741
|
-
return this.pages =
|
|
2818
|
+
const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? Jn(i) : null;
|
|
2819
|
+
if (!e || s)
|
|
2820
|
+
return this.rejection = e ? s : null, this.pages = [];
|
|
2821
|
+
const o = this.materialize(i);
|
|
2822
|
+
return this.pages = ti({ features: o, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
|
|
2742
2823
|
}
|
|
2743
2824
|
/**
|
|
2744
2825
|
* Rows from the layer, with the layer's OWN declarative filters applied —
|
|
@@ -2748,11 +2829,11 @@ class ar extends O {
|
|
|
2748
2829
|
materialize(t) {
|
|
2749
2830
|
const e = J(), n = t.data;
|
|
2750
2831
|
if (!n) return [];
|
|
2751
|
-
const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [],
|
|
2752
|
-
return
|
|
2753
|
-
(
|
|
2832
|
+
const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [], s = [t.filter, t.categoryFilter].filter(Boolean);
|
|
2833
|
+
return s.length === 0 ? i : i.filter(
|
|
2834
|
+
(o) => s.every((a) => {
|
|
2754
2835
|
if (!a.field) return !0;
|
|
2755
|
-
const l =
|
|
2836
|
+
const l = F(o, a.field);
|
|
2756
2837
|
if (a.range) {
|
|
2757
2838
|
const c = Number(l);
|
|
2758
2839
|
return Number.isFinite(c) && c >= a.range[0] && c <= a.range[1];
|
|
@@ -2787,14 +2868,14 @@ class ar extends O {
|
|
|
2787
2868
|
const t = this.current;
|
|
2788
2869
|
if (!t) return;
|
|
2789
2870
|
const e = this.closest("om-cartograph");
|
|
2790
|
-
for (const
|
|
2791
|
-
if (
|
|
2792
|
-
const
|
|
2793
|
-
if (!
|
|
2794
|
-
const a = Number(
|
|
2795
|
-
|
|
2796
|
-
}
|
|
2797
|
-
e?.setAtlasFields({ ...
|
|
2871
|
+
for (const s of e?.querySelectorAll("om-frame") ?? []) {
|
|
2872
|
+
if (s.getAttribute("atlas-fit") !== "feature") continue;
|
|
2873
|
+
const o = Zn(t);
|
|
2874
|
+
if (!o) continue;
|
|
2875
|
+
const a = Number(s.getAttribute("atlas-margin")), l = Qn(o, Number.isFinite(a) && a > 0 ? a : 0.15);
|
|
2876
|
+
s.fitBounds?.(l);
|
|
2877
|
+
}
|
|
2878
|
+
e?.setAtlasFields({ ...Gt(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture();
|
|
2798
2879
|
const n = this.pageName(this.currentIndex);
|
|
2799
2880
|
this.dispatchEvent(
|
|
2800
2881
|
new CustomEvent("om-atlas-page", {
|
|
@@ -2803,7 +2884,7 @@ class ar extends O {
|
|
|
2803
2884
|
})
|
|
2804
2885
|
), this.renderPager();
|
|
2805
2886
|
const i = typeof window < "u" ? window.parent : null;
|
|
2806
|
-
i && i !== window && i.postMessage({ source:
|
|
2887
|
+
i && i !== window && i.postMessage({ source: ai, type: "atlas-page", index: this.currentIndex, count: this.count, name: n }, "*");
|
|
2807
2888
|
}
|
|
2808
2889
|
/**
|
|
2809
2890
|
* Draw (or update) the reader's page control on the owning sheet:
|
|
@@ -2814,30 +2895,30 @@ class ar extends O {
|
|
|
2814
2895
|
renderPager() {
|
|
2815
2896
|
const t = this.closest("om-cartograph");
|
|
2816
2897
|
if (!t) return;
|
|
2817
|
-
const e = t.querySelector(`:scope > [${
|
|
2898
|
+
const e = t.querySelector(`:scope > [${Le}]`), n = this.count;
|
|
2818
2899
|
if (this.getAttribute("pager") === "none" || n === 0) {
|
|
2819
2900
|
e?.remove(), this.pager = null;
|
|
2820
2901
|
return;
|
|
2821
2902
|
}
|
|
2822
|
-
const i = this.ownerDocument,
|
|
2903
|
+
const i = this.ownerDocument, s = e ?? i.createElement("div");
|
|
2823
2904
|
if (!e) {
|
|
2824
|
-
|
|
2825
|
-
for (const [u,
|
|
2905
|
+
s.setAttribute(Le, ""), s.setAttribute(oi, ""), s.setAttribute("role", "navigation"), s.setAttribute("aria-label", "Atlas pages"), s.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;";
|
|
2906
|
+
for (const [u, h, d] of [
|
|
2826
2907
|
[-1, "‹", "Previous page"],
|
|
2827
2908
|
[1, "›", "Next page"]
|
|
2828
2909
|
]) {
|
|
2829
|
-
const
|
|
2830
|
-
|
|
2910
|
+
const m = i.createElement("button");
|
|
2911
|
+
m.type = "button", m.setAttribute("data-om-carto-pager-step", String(u)), m.setAttribute("aria-label", d), m.textContent = h, m.style.cssText = "all:unset;cursor:pointer;padding:0 6px;font-size:16px;line-height:1;color:inherit;", m.addEventListener("click", () => this.seek(this.currentIndex + u)), s.appendChild(m);
|
|
2831
2912
|
}
|
|
2832
2913
|
const c = i.createElement("span");
|
|
2833
|
-
c.setAttribute("data-om-carto-pager-label", ""),
|
|
2914
|
+
c.setAttribute("data-om-carto-pager-label", ""), s.insertBefore(c, s.lastElementChild), t.appendChild(s);
|
|
2834
2915
|
}
|
|
2835
|
-
const
|
|
2836
|
-
|
|
2837
|
-
const [a, l] =
|
|
2916
|
+
const o = s.querySelector("[data-om-carto-pager-label]");
|
|
2917
|
+
o.textContent = `${this.currentIndex + 1} / ${n} · ${this.pageName(this.currentIndex)}`;
|
|
2918
|
+
const [a, l] = s.querySelectorAll("button");
|
|
2838
2919
|
a && (a.disabled = this.currentIndex === 0), l && (l.disabled = this.currentIndex >= n - 1);
|
|
2839
2920
|
for (const c of [a, l]) c && (c.style.opacity = c.disabled ? ".35" : "1");
|
|
2840
|
-
this.pager =
|
|
2921
|
+
this.pager = s;
|
|
2841
2922
|
}
|
|
2842
2923
|
connectedCallback() {
|
|
2843
2924
|
super.connectedCallback(), this.ownerDocument.addEventListener("keydown", this.onKeyDown), typeof window < "u" && window.addEventListener("message", this.onHostMessage);
|
|
@@ -2853,8 +2934,8 @@ class ar extends O {
|
|
|
2853
2934
|
this.style.display = "none", this.refresh();
|
|
2854
2935
|
}
|
|
2855
2936
|
}
|
|
2856
|
-
|
|
2857
|
-
class
|
|
2937
|
+
x("om-atlas", hr);
|
|
2938
|
+
class ci extends Ge {
|
|
2858
2939
|
static observedAttributes = [...T["om-source"]];
|
|
2859
2940
|
connectedCallback() {
|
|
2860
2941
|
this.style.display = "none";
|
|
@@ -2868,8 +2949,8 @@ class ri extends De {
|
|
|
2868
2949
|
this.closest("om-frame")?.scheduleRender?.();
|
|
2869
2950
|
}
|
|
2870
2951
|
}
|
|
2871
|
-
const
|
|
2872
|
-
function
|
|
2952
|
+
const ui = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), hi = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), mi = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], di = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), fi = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), pi = 0.02, gi = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
|
|
2953
|
+
function mr(r) {
|
|
2873
2954
|
const t = r.tagName.toLowerCase();
|
|
2874
2955
|
return r.id ? `${t}#${r.id}` : t;
|
|
2875
2956
|
}
|
|
@@ -2879,97 +2960,97 @@ function H(r, t) {
|
|
|
2879
2960
|
const n = Number(e);
|
|
2880
2961
|
return Number.isFinite(n) ? n : null;
|
|
2881
2962
|
}
|
|
2882
|
-
function
|
|
2963
|
+
function bi(r, t) {
|
|
2883
2964
|
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;
|
|
2884
2965
|
}
|
|
2885
|
-
function
|
|
2966
|
+
function yi(r, t) {
|
|
2886
2967
|
const e = r.getAttribute("style");
|
|
2887
2968
|
if (!e) return null;
|
|
2888
2969
|
const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
|
|
2889
2970
|
return n ? Number(n[1]) : null;
|
|
2890
2971
|
}
|
|
2891
|
-
function
|
|
2892
|
-
const t = [], e = (
|
|
2893
|
-
t.push({ severity:
|
|
2972
|
+
function dr(r) {
|
|
2973
|
+
const t = [], e = (o, a, l, c, u) => {
|
|
2974
|
+
t.push({ severity: o, element: mr(a), ...u ? { attribute: u } : {}, message: l, fix: c });
|
|
2894
2975
|
}, n = [...r.querySelectorAll("om-cartograph")];
|
|
2895
2976
|
if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
|
|
2896
2977
|
return { valid: !0, errors: [], warnings: [] };
|
|
2897
|
-
for (const
|
|
2898
|
-
const i = t.filter((
|
|
2899
|
-
return { valid: i.length === 0, errors: i, warnings:
|
|
2978
|
+
for (const o of n) wi(o, e);
|
|
2979
|
+
const i = t.filter((o) => o.severity === "error"), s = t.filter((o) => o.severity === "warning");
|
|
2980
|
+
return { valid: i.length === 0, errors: i, warnings: s };
|
|
2900
2981
|
}
|
|
2901
|
-
function
|
|
2982
|
+
function wi(r, t) {
|
|
2902
2983
|
const e = r.getAttribute("size"), n = H(r, "width") != null && H(r, "height") != null;
|
|
2903
|
-
e && !
|
|
2984
|
+
e && !se.includes(e) && !n && t(
|
|
2904
2985
|
"error",
|
|
2905
2986
|
r,
|
|
2906
2987
|
`Unknown page size "${e}" and no width/height to fall back on.`,
|
|
2907
|
-
`Use one of ${
|
|
2988
|
+
`Use one of ${se.join(", ")}, or give width= and height= in millimetres.`,
|
|
2908
2989
|
"size"
|
|
2909
2990
|
);
|
|
2910
2991
|
const i = r.getAttribute("cvd");
|
|
2911
|
-
i && i.trim().toLowerCase() !== "none" && !
|
|
2912
|
-
const
|
|
2913
|
-
if (
|
|
2914
|
-
const
|
|
2915
|
-
|
|
2916
|
-
}
|
|
2917
|
-
const
|
|
2918
|
-
|
|
2919
|
-
const { widthMm: a, heightMm: l } =
|
|
2920
|
-
for (const
|
|
2921
|
-
|
|
2922
|
-
for (const
|
|
2923
|
-
if (
|
|
2924
|
-
const f =
|
|
2925
|
-
!
|
|
2992
|
+
i && i.trim().toLowerCase() !== "none" && !qt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${Mr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && gi(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");
|
|
2993
|
+
const s = H(r, "safe-zone");
|
|
2994
|
+
if (s != null && s > 0) {
|
|
2995
|
+
const m = dt(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
|
|
2996
|
+
s * 2 >= Math.min(m.widthMm, m.heightMm) && t("warning", r, `safe-zone=${s}mm leaves no usable area on a ${m.widthMm} × ${m.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
|
|
2997
|
+
}
|
|
2998
|
+
const o = r.getAttribute("format");
|
|
2999
|
+
o == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${bt}" so future runtimes can migrate this document.`, "format") : o !== bt && t("warning", r, `Unrecognised document format "${o}".`, `This build understands "${bt}".`, "format");
|
|
3000
|
+
const { widthMm: a, heightMm: l } = dt(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, H(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), h = [...r.querySelectorAll("om-frame")];
|
|
3001
|
+
for (const m of h)
|
|
3002
|
+
m.id ? u.add(m.id) : t("error", m, "Frame has no id.", "Give every frame an id so furniture can reference it with for=.", "id");
|
|
3003
|
+
for (const m of r.children) {
|
|
3004
|
+
if (mi.some((g) => m.hasAttribute(g))) continue;
|
|
3005
|
+
const f = m.tagName.toLowerCase();
|
|
3006
|
+
!yt.includes(f) && !hi.has(f) && t("error", m, `<${f}> is not a cartograph element.`, `Use one of ${yt.join(", ")}, or move this content inside an <om-text>.`);
|
|
2926
3007
|
}
|
|
2927
3008
|
const d = [];
|
|
2928
|
-
for (const
|
|
2929
|
-
const f =
|
|
2930
|
-
if (
|
|
2931
|
-
if (
|
|
2932
|
-
const g = S(
|
|
2933
|
-
|
|
3009
|
+
for (const m of [r, ...r.querySelectorAll("*")]) {
|
|
3010
|
+
const f = m.tagName.toLowerCase();
|
|
3011
|
+
if (yt.includes(f) && !m.closest("om-map")) {
|
|
3012
|
+
if (vi(m, f, t), fi.has(f)) {
|
|
3013
|
+
const g = S(m);
|
|
3014
|
+
Ai(m, g, a, l, c, t), di.has(f) && !m.hasAttribute("hidden") && d.push({ el: m, box: g });
|
|
2934
3015
|
}
|
|
2935
|
-
f === "om-frame" &&
|
|
3016
|
+
f === "om-frame" && Mi(m, t), f === "om-source" && Si(m, t), f === "om-legend" && Ci(m, h, t), f === "om-atlas" && xi(m, h, t), f === "om-scalebar" && ki(m, h, t), f === "om-text" && $i(m, h, t);
|
|
2936
3017
|
for (const g of ["for", "overview-of"]) {
|
|
2937
|
-
const p =
|
|
2938
|
-
p && !u.has(p) && t("error",
|
|
3018
|
+
const p = m.getAttribute(g);
|
|
3019
|
+
p && !u.has(p) && t("error", m, `${g}="${p}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, g);
|
|
2939
3020
|
}
|
|
2940
3021
|
}
|
|
2941
3022
|
}
|
|
2942
|
-
for (let
|
|
2943
|
-
for (let f =
|
|
2944
|
-
const g = d[
|
|
2945
|
-
g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 ||
|
|
3023
|
+
for (let m = 0; m < d.length; m++)
|
|
3024
|
+
for (let f = m + 1; f < d.length; f++) {
|
|
3025
|
+
const g = d[m], p = d[f];
|
|
3026
|
+
g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || bi(g.box, p.box) && t(
|
|
2946
3027
|
"warning",
|
|
2947
3028
|
g.el,
|
|
2948
|
-
`Overlaps ${
|
|
3029
|
+
`Overlaps ${mr(p.el)} on the page.`,
|
|
2949
3030
|
"Move one of them — furniture overlapping furniture usually means a stale layout (frames may sit under anything)."
|
|
2950
3031
|
);
|
|
2951
3032
|
}
|
|
2952
3033
|
}
|
|
2953
|
-
function
|
|
3034
|
+
function vi(r, t, e) {
|
|
2954
3035
|
const n = new Set(T[t] ?? []);
|
|
2955
3036
|
for (const i of r.attributes) {
|
|
2956
|
-
const
|
|
2957
|
-
if (n.has(
|
|
2958
|
-
const
|
|
2959
|
-
if (
|
|
2960
|
-
e("warning", r, `Attribute "${
|
|
3037
|
+
const s = i.name.toLowerCase();
|
|
3038
|
+
if (n.has(s) || ui.has(s) || s.startsWith("data-") || s.startsWith("aria-")) continue;
|
|
3039
|
+
const o = Ur.get(s);
|
|
3040
|
+
if (o) {
|
|
3041
|
+
e("warning", r, `Attribute "${s}" has no effect: ${o}`, "Remove it, or use the documented alternative.", s);
|
|
2961
3042
|
continue;
|
|
2962
3043
|
}
|
|
2963
|
-
e("warning", r, `Unknown attribute "${
|
|
3044
|
+
e("warning", r, `Unknown attribute "${s}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, s);
|
|
2964
3045
|
}
|
|
2965
3046
|
}
|
|
2966
|
-
function
|
|
3047
|
+
function Ai(r, t, e, n, i, s) {
|
|
2967
3048
|
if (t.w <= 0 || t.h <= 0) {
|
|
2968
|
-
|
|
3049
|
+
s("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");
|
|
2969
3050
|
return;
|
|
2970
3051
|
}
|
|
2971
|
-
const
|
|
2972
|
-
(t.x <
|
|
3052
|
+
const o = -i, a = e + i, l = n + i;
|
|
3053
|
+
(t.x < o || t.y < o || t.x + t.w > a + 1e-6 || t.y + t.h > l + 1e-6) && s(
|
|
2973
3054
|
"error",
|
|
2974
3055
|
r,
|
|
2975
3056
|
`Element box (${t.x}, ${t.y}, ${t.w} × ${t.h} mm) falls outside the ${e} × ${n} mm page${i ? ` (+${i}mm bleed)` : ""}.`,
|
|
@@ -2981,18 +3062,18 @@ function fi(r, t, e, n, i, o) {
|
|
|
2981
3062
|
["width", t.w],
|
|
2982
3063
|
["height", t.h]
|
|
2983
3064
|
];
|
|
2984
|
-
for (const [u,
|
|
2985
|
-
const d =
|
|
2986
|
-
d != null && Math.abs(d -
|
|
3065
|
+
for (const [u, h] of c) {
|
|
3066
|
+
const d = yi(r, u);
|
|
3067
|
+
d != null && Math.abs(d - h) > 0.01 && s(
|
|
2987
3068
|
"error",
|
|
2988
3069
|
r,
|
|
2989
|
-
`Inline style ${u}:${d}mm disagrees with the placement attribute (${
|
|
3070
|
+
`Inline style ${u}:${d}mm disagrees with the placement attribute (${h}mm).`,
|
|
2990
3071
|
"The attributes are authoritative — make the inline style match, or drop it and let the runtime write it.",
|
|
2991
3072
|
"style"
|
|
2992
3073
|
);
|
|
2993
3074
|
}
|
|
2994
3075
|
}
|
|
2995
|
-
function
|
|
3076
|
+
function Mi(r, t) {
|
|
2996
3077
|
if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
|
|
2997
3078
|
const n = r.getAttribute("corners"), i = X(n);
|
|
2998
3079
|
i || t(
|
|
@@ -3001,20 +3082,20 @@ function pi(r, t) {
|
|
|
3001
3082
|
n == null ? "Static frame has no corners=." : `Static frame has malformed corners= ("${n}").`,
|
|
3002
3083
|
'Give four lon/lat pairs in tl, tr, br, bl order — corners="[[lng,lat],[lng,lat],[lng,lat],[lng,lat]]".',
|
|
3003
3084
|
"corners"
|
|
3004
|
-
), !r.querySelector(":scope > img") && !r.querySelector(`:scope > svg[${
|
|
3085
|
+
), !r.querySelector(":scope > img") && !r.querySelector(`:scope > svg[${Lt}]`) && t(
|
|
3005
3086
|
"error",
|
|
3006
3087
|
r,
|
|
3007
3088
|
"Static frame has no <img> or inline <svg> child to place.",
|
|
3008
3089
|
'Add the georeferenced picture as a child — an <img> raster, or the inline <svg> that snapshot({format: "svg"}) produces.'
|
|
3009
3090
|
);
|
|
3010
|
-
const
|
|
3011
|
-
if (i &&
|
|
3012
|
-
const a = tt({ corners: i, widthMm:
|
|
3091
|
+
const s = S(r), o = Y(r.getAttribute("crs"));
|
|
3092
|
+
if (i && o && s.w > 0 && s.h > 0) {
|
|
3093
|
+
const a = tt({ corners: i, widthMm: s.w, heightMm: s.h, crsForward: o });
|
|
3013
3094
|
if (a.degenerate)
|
|
3014
3095
|
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");
|
|
3015
3096
|
else {
|
|
3016
|
-
const l =
|
|
3017
|
-
l != null && l >
|
|
3097
|
+
const l = An(a);
|
|
3098
|
+
l != null && l > pi && t(
|
|
3018
3099
|
"warning",
|
|
3019
3100
|
r,
|
|
3020
3101
|
`Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
|
|
@@ -3023,7 +3104,7 @@ function pi(r, t) {
|
|
|
3023
3104
|
}
|
|
3024
3105
|
}
|
|
3025
3106
|
} else {
|
|
3026
|
-
|
|
3107
|
+
mt(r) || t(
|
|
3027
3108
|
"error",
|
|
3028
3109
|
r,
|
|
3029
3110
|
"Live frame has no valid camera.",
|
|
@@ -3069,7 +3150,7 @@ function pi(r, t) {
|
|
|
3069
3150
|
);
|
|
3070
3151
|
}
|
|
3071
3152
|
}
|
|
3072
|
-
function
|
|
3153
|
+
function Si(r, t) {
|
|
3073
3154
|
const e = r.parentElement;
|
|
3074
3155
|
if (e?.tagName.toLowerCase() !== "om-frame") {
|
|
3075
3156
|
t(
|
|
@@ -3085,7 +3166,7 @@ function gi(r, t) {
|
|
|
3085
3166
|
t("error", r, "<om-source> has no src=.", "Give it a map document (.html) or a capture image.", "src");
|
|
3086
3167
|
return;
|
|
3087
3168
|
}
|
|
3088
|
-
const i =
|
|
3169
|
+
const i = Dt(n);
|
|
3089
3170
|
if (!i) {
|
|
3090
3171
|
t(
|
|
3091
3172
|
"error",
|
|
@@ -3097,22 +3178,22 @@ function gi(r, t) {
|
|
|
3097
3178
|
return;
|
|
3098
3179
|
}
|
|
3099
3180
|
if (i === "raster") {
|
|
3100
|
-
const
|
|
3101
|
-
X(
|
|
3181
|
+
const s = r.getAttribute("corners");
|
|
3182
|
+
X(s) || t(
|
|
3102
3183
|
"error",
|
|
3103
3184
|
r,
|
|
3104
|
-
|
|
3185
|
+
s == 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= ("${s}").`,
|
|
3105
3186
|
'Give four lon/lat pairs in tl, tr, br, bl order — corners="[[lng,lat],[lng,lat],[lng,lat],[lng,lat]]". These are the coordinates that were true when the capture was taken.',
|
|
3106
3187
|
"corners"
|
|
3107
3188
|
);
|
|
3108
3189
|
} else
|
|
3109
|
-
for (const
|
|
3110
|
-
r.hasAttribute(
|
|
3190
|
+
for (const s of ["corners", "crs", "crs-def"])
|
|
3191
|
+
r.hasAttribute(s) && t(
|
|
3111
3192
|
"warning",
|
|
3112
3193
|
r,
|
|
3113
|
-
`${
|
|
3194
|
+
`${s}= is ignored on a map-document <om-source> — a map carries its own projection and its corners come from the frame's camera.`,
|
|
3114
3195
|
"Remove it. It belongs on a capture <om-source>, whose georeference is otherwise unknowable.",
|
|
3115
|
-
|
|
3196
|
+
s
|
|
3116
3197
|
);
|
|
3117
3198
|
e.getAttribute("mode") === "static" && t(
|
|
3118
3199
|
"warning",
|
|
@@ -3121,12 +3202,12 @@ function gi(r, t) {
|
|
|
3121
3202
|
'Remove mode="static" to let the frame resolve its sources, or drop the <om-source>.'
|
|
3122
3203
|
);
|
|
3123
3204
|
}
|
|
3124
|
-
function
|
|
3205
|
+
function Yt(r, t) {
|
|
3125
3206
|
const e = r.getAttribute("for");
|
|
3126
3207
|
return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
|
|
3127
3208
|
}
|
|
3128
|
-
function
|
|
3129
|
-
const n = r.getAttribute("derived") !== "false", i =
|
|
3209
|
+
function Ci(r, t, e) {
|
|
3210
|
+
const n = r.getAttribute("derived") !== "false", i = Yt(r, t);
|
|
3130
3211
|
n && i?.getAttribute("mode") === "static" && e(
|
|
3131
3212
|
"warning",
|
|
3132
3213
|
r,
|
|
@@ -3134,30 +3215,30 @@ function bi(r, t, e) {
|
|
|
3134
3215
|
'Write the rows as <om-legend-row color= label= shape=> children and set derived="false".',
|
|
3135
3216
|
"derived"
|
|
3136
3217
|
);
|
|
3137
|
-
const
|
|
3138
|
-
if (
|
|
3139
|
-
const
|
|
3140
|
-
if (
|
|
3141
|
-
const a =
|
|
3218
|
+
const s = lr(r);
|
|
3219
|
+
if (s.length < 2) return;
|
|
3220
|
+
const o = xr(s.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
|
|
3221
|
+
if (o.collapses.length > 0 && o.worstType) {
|
|
3222
|
+
const a = o.collapses.filter((c) => c.type === o.worstType), l = a.slice(0, 3).map((c) => `"${c.a.label}"/"${c.b.label}"`).join(", ");
|
|
3142
3223
|
e(
|
|
3143
3224
|
"warning",
|
|
3144
3225
|
r,
|
|
3145
|
-
`Under ${
|
|
3226
|
+
`Under ${o.worstType}, ${a.length === 1 ? "one legend pair becomes" : `${a.length} legend pairs become`} indistinguishable: ${l}.`,
|
|
3146
3227
|
"Pick colours that differ in lightness as well as hue, or add a pattern or label to separate them."
|
|
3147
3228
|
);
|
|
3148
3229
|
}
|
|
3149
3230
|
}
|
|
3150
|
-
function
|
|
3231
|
+
function xi(r, t, e) {
|
|
3151
3232
|
const n = r.getAttribute("pager");
|
|
3152
3233
|
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");
|
|
3153
3234
|
const i = r.getAttribute("layer");
|
|
3154
3235
|
i || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
|
|
3155
|
-
const
|
|
3156
|
-
if (!
|
|
3157
|
-
!
|
|
3236
|
+
const s = r.getAttribute("for"), o = Yt(r, t);
|
|
3237
|
+
if (!o) {
|
|
3238
|
+
!s && t.length !== 1 && e("error", r, `Atlas does not say which frame drives it, and the page has ${t.length} frames.`, 'Add for="<frame id>".', "for");
|
|
3158
3239
|
return;
|
|
3159
3240
|
}
|
|
3160
|
-
if (
|
|
3241
|
+
if (o.getAttribute("mode") === "static") {
|
|
3161
3242
|
e(
|
|
3162
3243
|
"error",
|
|
3163
3244
|
r,
|
|
@@ -3167,11 +3248,11 @@ function yi(r, t, e) {
|
|
|
3167
3248
|
);
|
|
3168
3249
|
return;
|
|
3169
3250
|
}
|
|
3170
|
-
const a =
|
|
3251
|
+
const a = o.querySelector(":scope > om-map");
|
|
3171
3252
|
if (a && i) {
|
|
3172
3253
|
const l = [...a.querySelectorAll("om-layer")].find((u) => u.id === i);
|
|
3173
3254
|
if (!l) {
|
|
3174
|
-
e("error", r, `Atlas layer "${i}" is not in frame #${
|
|
3255
|
+
e("error", r, `Atlas layer "${i}" is not in frame #${o.id}'s map.`, "Check the layer id, or point the atlas at the frame that has it.", "layer");
|
|
3175
3256
|
return;
|
|
3176
3257
|
}
|
|
3177
3258
|
const c = l.getAttribute("data") ?? "";
|
|
@@ -3184,14 +3265,14 @@ function yi(r, t, e) {
|
|
|
3184
3265
|
);
|
|
3185
3266
|
}
|
|
3186
3267
|
}
|
|
3187
|
-
function
|
|
3268
|
+
function ki(r, t, e) {
|
|
3188
3269
|
const n = H(r, "segment-length");
|
|
3189
3270
|
if (n == null) return;
|
|
3190
|
-
const i =
|
|
3271
|
+
const i = Yt(r, t);
|
|
3191
3272
|
if (!i) return;
|
|
3192
|
-
const
|
|
3193
|
-
if (!
|
|
3194
|
-
const l = tt({ corners:
|
|
3273
|
+
const s = X(i.getAttribute("corners")), o = Y(i.getAttribute("crs")), a = S(i);
|
|
3274
|
+
if (!s || !o || a.w <= 0 || a.h <= 0) return;
|
|
3275
|
+
const l = tt({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = S(r), u = Be({
|
|
3195
3276
|
groundMetersPerMm: l.groundMetersPerMm(),
|
|
3196
3277
|
maxWidthMm: c.w,
|
|
3197
3278
|
segments: H(r, "segments") ?? void 0,
|
|
@@ -3205,148 +3286,148 @@ function wi(r, t, e) {
|
|
|
3205
3286
|
"segment-length"
|
|
3206
3287
|
);
|
|
3207
3288
|
}
|
|
3208
|
-
function
|
|
3209
|
-
const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]),
|
|
3210
|
-
for (const
|
|
3211
|
-
if (!
|
|
3212
|
-
if (
|
|
3213
|
-
const a =
|
|
3214
|
-
|
|
3289
|
+
function $i(r, t, e) {
|
|
3290
|
+
const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), s = new Set(t.map((o) => o.id).filter(Boolean));
|
|
3291
|
+
for (const o of Hr(n))
|
|
3292
|
+
if (!o.startsWith("atlas.")) {
|
|
3293
|
+
if (o.startsWith("frame.")) {
|
|
3294
|
+
const a = o.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
|
|
3295
|
+
s.has(c) ? u !== "scale" && u !== "crs" && e("warning", r, `{{${o}}} — frames provide scale and crs.`, `Use {{frame.${c}.scale}} or {{frame.${c}.crs}}.`) : e("warning", r, `{{${o}}} references no frame with id "${c}".`, `Frames on this page: ${[...s].join(", ") || "(none)"}.`);
|
|
3215
3296
|
continue;
|
|
3216
3297
|
}
|
|
3217
|
-
if ((
|
|
3298
|
+
if ((o === "scale" || o === "crs") && t.length !== 1) {
|
|
3218
3299
|
e(
|
|
3219
3300
|
"warning",
|
|
3220
3301
|
r,
|
|
3221
|
-
`{{${
|
|
3222
|
-
`Name the frame: {{frame.<id>.${
|
|
3302
|
+
`{{${o}}} is ambiguous with ${t.length} frames on the page.`,
|
|
3303
|
+
`Name the frame: {{frame.<id>.${o}}}.`
|
|
3223
3304
|
);
|
|
3224
3305
|
continue;
|
|
3225
3306
|
}
|
|
3226
|
-
i.has(
|
|
3307
|
+
i.has(o) || e("warning", r, `Unknown token {{${o}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
|
|
3227
3308
|
}
|
|
3228
3309
|
}
|
|
3229
|
-
function
|
|
3230
|
-
return
|
|
3310
|
+
function Oi(r) {
|
|
3311
|
+
return dr(Ir(r));
|
|
3231
3312
|
}
|
|
3232
|
-
async function
|
|
3233
|
-
const t =
|
|
3313
|
+
async function _i(r) {
|
|
3314
|
+
const t = dr(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
|
|
3234
3315
|
if (e.length === 0) return t;
|
|
3235
|
-
const { loadCore: n } = await Promise.resolve().then(() =>
|
|
3316
|
+
const { loadCore: n } = await Promise.resolve().then(() => yr), i = await n(), s = [...t.errors], o = [...t.warnings];
|
|
3236
3317
|
for (const a of e) {
|
|
3237
3318
|
const l = a.id ? `om-frame#${a.id}` : "om-frame", c = i.validateManifest(a);
|
|
3238
|
-
for (const u of c.errors)
|
|
3239
|
-
for (const u of c.warnings)
|
|
3319
|
+
for (const u of c.errors) s.push({ ...u, element: `${l} > ${u.element}` });
|
|
3320
|
+
for (const u of c.warnings) o.push({ ...u, element: `${l} > ${u.element}` });
|
|
3240
3321
|
}
|
|
3241
|
-
return { valid:
|
|
3322
|
+
return { valid: s.length === 0, errors: s, warnings: o };
|
|
3242
3323
|
}
|
|
3243
|
-
function
|
|
3244
|
-
|
|
3324
|
+
function Ui() {
|
|
3325
|
+
x("om-cartograph", Ze), x("om-text", Qe), x("om-frame", nr), x("om-scalebar", ir), x("om-north", sr), x("om-shape", or), x("om-image", ar), x("om-legend", cr), x("om-graticule", ur), x("om-atlas", hr), x("om-source", ci);
|
|
3245
3326
|
}
|
|
3246
|
-
|
|
3247
|
-
|
|
3327
|
+
Re(() => import("@nika-js/onlymap"));
|
|
3328
|
+
Rr();
|
|
3248
3329
|
export {
|
|
3249
3330
|
T as CARTOGRAPH_ELEMENT_ATTRS,
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3331
|
+
bt as CARTOGRAPH_FORMAT,
|
|
3332
|
+
yt as CARTOGRAPH_TAG_NAMES,
|
|
3333
|
+
Ei as CARTOGRAPH_THEMES,
|
|
3334
|
+
Cr as COLLAPSE_THRESHOLD,
|
|
3335
|
+
Wt as CVD_MATRICES,
|
|
3336
|
+
ft as CVD_TYPES,
|
|
3337
|
+
Mr as CVD_VALUES,
|
|
3338
|
+
zt as GEOGRAPHIC_PLANE,
|
|
3339
|
+
Ur as INERT_RESERVED_CARTOGRAPH_ATTRS,
|
|
3340
|
+
Ue as MAX_CANVAS_AREA,
|
|
3341
|
+
_e as MAX_CANVAS_DIMENSION,
|
|
3342
|
+
Nt as MAX_CATEGORY_ENTRIES,
|
|
3343
|
+
hr as OmAtlasElement,
|
|
3344
|
+
Ze as OmCartographElement,
|
|
3345
|
+
nr as OmFrameElement,
|
|
3346
|
+
ur as OmGraticuleElement,
|
|
3347
|
+
ar as OmImageElement,
|
|
3348
|
+
cr as OmLegendElement,
|
|
3349
|
+
sr as OmNorthElement,
|
|
3350
|
+
ir as OmScalebarElement,
|
|
3351
|
+
or as OmShapeElement,
|
|
3352
|
+
Qe as OmTextElement,
|
|
3353
|
+
Jt as PAGE_PRESETS,
|
|
3354
|
+
se as PAGE_SIZE_NAMES,
|
|
3274
3355
|
z as PLACED_ATTR_NAMES,
|
|
3275
3356
|
D as PX_PER_MM,
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3357
|
+
Br as SCALE_GROUP_SEPARATOR,
|
|
3358
|
+
Tr as URL_ACTION_TIMEOUT_MS,
|
|
3359
|
+
rn as alignOffset,
|
|
3360
|
+
Xe as allFrames,
|
|
3361
|
+
kr as applyCvdToCanvas,
|
|
3362
|
+
Yr as applyTokens,
|
|
3363
|
+
Lr as applyUrlActions,
|
|
3364
|
+
Gt as atlasFields,
|
|
3365
|
+
Fi as boundsArea,
|
|
3285
3366
|
S as boxMm,
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3367
|
+
Wn as buildGraticule,
|
|
3368
|
+
ti as buildPages,
|
|
3369
|
+
Be as buildScalebar,
|
|
3370
|
+
Wr as buildScalebarDrawing,
|
|
3290
3371
|
Y as builtinCrsForward,
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3372
|
+
Ni as canvasMeasurer,
|
|
3373
|
+
Zr as clearUnlinked,
|
|
3374
|
+
Ri as cornersFromBounds,
|
|
3375
|
+
Ut as cornersFromCamera,
|
|
3295
3376
|
tt as createFrameGeoref,
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3377
|
+
Ar as createZip,
|
|
3378
|
+
Ui as defineCartographElements,
|
|
3379
|
+
ee as deltaE00,
|
|
3380
|
+
zn as deriveLegendRows,
|
|
3381
|
+
$r as ensureCvdFilters,
|
|
3382
|
+
Zn as featureBounds,
|
|
3383
|
+
F as fieldOf,
|
|
3384
|
+
Ye as findFrame,
|
|
3385
|
+
Vn as formatDms,
|
|
3386
|
+
Kr as formatScaleDenominator,
|
|
3387
|
+
Rr as installUrlActions,
|
|
3388
|
+
br as isCoreLoaded,
|
|
3389
|
+
Xr as isoDate,
|
|
3390
|
+
en as layoutText,
|
|
3391
|
+
xr as lintLegendColours,
|
|
3392
|
+
Ie as loadCore,
|
|
3393
|
+
Ii as maxGeoreferenceablePitch,
|
|
3394
|
+
Pi as mercatorForward,
|
|
3395
|
+
Ti as mercatorInverse,
|
|
3396
|
+
$e as niceInterval,
|
|
3397
|
+
We as niceNumberBelow,
|
|
3398
|
+
Ot as normalizeCrs,
|
|
3399
|
+
vn as northBearingDegrees,
|
|
3400
|
+
He as ownerCartograph,
|
|
3401
|
+
Qn as padBounds,
|
|
3402
|
+
Xt as paintEnvForDpi,
|
|
3403
|
+
Sr as parseColor,
|
|
3323
3404
|
X as parseCorners,
|
|
3324
|
-
|
|
3405
|
+
ri as parseSort,
|
|
3325
3406
|
J as peekCore,
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3407
|
+
mt as readCamera,
|
|
3408
|
+
lr as readLiteralRows,
|
|
3409
|
+
qn as readOverrides,
|
|
3329
3410
|
U as referencedFrame,
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3411
|
+
Jn as rejectionFor,
|
|
3412
|
+
Bt as renderCartograph,
|
|
3413
|
+
ze as renderCartographAtlas,
|
|
3414
|
+
_t as resolveCrsForward,
|
|
3415
|
+
qt as resolveCvdType,
|
|
3416
|
+
si as resolveFilenames,
|
|
3417
|
+
dt as resolvePageSize,
|
|
3418
|
+
Vr as resolveToken,
|
|
3419
|
+
Ve as resolveTokens,
|
|
3420
|
+
Dn as rowColorFor,
|
|
3421
|
+
Sn as sanitizeAdoptedMap,
|
|
3422
|
+
ii as sanitizeFilename,
|
|
3423
|
+
An as scaleVariation,
|
|
3424
|
+
Re as setCoreLoader,
|
|
3425
|
+
Qt as simulate,
|
|
3426
|
+
Un as swatchShapeFor,
|
|
3427
|
+
Hr as tokensIn,
|
|
3428
|
+
Li as utmDef,
|
|
3429
|
+
dr as validateCartograph,
|
|
3430
|
+
_i as validateCartographDeep,
|
|
3431
|
+
Oi as validateCartographString,
|
|
3432
|
+
ie as whenPageReady
|
|
3352
3433
|
};
|