@nika-js/onlymap 0.10.3 → 0.10.5

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{basemap-BXj6TyI0.js → basemap-Q-Hd5jE-.js} +2 -2
  3. package/dist/{geoparquet-3uljKWBk.js → geoparquet-mtTpzfNU.js} +1 -1
  4. package/dist/{globe-view-SiqJKyZ3.js → globe-view-D6a6_ADT.js} +1 -1
  5. package/dist/{hillshade-DSVos950.js → hillshade-CY4PNGum.js} +1 -1
  6. package/dist/{index-CON8tYgk.js → index--Zswyzcw.js} +1 -1
  7. package/dist/{index-BmhZ-nHJ.js → index-4z9qUdmz.js} +1 -1
  8. package/dist/{index-BrdfEKdd.js → index-BhH8ySRp.js} +3 -3
  9. package/dist/{index-Bkz-w1s4.js → index-BwOC7qcd.js} +1 -1
  10. package/dist/{index-DScatzxZ.js → index-D6jtcTK4.js} +3 -3
  11. package/dist/{index-CaspQb0d.js → index-DUJtvAv2.js} +2 -2
  12. package/dist/{index-fdxfxPzR.js → index-DwIUeLzW.js} +1 -1
  13. package/dist/{index-BsqaPPAj.js → index-V-VuBp7C.js} +1 -1
  14. package/dist/{index-D3uUtM40.js → index-yJEyQjKn.js} +11048 -11016
  15. package/dist/legend-spec.d.ts +18 -0
  16. package/dist/{lerc-CDT_Q_Ki.js → lerc-BdO3Bk6b.js} +1 -1
  17. package/dist/onlymap.standalone.js +20861 -20774
  18. package/dist/onlymapjs.js +1 -1
  19. package/dist/plane-layers.d.ts +22 -0
  20. package/dist/{post-process-effect-CjGvim4U.js → post-process-effect-DqteD0Gr.js} +1 -1
  21. package/dist/{raster-BkCit2hH.js → raster-3YBp5u4H.js} +3 -3
  22. package/dist/{raster-pipeline-BvIx-poy.js → raster-pipeline-P1v9_jgU.js} +1 -1
  23. package/dist/text-on-path-DMUvpyS-.js +201 -0
  24. package/dist/text-on-path.d.ts +51 -11
  25. package/dist/version.d.ts +1 -1
  26. package/dist/{zarr-HSWSwGfd.js → zarr-CldzO0mP.js} +2 -2
  27. package/docs/cartograph.md +2 -2
  28. package/llms.txt +1 -1
  29. package/onlymapjs.attributes.json +2 -0
  30. package/onlymapjs.html-data.json +8 -0
  31. package/package.json +1 -1
  32. package/skills/onlymapjs/SKILL.md +1 -1
  33. package/skills/onlymapjs/references/syntax.md +5 -2
  34. package/dist/text-on-path-DTAVhz00.js +0 -146
@@ -1,146 +0,0 @@
1
- import { c as S, a3 as b } from "./index-D3uUtM40.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
- };