@nika-js/onlymap 0.11.2 → 0.11.4
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 +2 -2
- package/dist/attribution.d.ts +27 -0
- package/dist/{basemap-BlMlSRTo.js → basemap-UE11uf6w.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 +1143 -1060
- package/dist/cartograph.standalone.js +1599 -1516
- package/dist/elements/om-map.d.ts +6 -0
- package/dist/{geoparquet-Bqhh_idk.js → geoparquet-D7ZKVPDh.js} +1 -1
- package/dist/{globe-view-DQ0GLKSn.js → globe-view-B7Yn2BbK.js} +1 -1
- package/dist/{hillshade-CxMG6ocE.js → hillshade-tQaqlPhn.js} +1 -1
- package/dist/{index-DklXFu6D.js → index-B_L_7lV0.js} +1 -1
- package/dist/{index-m-7enOKi.js → index-C09RUa1s.js} +1 -1
- package/dist/{index-DBYIrdvb.js → index-C8a3EKM8.js} +3 -3
- package/dist/{index-CdAb2VR8.js → index-CFWt9qS0.js} +1 -1
- package/dist/{index-DO3-mfIk.js → index-CWtaL88w.js} +3 -3
- package/dist/{index-9W2ZrRyF.js → index-DIoKYXlh.js} +1 -1
- package/dist/{index-CF7q_mKH.js → index-DPV7mwIc.js} +2 -2
- package/dist/{index-CE3n5pQz.js → index-DzxpYTfi.js} +51 -20
- package/dist/{index-aoMhS8VK.js → index-N5acD4ii.js} +1 -1
- package/dist/{lerc-vNjPdkTs.js → lerc-BDcZeX07.js} +1 -1
- package/dist/onlymap.standalone.js +306 -231
- package/dist/onlymapjs.js +1 -1
- package/dist/{post-process-effect-eVlcdR0m.js → post-process-effect-C1iDE90L.js} +1 -1
- package/dist/{raster-8iVEbDdp.js → raster-D4nwLneR.js} +3 -3
- package/dist/{raster-pipeline-OqdVks6Y.js → raster-pipeline-DX-rZjRG.js} +1 -1
- package/dist/runtime-core.d.ts +22 -0
- package/dist/{text-on-path-C34MMnKY.js → text-on-path-onhHN4AZ.js} +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/{zarr-Dla-EY4o.js → zarr-CBGaInwF.js} +2 -2
- package/docs/cartograph.md +33 -4
- package/llms.txt +2 -2
- package/onlymapjs.html-data.json +8 -0
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +1 -1
- package/skills/onlymapjs/references/syntax.md +4 -3
package/dist/cartograph.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
let
|
|
2
|
-
function
|
|
3
|
-
|
|
1
|
+
let Pt = null, Z = null;
|
|
2
|
+
function Ie(r) {
|
|
3
|
+
Pt = r;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function yr() {
|
|
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 Fe() {
|
|
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 wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22
22
|
__proto__: null,
|
|
23
|
-
isCoreLoaded:
|
|
24
|
-
loadCore:
|
|
23
|
+
isCoreLoaded: yr,
|
|
24
|
+
loadCore: Fe,
|
|
25
25
|
peekCore: J,
|
|
26
|
-
setCoreLoader:
|
|
26
|
+
setCoreLoader: Ie
|
|
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 vr(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 Ar(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 Mr(r, t = /* @__PURE__ */ new Date()) {
|
|
98
|
+
const e = new TextEncoder(), { time: n, date: i } = Ar(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 = vr(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"], Oe = {
|
|
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 : Oe[t] ?? null;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
122
|
+
const Sr = ["none", ...ft, ...Object.keys(Oe)], 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 Cr(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 xr = 10;
|
|
170
|
+
function kr(r, t = xr) {
|
|
171
171
|
const e = /* @__PURE__ */ new Map();
|
|
172
172
|
for (const a of r) {
|
|
173
|
-
const l =
|
|
173
|
+
const l = Cr(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 $r(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 _e = (r) => `om-carto-cvd-${r}`;
|
|
215
|
+
function Er(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 = _e(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 Ue = 16384, De = 134217728;
|
|
230
|
+
async function Nr(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 ze(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 Pr(r) {
|
|
247
|
+
return [...r.children].filter(ze).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 ?? Ue, h = t.maxArea ?? De;
|
|
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 Nr(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 = Pr(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
|
+
_ && !$r(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 je(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 Mr(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 Tr = /* @__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: De,
|
|
345
|
+
MAX_CANVAS_DIMENSION: Ue,
|
|
346
|
+
paintsInExport: ze,
|
|
347
|
+
renderCartograph: Bt,
|
|
348
|
+
renderCartographAtlas: je
|
|
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 Lr = 3e4;
|
|
357
|
+
async function ie(r, t = Lr) {
|
|
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 Rr(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 je(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 Ir() {
|
|
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
|
+
Rr(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 Ge = typeof window < "u" && typeof document < "u" && typeof customElements < "u", qe = Ge ? HTMLElement : class {
|
|
412
412
|
};
|
|
413
|
-
function
|
|
414
|
-
|
|
413
|
+
function x(r, t) {
|
|
414
|
+
Ge && (customElements.get(r) || customElements.define(r, t));
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function Fr(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 = " · ", Or = {
|
|
424
|
+
copy: "©",
|
|
425
|
+
reg: "®",
|
|
426
|
+
amp: "&",
|
|
427
|
+
lt: "<",
|
|
428
|
+
gt: ">",
|
|
429
|
+
quot: '"',
|
|
430
|
+
apos: "'",
|
|
431
|
+
nbsp: " "
|
|
432
|
+
};
|
|
433
|
+
function _r(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 Or[e.toLowerCase()] ?? t;
|
|
440
|
+
}).replace(/\s+/g, " ").trim();
|
|
441
|
+
}
|
|
442
|
+
function We(r) {
|
|
443
|
+
const t = [...new Set(r.filter((e) => typeof e == "string").map(_r))].filter(
|
|
444
|
+
(e) => e.length > 0
|
|
445
|
+
);
|
|
446
|
+
return t.filter((e) => !t.some((n) => n !== e && n.includes(e)));
|
|
447
|
+
}
|
|
448
|
+
function se(r) {
|
|
449
|
+
return We((r ?? "").split(Kt.trim()));
|
|
450
|
+
}
|
|
451
|
+
class O extends qe {
|
|
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"], oe = ["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
|
|
@@ -486,60 +514,60 @@ const pt = "cartograph/2", Ai = ["default", "dark", "sepia", "blueprint", "minim
|
|
|
486
514
|
// carries the georeference that was true when it was taken, which is the
|
|
487
515
|
// only way furniture can be right when the live map never loaded and its
|
|
488
516
|
// CRS is therefore unknowable.
|
|
489
|
-
"om-source": ["src", "corners", "crs", "crs-def"],
|
|
517
|
+
"om-source": ["src", "corners", "crs", "crs-def", "attribution"],
|
|
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 Be(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 ae = {
|
|
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 Ke({ 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 = ae[n] ?? ae.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 = le(o, l);
|
|
518
546
|
else {
|
|
519
|
-
c =
|
|
520
|
-
const f =
|
|
547
|
+
c = le(o, a);
|
|
548
|
+
const f = Be(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 le(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 Ve = /\{\{\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 He(r, t) {
|
|
605
633
|
const e = [];
|
|
606
|
-
return { text: r.replace(
|
|
607
|
-
const
|
|
608
|
-
return
|
|
634
|
+
return { text: r.replace(Ve, (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(Ve)].map((t) => t[1]);
|
|
613
641
|
}
|
|
614
|
-
const
|
|
615
|
-
function
|
|
642
|
+
const ce = /* @__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 = ce.get(o);
|
|
626
654
|
if (a === void 0) {
|
|
627
|
-
if (a =
|
|
628
|
-
|
|
655
|
+
if (a = o.data, !a.includes("{{")) continue;
|
|
656
|
+
ce.set(o, a);
|
|
629
657
|
}
|
|
630
|
-
const l =
|
|
631
|
-
|
|
658
|
+
const l = He(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 Ye(r) {
|
|
640
668
|
return r.closest("om-cartograph");
|
|
641
669
|
}
|
|
642
|
-
function
|
|
643
|
-
const e =
|
|
670
|
+
function Xe(r, t) {
|
|
671
|
+
const e = Ye(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 Je(r) {
|
|
650
678
|
return [...r.querySelectorAll("om-frame")];
|
|
651
679
|
}
|
|
652
|
-
function
|
|
653
|
-
const t =
|
|
680
|
+
function Jr(r) {
|
|
681
|
+
const t = Ye(r);
|
|
654
682
|
if (!t) return null;
|
|
655
|
-
const e =
|
|
683
|
+
const e = Je(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 ? Xe(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 ue = "data-om-carto-page", he = "data-om-carto-marks", wt = "data-om-carto-credit", me = "data-om-carto-attribution", Ze = "Built with OnlyMap by NIKA", Qr = `${Ze} · 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 de(r) {
|
|
704
|
+
return r.replace(/©|\(c\)/gi, " ").replace(/\s+/g, " ").trim().toLowerCase();
|
|
673
705
|
}
|
|
674
|
-
|
|
675
|
-
class He extends O {
|
|
706
|
+
class Qe 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" ? Ze : 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 = We(t.flatMap((l) => l.attributions?.() ?? [])), n = [...this.querySelectorAll("om-text")].map((l) => de(l.textContent ?? "")).join(`
|
|
776
|
+
`), i = e.filter((l) => !n.includes(de(l))), s = this.querySelector(`:scope > [${me}]`);
|
|
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(me, ""), 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(() => Tr), { 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 = Je(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) => He(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[${ue}]`);
|
|
903
|
+
i || (i = document.createElement("style"), i.setAttribute(ue, ""), 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 > [${he}]`);
|
|
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(he, ""), 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
|
+
Er(this.ownerDocument), this.style.filter = `url(#${_e(t)})`;
|
|
888
957
|
}
|
|
889
958
|
}
|
|
890
|
-
|
|
891
|
-
function
|
|
892
|
-
const
|
|
959
|
+
x("om-cartograph", Qe);
|
|
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 tr 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", tr);
|
|
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, fe = Math.PI / 180, pe = 180 / Math.PI, ge = 85.0511287798066, It = 2 * Math.PI * et / 360;
|
|
1052
|
+
function Vt([r, t]) {
|
|
1053
|
+
const e = Math.max(-ge, Math.min(ge, t));
|
|
1054
|
+
return [et * r * fe, et * Math.log(Math.tan(Math.PI / 4 + e * fe / 2))];
|
|
986
1055
|
}
|
|
987
|
-
function
|
|
988
|
-
return [r / et *
|
|
1056
|
+
function pt([r, t]) {
|
|
1057
|
+
return [r / et * pe, (2 * Math.atan(Math.exp(t / et)) - Math.PI / 2) * pe];
|
|
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 er(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 rr = /* @__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 = rr.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 = rr.get(e);
|
|
1036
1105
|
if (n && typeof n != "string") return n;
|
|
1037
1106
|
if (!t) {
|
|
1038
|
-
const u =
|
|
1107
|
+
const u = er(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 be = Math.PI / 180, mn = 180 / Math.PI, dn = { code: "EPSG:3857", forward: Vt, inverse: pt }, Pi = Vt, Ti = pt, ye = 6378137, we = 89.9;
|
|
1122
|
+
function fn([r, t]) {
|
|
1123
|
+
const e = Math.max(-we, Math.min(we, t));
|
|
1124
|
+
return [ye * r * be, ye * Math.log(Math.tan(Math.PI / 4 + e * be / 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 er(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 ve(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 nr = (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 : nr(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 = ve(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 = ve(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 Fe();
|
|
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", Ae = "data-om-carto-source", $t = "data-om-carto-capture", Et = "data-om-carto-overview", Me = "http://www.w3.org/2000/svg", Se = 24, Ce = 0.25;
|
|
1433
|
+
class ir 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 ${Ce}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(Ae));
|
|
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,9 +1714,9 @@ 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(Ae, String(e));
|
|
1649
1718
|
const n = { id: this.id, index: e, kind: t.kind, src: t.src ?? null };
|
|
1650
|
-
this.dispatchEvent(new CustomEvent("om-frame-source", { bubbles: !0, detail: n })), this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } }));
|
|
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 } })), this.dispatchEvent(new CustomEvent("om-attributions-changed", { bubbles: !0 }));
|
|
1651
1720
|
}
|
|
1652
1721
|
/** Leave live mode without deleting an authored inline map. */
|
|
1653
1722
|
suspendLiveMode() {
|
|
@@ -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 = Xe(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 < Se; y++) {
|
|
1840
|
+
const A = y / Se, 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(Me, "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(Me, "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,32 @@ 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
|
+
if (this.mode !== "live") return se(this.getAttribute("attribution"));
|
|
1942
|
+
const t = this.settledSource;
|
|
1943
|
+
return t?.kind === "raster" ? se(t.el.getAttribute("attribution")) : this.liveMap?.attributions?.() ?? [];
|
|
1861
1944
|
}
|
|
1862
1945
|
/**
|
|
1863
1946
|
* Point this frame's camera at a lon/lat box — the atlas's per-page refit.
|
|
@@ -1867,13 +1950,13 @@ class Qe extends O {
|
|
|
1867
1950
|
* follows from the same source as any authored camera.
|
|
1868
1951
|
*/
|
|
1869
1952
|
fitBounds(t) {
|
|
1870
|
-
const [e, n, i,
|
|
1871
|
-
if (
|
|
1953
|
+
const [e, n, i, s] = t, { w: o, h: a } = S(this);
|
|
1954
|
+
if (o <= 0 || a <= 0) return;
|
|
1872
1955
|
const l = J();
|
|
1873
1956
|
if (!l) return;
|
|
1874
|
-
const c = new l.WebMercatorViewport({ width:
|
|
1957
|
+
const c = new l.WebMercatorViewport({ width: o * D, height: a * D, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
|
|
1875
1958
|
[e, n],
|
|
1876
|
-
[i,
|
|
1959
|
+
[i, s]
|
|
1877
1960
|
]);
|
|
1878
1961
|
[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
1962
|
}
|
|
@@ -1894,7 +1977,7 @@ class Qe extends O {
|
|
|
1894
1977
|
return;
|
|
1895
1978
|
}
|
|
1896
1979
|
const e = this.vector;
|
|
1897
|
-
e && (this.captureImage = await
|
|
1980
|
+
e && (this.captureImage = await Tn(e, S(this), t.pxPerMm));
|
|
1898
1981
|
}
|
|
1899
1982
|
/** Export hook: forget the capture, so a failed pre-pass never reuses it. */
|
|
1900
1983
|
discardCartograph() {
|
|
@@ -1915,46 +1998,46 @@ class Qe extends O {
|
|
|
1915
1998
|
this.printing = !1, this.querySelector(":scope > img[data-om-carto-print]")?.remove(), this.liveMap && (this.liveMap.hidden = !1);
|
|
1916
1999
|
}
|
|
1917
2000
|
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,
|
|
2001
|
+
const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
|
|
2002
|
+
if (s <= 0 || o <= 0) return;
|
|
2003
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = I(a?.backgroundColor);
|
|
2004
|
+
l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
|
|
1922
2005
|
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
|
-
|
|
2006
|
+
c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, s, o), this.paintOverview(t, e);
|
|
2007
|
+
const u = this.getAttribute("frame-stroke") || I(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = Ce * e.pxPerMm;
|
|
2008
|
+
h > 0 && (t.strokeStyle = u, t.lineWidth = h, t.strokeRect(h / 2, h / 2, s - h, o - h));
|
|
1926
2009
|
}
|
|
1927
2010
|
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) || (
|
|
2011
|
+
const n = this.querySelector(`:scope > [${Et}] polygon`), i = n?.getAttribute("points");
|
|
2012
|
+
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) => {
|
|
2013
|
+
const [a, l] = s.split(",").map(Number);
|
|
2014
|
+
!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
2015
|
}), t.closePath(), t.stroke(), t.restore());
|
|
1933
2016
|
}
|
|
1934
2017
|
}
|
|
1935
|
-
|
|
1936
|
-
const
|
|
1937
|
-
class
|
|
2018
|
+
x("om-frame", ir);
|
|
2019
|
+
const at = "http://www.w3.org/2000/svg", Ln = ["single", "double", "line", "ticks"];
|
|
2020
|
+
class sr extends O {
|
|
1938
2021
|
static observedAttributes = [...T["om-scalebar"]];
|
|
1939
2022
|
/** The geometry currently drawn — reused by the canvas exporter. */
|
|
1940
2023
|
get drawing() {
|
|
1941
2024
|
const e = U(this)?.georef;
|
|
1942
2025
|
if (!e) return null;
|
|
1943
|
-
const { w: n, h: i } = S(this),
|
|
2026
|
+
const { w: n, h: i } = S(this), s = Ke({
|
|
1944
2027
|
groundMetersPerMm: e.groundMetersPerMm(),
|
|
1945
2028
|
maxWidthMm: n,
|
|
1946
2029
|
segments: Number(this.getAttribute("segments")) || void 0,
|
|
1947
2030
|
units: this.unitSystem,
|
|
1948
2031
|
segmentLengthMeters: this.getAttribute("segment-length") ? Number(this.getAttribute("segment-length")) : null
|
|
1949
2032
|
});
|
|
1950
|
-
return
|
|
2033
|
+
return s ? Wr(s, this.barStyle, i) : null;
|
|
1951
2034
|
}
|
|
1952
2035
|
get barStyle() {
|
|
1953
2036
|
const t = this.getAttribute("kind");
|
|
1954
|
-
return
|
|
2037
|
+
return Ln.includes(t) ? t : "single";
|
|
1955
2038
|
}
|
|
1956
2039
|
get unitSystem() {
|
|
1957
|
-
return
|
|
2040
|
+
return qr(this.getAttribute("units")) ?? "metric";
|
|
1958
2041
|
}
|
|
1959
2042
|
renderNow() {
|
|
1960
2043
|
if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-scalebar-ink", !0), this.style.display = "block", !U(this)) {
|
|
@@ -1970,48 +2053,48 @@ class tr extends O {
|
|
|
1970
2053
|
this.renderSvg(e);
|
|
1971
2054
|
}
|
|
1972
2055
|
renderSvg(t) {
|
|
1973
|
-
const { w: e, h: n } = S(this), i = this.ownerDocument,
|
|
1974
|
-
|
|
1975
|
-
const
|
|
2056
|
+
const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(at, "svg");
|
|
2057
|
+
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";
|
|
2058
|
+
const o = "var(--om-carto-scalebar-ink)";
|
|
1976
2059
|
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 ?
|
|
2060
|
+
const l = i.createElementNS(at, "rect");
|
|
2061
|
+
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
2062
|
}
|
|
1980
2063
|
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",
|
|
2064
|
+
const l = i.createElementNS(at, "line");
|
|
2065
|
+
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
2066
|
}
|
|
1984
2067
|
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",
|
|
2068
|
+
const l = i.createElementNS(at, "text");
|
|
2069
|
+
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
2070
|
}
|
|
1988
|
-
this.replaceChildren(
|
|
2071
|
+
this.replaceChildren(s);
|
|
1989
2072
|
}
|
|
1990
2073
|
paintCartograph(t, e) {
|
|
1991
2074
|
const n = this.drawing;
|
|
1992
2075
|
if (!n) return;
|
|
1993
|
-
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null,
|
|
1994
|
-
t.strokeStyle =
|
|
2076
|
+
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = I(i?.color) ?? "#000", o = (l) => l * e.pxPerMm;
|
|
2077
|
+
t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(n.strokeMm);
|
|
1995
2078
|
for (const l of n.bars)
|
|
1996
|
-
l.filled && t.fillRect(
|
|
2079
|
+
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
2080
|
t.beginPath();
|
|
1998
2081
|
for (const l of n.strokes)
|
|
1999
|
-
t.moveTo(
|
|
2082
|
+
t.moveTo(o(l.x1), o(l.y1)), t.lineTo(o(l.x2), o(l.y2));
|
|
2000
2083
|
t.stroke();
|
|
2001
2084
|
const a = i?.fontFamily || "system-ui, sans-serif";
|
|
2002
|
-
t.font = `${
|
|
2085
|
+
t.font = `${o(n.fontMm)}px ${a}`, t.textBaseline = "alphabetic";
|
|
2003
2086
|
for (const l of n.labels)
|
|
2004
|
-
t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text,
|
|
2087
|
+
t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text, o(l.x), o(l.y));
|
|
2005
2088
|
}
|
|
2006
2089
|
}
|
|
2007
|
-
|
|
2090
|
+
x("om-scalebar", sr);
|
|
2008
2091
|
const Q = "http://www.w3.org/2000/svg";
|
|
2009
|
-
class
|
|
2092
|
+
class or extends O {
|
|
2010
2093
|
static observedAttributes = [...T["om-north"]];
|
|
2011
2094
|
/** Degrees clockwise from the page's "up", or null when unknowable. */
|
|
2012
2095
|
get bearing() {
|
|
2013
2096
|
const t = U(this)?.georef;
|
|
2014
|
-
return t ?
|
|
2097
|
+
return t ? vn(t) : null;
|
|
2015
2098
|
}
|
|
2016
2099
|
get indicatorKind() {
|
|
2017
2100
|
return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
|
|
@@ -2027,38 +2110,38 @@ class er extends O {
|
|
|
2027
2110
|
W(this, "North indicator cannot derive a direction from this frame yet.");
|
|
2028
2111
|
return;
|
|
2029
2112
|
}
|
|
2030
|
-
const { w: n, h: i } = S(this),
|
|
2031
|
-
|
|
2032
|
-
const a =
|
|
2113
|
+
const { w: n, h: i } = S(this), s = this.ownerDocument, o = s.createElementNS(Q, "svg");
|
|
2114
|
+
o.setAttribute("width", `${n}mm`), o.setAttribute("height", `${i}mm`), o.setAttribute("viewBox", `0 0 ${n} ${i}`), o.style.display = "block";
|
|
2115
|
+
const a = s.createElementNS(Q, "g");
|
|
2033
2116
|
a.setAttribute("transform", `rotate(${e.toFixed(3)} ${n / 2} ${i / 2})`);
|
|
2034
|
-
for (const l of this.buildGeometry(
|
|
2035
|
-
|
|
2117
|
+
for (const l of this.buildGeometry(s, n, i)) a.appendChild(l);
|
|
2118
|
+
o.appendChild(a), this.replaceChildren(o);
|
|
2036
2119
|
}
|
|
2037
2120
|
buildGeometry(t, e, n) {
|
|
2038
|
-
const i = "var(--om-carto-compass-ink)",
|
|
2121
|
+
const i = "var(--om-carto-compass-ink)", s = [], o = e / 2, a = Math.min(3, n * 0.24), l = n - a * 1.2;
|
|
2039
2122
|
if (this.indicatorKind === "rose") {
|
|
2040
2123
|
const f = Math.min(e, l) / 2, g = t.createElementNS(Q, "circle");
|
|
2041
|
-
g.setAttribute("cx", String(
|
|
2124
|
+
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
2125
|
}
|
|
2043
|
-
const c = 0, u = l,
|
|
2044
|
-
d.setAttribute("d", `M ${
|
|
2045
|
-
const
|
|
2046
|
-
return
|
|
2126
|
+
const c = 0, u = l, h = Math.min(e * 0.3, 4), d = t.createElementNS(Q, "path");
|
|
2127
|
+
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);
|
|
2128
|
+
const m = t.createElementNS(Q, "text");
|
|
2129
|
+
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
2130
|
}
|
|
2048
2131
|
paintCartograph(t, e) {
|
|
2049
2132
|
const n = this.bearing;
|
|
2050
2133
|
if (n == null) return;
|
|
2051
|
-
const { w: i, h:
|
|
2052
|
-
t.save(), t.translate(l(
|
|
2134
|
+
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);
|
|
2135
|
+
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
2136
|
}
|
|
2054
2137
|
}
|
|
2055
|
-
|
|
2056
|
-
const
|
|
2057
|
-
class
|
|
2138
|
+
x("om-north", or);
|
|
2139
|
+
const lt = "http://www.w3.org/2000/svg", Rn = ["rect", "ellipse", "line", "arrow"];
|
|
2140
|
+
class ar extends O {
|
|
2058
2141
|
static observedAttributes = [...T["om-shape"]];
|
|
2059
2142
|
get kind() {
|
|
2060
2143
|
const t = this.getAttribute("kind");
|
|
2061
|
-
return
|
|
2144
|
+
return Rn.includes(t) ? t : "rect";
|
|
2062
2145
|
}
|
|
2063
2146
|
get fill() {
|
|
2064
2147
|
return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
|
|
@@ -2084,44 +2167,44 @@ class rr extends O {
|
|
|
2084
2167
|
}
|
|
2085
2168
|
renderNow() {
|
|
2086
2169
|
this.applyPlacement(), this.style.display = "block";
|
|
2087
|
-
const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(
|
|
2170
|
+
const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(lt, "svg");
|
|
2088
2171
|
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
|
|
2172
|
+
const s = this.strokeWidthMm / 2, o = this.kind;
|
|
2090
2173
|
let a;
|
|
2091
|
-
|
|
2092
|
-
const l =
|
|
2174
|
+
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)));
|
|
2175
|
+
const l = o === "rect" || o === "ellipse" || o === "arrow";
|
|
2093
2176
|
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
2177
|
}
|
|
2095
2178
|
/** A line from the box's top-left to its bottom-right, with a solid head. */
|
|
2096
2179
|
arrowPath(t, e) {
|
|
2097
|
-
const n = Math.min(t, e) * 0.28, i = Math.atan2(e, t),
|
|
2098
|
-
return `M 0 0 L ${
|
|
2180
|
+
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) };
|
|
2181
|
+
return `M 0 0 L ${s} ${o} M ${s} ${o} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
|
|
2099
2182
|
}
|
|
2100
2183
|
paintCartograph(t, e) {
|
|
2101
2184
|
const { w: n, h: i } = S(this);
|
|
2102
2185
|
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(
|
|
2186
|
+
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;
|
|
2187
|
+
if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, h === "ellipse")
|
|
2188
|
+
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();
|
|
2189
|
+
else if (h === "line" || h === "arrow") {
|
|
2190
|
+
if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(o(n), o(i)), c > 0 && t.stroke(), h === "arrow") {
|
|
2191
|
+
const d = Math.min(o(n), o(i)) * 0.28, m = Math.atan2(o(i), o(n));
|
|
2192
|
+
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
2193
|
}
|
|
2111
2194
|
} else {
|
|
2112
|
-
const d =
|
|
2113
|
-
t.beginPath(), d > 0 && typeof t.roundRect == "function" ? t.roundRect(u, u,
|
|
2195
|
+
const d = o(this.radiusMm);
|
|
2196
|
+
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
2197
|
}
|
|
2115
2198
|
t.restore();
|
|
2116
2199
|
}
|
|
2117
2200
|
}
|
|
2118
|
-
|
|
2119
|
-
const
|
|
2120
|
-
class
|
|
2201
|
+
x("om-shape", ar);
|
|
2202
|
+
const xe = "data-om-carto-owned", In = ["contain", "cover", "fill"];
|
|
2203
|
+
class lr extends O {
|
|
2121
2204
|
static observedAttributes = [...T["om-image"]];
|
|
2122
2205
|
get fit() {
|
|
2123
2206
|
const t = this.getAttribute("fit");
|
|
2124
|
-
return
|
|
2207
|
+
return In.includes(t ?? "") ? t : "contain";
|
|
2125
2208
|
}
|
|
2126
2209
|
get image() {
|
|
2127
2210
|
return this.querySelector(":scope > img");
|
|
@@ -2130,29 +2213,29 @@ class nr extends O {
|
|
|
2130
2213
|
this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden";
|
|
2131
2214
|
const t = this.getAttribute("src");
|
|
2132
2215
|
let e = this.image;
|
|
2133
|
-
!e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(
|
|
2216
|
+
!e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(xe, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(xe) && 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
2217
|
}
|
|
2135
2218
|
paintCartograph(t, e) {
|
|
2136
2219
|
const n = this.image;
|
|
2137
2220
|
if (!n || !n.complete || n.naturalWidth === 0) return;
|
|
2138
|
-
const { w: i, h:
|
|
2139
|
-
if (
|
|
2221
|
+
const { w: i, h: s } = S(this), o = i * e.pxPerMm, a = s * e.pxPerMm;
|
|
2222
|
+
if (o <= 0 || a <= 0) return;
|
|
2140
2223
|
const l = this.fit;
|
|
2141
2224
|
if (l === "fill") {
|
|
2142
|
-
t.drawImage(n, 0, 0,
|
|
2225
|
+
t.drawImage(n, 0, 0, o, a);
|
|
2143
2226
|
return;
|
|
2144
2227
|
}
|
|
2145
|
-
const c = n.naturalWidth / n.naturalHeight, u =
|
|
2146
|
-
l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0,
|
|
2228
|
+
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;
|
|
2229
|
+
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
2230
|
}
|
|
2148
2231
|
}
|
|
2149
|
-
|
|
2150
|
-
const
|
|
2151
|
-
function
|
|
2232
|
+
x("om-image", lr);
|
|
2233
|
+
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"]);
|
|
2234
|
+
function Un(r) {
|
|
2152
2235
|
const t = r.type ?? "";
|
|
2153
|
-
if (
|
|
2154
|
-
if (
|
|
2155
|
-
if (
|
|
2236
|
+
if (_n.has(t)) return "ramp";
|
|
2237
|
+
if (Fn.has(t)) return "line";
|
|
2238
|
+
if (On.has(t)) return "point";
|
|
2156
2239
|
if (t === "GeoJsonLayer") {
|
|
2157
2240
|
const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
|
|
2158
2241
|
if (n && !i) return "polygon";
|
|
@@ -2160,69 +2243,69 @@ function Tn(r) {
|
|
|
2160
2243
|
}
|
|
2161
2244
|
return "polygon";
|
|
2162
2245
|
}
|
|
2163
|
-
function
|
|
2246
|
+
function Dn(r) {
|
|
2164
2247
|
const t = r.meta?.legend;
|
|
2165
2248
|
return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
|
|
2166
2249
|
}
|
|
2167
|
-
const
|
|
2168
|
-
function
|
|
2250
|
+
const Nt = 12;
|
|
2251
|
+
function zn(r, t = []) {
|
|
2169
2252
|
const e = [];
|
|
2170
2253
|
for (const n of r) {
|
|
2171
2254
|
if (n.props?.visible === !1) continue;
|
|
2172
|
-
const i = t.filter((a) => a.layer === n.id),
|
|
2173
|
-
if (
|
|
2174
|
-
const
|
|
2255
|
+
const i = t.filter((a) => a.layer === n.id), s = i.find((a) => a.match == null);
|
|
2256
|
+
if (s?.hide) continue;
|
|
2257
|
+
const o = jn(n.meta?.legend);
|
|
2175
2258
|
e.push({
|
|
2176
2259
|
layerId: n.id,
|
|
2177
|
-
label:
|
|
2178
|
-
color:
|
|
2179
|
-
shape:
|
|
2180
|
-
legend:
|
|
2181
|
-
order:
|
|
2260
|
+
label: s?.label ?? n.meta?.label ?? n.id,
|
|
2261
|
+
color: s?.color ?? Dn(n),
|
|
2262
|
+
shape: s?.shape ?? Un(n),
|
|
2263
|
+
legend: Gn(o, i),
|
|
2264
|
+
order: s?.order
|
|
2182
2265
|
});
|
|
2183
2266
|
}
|
|
2184
2267
|
return e.map((n, i) => ({ row: n, index: i })).sort((n, i) => {
|
|
2185
|
-
const
|
|
2186
|
-
return
|
|
2268
|
+
const s = n.row.order ?? Number.POSITIVE_INFINITY, o = i.row.order ?? Number.POSITIVE_INFINITY;
|
|
2269
|
+
return s - o || n.index - i.index;
|
|
2187
2270
|
}).map((n) => n.row);
|
|
2188
2271
|
}
|
|
2189
|
-
function
|
|
2190
|
-
if (!r || r.kind !== "categories" || r.entries.length <=
|
|
2191
|
-
const t = r.entries.slice(0,
|
|
2272
|
+
function jn(r) {
|
|
2273
|
+
if (!r || r.kind !== "categories" || r.entries.length <= Nt) return r;
|
|
2274
|
+
const t = r.entries.slice(0, Nt), e = r.entries.length - Nt;
|
|
2192
2275
|
return {
|
|
2193
2276
|
...r,
|
|
2194
2277
|
entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
|
|
2195
2278
|
};
|
|
2196
2279
|
}
|
|
2197
|
-
function
|
|
2280
|
+
function Gn(r, t) {
|
|
2198
2281
|
const e = t.filter((i) => i.match != null);
|
|
2199
2282
|
if (!r || r.kind === "ramp" || e.length === 0) return r;
|
|
2200
2283
|
const n = [];
|
|
2201
2284
|
for (const i of r.entries) {
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2285
|
+
const s = e.find((o) => o.match === i.label);
|
|
2286
|
+
s?.hide || n.push({ color: s?.color ?? i.color, label: s?.label ?? i.label });
|
|
2204
2287
|
}
|
|
2205
2288
|
return { ...r, entries: n };
|
|
2206
2289
|
}
|
|
2207
|
-
function
|
|
2290
|
+
function qn(r) {
|
|
2208
2291
|
const t = [];
|
|
2209
2292
|
for (const e of r.querySelectorAll(":scope > om-legend-row")) {
|
|
2210
2293
|
const n = e.getAttribute("layer");
|
|
2211
2294
|
if (!n) continue;
|
|
2212
|
-
const i = e.getAttribute("order"),
|
|
2295
|
+
const i = e.getAttribute("order"), s = i == null || i.trim() === "" ? void 0 : Number(i);
|
|
2213
2296
|
t.push({
|
|
2214
2297
|
layer: n,
|
|
2215
2298
|
match: e.getAttribute("match") ?? void 0,
|
|
2216
2299
|
label: e.getAttribute("label") ?? void 0,
|
|
2217
2300
|
hide: e.hasAttribute("hide"),
|
|
2218
|
-
order:
|
|
2301
|
+
order: s != null && Number.isFinite(s) ? s : void 0,
|
|
2219
2302
|
color: e.getAttribute("color") ?? void 0,
|
|
2220
2303
|
shape: e.getAttribute("shape") ?? void 0
|
|
2221
2304
|
});
|
|
2222
2305
|
}
|
|
2223
2306
|
return t;
|
|
2224
2307
|
}
|
|
2225
|
-
function
|
|
2308
|
+
function cr(r) {
|
|
2226
2309
|
const t = [];
|
|
2227
2310
|
for (const e of r.querySelectorAll(":scope > om-legend-row")) {
|
|
2228
2311
|
if (e.hasAttribute("hide")) continue;
|
|
@@ -2237,17 +2320,17 @@ function ir(r) {
|
|
|
2237
2320
|
}
|
|
2238
2321
|
return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
|
|
2239
2322
|
}
|
|
2240
|
-
const
|
|
2241
|
-
class
|
|
2323
|
+
const ke = "data-om-carto-legend-rows";
|
|
2324
|
+
class ur extends O {
|
|
2242
2325
|
static observedAttributes = [...T["om-legend"]];
|
|
2243
2326
|
get derived() {
|
|
2244
2327
|
return this.getAttribute("derived") !== "false";
|
|
2245
2328
|
}
|
|
2246
2329
|
/** The rows this legend currently shows — recomputed on demand, never stored. */
|
|
2247
2330
|
get rows() {
|
|
2248
|
-
if (!this.derived) return
|
|
2331
|
+
if (!this.derived) return cr(this);
|
|
2249
2332
|
const n = U(this)?.mapElement?.getLayers?.();
|
|
2250
|
-
return n ?
|
|
2333
|
+
return n ? zn(n, qn(this)) : [];
|
|
2251
2334
|
}
|
|
2252
2335
|
/** Inner padding in mm — authored, else the 2 mm the theme always used. */
|
|
2253
2336
|
get paddingMm() {
|
|
@@ -2274,18 +2357,18 @@ class sr extends O {
|
|
|
2274
2357
|
}
|
|
2275
2358
|
renderRows(t) {
|
|
2276
2359
|
const e = this.ownerDocument;
|
|
2277
|
-
this.querySelector(`:scope > [${
|
|
2360
|
+
this.querySelector(`:scope > [${ke}]`)?.remove(), Zr(this);
|
|
2278
2361
|
const n = e.createElement("div");
|
|
2279
|
-
n.setAttribute(
|
|
2362
|
+
n.setAttribute(ke, ""), n.style.cssText = `padding:${this.paddingMm}mm;font-size:${this.fontMm}mm;line-height:1.35;`;
|
|
2280
2363
|
const i = this.getAttribute("title");
|
|
2281
2364
|
if (i) {
|
|
2282
|
-
const
|
|
2283
|
-
|
|
2365
|
+
const o = e.createElement("div");
|
|
2366
|
+
o.textContent = i, o.style.cssText = "font-weight:600;margin-bottom:1.2mm;color:var(--om-carto-legend-title-ink);", n.appendChild(o);
|
|
2284
2367
|
}
|
|
2285
|
-
const
|
|
2286
|
-
Number.isFinite(
|
|
2287
|
-
for (const
|
|
2288
|
-
n.appendChild(this.buildRow(e,
|
|
2368
|
+
const s = Number(this.getAttribute("columns"));
|
|
2369
|
+
Number.isFinite(s) && s > 1 && (n.style.columnCount = String(Math.floor(s)), n.style.columnGap = "3mm");
|
|
2370
|
+
for (const o of t)
|
|
2371
|
+
n.appendChild(this.buildRow(e, o)), o.legend && n.appendChild(this.buildSymbology(e, o));
|
|
2289
2372
|
this.appendChild(n);
|
|
2290
2373
|
}
|
|
2291
2374
|
buildRow(t, e) {
|
|
@@ -2296,147 +2379,147 @@ class sr extends O {
|
|
|
2296
2379
|
}
|
|
2297
2380
|
/** The swatch geometry carries meaning: an area, a line and a point read differently. */
|
|
2298
2381
|
buildSwatch(t, e, n) {
|
|
2299
|
-
const i = t.createElement("span"),
|
|
2300
|
-
return n === "line" ? i.style.cssText = `${
|
|
2382
|
+
const i = t.createElement("span"), s = "display:inline-block;flex:none;width:3.2mm;height:3.2mm;";
|
|
2383
|
+
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
2384
|
}
|
|
2302
2385
|
buildSymbology(t, e) {
|
|
2303
2386
|
const n = t.createElement("div");
|
|
2304
2387
|
n.style.cssText = "margin:0.4mm 0 1.6mm 4.7mm;break-inside:avoid;";
|
|
2305
|
-
const i = e.legend,
|
|
2306
|
-
if (
|
|
2307
|
-
const
|
|
2308
|
-
|
|
2388
|
+
const i = e.legend, s = t.createElement("div");
|
|
2389
|
+
if (s.textContent = i.field, s.style.cssText = "font-size:2.1mm;opacity:.7;margin-bottom:0.5mm;", n.appendChild(s), i.kind === "ramp") {
|
|
2390
|
+
const o = t.createElement("div");
|
|
2391
|
+
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
2392
|
const a = t.createElement("div");
|
|
2310
|
-
return a.style.cssText = "display:flex;justify-content:space-between;font-size:2.1mm;opacity:.75;", a.append(
|
|
2393
|
+
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
2394
|
}
|
|
2312
|
-
for (const
|
|
2395
|
+
for (const o of i.entries) {
|
|
2313
2396
|
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,
|
|
2397
|
+
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
2398
|
}
|
|
2316
2399
|
if (i.kind === "categories" && i.defaultColor) {
|
|
2317
|
-
const
|
|
2318
|
-
|
|
2400
|
+
const o = t.createElement("div");
|
|
2401
|
+
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
2402
|
}
|
|
2320
2403
|
return n;
|
|
2321
2404
|
}
|
|
2322
2405
|
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 =
|
|
2406
|
+
const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
|
|
2407
|
+
if (s <= 0 || o <= 0) return;
|
|
2408
|
+
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = I(a?.backgroundColor);
|
|
2409
|
+
l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
|
|
2410
|
+
const c = I(a?.borderTopColor), u = Tt(a?.borderTopWidth) * e.scale;
|
|
2411
|
+
c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, s - u, o - u));
|
|
2412
|
+
const h = I(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", m = (M) => M * e.pxPerMm, f = this.paddingMm, g = this.fontMm;
|
|
2413
|
+
let p = m(f);
|
|
2331
2414
|
const b = this.getAttribute("title");
|
|
2332
|
-
b && (t.fillStyle =
|
|
2415
|
+
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
2416
|
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
2417
|
let E = -1, N = f;
|
|
2335
|
-
t.font = `${
|
|
2418
|
+
t.font = `${m(g)}px ${d}`;
|
|
2336
2419
|
for (const [M, C] of w.entries()) {
|
|
2337
2420
|
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(
|
|
2421
|
+
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;
|
|
2422
|
+
const k = C.legend;
|
|
2423
|
+
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") {
|
|
2424
|
+
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);
|
|
2425
|
+
k.colors.forEach((gr, br) => B.addColorStop(k.colors.length === 1 ? 0 : br / (k.colors.length - 1), gr)), 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);
|
|
2426
|
+
const pr = k.domain[1].toLocaleString("en-US");
|
|
2427
|
+
t.textAlign = "right", t.fillText(pr, m(R + L), p), t.textAlign = "left", p += m(3.2);
|
|
2345
2428
|
} else {
|
|
2346
|
-
const L = [...
|
|
2347
|
-
|
|
2429
|
+
const L = [...k.entries];
|
|
2430
|
+
k.kind === "categories" && k.defaultColor && L.push({ color: k.defaultColor, label: "other" }), t.font = `${m(2.3)}px ${d}`;
|
|
2348
2431
|
for (const R of L) {
|
|
2349
|
-
if (p >
|
|
2350
|
-
t.fillStyle = R.color, t.fillRect(
|
|
2432
|
+
if (p > o) break;
|
|
2433
|
+
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
2434
|
}
|
|
2352
|
-
p +=
|
|
2435
|
+
p += m(1);
|
|
2353
2436
|
}
|
|
2354
|
-
t.restore(), t.font = `${
|
|
2437
|
+
t.restore(), t.font = `${m(2.6)}px ${d}`;
|
|
2355
2438
|
}
|
|
2356
2439
|
}
|
|
2357
2440
|
}
|
|
2358
|
-
const
|
|
2441
|
+
const ct = (r, t) => {
|
|
2359
2442
|
const e = r.createElement("span");
|
|
2360
2443
|
return e.textContent = t, e;
|
|
2361
2444
|
};
|
|
2362
|
-
|
|
2363
|
-
const
|
|
2445
|
+
x("om-legend", ur);
|
|
2446
|
+
const $e = 48, zt = {
|
|
2364
2447
|
toLngLat: (r, t) => [r, t],
|
|
2365
2448
|
fromLngLat: (r) => [r[0], r[1]]
|
|
2366
2449
|
};
|
|
2367
|
-
function
|
|
2368
|
-
return !Number.isFinite(r) || r <= 0 ? 0 :
|
|
2450
|
+
function Ee(r, t = 5) {
|
|
2451
|
+
return !Number.isFinite(r) || r <= 0 ? 0 : Be(r / Math.max(1, t));
|
|
2369
2452
|
}
|
|
2370
|
-
function
|
|
2453
|
+
function Wn({ georef: r, plane: t = zt, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
|
|
2371
2454
|
if (r.degenerate) return null;
|
|
2372
2455
|
const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
|
|
2373
2456
|
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 =
|
|
2457
|
+
const u = Math.min(...l), h = Math.max(...l), d = Math.min(...c), m = Math.max(...c), f = Ne(n ?? e, Ee(h - u)), g = Ne(i ?? e, Ee(m - d));
|
|
2458
|
+
if (f <= 0 || g <= 0 || (h - u) / f > 500 || (m - d) / g > 500) return null;
|
|
2459
|
+
const p = [], b = [], w = o ?? Kn;
|
|
2460
|
+
for (let y = Math.ceil(u / f) * f; y <= h + 1e-9; y += f) {
|
|
2461
|
+
const A = Pe(r, t, y, d, m, "x");
|
|
2379
2462
|
if (A) {
|
|
2380
2463
|
p.push(A);
|
|
2381
|
-
const v = t ===
|
|
2382
|
-
|
|
2464
|
+
const v = t === zt ? nr(y) : y;
|
|
2465
|
+
s !== "none" && Le(b, A, r, w(v, "x"), "x", s);
|
|
2383
2466
|
}
|
|
2384
2467
|
}
|
|
2385
|
-
for (let y = Math.ceil(d / g) * g; y <=
|
|
2386
|
-
const A =
|
|
2387
|
-
A && (p.push(A),
|
|
2468
|
+
for (let y = Math.ceil(d / g) * g; y <= m + 1e-9; y += g) {
|
|
2469
|
+
const A = Pe(r, t, y, u, h, "y");
|
|
2470
|
+
A && (p.push(A), s !== "none" && Le(b, A, r, w(y, "y"), "y", s));
|
|
2388
2471
|
}
|
|
2389
2472
|
return { lines: p, labels: b, intervalX: f, intervalY: g };
|
|
2390
2473
|
}
|
|
2391
|
-
const
|
|
2392
|
-
function
|
|
2393
|
-
const
|
|
2394
|
-
for (let l = 0; l <=
|
|
2395
|
-
const c = n + (i - n) * l /
|
|
2474
|
+
const Ne = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
|
|
2475
|
+
function Pe(r, t, e, n, i, s) {
|
|
2476
|
+
const o = [];
|
|
2477
|
+
for (let l = 0; l <= $e; l++) {
|
|
2478
|
+
const c = n + (i - n) * l / $e, u = s === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
|
|
2396
2479
|
if (!Number.isFinite(u[0]) || !Number.isFinite(u[1])) continue;
|
|
2397
|
-
const
|
|
2398
|
-
|
|
2480
|
+
const h = r.project(u);
|
|
2481
|
+
h && o.push(h);
|
|
2399
2482
|
}
|
|
2400
|
-
const a =
|
|
2401
|
-
return a.length >= 2 ? { points: a, value: e, axis:
|
|
2483
|
+
const a = Bn(o, r.widthMm, r.heightMm);
|
|
2484
|
+
return a.length >= 2 ? { points: a, value: e, axis: s } : null;
|
|
2402
2485
|
}
|
|
2403
|
-
function
|
|
2486
|
+
function Bn(r, t, e) {
|
|
2404
2487
|
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
2488
|
if (i === -1) return [];
|
|
2406
|
-
let
|
|
2407
|
-
for (;
|
|
2408
|
-
return r.slice(Math.max(0, i - 1), Math.min(r.length,
|
|
2489
|
+
let s = r.length - 1;
|
|
2490
|
+
for (; s > i && !n(r[s]); ) s--;
|
|
2491
|
+
return r.slice(Math.max(0, i - 1), Math.min(r.length, s + 2)).map((a) => ({ xMm: Te(a.xMm, 0, t), yMm: Te(a.yMm, 0, e) }));
|
|
2409
2492
|
}
|
|
2410
|
-
const
|
|
2411
|
-
function
|
|
2493
|
+
const Te = (r, t, e) => Math.min(e, Math.max(t, r));
|
|
2494
|
+
function Le(r, t, e, n, i, s) {
|
|
2412
2495
|
if (i === "x") {
|
|
2413
|
-
const
|
|
2414
|
-
if (Math.abs(
|
|
2415
|
-
r.push({ text: n, xMm:
|
|
2496
|
+
const o = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
|
|
2497
|
+
if (Math.abs(o.yMm - e.heightMm) > 0.5) return;
|
|
2498
|
+
r.push({ text: n, xMm: o.xMm, yMm: e.heightMm + (s === "outside" ? 3 : -1), edge: "bottom", axis: i });
|
|
2416
2499
|
} else {
|
|
2417
|
-
const
|
|
2418
|
-
if (Math.abs(
|
|
2419
|
-
r.push({ text: n, xMm:
|
|
2500
|
+
const o = t.points.reduce((a, l) => l.xMm < a.xMm ? l : a);
|
|
2501
|
+
if (Math.abs(o.xMm) > 0.5) return;
|
|
2502
|
+
r.push({ text: n, xMm: s === "outside" ? -1.2 : 1.2, yMm: o.yMm, edge: "left", axis: i });
|
|
2420
2503
|
}
|
|
2421
2504
|
}
|
|
2422
|
-
function
|
|
2505
|
+
function Kn(r, t) {
|
|
2423
2506
|
if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
|
|
2424
2507
|
const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
|
|
2425
2508
|
return `${Number(r.toFixed(e))}°`;
|
|
2426
2509
|
}
|
|
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(
|
|
2510
|
+
function Vn(r, t) {
|
|
2511
|
+
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;
|
|
2512
|
+
return `${c}°${String(u).padStart(2, "0")}′${String(h).padStart(2, "0")}″${e}`;
|
|
2430
2513
|
}
|
|
2431
|
-
const
|
|
2432
|
-
class
|
|
2514
|
+
const ut = "http://www.w3.org/2000/svg", Hn = ["solid", "cross", "markers"], j = 1.4;
|
|
2515
|
+
class hr extends O {
|
|
2433
2516
|
static observedAttributes = [...T["om-graticule"]];
|
|
2434
2517
|
resolvedPlane = null;
|
|
2435
2518
|
resolvedPlaneKey = null;
|
|
2436
2519
|
resolveToken = 0;
|
|
2437
2520
|
get kind() {
|
|
2438
2521
|
const t = this.getAttribute("kind");
|
|
2439
|
-
return
|
|
2522
|
+
return Hn.includes(t) ? t : "solid";
|
|
2440
2523
|
}
|
|
2441
2524
|
get labelPlacement() {
|
|
2442
2525
|
const t = this.getAttribute("labels");
|
|
@@ -2449,17 +2532,17 @@ class or extends O {
|
|
|
2449
2532
|
const e = this.gridPlane();
|
|
2450
2533
|
if (!e) return null;
|
|
2451
2534
|
const n = (i) => {
|
|
2452
|
-
const
|
|
2453
|
-
return Number.isFinite(
|
|
2535
|
+
const s = Number(this.getAttribute(i));
|
|
2536
|
+
return Number.isFinite(s) && s > 0 ? s : null;
|
|
2454
2537
|
};
|
|
2455
|
-
return
|
|
2538
|
+
return Wn({
|
|
2456
2539
|
georef: t,
|
|
2457
2540
|
plane: e,
|
|
2458
2541
|
interval: n("interval"),
|
|
2459
2542
|
intervalX: n("interval-x"),
|
|
2460
2543
|
intervalY: n("interval-y"),
|
|
2461
2544
|
labels: this.labelPlacement,
|
|
2462
|
-
format: this.getAttribute("format") === "dms" ?
|
|
2545
|
+
format: this.getAttribute("format") === "dms" ? Vn : void 0
|
|
2463
2546
|
});
|
|
2464
2547
|
}
|
|
2465
2548
|
/**
|
|
@@ -2468,18 +2551,18 @@ class or extends O {
|
|
|
2468
2551
|
* a re-render when it lands.
|
|
2469
2552
|
*/
|
|
2470
2553
|
gridPlane() {
|
|
2471
|
-
const t =
|
|
2472
|
-
if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return
|
|
2554
|
+
const t = Ot(this.getAttribute("crs"));
|
|
2555
|
+
if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return zt;
|
|
2473
2556
|
const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
|
|
2474
2557
|
if (this.resolvedPlaneKey === e) return this.resolvedPlane;
|
|
2475
2558
|
const n = Y(t);
|
|
2476
2559
|
if (n) {
|
|
2477
|
-
const
|
|
2478
|
-
return this.resolvedPlane =
|
|
2560
|
+
const s = { toLngLat: (o, a) => n.inverse([o, a]), fromLngLat: (o) => n.forward(o) };
|
|
2561
|
+
return this.resolvedPlane = s, this.resolvedPlaneKey = e, s;
|
|
2479
2562
|
}
|
|
2480
2563
|
const i = ++this.resolveToken;
|
|
2481
|
-
return
|
|
2482
|
-
i !== this.resolveToken || !
|
|
2564
|
+
return _t(t, this.getAttribute("crs-def")).then((s) => {
|
|
2565
|
+
i !== this.resolveToken || !s || (this.resolvedPlane = { toLngLat: (o, a) => s.inverse([o, a]), fromLngLat: (o) => s.forward(o) }, this.resolvedPlaneKey = e, this.scheduleRender());
|
|
2483
2566
|
}).catch(() => {
|
|
2484
2567
|
}), null;
|
|
2485
2568
|
}
|
|
@@ -2497,149 +2580,149 @@ class or extends O {
|
|
|
2497
2580
|
this.renderSvg(e);
|
|
2498
2581
|
}
|
|
2499
2582
|
renderSvg(t) {
|
|
2500
|
-
const { w: e, h: n } = S(this), i = this.ownerDocument,
|
|
2501
|
-
|
|
2502
|
-
const
|
|
2583
|
+
const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(ut, "svg");
|
|
2584
|
+
s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.style.cssText = "display:block;overflow:visible;";
|
|
2585
|
+
const o = "var(--om-carto-graticule-ink)", a = this.kind;
|
|
2503
2586
|
for (const l of t.lines)
|
|
2504
2587
|
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",
|
|
2588
|
+
const c = i.createElementNS(ut, "polyline");
|
|
2589
|
+
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
2590
|
} else
|
|
2508
2591
|
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",
|
|
2592
|
+
const u = i.createElementNS(ut, "path");
|
|
2593
|
+
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
2594
|
}
|
|
2512
2595
|
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",
|
|
2596
|
+
const c = i.createElementNS(ut, "text");
|
|
2597
|
+
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
2598
|
}
|
|
2516
|
-
this.replaceChildren(
|
|
2599
|
+
this.replaceChildren(s);
|
|
2517
2600
|
}
|
|
2518
2601
|
/** Intersections of this line with the perpendicular family. */
|
|
2519
2602
|
tickPoints(t, e, n) {
|
|
2520
2603
|
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 &&
|
|
2604
|
+
const i = n.lines.filter((o) => o.axis !== t.axis), s = [];
|
|
2605
|
+
for (const o of i) {
|
|
2606
|
+
const a = Yn(t.points, o.points);
|
|
2607
|
+
a && s.push(a);
|
|
2525
2608
|
}
|
|
2526
|
-
return
|
|
2609
|
+
return s;
|
|
2527
2610
|
}
|
|
2528
2611
|
paintCartograph(t, e) {
|
|
2529
2612
|
const n = this.graticule;
|
|
2530
2613
|
if (!n) return;
|
|
2531
|
-
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null,
|
|
2532
|
-
t.save(), t.strokeStyle =
|
|
2614
|
+
const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = I(i?.color) ?? "#ffffff", o = (l) => l * e.pxPerMm, a = this.kind;
|
|
2615
|
+
t.save(), t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(0.15);
|
|
2533
2616
|
for (const l of n.lines)
|
|
2534
2617
|
if (a === "solid")
|
|
2535
|
-
t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(
|
|
2618
|
+
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
2619
|
else
|
|
2537
2620
|
for (const c of this.tickPoints(l, a, n))
|
|
2538
|
-
t.beginPath(), t.moveTo(
|
|
2539
|
-
t.font = `${
|
|
2621
|
+
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();
|
|
2622
|
+
t.font = `${o(2.2)}px ${i?.fontFamily || "system-ui, sans-serif"}`, t.textBaseline = "alphabetic";
|
|
2540
2623
|
for (const l of n.labels)
|
|
2541
|
-
t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text,
|
|
2624
|
+
t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text, o(l.xMm), o(l.yMm));
|
|
2542
2625
|
t.restore();
|
|
2543
2626
|
}
|
|
2544
2627
|
}
|
|
2545
|
-
function
|
|
2628
|
+
function Yn(r, t) {
|
|
2546
2629
|
let e = null, n = Number.POSITIVE_INFINITY;
|
|
2547
2630
|
for (const i of r)
|
|
2548
|
-
for (const
|
|
2549
|
-
const
|
|
2550
|
-
|
|
2631
|
+
for (const s of t) {
|
|
2632
|
+
const o = (i.xMm - s.xMm) ** 2 + (i.yMm - s.yMm) ** 2;
|
|
2633
|
+
o < n && (n = o, e = i);
|
|
2551
2634
|
}
|
|
2552
2635
|
return n <= 1 ? e : null;
|
|
2553
2636
|
}
|
|
2554
|
-
|
|
2555
|
-
function
|
|
2637
|
+
x("om-graticule", hr);
|
|
2638
|
+
function Xn(r, t) {
|
|
2556
2639
|
if (r == null || typeof r != "object") return;
|
|
2557
2640
|
const e = r.properties;
|
|
2558
2641
|
return e && t in e ? e[t] : r[t];
|
|
2559
2642
|
}
|
|
2560
|
-
function
|
|
2643
|
+
function jt(r, t) {
|
|
2561
2644
|
if (Array.isArray(r)) {
|
|
2562
2645
|
if (typeof r[0] == "number") {
|
|
2563
2646
|
t.push([r[0], r[1]]);
|
|
2564
2647
|
return;
|
|
2565
2648
|
}
|
|
2566
|
-
for (const e of r)
|
|
2649
|
+
for (const e of r) jt(e, t);
|
|
2567
2650
|
}
|
|
2568
2651
|
}
|
|
2569
|
-
function
|
|
2652
|
+
function Jn(r) {
|
|
2570
2653
|
return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
|
|
2571
2654
|
}
|
|
2572
|
-
function
|
|
2573
|
-
return
|
|
2655
|
+
function F(r, t) {
|
|
2656
|
+
return Xn(r, t);
|
|
2574
2657
|
}
|
|
2575
|
-
function
|
|
2658
|
+
function Gt(r) {
|
|
2576
2659
|
const t = {}, e = (i) => {
|
|
2577
|
-
for (const [
|
|
2578
|
-
|
|
2660
|
+
for (const [s, o] of Object.entries(i))
|
|
2661
|
+
o == null || typeof o == "object" || (t[s] = String(o));
|
|
2579
2662
|
};
|
|
2580
2663
|
e(r);
|
|
2581
2664
|
const n = r.properties;
|
|
2582
2665
|
return n && typeof n == "object" && e(n), t;
|
|
2583
2666
|
}
|
|
2584
|
-
function
|
|
2667
|
+
function Zn(r) {
|
|
2585
2668
|
let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
|
|
2586
|
-
const
|
|
2587
|
-
if (
|
|
2588
|
-
else if (Array.isArray(r.coordinates))
|
|
2669
|
+
const s = [], o = r.geometry;
|
|
2670
|
+
if (o?.coordinates != null) jt(o.coordinates, s);
|
|
2671
|
+
else if (Array.isArray(r.coordinates)) jt(r.coordinates, s);
|
|
2589
2672
|
else {
|
|
2590
|
-
const a = Number(
|
|
2591
|
-
Number.isFinite(a) && Number.isFinite(l) &&
|
|
2673
|
+
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"));
|
|
2674
|
+
Number.isFinite(a) && Number.isFinite(l) && s.push([a, l]);
|
|
2592
2675
|
}
|
|
2593
|
-
for (const [a, l] of
|
|
2676
|
+
for (const [a, l] of s)
|
|
2594
2677
|
!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
2678
|
return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
|
|
2596
2679
|
}
|
|
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((
|
|
2680
|
+
function Qn(r, t) {
|
|
2681
|
+
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;
|
|
2682
|
+
return [e - l, n - c, i + l, s + c];
|
|
2683
|
+
}
|
|
2684
|
+
const Fi = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
|
|
2685
|
+
function ti({ features: r, filter: t, sort: e }) {
|
|
2686
|
+
let n = t ? r.filter((s) => ei(t, s)) : [...r];
|
|
2687
|
+
const i = ri(e);
|
|
2688
|
+
return i.length > 0 && (n = [...n].sort((s, o) => {
|
|
2606
2689
|
for (const { field: a, descending: l } of i) {
|
|
2607
|
-
const c =
|
|
2690
|
+
const c = F(s, a), u = F(o, a);
|
|
2608
2691
|
if (c == null && u == null) continue;
|
|
2609
2692
|
if (c == null) return 1;
|
|
2610
2693
|
if (u == null) return -1;
|
|
2611
|
-
const
|
|
2612
|
-
if (
|
|
2694
|
+
const h = ni(c, u);
|
|
2695
|
+
if (h !== 0) return l ? -h : h;
|
|
2613
2696
|
}
|
|
2614
2697
|
return 0;
|
|
2615
2698
|
})), n;
|
|
2616
2699
|
}
|
|
2617
|
-
function
|
|
2700
|
+
function ei(r, t) {
|
|
2618
2701
|
try {
|
|
2619
2702
|
return !!r(t);
|
|
2620
2703
|
} catch {
|
|
2621
2704
|
return !1;
|
|
2622
2705
|
}
|
|
2623
2706
|
}
|
|
2624
|
-
function
|
|
2707
|
+
function ri(r) {
|
|
2625
2708
|
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
2709
|
}
|
|
2627
|
-
function
|
|
2710
|
+
function ni(r, t) {
|
|
2628
2711
|
return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
|
|
2629
2712
|
}
|
|
2630
|
-
function
|
|
2713
|
+
function ii(r) {
|
|
2631
2714
|
const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
|
|
2632
2715
|
return t === "" ? "page" : t;
|
|
2633
2716
|
}
|
|
2634
|
-
function
|
|
2717
|
+
function si(r, t, e) {
|
|
2635
2718
|
const n = /* @__PURE__ */ new Map();
|
|
2636
|
-
return t.map((i,
|
|
2637
|
-
const
|
|
2719
|
+
return t.map((i, s) => {
|
|
2720
|
+
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
2721
|
return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
|
|
2639
2722
|
});
|
|
2640
2723
|
}
|
|
2641
|
-
const
|
|
2642
|
-
class
|
|
2724
|
+
const Re = "data-om-carto-pager", oi = "data-om-carto-screen-only", ai = "onlymap-cartograph", li = "onlymap-cartograph-host";
|
|
2725
|
+
class mr extends O {
|
|
2643
2726
|
static observedAttributes = [...T["om-atlas"]];
|
|
2644
2727
|
/**
|
|
2645
2728
|
* Pages are SNAPSHOTTED when iteration first starts. A streaming or polling
|
|
@@ -2689,7 +2772,7 @@ class ar extends O {
|
|
|
2689
2772
|
*/
|
|
2690
2773
|
onHostMessage = (t) => {
|
|
2691
2774
|
const e = t.data;
|
|
2692
|
-
!e || e.source !==
|
|
2775
|
+
!e || e.source !== li || e.type !== "atlas-seek" || typeof e.index == "number" && Number.isInteger(e.index) && this.seek(e.index);
|
|
2693
2776
|
};
|
|
2694
2777
|
/** The frame whose layer drives the iteration — the same `for=` rule every furniture element follows. */
|
|
2695
2778
|
get frame() {
|
|
@@ -2710,16 +2793,16 @@ class ar extends O {
|
|
|
2710
2793
|
}
|
|
2711
2794
|
/** Export filenames, one per page, already de-duplicated. */
|
|
2712
2795
|
filenames(t = "png") {
|
|
2713
|
-
return
|
|
2796
|
+
return si(this.getAttribute("filename"), this.ensurePages(), t);
|
|
2714
2797
|
}
|
|
2715
2798
|
/** Human page labels, for an editor's stepper and PDF bookmarks. */
|
|
2716
2799
|
pageName(t) {
|
|
2717
2800
|
const e = this.ensurePages()[t];
|
|
2718
2801
|
if (!e) return `Page ${t + 1}`;
|
|
2719
|
-
const n =
|
|
2802
|
+
const n = Gt(e), i = this.getAttribute("page-name");
|
|
2720
2803
|
return i ? i.replace(
|
|
2721
2804
|
/\{\{\s*atlas\.([\w]+)\s*\}\}/g,
|
|
2722
|
-
(
|
|
2805
|
+
(s, o) => o === "index" ? String(t + 1) : o === "count" ? String(this.count) : n[o] ?? s
|
|
2723
2806
|
) : n.name ?? n.title ?? `Page ${t + 1}`;
|
|
2724
2807
|
}
|
|
2725
2808
|
/**
|
|
@@ -2734,11 +2817,11 @@ class ar extends O {
|
|
|
2734
2817
|
}
|
|
2735
2818
|
ensurePages() {
|
|
2736
2819
|
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 =
|
|
2820
|
+
const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? Jn(i) : null;
|
|
2821
|
+
if (!e || s)
|
|
2822
|
+
return this.rejection = e ? s : null, this.pages = [];
|
|
2823
|
+
const o = this.materialize(i);
|
|
2824
|
+
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
2825
|
}
|
|
2743
2826
|
/**
|
|
2744
2827
|
* Rows from the layer, with the layer's OWN declarative filters applied —
|
|
@@ -2748,11 +2831,11 @@ class ar extends O {
|
|
|
2748
2831
|
materialize(t) {
|
|
2749
2832
|
const e = J(), n = t.data;
|
|
2750
2833
|
if (!n) return [];
|
|
2751
|
-
const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [],
|
|
2752
|
-
return
|
|
2753
|
-
(
|
|
2834
|
+
const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [], s = [t.filter, t.categoryFilter].filter(Boolean);
|
|
2835
|
+
return s.length === 0 ? i : i.filter(
|
|
2836
|
+
(o) => s.every((a) => {
|
|
2754
2837
|
if (!a.field) return !0;
|
|
2755
|
-
const l =
|
|
2838
|
+
const l = F(o, a.field);
|
|
2756
2839
|
if (a.range) {
|
|
2757
2840
|
const c = Number(l);
|
|
2758
2841
|
return Number.isFinite(c) && c >= a.range[0] && c <= a.range[1];
|
|
@@ -2787,14 +2870,14 @@ class ar extends O {
|
|
|
2787
2870
|
const t = this.current;
|
|
2788
2871
|
if (!t) return;
|
|
2789
2872
|
const e = this.closest("om-cartograph");
|
|
2790
|
-
for (const
|
|
2791
|
-
if (
|
|
2792
|
-
const
|
|
2793
|
-
if (!
|
|
2794
|
-
const a = Number(
|
|
2795
|
-
|
|
2796
|
-
}
|
|
2797
|
-
e?.setAtlasFields({ ...
|
|
2873
|
+
for (const s of e?.querySelectorAll("om-frame") ?? []) {
|
|
2874
|
+
if (s.getAttribute("atlas-fit") !== "feature") continue;
|
|
2875
|
+
const o = Zn(t);
|
|
2876
|
+
if (!o) continue;
|
|
2877
|
+
const a = Number(s.getAttribute("atlas-margin")), l = Qn(o, Number.isFinite(a) && a > 0 ? a : 0.15);
|
|
2878
|
+
s.fitBounds?.(l);
|
|
2879
|
+
}
|
|
2880
|
+
e?.setAtlasFields({ ...Gt(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture();
|
|
2798
2881
|
const n = this.pageName(this.currentIndex);
|
|
2799
2882
|
this.dispatchEvent(
|
|
2800
2883
|
new CustomEvent("om-atlas-page", {
|
|
@@ -2803,7 +2886,7 @@ class ar extends O {
|
|
|
2803
2886
|
})
|
|
2804
2887
|
), this.renderPager();
|
|
2805
2888
|
const i = typeof window < "u" ? window.parent : null;
|
|
2806
|
-
i && i !== window && i.postMessage({ source:
|
|
2889
|
+
i && i !== window && i.postMessage({ source: ai, type: "atlas-page", index: this.currentIndex, count: this.count, name: n }, "*");
|
|
2807
2890
|
}
|
|
2808
2891
|
/**
|
|
2809
2892
|
* Draw (or update) the reader's page control on the owning sheet:
|
|
@@ -2814,30 +2897,30 @@ class ar extends O {
|
|
|
2814
2897
|
renderPager() {
|
|
2815
2898
|
const t = this.closest("om-cartograph");
|
|
2816
2899
|
if (!t) return;
|
|
2817
|
-
const e = t.querySelector(`:scope > [${
|
|
2900
|
+
const e = t.querySelector(`:scope > [${Re}]`), n = this.count;
|
|
2818
2901
|
if (this.getAttribute("pager") === "none" || n === 0) {
|
|
2819
2902
|
e?.remove(), this.pager = null;
|
|
2820
2903
|
return;
|
|
2821
2904
|
}
|
|
2822
|
-
const i = this.ownerDocument,
|
|
2905
|
+
const i = this.ownerDocument, s = e ?? i.createElement("div");
|
|
2823
2906
|
if (!e) {
|
|
2824
|
-
|
|
2825
|
-
for (const [u,
|
|
2907
|
+
s.setAttribute(Re, ""), 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;";
|
|
2908
|
+
for (const [u, h, d] of [
|
|
2826
2909
|
[-1, "‹", "Previous page"],
|
|
2827
2910
|
[1, "›", "Next page"]
|
|
2828
2911
|
]) {
|
|
2829
|
-
const
|
|
2830
|
-
|
|
2912
|
+
const m = i.createElement("button");
|
|
2913
|
+
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
2914
|
}
|
|
2832
2915
|
const c = i.createElement("span");
|
|
2833
|
-
c.setAttribute("data-om-carto-pager-label", ""),
|
|
2916
|
+
c.setAttribute("data-om-carto-pager-label", ""), s.insertBefore(c, s.lastElementChild), t.appendChild(s);
|
|
2834
2917
|
}
|
|
2835
|
-
const
|
|
2836
|
-
|
|
2837
|
-
const [a, l] =
|
|
2918
|
+
const o = s.querySelector("[data-om-carto-pager-label]");
|
|
2919
|
+
o.textContent = `${this.currentIndex + 1} / ${n} · ${this.pageName(this.currentIndex)}`;
|
|
2920
|
+
const [a, l] = s.querySelectorAll("button");
|
|
2838
2921
|
a && (a.disabled = this.currentIndex === 0), l && (l.disabled = this.currentIndex >= n - 1);
|
|
2839
2922
|
for (const c of [a, l]) c && (c.style.opacity = c.disabled ? ".35" : "1");
|
|
2840
|
-
this.pager =
|
|
2923
|
+
this.pager = s;
|
|
2841
2924
|
}
|
|
2842
2925
|
connectedCallback() {
|
|
2843
2926
|
super.connectedCallback(), this.ownerDocument.addEventListener("keydown", this.onKeyDown), typeof window < "u" && window.addEventListener("message", this.onHostMessage);
|
|
@@ -2853,8 +2936,8 @@ class ar extends O {
|
|
|
2853
2936
|
this.style.display = "none", this.refresh();
|
|
2854
2937
|
}
|
|
2855
2938
|
}
|
|
2856
|
-
|
|
2857
|
-
class
|
|
2939
|
+
x("om-atlas", mr);
|
|
2940
|
+
class ci extends qe {
|
|
2858
2941
|
static observedAttributes = [...T["om-source"]];
|
|
2859
2942
|
connectedCallback() {
|
|
2860
2943
|
this.style.display = "none";
|
|
@@ -2868,8 +2951,8 @@ class ri extends De {
|
|
|
2868
2951
|
this.closest("om-frame")?.scheduleRender?.();
|
|
2869
2952
|
}
|
|
2870
2953
|
}
|
|
2871
|
-
const
|
|
2872
|
-
function
|
|
2954
|
+
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);
|
|
2955
|
+
function dr(r) {
|
|
2873
2956
|
const t = r.tagName.toLowerCase();
|
|
2874
2957
|
return r.id ? `${t}#${r.id}` : t;
|
|
2875
2958
|
}
|
|
@@ -2879,97 +2962,97 @@ function H(r, t) {
|
|
|
2879
2962
|
const n = Number(e);
|
|
2880
2963
|
return Number.isFinite(n) ? n : null;
|
|
2881
2964
|
}
|
|
2882
|
-
function
|
|
2965
|
+
function bi(r, t) {
|
|
2883
2966
|
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
2967
|
}
|
|
2885
|
-
function
|
|
2968
|
+
function yi(r, t) {
|
|
2886
2969
|
const e = r.getAttribute("style");
|
|
2887
2970
|
if (!e) return null;
|
|
2888
2971
|
const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
|
|
2889
2972
|
return n ? Number(n[1]) : null;
|
|
2890
2973
|
}
|
|
2891
|
-
function
|
|
2892
|
-
const t = [], e = (
|
|
2893
|
-
t.push({ severity:
|
|
2974
|
+
function fr(r) {
|
|
2975
|
+
const t = [], e = (o, a, l, c, u) => {
|
|
2976
|
+
t.push({ severity: o, element: dr(a), ...u ? { attribute: u } : {}, message: l, fix: c });
|
|
2894
2977
|
}, n = [...r.querySelectorAll("om-cartograph")];
|
|
2895
2978
|
if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
|
|
2896
2979
|
return { valid: !0, errors: [], warnings: [] };
|
|
2897
|
-
for (const
|
|
2898
|
-
const i = t.filter((
|
|
2899
|
-
return { valid: i.length === 0, errors: i, warnings:
|
|
2980
|
+
for (const o of n) wi(o, e);
|
|
2981
|
+
const i = t.filter((o) => o.severity === "error"), s = t.filter((o) => o.severity === "warning");
|
|
2982
|
+
return { valid: i.length === 0, errors: i, warnings: s };
|
|
2900
2983
|
}
|
|
2901
|
-
function
|
|
2984
|
+
function wi(r, t) {
|
|
2902
2985
|
const e = r.getAttribute("size"), n = H(r, "width") != null && H(r, "height") != null;
|
|
2903
|
-
e && !
|
|
2986
|
+
e && !oe.includes(e) && !n && t(
|
|
2904
2987
|
"error",
|
|
2905
2988
|
r,
|
|
2906
2989
|
`Unknown page size "${e}" and no width/height to fall back on.`,
|
|
2907
|
-
`Use one of ${
|
|
2990
|
+
`Use one of ${oe.join(", ")}, or give width= and height= in millimetres.`,
|
|
2908
2991
|
"size"
|
|
2909
2992
|
);
|
|
2910
2993
|
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
|
-
!
|
|
2994
|
+
i && i.trim().toLowerCase() !== "none" && !qt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${Sr.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");
|
|
2995
|
+
const s = H(r, "safe-zone");
|
|
2996
|
+
if (s != null && s > 0) {
|
|
2997
|
+
const m = dt(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
|
|
2998
|
+
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");
|
|
2999
|
+
}
|
|
3000
|
+
const o = r.getAttribute("format");
|
|
3001
|
+
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");
|
|
3002
|
+
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")];
|
|
3003
|
+
for (const m of h)
|
|
3004
|
+
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");
|
|
3005
|
+
for (const m of r.children) {
|
|
3006
|
+
if (mi.some((g) => m.hasAttribute(g))) continue;
|
|
3007
|
+
const f = m.tagName.toLowerCase();
|
|
3008
|
+
!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
3009
|
}
|
|
2927
3010
|
const d = [];
|
|
2928
|
-
for (const
|
|
2929
|
-
const f =
|
|
2930
|
-
if (
|
|
2931
|
-
if (
|
|
2932
|
-
const g = S(
|
|
2933
|
-
|
|
3011
|
+
for (const m of [r, ...r.querySelectorAll("*")]) {
|
|
3012
|
+
const f = m.tagName.toLowerCase();
|
|
3013
|
+
if (yt.includes(f) && !m.closest("om-map")) {
|
|
3014
|
+
if (vi(m, f, t), fi.has(f)) {
|
|
3015
|
+
const g = S(m);
|
|
3016
|
+
Ai(m, g, a, l, c, t), di.has(f) && !m.hasAttribute("hidden") && d.push({ el: m, box: g });
|
|
2934
3017
|
}
|
|
2935
|
-
f === "om-frame" &&
|
|
3018
|
+
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
3019
|
for (const g of ["for", "overview-of"]) {
|
|
2937
|
-
const p =
|
|
2938
|
-
p && !u.has(p) && t("error",
|
|
3020
|
+
const p = m.getAttribute(g);
|
|
3021
|
+
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
3022
|
}
|
|
2940
3023
|
}
|
|
2941
3024
|
}
|
|
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 ||
|
|
3025
|
+
for (let m = 0; m < d.length; m++)
|
|
3026
|
+
for (let f = m + 1; f < d.length; f++) {
|
|
3027
|
+
const g = d[m], p = d[f];
|
|
3028
|
+
g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || bi(g.box, p.box) && t(
|
|
2946
3029
|
"warning",
|
|
2947
3030
|
g.el,
|
|
2948
|
-
`Overlaps ${
|
|
3031
|
+
`Overlaps ${dr(p.el)} on the page.`,
|
|
2949
3032
|
"Move one of them — furniture overlapping furniture usually means a stale layout (frames may sit under anything)."
|
|
2950
3033
|
);
|
|
2951
3034
|
}
|
|
2952
3035
|
}
|
|
2953
|
-
function
|
|
3036
|
+
function vi(r, t, e) {
|
|
2954
3037
|
const n = new Set(T[t] ?? []);
|
|
2955
3038
|
for (const i of r.attributes) {
|
|
2956
|
-
const
|
|
2957
|
-
if (n.has(
|
|
2958
|
-
const
|
|
2959
|
-
if (
|
|
2960
|
-
e("warning", r, `Attribute "${
|
|
3039
|
+
const s = i.name.toLowerCase();
|
|
3040
|
+
if (n.has(s) || ui.has(s) || s.startsWith("data-") || s.startsWith("aria-")) continue;
|
|
3041
|
+
const o = Ur.get(s);
|
|
3042
|
+
if (o) {
|
|
3043
|
+
e("warning", r, `Attribute "${s}" has no effect: ${o}`, "Remove it, or use the documented alternative.", s);
|
|
2961
3044
|
continue;
|
|
2962
3045
|
}
|
|
2963
|
-
e("warning", r, `Unknown attribute "${
|
|
3046
|
+
e("warning", r, `Unknown attribute "${s}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, s);
|
|
2964
3047
|
}
|
|
2965
3048
|
}
|
|
2966
|
-
function
|
|
3049
|
+
function Ai(r, t, e, n, i, s) {
|
|
2967
3050
|
if (t.w <= 0 || t.h <= 0) {
|
|
2968
|
-
|
|
3051
|
+
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
3052
|
return;
|
|
2970
3053
|
}
|
|
2971
|
-
const
|
|
2972
|
-
(t.x <
|
|
3054
|
+
const o = -i, a = e + i, l = n + i;
|
|
3055
|
+
(t.x < o || t.y < o || t.x + t.w > a + 1e-6 || t.y + t.h > l + 1e-6) && s(
|
|
2973
3056
|
"error",
|
|
2974
3057
|
r,
|
|
2975
3058
|
`Element box (${t.x}, ${t.y}, ${t.w} × ${t.h} mm) falls outside the ${e} × ${n} mm page${i ? ` (+${i}mm bleed)` : ""}.`,
|
|
@@ -2981,18 +3064,18 @@ function fi(r, t, e, n, i, o) {
|
|
|
2981
3064
|
["width", t.w],
|
|
2982
3065
|
["height", t.h]
|
|
2983
3066
|
];
|
|
2984
|
-
for (const [u,
|
|
2985
|
-
const d =
|
|
2986
|
-
d != null && Math.abs(d -
|
|
3067
|
+
for (const [u, h] of c) {
|
|
3068
|
+
const d = yi(r, u);
|
|
3069
|
+
d != null && Math.abs(d - h) > 0.01 && s(
|
|
2987
3070
|
"error",
|
|
2988
3071
|
r,
|
|
2989
|
-
`Inline style ${u}:${d}mm disagrees with the placement attribute (${
|
|
3072
|
+
`Inline style ${u}:${d}mm disagrees with the placement attribute (${h}mm).`,
|
|
2990
3073
|
"The attributes are authoritative — make the inline style match, or drop it and let the runtime write it.",
|
|
2991
3074
|
"style"
|
|
2992
3075
|
);
|
|
2993
3076
|
}
|
|
2994
3077
|
}
|
|
2995
|
-
function
|
|
3078
|
+
function Mi(r, t) {
|
|
2996
3079
|
if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
|
|
2997
3080
|
const n = r.getAttribute("corners"), i = X(n);
|
|
2998
3081
|
i || t(
|
|
@@ -3001,20 +3084,20 @@ function pi(r, t) {
|
|
|
3001
3084
|
n == null ? "Static frame has no corners=." : `Static frame has malformed corners= ("${n}").`,
|
|
3002
3085
|
'Give four lon/lat pairs in tl, tr, br, bl order — corners="[[lng,lat],[lng,lat],[lng,lat],[lng,lat]]".',
|
|
3003
3086
|
"corners"
|
|
3004
|
-
), !r.querySelector(":scope > img") && !r.querySelector(`:scope > svg[${
|
|
3087
|
+
), !r.querySelector(":scope > img") && !r.querySelector(`:scope > svg[${Lt}]`) && t(
|
|
3005
3088
|
"error",
|
|
3006
3089
|
r,
|
|
3007
3090
|
"Static frame has no <img> or inline <svg> child to place.",
|
|
3008
3091
|
'Add the georeferenced picture as a child — an <img> raster, or the inline <svg> that snapshot({format: "svg"}) produces.'
|
|
3009
3092
|
);
|
|
3010
|
-
const
|
|
3011
|
-
if (i &&
|
|
3012
|
-
const a = tt({ corners: i, widthMm:
|
|
3093
|
+
const s = S(r), o = Y(r.getAttribute("crs"));
|
|
3094
|
+
if (i && o && s.w > 0 && s.h > 0) {
|
|
3095
|
+
const a = tt({ corners: i, widthMm: s.w, heightMm: s.h, crsForward: o });
|
|
3013
3096
|
if (a.degenerate)
|
|
3014
3097
|
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
3098
|
else {
|
|
3016
|
-
const l =
|
|
3017
|
-
l != null && l >
|
|
3099
|
+
const l = An(a);
|
|
3100
|
+
l != null && l > pi && t(
|
|
3018
3101
|
"warning",
|
|
3019
3102
|
r,
|
|
3020
3103
|
`Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
|
|
@@ -3023,7 +3106,7 @@ function pi(r, t) {
|
|
|
3023
3106
|
}
|
|
3024
3107
|
}
|
|
3025
3108
|
} else {
|
|
3026
|
-
|
|
3109
|
+
mt(r) || t(
|
|
3027
3110
|
"error",
|
|
3028
3111
|
r,
|
|
3029
3112
|
"Live frame has no valid camera.",
|
|
@@ -3069,7 +3152,7 @@ function pi(r, t) {
|
|
|
3069
3152
|
);
|
|
3070
3153
|
}
|
|
3071
3154
|
}
|
|
3072
|
-
function
|
|
3155
|
+
function Si(r, t) {
|
|
3073
3156
|
const e = r.parentElement;
|
|
3074
3157
|
if (e?.tagName.toLowerCase() !== "om-frame") {
|
|
3075
3158
|
t(
|
|
@@ -3085,7 +3168,7 @@ function gi(r, t) {
|
|
|
3085
3168
|
t("error", r, "<om-source> has no src=.", "Give it a map document (.html) or a capture image.", "src");
|
|
3086
3169
|
return;
|
|
3087
3170
|
}
|
|
3088
|
-
const i =
|
|
3171
|
+
const i = Dt(n);
|
|
3089
3172
|
if (!i) {
|
|
3090
3173
|
t(
|
|
3091
3174
|
"error",
|
|
@@ -3097,22 +3180,22 @@ function gi(r, t) {
|
|
|
3097
3180
|
return;
|
|
3098
3181
|
}
|
|
3099
3182
|
if (i === "raster") {
|
|
3100
|
-
const
|
|
3101
|
-
X(
|
|
3183
|
+
const s = r.getAttribute("corners");
|
|
3184
|
+
X(s) || t(
|
|
3102
3185
|
"error",
|
|
3103
3186
|
r,
|
|
3104
|
-
|
|
3187
|
+
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
3188
|
'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
3189
|
"corners"
|
|
3107
3190
|
);
|
|
3108
3191
|
} else
|
|
3109
|
-
for (const
|
|
3110
|
-
r.hasAttribute(
|
|
3192
|
+
for (const s of ["corners", "crs", "crs-def"])
|
|
3193
|
+
r.hasAttribute(s) && t(
|
|
3111
3194
|
"warning",
|
|
3112
3195
|
r,
|
|
3113
|
-
`${
|
|
3196
|
+
`${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
3197
|
"Remove it. It belongs on a capture <om-source>, whose georeference is otherwise unknowable.",
|
|
3115
|
-
|
|
3198
|
+
s
|
|
3116
3199
|
);
|
|
3117
3200
|
e.getAttribute("mode") === "static" && t(
|
|
3118
3201
|
"warning",
|
|
@@ -3121,12 +3204,12 @@ function gi(r, t) {
|
|
|
3121
3204
|
'Remove mode="static" to let the frame resolve its sources, or drop the <om-source>.'
|
|
3122
3205
|
);
|
|
3123
3206
|
}
|
|
3124
|
-
function
|
|
3207
|
+
function Yt(r, t) {
|
|
3125
3208
|
const e = r.getAttribute("for");
|
|
3126
3209
|
return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
|
|
3127
3210
|
}
|
|
3128
|
-
function
|
|
3129
|
-
const n = r.getAttribute("derived") !== "false", i =
|
|
3211
|
+
function Ci(r, t, e) {
|
|
3212
|
+
const n = r.getAttribute("derived") !== "false", i = Yt(r, t);
|
|
3130
3213
|
n && i?.getAttribute("mode") === "static" && e(
|
|
3131
3214
|
"warning",
|
|
3132
3215
|
r,
|
|
@@ -3134,30 +3217,30 @@ function bi(r, t, e) {
|
|
|
3134
3217
|
'Write the rows as <om-legend-row color= label= shape=> children and set derived="false".',
|
|
3135
3218
|
"derived"
|
|
3136
3219
|
);
|
|
3137
|
-
const
|
|
3138
|
-
if (
|
|
3139
|
-
const
|
|
3140
|
-
if (
|
|
3141
|
-
const a =
|
|
3220
|
+
const s = cr(r);
|
|
3221
|
+
if (s.length < 2) return;
|
|
3222
|
+
const o = kr(s.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
|
|
3223
|
+
if (o.collapses.length > 0 && o.worstType) {
|
|
3224
|
+
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
3225
|
e(
|
|
3143
3226
|
"warning",
|
|
3144
3227
|
r,
|
|
3145
|
-
`Under ${
|
|
3228
|
+
`Under ${o.worstType}, ${a.length === 1 ? "one legend pair becomes" : `${a.length} legend pairs become`} indistinguishable: ${l}.`,
|
|
3146
3229
|
"Pick colours that differ in lightness as well as hue, or add a pattern or label to separate them."
|
|
3147
3230
|
);
|
|
3148
3231
|
}
|
|
3149
3232
|
}
|
|
3150
|
-
function
|
|
3233
|
+
function xi(r, t, e) {
|
|
3151
3234
|
const n = r.getAttribute("pager");
|
|
3152
3235
|
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
3236
|
const i = r.getAttribute("layer");
|
|
3154
3237
|
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
|
-
!
|
|
3238
|
+
const s = r.getAttribute("for"), o = Yt(r, t);
|
|
3239
|
+
if (!o) {
|
|
3240
|
+
!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
3241
|
return;
|
|
3159
3242
|
}
|
|
3160
|
-
if (
|
|
3243
|
+
if (o.getAttribute("mode") === "static") {
|
|
3161
3244
|
e(
|
|
3162
3245
|
"error",
|
|
3163
3246
|
r,
|
|
@@ -3167,11 +3250,11 @@ function yi(r, t, e) {
|
|
|
3167
3250
|
);
|
|
3168
3251
|
return;
|
|
3169
3252
|
}
|
|
3170
|
-
const a =
|
|
3253
|
+
const a = o.querySelector(":scope > om-map");
|
|
3171
3254
|
if (a && i) {
|
|
3172
3255
|
const l = [...a.querySelectorAll("om-layer")].find((u) => u.id === i);
|
|
3173
3256
|
if (!l) {
|
|
3174
|
-
e("error", r, `Atlas layer "${i}" is not in frame #${
|
|
3257
|
+
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
3258
|
return;
|
|
3176
3259
|
}
|
|
3177
3260
|
const c = l.getAttribute("data") ?? "";
|
|
@@ -3184,14 +3267,14 @@ function yi(r, t, e) {
|
|
|
3184
3267
|
);
|
|
3185
3268
|
}
|
|
3186
3269
|
}
|
|
3187
|
-
function
|
|
3270
|
+
function ki(r, t, e) {
|
|
3188
3271
|
const n = H(r, "segment-length");
|
|
3189
3272
|
if (n == null) return;
|
|
3190
|
-
const i =
|
|
3273
|
+
const i = Yt(r, t);
|
|
3191
3274
|
if (!i) return;
|
|
3192
|
-
const
|
|
3193
|
-
if (!
|
|
3194
|
-
const l = tt({ corners:
|
|
3275
|
+
const s = X(i.getAttribute("corners")), o = Y(i.getAttribute("crs")), a = S(i);
|
|
3276
|
+
if (!s || !o || a.w <= 0 || a.h <= 0) return;
|
|
3277
|
+
const l = tt({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = S(r), u = Ke({
|
|
3195
3278
|
groundMetersPerMm: l.groundMetersPerMm(),
|
|
3196
3279
|
maxWidthMm: c.w,
|
|
3197
3280
|
segments: H(r, "segments") ?? void 0,
|
|
@@ -3205,148 +3288,148 @@ function wi(r, t, e) {
|
|
|
3205
3288
|
"segment-length"
|
|
3206
3289
|
);
|
|
3207
3290
|
}
|
|
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
|
-
|
|
3291
|
+
function $i(r, t, e) {
|
|
3292
|
+
const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), s = new Set(t.map((o) => o.id).filter(Boolean));
|
|
3293
|
+
for (const o of Hr(n))
|
|
3294
|
+
if (!o.startsWith("atlas.")) {
|
|
3295
|
+
if (o.startsWith("frame.")) {
|
|
3296
|
+
const a = o.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
|
|
3297
|
+
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
3298
|
continue;
|
|
3216
3299
|
}
|
|
3217
|
-
if ((
|
|
3300
|
+
if ((o === "scale" || o === "crs") && t.length !== 1) {
|
|
3218
3301
|
e(
|
|
3219
3302
|
"warning",
|
|
3220
3303
|
r,
|
|
3221
|
-
`{{${
|
|
3222
|
-
`Name the frame: {{frame.<id>.${
|
|
3304
|
+
`{{${o}}} is ambiguous with ${t.length} frames on the page.`,
|
|
3305
|
+
`Name the frame: {{frame.<id>.${o}}}.`
|
|
3223
3306
|
);
|
|
3224
3307
|
continue;
|
|
3225
3308
|
}
|
|
3226
|
-
i.has(
|
|
3309
|
+
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
3310
|
}
|
|
3228
3311
|
}
|
|
3229
|
-
function
|
|
3230
|
-
return
|
|
3312
|
+
function Oi(r) {
|
|
3313
|
+
return fr(Fr(r));
|
|
3231
3314
|
}
|
|
3232
|
-
async function
|
|
3233
|
-
const t =
|
|
3315
|
+
async function _i(r) {
|
|
3316
|
+
const t = fr(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
|
|
3234
3317
|
if (e.length === 0) return t;
|
|
3235
|
-
const { loadCore: n } = await Promise.resolve().then(() =>
|
|
3318
|
+
const { loadCore: n } = await Promise.resolve().then(() => wr), i = await n(), s = [...t.errors], o = [...t.warnings];
|
|
3236
3319
|
for (const a of e) {
|
|
3237
3320
|
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)
|
|
3321
|
+
for (const u of c.errors) s.push({ ...u, element: `${l} > ${u.element}` });
|
|
3322
|
+
for (const u of c.warnings) o.push({ ...u, element: `${l} > ${u.element}` });
|
|
3240
3323
|
}
|
|
3241
|
-
return { valid:
|
|
3324
|
+
return { valid: s.length === 0, errors: s, warnings: o };
|
|
3242
3325
|
}
|
|
3243
|
-
function
|
|
3244
|
-
|
|
3326
|
+
function Ui() {
|
|
3327
|
+
x("om-cartograph", Qe), x("om-text", tr), x("om-frame", ir), x("om-scalebar", sr), x("om-north", or), x("om-shape", ar), x("om-image", lr), x("om-legend", ur), x("om-graticule", hr), x("om-atlas", mr), x("om-source", ci);
|
|
3245
3328
|
}
|
|
3246
|
-
|
|
3247
|
-
|
|
3329
|
+
Ie(() => import("@nika-js/onlymap"));
|
|
3330
|
+
Ir();
|
|
3248
3331
|
export {
|
|
3249
3332
|
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
|
-
|
|
3333
|
+
bt as CARTOGRAPH_FORMAT,
|
|
3334
|
+
yt as CARTOGRAPH_TAG_NAMES,
|
|
3335
|
+
Ei as CARTOGRAPH_THEMES,
|
|
3336
|
+
xr as COLLAPSE_THRESHOLD,
|
|
3337
|
+
Wt as CVD_MATRICES,
|
|
3338
|
+
ft as CVD_TYPES,
|
|
3339
|
+
Sr as CVD_VALUES,
|
|
3340
|
+
zt as GEOGRAPHIC_PLANE,
|
|
3341
|
+
Ur as INERT_RESERVED_CARTOGRAPH_ATTRS,
|
|
3342
|
+
De as MAX_CANVAS_AREA,
|
|
3343
|
+
Ue as MAX_CANVAS_DIMENSION,
|
|
3344
|
+
Nt as MAX_CATEGORY_ENTRIES,
|
|
3345
|
+
mr as OmAtlasElement,
|
|
3346
|
+
Qe as OmCartographElement,
|
|
3347
|
+
ir as OmFrameElement,
|
|
3348
|
+
hr as OmGraticuleElement,
|
|
3349
|
+
lr as OmImageElement,
|
|
3350
|
+
ur as OmLegendElement,
|
|
3351
|
+
or as OmNorthElement,
|
|
3352
|
+
sr as OmScalebarElement,
|
|
3353
|
+
ar as OmShapeElement,
|
|
3354
|
+
tr as OmTextElement,
|
|
3355
|
+
Jt as PAGE_PRESETS,
|
|
3356
|
+
oe as PAGE_SIZE_NAMES,
|
|
3274
3357
|
z as PLACED_ATTR_NAMES,
|
|
3275
3358
|
D as PX_PER_MM,
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3359
|
+
Br as SCALE_GROUP_SEPARATOR,
|
|
3360
|
+
Lr as URL_ACTION_TIMEOUT_MS,
|
|
3361
|
+
rn as alignOffset,
|
|
3362
|
+
Je as allFrames,
|
|
3363
|
+
$r as applyCvdToCanvas,
|
|
3364
|
+
Yr as applyTokens,
|
|
3365
|
+
Rr as applyUrlActions,
|
|
3366
|
+
Gt as atlasFields,
|
|
3367
|
+
Fi as boundsArea,
|
|
3285
3368
|
S as boxMm,
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3369
|
+
Wn as buildGraticule,
|
|
3370
|
+
ti as buildPages,
|
|
3371
|
+
Ke as buildScalebar,
|
|
3372
|
+
Wr as buildScalebarDrawing,
|
|
3290
3373
|
Y as builtinCrsForward,
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3374
|
+
Ni as canvasMeasurer,
|
|
3375
|
+
Zr as clearUnlinked,
|
|
3376
|
+
Ri as cornersFromBounds,
|
|
3377
|
+
Ut as cornersFromCamera,
|
|
3295
3378
|
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
|
-
|
|
3379
|
+
Mr as createZip,
|
|
3380
|
+
Ui as defineCartographElements,
|
|
3381
|
+
ee as deltaE00,
|
|
3382
|
+
zn as deriveLegendRows,
|
|
3383
|
+
Er as ensureCvdFilters,
|
|
3384
|
+
Zn as featureBounds,
|
|
3385
|
+
F as fieldOf,
|
|
3386
|
+
Xe as findFrame,
|
|
3387
|
+
Vn as formatDms,
|
|
3388
|
+
Kr as formatScaleDenominator,
|
|
3389
|
+
Ir as installUrlActions,
|
|
3390
|
+
yr as isCoreLoaded,
|
|
3391
|
+
Xr as isoDate,
|
|
3392
|
+
en as layoutText,
|
|
3393
|
+
kr as lintLegendColours,
|
|
3394
|
+
Fe as loadCore,
|
|
3395
|
+
Ii as maxGeoreferenceablePitch,
|
|
3396
|
+
Pi as mercatorForward,
|
|
3397
|
+
Ti as mercatorInverse,
|
|
3398
|
+
Ee as niceInterval,
|
|
3399
|
+
Be as niceNumberBelow,
|
|
3400
|
+
Ot as normalizeCrs,
|
|
3401
|
+
vn as northBearingDegrees,
|
|
3402
|
+
Ye as ownerCartograph,
|
|
3403
|
+
Qn as padBounds,
|
|
3404
|
+
Xt as paintEnvForDpi,
|
|
3405
|
+
Cr as parseColor,
|
|
3323
3406
|
X as parseCorners,
|
|
3324
|
-
|
|
3407
|
+
ri as parseSort,
|
|
3325
3408
|
J as peekCore,
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3409
|
+
mt as readCamera,
|
|
3410
|
+
cr as readLiteralRows,
|
|
3411
|
+
qn as readOverrides,
|
|
3329
3412
|
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
|
-
|
|
3413
|
+
Jn as rejectionFor,
|
|
3414
|
+
Bt as renderCartograph,
|
|
3415
|
+
je as renderCartographAtlas,
|
|
3416
|
+
_t as resolveCrsForward,
|
|
3417
|
+
qt as resolveCvdType,
|
|
3418
|
+
si as resolveFilenames,
|
|
3419
|
+
dt as resolvePageSize,
|
|
3420
|
+
Vr as resolveToken,
|
|
3421
|
+
He as resolveTokens,
|
|
3422
|
+
Dn as rowColorFor,
|
|
3423
|
+
Sn as sanitizeAdoptedMap,
|
|
3424
|
+
ii as sanitizeFilename,
|
|
3425
|
+
An as scaleVariation,
|
|
3426
|
+
Ie as setCoreLoader,
|
|
3427
|
+
Qt as simulate,
|
|
3428
|
+
Un as swatchShapeFor,
|
|
3429
|
+
Hr as tokensIn,
|
|
3430
|
+
Li as utmDef,
|
|
3431
|
+
fr as validateCartograph,
|
|
3432
|
+
_i as validateCartographDeep,
|
|
3433
|
+
Oi as validateCartographString,
|
|
3434
|
+
ie as whenPageReady
|
|
3352
3435
|
};
|