@nika-js/onlymap 0.10.4 → 0.10.6
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 +34 -0
- package/README.md +1 -1
- package/dist/{basemap-CEk-fwwQ.js → basemap-Do1r50ff.js} +2 -2
- package/dist/cartograph/elements/om-frame.d.ts +55 -2
- package/dist/cartograph/elements/om-source.d.ts +23 -0
- package/dist/cartograph/frame-sources.d.ts +64 -0
- package/dist/cartograph/live-frame.d.ts +8 -2
- package/dist/cartograph.js +1324 -1126
- package/dist/cartograph.standalone.js +1804 -1606
- package/dist/elements/om-map.d.ts +11 -0
- package/dist/{geoparquet-aBafoHei.js → geoparquet-CfnIgWoq.js} +1 -1
- package/dist/{globe-view-CPzn74yH.js → globe-view-CKrjE2_P.js} +1 -1
- package/dist/{hillshade-fonIyeOe.js → hillshade-DYX4HiM6.js} +1 -1
- package/dist/{index-6uyOjvvx.js → index-CLwi0tl1.js} +1 -1
- package/dist/{index-XlX-ORox.js → index-Cr2lpzhG.js} +9673 -9611
- package/dist/{index-CW9LiA0Z.js → index-D7pGwN4r.js} +2 -2
- package/dist/{index-CIiSsOZG.js → index-DfH_mTX9.js} +1 -1
- package/dist/{index-BOXzqzVq.js → index-DwX39Hco.js} +1 -1
- package/dist/{index-BYOHopZU.js → index-jOAZ7MGr.js} +1 -1
- package/dist/{index-irwJUTjX.js → index-pNSDUva1.js} +1 -1
- package/dist/{index-BlwNB2Fo.js → index-q_KoQjsU.js} +3 -3
- package/dist/{index-FP1-ImsV.js → index-xTIB8sjz.js} +3 -3
- package/dist/legend-spec.d.ts +18 -0
- package/dist/{lerc-B_m7L7RH.js → lerc-DIXeSlBh.js} +1 -1
- package/dist/onlymap.standalone.js +18707 -18590
- package/dist/onlymapjs.js +1 -1
- package/dist/{post-process-effect-D-uTiLdK.js → post-process-effect-BSBhBXeu.js} +1 -1
- package/dist/{raster-D3o26cuQ.js → raster-mlOu3P2H.js} +3 -3
- package/dist/{raster-pipeline-1u0HyuNs.js → raster-pipeline-ByRr7hBG.js} +1 -1
- package/dist/runtime-core.d.ts +19 -0
- package/dist/text-on-path-Q0dF8039.js +201 -0
- package/dist/text-on-path.d.ts +51 -11
- package/dist/version.d.ts +1 -1
- package/dist/{zarr-CVVmWsbf.js → zarr-D6-cCHW4.js} +2 -2
- package/docs/cartograph.md +49 -3
- package/docs/design/carto-substrate.md +12 -0
- package/docs/design/frame-sources.md +229 -0
- package/llms.txt +2 -2
- package/onlymapjs.attributes.json +2 -0
- package/onlymapjs.html-data.json +36 -0
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +3 -2
- package/skills/onlymapjs/references/syntax.md +16 -2
- package/dist/text-on-path-DCS_Eg0_.js +0 -146
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { c as S, a3 as b } from "./index-XlX-ORox.js";
|
|
2
|
-
const A = Math.PI / 180, P = /* @__PURE__ */ new Map();
|
|
3
|
-
let d = null;
|
|
4
|
-
function T(t) {
|
|
5
|
-
if (typeof document > "u") return null;
|
|
6
|
-
if (!d) {
|
|
7
|
-
const r = document.createElement("canvas");
|
|
8
|
-
r.width = 8, r.height = 8, d = r.getContext("2d");
|
|
9
|
-
}
|
|
10
|
-
return d && (d.font = t), d;
|
|
11
|
-
}
|
|
12
|
-
function C(t, r, e) {
|
|
13
|
-
const n = `${e} 100px ${r}`;
|
|
14
|
-
let s = P.get(n);
|
|
15
|
-
s || (s = /* @__PURE__ */ new Map(), P.set(n, s));
|
|
16
|
-
const c = s.get(t);
|
|
17
|
-
if (c !== void 0) return c;
|
|
18
|
-
const l = T(n), a = l ? l.measureText(t).width / 100 : 0.6;
|
|
19
|
-
return s.set(t, a), a;
|
|
20
|
-
}
|
|
21
|
-
function L(t) {
|
|
22
|
-
const r = [0];
|
|
23
|
-
let e = 0;
|
|
24
|
-
for (let n = 1; n < t.length; n++)
|
|
25
|
-
e += Math.hypot(t[n][0] - t[n - 1][0], t[n][1] - t[n - 1][1]), r.push(e);
|
|
26
|
-
return { cumulative: r, total: e };
|
|
27
|
-
}
|
|
28
|
-
function x(t, r, e) {
|
|
29
|
-
const { cumulative: n } = r;
|
|
30
|
-
if (t.length < 2) return null;
|
|
31
|
-
let s = 1;
|
|
32
|
-
for (; s < n.length - 1 && n[s] < e; ) s++;
|
|
33
|
-
const c = n[s] - n[s - 1], l = c > 0 ? (e - n[s - 1]) / c : 0, a = t[s - 1], o = t[s];
|
|
34
|
-
return {
|
|
35
|
-
position: [a[0] + (o[0] - a[0]) * l, a[1] + (o[1] - a[1]) * l],
|
|
36
|
-
angle: Math.atan2(-(o[1] - a[1]), o[0] - a[0]) * 180 / Math.PI
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function M(t, r, e) {
|
|
40
|
-
if (e === 0) return t;
|
|
41
|
-
const n = (r + 90) * A;
|
|
42
|
-
return [t[0] + Math.cos(n) * e, t[1] - Math.sin(n) * e];
|
|
43
|
-
}
|
|
44
|
-
function z(t) {
|
|
45
|
-
return t === "start" ? "end" : t === "end" ? "start" : "middle";
|
|
46
|
-
}
|
|
47
|
-
function w(t, r, e) {
|
|
48
|
-
if (t.length < 2 || !r) return [];
|
|
49
|
-
const n = L(t);
|
|
50
|
-
if (!(n.total > 0)) return [];
|
|
51
|
-
const s = [...r], c = s.map((i) => C(i, e.fontFamily, e.fontWeight) * e.sizePx + e.letterSpacing), l = c.reduce((i, u) => i + u, 0) - e.letterSpacing;
|
|
52
|
-
if (l > n.total) return [];
|
|
53
|
-
const a = n.total - l, o = e.placement === "start" ? 0 : e.placement === "end" ? a : a / 2, g = x(t, n, o), h = x(t, n, o + l);
|
|
54
|
-
if (g && h && h.position[0] < g.position[0]) {
|
|
55
|
-
const i = [...t].reverse();
|
|
56
|
-
return w(i, r, { ...e, placement: z(e.placement), offsetPx: -e.offsetPx });
|
|
57
|
-
}
|
|
58
|
-
let p = o;
|
|
59
|
-
const m = [];
|
|
60
|
-
for (let i = 0; i < s.length; i++) {
|
|
61
|
-
const u = x(t, n, p + (c[i] - e.letterSpacing) / 2);
|
|
62
|
-
if (!u) break;
|
|
63
|
-
m.push({ position: M(u.position, u.angle, e.offsetPx), angle: u.angle, char: s[i] }), p += c[i];
|
|
64
|
-
}
|
|
65
|
-
return m;
|
|
66
|
-
}
|
|
67
|
-
function y(t, r, e, n, s) {
|
|
68
|
-
if (typeof t != "function") return t ?? s;
|
|
69
|
-
try {
|
|
70
|
-
return t(r, { index: e, data: n });
|
|
71
|
-
} catch {
|
|
72
|
-
return s;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
class O extends S {
|
|
76
|
-
static layerName = "OmTextOnPathLayer";
|
|
77
|
-
static defaultProps = {
|
|
78
|
-
getPath: { type: "accessor", value: (r) => r.path },
|
|
79
|
-
getText: { type: "accessor", value: (r) => r.text },
|
|
80
|
-
getSize: { type: "accessor", value: 14 },
|
|
81
|
-
getColor: { type: "accessor", value: [30, 30, 30, 255] },
|
|
82
|
-
fontFamily: { type: "string", value: "sans-serif" },
|
|
83
|
-
fontWeight: { type: "string", value: "normal" },
|
|
84
|
-
letterSpacing: { type: "number", value: 0 },
|
|
85
|
-
offset: { type: "number", value: 0 },
|
|
86
|
-
placement: { type: "string", value: "middle" },
|
|
87
|
-
maxLabels: { type: "number", value: 2e3 }
|
|
88
|
-
};
|
|
89
|
-
/** Recompute on a viewport change: a glyph advance is pixels and a path is world distance. */
|
|
90
|
-
shouldUpdateState({ changeFlags: r }) {
|
|
91
|
-
return !!r.somethingChanged;
|
|
92
|
-
}
|
|
93
|
-
renderLayers() {
|
|
94
|
-
const r = this.context.viewport;
|
|
95
|
-
if (!r || !r.width) return null;
|
|
96
|
-
const e = Array.isArray(this.props.data) ? this.props.data : [], n = ["start", "middle", "end"].includes(this.props.placement) ? this.props.placement : "middle", s = this.props.fontFamily ?? "sans-serif", c = this.props.fontWeight ?? "normal", l = this.props.maxLabels ?? 2e3, a = [];
|
|
97
|
-
for (let o = 0; o < e.length && a.length < l; o++) {
|
|
98
|
-
const g = e[o], h = y(this.props.getPath, g, o, e, void 0), p = String(y(this.props.getText, g, o, e, "") ?? "");
|
|
99
|
-
if (!Array.isArray(h) || h.length < 2 || !p) continue;
|
|
100
|
-
const m = Number(y(this.props.getSize, g, o, e, 14)) || 14, i = y(this.props.getColor, g, o, e, [30, 30, 30, 255]), u = h.map((f) => r.project([f[0], f[1]]).slice(0, 2));
|
|
101
|
-
for (const f of w(u, p, {
|
|
102
|
-
fontFamily: s,
|
|
103
|
-
fontWeight: c,
|
|
104
|
-
sizePx: m,
|
|
105
|
-
letterSpacing: this.props.letterSpacing ?? 0,
|
|
106
|
-
offsetPx: this.props.offset ?? 0,
|
|
107
|
-
placement: n
|
|
108
|
-
})) {
|
|
109
|
-
const v = r.unproject([f.position[0], f.position[1]]);
|
|
110
|
-
if (a.push({
|
|
111
|
-
char: f.char,
|
|
112
|
-
position: [v[0], v[1]],
|
|
113
|
-
angle: f.angle,
|
|
114
|
-
size: m,
|
|
115
|
-
color: Array.isArray(i) ? i : [30, 30, 30, 255]
|
|
116
|
-
}), a.length >= l) break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return a.length === 0 ? null : new b(
|
|
120
|
-
this.getSubLayerProps({ id: "glyphs" }),
|
|
121
|
-
{
|
|
122
|
-
data: a,
|
|
123
|
-
getText: (o) => o.char,
|
|
124
|
-
getPosition: (o) => o.position,
|
|
125
|
-
getAngle: (o) => o.angle,
|
|
126
|
-
getSize: (o) => o.size,
|
|
127
|
-
getColor: (o) => o.color,
|
|
128
|
-
fontFamily: s,
|
|
129
|
-
fontWeight: c,
|
|
130
|
-
getTextAnchor: "middle",
|
|
131
|
-
getAlignmentBaseline: "center",
|
|
132
|
-
characterSet: "auto",
|
|
133
|
-
// Every glyph is its own instance, so deck's own collision would fight
|
|
134
|
-
// the word it belongs to. The whole label is placed or dropped.
|
|
135
|
-
updateTriggers: { getText: a.length, getPosition: a.length }
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
export {
|
|
141
|
-
O as OmTextOnPathLayer,
|
|
142
|
-
C as charAdvance,
|
|
143
|
-
L as pathMetrics,
|
|
144
|
-
w as placeTextOnPath,
|
|
145
|
-
x as pointAtDistance
|
|
146
|
-
};
|