@thibezer/ui-components-kit 2.31.2 → 2.32.0
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 +1329 -1302
- package/dist/camadas.cjs +8 -8
- package/dist/camadas.js +1 -1
- package/dist/canvas.cjs +57 -57
- package/dist/canvas.js +1127 -1082
- package/dist/components/ui-canvas-cad/cad-feicoes-operacoes.d.ts +6 -0
- package/dist/components/ui-canvas-cad/cad-feicoes.d.ts +5 -0
- package/dist/components/ui-canvas-cad/ui-canvas-cad.d.ts +5 -0
- package/dist/custom-elements.json +35126 -34994
- package/dist/feature_caixa-BRZGJHTG.cjs +1 -0
- package/dist/feature_caixa-DdI35r81.js +929 -0
- package/dist/{feature_desenho-fQfbVPvn.js → feature_desenho-BSuO-kdG.js} +1 -1
- package/dist/{feature_desenho-CESNXi8g.cjs → feature_desenho-BcvJt7r_.cjs} +1 -1
- package/dist/feedback.cjs +2 -2
- package/dist/feedback.js +6 -6
- package/dist/gerencigeo-canvas/feature_algoritmos.d.ts +10 -0
- package/dist/gerencigeo-canvas/feature_hud.d.ts +14 -0
- package/dist/prancha-nucleo.cjs +1 -1
- package/dist/prancha-nucleo.js +2 -2
- package/dist/prancha.cjs +1 -1
- package/dist/prancha.js +2 -2
- package/package.json +1 -1
- package/dist/feature_caixa-DAyED81R.cjs +0 -1
- package/dist/feature_caixa-zoUAn0qg.js +0 -877
|
@@ -0,0 +1,929 @@
|
|
|
1
|
+
var Pt = Object.defineProperty;
|
|
2
|
+
var Mt = (t, n, o) => n in t ? Pt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[n] = o;
|
|
3
|
+
var X = (t, n, o) => Mt(t, typeof n != "symbol" ? n + "" : n, o);
|
|
4
|
+
import { e as Lt, m as q, a as xt, c as vt, d as St, b as At, p as G, f as H } from "./feature_metricas-hUren6kK.js";
|
|
5
|
+
import { m as Z, b as U, e as Ct, a as bt, c as W, p as ft } from "./geometria-px-wXudjSxA.js";
|
|
6
|
+
const It = 111320;
|
|
7
|
+
function Et(t) {
|
|
8
|
+
const { lat: n, lng: o } = q(t[0]), e = t[0], r = t[1], s = n, a = Math.max(o, 1);
|
|
9
|
+
return {
|
|
10
|
+
paraXY: (c) => [(c[1] - r) * a, (c[0] - e) * s],
|
|
11
|
+
deXY: (c) => [e + c[1] / s, r + c[0] / a]
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const I = Object.freeze({
|
|
15
|
+
tipo: "geografico",
|
|
16
|
+
unidade: "m",
|
|
17
|
+
distancia: (t, n) => St(t, n),
|
|
18
|
+
comprimento: (t, n = !1) => vt(t, n),
|
|
19
|
+
area: (t) => xt(t),
|
|
20
|
+
planoLocal: Et,
|
|
21
|
+
deslocar(t, n, o) {
|
|
22
|
+
const e = q(t[0]), r = o / e.lat, s = n / Math.max(e.lng, 1);
|
|
23
|
+
return [t[0] + r, t[1] + s];
|
|
24
|
+
},
|
|
25
|
+
pontoDaBorda(t, n) {
|
|
26
|
+
return [t[0], t[1] + n / Math.max(q(t[0]).lng, 1)];
|
|
27
|
+
},
|
|
28
|
+
pontoDeMedidaDoRaio: (t, n) => [t[0] + n / It, t[1]],
|
|
29
|
+
extremosDoCirculo: Lt,
|
|
30
|
+
fatorEixo: (t) => Math.cos(t[0] * Math.PI / 180) || 1
|
|
31
|
+
});
|
|
32
|
+
function Nt(t, n) {
|
|
33
|
+
const o = (e) => {
|
|
34
|
+
let r = !1;
|
|
35
|
+
for (let s = 0, a = e.length - 1; s < e.length; a = s++) {
|
|
36
|
+
const [c, u] = e[s], [f, l] = e[a];
|
|
37
|
+
c > t[0] != f > t[0] && t[1] < (l - u) * (t[0] - c) / (f - c) + u && (r = !r);
|
|
38
|
+
}
|
|
39
|
+
return r;
|
|
40
|
+
};
|
|
41
|
+
return !n[0] || !o(n[0]) ? !1 : !n.slice(1).some(o);
|
|
42
|
+
}
|
|
43
|
+
function ht(t, n, o, e) {
|
|
44
|
+
const r = n[0] - t[0], s = n[1] - t[1], a = e[0] - o[0], c = e[1] - o[1], u = r * c - s * a;
|
|
45
|
+
if (Math.abs(u) < 1e-12) return null;
|
|
46
|
+
const f = ((o[0] - t[0]) * c - (o[1] - t[1]) * a) / u, l = ((o[0] - t[0]) * s - (o[1] - t[1]) * r) / u;
|
|
47
|
+
return f < 0 || f > 1 || l < 0 || l >= 1 ? null : { t: f, u: l };
|
|
48
|
+
}
|
|
49
|
+
function B(t) {
|
|
50
|
+
let n = 0;
|
|
51
|
+
for (let o = 0; o < t.length; o++) {
|
|
52
|
+
const [e, r] = t[o], [s, a] = t[(o + 1) % t.length];
|
|
53
|
+
n += e * a - s * r;
|
|
54
|
+
}
|
|
55
|
+
return Math.abs(n) / 2;
|
|
56
|
+
}
|
|
57
|
+
function nn(t, n, o = I) {
|
|
58
|
+
if (t.length < 3 || n.length < 2) return null;
|
|
59
|
+
const e = o.planoLocal(t[0]), r = N(t, e), s = N(n, e), a = pt(r, s, 0);
|
|
60
|
+
return a && a.length >= 2 ? a.map((c) => k(c, e)) : null;
|
|
61
|
+
}
|
|
62
|
+
function pt(t, n, o) {
|
|
63
|
+
if (o > 8) return null;
|
|
64
|
+
const e = t.length, r = [];
|
|
65
|
+
for (let m = 0; m < n.length - 1; m++)
|
|
66
|
+
for (let L = 0; L < e; L++) {
|
|
67
|
+
const x = ht(n[m], n[m + 1], t[L], t[(L + 1) % e]);
|
|
68
|
+
x && r.push({
|
|
69
|
+
tLinha: m + x.t,
|
|
70
|
+
tAnel: L + x.u,
|
|
71
|
+
ponto: [n[m][0] + x.t * (n[m + 1][0] - n[m][0]), n[m][1] + x.t * (n[m + 1][1] - n[m][1])]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (r.sort((m, L) => m.tLinha - L.tLinha), r.length < 2) return null;
|
|
75
|
+
const [s, a] = r, c = [];
|
|
76
|
+
for (let m = Math.floor(s.tLinha) + 1; m <= Math.floor(a.tLinha); m++)
|
|
77
|
+
m > s.tLinha && m < a.tLinha && c.push(n[m]);
|
|
78
|
+
const u = [s.ponto, ...c, a.ponto];
|
|
79
|
+
let f = s, l = a, i = u;
|
|
80
|
+
s.tAnel > a.tAnel && (f = a, l = s, i = [...u].reverse());
|
|
81
|
+
const h = Math.floor(f.tAnel), p = Math.floor(l.tAnel), y = i.slice(1, -1), g = [f.ponto];
|
|
82
|
+
for (let m = h + 1; m <= p; m++) g.push(t[m % e]);
|
|
83
|
+
g.push(l.ponto, ...[...y].reverse());
|
|
84
|
+
const P = [l.ponto];
|
|
85
|
+
for (let m = p + 1; m <= h + e; m++) P.push(t[m % e]);
|
|
86
|
+
P.push(f.ponto, ...y);
|
|
87
|
+
const A = B(t) * 1e-9, v = [g, P].filter((m) => m.length >= 3 && B(m) > A);
|
|
88
|
+
if (v.length < 2) return null;
|
|
89
|
+
const d = [a.ponto, ...n.slice(Math.floor(a.tLinha) + 1)];
|
|
90
|
+
if (r.length > 2 && d.length >= 2) {
|
|
91
|
+
const m = [];
|
|
92
|
+
for (const L of v) {
|
|
93
|
+
const x = pt(L, d, o + 1);
|
|
94
|
+
x ? m.push(...x) : m.push(L);
|
|
95
|
+
}
|
|
96
|
+
return m;
|
|
97
|
+
}
|
|
98
|
+
return v;
|
|
99
|
+
}
|
|
100
|
+
function N(t, n) {
|
|
101
|
+
return t.map((o) => n.paraXY(o));
|
|
102
|
+
}
|
|
103
|
+
function k(t, n) {
|
|
104
|
+
return t.map((o) => n.deXY(o));
|
|
105
|
+
}
|
|
106
|
+
const b = (t, n) => Math.hypot(t[0] - n[0], t[1] - n[1]);
|
|
107
|
+
function on(t, n = 0, o = I) {
|
|
108
|
+
if (t.length === 0 || t.some((a) => a.length < 2)) return null;
|
|
109
|
+
const e = o.planoLocal(t[0][0]), r = t.slice(1).map((a) => N(a, e));
|
|
110
|
+
let s = N(t[0], e);
|
|
111
|
+
for (; r.length > 0; ) {
|
|
112
|
+
let a = null;
|
|
113
|
+
if (r.forEach((i, h) => {
|
|
114
|
+
const p = s[0], y = s[s.length - 1], g = [
|
|
115
|
+
{ inverter: !1, noFim: !0, d: b(y, i[0]) },
|
|
116
|
+
{ inverter: !0, noFim: !0, d: b(y, i[i.length - 1]) },
|
|
117
|
+
{ inverter: !1, noFim: !1, d: b(p, i[i.length - 1]) },
|
|
118
|
+
{ inverter: !0, noFim: !1, d: b(p, i[0]) }
|
|
119
|
+
];
|
|
120
|
+
for (const P of g) (!a || P.d < a.d) && (a = { idx: h, ...P });
|
|
121
|
+
}), !a || a.d > n) return null;
|
|
122
|
+
const { idx: c, inverter: u, noFim: f } = a;
|
|
123
|
+
let l = r.splice(c, 1)[0];
|
|
124
|
+
u && (l = [...l].reverse()), s = f ? [...s, ...b(s[s.length - 1], l[0]) > 0 ? l : l.slice(1)] : [...l, ...b(l[l.length - 1], s[0]) > 0 ? s : s.slice(1)];
|
|
125
|
+
}
|
|
126
|
+
return k(s, e);
|
|
127
|
+
}
|
|
128
|
+
function Ot(t, n, o, e) {
|
|
129
|
+
const r = ht(t, n, o, e);
|
|
130
|
+
return !!r && r.t > 1e-9 && r.t < 1 - 1e-9 && r.u > 1e-9;
|
|
131
|
+
}
|
|
132
|
+
function Tt(t, n) {
|
|
133
|
+
for (let o = 0; o < t.length; o++)
|
|
134
|
+
for (let e = 0; e < n.length; e++)
|
|
135
|
+
if (Ot(t[o], t[(o + 1) % t.length], n[e], n[(e + 1) % n.length])) return !0;
|
|
136
|
+
return !1;
|
|
137
|
+
}
|
|
138
|
+
function en(t, n, o = 0, e = I) {
|
|
139
|
+
if (t.length < 3 || n.length < 3) return null;
|
|
140
|
+
const r = e.planoLocal(t[0]), s = N(t, r), a = N(n, r);
|
|
141
|
+
if (Tt(s, a)) return null;
|
|
142
|
+
let c = { i: 0, j: 0, d: 1 / 0 };
|
|
143
|
+
for (let i = 0; i < s.length; i++)
|
|
144
|
+
for (let h = 0; h < a.length; h++) {
|
|
145
|
+
const p = b(s[i], a[h]);
|
|
146
|
+
p < c.d && (c = { i, j: h, d: p });
|
|
147
|
+
}
|
|
148
|
+
if (c.d > o) return null;
|
|
149
|
+
const { i: u, j: f } = c, l = [];
|
|
150
|
+
for (let i = 0; i <= s.length; i++) l.push(s[(u + i) % s.length]);
|
|
151
|
+
for (let i = 0; i <= a.length; i++) l.push(a[(f + i) % a.length]);
|
|
152
|
+
return k(l, r);
|
|
153
|
+
}
|
|
154
|
+
const $ = 16;
|
|
155
|
+
function tt(t, n, o, e) {
|
|
156
|
+
const r = [];
|
|
157
|
+
for (let s = 0; s <= $; s++) {
|
|
158
|
+
const a = o + (e - o) * s / $;
|
|
159
|
+
r.push([t[0] + n * Math.cos(a), t[1] + n * Math.sin(a)]);
|
|
160
|
+
}
|
|
161
|
+
return r;
|
|
162
|
+
}
|
|
163
|
+
function V(t, n) {
|
|
164
|
+
const o = b(t, n) || 1;
|
|
165
|
+
return [-(n[1] - t[1]) / o, (n[0] - t[0]) / o];
|
|
166
|
+
}
|
|
167
|
+
function J(t, n, o) {
|
|
168
|
+
const e = t.length, r = [], s = e;
|
|
169
|
+
for (let a = 0; a < s; a++) {
|
|
170
|
+
const c = o ? t[(a - 1 + e) % e] : t[Math.max(0, a - 1)], u = t[a], f = o ? t[(a + 1) % e] : t[Math.min(e - 1, a + 1)], l = a === 0 && !o ? V(u, f) : V(c, u), i = a === e - 1 && !o ? V(c, u) : V(u, f);
|
|
171
|
+
let h = l[0] + i[0], p = l[1] + i[1];
|
|
172
|
+
const y = Math.hypot(h, p);
|
|
173
|
+
if (y < 1e-9) {
|
|
174
|
+
r.push([u[0] + l[0] * n, u[1] + l[1] * n]);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
h /= y, p /= y;
|
|
178
|
+
const g = h * l[0] + p * l[1], P = Math.min(1 / Math.max(g, 0.5), 2);
|
|
179
|
+
r.push([u[0] + h * n * P, u[1] + p * n * P]);
|
|
180
|
+
}
|
|
181
|
+
return r;
|
|
182
|
+
}
|
|
183
|
+
function mt(t) {
|
|
184
|
+
let n = 0;
|
|
185
|
+
for (let o = 0; o < t.length; o++) {
|
|
186
|
+
const [e, r] = t[o], [s, a] = t[(o + 1) % t.length];
|
|
187
|
+
n += (s - e) * (a + r);
|
|
188
|
+
}
|
|
189
|
+
return n > 0;
|
|
190
|
+
}
|
|
191
|
+
function rn(t, n, o = I) {
|
|
192
|
+
if (!Number.isFinite(n) || n === 0) return null;
|
|
193
|
+
if (t.tipo === "Point" || t.tipo === "Text" || t.tipo === "Circle") {
|
|
194
|
+
const e = t.tipo === "Circle" ? t.centro : t.coordenada, r = t.tipo === "Circle" ? t.raioMetros + n : n;
|
|
195
|
+
if (r <= 0) return null;
|
|
196
|
+
const s = o.planoLocal(e), a = 64;
|
|
197
|
+
return Array.from({ length: a }, (c, u) => [r * Math.cos(2 * Math.PI * u / a), r * Math.sin(2 * Math.PI * u / a)]).map((c) => s.deXY(c));
|
|
198
|
+
}
|
|
199
|
+
if (t.tipo === "LineString") {
|
|
200
|
+
if (n < 0 || t.coordenadas.length < 2 || H(t)) return null;
|
|
201
|
+
const e = o.planoLocal(t.coordenadas[0]), r = N(t.coordenadas, e), s = J(r, n, !1), a = J([...r].reverse(), n, !1), c = r[r.length - 1], u = r[0], f = Math.atan2(c[1] - r[r.length - 2][1], c[0] - r[r.length - 2][0]), l = Math.atan2(u[1] - r[1][1], u[0] - r[1][0]), i = tt(c, n, f + Math.PI / 2, f - Math.PI / 2), h = tt(u, n, l + Math.PI / 2, l - Math.PI / 2);
|
|
202
|
+
return k([...s, ...i, ...a, ...h], e);
|
|
203
|
+
}
|
|
204
|
+
if (t.tipo === "Polygon") {
|
|
205
|
+
const e = t.aneis[0];
|
|
206
|
+
if (!e || e.length < 3) return null;
|
|
207
|
+
const r = o.planoLocal(e[0]);
|
|
208
|
+
let s = N(e, r);
|
|
209
|
+
mt(s) && (s = [...s].reverse());
|
|
210
|
+
const c = J(s, -n, !0);
|
|
211
|
+
return c.length < 3 || n < 0 && B(c) >= B(s) ? null : k(c, r);
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
function nt(t, n, o, e) {
|
|
216
|
+
if (t.some((i) => !Number.isFinite(i[0]) || !Number.isFinite(i[1]))) return null;
|
|
217
|
+
const r = t.filter((i, h) => h === 0 || b(i, t[h - 1]) >= 1e-9);
|
|
218
|
+
e && r.length > 1 && b(r[0], r[r.length - 1]) < 1e-9 && r.pop();
|
|
219
|
+
const s = r.length;
|
|
220
|
+
if (s < (e ? 3 : 2)) return null;
|
|
221
|
+
const a = o === "esquerda" ? 1 : -1, c = e ? s : s - 1, u = [];
|
|
222
|
+
for (let i = 0; i < c; i++) {
|
|
223
|
+
const h = r[i], p = r[(i + 1) % s], y = b(h, p);
|
|
224
|
+
if (!Number.isFinite(y) || y < 1e-9) return null;
|
|
225
|
+
const g = -(p[1] - h[1]) / y * n * a, P = (p[0] - h[0]) / y * n * a;
|
|
226
|
+
u.push([[h[0] + g, h[1] + P], [p[0] + g, p[1] + P]]);
|
|
227
|
+
}
|
|
228
|
+
const f = (i, h, p) => {
|
|
229
|
+
const y = () => [(i[1][0] + h[0][0]) / 2, (i[1][1] + h[0][1]) / 2], g = b(i[0], i[1]), P = b(h[0], h[1]), M = i[1][0] - i[0][0], A = i[1][1] - i[0][1], v = h[1][0] - h[0][0], d = h[1][1] - h[0][1], m = M * d - A * v;
|
|
230
|
+
if (Math.abs(m) < 1e-12 || Math.asin(Math.min(1, Math.abs(m) / (g * P))) * (180 / Math.PI) < 1) return y();
|
|
231
|
+
const L = ((h[0][0] - i[0][0]) * d - (h[0][1] - i[0][1]) * v) / m, x = [i[0][0] + L * M, i[0][1] + L * A];
|
|
232
|
+
return b(x, p) > Math.max(2.5 * Math.abs(n), 1) ? y() : x;
|
|
233
|
+
}, l = [];
|
|
234
|
+
if (e)
|
|
235
|
+
for (let i = 0; i < s; i++) l.push(f(u[(i - 1 + s) % s], u[i], r[i]));
|
|
236
|
+
else {
|
|
237
|
+
l.push(u[0][0]);
|
|
238
|
+
for (let i = 1; i < s - 1; i++) l.push(f(u[i - 1], u[i], r[i]));
|
|
239
|
+
l.push(u[c - 1][1]);
|
|
240
|
+
}
|
|
241
|
+
if (e)
|
|
242
|
+
for (let i = 0; i < s; i++) {
|
|
243
|
+
const h = r[i], p = r[(i + 1) % s], y = l[i], g = l[(i + 1) % s];
|
|
244
|
+
if ((p[0] - h[0]) * (g[0] - y[0]) + (p[1] - h[1]) * (g[1] - y[1]) <= 0) return null;
|
|
245
|
+
}
|
|
246
|
+
return l;
|
|
247
|
+
}
|
|
248
|
+
function sn(t, n, o, e = I) {
|
|
249
|
+
if (!Number.isFinite(n) || n <= 0) return null;
|
|
250
|
+
if (t.tipo === "LineString") {
|
|
251
|
+
if (H(t) || t.coordenadas.length < 2) return null;
|
|
252
|
+
const r = e.planoLocal(t.coordenadas[0]), s = nt(N(t.coordenadas, r), n, o, !1);
|
|
253
|
+
return s ? { tipo: "LineString", coordenadas: k(s, r) } : null;
|
|
254
|
+
}
|
|
255
|
+
if (t.tipo === "Polygon") {
|
|
256
|
+
const r = t.aneis[0];
|
|
257
|
+
if (!r || r.length < 3 || t.aneis.length > 1) return null;
|
|
258
|
+
const s = e.planoLocal(r[0]);
|
|
259
|
+
let a = N(r, s);
|
|
260
|
+
mt(a) && (a = [...a].reverse());
|
|
261
|
+
const c = nt(a, n, o, !0);
|
|
262
|
+
return c ? { tipo: "Polygon", aneis: [k(c, s)] } : null;
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
function an(t, n, o, e = I) {
|
|
267
|
+
const r = (s) => e.deslocar(s, n, o);
|
|
268
|
+
switch (t.tipo) {
|
|
269
|
+
case "Point":
|
|
270
|
+
return { tipo: "Point", coordenada: r(t.coordenada) };
|
|
271
|
+
case "Text":
|
|
272
|
+
return { ...t, coordenada: r(t.coordenada) };
|
|
273
|
+
case "Circle":
|
|
274
|
+
return { ...t, centro: r(t.centro) };
|
|
275
|
+
case "LineString": {
|
|
276
|
+
const s = At(G(t).map((a) => a.map(r)));
|
|
277
|
+
return t.curva ? { ...s, curva: Z(t.curva, r) } : s;
|
|
278
|
+
}
|
|
279
|
+
case "Polygon": {
|
|
280
|
+
const s = { tipo: "Polygon", aneis: t.aneis.map((a) => a.map(r)) };
|
|
281
|
+
return t.curva ? { ...s, curva: Z(t.curva, r) } : s;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const ot = { m: 1, km: 1e3, ft: 0.3048, mi: 1609.344 }, et = { m2: 1, ha: 1e4, km2: 1e6, ac: 4046.8564224, alqueire: 24200 };
|
|
286
|
+
function cn(t, n, o) {
|
|
287
|
+
return t * ot[n] / ot[o];
|
|
288
|
+
}
|
|
289
|
+
function ln(t, n, o) {
|
|
290
|
+
return t * et[n] / et[o];
|
|
291
|
+
}
|
|
292
|
+
function un(t, n, o = I) {
|
|
293
|
+
return o.distancia(t, n);
|
|
294
|
+
}
|
|
295
|
+
function fn(t, n, o) {
|
|
296
|
+
return {
|
|
297
|
+
...t,
|
|
298
|
+
id: n,
|
|
299
|
+
geometria: o ?? JSON.parse(JSON.stringify(t.geometria)),
|
|
300
|
+
estilo: t.estilo ? { ...t.estilo } : void 0,
|
|
301
|
+
propriedades: { ...t.propriedades }
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const Dt = 5e3;
|
|
305
|
+
function K(t) {
|
|
306
|
+
return t.tipo === "Polygon" ? 3 : t.tipo === "LineString" ? 2 : 1;
|
|
307
|
+
}
|
|
308
|
+
function hn(t, n = !1) {
|
|
309
|
+
if (t.bloqueada || n) return "bloqueada";
|
|
310
|
+
const o = t.geometria;
|
|
311
|
+
return o.tipo !== "Point" && o.tipo !== "LineString" && o.tipo !== "Polygon" && o.tipo !== "Circle" ? "tipo-nao-suportado" : o.tipo === "Polygon" && o.aneis.length !== 1 ? "poligono-com-furos" : H(o) ? "multiparte" : O(o).length > Dt ? "muitos-vertices" : null;
|
|
312
|
+
}
|
|
313
|
+
function O(t) {
|
|
314
|
+
return t.tipo === "Point" ? [t.coordenada] : t.tipo === "LineString" ? t.coordenadas : t.tipo === "Polygon" ? t.aneis[0] ?? [] : [];
|
|
315
|
+
}
|
|
316
|
+
function z(t, n) {
|
|
317
|
+
return t.tipo === "Point" ? { tipo: "Point", coordenada: n[0] } : t.tipo === "LineString" ? { tipo: "LineString", coordenadas: n } : t.tipo === "Polygon" ? { tipo: "Polygon", aneis: [n] } : t;
|
|
318
|
+
}
|
|
319
|
+
function pn(t, n, o) {
|
|
320
|
+
const e = O(t).slice();
|
|
321
|
+
return n < 0 || n >= e.length ? t : (e[n] = o, z(t, e));
|
|
322
|
+
}
|
|
323
|
+
function _t(t, n, o) {
|
|
324
|
+
if (t.tipo !== "LineString" && t.tipo !== "Polygon") return t;
|
|
325
|
+
const e = O(t).slice();
|
|
326
|
+
return n < 0 || n >= e.length ? t : (e.splice(n + 1, 0, o), z(t, e));
|
|
327
|
+
}
|
|
328
|
+
function Rt(t, n) {
|
|
329
|
+
if (t.tipo !== "LineString" && t.tipo !== "Polygon") return null;
|
|
330
|
+
const o = O(t);
|
|
331
|
+
return n < 0 || n >= o.length || o.length <= K(t) ? null : z(t, o.filter((e, r) => r !== n));
|
|
332
|
+
}
|
|
333
|
+
function dt(t, n) {
|
|
334
|
+
return [(t[0] + n[0]) / 2, (t[1] + n[1]) / 2];
|
|
335
|
+
}
|
|
336
|
+
function kt(t) {
|
|
337
|
+
const n = O(t).length, o = [];
|
|
338
|
+
if (t.tipo !== "LineString" && t.tipo !== "Polygon") return o;
|
|
339
|
+
for (let e = 0; e < n - 1; e++) o.push([e, e + 1]);
|
|
340
|
+
return t.tipo === "Polygon" && n > 2 && o.push([n - 1, 0]), o;
|
|
341
|
+
}
|
|
342
|
+
function _(t) {
|
|
343
|
+
return (t.tipo === "LineString" || t.tipo === "Polygon") && t.curva && t.curva.length >= K(t) ? t.curva : null;
|
|
344
|
+
}
|
|
345
|
+
const Ft = 0.5;
|
|
346
|
+
function wt(t, n, o = I) {
|
|
347
|
+
return o.pontoDaBorda(t, n);
|
|
348
|
+
}
|
|
349
|
+
function mn(t, n = I) {
|
|
350
|
+
var o;
|
|
351
|
+
return t.tipo === "Circle" ? [t.centro, wt(t.centro, t.raioMetros, n)] : ((o = _(t)) == null ? void 0 : o.map((e) => e.ponto)) ?? O(t);
|
|
352
|
+
}
|
|
353
|
+
function w(t, n) {
|
|
354
|
+
const o = t.tipo === "Polygon", e = bt(n, o);
|
|
355
|
+
return o ? { tipo: "Polygon", aneis: [e], curva: n } : { tipo: "LineString", coordenadas: e, curva: n };
|
|
356
|
+
}
|
|
357
|
+
function dn(t, n, o = I) {
|
|
358
|
+
if (t.tipo === "Circle")
|
|
359
|
+
return n.length < 2 ? t : { ...t, centro: n[0], raioMetros: Math.max(Ft, o.distancia(n[0], n[1])) };
|
|
360
|
+
const e = _(t);
|
|
361
|
+
if (!e || e.length !== n.length) return z(t, n);
|
|
362
|
+
const r = e.map((s, a) => {
|
|
363
|
+
const c = n[a][0] - s.ponto[0], u = n[a][1] - s.ponto[1], f = (i) => [i[0] + c, i[1] + u], l = { ponto: n[a] };
|
|
364
|
+
return s.entrada && (l.entrada = f(s.entrada)), s.saida && (l.saida = f(s.saida)), s.modo && (l.modo = s.modo), l;
|
|
365
|
+
});
|
|
366
|
+
return w(t, r);
|
|
367
|
+
}
|
|
368
|
+
function F(t, n, o) {
|
|
369
|
+
return [t[0] + (n[0] - t[0]) * o, t[1] + (n[1] - t[1]) * o];
|
|
370
|
+
}
|
|
371
|
+
function Xt(t, n, o) {
|
|
372
|
+
const [e, r] = W(t, n);
|
|
373
|
+
let s = 0.5, a = 1 / 0;
|
|
374
|
+
for (let c = 1; c < 64; c++) {
|
|
375
|
+
const u = c / 64, f = ft(t.ponto, e, r, n.ponto, u), l = (f[0] - o[0]) ** 2 + (f[1] - o[1]) ** 2;
|
|
376
|
+
l < a && (a = l, s = u);
|
|
377
|
+
}
|
|
378
|
+
return s;
|
|
379
|
+
}
|
|
380
|
+
function Yt(t, n, o) {
|
|
381
|
+
const e = _(t);
|
|
382
|
+
if (!e) {
|
|
383
|
+
const a = O(t);
|
|
384
|
+
return dt(a[n], a[o]);
|
|
385
|
+
}
|
|
386
|
+
const [r, s] = W(e[n], e[o]);
|
|
387
|
+
return ft(e[n].ponto, r, s, e[o].ponto, 0.5);
|
|
388
|
+
}
|
|
389
|
+
function jt(t) {
|
|
390
|
+
const n = _(t);
|
|
391
|
+
if (!n) return kt(t);
|
|
392
|
+
const o = [];
|
|
393
|
+
for (let e = 0; e < n.length - 1; e++) o.push([e, e + 1]);
|
|
394
|
+
return t.tipo === "Polygon" && n.length > 2 && o.push([n.length - 1, 0]), o;
|
|
395
|
+
}
|
|
396
|
+
function gn(t, n, o) {
|
|
397
|
+
const e = _(t);
|
|
398
|
+
if (!e) return _t(t, n, o);
|
|
399
|
+
if (n < 0 || n >= e.length) return t;
|
|
400
|
+
const r = (n + 1) % e.length, s = e[n], a = e[r], c = s.saida === void 0 && a.entrada === void 0;
|
|
401
|
+
let u, f = s, l = a;
|
|
402
|
+
if (c)
|
|
403
|
+
u = { ponto: o };
|
|
404
|
+
else {
|
|
405
|
+
const h = Xt(s, a, o), [p, y] = W(s, a), g = F(s.ponto, p, h), P = F(p, y, h), M = F(y, a.ponto, h), A = F(g, P, h), v = F(P, M, h);
|
|
406
|
+
u = { ponto: F(A, v, h), entrada: A, saida: v, modo: "suave" }, f = { ...s, saida: g }, l = { ...a, entrada: M }, U(s) === "simetrico" && s.entrada && (f.modo = "suave"), U(a) === "simetrico" && a.saida && (l.modo = "suave");
|
|
407
|
+
}
|
|
408
|
+
const i = e.slice();
|
|
409
|
+
return i[n] = f, i[r] = l, i.splice(n + 1, 0, u), w(t, i);
|
|
410
|
+
}
|
|
411
|
+
function yn(t, n) {
|
|
412
|
+
const o = _(t);
|
|
413
|
+
return o ? n < 0 || n >= o.length || o.length <= K(t) ? null : w(t, o.filter((e, r) => r !== n)) : Rt(t, n);
|
|
414
|
+
}
|
|
415
|
+
function Q(t) {
|
|
416
|
+
return t.tipo !== "LineString" && t.tipo !== "Polygon" ? null : _(t) ?? O(t).map((n) => ({ ponto: [n[0], n[1]] }));
|
|
417
|
+
}
|
|
418
|
+
const Pn = 40;
|
|
419
|
+
function Mn(t, n, o) {
|
|
420
|
+
const e = Q(t);
|
|
421
|
+
if (!e || n < 0 || n >= e.length) return null;
|
|
422
|
+
const r = t.tipo === "Polygon", s = e.length, a = o === "saida" ? n < s - 1 ? e[n + 1] : r ? e[0] : null : n > 0 ? e[n - 1] : r ? e[s - 1] : null;
|
|
423
|
+
if (!a) return null;
|
|
424
|
+
const c = e[n].ponto;
|
|
425
|
+
return [c[0] + (a.ponto[0] - c[0]) / 3, c[1] + (a.ponto[1] - c[1]) / 3];
|
|
426
|
+
}
|
|
427
|
+
function Vt(t) {
|
|
428
|
+
const n = q(t[0]);
|
|
429
|
+
return { ref: t, mLat: Math.max(n.lat, 1e-9), mLng: Math.max(n.lng, 1e-9) };
|
|
430
|
+
}
|
|
431
|
+
const rt = (t, n) => [(n[1] - t.ref[1]) * t.mLng, (n[0] - t.ref[0]) * t.mLat], qt = (t, n, o) => [t.ref[0] + o / t.mLat, t.ref[1] + n / t.mLng], Bt = (t) => Array.isArray(t) && t.length === 2 && Number.isFinite(t[0]) && Number.isFinite(t[1]);
|
|
432
|
+
function Gt(t, n, o, e, r = !1) {
|
|
433
|
+
const s = U(t), a = r ? "livre" : s === "canto" ? e : s, c = n === "saida" ? "entrada" : "saida", u = { ...t, [n]: o, modo: a };
|
|
434
|
+
if (a === "simetrico")
|
|
435
|
+
u[c] = Ct(t.ponto, o);
|
|
436
|
+
else if (a === "suave") {
|
|
437
|
+
const f = Vt(t.ponto), [l, i] = rt(f, o), h = Math.hypot(l, i), p = t[c], [y, g] = p ? rt(f, p) : [l, i], P = Math.hypot(y, g);
|
|
438
|
+
h > 0 && P > 0 && (u[c] = qt(f, -(l / h) * P, -(i / h) * P));
|
|
439
|
+
}
|
|
440
|
+
return u;
|
|
441
|
+
}
|
|
442
|
+
function Ln(t, n, o, e, r = !0) {
|
|
443
|
+
const s = Q(t);
|
|
444
|
+
if (!s || n < 0 || n >= s.length || !Bt(e)) return t;
|
|
445
|
+
const a = s.slice();
|
|
446
|
+
return a[n] = Gt(s[n], o, e, "simetrico", !r), w(t, a);
|
|
447
|
+
}
|
|
448
|
+
function xn(t, n) {
|
|
449
|
+
const o = Q(t);
|
|
450
|
+
if (!o || n < 0 || n >= o.length) return t;
|
|
451
|
+
const e = o[n], r = o.slice();
|
|
452
|
+
if (e.entrada || e.saida)
|
|
453
|
+
return r[n] = { ponto: e.ponto }, w(t, r);
|
|
454
|
+
const s = t.tipo === "Polygon", a = o.length, c = n > 0 ? o[n - 1] : s ? o[a - 1] : null, u = n < a - 1 ? o[n + 1] : s ? o[0] : null;
|
|
455
|
+
if (!c && !u) return t;
|
|
456
|
+
const f = e.ponto;
|
|
457
|
+
let l, i;
|
|
458
|
+
if (c && u)
|
|
459
|
+
l = (u.ponto[0] - c.ponto[0]) / 6, i = (u.ponto[1] - c.ponto[1]) / 6;
|
|
460
|
+
else {
|
|
461
|
+
const h = (u ?? c).ponto, p = u ? 1 : -1;
|
|
462
|
+
l = (h[0] - f[0]) / 3 * p, i = (h[1] - f[1]) / 3 * p;
|
|
463
|
+
}
|
|
464
|
+
return r[n] = { ponto: f, saida: [f[0] + l, f[1] + i], entrada: [f[0] - l, f[1] - i] }, w(t, r);
|
|
465
|
+
}
|
|
466
|
+
const zt = 128, Jt = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), Ut = "rgba(255,255,255,0.9)";
|
|
467
|
+
function Ht(t) {
|
|
468
|
+
if (!t) return [];
|
|
469
|
+
const n = t.split(/[\s,]+/).map(Number).filter((o) => Number.isFinite(o) && o >= 0);
|
|
470
|
+
return n.length > 0 && n.some((o) => o > 0) ? n.length % 2 === 1 ? [...n, ...n] : n : [];
|
|
471
|
+
}
|
|
472
|
+
const E = (t) => Number.isFinite(t), Wt = /* @__PURE__ */ new Set(["marca", "caixa", "poligono", "circulo", "linha", "ponto"]);
|
|
473
|
+
function vn(t) {
|
|
474
|
+
let n = 0;
|
|
475
|
+
if (t)
|
|
476
|
+
for (const o of t.itens) Wt.has(o.forma) && n++;
|
|
477
|
+
return n;
|
|
478
|
+
}
|
|
479
|
+
class Sn {
|
|
480
|
+
constructor(n) {
|
|
481
|
+
X(this, "destaques", /* @__PURE__ */ new Set());
|
|
482
|
+
X(this, "destruido", !1);
|
|
483
|
+
/** Estatística da última pintura (diagnóstico e testes). */
|
|
484
|
+
X(this, "ultima", { itens: 0, marcas: 0, preenchimentos: 0, tracos: 0, chamadas: 0 });
|
|
485
|
+
/** Perfil de qualidade `baixa`: ignora `dash` (linha contínua, mais barata no Canvas 2D). */
|
|
486
|
+
X(this, "semTracejado", !1);
|
|
487
|
+
this.alvos = n;
|
|
488
|
+
}
|
|
489
|
+
definirTracejado(n) {
|
|
490
|
+
this.semTracejado = !n;
|
|
491
|
+
}
|
|
492
|
+
destacar(n) {
|
|
493
|
+
this.destaques = new Set(n);
|
|
494
|
+
}
|
|
495
|
+
limpar() {
|
|
496
|
+
const n = this.alvos.sobreposicao();
|
|
497
|
+
n && this.limparSuperficie(n);
|
|
498
|
+
}
|
|
499
|
+
destruir() {
|
|
500
|
+
this.destruido = !0, this.destaques.clear();
|
|
501
|
+
}
|
|
502
|
+
desenhar(n, o, e = {}) {
|
|
503
|
+
const r = this.desenharFatiado(n, o, e);
|
|
504
|
+
return r.passo(Number.POSITIVE_INFINITY), r.estatisticas;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* A mesma pintura de `desenhar`, retomável: cada `passo(prazo)` pinta até o instante `prazo` (no relógio `agora`) e
|
|
508
|
+
* devolve se terminou. A superfície é limpa (se for o caso) no primeiro passo; o estilo do lote é redefinido a cada
|
|
509
|
+
* retomada (outra pintura pode ter mexido no contexto entre dois passos). Com `recorte`, o recorte é refeito a cada
|
|
510
|
+
* passo. `ultima` recebe a estatística quando termina.
|
|
511
|
+
*/
|
|
512
|
+
desenharFatiado(n, o, e = {}, r = Jt) {
|
|
513
|
+
const s = { itens: 0, marcas: 0, caixas: 0, preenchimentos: 0, tracos: 0, chamadas: 0 };
|
|
514
|
+
if (this.destruido || !n) return { passo: () => !0, estatisticas: s };
|
|
515
|
+
const a = e.alvo === "sobreposicao", c = o && E(o.dpr) && o.dpr > 0 ? o.dpr : 1, u = n.origem;
|
|
516
|
+
let f = null, l = 0, i = 0, h = 0, p = !1;
|
|
517
|
+
const y = () => {
|
|
518
|
+
const P = [];
|
|
519
|
+
if (a) {
|
|
520
|
+
const M = this.alvos.sobreposicao();
|
|
521
|
+
M && e.limpar !== !1 && this.limparSuperficie(M, c);
|
|
522
|
+
}
|
|
523
|
+
for (const M of n.camadas) {
|
|
524
|
+
const A = a ? this.alvos.sobreposicao() : this.alvos.camada(M.camadaId);
|
|
525
|
+
A && (!a && e.limpar !== !1 && this.limparSuperficie(A, c), P.push({ sup: A, lotes: this.lotesDaCamada(M, a, s) }));
|
|
526
|
+
}
|
|
527
|
+
return P;
|
|
528
|
+
};
|
|
529
|
+
return { passo: (P) => {
|
|
530
|
+
if (p) return !0;
|
|
531
|
+
if (this.destruido)
|
|
532
|
+
return p = !0, !0;
|
|
533
|
+
f ?? (f = y());
|
|
534
|
+
const M = e.recorte;
|
|
535
|
+
for (; l < f.length; ) {
|
|
536
|
+
const { sup: A, lotes: v } = f[l], d = A.ctx;
|
|
537
|
+
d.setTransform(c, 0, 0, c, 0, 0), M && (d.save(), d.beginPath(), d.rect(M.x, M.y, M.largura, M.altura), d.clip());
|
|
538
|
+
let m = !1;
|
|
539
|
+
try {
|
|
540
|
+
for (d.lineJoin = "round", d.lineCap = "round"; i < v.length; ) {
|
|
541
|
+
const L = v[i], x = this.pintorDoLote(d, L, u, s, h === 0);
|
|
542
|
+
if (!x) {
|
|
543
|
+
i++, h = 0;
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
const S = L.itens.length;
|
|
547
|
+
for (; h < S; ) {
|
|
548
|
+
const C = Math.min(S, h + zt);
|
|
549
|
+
for (; h < C; h++) x(L.itens[h]);
|
|
550
|
+
if (h < S && r() >= P) {
|
|
551
|
+
m = !0;
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (m) break;
|
|
556
|
+
if (i++, h = 0, i < v.length && r() >= P) {
|
|
557
|
+
m = !0;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
m || (d.globalAlpha = 1, d.setLineDash([]), d.lineDashOffset = 0);
|
|
562
|
+
} finally {
|
|
563
|
+
M && d.restore();
|
|
564
|
+
}
|
|
565
|
+
if (m) return !1;
|
|
566
|
+
l++, i = 0, h = 0;
|
|
567
|
+
}
|
|
568
|
+
return p = !0, this.ultima = s, !0;
|
|
569
|
+
}, estatisticas: s };
|
|
570
|
+
}
|
|
571
|
+
limparSuperficie(n, o) {
|
|
572
|
+
const e = o ?? n.dpr;
|
|
573
|
+
n.ctx.setTransform(1, 0, 0, 1, 0, 0), n.ctx.clearRect(0, 0, Math.ceil(n.largura * e), Math.ceil(n.altura * e)), n.ctx.setTransform(e, 0, 0, e, 0, 0);
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Separa os itens da camada nos lotes de pintura, na ordem de sempre: halos (só na sobreposição), marcas, caixas,
|
|
577
|
+
* polígonos/círculos, linhas e pontos; dentro de cada tipo, um lote por estilo (na ordem em que o estilo aparece).
|
|
578
|
+
*/
|
|
579
|
+
lotesDaCamada(n, o, e) {
|
|
580
|
+
const r = [], s = [], a = [], c = [], u = [];
|
|
581
|
+
for (const i of n.itens)
|
|
582
|
+
switch (i.forma) {
|
|
583
|
+
case "marca":
|
|
584
|
+
r.push(i);
|
|
585
|
+
break;
|
|
586
|
+
case "caixa":
|
|
587
|
+
s.push(i);
|
|
588
|
+
break;
|
|
589
|
+
case "poligono":
|
|
590
|
+
case "circulo":
|
|
591
|
+
a.push(i);
|
|
592
|
+
break;
|
|
593
|
+
case "linha":
|
|
594
|
+
c.push(i);
|
|
595
|
+
break;
|
|
596
|
+
case "ponto":
|
|
597
|
+
u.push(i);
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
e.itens += r.length + s.length + a.length + c.length + u.length;
|
|
601
|
+
const f = [];
|
|
602
|
+
if (o) {
|
|
603
|
+
const i = [];
|
|
604
|
+
for (const h of [a, c, u]) for (const p of h) (p.destaque || this.destaques.has(p.id)) && i.push(p);
|
|
605
|
+
i.length > 0 && f.push({ tipo: "halo", estilo: null, itens: i });
|
|
606
|
+
}
|
|
607
|
+
const l = (i, h) => {
|
|
608
|
+
for (const [p, y] of this.agrupar(h)) f.push({ tipo: i, estilo: p, itens: y });
|
|
609
|
+
};
|
|
610
|
+
return l("marca", r), l("caixa", s), l("area", a), l("linha", c), l("area", u), f;
|
|
611
|
+
}
|
|
612
|
+
agrupar(n) {
|
|
613
|
+
const o = /* @__PURE__ */ new Map();
|
|
614
|
+
for (const e of n) {
|
|
615
|
+
const r = o.get(e.estilo);
|
|
616
|
+
r ? r.push(e) : o.set(e.estilo, [e]);
|
|
617
|
+
}
|
|
618
|
+
return o;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Define no contexto o estilo do lote e devolve quem pinta cada item dele (`null`: o lote não pinta nada).
|
|
622
|
+
* `inicio`: primeira vez que o lote é pintado (conta as chamadas de estilo na estatística; numa retomada, não).
|
|
623
|
+
*/
|
|
624
|
+
pintorDoLote(n, o, e, r, s) {
|
|
625
|
+
const a = o.estilo;
|
|
626
|
+
if (o.tipo === "halo") return (i) => this.halo(n, i, e, r);
|
|
627
|
+
if (!a) return null;
|
|
628
|
+
if (o.tipo === "marca")
|
|
629
|
+
return n.fillStyle = a.corPreenchimento, n.globalAlpha = a.opacidadePreenchimento, s && (r.chamadas += 2), (i) => {
|
|
630
|
+
const h = i.geometriaEmPx[0];
|
|
631
|
+
if (!h) return;
|
|
632
|
+
const p = h[0] - e.x, y = h[1] - e.y;
|
|
633
|
+
if (!(E(p) && E(y))) return;
|
|
634
|
+
const g = i.raioPx >= 2 ? 2 : 1;
|
|
635
|
+
n.fillRect(Math.round(p - g / 2), Math.round(y - g / 2), g, g), r.marcas++, r.chamadas++;
|
|
636
|
+
};
|
|
637
|
+
if (o.tipo === "caixa") {
|
|
638
|
+
const i = a.traco && a.peso > 0, h = a.preencher && a.opacidadePreenchimento > 0;
|
|
639
|
+
if (!i && !h) return null;
|
|
640
|
+
n.fillStyle = i ? a.cor : a.corPreenchimento, n.globalAlpha = i ? a.opacidadeTraco ?? 1 : a.opacidadePreenchimento;
|
|
641
|
+
const p = i ? a.peso / 2 : 0;
|
|
642
|
+
return s && (r.chamadas += 2), (y) => {
|
|
643
|
+
const g = y.geometriaEmPx[0];
|
|
644
|
+
if (!g || g.length < 4) return;
|
|
645
|
+
const P = Math.floor(g[0] - e.x - p), M = Math.floor(g[1] - e.y - p), A = Math.ceil(g[2] - e.x + p), v = Math.ceil(g[3] - e.y + p);
|
|
646
|
+
E(P) && E(M) && E(A) && E(v) && (n.fillRect(P, M, Math.max(1, A - P), Math.max(1, v - M)), r.caixas = (r.caixas ?? 0) + 1, r.chamadas++);
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
const c = o.tipo === "area" && a.preencher && a.opacidadePreenchimento > 0, u = a.traco && a.peso > 0;
|
|
650
|
+
if (!c && !u) return null;
|
|
651
|
+
c && (n.fillStyle = a.corPreenchimento), u && (n.strokeStyle = a.cor, n.lineWidth = a.peso, n.setLineDash(this.semTracejado ? [] : Ht(a.dash)), n.lineDashOffset = this.semTracejado ? 0 : a.deslocamentoDash ?? 0, n.lineCap = a.terminacao ?? "round", n.lineJoin = a.juncao ?? "round"), s && (r.chamadas += 3);
|
|
652
|
+
const f = a.opacidadePreenchimento, l = a.opacidadeTraco ?? 1;
|
|
653
|
+
return (i) => {
|
|
654
|
+
n.beginPath(), this.caminho(n, i, e), c && (n.globalAlpha = f, n.fill(), r.preenchimentos++, r.chamadas++), u && (n.globalAlpha = l, n.stroke(), r.tracos++, r.chamadas++);
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
/** Caminho de um item: anéis/partes (polígono e linha), círculo ou ponto. */
|
|
658
|
+
caminho(n, o, e) {
|
|
659
|
+
if (o.forma === "circulo" || o.forma === "ponto") {
|
|
660
|
+
const s = o.geometriaEmPx[0];
|
|
661
|
+
if (!s) return;
|
|
662
|
+
const a = s[0] - e.x, c = s[1] - e.y;
|
|
663
|
+
E(a) && E(c) && E(o.raioPx) && (n.moveTo(a + o.raioPx, c), n.arc(a, c, o.raioPx, 0, Math.PI * 2));
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
const r = o.forma === "poligono";
|
|
667
|
+
for (const s of o.geometriaEmPx) {
|
|
668
|
+
const a = s.length >> 1;
|
|
669
|
+
if (a < 2) continue;
|
|
670
|
+
let c = !1;
|
|
671
|
+
for (let u = 0; u < a; u++) {
|
|
672
|
+
const f = s[u * 2] - e.x, l = s[u * 2 + 1] - e.y;
|
|
673
|
+
E(f) && E(l) && (c ? n.lineTo(f, l) : (n.moveTo(f, l), c = !0));
|
|
674
|
+
}
|
|
675
|
+
c && r && n.closePath();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
/** Halo de destaque (hover): traço claro, mais grosso, por baixo do desenho normal. */
|
|
679
|
+
halo(n, o, e, r) {
|
|
680
|
+
n.strokeStyle = Ut, n.lineWidth = Math.max(o.estilo.peso, 1) + 4, n.globalAlpha = 0.9, n.setLineDash([]), n.lineCap = "round", n.lineJoin = "round", n.beginPath(), this.caminho(n, o, e), n.stroke(), r.tracos++, r.chamadas += 4;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
const st = 36, at = 0.45;
|
|
684
|
+
function An(t, n) {
|
|
685
|
+
const o = Math.abs(n[0] - t[0]), e = Math.abs(n[1] - t[1]);
|
|
686
|
+
if (o === 0 && e === 0) return null;
|
|
687
|
+
const r = [];
|
|
688
|
+
for (let s = 0; s < st; s++) {
|
|
689
|
+
const a = s * 2 * Math.PI / st;
|
|
690
|
+
r.push([t[0] + o * Math.sin(a), t[1] + e * Math.cos(a)]);
|
|
691
|
+
}
|
|
692
|
+
return r;
|
|
693
|
+
}
|
|
694
|
+
function gt(t, n, o) {
|
|
695
|
+
const e = o.fatorEixo(t), r = n[0] - t[0], s = (n[1] - t[1]) * e, a = Math.hypot(r, s);
|
|
696
|
+
return a === 0 ? null : { raio: a, inicio: Math.atan2(r, s), cosLat: e };
|
|
697
|
+
}
|
|
698
|
+
function Cn(t, n, o = 6, e = I) {
|
|
699
|
+
const r = gt(t, n, e);
|
|
700
|
+
if (!r || o < 3) return null;
|
|
701
|
+
const s = [];
|
|
702
|
+
for (let a = 0; a < o; a++) {
|
|
703
|
+
const c = r.inicio + a * 2 * Math.PI / o;
|
|
704
|
+
s.push([t[0] + r.raio * Math.sin(c), t[1] + r.raio * Math.cos(c) / r.cosLat]);
|
|
705
|
+
}
|
|
706
|
+
return s;
|
|
707
|
+
}
|
|
708
|
+
function bn(t, n, o = 5, e = I, r = at) {
|
|
709
|
+
const s = gt(t, n, e);
|
|
710
|
+
if (!s || o < 3) return null;
|
|
711
|
+
const a = Number.isFinite(r) && r > 0 && r <= 1 ? r : at, c = o * 2, u = [];
|
|
712
|
+
for (let f = 0; f < c; f++) {
|
|
713
|
+
const l = f % 2 === 0 ? s.raio : s.raio * a, i = s.inicio + f * 2 * Math.PI / c;
|
|
714
|
+
u.push([t[0] + l * Math.sin(i), t[1] + l * Math.cos(i) / s.cosLat]);
|
|
715
|
+
}
|
|
716
|
+
return u;
|
|
717
|
+
}
|
|
718
|
+
const Kt = 10, Y = (t, n) => Math.hypot(t.x - n.x, t.y - n.y);
|
|
719
|
+
function it(t, n, o) {
|
|
720
|
+
const e = o.x - n.x, r = o.y - n.y, s = e * e + r * r, a = s === 0 ? 0 : Math.max(0, Math.min(1, ((t.x - n.x) * e + (t.y - n.y) * r) / s));
|
|
721
|
+
return { t: a, d: Math.hypot(t.x - (n.x + a * e), t.y - (n.y + a * r)) };
|
|
722
|
+
}
|
|
723
|
+
function In(t, n, o, e = {}, r) {
|
|
724
|
+
const s = e.toleranciaPx ?? Kt, a = e.vertice !== !1, c = e.meio !== !1, u = e.aresta !== !1;
|
|
725
|
+
let f = null, l = null, i = null;
|
|
726
|
+
const h = (p, y) => !p || y.distanciaPx < p.distanciaPx ? y : p;
|
|
727
|
+
for (const p of n) {
|
|
728
|
+
if (p.excluida || p.oculta) continue;
|
|
729
|
+
const y = !!r && r.feicaoId === p.id && (r.camadaId === void 0 || r.camadaId === p.camadaId), g = p.geometria, P = { feicaoId: p.id, camadaId: p.camadaId };
|
|
730
|
+
if (g.tipo === "Point" || g.tipo === "Text" || g.tipo === "Circle") {
|
|
731
|
+
if (!a || y) continue;
|
|
732
|
+
const d = g.tipo === "Circle" ? g.centro : g.coordenada, m = Y(t, o(d));
|
|
733
|
+
m <= s && (f = h(f, { tipo: "vertice", coordenada: d, distanciaPx: m, ...P }));
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
if (y && (g.tipo === "LineString" || g.tipo === "Polygon") && g.curva) continue;
|
|
737
|
+
const M = g.tipo === "LineString" || g.tipo === "Polygon" ? _(g) : null;
|
|
738
|
+
if (M) {
|
|
739
|
+
if (a)
|
|
740
|
+
for (const d of M) {
|
|
741
|
+
const m = Y(t, o(d.ponto));
|
|
742
|
+
m <= s && (f = h(f, { tipo: "vertice", coordenada: d.ponto, distanciaPx: m, ...P }));
|
|
743
|
+
}
|
|
744
|
+
if (c)
|
|
745
|
+
for (const [d, m] of jt(g)) {
|
|
746
|
+
const L = Yt(g, d, m), x = Y(t, o(L));
|
|
747
|
+
x <= s && (l = h(l, { tipo: "meio", coordenada: L, distanciaPx: x, ...P }));
|
|
748
|
+
}
|
|
749
|
+
if (u) {
|
|
750
|
+
const d = O(g), m = d.map(o), L = g.tipo === "Polygon" && d.length > 2 ? d.length : d.length - 1;
|
|
751
|
+
for (let x = 0; x < L; x++) {
|
|
752
|
+
const S = x, C = (x + 1) % d.length, { t: T, d: D } = it(t, m[S], m[C]);
|
|
753
|
+
if (D <= s) {
|
|
754
|
+
const R = [d[S][0] + T * (d[C][0] - d[S][0]), d[S][1] + T * (d[C][1] - d[S][1])];
|
|
755
|
+
i = h(i, { tipo: "aresta", coordenada: R, distanciaPx: D, ...P });
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
const A = g.tipo === "LineString" ? G(g).map((d) => ({ pts: d, fechado: !1 })) : [{ pts: O(g), fechado: g.tipo === "Polygon" }], v = y ? r.vertice : void 0;
|
|
762
|
+
for (const { pts: d, fechado: m } of A) {
|
|
763
|
+
const L = d.map(o);
|
|
764
|
+
if (a)
|
|
765
|
+
for (let S = 0; S < d.length; S++) {
|
|
766
|
+
if (S === v) continue;
|
|
767
|
+
const C = Y(t, L[S]);
|
|
768
|
+
C <= s && (f = h(f, { tipo: "vertice", coordenada: d[S], distanciaPx: C, ...P }));
|
|
769
|
+
}
|
|
770
|
+
if (!c && !u) continue;
|
|
771
|
+
const x = m && d.length > 2 ? d.length : d.length - 1;
|
|
772
|
+
for (let S = 0; S < x; S++) {
|
|
773
|
+
const C = S, T = (S + 1) % d.length;
|
|
774
|
+
if (!(v !== void 0 && (C === v || T === v)) && !(y && v === void 0)) {
|
|
775
|
+
if (c) {
|
|
776
|
+
const D = dt(d[C], d[T]), R = Y(t, o(D));
|
|
777
|
+
R <= s && (l = h(l, { tipo: "meio", coordenada: D, distanciaPx: R, ...P }));
|
|
778
|
+
}
|
|
779
|
+
if (u) {
|
|
780
|
+
const { t: D, d: R } = it(t, L[C], L[T]);
|
|
781
|
+
if (R <= s) {
|
|
782
|
+
const yt = [d[C][0] + D * (d[T][0] - d[C][0]), d[C][1] + D * (d[T][1] - d[C][1])];
|
|
783
|
+
i = h(i, { tipo: "aresta", coordenada: yt, distanciaPx: R, ...P });
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return f ?? l ?? i;
|
|
791
|
+
}
|
|
792
|
+
function j(t, n) {
|
|
793
|
+
return t.x >= n.x1 && t.x <= n.x2 && t.y >= n.y1 && t.y <= n.y2;
|
|
794
|
+
}
|
|
795
|
+
function ct(t, n, o) {
|
|
796
|
+
let e = 0, r = 1;
|
|
797
|
+
const s = n.x - t.x, a = n.y - t.y, c = [-s, s, -a, a], u = [t.x - o.x1, o.x2 - t.x, t.y - o.y1, o.y2 - t.y];
|
|
798
|
+
for (let f = 0; f < 4; f++)
|
|
799
|
+
if (c[f] === 0) {
|
|
800
|
+
if (u[f] < 0) return !1;
|
|
801
|
+
} else {
|
|
802
|
+
const l = u[f] / c[f];
|
|
803
|
+
if (c[f] < 0) {
|
|
804
|
+
if (l > r) return !1;
|
|
805
|
+
l > e && (e = l);
|
|
806
|
+
} else {
|
|
807
|
+
if (l < e) return !1;
|
|
808
|
+
l < r && (r = l);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return !0;
|
|
812
|
+
}
|
|
813
|
+
function lt(t, n) {
|
|
814
|
+
let o = !1;
|
|
815
|
+
for (let e = 0, r = n.length - 1; e < n.length; r = e++) {
|
|
816
|
+
const s = n[e], a = n[r];
|
|
817
|
+
s.y > t.y != a.y > t.y && t.x < (a.x - s.x) * (t.y - s.y) / (a.y - s.y) + s.x && (o = !o);
|
|
818
|
+
}
|
|
819
|
+
return o;
|
|
820
|
+
}
|
|
821
|
+
function ut(t, n, o) {
|
|
822
|
+
for (let e = 1; e < t.length; e++) if (ct(t[e - 1], t[e], n)) return !0;
|
|
823
|
+
return o && t.length > 2 && ct(t[t.length - 1], t[0], n);
|
|
824
|
+
}
|
|
825
|
+
function Qt(t, n, o, e) {
|
|
826
|
+
const r = o(t), s = o(e.pontoDeMedidaDoRaio(t, n));
|
|
827
|
+
return Math.hypot(s.x - r.x, s.y - r.y);
|
|
828
|
+
}
|
|
829
|
+
function En(t, n, o, e, r = I) {
|
|
830
|
+
if (t.oculta) return !1;
|
|
831
|
+
const s = t.geometria, a = e === "window";
|
|
832
|
+
switch (s.tipo) {
|
|
833
|
+
case "Point":
|
|
834
|
+
case "Text":
|
|
835
|
+
return j(o(s.coordenada), n);
|
|
836
|
+
case "LineString": {
|
|
837
|
+
const c = G(s).map((u) => u.map(o));
|
|
838
|
+
return a ? c.every((u) => u.every((f) => j(f, n))) : c.some((u) => u.some((f) => j(f, n)) || ut(u, n, !1));
|
|
839
|
+
}
|
|
840
|
+
case "Polygon": {
|
|
841
|
+
const c = s.aneis.map((l) => l.map(o)), u = c[0];
|
|
842
|
+
if (!u) return !1;
|
|
843
|
+
if (a) return u.every((l) => j(l, n));
|
|
844
|
+
if (c.some((l) => l.some((i) => j(i, n)) || ut(l, n, !0))) return !0;
|
|
845
|
+
const f = { x: n.x1, y: n.y1 };
|
|
846
|
+
return lt(f, u) && !c.slice(1).some((l) => lt(f, l));
|
|
847
|
+
}
|
|
848
|
+
case "Circle": {
|
|
849
|
+
const c = o(s.centro), u = Qt(s.centro, s.raioMetros, o, r);
|
|
850
|
+
if (a)
|
|
851
|
+
return c.x - u >= n.x1 && c.x + u <= n.x2 && c.y - u >= n.y1 && c.y + u <= n.y2;
|
|
852
|
+
const f = Math.max(n.x1, Math.min(c.x, n.x2)), l = Math.max(n.y1, Math.min(c.y, n.y2));
|
|
853
|
+
return Math.hypot(c.x - f, c.y - l) <= u;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function Nn(t, n) {
|
|
858
|
+
if (n.length < 3 || t.oculta) return !1;
|
|
859
|
+
const o = (r) => Nt(r, [n]), e = t.geometria;
|
|
860
|
+
switch (e.tipo) {
|
|
861
|
+
case "Point":
|
|
862
|
+
case "Text":
|
|
863
|
+
return o(e.coordenada);
|
|
864
|
+
case "Circle":
|
|
865
|
+
return o(e.centro);
|
|
866
|
+
case "LineString":
|
|
867
|
+
return G(e).some((r) => r.some(o));
|
|
868
|
+
case "Polygon": {
|
|
869
|
+
const r = e.aneis[0] ?? [];
|
|
870
|
+
if (r.some(o)) return !0;
|
|
871
|
+
if (r.length < 3) return !1;
|
|
872
|
+
const s = r.reduce((a, c) => [a[0] + c[0], a[1] + c[1]], [0, 0]);
|
|
873
|
+
return o([s[0] / r.length, s[1] / r.length]);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
export {
|
|
878
|
+
Yt as A,
|
|
879
|
+
gn as B,
|
|
880
|
+
yn as C,
|
|
881
|
+
K as D,
|
|
882
|
+
I as E,
|
|
883
|
+
hn as F,
|
|
884
|
+
In as G,
|
|
885
|
+
Nn as H,
|
|
886
|
+
En as I,
|
|
887
|
+
Dt as J,
|
|
888
|
+
z as K,
|
|
889
|
+
ln as L,
|
|
890
|
+
Pn as M,
|
|
891
|
+
cn as N,
|
|
892
|
+
un as O,
|
|
893
|
+
Sn as P,
|
|
894
|
+
_t as Q,
|
|
895
|
+
Ft as R,
|
|
896
|
+
pn as S,
|
|
897
|
+
Kt as T,
|
|
898
|
+
Ht as U,
|
|
899
|
+
wt as V,
|
|
900
|
+
dt as W,
|
|
901
|
+
Rt as X,
|
|
902
|
+
O as Y,
|
|
903
|
+
Cn as a,
|
|
904
|
+
bn as b,
|
|
905
|
+
vn as c,
|
|
906
|
+
nn as d,
|
|
907
|
+
fn as e,
|
|
908
|
+
rn as f,
|
|
909
|
+
An as g,
|
|
910
|
+
an as h,
|
|
911
|
+
en as i,
|
|
912
|
+
on as j,
|
|
913
|
+
rt as k,
|
|
914
|
+
qt as l,
|
|
915
|
+
w as m,
|
|
916
|
+
Q as n,
|
|
917
|
+
sn as o,
|
|
918
|
+
Nt as p,
|
|
919
|
+
xn as q,
|
|
920
|
+
mn as r,
|
|
921
|
+
kt as s,
|
|
922
|
+
dn as t,
|
|
923
|
+
Ln as u,
|
|
924
|
+
Gt as v,
|
|
925
|
+
Vt as w,
|
|
926
|
+
Mn as x,
|
|
927
|
+
jt as y,
|
|
928
|
+
_ as z
|
|
929
|
+
};
|