@nika-js/onlymap 0.10.8 → 0.10.9
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 +9 -0
- package/dist/{basemap-BVnjFQjy.js → basemap-B2VvspL4.js} +2 -2
- package/dist/cartograph/elements/om-atlas.d.ts +24 -0
- package/dist/cartograph/render.d.ts +12 -0
- package/dist/cartograph.js +709 -591
- package/dist/cartograph.standalone.js +1359 -1241
- package/dist/{geoparquet-B9T6_4zS.js → geoparquet-BJQC6zwS.js} +1 -1
- package/dist/{globe-view-H-M5WaEA.js → globe-view-C3Gaf--d.js} +1 -1
- package/dist/{hillshade-CIVdviss.js → hillshade-CNtzlYlz.js} +1 -1
- package/dist/{index-DZAIpBqJ.js → index-C3S0FWlc.js} +3 -3
- package/dist/{index-BmEcYwOm.js → index-CI0vdi2E.js} +1 -1
- package/dist/{index-DlDUl8ad.js → index-CQdTYZ08.js} +3 -3
- package/dist/{index-D_sOimHC.js → index-Cp2kquh5.js} +1 -1
- package/dist/{index-BnOXGh3D.js → index-D2RzlXff.js} +1 -1
- package/dist/{index-8Pn7CrwJ.js → index-DPEWcZeV.js} +18 -18
- package/dist/{index-DZYIEPWK.js → index-a-wOE5hE.js} +1 -1
- package/dist/{index-D2PbSGEg.js → index-j_Ojvo4x.js} +1 -1
- package/dist/{index-C2dp0xNz.js → index-m3UsmxCq.js} +2 -2
- package/dist/{lerc-By_uKoCw.js → lerc-Bv4RLXha.js} +1 -1
- package/dist/onlymap.standalone.js +1 -1
- package/dist/onlymapjs.js +1 -1
- package/dist/{post-process-effect-nmzWxY7I.js → post-process-effect-Cpbyy4I3.js} +1 -1
- package/dist/{raster-2v19l86Q.js → raster-D_HU2WuR.js} +3 -3
- package/dist/{raster-pipeline-BvnoZO-T.js → raster-pipeline-BmcWLImS.js} +1 -1
- package/dist/{text-on-path-huXjU_aC.js → text-on-path-ClLwT2eS.js} +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/{zarr-BTXLI2Nu.js → zarr-CCCIYwWt.js} +2 -2
- package/docs/cartograph.md +22 -3
- package/llms.txt +1 -1
- package/onlymapjs.html-data.json +12 -0
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +1 -1
- package/skills/onlymapjs/references/syntax.md +3 -3
package/dist/cartograph.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
let
|
|
2
|
-
function
|
|
3
|
-
|
|
1
|
+
let xt = null, J = null;
|
|
2
|
+
function Pe(r) {
|
|
3
|
+
xt = r;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function hr() {
|
|
6
6
|
return B !== null;
|
|
7
7
|
}
|
|
8
8
|
let B = null;
|
|
9
9
|
function Y() {
|
|
10
10
|
return B;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return B ? Promise.resolve(B) : J || (
|
|
12
|
+
function Te() {
|
|
13
|
+
return B ? Promise.resolve(B) : J || (xt ? (J = Promise.resolve(xt()).then((r) => (B = r, B)).catch((r) => {
|
|
14
14
|
throw J = null, r;
|
|
15
15
|
}), J) : Promise.reject(
|
|
16
16
|
new Error(
|
|
@@ -18,12 +18,12 @@ function Pe() {
|
|
|
18
18
|
)
|
|
19
19
|
));
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22
22
|
__proto__: null,
|
|
23
|
-
isCoreLoaded:
|
|
24
|
-
loadCore:
|
|
23
|
+
isCoreLoaded: hr,
|
|
24
|
+
loadCore: Te,
|
|
25
25
|
peekCore: Y,
|
|
26
|
-
setCoreLoader:
|
|
26
|
+
setCoreLoader: Pe
|
|
27
27
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
28
28
|
function Bt(r) {
|
|
29
29
|
return { scale: r / 96, pxPerMm: r / 25.4 };
|
|
@@ -47,7 +47,7 @@ function C(r) {
|
|
|
47
47
|
z: W(r, "z")
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function $t(r, t = 0) {
|
|
51
51
|
if (!r) return t;
|
|
52
52
|
const e = Number.parseFloat(r);
|
|
53
53
|
return Number.isFinite(e) ? e : t;
|
|
@@ -57,7 +57,7 @@ function R(r) {
|
|
|
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, Kt = {
|
|
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, Vt = {
|
|
|
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
|
-
},
|
|
69
|
+
}, Vt = "A4";
|
|
70
70
|
function ht(r, t, e, n) {
|
|
71
71
|
const i = t != null ? Number(t) : NaN, o = e != null ? Number(e) : NaN;
|
|
72
72
|
if (Number.isFinite(i) && i > 0 && Number.isFinite(o) && o > 0) return { widthMm: i, heightMm: o };
|
|
73
|
-
const s =
|
|
73
|
+
const s = Kt[r ?? Vt] ?? Kt[Vt];
|
|
74
74
|
return n === "landscape" ? { widthMm: s.heightMm, heightMm: s.widthMm } : { ...s };
|
|
75
75
|
}
|
|
76
76
|
let rt = null;
|
|
77
|
-
function
|
|
77
|
+
function dr(r) {
|
|
78
78
|
if (!rt) {
|
|
79
79
|
rt = new Uint32Array(256);
|
|
80
80
|
for (let e = 0; e < 256; e++) {
|
|
@@ -87,29 +87,29 @@ function hr(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 fr(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 gr(r, t = /* @__PURE__ */ new Date()) {
|
|
98
|
+
const e = new TextEncoder(), { time: n, date: i } = fr(t), o = [], s = [];
|
|
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 m = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), h = dr(m), 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, h, !0), f.setUint32(18, m.length, !0), f.setUint32(22, m.length, !0), f.setUint16(26, d.length, !0), f.setUint16(28, 0, !0), o.push(new Uint8Array(f.buffer), d, m), s.push({ name: u.name, bytes: m, crc: h, offset: a }), a += 30 + d.length + m.length;
|
|
103
103
|
}
|
|
104
104
|
const l = a;
|
|
105
105
|
for (const u of s) {
|
|
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,
|
|
106
|
+
const m = 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, m.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), o.push(new Uint8Array(d.buffer), m), a += 46 + m.length;
|
|
108
108
|
}
|
|
109
109
|
const c = new DataView(new ArrayBuffer(22));
|
|
110
110
|
return c.setUint32(0, 101010256, !0), c.setUint16(4, 0, !0), c.setUint16(6, 0, !0), c.setUint16(8, s.length, !0), c.setUint16(10, s.length, !0), c.setUint32(12, a - l, !0), c.setUint32(16, l, !0), c.setUint16(20, 0, !0), o.push(new Uint8Array(c.buffer)), new Blob(o, { type: "application/zip" });
|
|
111
111
|
}
|
|
112
|
-
const mt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"],
|
|
112
|
+
const mt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Le = {
|
|
113
113
|
protan: "protanopia",
|
|
114
114
|
deutan: "deuteranopia",
|
|
115
115
|
tritan: "tritanopia",
|
|
@@ -117,9 +117,9 @@ const mt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Te = {
|
|
|
117
117
|
};
|
|
118
118
|
function Dt(r) {
|
|
119
119
|
const t = r?.trim().toLowerCase();
|
|
120
|
-
return !t || t === "none" ? null : mt.includes(t) ? t :
|
|
120
|
+
return !t || t === "none" ? null : mt.includes(t) ? t : Le[t] ?? null;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
122
|
+
const pr = ["none", ...mt, ...Object.keys(Le)], jt = {
|
|
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],
|
|
@@ -131,7 +131,7 @@ const fr = ["none", ...mt, ...Object.keys(Te)], jt = {
|
|
|
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 br(r) {
|
|
135
135
|
const t = r.trim().toLowerCase(), e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);
|
|
136
136
|
if (e) {
|
|
137
137
|
const i = e[1], o = (s) => parseInt(s.length === 1 ? s + s : s, 16);
|
|
@@ -149,28 +149,28 @@ function Ht(r, t) {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
function Yt({ r, g: t, b: e }) {
|
|
152
|
-
const [n, i, o] = [G(r), G(t), G(e)], s = (n * 0.4124564 + i * 0.3575761 + o * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + o * 0.072175, l = (n * 0.0193339 + i * 0.119192 + o * 0.9503041) / 1.08883, c = (
|
|
153
|
-
return [116 *
|
|
152
|
+
const [n, i, o] = [G(r), G(t), G(e)], s = (n * 0.4124564 + i * 0.3575761 + o * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + o * 0.072175, l = (n * 0.0193339 + i * 0.119192 + o * 0.9503041) / 1.08883, c = (h) => h > 216 / 24389 ? Math.cbrt(h) : 841 / 108 * h + 4 / 29, [u, m, d] = [c(s), c(a), c(l)];
|
|
153
|
+
return [116 * m - 16, 500 * (u - m), 200 * (m - d)];
|
|
154
154
|
}
|
|
155
155
|
function Xt(r, t) {
|
|
156
|
-
const [e, n, i] = Yt(r), [o, s, a] = Yt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(s, a)) / 2,
|
|
156
|
+
const [e, n, i] = Yt(r), [o, s, a] = Yt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(s, a)) / 2, m = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, h] = [n * (1 + m), s * (1 + m)], [f, g] = [Math.hypot(d, i), Math.hypot(h, a)], p = (U, et) => {
|
|
157
157
|
if (U === 0 && et === 0) return 0;
|
|
158
158
|
const X = Math.atan2(et, U) * c;
|
|
159
159
|
return X >= 0 ? X : X + 360;
|
|
160
|
-
}, [b, w] = [p(d, i), p(
|
|
160
|
+
}, [b, w] = [p(d, i), p(h, a)], y = o - e, A = g - f;
|
|
161
161
|
let v = 0;
|
|
162
162
|
f * g !== 0 && (v = w - b, v > 180 ? v -= 360 : v < -180 && (v += 360));
|
|
163
|
-
const N = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), _ = (e + o) / 2,
|
|
163
|
+
const N = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), _ = (e + o) / 2, x = (f + g) / 2;
|
|
164
164
|
let P = b + w;
|
|
165
165
|
f * g !== 0 && (Math.abs(b - w) > 180 && (P += b + w < 360 ? 360 : -360), P /= 2);
|
|
166
|
-
const L = 1 - 0.17 * Math.cos((P - 30) * l) + 0.24 * Math.cos(2 * P * l) + 0.32 * Math.cos((3 * P + 6) * l) - 0.2 * Math.cos((4 * P - 63) * l),
|
|
167
|
-
return Math.sqrt((y /
|
|
166
|
+
const L = 1 - 0.17 * Math.cos((P - 30) * l) + 0.24 * Math.cos(2 * P * l) + 0.32 * Math.cos((3 * P + 6) * l) - 0.2 * Math.cos((4 * P - 63) * l), M = 1 + 0.015 * (_ - 50) ** 2 / Math.sqrt(20 + (_ - 50) ** 2), S = 1 + 0.045 * x, $ = 1 + 0.015 * x * L, E = -2 * Math.sqrt(x ** 7 / (x ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((P - 275) / 25) ** 2)) * l);
|
|
167
|
+
return Math.sqrt((y / M) ** 2 + (A / S) ** 2 + (N / $) ** 2 + E * (A / S) * (N / $));
|
|
168
168
|
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
169
|
+
const yr = 10;
|
|
170
|
+
function wr(r, t = yr) {
|
|
171
171
|
const e = /* @__PURE__ */ new Map();
|
|
172
172
|
for (const a of r) {
|
|
173
|
-
const l =
|
|
173
|
+
const l = br(a.color);
|
|
174
174
|
if (!l) continue;
|
|
175
175
|
const c = a.layer ?? "", u = e.get(c);
|
|
176
176
|
u ? u.push({ entry: a, rgb: l }) : e.set(c, [{ entry: a, rgb: l }]);
|
|
@@ -189,7 +189,7 @@ function br(r, t = pr) {
|
|
|
189
189
|
l > s && (s = l, o = a);
|
|
190
190
|
return { collapses: n, worstType: o };
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function vr(r, t, e, n) {
|
|
193
193
|
if (t <= 0 || e <= 0) return !0;
|
|
194
194
|
let i;
|
|
195
195
|
try {
|
|
@@ -198,27 +198,27 @@ function yr(r, t, e, n) {
|
|
|
198
198
|
return !1;
|
|
199
199
|
}
|
|
200
200
|
const o = new Float64Array(256);
|
|
201
|
-
for (let
|
|
201
|
+
for (let m = 0; m < 256; m++) o[m] = G(m);
|
|
202
202
|
const s = 1024, a = new Float64Array(s + 1);
|
|
203
|
-
for (let
|
|
204
|
-
const l = (
|
|
205
|
-
const d = Math.min(1, Math.max(0,
|
|
206
|
-
return
|
|
203
|
+
for (let m = 0; m <= s; m++) a[m] = ct(m / s);
|
|
204
|
+
const l = (m) => {
|
|
205
|
+
const d = Math.min(1, Math.max(0, m)) * s, h = Math.floor(d);
|
|
206
|
+
return h >= s ? a[s] : a[h] + (a[h + 1] - a[h]) * (d - h);
|
|
207
207
|
}, c = jt[n], u = i.data;
|
|
208
|
-
for (let
|
|
209
|
-
const d = o[u[
|
|
210
|
-
u[
|
|
208
|
+
for (let m = 0; m < u.length; m += 4) {
|
|
209
|
+
const d = o[u[m]], h = o[u[m + 1]], f = o[u[m + 2]];
|
|
210
|
+
u[m] = l(c[0] * d + c[1] * h + c[2] * f), u[m + 1] = l(c[3] * d + c[4] * h + c[5] * f), u[m + 2] = l(c[6] * d + c[7] * h + c[8] * f);
|
|
211
211
|
}
|
|
212
212
|
return r.putImageData(i, 0, 0), !0;
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
function
|
|
214
|
+
const Re = (r) => `om-carto-cvd-${r}`;
|
|
215
|
+
function Ar(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
219
|
for (const e of mt) {
|
|
220
220
|
const n = r.createElementNS("http://www.w3.org/2000/svg", "filter");
|
|
221
|
-
n.id =
|
|
221
|
+
n.id = Re(e), n.setAttribute("color-interpolation-filters", "linearRGB");
|
|
222
222
|
const i = r.createElementNS("http://www.w3.org/2000/svg", "feColorMatrix");
|
|
223
223
|
i.setAttribute("type", "matrix");
|
|
224
224
|
const o = jt[e];
|
|
@@ -226,8 +226,8 @@ function wr(r) {
|
|
|
226
226
|
}
|
|
227
227
|
r.body.appendChild(t);
|
|
228
228
|
}
|
|
229
|
-
const
|
|
230
|
-
async function
|
|
229
|
+
const Ie = 16384, Fe = 134217728;
|
|
230
|
+
async function Mr(r) {
|
|
231
231
|
const t = [], e = [...r.querySelectorAll("img")];
|
|
232
232
|
return await Promise.all(
|
|
233
233
|
e.map(async (n) => {
|
|
@@ -240,10 +240,11 @@ async function vr(r) {
|
|
|
240
240
|
})
|
|
241
241
|
), t;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
function _e(r) {
|
|
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
|
+
}
|
|
246
|
+
function Sr(r) {
|
|
247
|
+
return [...r.children].filter(_e).map((t, e) => ({ el: t, index: e, z: C(t).z ?? 0 })).sort((t, e) => t.z - e.z || t.index - e.index).map((t) => t.el);
|
|
247
248
|
}
|
|
248
249
|
async function zt(r, t = {}) {
|
|
249
250
|
const e = r ?? document.querySelector("om-cartograph");
|
|
@@ -255,53 +256,53 @@ async function zt(r, t = {}) {
|
|
|
255
256
|
e.getAttribute("width"),
|
|
256
257
|
e.getAttribute("height"),
|
|
257
258
|
e.getAttribute("orientation")
|
|
258
|
-
), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = o + a * 2, c = s + a * 2, u = t.maxDimension ??
|
|
259
|
+
), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = o + a * 2, c = s + a * 2, u = t.maxDimension ?? Ie, m = t.maxArea ?? Fe;
|
|
259
260
|
let d = i;
|
|
260
|
-
const
|
|
261
|
-
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
|
|
262
|
-
const p = Bt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y =
|
|
263
|
-
for (const
|
|
264
|
-
if (!(!ft(
|
|
261
|
+
const h = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(m / (l / 25.4 * (c / 25.4))), g = Math.min(h, f);
|
|
262
|
+
d > g && (d = Math.floor(g), n.push(`Requested ${i} dpi exceeds this browser's canvas budget for a ${l.toFixed(0)}×${c.toFixed(0)}mm page; rendered at ${d} dpi instead.`)), n.push(...await Mr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
|
|
263
|
+
const p = Bt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = Sr(e);
|
|
264
|
+
for (const M of y)
|
|
265
|
+
if (!(!ft(M) || !M.prepareCartograph))
|
|
265
266
|
try {
|
|
266
|
-
await
|
|
267
|
+
await M.prepareCartograph(Bt(d));
|
|
267
268
|
} catch (S) {
|
|
268
|
-
|
|
269
|
+
M.discardCartograph?.(), n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} could not be captured: ${S.message}`);
|
|
269
270
|
}
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
const v =
|
|
271
|
+
const A = document.createElement("canvas");
|
|
272
|
+
A.width = b, A.height = w;
|
|
273
|
+
const v = A.getContext("2d");
|
|
273
274
|
if (!v) throw new Error("[onlymapjs/cartograph] renderCartograph: could not get a 2D canvas context.");
|
|
274
275
|
const N = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
|
|
275
276
|
v.fillStyle = R(N?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
|
|
276
|
-
for (const
|
|
277
|
-
if (!ft(
|
|
278
|
-
const S = C(
|
|
277
|
+
for (const M of y) {
|
|
278
|
+
if (!ft(M)) continue;
|
|
279
|
+
const S = C(M);
|
|
279
280
|
if (v.save(), v.translate((S.x + a) * p.pxPerMm, (S.y + a) * p.pxPerMm), S.rotation) {
|
|
280
|
-
const
|
|
281
|
-
v.translate(
|
|
281
|
+
const $ = S.w / 2 * p.pxPerMm, E = S.h / 2 * p.pxPerMm;
|
|
282
|
+
v.translate($, E), v.rotate(S.rotation * Math.PI / 180), v.translate(-$, -E);
|
|
282
283
|
}
|
|
283
284
|
try {
|
|
284
|
-
|
|
285
|
-
} catch (
|
|
286
|
-
n.push(`${
|
|
285
|
+
M.paintCartograph(v, p);
|
|
286
|
+
} catch ($) {
|
|
287
|
+
n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} failed to render: ${$.message}`);
|
|
287
288
|
}
|
|
288
289
|
v.restore();
|
|
289
290
|
}
|
|
290
291
|
const _ = e.querySelector(":scope > [data-om-carto-marks]");
|
|
291
|
-
for (const
|
|
292
|
-
const S = Number(
|
|
293
|
-
[S,
|
|
292
|
+
for (const M of _?.querySelectorAll("line") ?? []) {
|
|
293
|
+
const S = Number(M.getAttribute("x1")), $ = Number(M.getAttribute("y1")), E = Number(M.getAttribute("x2")), U = Number(M.getAttribute("y2"));
|
|
294
|
+
[S, $, E, U].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((S + a) * p.pxPerMm, ($ + a) * p.pxPerMm), v.lineTo((E + a) * p.pxPerMm, (U + a) * p.pxPerMm), v.stroke(), v.restore());
|
|
294
295
|
}
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
for (const
|
|
296
|
+
const x = Dt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
|
|
297
|
+
x && !vr(v, b, w, x) && 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) ft(M) && M.discardCartograph?.();
|
|
298
299
|
const P = t.format === "jpeg" ? "image/jpeg" : "image/png";
|
|
299
300
|
P === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
|
|
300
|
-
const L = await new Promise((
|
|
301
|
+
const L = await new Promise((M) => A.toBlob(M, P, t.quality));
|
|
301
302
|
if (!L) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
|
|
302
303
|
return { blob: L, widthPx: b, heightPx: w, dpi: d, warnings: n };
|
|
303
304
|
}
|
|
304
|
-
async function
|
|
305
|
+
async function Oe(r, t = {}) {
|
|
305
306
|
const e = r ?? document.querySelector("om-cartograph");
|
|
306
307
|
if (!e) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: no <om-cartograph> to render.");
|
|
307
308
|
const n = e.querySelector("om-atlas") ?? null;
|
|
@@ -313,21 +314,21 @@ async function Ie(r, t = {}) {
|
|
|
313
314
|
const o = t.format === "jpeg" ? "jpg" : "png", s = n.filenames(o), a = [], l = n.index;
|
|
314
315
|
try {
|
|
315
316
|
if (t.page != null) {
|
|
316
|
-
const
|
|
317
|
-
if (!Number.isInteger(
|
|
317
|
+
const m = Math.trunc(t.page);
|
|
318
|
+
if (!Number.isInteger(m) || m < 0 || m >= i)
|
|
318
319
|
throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: page ${t.page} is out of range (this atlas has ${i}).`);
|
|
319
|
-
n.seek(
|
|
320
|
+
n.seek(m);
|
|
320
321
|
const d = await Jt(e, t, a);
|
|
321
|
-
return { blob: d.blob, filenames: [s[
|
|
322
|
+
return { blob: d.blob, filenames: [s[m]], pages: 1, dpi: d.dpi, warnings: a };
|
|
322
323
|
}
|
|
323
324
|
const c = [];
|
|
324
325
|
let u = t.dpi ?? 300;
|
|
325
|
-
for (let
|
|
326
|
-
n.seek(
|
|
326
|
+
for (let m = 0; m < i; m++) {
|
|
327
|
+
n.seek(m);
|
|
327
328
|
const d = await Jt(e, t, a);
|
|
328
|
-
u = d.dpi, c.push({ name: s[
|
|
329
|
+
u = d.dpi, c.push({ name: s[m], data: d.blob }), t.onPage?.(m + 1, i);
|
|
329
330
|
}
|
|
330
|
-
return { blob: await
|
|
331
|
+
return { blob: await gr(c), filenames: s, pages: i, dpi: u, warnings: a };
|
|
331
332
|
} finally {
|
|
332
333
|
n.seek(l);
|
|
333
334
|
}
|
|
@@ -338,12 +339,13 @@ async function Jt(r, t, e) {
|
|
|
338
339
|
const n = await zt(r, t);
|
|
339
340
|
return e.push(...n.warnings), n;
|
|
340
341
|
}
|
|
341
|
-
const
|
|
342
|
+
const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
342
343
|
__proto__: null,
|
|
343
344
|
MAX_CANVAS_AREA: Fe,
|
|
344
|
-
MAX_CANVAS_DIMENSION:
|
|
345
|
+
MAX_CANVAS_DIMENSION: Ie,
|
|
346
|
+
paintsInExport: _e,
|
|
345
347
|
renderCartograph: zt,
|
|
346
|
-
renderCartographAtlas:
|
|
348
|
+
renderCartographAtlas: Oe
|
|
347
349
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
348
350
|
function Zt(r, t, e = {}) {
|
|
349
351
|
const n = URL.createObjectURL(r), i = document.createElement("a");
|
|
@@ -351,8 +353,8 @@ function Zt(r, t, e = {}) {
|
|
|
351
353
|
const o = e.revokeAfterMs ?? 0;
|
|
352
354
|
o > 0 ? setTimeout(() => URL.revokeObjectURL(n), o) : URL.revokeObjectURL(n);
|
|
353
355
|
}
|
|
354
|
-
const
|
|
355
|
-
async function Qt(r, t =
|
|
356
|
+
const kr = 3e4;
|
|
357
|
+
async function Qt(r, t = kr) {
|
|
356
358
|
let e = !1;
|
|
357
359
|
const n = new Promise(
|
|
358
360
|
(o) => setTimeout(() => {
|
|
@@ -372,7 +374,7 @@ async function Qt(r, t = Sr) {
|
|
|
372
374
|
})();
|
|
373
375
|
return await Promise.race([i, n]), { timedOut: e };
|
|
374
376
|
}
|
|
375
|
-
async function
|
|
377
|
+
async function xr(r, t = {}) {
|
|
376
378
|
if (!r.hasAttribute("allow-url-actions") || typeof document < "u" && document.documentElement?.dataset?.omHost === "editor") return null;
|
|
377
379
|
const e = t.search ?? (typeof location < "u" ? location.search : "");
|
|
378
380
|
if (!e) return null;
|
|
@@ -383,42 +385,42 @@ async function Cr(r, t = {}) {
|
|
|
383
385
|
await Qt(r, t.timeoutMs);
|
|
384
386
|
const s = o === "jpeg" ? "jpeg" : "png", a = Number(n.get("dpi")) || void 0, l = r.getAttribute("cartograph-id") || "cartograph", c = n.get("page");
|
|
385
387
|
if (c != null) {
|
|
386
|
-
const
|
|
387
|
-
if (!
|
|
388
|
+
const m = r.querySelector("om-atlas");
|
|
389
|
+
if (!m) throw new Error(`?page=${c} needs an <om-atlas>; this cartograph is a single sheet.`);
|
|
388
390
|
const d = Number(c);
|
|
389
391
|
if (!Number.isInteger(d) || d < 1) throw new Error(`?page=${c} is not a page number (they start at 1).`);
|
|
390
|
-
|
|
391
|
-
const
|
|
392
|
-
for (const f of
|
|
393
|
-
return Zt(
|
|
392
|
+
m.refresh?.();
|
|
393
|
+
const h = await Oe(r, { dpi: a, format: s, page: d - 1 });
|
|
394
|
+
for (const f of h.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
|
|
395
|
+
return Zt(h.blob, h.filenames[0] ?? `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
|
|
394
396
|
}
|
|
395
397
|
const u = await zt(r, { dpi: a, format: s });
|
|
396
|
-
for (const
|
|
398
|
+
for (const m of u.warnings) console.warn(`[onlymapjs/cartograph] ${m}`);
|
|
397
399
|
return Zt(u.blob, `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
|
|
398
400
|
}
|
|
399
401
|
return n.get("print") === "1" ? (await Qt(r, t.timeoutMs), typeof r.print == "function" ? await r.print({ dpi: Number(n.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
|
|
400
402
|
}
|
|
401
|
-
function
|
|
403
|
+
function $r() {
|
|
402
404
|
if (typeof document > "u") return;
|
|
403
405
|
const r = () => {
|
|
404
406
|
for (const t of document.querySelectorAll("om-cartograph[allow-url-actions]"))
|
|
405
|
-
|
|
407
|
+
xr(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
|
|
406
408
|
};
|
|
407
409
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", r, { once: !0 }) : r();
|
|
408
410
|
}
|
|
409
|
-
const
|
|
411
|
+
const Ue = typeof window < "u" && typeof document < "u" && typeof customElements < "u", De = Ue ? HTMLElement : class {
|
|
410
412
|
};
|
|
411
413
|
function k(r, t) {
|
|
412
|
-
|
|
414
|
+
Ue && (customElements.get(r) || customElements.define(r, t));
|
|
413
415
|
}
|
|
414
|
-
function
|
|
416
|
+
function Er(r) {
|
|
415
417
|
if (typeof DOMParser > "u")
|
|
416
418
|
throw new Error(
|
|
417
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."
|
|
418
420
|
);
|
|
419
421
|
return new DOMParser().parseFromString(r, "text/html");
|
|
420
422
|
}
|
|
421
|
-
class
|
|
423
|
+
class F extends De {
|
|
422
424
|
renderQueued = !1;
|
|
423
425
|
connectedCallback() {
|
|
424
426
|
this.scheduleRender();
|
|
@@ -450,7 +452,7 @@ class I extends Oe {
|
|
|
450
452
|
a != null && Number.isInteger(a) ? this.style.zIndex = String(a) : this.style.removeProperty("z-index");
|
|
451
453
|
}
|
|
452
454
|
}
|
|
453
|
-
const gt = "cartograph/2",
|
|
455
|
+
const gt = "cartograph/2", wi = ["default", "dark", "sepia", "blueprint", "minimal"], te = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], Nr = /* @__PURE__ */ new Map([
|
|
454
456
|
["projection", "live frames render Web Mercator (EPSG:3857) only — Globe support is design-only; use a static frame for other projections"]
|
|
455
457
|
]), j = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], T = {
|
|
456
458
|
"om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions", "keep-badge"],
|
|
@@ -473,12 +475,12 @@ const gt = "cartograph/2", fi = ["default", "dark", "sepia", "blueprint", "minim
|
|
|
473
475
|
// only way furniture can be right when the live map never loaded and its
|
|
474
476
|
// CRS is therefore unknowable.
|
|
475
477
|
"om-source": ["src", "corners", "crs", "crs-def"],
|
|
476
|
-
"om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name"]
|
|
477
|
-
}, pt = Object.keys(T), Et = "data-om-carto-vector",
|
|
478
|
-
function
|
|
479
|
-
return r != null &&
|
|
478
|
+
"om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name", "pager"]
|
|
479
|
+
}, pt = Object.keys(T), Et = "data-om-carto-vector", Pr = ["metric", "imperial", "nautical"], Tr = 0.3048, Lr = 1609.344, Rr = 1852;
|
|
480
|
+
function Ir(r) {
|
|
481
|
+
return r != null && Pr.includes(r) ? r : null;
|
|
480
482
|
}
|
|
481
|
-
function
|
|
483
|
+
function je(r) {
|
|
482
484
|
if (!isFinite(r) || r <= 0) return 0;
|
|
483
485
|
const t = Math.pow(10, Math.floor(Math.log10(r))), e = r / t;
|
|
484
486
|
return (e >= 5 ? 5 : e >= 2 ? 2 : 1) * t;
|
|
@@ -490,12 +492,12 @@ const ee = {
|
|
|
490
492
|
{ metersPerUnit: 1e3, label: "km" }
|
|
491
493
|
],
|
|
492
494
|
imperial: [
|
|
493
|
-
{ metersPerUnit:
|
|
494
|
-
{ metersPerUnit:
|
|
495
|
+
{ metersPerUnit: Tr, label: "ft" },
|
|
496
|
+
{ metersPerUnit: Lr, label: "mi" }
|
|
495
497
|
],
|
|
496
|
-
nautical: [{ metersPerUnit:
|
|
498
|
+
nautical: [{ metersPerUnit: Rr, label: "nmi" }]
|
|
497
499
|
};
|
|
498
|
-
function
|
|
500
|
+
function ze({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
|
|
499
501
|
if (!Number.isFinite(r) || r <= 0 || !Number.isFinite(t) || t <= 0) return null;
|
|
500
502
|
const o = Number.isInteger(e) && e > 0 ? e : 4, s = ee[n] ?? ee.metric, a = t / o * r;
|
|
501
503
|
let l, c;
|
|
@@ -503,26 +505,26 @@ function De({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "
|
|
|
503
505
|
l = i, c = re(s, l);
|
|
504
506
|
else {
|
|
505
507
|
c = re(s, a);
|
|
506
|
-
const f =
|
|
508
|
+
const f = je(a / c.metersPerUnit);
|
|
507
509
|
if (f <= 0) return null;
|
|
508
510
|
l = f * c.metersPerUnit;
|
|
509
511
|
}
|
|
510
512
|
const u = l / r;
|
|
511
513
|
if (!Number.isFinite(u) || u <= 0) return null;
|
|
512
|
-
const
|
|
514
|
+
const m = l / c.metersPerUnit, d = m < 1 ? 2 : m < 10 && !Number.isInteger(m) ? 1 : 0, h = Array.from({ length: o + 1 }, (f, g) => (g * m).toFixed(d));
|
|
513
515
|
return {
|
|
514
516
|
segmentMeters: l,
|
|
515
517
|
segmentMm: u,
|
|
516
518
|
segments: o,
|
|
517
519
|
totalMm: u * o,
|
|
518
|
-
labels:
|
|
520
|
+
labels: h,
|
|
519
521
|
unitLabel: c.label,
|
|
520
522
|
// 1 mm on the page is groundMetersPerMm metres on the ground; the RF is
|
|
521
523
|
// that ratio in consistent units (mm : mm).
|
|
522
524
|
scaleDenominator: r * 1e3
|
|
523
525
|
};
|
|
524
526
|
}
|
|
525
|
-
function
|
|
527
|
+
function Fr(r, t, e) {
|
|
526
528
|
const n = Math.min(2.6, Math.max(1.6, e * 0.34)), i = 0.2, o = n * 1.25, s = Math.max(0.6, Math.min(2.2, e - o - 0.4)), a = 0, l = r.segmentMm, c = [], u = [];
|
|
527
529
|
if (t === "single" || t === "double") {
|
|
528
530
|
const p = t === "double" ? 2 : 1, b = s / p;
|
|
@@ -544,21 +546,21 @@ function Rr(r, t, e) {
|
|
|
544
546
|
u.push({ x1: w, y1: a, x2: w, y2: a + s });
|
|
545
547
|
}
|
|
546
548
|
}
|
|
547
|
-
const
|
|
549
|
+
const m = r.labels.length - 1, d = r.labels.map((p, b) => ({
|
|
548
550
|
// The end label carries the unit so the bar reads "0 2 4 6 8 km".
|
|
549
|
-
text: b ===
|
|
551
|
+
text: b === m ? `${p} ${r.unitLabel}` : p,
|
|
550
552
|
// Keep the end label inside the drawn width rather than hanging off it.
|
|
551
|
-
x: b ===
|
|
553
|
+
x: b === m ? r.totalMm : b * l,
|
|
552
554
|
y: a + s + n,
|
|
553
|
-
anchor: b === 0 ? "start" : b ===
|
|
555
|
+
anchor: b === 0 ? "start" : b === m ? "end" : "middle",
|
|
554
556
|
index: b
|
|
555
|
-
})),
|
|
557
|
+
})), h = (p) => p.length * n * 0.62, f = [];
|
|
556
558
|
let g = -1 / 0;
|
|
557
559
|
for (const p of d) {
|
|
558
|
-
const b =
|
|
559
|
-
if (!(!(p.index === 0 || p.index ===
|
|
560
|
-
if (p.index ===
|
|
561
|
-
for (; f.length > 1 && f[f.length - 1].x +
|
|
560
|
+
const b = h(p.text) / 2, w = p.anchor === "start" ? p.x : p.anchor === "end" ? p.x - b * 2 : p.x - b, y = w + h(p.text);
|
|
561
|
+
if (!(!(p.index === 0 || p.index === m) && w < g + n * 0.4)) {
|
|
562
|
+
if (p.index === m && w < g + n * 0.4)
|
|
563
|
+
for (; f.length > 1 && f[f.length - 1].x + h(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
|
|
562
564
|
f.push({ text: p.text, x: p.x, y: p.y, anchor: p.anchor }), g = y;
|
|
563
565
|
}
|
|
564
566
|
}
|
|
@@ -570,12 +572,12 @@ function re(r, t) {
|
|
|
570
572
|
t / n.metersPerUnit >= 1 && (e = n);
|
|
571
573
|
return e;
|
|
572
574
|
}
|
|
573
|
-
const
|
|
574
|
-
function
|
|
575
|
-
return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
575
|
+
const _r = " ";
|
|
576
|
+
function Or(r) {
|
|
577
|
+
return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, _r);
|
|
576
578
|
}
|
|
577
|
-
const
|
|
578
|
-
function
|
|
579
|
+
const Ge = /\{\{\s*([\w.]+)\s*\}\}/g;
|
|
580
|
+
function Ur(r, t) {
|
|
579
581
|
if (r.startsWith("atlas.")) return t.atlas?.[r.slice(6)];
|
|
580
582
|
if (r.startsWith("frame.")) {
|
|
581
583
|
const e = r.slice(6), n = e.lastIndexOf(".");
|
|
@@ -587,18 +589,18 @@ function _r(r, t) {
|
|
|
587
589
|
}
|
|
588
590
|
return t.page[r];
|
|
589
591
|
}
|
|
590
|
-
function
|
|
592
|
+
function qe(r, t) {
|
|
591
593
|
const e = [];
|
|
592
|
-
return { text: r.replace(
|
|
593
|
-
const s =
|
|
594
|
+
return { text: r.replace(Ge, (i, o) => {
|
|
595
|
+
const s = Ur(o, t);
|
|
594
596
|
return s === void 0 ? (e.push(o), i) : s;
|
|
595
597
|
}), unresolved: e };
|
|
596
598
|
}
|
|
597
|
-
function
|
|
598
|
-
return [...r.matchAll(
|
|
599
|
+
function Dr(r) {
|
|
600
|
+
return [...r.matchAll(Ge)].map((t) => t[1]);
|
|
599
601
|
}
|
|
600
602
|
const ne = /* @__PURE__ */ new WeakMap();
|
|
601
|
-
function
|
|
603
|
+
function jr(r, t) {
|
|
602
604
|
const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
|
|
603
605
|
if (!n) return e;
|
|
604
606
|
const i = n.createTreeWalker(
|
|
@@ -613,37 +615,37 @@ function Ur(r, t) {
|
|
|
613
615
|
if (a = s.data, !a.includes("{{")) continue;
|
|
614
616
|
ne.set(s, a);
|
|
615
617
|
}
|
|
616
|
-
const l =
|
|
618
|
+
const l = qe(a, t);
|
|
617
619
|
s.data !== l.text && (s.data = l.text), e.push(...l.unresolved);
|
|
618
620
|
}
|
|
619
621
|
return e;
|
|
620
622
|
}
|
|
621
|
-
function
|
|
623
|
+
function zr(r = /* @__PURE__ */ new Date()) {
|
|
622
624
|
return `${r.getFullYear()}-${String(r.getMonth() + 1).padStart(2, "0")}-${String(r.getDate()).padStart(2, "0")}`;
|
|
623
625
|
}
|
|
624
626
|
const Nt = "data-om-carto-unlinked";
|
|
625
|
-
function
|
|
627
|
+
function We(r) {
|
|
626
628
|
return r.closest("om-cartograph");
|
|
627
629
|
}
|
|
628
|
-
function
|
|
629
|
-
const e =
|
|
630
|
+
function Be(r, t) {
|
|
631
|
+
const e = We(r);
|
|
630
632
|
if (!e || !t) return null;
|
|
631
633
|
for (const n of e.querySelectorAll("om-frame"))
|
|
632
634
|
if (n.id === t) return n;
|
|
633
635
|
return null;
|
|
634
636
|
}
|
|
635
|
-
function
|
|
637
|
+
function Ke(r) {
|
|
636
638
|
return [...r.querySelectorAll("om-frame")];
|
|
637
639
|
}
|
|
638
|
-
function
|
|
639
|
-
const t =
|
|
640
|
+
function Gr(r) {
|
|
641
|
+
const t = We(r);
|
|
640
642
|
if (!t) return null;
|
|
641
|
-
const e =
|
|
643
|
+
const e = Ke(t);
|
|
642
644
|
return e.length === 1 ? e[0] : null;
|
|
643
645
|
}
|
|
644
646
|
function O(r) {
|
|
645
647
|
const t = r.getAttribute("for");
|
|
646
|
-
return t ?
|
|
648
|
+
return t ? Be(r, t) : Gr(r);
|
|
647
649
|
}
|
|
648
650
|
function q(r, t) {
|
|
649
651
|
let e = r.querySelector(`:scope > [${Nt}]`);
|
|
@@ -654,11 +656,11 @@ function q(r, t) {
|
|
|
654
656
|
}
|
|
655
657
|
e.textContent !== t && (e.textContent = t);
|
|
656
658
|
}
|
|
657
|
-
function
|
|
659
|
+
function qr(r) {
|
|
658
660
|
r.querySelector(`:scope > [${Nt}]`)?.remove();
|
|
659
661
|
}
|
|
660
|
-
const ie = "data-om-carto-page", se = "data-om-carto-marks", bt = "data-om-carto-credit",
|
|
661
|
-
class
|
|
662
|
+
const ie = "data-om-carto-page", se = "data-om-carto-marks", bt = "data-om-carto-credit", Ve = "Built with OnlyMap by NIKA", Wr = `${Ve} · free for non-commercial use`, nt = 2, oe = 1.2, yt = 2.4, ae = 1.5, wt = 1.2, le = 0.3, ce = 0.8, vt = "http://www.w3.org/2000/svg", Br = 6e4;
|
|
663
|
+
class He extends F {
|
|
662
664
|
static observedAttributes = [...T["om-cartograph"]];
|
|
663
665
|
frameListenerBound = !1;
|
|
664
666
|
/** Fields of the atlas page currently displayed, for {{atlas.<field>}}. */
|
|
@@ -704,7 +706,7 @@ class Ve extends I {
|
|
|
704
706
|
i?.remove();
|
|
705
707
|
return;
|
|
706
708
|
}
|
|
707
|
-
const o = e === "voluntary" ?
|
|
709
|
+
const o = e === "voluntary" ? Ve : Wr;
|
|
708
710
|
if (i) {
|
|
709
711
|
i.textContent !== o && (i.textContent = o), this.armCreditPainter(i);
|
|
710
712
|
return;
|
|
@@ -759,12 +761,12 @@ class Ve extends I {
|
|
|
759
761
|
try {
|
|
760
762
|
window.print();
|
|
761
763
|
} finally {
|
|
762
|
-
o || setTimeout(s,
|
|
764
|
+
o || setTimeout(s, Br);
|
|
763
765
|
}
|
|
764
766
|
}
|
|
765
767
|
/** Render the whole page to one image, for `flatten`. */
|
|
766
768
|
async buildFlattenedImage(t) {
|
|
767
|
-
const { renderCartograph: e } = await Promise.resolve().then(() =>
|
|
769
|
+
const { renderCartograph: e } = await Promise.resolve().then(() => Cr), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
|
|
768
770
|
i.src = URL.createObjectURL(n), i.setAttribute("data-om-carto-flattened", "");
|
|
769
771
|
const o = this.bleedMm;
|
|
770
772
|
return i.style.cssText = `position:absolute;left:${-o}mm;top:${-o}mm;width:calc(100% + ${o * 2}mm);height:calc(100% + ${o * 2}mm);z-index:2147483645;`, await i.decode().catch(() => {
|
|
@@ -785,20 +787,20 @@ class Ve extends I {
|
|
|
785
787
|
}
|
|
786
788
|
/** Values every `{{token}}` on this page resolves against. */
|
|
787
789
|
tokenContext() {
|
|
788
|
-
const t = /* @__PURE__ */ new Map(), e =
|
|
790
|
+
const t = /* @__PURE__ */ new Map(), e = Ke(this);
|
|
789
791
|
for (const o of e) {
|
|
790
792
|
const s = o.georef, a = s?.groundMetersPerMm() ?? 0;
|
|
791
793
|
t.set(o.id, {
|
|
792
|
-
scale: a > 0 ?
|
|
794
|
+
scale: a > 0 ? Or(a * 1e3) : void 0,
|
|
793
795
|
crs: s?.crs
|
|
794
796
|
});
|
|
795
797
|
}
|
|
796
|
-
const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (o) =>
|
|
798
|
+
const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (o) => qe(this.getAttribute(o) ?? "", n).text;
|
|
797
799
|
return {
|
|
798
800
|
page: {
|
|
799
801
|
title: i("title"),
|
|
800
802
|
attribution: i("attribution"),
|
|
801
|
-
date:
|
|
803
|
+
date: zr(),
|
|
802
804
|
notes: i("notes")
|
|
803
805
|
},
|
|
804
806
|
frames: t,
|
|
@@ -839,15 +841,15 @@ class Ve extends I {
|
|
|
839
841
|
}
|
|
840
842
|
const l = this.ownerDocument, c = a ?? l.createElementNS(vt, "svg");
|
|
841
843
|
if (c.setAttribute(se, ""), 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) {
|
|
842
|
-
const u = Math.min(n, 4),
|
|
843
|
-
for (const
|
|
844
|
+
const u = Math.min(n, 4), m = Math.min(n * 0.35, 1.5), d = [];
|
|
845
|
+
for (const h of [0, t])
|
|
844
846
|
for (const f of [0, e]) {
|
|
845
|
-
const g =
|
|
846
|
-
d.push([
|
|
847
|
+
const g = h === 0 ? -1 : 1, p = f === 0 ? -1 : 1;
|
|
848
|
+
d.push([h + g * m, f, h + g * (m + u), f]), d.push([h, f + p * m, h, f + p * (m + u)]);
|
|
847
849
|
}
|
|
848
|
-
for (const [
|
|
850
|
+
for (const [h, f, g, p] of d) {
|
|
849
851
|
const b = l.createElementNS(vt, "line");
|
|
850
|
-
b.setAttribute("x1", String(
|
|
852
|
+
b.setAttribute("x1", String(h)), 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);
|
|
851
853
|
}
|
|
852
854
|
}
|
|
853
855
|
if (s) {
|
|
@@ -870,20 +872,20 @@ class Ve extends I {
|
|
|
870
872
|
this.style.removeProperty("filter");
|
|
871
873
|
return;
|
|
872
874
|
}
|
|
873
|
-
|
|
875
|
+
Ar(this.ownerDocument), this.style.filter = `url(#${Re(t)})`;
|
|
874
876
|
}
|
|
875
877
|
}
|
|
876
|
-
k("om-cartograph",
|
|
877
|
-
function
|
|
878
|
+
k("om-cartograph", He);
|
|
879
|
+
function Kr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
|
|
878
880
|
const o = n > 0 ? n : e * 1.2, s = [];
|
|
879
881
|
for (const c of r.split(/\r?\n/)) {
|
|
880
|
-
const u = c.split(/\s+/).filter((
|
|
882
|
+
const u = c.split(/\s+/).filter((h) => h !== "");
|
|
881
883
|
if (u.length === 0) {
|
|
882
884
|
s.push({ text: "", baselineY: 0, width: 0 });
|
|
883
885
|
continue;
|
|
884
886
|
}
|
|
885
|
-
const
|
|
886
|
-
let f =
|
|
887
|
+
const m = (h) => {
|
|
888
|
+
let f = h;
|
|
887
889
|
for (; i(f) > t && f.length > 1; ) {
|
|
888
890
|
let g = f.length - 1;
|
|
889
891
|
for (; g > 1 && i(f.slice(0, g)) > t; ) g--;
|
|
@@ -892,9 +894,9 @@ function Wr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
|
|
|
892
894
|
return f;
|
|
893
895
|
};
|
|
894
896
|
let d = "";
|
|
895
|
-
for (const
|
|
896
|
-
const f = d === "" ?
|
|
897
|
-
d === "" ? d = h
|
|
897
|
+
for (const h of u) {
|
|
898
|
+
const f = d === "" ? h : `${d} ${h}`;
|
|
899
|
+
d === "" ? d = m(h) : i(f) > t ? (s.push({ text: d, baselineY: 0, width: i(d) }), d = m(h)) : d = f;
|
|
898
900
|
}
|
|
899
901
|
s.push({ text: d, baselineY: 0, width: i(d) });
|
|
900
902
|
}
|
|
@@ -904,15 +906,15 @@ function Wr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
|
|
|
904
906
|
c.baselineY = a + u * o, c.width > l && (l = c.width);
|
|
905
907
|
}), { lines: s, lineHeight: o, maxWidth: l };
|
|
906
908
|
}
|
|
907
|
-
function
|
|
909
|
+
function vi(r) {
|
|
908
910
|
if (typeof document > "u") return null;
|
|
909
911
|
const e = document.createElement("canvas").getContext("2d");
|
|
910
912
|
return e ? (e.font = r, (n) => e.measureText(n).width) : null;
|
|
911
913
|
}
|
|
912
|
-
function
|
|
914
|
+
function Vr(r, t, e) {
|
|
913
915
|
return r === "center" ? (t - e) / 2 : r === "end" || r === "right" ? t - e : 0;
|
|
914
916
|
}
|
|
915
|
-
class
|
|
917
|
+
class Ye extends F {
|
|
916
918
|
static observedAttributes = [...T["om-text"]];
|
|
917
919
|
renderNow() {
|
|
918
920
|
this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden";
|
|
@@ -932,7 +934,7 @@ class Ke extends I {
|
|
|
932
934
|
/** Re-run token substitution from the authored templates. */
|
|
933
935
|
resolveTokens() {
|
|
934
936
|
const t = this.closest("om-cartograph");
|
|
935
|
-
t && typeof t.tokenContext == "function" &&
|
|
937
|
+
t && typeof t.tokenContext == "function" && jr(this, t.tokenContext());
|
|
936
938
|
}
|
|
937
939
|
paintCartograph(t, e) {
|
|
938
940
|
const { w: n, h: i } = C(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
|
|
@@ -941,9 +943,9 @@ class Ke extends I {
|
|
|
941
943
|
l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
|
|
942
944
|
const c = (this.textContent ?? "").trim();
|
|
943
945
|
if (c === "") return;
|
|
944
|
-
const u =
|
|
946
|
+
const u = $t(a?.fontSize, 12), m = a?.lineHeight === "normal" ? u * 1.4 : $t(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", h = a?.fontWeight || "400", f = u * e.scale, g = m * e.scale, p = `${h} ${f}px ${d}`;
|
|
945
947
|
t.save(), t.font = p, t.fillStyle = R(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
|
|
946
|
-
const b =
|
|
948
|
+
const b = Kr({
|
|
947
949
|
text: c,
|
|
948
950
|
maxWidth: o,
|
|
949
951
|
fontSizePx: f,
|
|
@@ -952,16 +954,16 @@ class Ke extends I {
|
|
|
952
954
|
}), w = a?.textAlign || "start";
|
|
953
955
|
for (const y of b.lines) {
|
|
954
956
|
if (y.baselineY > s + g) break;
|
|
955
|
-
t.fillText(y.text,
|
|
957
|
+
t.fillText(y.text, Vr(w, o, y.width), y.baselineY);
|
|
956
958
|
}
|
|
957
959
|
t.restore();
|
|
958
960
|
}
|
|
959
961
|
}
|
|
960
|
-
k("om-text",
|
|
961
|
-
const
|
|
962
|
-
let
|
|
962
|
+
k("om-text", Ye);
|
|
963
|
+
const Hr = 63710087714e-4;
|
|
964
|
+
let Yr = Hr;
|
|
963
965
|
const it = Math.PI / 180;
|
|
964
|
-
function
|
|
966
|
+
function Xr(r, t, e = Yr) {
|
|
965
967
|
const n = (t[1] - r[1]) * it, i = (t[0] - r[0]) * it, o = r[1] * it, s = t[1] * it, a = Math.sin(n / 2) ** 2 + Math.cos(o) * Math.cos(s) * Math.sin(i / 2) ** 2;
|
|
966
968
|
return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
|
|
967
969
|
}
|
|
@@ -973,13 +975,13 @@ function Gt([r, t]) {
|
|
|
973
975
|
function dt([r, t]) {
|
|
974
976
|
return [r / tt * he, (2 * Math.atan(Math.exp(t / tt)) - Math.PI / 2) * he];
|
|
975
977
|
}
|
|
976
|
-
const
|
|
978
|
+
const Jr = {
|
|
977
979
|
code: "EPSG:3857",
|
|
978
980
|
units: "linear",
|
|
979
981
|
metresPerUnit: 1,
|
|
980
982
|
forward: Gt,
|
|
981
983
|
inverse: dt
|
|
982
|
-
},
|
|
984
|
+
}, Zr = {
|
|
983
985
|
code: "EPSG:4326",
|
|
984
986
|
units: "degree",
|
|
985
987
|
metresPerUnit: Pt,
|
|
@@ -993,16 +995,16 @@ function qt(r) {
|
|
|
993
995
|
const e = /^(?:epsg:{1,2})?(\d{4,6})$/i.exec(t);
|
|
994
996
|
return e ? `EPSG:${e[1]}` : t.toUpperCase();
|
|
995
997
|
}
|
|
996
|
-
function
|
|
998
|
+
function Xe(r) {
|
|
997
999
|
const t = qt(r) ?? "EPSG:3857";
|
|
998
|
-
return t === "EPSG:3857" || t === "EPSG:900913" ?
|
|
1000
|
+
return t === "EPSG:3857" || t === "EPSG:900913" ? Jr : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? Zr : null;
|
|
999
1001
|
}
|
|
1000
|
-
const
|
|
1002
|
+
const Je = /* @__PURE__ */ new Map();
|
|
1001
1003
|
function Tt(r, t) {
|
|
1002
1004
|
return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
|
|
1003
1005
|
}
|
|
1004
|
-
async function
|
|
1005
|
-
const t =
|
|
1006
|
+
async function Qr(r) {
|
|
1007
|
+
const t = Je.get(r);
|
|
1006
1008
|
if (typeof t == "string") return t;
|
|
1007
1009
|
const e = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
|
|
1008
1010
|
if (!Number.isFinite(e)) return null;
|
|
@@ -1011,22 +1013,22 @@ async function Jr(r) {
|
|
|
1011
1013
|
const { CRS_DEFS: n } = await import("./crs-BzE_KP4M.js");
|
|
1012
1014
|
return n[e]?.def ?? null;
|
|
1013
1015
|
}
|
|
1014
|
-
function
|
|
1016
|
+
function tn(r) {
|
|
1015
1017
|
if (r.projName === "longlat") return { units: "degree", metresPerUnit: Pt };
|
|
1016
1018
|
if (typeof r.to_meter == "number" && r.to_meter > 0) return { units: "linear", metresPerUnit: r.to_meter };
|
|
1017
1019
|
const t = (r.units ?? "m").toLowerCase();
|
|
1018
1020
|
return t.startsWith("deg") ? { units: "degree", metresPerUnit: Pt } : t.includes("ft") || t.includes("foot") ? { units: "linear", metresPerUnit: 0.3048 } : { units: "linear", metresPerUnit: 1 };
|
|
1019
1021
|
}
|
|
1020
|
-
async function
|
|
1021
|
-
const e = qt(r) ?? "EPSG:3857", n =
|
|
1022
|
+
async function en(r, t) {
|
|
1023
|
+
const e = qt(r) ?? "EPSG:3857", n = Je.get(e);
|
|
1022
1024
|
if (n && typeof n != "string") return n;
|
|
1023
1025
|
if (!t) {
|
|
1024
|
-
const u =
|
|
1026
|
+
const u = Xe(e);
|
|
1025
1027
|
if (u) return u;
|
|
1026
1028
|
}
|
|
1027
|
-
const i = t?.trim() || await
|
|
1029
|
+
const i = t?.trim() || await Qr(e);
|
|
1028
1030
|
if (!i) return null;
|
|
1029
|
-
const o = (await import("./index-CcLC9jE5.js")).default, a = o(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } =
|
|
1031
|
+
const o = (await import("./index-CcLC9jE5.js")).default, a = o(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } = tn(new o.Proj(i));
|
|
1030
1032
|
return {
|
|
1031
1033
|
code: e,
|
|
1032
1034
|
units: l,
|
|
@@ -1035,20 +1037,20 @@ async function Qr(r, t) {
|
|
|
1035
1037
|
inverse: (u) => a.forward(u)
|
|
1036
1038
|
};
|
|
1037
1039
|
}
|
|
1038
|
-
const de = Math.PI / 180,
|
|
1039
|
-
function
|
|
1040
|
+
const de = Math.PI / 180, rn = 180 / Math.PI, nn = { code: "EPSG:3857", forward: Gt, inverse: dt }, Ai = Gt, Mi = dt, fe = 6378137, ge = 89.9;
|
|
1041
|
+
function sn([r, t]) {
|
|
1040
1042
|
const e = Math.max(-ge, Math.min(ge, t));
|
|
1041
1043
|
return [fe * r * de, fe * Math.log(Math.tan(Math.PI / 4 + e * de / 2))];
|
|
1042
1044
|
}
|
|
1043
|
-
const
|
|
1044
|
-
function
|
|
1045
|
-
return
|
|
1045
|
+
const on = { code: "EPSG:3857", forward: sn, inverse: dt }, Lt = qt;
|
|
1046
|
+
function V(r) {
|
|
1047
|
+
return Xe(r);
|
|
1046
1048
|
}
|
|
1047
1049
|
async function Rt(r, t) {
|
|
1048
|
-
return
|
|
1050
|
+
return en(r, t);
|
|
1049
1051
|
}
|
|
1050
|
-
const
|
|
1051
|
-
function
|
|
1052
|
+
const Si = Tt;
|
|
1053
|
+
function an(r, t) {
|
|
1052
1054
|
const e = t.length, n = r.map((i, o) => [...i, t[o]]);
|
|
1053
1055
|
for (let i = 0; i < e; i++) {
|
|
1054
1056
|
let o = i;
|
|
@@ -1064,23 +1066,23 @@ function sn(r, t) {
|
|
|
1064
1066
|
}
|
|
1065
1067
|
return n.map((i, o) => i[e] / i[o]);
|
|
1066
1068
|
}
|
|
1067
|
-
function
|
|
1069
|
+
function ln(r, t) {
|
|
1068
1070
|
if (r.length !== 4 || t.length !== 4) return null;
|
|
1069
|
-
const e = r.reduce((
|
|
1070
|
-
for (let
|
|
1071
|
-
const [d,
|
|
1072
|
-
a.push([d,
|
|
1073
|
-
}
|
|
1074
|
-
const c =
|
|
1075
|
-
if (!c || c.some((
|
|
1076
|
-
const u = (
|
|
1071
|
+
const e = r.reduce((m, d) => m + d[0], 0) / 4, n = r.reduce((m, d) => m + d[1], 0) / 4, i = r.reduce((m, d) => m + Math.hypot(d[0] - e, d[1] - n), 0) / 4, o = i > 1e-12 ? Math.SQRT2 / i : 1, s = (m) => [(m[0] - e) * o, (m[1] - n) * o], a = [], l = [];
|
|
1072
|
+
for (let m = 0; m < 4; m++) {
|
|
1073
|
+
const [d, h] = s(r[m]), [f, g] = t[m];
|
|
1074
|
+
a.push([d, h, 1, 0, 0, 0, -d * f, -h * f]), l.push(f), a.push([0, 0, 0, d, h, 1, -d * g, -h * g]), l.push(g);
|
|
1075
|
+
}
|
|
1076
|
+
const c = an(a, l);
|
|
1077
|
+
if (!c || c.some((m) => !Number.isFinite(m))) return null;
|
|
1078
|
+
const u = (m) => [m[0] / o + e, m[1] / o + n];
|
|
1077
1079
|
return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: s, denormalize: u };
|
|
1078
1080
|
}
|
|
1079
1081
|
function pe(r, [t, e]) {
|
|
1080
1082
|
const n = r[6] * t + r[7] * e + r[8];
|
|
1081
1083
|
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];
|
|
1082
1084
|
}
|
|
1083
|
-
function
|
|
1085
|
+
function cn(r) {
|
|
1084
1086
|
const [t, e, n, i, o, s, a, l, c] = r, u = t * (o * c - s * l) - e * (i * c - s * a) + n * (i * l - o * a);
|
|
1085
1087
|
return !Number.isFinite(u) || Math.abs(u) < 1e-15 ? null : [
|
|
1086
1088
|
(o * c - s * l) / u,
|
|
@@ -1094,29 +1096,29 @@ function an(r) {
|
|
|
1094
1096
|
(t * o - e * i) / u
|
|
1095
1097
|
];
|
|
1096
1098
|
}
|
|
1097
|
-
function
|
|
1099
|
+
function un(r, t) {
|
|
1098
1100
|
let e = r;
|
|
1099
1101
|
for (; e - t > 180; ) e -= 360;
|
|
1100
1102
|
for (; t - e > 180; ) e += 360;
|
|
1101
1103
|
return e;
|
|
1102
1104
|
}
|
|
1103
|
-
const
|
|
1105
|
+
const Ze = (r) => {
|
|
1104
1106
|
let t = ((r + 180) % 360 + 360) % 360 - 180;
|
|
1105
1107
|
return t === -180 && (t = 180), t;
|
|
1106
1108
|
};
|
|
1107
1109
|
function Q({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i = !1 }) {
|
|
1108
|
-
const o = n ?? (i ?
|
|
1110
|
+
const o = n ?? (i ? on : nn), s = r[0][0], a = (b) => i ? b : un(b, s), l = (b) => i ? b : Ze(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => o.forward(b)), m = [
|
|
1109
1111
|
[0, 0],
|
|
1110
1112
|
[t, 0],
|
|
1111
1113
|
[t, e],
|
|
1112
1114
|
[0, e]
|
|
1113
|
-
], d = t > 0 && e > 0 ?
|
|
1114
|
-
let y = 0,
|
|
1115
|
-
if (!
|
|
1115
|
+
], d = t > 0 && e > 0 ? ln(u, m) : null, h = d ? cn(d.matrix) : null, f = !d || !h, g = (b, w = i ? 16 : 1) => {
|
|
1116
|
+
let y = 0, A = p.unproject(0, b);
|
|
1117
|
+
if (!A) return null;
|
|
1116
1118
|
for (let v = 1; v <= w; v++) {
|
|
1117
1119
|
const N = p.unproject(t * v / w, b);
|
|
1118
1120
|
if (!N) return null;
|
|
1119
|
-
y +=
|
|
1121
|
+
y += Xr(A, N), A = N;
|
|
1120
1122
|
}
|
|
1121
1123
|
return y;
|
|
1122
1124
|
}, p = {
|
|
@@ -1132,11 +1134,11 @@ function Q({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i =
|
|
|
1132
1134
|
return y && Number.isFinite(y[0]) && Number.isFinite(y[1]) ? { xMm: y[0], yMm: y[1] } : null;
|
|
1133
1135
|
},
|
|
1134
1136
|
unproject(b, w) {
|
|
1135
|
-
if (!d || !
|
|
1136
|
-
const y = pe(
|
|
1137
|
+
if (!d || !h) return null;
|
|
1138
|
+
const y = pe(h, [b, w]);
|
|
1137
1139
|
if (!y) return null;
|
|
1138
|
-
const
|
|
1139
|
-
return Number.isFinite(
|
|
1140
|
+
const A = o.inverse(d.denormalize(y));
|
|
1141
|
+
return Number.isFinite(A[0]) && Number.isFinite(A[1]) ? [l(A[0]), A[1]] : null;
|
|
1140
1142
|
},
|
|
1141
1143
|
groundMetersPerMm() {
|
|
1142
1144
|
if (f || t <= 0) return 0;
|
|
@@ -1182,16 +1184,16 @@ function H(r) {
|
|
|
1182
1184
|
}
|
|
1183
1185
|
return e;
|
|
1184
1186
|
}
|
|
1185
|
-
function
|
|
1187
|
+
function hn(r) {
|
|
1186
1188
|
if (r.degenerate) return null;
|
|
1187
1189
|
const t = r.unproject(r.widthMm / 2, r.heightMm / 2);
|
|
1188
1190
|
if (!t) return null;
|
|
1189
1191
|
const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t), o = r.project(n);
|
|
1190
1192
|
if (!i || !o) return null;
|
|
1191
1193
|
const s = o.xMm - i.xMm, a = o.yMm - i.yMm;
|
|
1192
|
-
return Math.abs(s) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(s, -a) *
|
|
1194
|
+
return Math.abs(s) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(s, -a) * rn % 360 + 360) % 360;
|
|
1193
1195
|
}
|
|
1194
|
-
function
|
|
1196
|
+
function mn(r) {
|
|
1195
1197
|
if (r.degenerate) return null;
|
|
1196
1198
|
const { widthMm: t, heightMm: e } = r, n = [];
|
|
1197
1199
|
for (const s of [0.02, 0.5, 0.98]) {
|
|
@@ -1202,7 +1204,7 @@ function un(r) {
|
|
|
1202
1204
|
const i = Math.min(...n), o = Math.max(...n);
|
|
1203
1205
|
return i > 0 ? (o - i) / i : null;
|
|
1204
1206
|
}
|
|
1205
|
-
function
|
|
1207
|
+
function Ci(r, t, e, n) {
|
|
1206
1208
|
return [
|
|
1207
1209
|
[r, n],
|
|
1208
1210
|
[e, n],
|
|
@@ -1210,8 +1212,8 @@ function wi(r, t, e, n) {
|
|
|
1210
1212
|
[r, t]
|
|
1211
1213
|
];
|
|
1212
1214
|
}
|
|
1213
|
-
const
|
|
1214
|
-
function
|
|
1215
|
+
const dn = (r) => r.toLowerCase().startsWith("on");
|
|
1216
|
+
function fn(r, t) {
|
|
1215
1217
|
const e = (n) => {
|
|
1216
1218
|
const i = n.tagName.toLowerCase();
|
|
1217
1219
|
if (i === "script") {
|
|
@@ -1222,7 +1224,7 @@ function mn(r, t) {
|
|
|
1222
1224
|
if (i === "style" || i === "link" || i === "iframe" || i === "object" || i === "embed") return null;
|
|
1223
1225
|
const o = t.createElement(i);
|
|
1224
1226
|
for (const s of n.attributes)
|
|
1225
|
-
|
|
1227
|
+
dn(s.name) || /^\s*javascript:/i.test(s.value) || o.setAttribute(s.name, s.value);
|
|
1226
1228
|
for (const s of n.childNodes)
|
|
1227
1229
|
if (s.nodeType === 3) o.appendChild(t.createTextNode(s.textContent ?? ""));
|
|
1228
1230
|
else if (s.nodeType === 1) {
|
|
@@ -1233,12 +1235,12 @@ function mn(r, t) {
|
|
|
1233
1235
|
};
|
|
1234
1236
|
return e(r);
|
|
1235
1237
|
}
|
|
1236
|
-
async function
|
|
1238
|
+
async function gn(r, t = document) {
|
|
1237
1239
|
const e = await fetch(r, { credentials: "same-origin", cache: "no-store" });
|
|
1238
1240
|
if (!e.ok) throw new Error(`fetching ${r} failed with HTTP ${e.status}`);
|
|
1239
1241
|
const n = await e.text(), o = new DOMParser().parseFromString(n, "text/html").querySelector("om-map");
|
|
1240
1242
|
if (!o) throw new Error(`${r} contains no <om-map>`);
|
|
1241
|
-
const s =
|
|
1243
|
+
const s = fn(o, t);
|
|
1242
1244
|
if (!s) throw new Error(`${r} could not be adopted`);
|
|
1243
1245
|
return s;
|
|
1244
1246
|
}
|
|
@@ -1263,8 +1265,8 @@ function ut(r) {
|
|
|
1263
1265
|
pitch: Number(r.getAttribute("pitch")) || 0
|
|
1264
1266
|
};
|
|
1265
1267
|
}
|
|
1266
|
-
function
|
|
1267
|
-
const o = (l) =>
|
|
1268
|
+
function ki(r, t, e, n, i = 60) {
|
|
1269
|
+
const o = (l) => It(r, { ...t, pitch: l }, e, n) !== null;
|
|
1268
1270
|
if (o(i)) return i;
|
|
1269
1271
|
if (!o(0)) return 0;
|
|
1270
1272
|
let s = 0, a = i;
|
|
@@ -1274,7 +1276,7 @@ function vi(r, t, e, n, i = 60) {
|
|
|
1274
1276
|
}
|
|
1275
1277
|
return s;
|
|
1276
1278
|
}
|
|
1277
|
-
function
|
|
1279
|
+
function It(r, t, e, n) {
|
|
1278
1280
|
if (!(e > 0) || !(n > 0)) return null;
|
|
1279
1281
|
const i = new r.WebMercatorViewport({
|
|
1280
1282
|
width: e,
|
|
@@ -1297,44 +1299,44 @@ function Ft(r, t, e, n) {
|
|
|
1297
1299
|
}
|
|
1298
1300
|
return s;
|
|
1299
1301
|
}
|
|
1300
|
-
async function
|
|
1301
|
-
const e = await
|
|
1302
|
+
async function pn(r, t) {
|
|
1303
|
+
const e = await Te();
|
|
1302
1304
|
if (t && typeof t != "string") return { core: e, map: t };
|
|
1303
1305
|
if (!t) throw new Error("a live frame needs src= or an inline <om-map> child");
|
|
1304
|
-
const n = await
|
|
1306
|
+
const n = await gn(t, r.ownerDocument);
|
|
1305
1307
|
return { core: e, map: n };
|
|
1306
1308
|
}
|
|
1307
|
-
function
|
|
1308
|
-
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)),
|
|
1309
|
+
function At(r, t) {
|
|
1310
|
+
r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)), bn(r, t);
|
|
1309
1311
|
}
|
|
1310
|
-
function
|
|
1312
|
+
function bn(r, t) {
|
|
1311
1313
|
const e = r;
|
|
1312
1314
|
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 });
|
|
1313
1315
|
}
|
|
1314
|
-
const
|
|
1315
|
-
function
|
|
1316
|
+
const yn = [".png", ".jpg", ".jpeg", ".webp", ".avif", ".gif", ".svg"], wn = [".html", ".htm"];
|
|
1317
|
+
function Ft(r) {
|
|
1316
1318
|
const t = r.trim().split(/[?#]/, 1)[0]?.toLowerCase() ?? "";
|
|
1317
|
-
return
|
|
1319
|
+
return wn.some((e) => t.endsWith(e)) ? "map" : yn.some((e) => t.endsWith(e)) ? "raster" : null;
|
|
1318
1320
|
}
|
|
1319
|
-
function
|
|
1321
|
+
function vn(r, t) {
|
|
1320
1322
|
const e = [], n = [...r.children].find(
|
|
1321
1323
|
(s) => s.tagName.toLowerCase() === "om-map" && s !== t
|
|
1322
1324
|
);
|
|
1323
1325
|
n && e.push({ kind: "inline", key: "inline", el: r, map: n });
|
|
1324
1326
|
const i = r.getAttribute("src")?.trim();
|
|
1325
|
-
i && e.push({ kind:
|
|
1327
|
+
i && e.push({ kind: Ft(i) ?? "map", key: `src:${i}`, el: r, src: i });
|
|
1326
1328
|
let o = 0;
|
|
1327
1329
|
for (const s of r.children) {
|
|
1328
1330
|
if (s.tagName.toLowerCase() !== "om-source") continue;
|
|
1329
1331
|
const a = s.getAttribute("src")?.trim();
|
|
1330
|
-
a && e.push({ kind:
|
|
1332
|
+
a && e.push({ kind: Ft(a) ?? "map", key: `source:${o++}:${a}`, el: s, src: a });
|
|
1331
1333
|
}
|
|
1332
1334
|
return e;
|
|
1333
1335
|
}
|
|
1334
|
-
function
|
|
1336
|
+
function An(r) {
|
|
1335
1337
|
return r.map((t) => t.key).join("|");
|
|
1336
1338
|
}
|
|
1337
|
-
async function
|
|
1339
|
+
async function Mn(r, t, e) {
|
|
1338
1340
|
const n = Math.max(1, Math.round(t.w * e)), i = Math.max(1, Math.round(t.h * e)), o = r.cloneNode(!0);
|
|
1339
1341
|
o.removeAttribute("style"), o.setAttribute("width", String(n)), o.setAttribute("height", String(i)), o.setAttribute("preserveAspectRatio", "none");
|
|
1340
1342
|
const s = new XMLSerializer().serializeToString(o), a = new Image();
|
|
@@ -1346,8 +1348,8 @@ async function vn(r, t, e) {
|
|
|
1346
1348
|
}
|
|
1347
1349
|
return a;
|
|
1348
1350
|
}
|
|
1349
|
-
const
|
|
1350
|
-
class
|
|
1351
|
+
const Mt = "data-om-carto-placeholder", be = "data-om-carto-source", St = "data-om-carto-capture", Ct = "data-om-carto-overview", ye = "http://www.w3.org/2000/svg", we = 24, ve = 0.25;
|
|
1352
|
+
class Qe extends F {
|
|
1351
1353
|
static observedAttributes = [...T["om-frame"]];
|
|
1352
1354
|
/** Resolved non-builtin CRS planes, so a re-render does not re-await proj4. */
|
|
1353
1355
|
resolvedForward = null;
|
|
@@ -1430,7 +1432,7 @@ class Je extends I {
|
|
|
1430
1432
|
if (!this.liveCorners) return null;
|
|
1431
1433
|
const l = this.liveMap?.projectedCrs?.() ?? null;
|
|
1432
1434
|
if (l) {
|
|
1433
|
-
const c = this.resolvedForwardKey === `${l}|` ? this.resolvedForward :
|
|
1435
|
+
const c = this.resolvedForwardKey === `${l}|` ? this.resolvedForward : V(l);
|
|
1434
1436
|
return c ? Q({ corners: this.liveCorners, widthMm: t, heightMm: e, crsForward: c }) : (this.ensureLiveCrsForward(l), null);
|
|
1435
1437
|
}
|
|
1436
1438
|
return Q({ corners: this.liveCorners, widthMm: t, heightMm: e, continuous: !0 });
|
|
@@ -1438,7 +1440,7 @@ class Je extends I {
|
|
|
1438
1440
|
const n = this.georefHost, i = H(n.getAttribute("corners"));
|
|
1439
1441
|
if (!i) return null;
|
|
1440
1442
|
const o = Lt(n.getAttribute("crs")) ?? "EPSG:3857", s = n.getAttribute("crs-def");
|
|
1441
|
-
let a = s ? null :
|
|
1443
|
+
let a = s ? null : V(o);
|
|
1442
1444
|
return !a && this.resolvedForwardKey === `${o}|${s ?? ""}` && (a = this.resolvedForward), a ? Q({ corners: i, widthMm: t, heightMm: e, crsForward: a }) : null;
|
|
1443
1445
|
}
|
|
1444
1446
|
/**
|
|
@@ -1515,7 +1517,7 @@ class Je extends I {
|
|
|
1515
1517
|
const e = t.style;
|
|
1516
1518
|
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";
|
|
1517
1519
|
const n = Lt(this.getAttribute("crs")) ?? "EPSG:3857", i = this.getAttribute("crs-def"), o = `${n}|${i ?? ""}`;
|
|
1518
|
-
if ((i != null ||
|
|
1520
|
+
if ((i != null || V(n) == null) && this.resolvedForwardKey !== o) {
|
|
1519
1521
|
const a = ++this.resolveToken;
|
|
1520
1522
|
this.resolvedForward = null, this.resolvedForwardKey = null, Rt(n, i).then((l) => {
|
|
1521
1523
|
if (a === this.resolveToken) {
|
|
@@ -1556,7 +1558,7 @@ class Je extends I {
|
|
|
1556
1558
|
this.showPlaceholder("no-source", "Live frame needs src=, an <om-source> child, or an inline <om-map>.");
|
|
1557
1559
|
return;
|
|
1558
1560
|
}
|
|
1559
|
-
const s =
|
|
1561
|
+
const s = An(o);
|
|
1560
1562
|
s !== this.knownSourceList && (this.knownSourceList = s, this.sourceCursor = 0, this.settledSource = null, this.removeAttribute(be));
|
|
1561
1563
|
const a = Math.min(this.sourceCursor, o.length - 1), l = o[a];
|
|
1562
1564
|
if (l.kind === "raster") {
|
|
@@ -1567,7 +1569,7 @@ class Je extends I {
|
|
|
1567
1569
|
if (this.mountedSource !== l.key)
|
|
1568
1570
|
this.releaseLiveMap();
|
|
1569
1571
|
else {
|
|
1570
|
-
|
|
1572
|
+
At(this.liveMap, e), this.sizeLiveMap();
|
|
1571
1573
|
return;
|
|
1572
1574
|
}
|
|
1573
1575
|
if (this.mounting) {
|
|
@@ -1606,7 +1608,7 @@ class Je extends I {
|
|
|
1606
1608
|
* inline source on the next render.
|
|
1607
1609
|
*/
|
|
1608
1610
|
sources() {
|
|
1609
|
-
return
|
|
1611
|
+
return vn(this, this.liveMapOwned ? this.liveMap : null);
|
|
1610
1612
|
}
|
|
1611
1613
|
/**
|
|
1612
1614
|
* Move to the next source, or report that there is none.
|
|
@@ -1677,7 +1679,7 @@ class Je extends I {
|
|
|
1677
1679
|
if (!t) return;
|
|
1678
1680
|
const e = Y();
|
|
1679
1681
|
if (!e) return;
|
|
1680
|
-
const { w: n, h: i } = C(this), s = this.liveMap?.groundCorners?.(n * D, i * D) ??
|
|
1682
|
+
const { w: n, h: i } = C(this), s = this.liveMap?.groundCorners?.(n * D, i * D) ?? It(e, t, n * D, i * D), a = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
|
|
1681
1683
|
this.liveCorners = s, a && this.liveMap && this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } })), this.applyReferenceScale(), s ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder("degenerate-view", "This frame's box cannot be georeferenced — give it a positive width and height.");
|
|
1682
1684
|
}
|
|
1683
1685
|
async mountLive(t, e, n) {
|
|
@@ -1685,15 +1687,15 @@ class Je extends I {
|
|
|
1685
1687
|
this.mounting = !0, this.mountingSource = t.key;
|
|
1686
1688
|
let o = !1;
|
|
1687
1689
|
try {
|
|
1688
|
-
const { core: s, map: a } = await
|
|
1690
|
+
const { core: s, map: a } = await pn(this, t.map ?? t.src);
|
|
1689
1691
|
if (i !== this.mountToken || !this.isConnected || this.mode !== "live") return;
|
|
1690
1692
|
const l = ut(this);
|
|
1691
1693
|
if (!l) return;
|
|
1692
|
-
this.appliedCameraKey = JSON.stringify(l),
|
|
1694
|
+
this.appliedCameraKey = JSON.stringify(l), At(a, l);
|
|
1693
1695
|
const c = a;
|
|
1694
1696
|
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();
|
|
1695
|
-
const { w: u, h } = C(this);
|
|
1696
|
-
if (this.liveCorners =
|
|
1697
|
+
const { w: u, h: m } = C(this);
|
|
1698
|
+
if (this.liveCorners = It(s, l, u * D, m * D), this.applyReferenceScale(), await c.ready, i !== this.mountToken || (At(a, l), await c.whenSettled?.({ timeout: 2e4 }), i !== this.mountToken)) return;
|
|
1697
1699
|
if (c.hasDrawableContent?.() === !1) {
|
|
1698
1700
|
if (this.advanceSource(n)) return;
|
|
1699
1701
|
console.warn(
|
|
@@ -1741,20 +1743,20 @@ class Je extends I {
|
|
|
1741
1743
|
e?.remove();
|
|
1742
1744
|
return;
|
|
1743
1745
|
}
|
|
1744
|
-
const n =
|
|
1746
|
+
const n = Be(this, t), i = this.georef, o = n?.georef;
|
|
1745
1747
|
if (!n || !i || !o) {
|
|
1746
1748
|
e?.remove();
|
|
1747
1749
|
return;
|
|
1748
1750
|
}
|
|
1749
|
-
const { w: s, h: a } = C(this), l = [], [c, u,
|
|
1751
|
+
const { w: s, h: a } = C(this), l = [], [c, u, m, d] = o.corners, h = [
|
|
1750
1752
|
[c, u],
|
|
1751
|
-
[u,
|
|
1752
|
-
[
|
|
1753
|
+
[u, m],
|
|
1754
|
+
[m, d],
|
|
1753
1755
|
[d, c]
|
|
1754
1756
|
];
|
|
1755
|
-
for (const [b, w] of
|
|
1757
|
+
for (const [b, w] of h)
|
|
1756
1758
|
for (let y = 0; y < we; y++) {
|
|
1757
|
-
const
|
|
1759
|
+
const A = y / we, v = [b[0] + (w[0] - b[0]) * A, b[1] + (w[1] - b[1]) * A], N = i.project(v);
|
|
1758
1760
|
N && l.push(`${N.xMm.toFixed(3)},${N.yMm.toFixed(3)}`);
|
|
1759
1761
|
}
|
|
1760
1762
|
if (l.length < 3) {
|
|
@@ -1787,11 +1789,11 @@ class Je extends I {
|
|
|
1787
1789
|
* the worst outcome — it looks like a design choice.
|
|
1788
1790
|
*/
|
|
1789
1791
|
showPlaceholder(t, e) {
|
|
1790
|
-
let n = this.querySelector(`:scope > [${
|
|
1791
|
-
n || (n = document.createElement("div"), n.setAttribute(
|
|
1792
|
+
let n = this.querySelector(`:scope > [${Mt}]`);
|
|
1793
|
+
n || (n = document.createElement("div"), n.setAttribute(Mt, ""), 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 } })));
|
|
1792
1794
|
}
|
|
1793
1795
|
clearPlaceholder() {
|
|
1794
|
-
this.querySelector(`:scope > [${
|
|
1796
|
+
this.querySelector(`:scope > [${Mt}]`)?.remove(), this.lastError = null;
|
|
1795
1797
|
}
|
|
1796
1798
|
// -------------------------------------------------------------------------
|
|
1797
1799
|
// Capture, export and print
|
|
@@ -1880,7 +1882,7 @@ class Je extends I {
|
|
|
1880
1882
|
return;
|
|
1881
1883
|
}
|
|
1882
1884
|
const e = this.vector;
|
|
1883
|
-
e && (this.captureImage = await
|
|
1885
|
+
e && (this.captureImage = await Mn(e, C(this), t.pxPerMm));
|
|
1884
1886
|
}
|
|
1885
1887
|
/** Export hook: forget the capture, so a failed pre-pass never reuses it. */
|
|
1886
1888
|
discardCartograph() {
|
|
@@ -1907,8 +1909,8 @@ class Je extends I {
|
|
|
1907
1909
|
l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
|
|
1908
1910
|
const c = this.mode === "static" ? this.vector ? this.captureImage : this.raster : this.captureImage;
|
|
1909
1911
|
c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, o, s), this.paintOverview(t, e);
|
|
1910
|
-
const u = this.getAttribute("frame-stroke") || R(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333",
|
|
1911
|
-
|
|
1912
|
+
const u = this.getAttribute("frame-stroke") || R(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", m = ve * e.pxPerMm;
|
|
1913
|
+
m > 0 && (t.strokeStyle = u, t.lineWidth = m, t.strokeRect(m / 2, m / 2, o - m, s - m));
|
|
1912
1914
|
}
|
|
1913
1915
|
paintOverview(t, e) {
|
|
1914
1916
|
const n = this.querySelector(`:scope > [${Ct}] polygon`), i = n?.getAttribute("points");
|
|
@@ -1918,29 +1920,29 @@ class Je extends I {
|
|
|
1918
1920
|
}), t.closePath(), t.stroke(), t.restore());
|
|
1919
1921
|
}
|
|
1920
1922
|
}
|
|
1921
|
-
k("om-frame",
|
|
1922
|
-
const st = "http://www.w3.org/2000/svg",
|
|
1923
|
-
class
|
|
1923
|
+
k("om-frame", Qe);
|
|
1924
|
+
const st = "http://www.w3.org/2000/svg", Sn = ["single", "double", "line", "ticks"];
|
|
1925
|
+
class tr extends F {
|
|
1924
1926
|
static observedAttributes = [...T["om-scalebar"]];
|
|
1925
1927
|
/** The geometry currently drawn — reused by the canvas exporter. */
|
|
1926
1928
|
get drawing() {
|
|
1927
1929
|
const e = O(this)?.georef;
|
|
1928
1930
|
if (!e) return null;
|
|
1929
|
-
const { w: n, h: i } = C(this), o =
|
|
1931
|
+
const { w: n, h: i } = C(this), o = ze({
|
|
1930
1932
|
groundMetersPerMm: e.groundMetersPerMm(),
|
|
1931
1933
|
maxWidthMm: n,
|
|
1932
1934
|
segments: Number(this.getAttribute("segments")) || void 0,
|
|
1933
1935
|
units: this.unitSystem,
|
|
1934
1936
|
segmentLengthMeters: this.getAttribute("segment-length") ? Number(this.getAttribute("segment-length")) : null
|
|
1935
1937
|
});
|
|
1936
|
-
return o ?
|
|
1938
|
+
return o ? Fr(o, this.barStyle, i) : null;
|
|
1937
1939
|
}
|
|
1938
1940
|
get barStyle() {
|
|
1939
1941
|
const t = this.getAttribute("kind");
|
|
1940
|
-
return
|
|
1942
|
+
return Sn.includes(t) ? t : "single";
|
|
1941
1943
|
}
|
|
1942
1944
|
get unitSystem() {
|
|
1943
|
-
return
|
|
1945
|
+
return Ir(this.getAttribute("units")) ?? "metric";
|
|
1944
1946
|
}
|
|
1945
1947
|
renderNow() {
|
|
1946
1948
|
if (this.applyPlacement(), this.style.display = "block", !O(this)) {
|
|
@@ -1990,14 +1992,14 @@ class Ze extends I {
|
|
|
1990
1992
|
t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text, s(l.x), s(l.y));
|
|
1991
1993
|
}
|
|
1992
1994
|
}
|
|
1993
|
-
k("om-scalebar",
|
|
1995
|
+
k("om-scalebar", tr);
|
|
1994
1996
|
const Z = "http://www.w3.org/2000/svg";
|
|
1995
|
-
class
|
|
1997
|
+
class er extends F {
|
|
1996
1998
|
static observedAttributes = [...T["om-north"]];
|
|
1997
1999
|
/** Degrees clockwise from the page's "up", or null when unknowable. */
|
|
1998
2000
|
get bearing() {
|
|
1999
2001
|
const t = O(this)?.georef;
|
|
2000
|
-
return t ?
|
|
2002
|
+
return t ? hn(t) : null;
|
|
2001
2003
|
}
|
|
2002
2004
|
get indicatorKind() {
|
|
2003
2005
|
return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
|
|
@@ -2026,25 +2028,25 @@ class Qe extends I {
|
|
|
2026
2028
|
const f = Math.min(e, l) / 2, g = t.createElementNS(Z, "circle");
|
|
2027
2029
|
g.setAttribute("cx", String(s)), g.setAttribute("cy", String(l / 2)), g.setAttribute("r", String(f)), g.setAttribute("fill", "none"), g.setAttribute("stroke", i), g.setAttribute("stroke-width", "0.2"), o.push(g);
|
|
2028
2030
|
}
|
|
2029
|
-
const c = 0, u = l,
|
|
2030
|
-
d.setAttribute("d", `M ${s} ${c} L ${s +
|
|
2031
|
-
const
|
|
2032
|
-
return
|
|
2031
|
+
const c = 0, u = l, m = Math.min(e * 0.3, 4), d = t.createElementNS(Z, "path");
|
|
2032
|
+
d.setAttribute("d", `M ${s} ${c} L ${s + m} ${u} L ${s} ${u - m * 0.55} L ${s - m} ${u} Z`), d.setAttribute("fill", i), o.push(d);
|
|
2033
|
+
const h = t.createElementNS(Z, "text");
|
|
2034
|
+
return h.setAttribute("x", String(s)), h.setAttribute("y", String(n)), h.setAttribute("font-size", String(a)), h.setAttribute("text-anchor", "middle"), h.setAttribute("fill", i), h.setAttribute("font-family", "var(--om-carto-font)"), h.textContent = "N", o.push(h), o;
|
|
2033
2035
|
}
|
|
2034
2036
|
paintCartograph(t, e) {
|
|
2035
2037
|
const n = this.bearing;
|
|
2036
2038
|
if (n == null) return;
|
|
2037
|
-
const { w: i, h: o } = C(this), s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = R(s?.color) ?? "#000", l = (
|
|
2038
|
-
t.save(), t.translate(l(
|
|
2039
|
+
const { w: i, h: o } = C(this), s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = R(s?.color) ?? "#000", l = (h) => h * e.pxPerMm, c = Math.min(3, o * 0.24), u = o - c * 1.2, m = i / 2, d = Math.min(i * 0.3, 4);
|
|
2040
|
+
t.save(), t.translate(l(m), l(o / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(m), -l(o / 2)), t.fillStyle = a, t.strokeStyle = a, this.indicatorKind === "rose" && (t.lineWidth = l(0.2), t.beginPath(), t.arc(l(m), l(u / 2), l(Math.min(i, u) / 2), 0, Math.PI * 2), t.stroke()), t.beginPath(), t.moveTo(l(m), 0), t.lineTo(l(m + d), l(u)), t.lineTo(l(m), l(u - d * 0.55)), t.lineTo(l(m - d), l(u)), t.closePath(), t.fill(), t.font = `${l(c)}px ${s?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(m), l(o)), t.restore();
|
|
2039
2041
|
}
|
|
2040
2042
|
}
|
|
2041
|
-
k("om-north",
|
|
2042
|
-
const ot = "http://www.w3.org/2000/svg",
|
|
2043
|
-
class
|
|
2043
|
+
k("om-north", er);
|
|
2044
|
+
const ot = "http://www.w3.org/2000/svg", Cn = ["rect", "ellipse", "line", "arrow"];
|
|
2045
|
+
class rr extends F {
|
|
2044
2046
|
static observedAttributes = [...T["om-shape"]];
|
|
2045
2047
|
get kind() {
|
|
2046
2048
|
const t = this.getAttribute("kind");
|
|
2047
|
-
return
|
|
2049
|
+
return Cn.includes(t) ? t : "rect";
|
|
2048
2050
|
}
|
|
2049
2051
|
get fill() {
|
|
2050
2052
|
return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
|
|
@@ -2086,13 +2088,13 @@ class tr extends I {
|
|
|
2086
2088
|
paintCartograph(t, e) {
|
|
2087
2089
|
const { w: n, h: i } = C(this);
|
|
2088
2090
|
if (n <= 0 || i <= 0) return;
|
|
2089
|
-
const o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || o?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || o?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = s(this.strokeWidthMm), u = c / 2,
|
|
2090
|
-
if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c,
|
|
2091
|
+
const o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || o?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || o?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = s(this.strokeWidthMm), u = c / 2, m = this.kind;
|
|
2092
|
+
if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, m === "ellipse")
|
|
2091
2093
|
t.beginPath(), t.ellipse(s(n / 2), s(i / 2), Math.max(0, s(n / 2) - u), Math.max(0, s(i / 2) - u), 0, 0, Math.PI * 2), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
|
|
2092
|
-
else if (
|
|
2093
|
-
if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(s(n), s(i)), c > 0 && t.stroke(),
|
|
2094
|
-
const d = Math.min(s(n), s(i)) * 0.28,
|
|
2095
|
-
t.beginPath(), t.moveTo(s(n), s(i)), t.lineTo(s(n) - d * Math.cos(
|
|
2094
|
+
else if (m === "line" || m === "arrow") {
|
|
2095
|
+
if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(s(n), s(i)), c > 0 && t.stroke(), m === "arrow") {
|
|
2096
|
+
const d = Math.min(s(n), s(i)) * 0.28, h = Math.atan2(s(i), s(n));
|
|
2097
|
+
t.beginPath(), t.moveTo(s(n), s(i)), t.lineTo(s(n) - d * Math.cos(h - 0.4), s(i) - d * Math.sin(h - 0.4)), t.lineTo(s(n) - d * Math.cos(h + 0.4), s(i) - d * Math.sin(h + 0.4)), t.closePath(), t.fillStyle = l, t.fill();
|
|
2096
2098
|
}
|
|
2097
2099
|
} else {
|
|
2098
2100
|
const d = s(this.radiusMm);
|
|
@@ -2101,13 +2103,13 @@ class tr extends I {
|
|
|
2101
2103
|
t.restore();
|
|
2102
2104
|
}
|
|
2103
2105
|
}
|
|
2104
|
-
k("om-shape",
|
|
2105
|
-
const
|
|
2106
|
-
class
|
|
2106
|
+
k("om-shape", rr);
|
|
2107
|
+
const Ae = "data-om-carto-owned", kn = ["contain", "cover", "fill"];
|
|
2108
|
+
class nr extends F {
|
|
2107
2109
|
static observedAttributes = [...T["om-image"]];
|
|
2108
2110
|
get fit() {
|
|
2109
2111
|
const t = this.getAttribute("fit");
|
|
2110
|
-
return
|
|
2112
|
+
return kn.includes(t ?? "") ? t : "contain";
|
|
2111
2113
|
}
|
|
2112
2114
|
get image() {
|
|
2113
2115
|
return this.querySelector(":scope > img");
|
|
@@ -2116,7 +2118,7 @@ class er extends I {
|
|
|
2116
2118
|
this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden";
|
|
2117
2119
|
const t = this.getAttribute("src");
|
|
2118
2120
|
let e = this.image;
|
|
2119
|
-
!e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(
|
|
2121
|
+
!e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(Ae, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(Ae) && 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");
|
|
2120
2122
|
}
|
|
2121
2123
|
paintCartograph(t, e) {
|
|
2122
2124
|
const n = this.image;
|
|
@@ -2128,17 +2130,17 @@ class er extends I {
|
|
|
2128
2130
|
t.drawImage(n, 0, 0, s, a);
|
|
2129
2131
|
return;
|
|
2130
2132
|
}
|
|
2131
|
-
const c = n.naturalWidth / n.naturalHeight, u = s / a,
|
|
2132
|
-
l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, s, a), t.clip()), t.drawImage(n, (s - d) / 2, (a -
|
|
2133
|
+
const c = n.naturalWidth / n.naturalHeight, u = s / a, m = l === "contain" ? c > u : c < u, d = m ? s : a * c, h = m ? s / c : a;
|
|
2134
|
+
l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, s, a), t.clip()), t.drawImage(n, (s - d) / 2, (a - h) / 2, d, h), l === "cover" && t.restore();
|
|
2133
2135
|
}
|
|
2134
2136
|
}
|
|
2135
|
-
k("om-image",
|
|
2136
|
-
const
|
|
2137
|
-
function
|
|
2137
|
+
k("om-image", nr);
|
|
2138
|
+
const xn = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), $n = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), En = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
|
|
2139
|
+
function Nn(r) {
|
|
2138
2140
|
const t = r.type ?? "";
|
|
2139
|
-
if (
|
|
2140
|
-
if (
|
|
2141
|
-
if (
|
|
2141
|
+
if (En.has(t)) return "ramp";
|
|
2142
|
+
if (xn.has(t)) return "line";
|
|
2143
|
+
if ($n.has(t)) return "point";
|
|
2142
2144
|
if (t === "GeoJsonLayer") {
|
|
2143
2145
|
const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
|
|
2144
2146
|
if (n && !i) return "polygon";
|
|
@@ -2146,24 +2148,24 @@ function xn(r) {
|
|
|
2146
2148
|
}
|
|
2147
2149
|
return "polygon";
|
|
2148
2150
|
}
|
|
2149
|
-
function
|
|
2151
|
+
function Pn(r) {
|
|
2150
2152
|
const t = r.meta?.legend;
|
|
2151
2153
|
return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
|
|
2152
2154
|
}
|
|
2153
2155
|
const kt = 12;
|
|
2154
|
-
function
|
|
2156
|
+
function Tn(r, t = []) {
|
|
2155
2157
|
const e = [];
|
|
2156
2158
|
for (const n of r) {
|
|
2157
2159
|
if (n.props?.visible === !1) continue;
|
|
2158
2160
|
const i = t.filter((a) => a.layer === n.id), o = i.find((a) => a.match == null);
|
|
2159
2161
|
if (o?.hide) continue;
|
|
2160
|
-
const s =
|
|
2162
|
+
const s = Ln(n.meta?.legend);
|
|
2161
2163
|
e.push({
|
|
2162
2164
|
layerId: n.id,
|
|
2163
2165
|
label: o?.label ?? n.meta?.label ?? n.id,
|
|
2164
|
-
color: o?.color ??
|
|
2165
|
-
shape: o?.shape ??
|
|
2166
|
-
legend:
|
|
2166
|
+
color: o?.color ?? Pn(n),
|
|
2167
|
+
shape: o?.shape ?? Nn(n),
|
|
2168
|
+
legend: Rn(s, i),
|
|
2167
2169
|
order: o?.order
|
|
2168
2170
|
});
|
|
2169
2171
|
}
|
|
@@ -2172,7 +2174,7 @@ function Nn(r, t = []) {
|
|
|
2172
2174
|
return o - s || n.index - i.index;
|
|
2173
2175
|
}).map((n) => n.row);
|
|
2174
2176
|
}
|
|
2175
|
-
function
|
|
2177
|
+
function Ln(r) {
|
|
2176
2178
|
if (!r || r.kind !== "categories" || r.entries.length <= kt) return r;
|
|
2177
2179
|
const t = r.entries.slice(0, kt), e = r.entries.length - kt;
|
|
2178
2180
|
return {
|
|
@@ -2180,7 +2182,7 @@ function Pn(r) {
|
|
|
2180
2182
|
entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
|
|
2181
2183
|
};
|
|
2182
2184
|
}
|
|
2183
|
-
function
|
|
2185
|
+
function Rn(r, t) {
|
|
2184
2186
|
const e = t.filter((i) => i.match != null);
|
|
2185
2187
|
if (!r || r.kind === "ramp" || e.length === 0) return r;
|
|
2186
2188
|
const n = [];
|
|
@@ -2190,7 +2192,7 @@ function Tn(r, t) {
|
|
|
2190
2192
|
}
|
|
2191
2193
|
return { ...r, entries: n };
|
|
2192
2194
|
}
|
|
2193
|
-
function
|
|
2195
|
+
function In(r) {
|
|
2194
2196
|
const t = [];
|
|
2195
2197
|
for (const e of r.querySelectorAll(":scope > om-legend-row")) {
|
|
2196
2198
|
const n = e.getAttribute("layer");
|
|
@@ -2208,7 +2210,7 @@ function Ln(r) {
|
|
|
2208
2210
|
}
|
|
2209
2211
|
return t;
|
|
2210
2212
|
}
|
|
2211
|
-
function
|
|
2213
|
+
function ir(r) {
|
|
2212
2214
|
const t = [];
|
|
2213
2215
|
for (const e of r.querySelectorAll(":scope > om-legend-row")) {
|
|
2214
2216
|
if (e.hasAttribute("hide")) continue;
|
|
@@ -2223,17 +2225,17 @@ function rr(r) {
|
|
|
2223
2225
|
}
|
|
2224
2226
|
return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
|
|
2225
2227
|
}
|
|
2226
|
-
const
|
|
2227
|
-
class
|
|
2228
|
+
const Me = "data-om-carto-legend-rows";
|
|
2229
|
+
class sr extends F {
|
|
2228
2230
|
static observedAttributes = [...T["om-legend"]];
|
|
2229
2231
|
get derived() {
|
|
2230
2232
|
return this.getAttribute("derived") !== "false";
|
|
2231
2233
|
}
|
|
2232
2234
|
/** The rows this legend currently shows — recomputed on demand, never stored. */
|
|
2233
2235
|
get rows() {
|
|
2234
|
-
if (!this.derived) return
|
|
2236
|
+
if (!this.derived) return ir(this);
|
|
2235
2237
|
const n = O(this)?.mapElement?.getLayers?.();
|
|
2236
|
-
return n ?
|
|
2238
|
+
return n ? Tn(n, In(this)) : [];
|
|
2237
2239
|
}
|
|
2238
2240
|
renderNow() {
|
|
2239
2241
|
if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !O(this)) {
|
|
@@ -2250,9 +2252,9 @@ class nr extends I {
|
|
|
2250
2252
|
}
|
|
2251
2253
|
renderRows(t) {
|
|
2252
2254
|
const e = this.ownerDocument;
|
|
2253
|
-
this.querySelector(`:scope > [${
|
|
2255
|
+
this.querySelector(`:scope > [${Me}]`)?.remove(), qr(this);
|
|
2254
2256
|
const n = e.createElement("div");
|
|
2255
|
-
n.setAttribute(
|
|
2257
|
+
n.setAttribute(Me, ""), n.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
|
|
2256
2258
|
const i = this.getAttribute("title");
|
|
2257
2259
|
if (i) {
|
|
2258
2260
|
const s = e.createElement("div");
|
|
@@ -2300,34 +2302,34 @@ class nr extends I {
|
|
|
2300
2302
|
if (o <= 0 || s <= 0) return;
|
|
2301
2303
|
const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = R(a?.backgroundColor);
|
|
2302
2304
|
l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
|
|
2303
|
-
const c = R(a?.borderTopColor), u =
|
|
2305
|
+
const c = R(a?.borderTopColor), u = $t(a?.borderTopWidth) * e.scale;
|
|
2304
2306
|
c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, o - u, s - u));
|
|
2305
|
-
const
|
|
2306
|
-
let f =
|
|
2307
|
+
const m = R(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", h = (P) => P * e.pxPerMm;
|
|
2308
|
+
let f = h(2);
|
|
2307
2309
|
const g = this.getAttribute("title");
|
|
2308
|
-
g && (t.fillStyle =
|
|
2309
|
-
const p = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(p.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(p.length / w)),
|
|
2310
|
-
let _ = -1,
|
|
2311
|
-
t.font = `${
|
|
2310
|
+
g && (t.fillStyle = m, t.font = `600 ${h(2.6)}px ${d}`, t.textBaseline = "top", t.fillText(g, h(2), f), f += h(4));
|
|
2311
|
+
const p = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(p.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(p.length / w)), A = 3, v = Math.max(1, (n - 4 - A * (w - 1)) / w), N = f;
|
|
2312
|
+
let _ = -1, x = 2;
|
|
2313
|
+
t.font = `${h(2.6)}px ${d}`;
|
|
2312
2314
|
for (const [P, L] of p.entries()) {
|
|
2313
|
-
const
|
|
2314
|
-
if (
|
|
2315
|
+
const M = Math.min(w - 1, Math.floor(P / y));
|
|
2316
|
+
if (M !== _ && (_ = M, x = 2 + _ * (v + A), f = _ === 0 ? N : h(2)), f > s || (t.fillStyle = L.color, L.shape === "line" ? t.fillRect(h(x), f + h(1.2), h(3.2), h(0.9)) : L.shape === "point" ? (t.beginPath(), t.arc(h(x + 1.6), f + h(1.6), h(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(h(x), f, h(3.2), h(3.2)), t.fillStyle = m, t.textBaseline = "top", t.fillText(L.label, h(x + 4.7), f + h(0.3)), f += h(4.2), !L.legend)) continue;
|
|
2315
2317
|
const S = L.legend;
|
|
2316
|
-
if (t.save(), t.font = `${
|
|
2317
|
-
const
|
|
2318
|
-
S.colors.forEach((X,
|
|
2318
|
+
if (t.save(), t.font = `${h(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(S.field, h(x + 2.7), f), t.globalAlpha = 1, f += h(2.8), S.kind === "ramp") {
|
|
2319
|
+
const $ = Math.min(24, Math.max(1, v - 2.7)), E = x + 2.7, U = t.createLinearGradient(h(E), 0, h(E + $), 0);
|
|
2320
|
+
S.colors.forEach((X, ur) => U.addColorStop(S.colors.length === 1 ? 0 : ur / (S.colors.length - 1), X)), t.fillStyle = U, t.fillRect(h(E), f, h($), h(2.4)), f += h(3.4), t.fillStyle = m, t.font = `${h(2.1)}px ${d}`, t.fillText(S.domain[0].toLocaleString("en-US"), h(E), f);
|
|
2319
2321
|
const et = S.domain[1].toLocaleString("en-US");
|
|
2320
|
-
t.textAlign = "right", t.fillText(et,
|
|
2322
|
+
t.textAlign = "right", t.fillText(et, h(E + $), f), t.textAlign = "left", f += h(3.2);
|
|
2321
2323
|
} else {
|
|
2322
|
-
const
|
|
2323
|
-
S.kind === "categories" && S.defaultColor &&
|
|
2324
|
-
for (const E of
|
|
2324
|
+
const $ = [...S.entries];
|
|
2325
|
+
S.kind === "categories" && S.defaultColor && $.push({ color: S.defaultColor, label: "other" }), t.font = `${h(2.3)}px ${d}`;
|
|
2326
|
+
for (const E of $) {
|
|
2325
2327
|
if (f > s) break;
|
|
2326
|
-
t.fillStyle = E.color, t.fillRect(
|
|
2328
|
+
t.fillStyle = E.color, t.fillRect(h(x + 2.7), f, h(2.6), h(2.6)), t.fillStyle = m, t.fillText(E.label, h(x + 6.3), f + h(0.2)), f += h(3.2);
|
|
2327
2329
|
}
|
|
2328
|
-
f +=
|
|
2330
|
+
f += h(1);
|
|
2329
2331
|
}
|
|
2330
|
-
t.restore(), t.font = `${
|
|
2332
|
+
t.restore(), t.font = `${h(2.6)}px ${d}`;
|
|
2331
2333
|
}
|
|
2332
2334
|
}
|
|
2333
2335
|
}
|
|
@@ -2335,55 +2337,55 @@ const at = (r, t) => {
|
|
|
2335
2337
|
const e = r.createElement("span");
|
|
2336
2338
|
return e.textContent = t, e;
|
|
2337
2339
|
};
|
|
2338
|
-
k("om-legend",
|
|
2340
|
+
k("om-legend", sr);
|
|
2339
2341
|
const Se = 48, _t = {
|
|
2340
2342
|
toLngLat: (r, t) => [r, t],
|
|
2341
2343
|
fromLngLat: (r) => [r[0], r[1]]
|
|
2342
2344
|
};
|
|
2343
2345
|
function Ce(r, t = 5) {
|
|
2344
|
-
return !Number.isFinite(r) || r <= 0 ? 0 :
|
|
2346
|
+
return !Number.isFinite(r) || r <= 0 ? 0 : je(r / Math.max(1, t));
|
|
2345
2347
|
}
|
|
2346
|
-
function
|
|
2348
|
+
function Fn({ georef: r, plane: t = _t, interval: e, intervalX: n, intervalY: i, labels: o = "outside", format: s }) {
|
|
2347
2349
|
if (r.degenerate) return null;
|
|
2348
2350
|
const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
|
|
2349
2351
|
if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
|
|
2350
|
-
const u = Math.min(...l),
|
|
2351
|
-
if (f <= 0 || g <= 0 || (
|
|
2352
|
-
const p = [], b = [], w = s ??
|
|
2353
|
-
for (let y = Math.ceil(u / f) * f; y <=
|
|
2354
|
-
const
|
|
2355
|
-
if (
|
|
2356
|
-
p.push(
|
|
2357
|
-
const v = t === _t ?
|
|
2358
|
-
o !== "none" && Ee(b,
|
|
2352
|
+
const u = Math.min(...l), m = Math.max(...l), d = Math.min(...c), h = Math.max(...c), f = ke(n ?? e, Ce(m - u)), g = ke(i ?? e, Ce(h - d));
|
|
2353
|
+
if (f <= 0 || g <= 0 || (m - u) / f > 500 || (h - d) / g > 500) return null;
|
|
2354
|
+
const p = [], b = [], w = s ?? On;
|
|
2355
|
+
for (let y = Math.ceil(u / f) * f; y <= m + 1e-9; y += f) {
|
|
2356
|
+
const A = xe(r, t, y, d, h, "x");
|
|
2357
|
+
if (A) {
|
|
2358
|
+
p.push(A);
|
|
2359
|
+
const v = t === _t ? Ze(y) : y;
|
|
2360
|
+
o !== "none" && Ee(b, A, r, w(v, "x"), "x", o);
|
|
2359
2361
|
}
|
|
2360
2362
|
}
|
|
2361
|
-
for (let y = Math.ceil(d / g) * g; y <=
|
|
2362
|
-
const
|
|
2363
|
-
|
|
2363
|
+
for (let y = Math.ceil(d / g) * g; y <= h + 1e-9; y += g) {
|
|
2364
|
+
const A = xe(r, t, y, u, m, "y");
|
|
2365
|
+
A && (p.push(A), o !== "none" && Ee(b, A, r, w(y, "y"), "y", o));
|
|
2364
2366
|
}
|
|
2365
2367
|
return { lines: p, labels: b, intervalX: f, intervalY: g };
|
|
2366
2368
|
}
|
|
2367
2369
|
const ke = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
|
|
2368
|
-
function
|
|
2370
|
+
function xe(r, t, e, n, i, o) {
|
|
2369
2371
|
const s = [];
|
|
2370
2372
|
for (let l = 0; l <= Se; l++) {
|
|
2371
2373
|
const c = n + (i - n) * l / Se, u = o === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
|
|
2372
2374
|
if (!Number.isFinite(u[0]) || !Number.isFinite(u[1])) continue;
|
|
2373
|
-
const
|
|
2374
|
-
|
|
2375
|
+
const m = r.project(u);
|
|
2376
|
+
m && s.push(m);
|
|
2375
2377
|
}
|
|
2376
|
-
const a =
|
|
2378
|
+
const a = _n(s, r.widthMm, r.heightMm);
|
|
2377
2379
|
return a.length >= 2 ? { points: a, value: e, axis: o } : null;
|
|
2378
2380
|
}
|
|
2379
|
-
function
|
|
2381
|
+
function _n(r, t, e) {
|
|
2380
2382
|
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);
|
|
2381
2383
|
if (i === -1) return [];
|
|
2382
2384
|
let o = r.length - 1;
|
|
2383
2385
|
for (; o > i && !n(r[o]); ) o--;
|
|
2384
|
-
return r.slice(Math.max(0, i - 1), Math.min(r.length, o + 2)).map((a) => ({ xMm:
|
|
2386
|
+
return r.slice(Math.max(0, i - 1), Math.min(r.length, o + 2)).map((a) => ({ xMm: $e(a.xMm, 0, t), yMm: $e(a.yMm, 0, e) }));
|
|
2385
2387
|
}
|
|
2386
|
-
const
|
|
2388
|
+
const $e = (r, t, e) => Math.min(e, Math.max(t, r));
|
|
2387
2389
|
function Ee(r, t, e, n, i, o) {
|
|
2388
2390
|
if (i === "x") {
|
|
2389
2391
|
const s = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
|
|
@@ -2395,24 +2397,24 @@ function Ee(r, t, e, n, i, o) {
|
|
|
2395
2397
|
r.push({ text: n, xMm: o === "outside" ? -1.2 : 1.2, yMm: s.yMm, edge: "left", axis: i });
|
|
2396
2398
|
}
|
|
2397
2399
|
}
|
|
2398
|
-
function
|
|
2400
|
+
function On(r, t) {
|
|
2399
2401
|
if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
|
|
2400
2402
|
const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
|
|
2401
2403
|
return `${Number(r.toFixed(e))}°`;
|
|
2402
2404
|
}
|
|
2403
|
-
function
|
|
2404
|
-
const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), o = (n - i) * 60, s = Math.floor(o), a = Math.round((o - s) * 60), l = a === 60 ? s + 1 : s, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l,
|
|
2405
|
-
return `${c}°${String(u).padStart(2, "0")}′${String(
|
|
2405
|
+
function Un(r, t) {
|
|
2406
|
+
const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), o = (n - i) * 60, s = Math.floor(o), a = Math.round((o - s) * 60), l = a === 60 ? s + 1 : s, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, m = a === 60 ? 0 : a;
|
|
2407
|
+
return `${c}°${String(u).padStart(2, "0")}′${String(m).padStart(2, "0")}″${e}`;
|
|
2406
2408
|
}
|
|
2407
|
-
const lt = "http://www.w3.org/2000/svg",
|
|
2408
|
-
class
|
|
2409
|
+
const lt = "http://www.w3.org/2000/svg", Dn = ["solid", "cross", "markers"], z = 1.4;
|
|
2410
|
+
class or extends F {
|
|
2409
2411
|
static observedAttributes = [...T["om-graticule"]];
|
|
2410
2412
|
resolvedPlane = null;
|
|
2411
2413
|
resolvedPlaneKey = null;
|
|
2412
2414
|
resolveToken = 0;
|
|
2413
2415
|
get kind() {
|
|
2414
2416
|
const t = this.getAttribute("kind");
|
|
2415
|
-
return
|
|
2417
|
+
return Dn.includes(t) ? t : "solid";
|
|
2416
2418
|
}
|
|
2417
2419
|
get labelPlacement() {
|
|
2418
2420
|
const t = this.getAttribute("labels");
|
|
@@ -2428,14 +2430,14 @@ class ir extends I {
|
|
|
2428
2430
|
const o = Number(this.getAttribute(i));
|
|
2429
2431
|
return Number.isFinite(o) && o > 0 ? o : null;
|
|
2430
2432
|
};
|
|
2431
|
-
return
|
|
2433
|
+
return Fn({
|
|
2432
2434
|
georef: t,
|
|
2433
2435
|
plane: e,
|
|
2434
2436
|
interval: n("interval"),
|
|
2435
2437
|
intervalX: n("interval-x"),
|
|
2436
2438
|
intervalY: n("interval-y"),
|
|
2437
2439
|
labels: this.labelPlacement,
|
|
2438
|
-
format: this.getAttribute("format") === "dms" ?
|
|
2440
|
+
format: this.getAttribute("format") === "dms" ? Un : void 0
|
|
2439
2441
|
});
|
|
2440
2442
|
}
|
|
2441
2443
|
/**
|
|
@@ -2448,7 +2450,7 @@ class ir extends I {
|
|
|
2448
2450
|
if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return _t;
|
|
2449
2451
|
const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
|
|
2450
2452
|
if (this.resolvedPlaneKey === e) return this.resolvedPlane;
|
|
2451
|
-
const n =
|
|
2453
|
+
const n = V(t);
|
|
2452
2454
|
if (n) {
|
|
2453
2455
|
const o = { toLngLat: (s, a) => n.inverse([s, a]), fromLngLat: (s) => n.forward(s) };
|
|
2454
2456
|
return this.resolvedPlane = o, this.resolvedPlaneKey = e, o;
|
|
@@ -2496,7 +2498,7 @@ class ir extends I {
|
|
|
2496
2498
|
if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
|
|
2497
2499
|
const i = n.lines.filter((s) => s.axis !== t.axis), o = [];
|
|
2498
2500
|
for (const s of i) {
|
|
2499
|
-
const a =
|
|
2501
|
+
const a = jn(t.points, s.points);
|
|
2500
2502
|
a && o.push(a);
|
|
2501
2503
|
}
|
|
2502
2504
|
return o;
|
|
@@ -2518,7 +2520,7 @@ class ir extends I {
|
|
|
2518
2520
|
t.restore();
|
|
2519
2521
|
}
|
|
2520
2522
|
}
|
|
2521
|
-
function
|
|
2523
|
+
function jn(r, t) {
|
|
2522
2524
|
let e = null, n = Number.POSITIVE_INFINITY;
|
|
2523
2525
|
for (const i of r)
|
|
2524
2526
|
for (const o of t) {
|
|
@@ -2527,8 +2529,8 @@ function Un(r, t) {
|
|
|
2527
2529
|
}
|
|
2528
2530
|
return n <= 1 ? e : null;
|
|
2529
2531
|
}
|
|
2530
|
-
k("om-graticule",
|
|
2531
|
-
function
|
|
2532
|
+
k("om-graticule", or);
|
|
2533
|
+
function zn(r, t) {
|
|
2532
2534
|
if (r == null || typeof r != "object") return;
|
|
2533
2535
|
const e = r.properties;
|
|
2534
2536
|
return e && t in e ? e[t] : r[t];
|
|
@@ -2542,11 +2544,11 @@ function Ot(r, t) {
|
|
|
2542
2544
|
for (const e of r) Ot(e, t);
|
|
2543
2545
|
}
|
|
2544
2546
|
}
|
|
2545
|
-
function
|
|
2547
|
+
function Gn(r) {
|
|
2546
2548
|
return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
|
|
2547
2549
|
}
|
|
2548
|
-
function
|
|
2549
|
-
return
|
|
2550
|
+
function I(r, t) {
|
|
2551
|
+
return zn(r, t);
|
|
2550
2552
|
}
|
|
2551
2553
|
function Ut(r) {
|
|
2552
2554
|
const t = {}, e = (i) => {
|
|
@@ -2557,64 +2559,65 @@ function Ut(r) {
|
|
|
2557
2559
|
const n = r.properties;
|
|
2558
2560
|
return n && typeof n == "object" && e(n), t;
|
|
2559
2561
|
}
|
|
2560
|
-
function
|
|
2562
|
+
function qn(r) {
|
|
2561
2563
|
let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
|
|
2562
2564
|
const o = [], s = r.geometry;
|
|
2563
2565
|
if (s?.coordinates != null) Ot(s.coordinates, o);
|
|
2564
2566
|
else if (Array.isArray(r.coordinates)) Ot(r.coordinates, o);
|
|
2565
2567
|
else {
|
|
2566
|
-
const a = Number(
|
|
2568
|
+
const a = Number(I(r, "lng") ?? I(r, "longitude") ?? I(r, "lon") ?? I(r, "x")), l = Number(I(r, "lat") ?? I(r, "latitude") ?? I(r, "y"));
|
|
2567
2569
|
Number.isFinite(a) && Number.isFinite(l) && o.push([a, l]);
|
|
2568
2570
|
}
|
|
2569
2571
|
for (const [a, l] of o)
|
|
2570
2572
|
!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));
|
|
2571
2573
|
return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
|
|
2572
2574
|
}
|
|
2573
|
-
function
|
|
2575
|
+
function Wn(r, t) {
|
|
2574
2576
|
const [e, n, i, o] = r, s = Math.max(i - e, 1e-4), a = Math.max(o - n, 1e-4), l = s * t, c = a * t;
|
|
2575
2577
|
return [e - l, n - c, i + l, o + c];
|
|
2576
2578
|
}
|
|
2577
|
-
const
|
|
2578
|
-
function
|
|
2579
|
-
let n = t ? r.filter((o) =>
|
|
2580
|
-
const i =
|
|
2579
|
+
const xi = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
|
|
2580
|
+
function Bn({ features: r, filter: t, sort: e }) {
|
|
2581
|
+
let n = t ? r.filter((o) => Kn(t, o)) : [...r];
|
|
2582
|
+
const i = Vn(e);
|
|
2581
2583
|
return i.length > 0 && (n = [...n].sort((o, s) => {
|
|
2582
2584
|
for (const { field: a, descending: l } of i) {
|
|
2583
|
-
const c =
|
|
2585
|
+
const c = I(o, a), u = I(s, a);
|
|
2584
2586
|
if (c == null && u == null) continue;
|
|
2585
2587
|
if (c == null) return 1;
|
|
2586
2588
|
if (u == null) return -1;
|
|
2587
|
-
const
|
|
2588
|
-
if (
|
|
2589
|
+
const m = Hn(c, u);
|
|
2590
|
+
if (m !== 0) return l ? -m : m;
|
|
2589
2591
|
}
|
|
2590
2592
|
return 0;
|
|
2591
2593
|
})), n;
|
|
2592
2594
|
}
|
|
2593
|
-
function
|
|
2595
|
+
function Kn(r, t) {
|
|
2594
2596
|
try {
|
|
2595
2597
|
return !!r(t);
|
|
2596
2598
|
} catch {
|
|
2597
2599
|
return !1;
|
|
2598
2600
|
}
|
|
2599
2601
|
}
|
|
2600
|
-
function
|
|
2602
|
+
function Vn(r) {
|
|
2601
2603
|
return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
|
|
2602
2604
|
}
|
|
2603
|
-
function
|
|
2605
|
+
function Hn(r, t) {
|
|
2604
2606
|
return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
|
|
2605
2607
|
}
|
|
2606
|
-
function
|
|
2608
|
+
function Yn(r) {
|
|
2607
2609
|
const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
|
|
2608
2610
|
return t === "" ? "page" : t;
|
|
2609
2611
|
}
|
|
2610
|
-
function
|
|
2612
|
+
function Xn(r, t, e) {
|
|
2611
2613
|
const n = /* @__PURE__ */ new Map();
|
|
2612
2614
|
return t.map((i, o) => {
|
|
2613
|
-
const s = Ut(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u,
|
|
2615
|
+
const s = Ut(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, m) => m === "index" ? String(o + 1) : m === "count" ? String(t.length) : s[m] ?? u), l = Yn(a), c = n.get(l) ?? 0;
|
|
2614
2616
|
return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
|
|
2615
2617
|
});
|
|
2616
2618
|
}
|
|
2617
|
-
|
|
2619
|
+
const Ne = "data-om-carto-pager", Jn = "data-om-carto-screen-only", Zn = "onlymap-cartograph", Qn = "onlymap-cartograph-host";
|
|
2620
|
+
class ar extends F {
|
|
2618
2621
|
static observedAttributes = [...T["om-atlas"]];
|
|
2619
2622
|
/**
|
|
2620
2623
|
* Pages are SNAPSHOTTED when iteration first starts. A streaming or polling
|
|
@@ -2624,6 +2627,48 @@ class sr extends I {
|
|
|
2624
2627
|
pages = null;
|
|
2625
2628
|
currentIndex = 0;
|
|
2626
2629
|
rejection = null;
|
|
2630
|
+
pager = null;
|
|
2631
|
+
/**
|
|
2632
|
+
* Arrow keys page the atlas. This element had `seek()`, `next()` and an
|
|
2633
|
+
* event, and no way for a READER to use any of them: a 49-page atlas opened
|
|
2634
|
+
* in a preview, a browser or an exported file showed page one and could not
|
|
2635
|
+
* be moved off it. Bound as fields so the exact function is removed again.
|
|
2636
|
+
*/
|
|
2637
|
+
onKeyDown = (t) => {
|
|
2638
|
+
if (t.defaultPrevented || t.metaKey || t.ctrlKey || t.altKey || !this.isConnected || this.count === 0) return;
|
|
2639
|
+
const e = t.target, n = e?.tagName?.toLowerCase();
|
|
2640
|
+
if (n === "input" || n === "textarea" || n === "select" || e?.isContentEditable) return;
|
|
2641
|
+
let i = null;
|
|
2642
|
+
switch (t.key) {
|
|
2643
|
+
case "ArrowRight":
|
|
2644
|
+
case "PageDown":
|
|
2645
|
+
i = this.currentIndex + 1;
|
|
2646
|
+
break;
|
|
2647
|
+
case "ArrowLeft":
|
|
2648
|
+
case "PageUp":
|
|
2649
|
+
i = this.currentIndex - 1;
|
|
2650
|
+
break;
|
|
2651
|
+
case "Home":
|
|
2652
|
+
i = 0;
|
|
2653
|
+
break;
|
|
2654
|
+
case "End":
|
|
2655
|
+
i = this.count - 1;
|
|
2656
|
+
break;
|
|
2657
|
+
default:
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
t.preventDefault(), this.seek(i);
|
|
2661
|
+
};
|
|
2662
|
+
/**
|
|
2663
|
+
* A parent window may drive the atlas: `{ source: "onlymap-cartograph-host",
|
|
2664
|
+
* type: "atlas-seek", index }`. This is what lets a host that shows the
|
|
2665
|
+
* sheet in a CROSS-ORIGIN iframe — where it cannot reach `seek()` — page it
|
|
2666
|
+
* anyway. Any window can post this; the worst it can do is turn a page.
|
|
2667
|
+
*/
|
|
2668
|
+
onHostMessage = (t) => {
|
|
2669
|
+
const e = t.data;
|
|
2670
|
+
!e || e.source !== Qn || e.type !== "atlas-seek" || typeof e.index == "number" && Number.isInteger(e.index) && this.seek(e.index);
|
|
2671
|
+
};
|
|
2627
2672
|
/** The frame whose layer drives the iteration — the same `for=` rule every furniture element follows. */
|
|
2628
2673
|
get frame() {
|
|
2629
2674
|
return O(this);
|
|
@@ -2643,7 +2688,7 @@ class sr extends I {
|
|
|
2643
2688
|
}
|
|
2644
2689
|
/** Export filenames, one per page, already de-duplicated. */
|
|
2645
2690
|
filenames(t = "png") {
|
|
2646
|
-
return
|
|
2691
|
+
return Xn(this.getAttribute("filename"), this.ensurePages(), t);
|
|
2647
2692
|
}
|
|
2648
2693
|
/** Human page labels, for an editor's stepper and PDF bookmarks. */
|
|
2649
2694
|
pageName(t) {
|
|
@@ -2663,15 +2708,15 @@ class sr extends I {
|
|
|
2663
2708
|
* the authored camera, until something else happened to seek.
|
|
2664
2709
|
*/
|
|
2665
2710
|
refresh() {
|
|
2666
|
-
this.pages = null, this.rejection = null, this.ensurePages().length > 0
|
|
2711
|
+
this.pages = null, this.rejection = null, this.ensurePages().length > 0 ? this.applyPage() : this.renderPager();
|
|
2667
2712
|
}
|
|
2668
2713
|
ensurePages() {
|
|
2669
2714
|
if (this.pages) return this.pages;
|
|
2670
|
-
const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), o = e ?
|
|
2715
|
+
const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), o = e ? Gn(i) : null;
|
|
2671
2716
|
if (!e || o)
|
|
2672
2717
|
return this.rejection = e ? o : null, this.pages = [];
|
|
2673
2718
|
const s = this.materialize(i);
|
|
2674
|
-
return this.pages =
|
|
2719
|
+
return this.pages = Bn({ features: s, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
|
|
2675
2720
|
}
|
|
2676
2721
|
/**
|
|
2677
2722
|
* Rows from the layer, with the layer's OWN declarative filters applied —
|
|
@@ -2685,7 +2730,7 @@ class sr extends I {
|
|
|
2685
2730
|
return o.length === 0 ? i : i.filter(
|
|
2686
2731
|
(s) => o.every((a) => {
|
|
2687
2732
|
if (!a.field) return !0;
|
|
2688
|
-
const l =
|
|
2733
|
+
const l = I(s, a.field);
|
|
2689
2734
|
if (a.range) {
|
|
2690
2735
|
const c = Number(l);
|
|
2691
2736
|
return Number.isFinite(c) && c >= a.range[0] && c <= a.range[1];
|
|
@@ -2720,26 +2765,74 @@ class sr extends I {
|
|
|
2720
2765
|
const t = this.current;
|
|
2721
2766
|
if (!t) return;
|
|
2722
2767
|
const e = this.closest("om-cartograph");
|
|
2723
|
-
for (const
|
|
2724
|
-
if (
|
|
2725
|
-
const
|
|
2726
|
-
if (!
|
|
2727
|
-
const
|
|
2728
|
-
|
|
2729
|
-
}
|
|
2730
|
-
e?.setAtlasFields({ ...Ut(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture()
|
|
2768
|
+
for (const o of e?.querySelectorAll("om-frame") ?? []) {
|
|
2769
|
+
if (o.getAttribute("atlas-fit") !== "feature") continue;
|
|
2770
|
+
const s = qn(t);
|
|
2771
|
+
if (!s) continue;
|
|
2772
|
+
const a = Number(o.getAttribute("atlas-margin")), l = Wn(s, Number.isFinite(a) && a > 0 ? a : 0.15);
|
|
2773
|
+
o.fitBounds?.(l);
|
|
2774
|
+
}
|
|
2775
|
+
e?.setAtlasFields({ ...Ut(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture();
|
|
2776
|
+
const n = this.pageName(this.currentIndex);
|
|
2777
|
+
this.dispatchEvent(
|
|
2731
2778
|
new CustomEvent("om-atlas-page", {
|
|
2732
2779
|
bubbles: !0,
|
|
2733
|
-
detail: { index: this.currentIndex, count: this.count, name:
|
|
2780
|
+
detail: { index: this.currentIndex, count: this.count, name: n, feature: t }
|
|
2734
2781
|
})
|
|
2735
|
-
);
|
|
2782
|
+
), this.renderPager();
|
|
2783
|
+
const i = typeof window < "u" ? window.parent : null;
|
|
2784
|
+
i && i !== window && i.postMessage({ source: Zn, type: "atlas-page", index: this.currentIndex, count: this.count, name: n }, "*");
|
|
2785
|
+
}
|
|
2786
|
+
/**
|
|
2787
|
+
* Draw (or update) the reader's page control on the owning sheet:
|
|
2788
|
+
* `‹ 3 / 49 · Alabama ›`. Find-or-create, like the page's own overlays, so
|
|
2789
|
+
* paging updates one element rather than stacking them. `pager="none"`
|
|
2790
|
+
* removes it for a host that draws its own.
|
|
2791
|
+
*/
|
|
2792
|
+
renderPager() {
|
|
2793
|
+
const t = this.closest("om-cartograph");
|
|
2794
|
+
if (!t) return;
|
|
2795
|
+
const e = t.querySelector(`:scope > [${Ne}]`), n = this.count;
|
|
2796
|
+
if (this.getAttribute("pager") === "none" || n === 0) {
|
|
2797
|
+
e?.remove(), this.pager = null;
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
const i = this.ownerDocument, o = e ?? i.createElement("div");
|
|
2801
|
+
if (!e) {
|
|
2802
|
+
o.setAttribute(Ne, ""), o.setAttribute(Jn, ""), o.setAttribute("role", "navigation"), o.setAttribute("aria-label", "Atlas pages"), o.style.cssText = "position:absolute;left:50%;bottom:4mm;transform:translateX(-50%);z-index:2147483000;display:flex;align-items:center;gap:8px;padding:4px 10px;border-radius:999px;background:rgba(20,20,24,.82);color:#fff;font:12px/1.2 system-ui,sans-serif;box-shadow:0 2px 10px rgba(0,0,0,.35);user-select:none;pointer-events:auto;";
|
|
2803
|
+
for (const [u, m, d] of [
|
|
2804
|
+
[-1, "‹", "Previous page"],
|
|
2805
|
+
[1, "›", "Next page"]
|
|
2806
|
+
]) {
|
|
2807
|
+
const h = i.createElement("button");
|
|
2808
|
+
h.type = "button", h.setAttribute("data-om-carto-pager-step", String(u)), h.setAttribute("aria-label", d), h.textContent = m, h.style.cssText = "all:unset;cursor:pointer;padding:0 6px;font-size:16px;line-height:1;color:inherit;", h.addEventListener("click", () => this.seek(this.currentIndex + u)), o.appendChild(h);
|
|
2809
|
+
}
|
|
2810
|
+
const c = i.createElement("span");
|
|
2811
|
+
c.setAttribute("data-om-carto-pager-label", ""), o.insertBefore(c, o.lastElementChild), t.appendChild(o);
|
|
2812
|
+
}
|
|
2813
|
+
const s = o.querySelector("[data-om-carto-pager-label]");
|
|
2814
|
+
s.textContent = `${this.currentIndex + 1} / ${n} · ${this.pageName(this.currentIndex)}`;
|
|
2815
|
+
const [a, l] = o.querySelectorAll("button");
|
|
2816
|
+
a && (a.disabled = this.currentIndex === 0), l && (l.disabled = this.currentIndex >= n - 1);
|
|
2817
|
+
for (const c of [a, l]) c && (c.style.opacity = c.disabled ? ".35" : "1");
|
|
2818
|
+
this.pager = o;
|
|
2819
|
+
}
|
|
2820
|
+
connectedCallback() {
|
|
2821
|
+
super.connectedCallback(), this.ownerDocument.addEventListener("keydown", this.onKeyDown), typeof window < "u" && window.addEventListener("message", this.onHostMessage);
|
|
2822
|
+
}
|
|
2823
|
+
disconnectedCallback() {
|
|
2824
|
+
this.ownerDocument.removeEventListener("keydown", this.onKeyDown), typeof window < "u" && window.removeEventListener("message", this.onHostMessage);
|
|
2825
|
+
const t = this.pager;
|
|
2826
|
+
this.pager = null, t && queueMicrotask(() => {
|
|
2827
|
+
t.isConnected && !this.isConnected && t.remove();
|
|
2828
|
+
});
|
|
2736
2829
|
}
|
|
2737
2830
|
renderNow() {
|
|
2738
2831
|
this.style.display = "none", this.refresh();
|
|
2739
2832
|
}
|
|
2740
2833
|
}
|
|
2741
|
-
k("om-atlas",
|
|
2742
|
-
class
|
|
2834
|
+
k("om-atlas", ar);
|
|
2835
|
+
class ti extends De {
|
|
2743
2836
|
static observedAttributes = [...T["om-source"]];
|
|
2744
2837
|
connectedCallback() {
|
|
2745
2838
|
this.style.display = "none";
|
|
@@ -2753,38 +2846,38 @@ class Yn extends Oe {
|
|
|
2753
2846
|
this.closest("om-frame")?.scheduleRender?.();
|
|
2754
2847
|
}
|
|
2755
2848
|
}
|
|
2756
|
-
const
|
|
2757
|
-
function
|
|
2849
|
+
const ei = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), ri = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), ni = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], ii = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), si = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), oi = 0.02, ai = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
|
|
2850
|
+
function lr(r) {
|
|
2758
2851
|
const t = r.tagName.toLowerCase();
|
|
2759
2852
|
return r.id ? `${t}#${r.id}` : t;
|
|
2760
2853
|
}
|
|
2761
|
-
function
|
|
2854
|
+
function K(r, t) {
|
|
2762
2855
|
const e = r.getAttribute(t);
|
|
2763
2856
|
if (e == null || e.trim() === "") return null;
|
|
2764
2857
|
const n = Number(e);
|
|
2765
2858
|
return Number.isFinite(n) ? n : null;
|
|
2766
2859
|
}
|
|
2767
|
-
function
|
|
2860
|
+
function li(r, t) {
|
|
2768
2861
|
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;
|
|
2769
2862
|
}
|
|
2770
|
-
function
|
|
2863
|
+
function ci(r, t) {
|
|
2771
2864
|
const e = r.getAttribute("style");
|
|
2772
2865
|
if (!e) return null;
|
|
2773
2866
|
const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
|
|
2774
2867
|
return n ? Number(n[1]) : null;
|
|
2775
2868
|
}
|
|
2776
|
-
function
|
|
2869
|
+
function cr(r) {
|
|
2777
2870
|
const t = [], e = (s, a, l, c, u) => {
|
|
2778
|
-
t.push({ severity: s, element:
|
|
2871
|
+
t.push({ severity: s, element: lr(a), ...u ? { attribute: u } : {}, message: l, fix: c });
|
|
2779
2872
|
}, n = [...r.querySelectorAll("om-cartograph")];
|
|
2780
2873
|
if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
|
|
2781
2874
|
return { valid: !0, errors: [], warnings: [] };
|
|
2782
|
-
for (const s of n)
|
|
2875
|
+
for (const s of n) ui(s, e);
|
|
2783
2876
|
const i = t.filter((s) => s.severity === "error"), o = t.filter((s) => s.severity === "warning");
|
|
2784
2877
|
return { valid: i.length === 0, errors: i, warnings: o };
|
|
2785
2878
|
}
|
|
2786
|
-
function
|
|
2787
|
-
const e = r.getAttribute("size"), n =
|
|
2879
|
+
function ui(r, t) {
|
|
2880
|
+
const e = r.getAttribute("size"), n = K(r, "width") != null && K(r, "height") != null;
|
|
2788
2881
|
e && !te.includes(e) && !n && t(
|
|
2789
2882
|
"error",
|
|
2790
2883
|
r,
|
|
@@ -2793,54 +2886,54 @@ function si(r, t) {
|
|
|
2793
2886
|
"size"
|
|
2794
2887
|
);
|
|
2795
2888
|
const i = r.getAttribute("cvd");
|
|
2796
|
-
i && i.trim().toLowerCase() !== "none" && !Dt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${
|
|
2797
|
-
const o =
|
|
2889
|
+
i && i.trim().toLowerCase() !== "none" && !Dt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${pr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && ai(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");
|
|
2890
|
+
const o = K(r, "safe-zone");
|
|
2798
2891
|
if (o != null && o > 0) {
|
|
2799
|
-
const
|
|
2800
|
-
o * 2 >= Math.min(
|
|
2892
|
+
const h = ht(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
|
|
2893
|
+
o * 2 >= Math.min(h.widthMm, h.heightMm) && t("warning", r, `safe-zone=${o}mm leaves no usable area on a ${h.widthMm} × ${h.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
|
|
2801
2894
|
}
|
|
2802
2895
|
const s = r.getAttribute("format");
|
|
2803
2896
|
s == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${gt}" so future runtimes can migrate this document.`, "format") : s !== gt && t("warning", r, `Unrecognised document format "${s}".`, `This build understands "${gt}".`, "format");
|
|
2804
|
-
const { widthMm: a, heightMm: l } = ht(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0,
|
|
2805
|
-
for (const
|
|
2806
|
-
|
|
2807
|
-
for (const
|
|
2808
|
-
if (
|
|
2809
|
-
const f =
|
|
2810
|
-
!pt.includes(f) && !
|
|
2897
|
+
const { widthMm: a, heightMm: l } = ht(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, K(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), m = [...r.querySelectorAll("om-frame")];
|
|
2898
|
+
for (const h of m)
|
|
2899
|
+
h.id ? u.add(h.id) : t("error", h, "Frame has no id.", "Give every frame an id so furniture can reference it with for=.", "id");
|
|
2900
|
+
for (const h of r.children) {
|
|
2901
|
+
if (ni.some((g) => h.hasAttribute(g))) continue;
|
|
2902
|
+
const f = h.tagName.toLowerCase();
|
|
2903
|
+
!pt.includes(f) && !ri.has(f) && t("error", h, `<${f}> is not a cartograph element.`, `Use one of ${pt.join(", ")}, or move this content inside an <om-text>.`);
|
|
2811
2904
|
}
|
|
2812
2905
|
const d = [];
|
|
2813
|
-
for (const
|
|
2814
|
-
const f =
|
|
2815
|
-
if (pt.includes(f) && !
|
|
2816
|
-
if (
|
|
2817
|
-
const g = C(
|
|
2818
|
-
|
|
2906
|
+
for (const h of [r, ...r.querySelectorAll("*")]) {
|
|
2907
|
+
const f = h.tagName.toLowerCase();
|
|
2908
|
+
if (pt.includes(f) && !h.closest("om-map")) {
|
|
2909
|
+
if (hi(h, f, t), si.has(f)) {
|
|
2910
|
+
const g = C(h);
|
|
2911
|
+
mi(h, g, a, l, c, t), ii.has(f) && !h.hasAttribute("hidden") && d.push({ el: h, box: g });
|
|
2819
2912
|
}
|
|
2820
|
-
f === "om-frame" &&
|
|
2913
|
+
f === "om-frame" && di(h, t), f === "om-source" && fi(h, t), f === "om-legend" && gi(h, m, t), f === "om-atlas" && pi(h, m, t), f === "om-scalebar" && bi(h, m, t), f === "om-text" && yi(h, m, t);
|
|
2821
2914
|
for (const g of ["for", "overview-of"]) {
|
|
2822
|
-
const p =
|
|
2823
|
-
p && !u.has(p) && t("error",
|
|
2915
|
+
const p = h.getAttribute(g);
|
|
2916
|
+
p && !u.has(p) && t("error", h, `${g}="${p}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, g);
|
|
2824
2917
|
}
|
|
2825
2918
|
}
|
|
2826
2919
|
}
|
|
2827
|
-
for (let
|
|
2828
|
-
for (let f =
|
|
2829
|
-
const g = d[
|
|
2830
|
-
g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 ||
|
|
2920
|
+
for (let h = 0; h < d.length; h++)
|
|
2921
|
+
for (let f = h + 1; f < d.length; f++) {
|
|
2922
|
+
const g = d[h], p = d[f];
|
|
2923
|
+
g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || li(g.box, p.box) && t(
|
|
2831
2924
|
"warning",
|
|
2832
2925
|
g.el,
|
|
2833
|
-
`Overlaps ${
|
|
2926
|
+
`Overlaps ${lr(p.el)} on the page.`,
|
|
2834
2927
|
"Move one of them — furniture overlapping furniture usually means a stale layout (frames may sit under anything)."
|
|
2835
2928
|
);
|
|
2836
2929
|
}
|
|
2837
2930
|
}
|
|
2838
|
-
function
|
|
2931
|
+
function hi(r, t, e) {
|
|
2839
2932
|
const n = new Set(T[t] ?? []);
|
|
2840
2933
|
for (const i of r.attributes) {
|
|
2841
2934
|
const o = i.name.toLowerCase();
|
|
2842
|
-
if (n.has(o) ||
|
|
2843
|
-
const s =
|
|
2935
|
+
if (n.has(o) || ei.has(o) || o.startsWith("data-") || o.startsWith("aria-")) continue;
|
|
2936
|
+
const s = Nr.get(o);
|
|
2844
2937
|
if (s) {
|
|
2845
2938
|
e("warning", r, `Attribute "${o}" has no effect: ${s}`, "Remove it, or use the documented alternative.", o);
|
|
2846
2939
|
continue;
|
|
@@ -2848,7 +2941,7 @@ function oi(r, t, e) {
|
|
|
2848
2941
|
e("warning", r, `Unknown attribute "${o}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, o);
|
|
2849
2942
|
}
|
|
2850
2943
|
}
|
|
2851
|
-
function
|
|
2944
|
+
function mi(r, t, e, n, i, o) {
|
|
2852
2945
|
if (t.w <= 0 || t.h <= 0) {
|
|
2853
2946
|
o("error", r, `Element has no size (w=${t.w}, h=${t.h}).`, "Give w= and h= in millimetres — both greater than zero.", t.w <= 0 ? "w" : "h");
|
|
2854
2947
|
return;
|
|
@@ -2866,18 +2959,18 @@ function ai(r, t, e, n, i, o) {
|
|
|
2866
2959
|
["width", t.w],
|
|
2867
2960
|
["height", t.h]
|
|
2868
2961
|
];
|
|
2869
|
-
for (const [u,
|
|
2870
|
-
const d =
|
|
2871
|
-
d != null && Math.abs(d -
|
|
2962
|
+
for (const [u, m] of c) {
|
|
2963
|
+
const d = ci(r, u);
|
|
2964
|
+
d != null && Math.abs(d - m) > 0.01 && o(
|
|
2872
2965
|
"error",
|
|
2873
2966
|
r,
|
|
2874
|
-
`Inline style ${u}:${d}mm disagrees with the placement attribute (${
|
|
2967
|
+
`Inline style ${u}:${d}mm disagrees with the placement attribute (${m}mm).`,
|
|
2875
2968
|
"The attributes are authoritative — make the inline style match, or drop it and let the runtime write it.",
|
|
2876
2969
|
"style"
|
|
2877
2970
|
);
|
|
2878
2971
|
}
|
|
2879
2972
|
}
|
|
2880
|
-
function
|
|
2973
|
+
function di(r, t) {
|
|
2881
2974
|
if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
|
|
2882
2975
|
const n = r.getAttribute("corners"), i = H(n);
|
|
2883
2976
|
i || t(
|
|
@@ -2892,14 +2985,14 @@ function li(r, t) {
|
|
|
2892
2985
|
"Static frame has no <img> or inline <svg> child to place.",
|
|
2893
2986
|
'Add the georeferenced picture as a child — an <img> raster, or the inline <svg> that snapshot({format: "svg"}) produces.'
|
|
2894
2987
|
);
|
|
2895
|
-
const o = C(r), s =
|
|
2988
|
+
const o = C(r), s = V(r.getAttribute("crs"));
|
|
2896
2989
|
if (i && s && o.w > 0 && o.h > 0) {
|
|
2897
2990
|
const a = Q({ corners: i, widthMm: o.w, heightMm: o.h, crsForward: s });
|
|
2898
2991
|
if (a.degenerate)
|
|
2899
2992
|
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");
|
|
2900
2993
|
else {
|
|
2901
|
-
const l =
|
|
2902
|
-
l != null && l >
|
|
2994
|
+
const l = mn(a);
|
|
2995
|
+
l != null && l > oi && t(
|
|
2903
2996
|
"warning",
|
|
2904
2997
|
r,
|
|
2905
2998
|
`Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
|
|
@@ -2921,17 +3014,40 @@ function li(r, t) {
|
|
|
2921
3014
|
"Give it src=, add an <om-source src=> child, or add an inline <om-map> child.",
|
|
2922
3015
|
"src"
|
|
2923
3016
|
);
|
|
2924
|
-
|
|
2925
|
-
|
|
3017
|
+
const n = r.getAttribute("atlas-margin");
|
|
3018
|
+
if (n != null) {
|
|
3019
|
+
const i = Number(n);
|
|
3020
|
+
!Number.isFinite(i) || i < 0 ? t(
|
|
3021
|
+
"warning",
|
|
3022
|
+
r,
|
|
3023
|
+
`atlas-margin="${n}" is not a number, so the default (0.15) is used.`,
|
|
3024
|
+
`Give a fraction of the feature's extent, e.g. atlas-margin="0.15".`,
|
|
3025
|
+
"atlas-margin"
|
|
3026
|
+
) : i > 2 && t(
|
|
2926
3027
|
"warning",
|
|
2927
3028
|
r,
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
3029
|
+
`atlas-margin="${n}" pads each side by ${i}× the feature's extent — it is a FRACTION (default 0.15), not millimetres.`,
|
|
3030
|
+
'Use 0.1–0.3. "A 10 mm margin" is atlas-margin="0.1", not "10".',
|
|
3031
|
+
"atlas-margin"
|
|
3032
|
+
), r.getAttribute("atlas-fit") !== "feature" && t(
|
|
3033
|
+
"warning",
|
|
3034
|
+
r,
|
|
3035
|
+
'atlas-margin= has no effect without atlas-fit="feature" — the frame is not refit per page.',
|
|
3036
|
+
'Add atlas-fit="feature" to this frame, or remove atlas-margin.',
|
|
3037
|
+
"atlas-margin"
|
|
3038
|
+
);
|
|
3039
|
+
}
|
|
3040
|
+
for (const i of ["crs", "corners"])
|
|
3041
|
+
r.hasAttribute(i) && t(
|
|
3042
|
+
"warning",
|
|
3043
|
+
r,
|
|
3044
|
+
`${i}= is ignored on a live frame — a live frame takes its projection from the <om-map> it mounts and its corners from that map's camera.`,
|
|
3045
|
+
i === "crs" ? `Put crs= on the frame's <om-map> instead, on an <om-source> if it describes a capture, or set mode="static" for a georeferenced picture placed by corners.` : 'Remove it, put it on the <om-source> whose capture it describes, or set mode="static" if this frame is a georeferenced picture.',
|
|
3046
|
+
i
|
|
2931
3047
|
);
|
|
2932
3048
|
}
|
|
2933
3049
|
}
|
|
2934
|
-
function
|
|
3050
|
+
function fi(r, t) {
|
|
2935
3051
|
const e = r.parentElement;
|
|
2936
3052
|
if (e?.tagName.toLowerCase() !== "om-frame") {
|
|
2937
3053
|
t(
|
|
@@ -2947,7 +3063,7 @@ function ci(r, t) {
|
|
|
2947
3063
|
t("error", r, "<om-source> has no src=.", "Give it a map document (.html) or a capture image.", "src");
|
|
2948
3064
|
return;
|
|
2949
3065
|
}
|
|
2950
|
-
const i =
|
|
3066
|
+
const i = Ft(n);
|
|
2951
3067
|
if (!i) {
|
|
2952
3068
|
t(
|
|
2953
3069
|
"error",
|
|
@@ -2987,7 +3103,7 @@ function Wt(r, t) {
|
|
|
2987
3103
|
const e = r.getAttribute("for");
|
|
2988
3104
|
return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
|
|
2989
3105
|
}
|
|
2990
|
-
function
|
|
3106
|
+
function gi(r, t, e) {
|
|
2991
3107
|
const n = r.getAttribute("derived") !== "false", i = Wt(r, t);
|
|
2992
3108
|
n && i?.getAttribute("mode") === "static" && e(
|
|
2993
3109
|
"warning",
|
|
@@ -2996,9 +3112,9 @@ function ui(r, t, e) {
|
|
|
2996
3112
|
'Write the rows as <om-legend-row color= label= shape=> children and set derived="false".',
|
|
2997
3113
|
"derived"
|
|
2998
3114
|
);
|
|
2999
|
-
const o =
|
|
3115
|
+
const o = ir(r);
|
|
3000
3116
|
if (o.length < 2) return;
|
|
3001
|
-
const s =
|
|
3117
|
+
const s = wr(o.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
|
|
3002
3118
|
if (s.collapses.length > 0 && s.worstType) {
|
|
3003
3119
|
const a = s.collapses.filter((c) => c.type === s.worstType), l = a.slice(0, 3).map((c) => `"${c.a.label}"/"${c.b.label}"`).join(", ");
|
|
3004
3120
|
e(
|
|
@@ -3009,15 +3125,17 @@ function ui(r, t, e) {
|
|
|
3009
3125
|
);
|
|
3010
3126
|
}
|
|
3011
3127
|
}
|
|
3012
|
-
function
|
|
3013
|
-
const n = r.getAttribute("
|
|
3014
|
-
n
|
|
3015
|
-
const i = r.getAttribute("
|
|
3016
|
-
|
|
3017
|
-
|
|
3128
|
+
function pi(r, t, e) {
|
|
3129
|
+
const n = r.getAttribute("pager");
|
|
3130
|
+
n != null && n !== "auto" && n !== "none" && e("warning", r, `pager="${n}" is not a value; the control is drawn as if "auto".`, 'Use pager="none" to remove the on-screen page control, or omit the attribute.', "pager");
|
|
3131
|
+
const i = r.getAttribute("layer");
|
|
3132
|
+
i || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
|
|
3133
|
+
const o = r.getAttribute("for"), s = Wt(r, t);
|
|
3134
|
+
if (!s) {
|
|
3135
|
+
!o && 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");
|
|
3018
3136
|
return;
|
|
3019
3137
|
}
|
|
3020
|
-
if (
|
|
3138
|
+
if (s.getAttribute("mode") === "static") {
|
|
3021
3139
|
e(
|
|
3022
3140
|
"error",
|
|
3023
3141
|
r,
|
|
@@ -3027,34 +3145,34 @@ function hi(r, t, e) {
|
|
|
3027
3145
|
);
|
|
3028
3146
|
return;
|
|
3029
3147
|
}
|
|
3030
|
-
const
|
|
3031
|
-
if (
|
|
3032
|
-
const
|
|
3033
|
-
if (!
|
|
3034
|
-
e("error", r, `Atlas layer "${
|
|
3148
|
+
const a = s.querySelector(":scope > om-map");
|
|
3149
|
+
if (a && i) {
|
|
3150
|
+
const l = [...a.querySelectorAll("om-layer")].find((u) => u.id === i);
|
|
3151
|
+
if (!l) {
|
|
3152
|
+
e("error", r, `Atlas layer "${i}" is not in frame #${s.id}'s map.`, "Check the layer id, or point the atlas at the frame that has it.", "layer");
|
|
3035
3153
|
return;
|
|
3036
3154
|
}
|
|
3037
|
-
const
|
|
3038
|
-
/\{z\}|\{x\}|\{y\}/.test(
|
|
3155
|
+
const c = l.getAttribute("data") ?? "";
|
|
3156
|
+
/\{z\}|\{x\}|\{y\}/.test(c) && e(
|
|
3039
3157
|
"error",
|
|
3040
3158
|
r,
|
|
3041
|
-
`Atlas layer "${
|
|
3159
|
+
`Atlas layer "${i}" is tiled, so its features live on a server rather than in this document.`,
|
|
3042
3160
|
"Iterate a layer whose data is loaded locally (GeoJSON, CSV, inline JSON).",
|
|
3043
3161
|
"layer"
|
|
3044
3162
|
);
|
|
3045
3163
|
}
|
|
3046
3164
|
}
|
|
3047
|
-
function
|
|
3048
|
-
const n =
|
|
3165
|
+
function bi(r, t, e) {
|
|
3166
|
+
const n = K(r, "segment-length");
|
|
3049
3167
|
if (n == null) return;
|
|
3050
3168
|
const i = Wt(r, t);
|
|
3051
3169
|
if (!i) return;
|
|
3052
|
-
const o = H(i.getAttribute("corners")), s =
|
|
3170
|
+
const o = H(i.getAttribute("corners")), s = V(i.getAttribute("crs")), a = C(i);
|
|
3053
3171
|
if (!o || !s || a.w <= 0 || a.h <= 0) return;
|
|
3054
|
-
const l = Q({ corners: o, widthMm: a.w, heightMm: a.h, crsForward: s }), c = C(r), u =
|
|
3172
|
+
const l = Q({ corners: o, widthMm: a.w, heightMm: a.h, crsForward: s }), c = C(r), u = ze({
|
|
3055
3173
|
groundMetersPerMm: l.groundMetersPerMm(),
|
|
3056
3174
|
maxWidthMm: c.w,
|
|
3057
|
-
segments:
|
|
3175
|
+
segments: K(r, "segments") ?? void 0,
|
|
3058
3176
|
segmentLengthMeters: n
|
|
3059
3177
|
});
|
|
3060
3178
|
u && u.totalMm > c.w + 1e-6 && e(
|
|
@@ -3065,9 +3183,9 @@ function mi(r, t, e) {
|
|
|
3065
3183
|
"segment-length"
|
|
3066
3184
|
);
|
|
3067
3185
|
}
|
|
3068
|
-
function
|
|
3186
|
+
function yi(r, t, e) {
|
|
3069
3187
|
const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), o = new Set(t.map((s) => s.id).filter(Boolean));
|
|
3070
|
-
for (const s of
|
|
3188
|
+
for (const s of Dr(n))
|
|
3071
3189
|
if (!s.startsWith("atlas.")) {
|
|
3072
3190
|
if (s.startsWith("frame.")) {
|
|
3073
3191
|
const a = s.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
|
|
@@ -3086,13 +3204,13 @@ function di(r, t, e) {
|
|
|
3086
3204
|
i.has(s) || e("warning", r, `Unknown token {{${s}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
|
|
3087
3205
|
}
|
|
3088
3206
|
}
|
|
3089
|
-
function
|
|
3090
|
-
return
|
|
3207
|
+
function $i(r) {
|
|
3208
|
+
return cr(Er(r));
|
|
3091
3209
|
}
|
|
3092
|
-
async function
|
|
3093
|
-
const t =
|
|
3210
|
+
async function Ei(r) {
|
|
3211
|
+
const t = cr(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
|
|
3094
3212
|
if (e.length === 0) return t;
|
|
3095
|
-
const { loadCore: n } = await Promise.resolve().then(() =>
|
|
3213
|
+
const { loadCore: n } = await Promise.resolve().then(() => mr), i = await n(), o = [...t.errors], s = [...t.warnings];
|
|
3096
3214
|
for (const a of e) {
|
|
3097
3215
|
const l = a.id ? `om-frame#${a.id}` : "om-frame", c = i.validateManifest(a);
|
|
3098
3216
|
for (const u of c.errors) o.push({ ...u, element: `${l} > ${u.element}` });
|
|
@@ -3100,113 +3218,113 @@ async function Si(r) {
|
|
|
3100
3218
|
}
|
|
3101
3219
|
return { valid: o.length === 0, errors: o, warnings: s };
|
|
3102
3220
|
}
|
|
3103
|
-
function
|
|
3104
|
-
k("om-cartograph",
|
|
3221
|
+
function Ni() {
|
|
3222
|
+
k("om-cartograph", He), k("om-text", Ye), k("om-frame", Qe), k("om-scalebar", tr), k("om-north", er), k("om-shape", rr), k("om-image", nr), k("om-legend", sr), k("om-graticule", or), k("om-atlas", ar), k("om-source", ti);
|
|
3105
3223
|
}
|
|
3106
|
-
|
|
3107
|
-
|
|
3224
|
+
Pe(() => import("@nika-js/onlymap"));
|
|
3225
|
+
$r();
|
|
3108
3226
|
export {
|
|
3109
3227
|
T as CARTOGRAPH_ELEMENT_ATTRS,
|
|
3110
3228
|
gt as CARTOGRAPH_FORMAT,
|
|
3111
3229
|
pt as CARTOGRAPH_TAG_NAMES,
|
|
3112
|
-
|
|
3113
|
-
|
|
3230
|
+
wi as CARTOGRAPH_THEMES,
|
|
3231
|
+
yr as COLLAPSE_THRESHOLD,
|
|
3114
3232
|
jt as CVD_MATRICES,
|
|
3115
3233
|
mt as CVD_TYPES,
|
|
3116
|
-
|
|
3234
|
+
pr as CVD_VALUES,
|
|
3117
3235
|
_t as GEOGRAPHIC_PLANE,
|
|
3118
|
-
|
|
3236
|
+
Nr as INERT_RESERVED_CARTOGRAPH_ATTRS,
|
|
3119
3237
|
Fe as MAX_CANVAS_AREA,
|
|
3120
|
-
|
|
3238
|
+
Ie as MAX_CANVAS_DIMENSION,
|
|
3121
3239
|
kt as MAX_CATEGORY_ENTRIES,
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3240
|
+
ar as OmAtlasElement,
|
|
3241
|
+
He as OmCartographElement,
|
|
3242
|
+
Qe as OmFrameElement,
|
|
3243
|
+
or as OmGraticuleElement,
|
|
3244
|
+
nr as OmImageElement,
|
|
3245
|
+
sr as OmLegendElement,
|
|
3246
|
+
er as OmNorthElement,
|
|
3247
|
+
tr as OmScalebarElement,
|
|
3248
|
+
rr as OmShapeElement,
|
|
3249
|
+
Ye as OmTextElement,
|
|
3250
|
+
Kt as PAGE_PRESETS,
|
|
3133
3251
|
te as PAGE_SIZE_NAMES,
|
|
3134
3252
|
j as PLACED_ATTR_NAMES,
|
|
3135
3253
|
D as PX_PER_MM,
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3254
|
+
_r as SCALE_GROUP_SEPARATOR,
|
|
3255
|
+
kr as URL_ACTION_TIMEOUT_MS,
|
|
3256
|
+
Vr as alignOffset,
|
|
3257
|
+
Ke as allFrames,
|
|
3258
|
+
vr as applyCvdToCanvas,
|
|
3259
|
+
jr as applyTokens,
|
|
3260
|
+
xr as applyUrlActions,
|
|
3143
3261
|
Ut as atlasFields,
|
|
3144
|
-
|
|
3262
|
+
xi as boundsArea,
|
|
3145
3263
|
C as boxMm,
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3264
|
+
Fn as buildGraticule,
|
|
3265
|
+
Bn as buildPages,
|
|
3266
|
+
ze as buildScalebar,
|
|
3267
|
+
Fr as buildScalebarDrawing,
|
|
3268
|
+
V as builtinCrsForward,
|
|
3269
|
+
vi as canvasMeasurer,
|
|
3270
|
+
qr as clearUnlinked,
|
|
3271
|
+
Ci as cornersFromBounds,
|
|
3272
|
+
It as cornersFromCamera,
|
|
3155
3273
|
Q as createFrameGeoref,
|
|
3156
|
-
|
|
3157
|
-
|
|
3274
|
+
gr as createZip,
|
|
3275
|
+
Ni as defineCartographElements,
|
|
3158
3276
|
Xt as deltaE00,
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3277
|
+
Tn as deriveLegendRows,
|
|
3278
|
+
Ar as ensureCvdFilters,
|
|
3279
|
+
qn as featureBounds,
|
|
3280
|
+
I as fieldOf,
|
|
3281
|
+
Be as findFrame,
|
|
3282
|
+
Un as formatDms,
|
|
3283
|
+
Or as formatScaleDenominator,
|
|
3284
|
+
$r as installUrlActions,
|
|
3285
|
+
hr as isCoreLoaded,
|
|
3286
|
+
zr as isoDate,
|
|
3287
|
+
Kr as layoutText,
|
|
3288
|
+
wr as lintLegendColours,
|
|
3289
|
+
Te as loadCore,
|
|
3290
|
+
ki as maxGeoreferenceablePitch,
|
|
3291
|
+
Ai as mercatorForward,
|
|
3292
|
+
Mi as mercatorInverse,
|
|
3175
3293
|
Ce as niceInterval,
|
|
3176
|
-
|
|
3294
|
+
je as niceNumberBelow,
|
|
3177
3295
|
Lt as normalizeCrs,
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3296
|
+
hn as northBearingDegrees,
|
|
3297
|
+
We as ownerCartograph,
|
|
3298
|
+
Wn as padBounds,
|
|
3181
3299
|
Bt as paintEnvForDpi,
|
|
3182
|
-
|
|
3300
|
+
br as parseColor,
|
|
3183
3301
|
H as parseCorners,
|
|
3184
|
-
|
|
3302
|
+
Vn as parseSort,
|
|
3185
3303
|
Y as peekCore,
|
|
3186
3304
|
ut as readCamera,
|
|
3187
|
-
|
|
3188
|
-
|
|
3305
|
+
ir as readLiteralRows,
|
|
3306
|
+
In as readOverrides,
|
|
3189
3307
|
O as referencedFrame,
|
|
3190
|
-
|
|
3308
|
+
Gn as rejectionFor,
|
|
3191
3309
|
zt as renderCartograph,
|
|
3192
|
-
|
|
3310
|
+
Oe as renderCartographAtlas,
|
|
3193
3311
|
Rt as resolveCrsForward,
|
|
3194
3312
|
Dt as resolveCvdType,
|
|
3195
|
-
|
|
3313
|
+
Xn as resolveFilenames,
|
|
3196
3314
|
ht as resolvePageSize,
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3315
|
+
Ur as resolveToken,
|
|
3316
|
+
qe as resolveTokens,
|
|
3317
|
+
Pn as rowColorFor,
|
|
3318
|
+
fn as sanitizeAdoptedMap,
|
|
3319
|
+
Yn as sanitizeFilename,
|
|
3320
|
+
mn as scaleVariation,
|
|
3321
|
+
Pe as setCoreLoader,
|
|
3204
3322
|
Ht as simulate,
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3323
|
+
Nn as swatchShapeFor,
|
|
3324
|
+
Dr as tokensIn,
|
|
3325
|
+
Si as utmDef,
|
|
3326
|
+
cr as validateCartograph,
|
|
3327
|
+
Ei as validateCartographDeep,
|
|
3328
|
+
$i as validateCartographString,
|
|
3211
3329
|
Qt as whenPageReady
|
|
3212
3330
|
};
|