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