@hybridcore/ui 1.6.12 → 1.6.13

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 (105) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/assets/index2.css +1 -1
  3. package/dist/components/button/styled.js +1 -1
  4. package/dist/components/charts/_common/format.js +149 -41
  5. package/dist/components/charts/_common/utils.js +16 -11
  6. package/dist/components/collapsible-card/index.js +21 -30
  7. package/dist/components/collapsible-card/styled.js +16 -14
  8. package/dist/components/color-picker/index.js +2227 -3357
  9. package/dist/components/color-picker/styled.js +87 -7
  10. package/dist/components/confirm/dialog.js +89 -8
  11. package/dist/components/confirm/index.js +1 -1
  12. package/dist/components/data-map/index.js +1 -1
  13. package/dist/components/data-map/logic.js +20 -20
  14. package/dist/components/data-security-selectors/dissemination-list/index.js +32 -3117
  15. package/dist/components/date-picker-with-custom-range/index.js +86 -7
  16. package/dist/components/date-range-picker/index.js +464 -452
  17. package/dist/components/document-viewer/components/viewer/index.js +1 -1
  18. package/dist/components/duration-select/index.js +10 -10
  19. package/dist/components/duration-select/styled.js +1 -1
  20. package/dist/components/geometry-picker/coordinate/index.js +14 -14
  21. package/dist/components/geometry-picker/edit/index.js +1 -1
  22. package/dist/components/geometry-picker/geometry/index.js +1 -1
  23. package/dist/components/geometry-picker/kml/index.js +11 -11
  24. package/dist/components/geometry-picker/map/logic.js +145 -3656
  25. package/dist/components/geometry-picker/map/style.js +18 -17
  26. package/dist/components/geometry-picker/parser/coordinate-input/logic.js +43 -1255
  27. package/dist/components/heat-map/index.js +1 -1
  28. package/dist/components/heat-map/logic.js +77 -1924
  29. package/dist/components/instance-hierarchy-table/styled.js +18 -16
  30. package/dist/components/map/helpers/mapbox.js +17 -15
  31. package/dist/components/map/helpers/ol.js +386 -27
  32. package/dist/components/map/index.js +11 -10
  33. package/dist/components/map/logic.js +22 -22
  34. package/dist/components/map/styled.js +31 -27
  35. package/dist/components/metric-card/logic.js +46 -49
  36. package/dist/components/phone-input/index.js +10 -9
  37. package/dist/components/property-mapping/index.js +1 -1
  38. package/dist/components/prr-map/index.js +1 -1
  39. package/dist/components/prr-map/logic.js +27 -26
  40. package/dist/components/range-selector/styled.js +65 -4228
  41. package/dist/components/raster-grid-map/index.js +1 -1
  42. package/dist/components/raster-grid-map/logic.js +60 -57
  43. package/dist/components/simple-pivot-table/index.js +17 -17
  44. package/dist/components/simple-pivot-table/logic.js +67 -76
  45. package/dist/components/sortable-list/index.js +1091 -1264
  46. package/dist/components/template-form/components/property-list/index.js +36 -33
  47. package/dist/components/template-form/components/property-list/property-list-columns.js +19 -18
  48. package/dist/components/template-form/components/property-list/property-list-form.js +137 -601
  49. package/dist/components/template-form/components/recognition-property-list/index.js +40 -37
  50. package/dist/components/template-form/components/recognition-property-list/recognition-property-list-columns.js +11 -10
  51. package/dist/components/template-form/components/recognition-property-list/recognition-property-list-form.js +55 -63
  52. package/dist/components/tree-select/index.js +16 -16
  53. package/dist/index.esm-UfGMjYOL.js +197 -0
  54. package/dist/main.d.ts +54 -8
  55. package/dist/main.js +176 -175
  56. package/package.json +1 -1
  57. package/dist/AccordionSummary-CJppWeqF.js +0 -781
  58. package/dist/Add-CqcD1PWb.js +0 -403
  59. package/dist/Box-DqUMmZjL.js +0 -31
  60. package/dist/Button-C5yquWAB.js +0 -357
  61. package/dist/ButtonBase-BEF7oTOe.js +0 -887
  62. package/dist/Delete-BdyYpINH.js +0 -23
  63. package/dist/DialogContent-BvVjD9z3.js +0 -523
  64. package/dist/FormGroup-CpBsIyYR.js +0 -89
  65. package/dist/IconButton-BoGwbvrP.js +0 -184
  66. package/dist/InputLabel-Dd8RrneV.js +0 -341
  67. package/dist/MenuItem-DwqJqzuM.js +0 -233
  68. package/dist/Modal-MUZygjmQ.js +0 -1158
  69. package/dist/Paper-BkQLdsCI.js +0 -582
  70. package/dist/Select-DHUl_uG3.js +0 -3916
  71. package/dist/Source-BSZST_GH.js +0 -4410
  72. package/dist/SwitchBase-DTndTqI8.js +0 -235
  73. package/dist/Text-ChJRuaD8.js +0 -2197
  74. package/dist/TextField-e2oKaUN1.js +0 -669
  75. package/dist/TransitionGroupContext-BDAp2T0O.js +0 -96
  76. package/dist/Typography-DgsSLCFC.js +0 -178
  77. package/dist/Vector-BmuhQO4p.js +0 -3606
  78. package/dist/Vector-DfTqQEln.js +0 -1735
  79. package/dist/WKT-2wsDT-nq.js +0 -2310
  80. package/dist/assertThisInitialized-C1dAyb4j.js +0 -7
  81. package/dist/assets/index3.css +0 -1
  82. package/dist/assets/index4.css +0 -1
  83. package/dist/clsx-OuTLNxxd.js +0 -16
  84. package/dist/createChainedFunction-C0nujS3O.js +0 -9
  85. package/dist/createSvgIcon-Ch_cT8az.js +0 -185
  86. package/dist/createSvgIcon-DuDuASu1.js +0 -62
  87. package/dist/debounce-46wSf_lW.js +0 -15
  88. package/dist/dialog-BYRnCztH.js +0 -154
  89. package/dist/formControlState-vgaj2ksH.js +0 -10
  90. package/dist/generateUtilityClasses-C3ivN9Ie.js +0 -2973
  91. package/dist/index-DH6qsPBn.js +0 -153
  92. package/dist/index-e9xTIYWt.js +0 -1934
  93. package/dist/index.esm-BLLrbTzY.js +0 -318
  94. package/dist/math-Bvt2Ubuz.js +0 -704
  95. package/dist/objectWithoutPropertiesLoose-DJteAcBH.js +0 -22
  96. package/dist/ol-yOE-NV0X.js +0 -7465
  97. package/dist/ownerWindow-wg6foiOE.js +0 -10
  98. package/dist/setPrototypeOf-NPgp4cYc.js +0 -8
  99. package/dist/styled-SoqbyrkW.js +0 -350
  100. package/dist/unsupportedProp-DuqR2hj9.js +0 -36
  101. package/dist/useControlled-BYdyS7Pn.js +0 -31
  102. package/dist/useFormControl-CatNKXAi.js +0 -10
  103. package/dist/useId-BW-oWmul.js +0 -19
  104. package/dist/useMobilePicker-CY8ndYRL.js +0 -8279
  105. package/dist/useSlot-B_Q4vnX5.js +0 -42
@@ -1,3606 +0,0 @@
1
- import { L as ze, R as qe, l as Ue, B as $e } from "./Vector-DfTqQEln.js";
2
- import { W as ht, am as Qe, au as ti, av as ei, aw as ii, a5 as G, a0 as vt, _ as Vt, at as ni, ax as si, ay as oi, k as bt, r as me, E as ye, az as ri, a4 as se, aA as li, aB as tt, aC as ai, T as Ce, aD as yt, aE as hi, y as At, aF as ci, aG as di, a3 as Mt, a2 as Ft, aH as fi, a1 as ui, aI as gi, ae as _i, V as Wt, aJ as xi, aK as pi, af as Si } from "./Source-BSZST_GH.js";
3
- import { g as Te, d as gt, h as ot, i as V, j as Bt, k as Gt, l as et, m as it, n as Yt, o as Xt, p as Nt, q as lt, r as Tt, u as Ht, v as Fe, w as mi, x as yi, y as Ci, z as Ie, I as Ti, b as Ct, A as Ii } from "./Text-ChJRuaD8.js";
4
- import { k as Rt, x as Ri, d as K, g as It, y as ie, i as ki, t as wi, m as Re } from "./math-Bvt2Ubuz.js";
5
- const ke = [];
6
- let ut = null;
7
- function Ei() {
8
- ut = gt(1, 1, void 0, {
9
- willReadFrequently: !0
10
- });
11
- }
12
- class Li extends ze {
13
- /**
14
- * @param {LayerType} layer Layer.
15
- */
16
- constructor(t) {
17
- super(t), this.container = null, this.renderedResolution, this.tempTransform = ht(), this.pixelTransform = ht(), this.inversePixelTransform = ht(), this.context = null, this.containerReused = !1, this.pixelContext_ = null, this.frameState = null;
18
- }
19
- /**
20
- * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
21
- * @param {number} col The column index.
22
- * @param {number} row The row index.
23
- * @return {Uint8ClampedArray|null} The image data.
24
- */
25
- getImageData(t, e, i) {
26
- ut || Ei(), ut.clearRect(0, 0, 1, 1);
27
- let n;
28
- try {
29
- ut.drawImage(t, e, i, 1, 1, 0, 0, 1, 1), n = ut.getImageData(0, 0, 1, 1).data;
30
- } catch {
31
- return ut = null, null;
32
- }
33
- return n;
34
- }
35
- /**
36
- * @param {import('../../Map.js').FrameState} frameState Frame state.
37
- * @return {string} Background color.
38
- */
39
- getBackground(t) {
40
- let i = this.getLayer().getBackground();
41
- return typeof i == "function" && (i = i(t.viewState.resolution)), i || void 0;
42
- }
43
- /**
44
- * Get a rendering container from an existing target, if compatible.
45
- * @param {HTMLElement} target Potential render target.
46
- * @param {string} transform CSS Transform.
47
- * @param {string} [backgroundColor] Background color.
48
- */
49
- useContainer(t, e, i) {
50
- const n = this.getLayer().getClassName();
51
- let s, o;
52
- if (t && t.className === n && (!i || t && t.style.backgroundColor && Rt(
53
- Te(t.style.backgroundColor),
54
- Te(i)
55
- ))) {
56
- const r = t.firstElementChild;
57
- r instanceof HTMLCanvasElement && (o = r.getContext("2d"));
58
- }
59
- if (o && o.canvas.style.transform === e ? (this.container = t, this.context = o, this.containerReused = !0) : this.containerReused ? (this.container = null, this.context = null, this.containerReused = !1) : this.container && (this.container.style.backgroundColor = null), !this.container) {
60
- s = document.createElement("div"), s.className = n;
61
- let r = s.style;
62
- r.position = "absolute", r.width = "100%", r.height = "100%", o = gt();
63
- const l = o.canvas;
64
- s.appendChild(l), r = l.style, r.position = "absolute", r.left = "0", r.transformOrigin = "top left", this.container = s, this.context = o;
65
- }
66
- !this.containerReused && i && !this.container.style.backgroundColor && (this.container.style.backgroundColor = i);
67
- }
68
- /**
69
- * @param {CanvasRenderingContext2D} context Context.
70
- * @param {import("../../Map.js").FrameState} frameState Frame state.
71
- * @param {import("../../extent.js").Extent} extent Clip extent.
72
- * @protected
73
- */
74
- clipUnrotated(t, e, i) {
75
- const n = Qe(i), s = ti(i), o = ei(i), r = ii(i);
76
- G(e.coordinateToPixelTransform, n), G(e.coordinateToPixelTransform, s), G(e.coordinateToPixelTransform, o), G(e.coordinateToPixelTransform, r);
77
- const l = this.inversePixelTransform;
78
- G(l, n), G(l, s), G(l, o), G(l, r), t.save(), t.beginPath(), t.moveTo(Math.round(n[0]), Math.round(n[1])), t.lineTo(Math.round(s[0]), Math.round(s[1])), t.lineTo(Math.round(o[0]), Math.round(o[1])), t.lineTo(Math.round(r[0]), Math.round(r[1])), t.clip();
79
- }
80
- /**
81
- * @param {import("../../render/EventType.js").default} type Event type.
82
- * @param {CanvasRenderingContext2D} context Context.
83
- * @param {import("../../Map.js").FrameState} frameState Frame state.
84
- * @private
85
- */
86
- dispatchRenderEvent_(t, e, i) {
87
- const n = this.getLayer();
88
- if (n.hasListener(t)) {
89
- const s = new qe(
90
- t,
91
- this.inversePixelTransform,
92
- i,
93
- e
94
- );
95
- n.dispatchEvent(s);
96
- }
97
- }
98
- /**
99
- * @param {CanvasRenderingContext2D} context Context.
100
- * @param {import("../../Map.js").FrameState} frameState Frame state.
101
- * @protected
102
- */
103
- preRender(t, e) {
104
- this.frameState = e, this.dispatchRenderEvent_(vt.PRERENDER, t, e);
105
- }
106
- /**
107
- * @param {CanvasRenderingContext2D} context Context.
108
- * @param {import("../../Map.js").FrameState} frameState Frame state.
109
- * @protected
110
- */
111
- postRender(t, e) {
112
- this.dispatchRenderEvent_(vt.POSTRENDER, t, e);
113
- }
114
- /**
115
- * Creates a transform for rendering to an element that will be rotated after rendering.
116
- * @param {import("../../coordinate.js").Coordinate} center Center.
117
- * @param {number} resolution Resolution.
118
- * @param {number} rotation Rotation.
119
- * @param {number} pixelRatio Pixel ratio.
120
- * @param {number} width Width of the rendered element (in pixels).
121
- * @param {number} height Height of the rendered element (in pixels).
122
- * @param {number} offsetX Offset on the x-axis in view coordinates.
123
- * @protected
124
- * @return {!import("../../transform.js").Transform} Transform.
125
- */
126
- getRenderTransform(t, e, i, n, s, o, r) {
127
- const l = s / 2, a = o / 2, h = n / e, d = -h, c = -t[0] + r, f = -t[1];
128
- return Vt(
129
- this.tempTransform,
130
- l,
131
- a,
132
- h,
133
- d,
134
- -i,
135
- c,
136
- f
137
- );
138
- }
139
- /**
140
- * Clean up.
141
- */
142
- disposeInternal() {
143
- delete this.frameState, super.disposeInternal();
144
- }
145
- }
146
- const I = {
147
- BEGIN_GEOMETRY: 0,
148
- BEGIN_PATH: 1,
149
- CIRCLE: 2,
150
- CLOSE_PATH: 3,
151
- CUSTOM: 4,
152
- DRAW_CHARS: 5,
153
- DRAW_IMAGE: 6,
154
- END_GEOMETRY: 7,
155
- FILL: 8,
156
- MOVE_TO_LINE_TO: 9,
157
- SET_FILL_STYLE: 10,
158
- SET_STROKE_STYLE: 11,
159
- STROKE: 12
160
- }, Pt = [I.FILL], rt = [I.STROKE], at = [I.BEGIN_PATH], we = [I.CLOSE_PATH];
161
- class We {
162
- /**
163
- * Render a geometry with a custom renderer.
164
- *
165
- * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
166
- * @param {import("../Feature.js").FeatureLike} feature Feature.
167
- * @param {Function} renderer Renderer.
168
- * @param {Function} hitDetectionRenderer Renderer.
169
- */
170
- drawCustom(t, e, i, n) {
171
- }
172
- /**
173
- * Render a geometry.
174
- *
175
- * @param {import("../geom/Geometry.js").default} geometry The geometry to render.
176
- */
177
- drawGeometry(t) {
178
- }
179
- /**
180
- * Set the rendering style.
181
- *
182
- * @param {import("../style/Style.js").default} style The rendering style.
183
- */
184
- setStyle(t) {
185
- }
186
- /**
187
- * @param {import("../geom/Circle.js").default} circleGeometry Circle geometry.
188
- * @param {import("../Feature.js").default} feature Feature.
189
- */
190
- drawCircle(t, e) {
191
- }
192
- /**
193
- * @param {import("../Feature.js").default} feature Feature.
194
- * @param {import("../style/Style.js").default} style Style.
195
- */
196
- drawFeature(t, e) {
197
- }
198
- /**
199
- * @param {import("../geom/GeometryCollection.js").default} geometryCollectionGeometry Geometry collection.
200
- * @param {import("../Feature.js").default} feature Feature.
201
- */
202
- drawGeometryCollection(t, e) {
203
- }
204
- /**
205
- * @param {import("../geom/LineString.js").default|import("./Feature.js").default} lineStringGeometry Line string geometry.
206
- * @param {import("../Feature.js").FeatureLike} feature Feature.
207
- */
208
- drawLineString(t, e) {
209
- }
210
- /**
211
- * @param {import("../geom/MultiLineString.js").default|import("./Feature.js").default} multiLineStringGeometry MultiLineString geometry.
212
- * @param {import("../Feature.js").FeatureLike} feature Feature.
213
- */
214
- drawMultiLineString(t, e) {
215
- }
216
- /**
217
- * @param {import("../geom/MultiPoint.js").default|import("./Feature.js").default} multiPointGeometry MultiPoint geometry.
218
- * @param {import("../Feature.js").FeatureLike} feature Feature.
219
- */
220
- drawMultiPoint(t, e) {
221
- }
222
- /**
223
- * @param {import("../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry.
224
- * @param {import("../Feature.js").FeatureLike} feature Feature.
225
- */
226
- drawMultiPolygon(t, e) {
227
- }
228
- /**
229
- * @param {import("../geom/Point.js").default|import("./Feature.js").default} pointGeometry Point geometry.
230
- * @param {import("../Feature.js").FeatureLike} feature Feature.
231
- */
232
- drawPoint(t, e) {
233
- }
234
- /**
235
- * @param {import("../geom/Polygon.js").default|import("./Feature.js").default} polygonGeometry Polygon geometry.
236
- * @param {import("../Feature.js").FeatureLike} feature Feature.
237
- */
238
- drawPolygon(t, e) {
239
- }
240
- /**
241
- * @param {import("../geom/SimpleGeometry.js").default|import("./Feature.js").default} geometry Geometry.
242
- * @param {import("../Feature.js").FeatureLike} feature Feature.
243
- */
244
- drawText(t, e) {
245
- }
246
- /**
247
- * @param {import("../style/Fill.js").default} fillStyle Fill style.
248
- * @param {import("../style/Stroke.js").default} strokeStyle Stroke style.
249
- */
250
- setFillStrokeStyle(t, e) {
251
- }
252
- /**
253
- * @param {import("../style/Image.js").default} imageStyle Image style.
254
- * @param {import("../render/canvas.js").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with a text style.
255
- */
256
- setImageStyle(t, e) {
257
- }
258
- /**
259
- * @param {import("../style/Text.js").default} textStyle Text style.
260
- * @param {import("../render/canvas.js").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with an image style.
261
- */
262
- setTextStyle(t, e) {
263
- }
264
- }
265
- class kt extends We {
266
- /**
267
- * @param {number} tolerance Tolerance.
268
- * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
269
- * @param {number} resolution Resolution.
270
- * @param {number} pixelRatio Pixel ratio.
271
- */
272
- constructor(t, e, i, n) {
273
- super(), this.tolerance = t, this.maxExtent = e, this.pixelRatio = n, this.maxLineWidth = 0, this.resolution = i, this.beginGeometryInstruction1_ = null, this.beginGeometryInstruction2_ = null, this.bufferedMaxExtent_ = null, this.instructions = [], this.coordinates = [], this.tmpCoordinate_ = [], this.hitDetectionInstructions = [], this.state = /** @type {import("../canvas.js").FillStrokeState} */
274
- {};
275
- }
276
- /**
277
- * @protected
278
- * @param {Array<number>} dashArray Dash array.
279
- * @return {Array<number>} Dash array with pixel ratio applied
280
- */
281
- applyPixelRatio(t) {
282
- const e = this.pixelRatio;
283
- return e == 1 ? t : t.map(function(i) {
284
- return i * e;
285
- });
286
- }
287
- /**
288
- * @param {Array<number>} flatCoordinates Flat coordinates.
289
- * @param {number} stride Stride.
290
- * @protected
291
- * @return {number} My end
292
- */
293
- appendFlatPointCoordinates(t, e) {
294
- const i = this.getBufferedMaxExtent(), n = this.tmpCoordinate_, s = this.coordinates;
295
- let o = s.length;
296
- for (let r = 0, l = t.length; r < l; r += e)
297
- n[0] = t[r], n[1] = t[r + 1], ni(i, n) && (s[o++] = n[0], s[o++] = n[1]);
298
- return o;
299
- }
300
- /**
301
- * @param {Array<number>} flatCoordinates Flat coordinates.
302
- * @param {number} offset Offset.
303
- * @param {number} end End.
304
- * @param {number} stride Stride.
305
- * @param {boolean} closed Last input coordinate equals first.
306
- * @param {boolean} skipFirst Skip first coordinate.
307
- * @protected
308
- * @return {number} My end.
309
- */
310
- appendFlatLineCoordinates(t, e, i, n, s, o) {
311
- const r = this.coordinates;
312
- let l = r.length;
313
- const a = this.getBufferedMaxExtent();
314
- o && (e += n);
315
- let h = t[e], d = t[e + 1];
316
- const c = this.tmpCoordinate_;
317
- let f = !0, u, _, p;
318
- for (u = e + n; u < i; u += n)
319
- c[0] = t[u], c[1] = t[u + 1], p = si(a, c), p !== _ ? (f && (r[l++] = h, r[l++] = d, f = !1), r[l++] = c[0], r[l++] = c[1]) : p === oi.INTERSECTING ? (r[l++] = c[0], r[l++] = c[1], f = !1) : f = !0, h = c[0], d = c[1], _ = p;
320
- return (s && f || u === e + n) && (r[l++] = h, r[l++] = d), l;
321
- }
322
- /**
323
- * @param {Array<number>} flatCoordinates Flat coordinates.
324
- * @param {number} offset Offset.
325
- * @param {Array<number>} ends Ends.
326
- * @param {number} stride Stride.
327
- * @param {Array<number>} builderEnds Builder ends.
328
- * @return {number} Offset.
329
- */
330
- drawCustomCoordinates_(t, e, i, n, s) {
331
- for (let o = 0, r = i.length; o < r; ++o) {
332
- const l = i[o], a = this.appendFlatLineCoordinates(
333
- t,
334
- e,
335
- l,
336
- n,
337
- !1,
338
- !1
339
- );
340
- s.push(a), e = l;
341
- }
342
- return e;
343
- }
344
- /**
345
- * @param {import("../../geom/SimpleGeometry.js").default} geometry Geometry.
346
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
347
- * @param {Function} renderer Renderer.
348
- * @param {Function} hitDetectionRenderer Renderer.
349
- */
350
- drawCustom(t, e, i, n) {
351
- this.beginGeometry(t, e);
352
- const s = t.getType(), o = t.getStride(), r = this.coordinates.length;
353
- let l, a, h, d, c;
354
- switch (s) {
355
- case "MultiPolygon":
356
- l = /** @type {import("../../geom/MultiPolygon.js").default} */
357
- t.getOrientedFlatCoordinates(), d = [];
358
- const f = (
359
- /** @type {import("../../geom/MultiPolygon.js").default} */
360
- t.getEndss()
361
- );
362
- c = 0;
363
- for (let u = 0, _ = f.length; u < _; ++u) {
364
- const p = [];
365
- c = this.drawCustomCoordinates_(
366
- l,
367
- c,
368
- f[u],
369
- o,
370
- p
371
- ), d.push(p);
372
- }
373
- this.instructions.push([
374
- I.CUSTOM,
375
- r,
376
- d,
377
- t,
378
- i,
379
- ye
380
- ]), this.hitDetectionInstructions.push([
381
- I.CUSTOM,
382
- r,
383
- d,
384
- t,
385
- n || i,
386
- ye
387
- ]);
388
- break;
389
- case "Polygon":
390
- case "MultiLineString":
391
- h = [], l = s == "Polygon" ? (
392
- /** @type {import("../../geom/Polygon.js").default} */
393
- t.getOrientedFlatCoordinates()
394
- ) : t.getFlatCoordinates(), c = this.drawCustomCoordinates_(
395
- l,
396
- 0,
397
- /** @type {import("../../geom/Polygon.js").default|import("../../geom/MultiLineString.js").default} */
398
- t.getEnds(),
399
- o,
400
- h
401
- ), this.instructions.push([
402
- I.CUSTOM,
403
- r,
404
- h,
405
- t,
406
- i,
407
- me
408
- ]), this.hitDetectionInstructions.push([
409
- I.CUSTOM,
410
- r,
411
- h,
412
- t,
413
- n || i,
414
- me
415
- ]);
416
- break;
417
- case "LineString":
418
- case "Circle":
419
- l = t.getFlatCoordinates(), a = this.appendFlatLineCoordinates(
420
- l,
421
- 0,
422
- l.length,
423
- o,
424
- !1,
425
- !1
426
- ), this.instructions.push([
427
- I.CUSTOM,
428
- r,
429
- a,
430
- t,
431
- i,
432
- bt
433
- ]), this.hitDetectionInstructions.push([
434
- I.CUSTOM,
435
- r,
436
- a,
437
- t,
438
- n || i,
439
- bt
440
- ]);
441
- break;
442
- case "MultiPoint":
443
- l = t.getFlatCoordinates(), a = this.appendFlatPointCoordinates(l, o), a > r && (this.instructions.push([
444
- I.CUSTOM,
445
- r,
446
- a,
447
- t,
448
- i,
449
- bt
450
- ]), this.hitDetectionInstructions.push([
451
- I.CUSTOM,
452
- r,
453
- a,
454
- t,
455
- n || i,
456
- bt
457
- ]));
458
- break;
459
- case "Point":
460
- l = t.getFlatCoordinates(), this.coordinates.push(l[0], l[1]), a = this.coordinates.length, this.instructions.push([
461
- I.CUSTOM,
462
- r,
463
- a,
464
- t,
465
- i
466
- ]), this.hitDetectionInstructions.push([
467
- I.CUSTOM,
468
- r,
469
- a,
470
- t,
471
- n || i
472
- ]);
473
- break;
474
- }
475
- this.endGeometry(e);
476
- }
477
- /**
478
- * @protected
479
- * @param {import("../../geom/Geometry").default|import("../Feature.js").default} geometry The geometry.
480
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
481
- */
482
- beginGeometry(t, e) {
483
- this.beginGeometryInstruction1_ = [
484
- I.BEGIN_GEOMETRY,
485
- e,
486
- 0,
487
- t
488
- ], this.instructions.push(this.beginGeometryInstruction1_), this.beginGeometryInstruction2_ = [
489
- I.BEGIN_GEOMETRY,
490
- e,
491
- 0,
492
- t
493
- ], this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
494
- }
495
- /**
496
- * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
497
- */
498
- finish() {
499
- return {
500
- instructions: this.instructions,
501
- hitDetectionInstructions: this.hitDetectionInstructions,
502
- coordinates: this.coordinates
503
- };
504
- }
505
- /**
506
- * Reverse the hit detection instructions.
507
- */
508
- reverseHitDetectionInstructions() {
509
- const t = this.hitDetectionInstructions;
510
- t.reverse();
511
- let e;
512
- const i = t.length;
513
- let n, s, o = -1;
514
- for (e = 0; e < i; ++e)
515
- n = t[e], s = /** @type {import("./Instruction.js").default} */
516
- n[0], s == I.END_GEOMETRY ? o = e : s == I.BEGIN_GEOMETRY && (n[2] = e, Ri(this.hitDetectionInstructions, o, e), o = -1);
517
- }
518
- /**
519
- * @param {import("../../style/Fill.js").default} fillStyle Fill style.
520
- * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style.
521
- */
522
- setFillStrokeStyle(t, e) {
523
- const i = this.state;
524
- if (t) {
525
- const n = t.getColor();
526
- i.fillStyle = ot(
527
- n || V
528
- );
529
- } else
530
- i.fillStyle = void 0;
531
- if (e) {
532
- const n = e.getColor();
533
- i.strokeStyle = ot(
534
- n || Bt
535
- );
536
- const s = e.getLineCap();
537
- i.lineCap = s !== void 0 ? s : Gt;
538
- const o = e.getLineDash();
539
- i.lineDash = o ? o.slice() : et;
540
- const r = e.getLineDashOffset();
541
- i.lineDashOffset = r || it;
542
- const l = e.getLineJoin();
543
- i.lineJoin = l !== void 0 ? l : Yt;
544
- const a = e.getWidth();
545
- i.lineWidth = a !== void 0 ? a : Xt;
546
- const h = e.getMiterLimit();
547
- i.miterLimit = h !== void 0 ? h : Nt, i.lineWidth > this.maxLineWidth && (this.maxLineWidth = i.lineWidth, this.bufferedMaxExtent_ = null);
548
- } else
549
- i.strokeStyle = void 0, i.lineCap = void 0, i.lineDash = null, i.lineDashOffset = void 0, i.lineJoin = void 0, i.lineWidth = void 0, i.miterLimit = void 0;
550
- }
551
- /**
552
- * @param {import("../canvas.js").FillStrokeState} state State.
553
- * @return {Array<*>} Fill instruction.
554
- */
555
- createFill(t) {
556
- const e = t.fillStyle, i = [I.SET_FILL_STYLE, e];
557
- return typeof e != "string" && i.push(!0), i;
558
- }
559
- /**
560
- * @param {import("../canvas.js").FillStrokeState} state State.
561
- */
562
- applyStroke(t) {
563
- this.instructions.push(this.createStroke(t));
564
- }
565
- /**
566
- * @param {import("../canvas.js").FillStrokeState} state State.
567
- * @return {Array<*>} Stroke instruction.
568
- */
569
- createStroke(t) {
570
- return [
571
- I.SET_STROKE_STYLE,
572
- t.strokeStyle,
573
- t.lineWidth * this.pixelRatio,
574
- t.lineCap,
575
- t.lineJoin,
576
- t.miterLimit,
577
- this.applyPixelRatio(t.lineDash),
578
- t.lineDashOffset * this.pixelRatio
579
- ];
580
- }
581
- /**
582
- * @param {import("../canvas.js").FillStrokeState} state State.
583
- * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState):Array<*>} createFill Create fill.
584
- */
585
- updateFillStyle(t, e) {
586
- const i = t.fillStyle;
587
- (typeof i != "string" || t.currentFillStyle != i) && (i !== void 0 && this.instructions.push(e.call(this, t)), t.currentFillStyle = i);
588
- }
589
- /**
590
- * @param {import("../canvas.js").FillStrokeState} state State.
591
- * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState): void} applyStroke Apply stroke.
592
- */
593
- updateStrokeStyle(t, e) {
594
- const i = t.strokeStyle, n = t.lineCap, s = t.lineDash, o = t.lineDashOffset, r = t.lineJoin, l = t.lineWidth, a = t.miterLimit;
595
- (t.currentStrokeStyle != i || t.currentLineCap != n || s != t.currentLineDash && !Rt(t.currentLineDash, s) || t.currentLineDashOffset != o || t.currentLineJoin != r || t.currentLineWidth != l || t.currentMiterLimit != a) && (i !== void 0 && e.call(this, t), t.currentStrokeStyle = i, t.currentLineCap = n, t.currentLineDash = s, t.currentLineDashOffset = o, t.currentLineJoin = r, t.currentLineWidth = l, t.currentMiterLimit = a);
596
- }
597
- /**
598
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
599
- */
600
- endGeometry(t) {
601
- this.beginGeometryInstruction1_[2] = this.instructions.length, this.beginGeometryInstruction1_ = null, this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length, this.beginGeometryInstruction2_ = null;
602
- const e = [I.END_GEOMETRY, t];
603
- this.instructions.push(e), this.hitDetectionInstructions.push(e);
604
- }
605
- /**
606
- * Get the buffered rendering extent. Rendering will be clipped to the extent
607
- * provided to the constructor. To account for symbolizers that may intersect
608
- * this extent, we calculate a buffered extent (e.g. based on stroke width).
609
- * @return {import("../../extent.js").Extent} The buffered rendering extent.
610
- * @protected
611
- */
612
- getBufferedMaxExtent() {
613
- if (!this.bufferedMaxExtent_ && (this.bufferedMaxExtent_ = ri(this.maxExtent), this.maxLineWidth > 0)) {
614
- const t = this.resolution * (this.maxLineWidth + 1) / 2;
615
- se(this.bufferedMaxExtent_, t, this.bufferedMaxExtent_);
616
- }
617
- return this.bufferedMaxExtent_;
618
- }
619
- }
620
- class Di extends kt {
621
- /**
622
- * @param {number} tolerance Tolerance.
623
- * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
624
- * @param {number} resolution Resolution.
625
- * @param {number} pixelRatio Pixel ratio.
626
- */
627
- constructor(t, e, i, n) {
628
- super(t, e, i, n), this.hitDetectionImage_ = null, this.image_ = null, this.imagePixelRatio_ = void 0, this.anchorX_ = void 0, this.anchorY_ = void 0, this.height_ = void 0, this.opacity_ = void 0, this.originX_ = void 0, this.originY_ = void 0, this.rotateWithView_ = void 0, this.rotation_ = void 0, this.scale_ = void 0, this.width_ = void 0, this.declutterMode_ = void 0, this.declutterImageWithText_ = void 0;
629
- }
630
- /**
631
- * @param {import("../../geom/Point.js").default|import("../Feature.js").default} pointGeometry Point geometry.
632
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
633
- */
634
- drawPoint(t, e) {
635
- if (!this.image_)
636
- return;
637
- this.beginGeometry(t, e);
638
- const i = t.getFlatCoordinates(), n = t.getStride(), s = this.coordinates.length, o = this.appendFlatPointCoordinates(i, n);
639
- this.instructions.push([
640
- I.DRAW_IMAGE,
641
- s,
642
- o,
643
- this.image_,
644
- // Remaining arguments to DRAW_IMAGE are in alphabetical order
645
- this.anchorX_ * this.imagePixelRatio_,
646
- this.anchorY_ * this.imagePixelRatio_,
647
- Math.ceil(this.height_ * this.imagePixelRatio_),
648
- this.opacity_,
649
- this.originX_ * this.imagePixelRatio_,
650
- this.originY_ * this.imagePixelRatio_,
651
- this.rotateWithView_,
652
- this.rotation_,
653
- [
654
- this.scale_[0] * this.pixelRatio / this.imagePixelRatio_,
655
- this.scale_[1] * this.pixelRatio / this.imagePixelRatio_
656
- ],
657
- Math.ceil(this.width_ * this.imagePixelRatio_),
658
- this.declutterMode_,
659
- this.declutterImageWithText_
660
- ]), this.hitDetectionInstructions.push([
661
- I.DRAW_IMAGE,
662
- s,
663
- o,
664
- this.hitDetectionImage_,
665
- // Remaining arguments to DRAW_IMAGE are in alphabetical order
666
- this.anchorX_,
667
- this.anchorY_,
668
- this.height_,
669
- 1,
670
- this.originX_,
671
- this.originY_,
672
- this.rotateWithView_,
673
- this.rotation_,
674
- this.scale_,
675
- this.width_,
676
- this.declutterMode_,
677
- this.declutterImageWithText_
678
- ]), this.endGeometry(e);
679
- }
680
- /**
681
- * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} multiPointGeometry MultiPoint geometry.
682
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
683
- */
684
- drawMultiPoint(t, e) {
685
- if (!this.image_)
686
- return;
687
- this.beginGeometry(t, e);
688
- const i = t.getFlatCoordinates(), n = t.getStride(), s = this.coordinates.length, o = this.appendFlatPointCoordinates(i, n);
689
- this.instructions.push([
690
- I.DRAW_IMAGE,
691
- s,
692
- o,
693
- this.image_,
694
- // Remaining arguments to DRAW_IMAGE are in alphabetical order
695
- this.anchorX_ * this.imagePixelRatio_,
696
- this.anchorY_ * this.imagePixelRatio_,
697
- Math.ceil(this.height_ * this.imagePixelRatio_),
698
- this.opacity_,
699
- this.originX_ * this.imagePixelRatio_,
700
- this.originY_ * this.imagePixelRatio_,
701
- this.rotateWithView_,
702
- this.rotation_,
703
- [
704
- this.scale_[0] * this.pixelRatio / this.imagePixelRatio_,
705
- this.scale_[1] * this.pixelRatio / this.imagePixelRatio_
706
- ],
707
- Math.ceil(this.width_ * this.imagePixelRatio_),
708
- this.declutterMode_,
709
- this.declutterImageWithText_
710
- ]), this.hitDetectionInstructions.push([
711
- I.DRAW_IMAGE,
712
- s,
713
- o,
714
- this.hitDetectionImage_,
715
- // Remaining arguments to DRAW_IMAGE are in alphabetical order
716
- this.anchorX_,
717
- this.anchorY_,
718
- this.height_,
719
- 1,
720
- this.originX_,
721
- this.originY_,
722
- this.rotateWithView_,
723
- this.rotation_,
724
- this.scale_,
725
- this.width_,
726
- this.declutterMode_,
727
- this.declutterImageWithText_
728
- ]), this.endGeometry(e);
729
- }
730
- /**
731
- * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
732
- */
733
- finish() {
734
- return this.reverseHitDetectionInstructions(), this.anchorX_ = void 0, this.anchorY_ = void 0, this.hitDetectionImage_ = null, this.image_ = null, this.imagePixelRatio_ = void 0, this.height_ = void 0, this.scale_ = void 0, this.opacity_ = void 0, this.originX_ = void 0, this.originY_ = void 0, this.rotateWithView_ = void 0, this.rotation_ = void 0, this.width_ = void 0, super.finish();
735
- }
736
- /**
737
- * @param {import("../../style/Image.js").default} imageStyle Image style.
738
- * @param {Object} [sharedData] Shared data.
739
- */
740
- setImageStyle(t, e) {
741
- const i = t.getAnchor(), n = t.getSize(), s = t.getOrigin();
742
- this.imagePixelRatio_ = t.getPixelRatio(this.pixelRatio), this.anchorX_ = i[0], this.anchorY_ = i[1], this.hitDetectionImage_ = t.getHitDetectionImage(), this.image_ = t.getImage(this.pixelRatio), this.height_ = n[1], this.opacity_ = t.getOpacity(), this.originX_ = s[0], this.originY_ = s[1], this.rotateWithView_ = t.getRotateWithView(), this.rotation_ = t.getRotation(), this.scale_ = t.getScaleArray(), this.width_ = n[0], this.declutterMode_ = t.getDeclutterMode(), this.declutterImageWithText_ = e;
743
- }
744
- }
745
- class Oi extends kt {
746
- /**
747
- * @param {number} tolerance Tolerance.
748
- * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
749
- * @param {number} resolution Resolution.
750
- * @param {number} pixelRatio Pixel ratio.
751
- */
752
- constructor(t, e, i, n) {
753
- super(t, e, i, n);
754
- }
755
- /**
756
- * @param {Array<number>} flatCoordinates Flat coordinates.
757
- * @param {number} offset Offset.
758
- * @param {number} end End.
759
- * @param {number} stride Stride.
760
- * @private
761
- * @return {number} end.
762
- */
763
- drawFlatCoordinates_(t, e, i, n) {
764
- const s = this.coordinates.length, o = this.appendFlatLineCoordinates(
765
- t,
766
- e,
767
- i,
768
- n,
769
- !1,
770
- !1
771
- ), r = [
772
- I.MOVE_TO_LINE_TO,
773
- s,
774
- o
775
- ];
776
- return this.instructions.push(r), this.hitDetectionInstructions.push(r), i;
777
- }
778
- /**
779
- * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} lineStringGeometry Line string geometry.
780
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
781
- */
782
- drawLineString(t, e) {
783
- const i = this.state, n = i.strokeStyle, s = i.lineWidth;
784
- if (n === void 0 || s === void 0)
785
- return;
786
- this.updateStrokeStyle(i, this.applyStroke), this.beginGeometry(t, e), this.hitDetectionInstructions.push(
787
- [
788
- I.SET_STROKE_STYLE,
789
- i.strokeStyle,
790
- i.lineWidth,
791
- i.lineCap,
792
- i.lineJoin,
793
- i.miterLimit,
794
- et,
795
- it
796
- ],
797
- at
798
- );
799
- const o = t.getFlatCoordinates(), r = t.getStride();
800
- this.drawFlatCoordinates_(
801
- o,
802
- 0,
803
- o.length,
804
- r
805
- ), this.hitDetectionInstructions.push(rt), this.endGeometry(e);
806
- }
807
- /**
808
- * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} multiLineStringGeometry MultiLineString geometry.
809
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
810
- */
811
- drawMultiLineString(t, e) {
812
- const i = this.state, n = i.strokeStyle, s = i.lineWidth;
813
- if (n === void 0 || s === void 0)
814
- return;
815
- this.updateStrokeStyle(i, this.applyStroke), this.beginGeometry(t, e), this.hitDetectionInstructions.push(
816
- [
817
- I.SET_STROKE_STYLE,
818
- i.strokeStyle,
819
- i.lineWidth,
820
- i.lineCap,
821
- i.lineJoin,
822
- i.miterLimit,
823
- et,
824
- it
825
- ],
826
- at
827
- );
828
- const o = t.getEnds(), r = t.getFlatCoordinates(), l = t.getStride();
829
- let a = 0;
830
- for (let h = 0, d = o.length; h < d; ++h)
831
- a = this.drawFlatCoordinates_(
832
- r,
833
- a,
834
- /** @type {number} */
835
- o[h],
836
- l
837
- );
838
- this.hitDetectionInstructions.push(rt), this.endGeometry(e);
839
- }
840
- /**
841
- * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
842
- */
843
- finish() {
844
- const t = this.state;
845
- return t.lastStroke != null && t.lastStroke != this.coordinates.length && this.instructions.push(rt), this.reverseHitDetectionInstructions(), this.state = null, super.finish();
846
- }
847
- /**
848
- * @param {import("../canvas.js").FillStrokeState} state State.
849
- */
850
- applyStroke(t) {
851
- t.lastStroke != null && t.lastStroke != this.coordinates.length && (this.instructions.push(rt), t.lastStroke = this.coordinates.length), t.lastStroke = 0, super.applyStroke(t), this.instructions.push(at);
852
- }
853
- }
854
- class Ee extends kt {
855
- /**
856
- * @param {number} tolerance Tolerance.
857
- * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
858
- * @param {number} resolution Resolution.
859
- * @param {number} pixelRatio Pixel ratio.
860
- */
861
- constructor(t, e, i, n) {
862
- super(t, e, i, n);
863
- }
864
- /**
865
- * @param {Array<number>} flatCoordinates Flat coordinates.
866
- * @param {number} offset Offset.
867
- * @param {Array<number>} ends Ends.
868
- * @param {number} stride Stride.
869
- * @private
870
- * @return {number} End.
871
- */
872
- drawFlatCoordinatess_(t, e, i, n) {
873
- const s = this.state, o = s.fillStyle !== void 0, r = s.strokeStyle !== void 0, l = i.length;
874
- this.instructions.push(at), this.hitDetectionInstructions.push(at);
875
- for (let a = 0; a < l; ++a) {
876
- const h = i[a], d = this.coordinates.length, c = this.appendFlatLineCoordinates(
877
- t,
878
- e,
879
- h,
880
- n,
881
- !0,
882
- !r
883
- ), f = [
884
- I.MOVE_TO_LINE_TO,
885
- d,
886
- c
887
- ];
888
- this.instructions.push(f), this.hitDetectionInstructions.push(f), r && (this.instructions.push(we), this.hitDetectionInstructions.push(we)), e = h;
889
- }
890
- return o && (this.instructions.push(Pt), this.hitDetectionInstructions.push(Pt)), r && (this.instructions.push(rt), this.hitDetectionInstructions.push(rt)), e;
891
- }
892
- /**
893
- * @param {import("../../geom/Circle.js").default} circleGeometry Circle geometry.
894
- * @param {import("../../Feature.js").default} feature Feature.
895
- */
896
- drawCircle(t, e) {
897
- const i = this.state, n = i.fillStyle, s = i.strokeStyle;
898
- if (n === void 0 && s === void 0)
899
- return;
900
- this.setFillStrokeStyles_(), this.beginGeometry(t, e), i.fillStyle !== void 0 && this.hitDetectionInstructions.push([
901
- I.SET_FILL_STYLE,
902
- V
903
- ]), i.strokeStyle !== void 0 && this.hitDetectionInstructions.push([
904
- I.SET_STROKE_STYLE,
905
- i.strokeStyle,
906
- i.lineWidth,
907
- i.lineCap,
908
- i.lineJoin,
909
- i.miterLimit,
910
- et,
911
- it
912
- ]);
913
- const o = t.getFlatCoordinates(), r = t.getStride(), l = this.coordinates.length;
914
- this.appendFlatLineCoordinates(
915
- o,
916
- 0,
917
- o.length,
918
- r,
919
- !1,
920
- !1
921
- );
922
- const a = [I.CIRCLE, l];
923
- this.instructions.push(at, a), this.hitDetectionInstructions.push(at, a), i.fillStyle !== void 0 && (this.instructions.push(Pt), this.hitDetectionInstructions.push(Pt)), i.strokeStyle !== void 0 && (this.instructions.push(rt), this.hitDetectionInstructions.push(rt)), this.endGeometry(e);
924
- }
925
- /**
926
- * @param {import("../../geom/Polygon.js").default|import("../Feature.js").default} polygonGeometry Polygon geometry.
927
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
928
- */
929
- drawPolygon(t, e) {
930
- const i = this.state, n = i.fillStyle, s = i.strokeStyle;
931
- if (n === void 0 && s === void 0)
932
- return;
933
- this.setFillStrokeStyles_(), this.beginGeometry(t, e), i.fillStyle !== void 0 && this.hitDetectionInstructions.push([
934
- I.SET_FILL_STYLE,
935
- V
936
- ]), i.strokeStyle !== void 0 && this.hitDetectionInstructions.push([
937
- I.SET_STROKE_STYLE,
938
- i.strokeStyle,
939
- i.lineWidth,
940
- i.lineCap,
941
- i.lineJoin,
942
- i.miterLimit,
943
- et,
944
- it
945
- ]);
946
- const o = t.getEnds(), r = t.getOrientedFlatCoordinates(), l = t.getStride();
947
- this.drawFlatCoordinatess_(
948
- r,
949
- 0,
950
- /** @type {Array<number>} */
951
- o,
952
- l
953
- ), this.endGeometry(e);
954
- }
955
- /**
956
- * @param {import("../../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry.
957
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
958
- */
959
- drawMultiPolygon(t, e) {
960
- const i = this.state, n = i.fillStyle, s = i.strokeStyle;
961
- if (n === void 0 && s === void 0)
962
- return;
963
- this.setFillStrokeStyles_(), this.beginGeometry(t, e), i.fillStyle !== void 0 && this.hitDetectionInstructions.push([
964
- I.SET_FILL_STYLE,
965
- V
966
- ]), i.strokeStyle !== void 0 && this.hitDetectionInstructions.push([
967
- I.SET_STROKE_STYLE,
968
- i.strokeStyle,
969
- i.lineWidth,
970
- i.lineCap,
971
- i.lineJoin,
972
- i.miterLimit,
973
- et,
974
- it
975
- ]);
976
- const o = t.getEndss(), r = t.getOrientedFlatCoordinates(), l = t.getStride();
977
- let a = 0;
978
- for (let h = 0, d = o.length; h < d; ++h)
979
- a = this.drawFlatCoordinatess_(
980
- r,
981
- a,
982
- o[h],
983
- l
984
- );
985
- this.endGeometry(e);
986
- }
987
- /**
988
- * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
989
- */
990
- finish() {
991
- this.reverseHitDetectionInstructions(), this.state = null;
992
- const t = this.tolerance;
993
- if (t !== 0) {
994
- const e = this.coordinates;
995
- for (let i = 0, n = e.length; i < n; ++i)
996
- e[i] = li(e[i], t);
997
- }
998
- return super.finish();
999
- }
1000
- /**
1001
- * @private
1002
- */
1003
- setFillStrokeStyles_() {
1004
- const t = this.state;
1005
- t.fillStyle !== void 0 && this.updateFillStyle(t, this.createFill), t.strokeStyle !== void 0 && this.updateStrokeStyle(t, this.applyStroke);
1006
- }
1007
- }
1008
- function bi(g, t, e, i, n) {
1009
- const s = [];
1010
- let o = e, r = 0, l = t.slice(e, 2);
1011
- for (; r < g && o + n < i; ) {
1012
- const [a, h] = l.slice(-2), d = t[o + n], c = t[o + n + 1], f = Math.sqrt(
1013
- (d - a) * (d - a) + (c - h) * (c - h)
1014
- );
1015
- if (r += f, r >= g) {
1016
- const u = (g - r + f) / f, _ = K(a, d, u), p = K(h, c, u);
1017
- l.push(_, p), s.push(l), l = [_, p], r == g && (o += n), r = 0;
1018
- } else if (r < g)
1019
- l.push(
1020
- t[o + n],
1021
- t[o + n + 1]
1022
- ), o += n;
1023
- else {
1024
- const u = f - r, _ = K(a, d, u / f), p = K(h, c, u / f);
1025
- l.push(_, p), s.push(l), l = [_, p], r = 0, o += n;
1026
- }
1027
- }
1028
- return r > 0 && s.push(l), s;
1029
- }
1030
- function Mi(g, t, e, i, n) {
1031
- let s = e, o = e, r = 0, l = 0, a = e, h, d, c, f, u, _, p, x, y, m;
1032
- for (d = e; d < i; d += n) {
1033
- const C = t[d], T = t[d + 1];
1034
- u !== void 0 && (y = C - u, m = T - _, f = Math.sqrt(y * y + m * m), p !== void 0 && (l += c, h = Math.acos((p * y + x * m) / (c * f)), h > g && (l > r && (r = l, s = a, o = d), l = 0, a = d - n)), c = f, p = y, x = m), u = C, _ = T;
1035
- }
1036
- return l += f, l > r ? [a, d] : [s, o];
1037
- }
1038
- const Jt = {
1039
- left: 0,
1040
- center: 0.5,
1041
- right: 1,
1042
- top: 0,
1043
- middle: 0.5,
1044
- hanging: 0.2,
1045
- alphabetic: 0.8,
1046
- ideographic: 0.8,
1047
- bottom: 1
1048
- };
1049
- class Fi extends kt {
1050
- /**
1051
- * @param {number} tolerance Tolerance.
1052
- * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
1053
- * @param {number} resolution Resolution.
1054
- * @param {number} pixelRatio Pixel ratio.
1055
- */
1056
- constructor(t, e, i, n) {
1057
- super(t, e, i, n), this.labels_ = null, this.text_ = "", this.textOffsetX_ = 0, this.textOffsetY_ = 0, this.textRotateWithView_ = void 0, this.textRotation_ = 0, this.textFillState_ = null, this.fillStates = {}, this.fillStates[V] = { fillStyle: V }, this.textStrokeState_ = null, this.strokeStates = {}, this.textState_ = /** @type {import("../canvas.js").TextState} */
1058
- {}, this.textStates = {}, this.textKey_ = "", this.fillKey_ = "", this.strokeKey_ = "", this.declutterImageWithText_ = void 0;
1059
- }
1060
- /**
1061
- * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
1062
- */
1063
- finish() {
1064
- const t = super.finish();
1065
- return t.textStates = this.textStates, t.fillStates = this.fillStates, t.strokeStates = this.strokeStates, t;
1066
- }
1067
- /**
1068
- * @param {import("../../geom/SimpleGeometry.js").default|import("../Feature.js").default} geometry Geometry.
1069
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
1070
- */
1071
- drawText(t, e) {
1072
- const i = this.textFillState_, n = this.textStrokeState_, s = this.textState_;
1073
- if (this.text_ === "" || !s || !i && !n)
1074
- return;
1075
- const o = this.coordinates;
1076
- let r = o.length;
1077
- const l = t.getType();
1078
- let a = null, h = t.getStride();
1079
- if (s.placement === "line" && (l == "LineString" || l == "MultiLineString" || l == "Polygon" || l == "MultiPolygon")) {
1080
- if (!tt(this.getBufferedMaxExtent(), t.getExtent()))
1081
- return;
1082
- let d;
1083
- if (a = t.getFlatCoordinates(), l == "LineString")
1084
- d = [a.length];
1085
- else if (l == "MultiLineString")
1086
- d = /** @type {import("../../geom/MultiLineString.js").default} */
1087
- t.getEnds();
1088
- else if (l == "Polygon")
1089
- d = /** @type {import("../../geom/Polygon.js").default} */
1090
- t.getEnds().slice(0, 1);
1091
- else if (l == "MultiPolygon") {
1092
- const _ = (
1093
- /** @type {import("../../geom/MultiPolygon.js").default} */
1094
- t.getEndss()
1095
- );
1096
- d = [];
1097
- for (let p = 0, x = _.length; p < x; ++p)
1098
- d.push(_[p][0]);
1099
- }
1100
- this.beginGeometry(t, e);
1101
- const c = s.repeat, f = c ? void 0 : s.textAlign;
1102
- let u = 0;
1103
- for (let _ = 0, p = d.length; _ < p; ++_) {
1104
- let x;
1105
- c ? x = bi(
1106
- c * this.resolution,
1107
- a,
1108
- u,
1109
- d[_],
1110
- h
1111
- ) : x = [a.slice(u, d[_])];
1112
- for (let y = 0, m = x.length; y < m; ++y) {
1113
- const C = x[y];
1114
- let T = 0, L = C.length;
1115
- if (f == null) {
1116
- const k = Mi(
1117
- s.maxAngle,
1118
- C,
1119
- 0,
1120
- C.length,
1121
- 2
1122
- );
1123
- T = k[0], L = k[1];
1124
- }
1125
- for (let k = T; k < L; k += h)
1126
- o.push(C[k], C[k + 1]);
1127
- const O = o.length;
1128
- u = d[_], this.drawChars_(r, O), r = O;
1129
- }
1130
- }
1131
- this.endGeometry(e);
1132
- } else {
1133
- let d = s.overflow ? null : [];
1134
- switch (l) {
1135
- case "Point":
1136
- case "MultiPoint":
1137
- a = /** @type {import("../../geom/MultiPoint.js").default} */
1138
- t.getFlatCoordinates();
1139
- break;
1140
- case "LineString":
1141
- a = /** @type {import("../../geom/LineString.js").default} */
1142
- t.getFlatMidpoint();
1143
- break;
1144
- case "Circle":
1145
- a = /** @type {import("../../geom/Circle.js").default} */
1146
- t.getCenter();
1147
- break;
1148
- case "MultiLineString":
1149
- a = /** @type {import("../../geom/MultiLineString.js").default} */
1150
- t.getFlatMidpoints(), h = 2;
1151
- break;
1152
- case "Polygon":
1153
- a = /** @type {import("../../geom/Polygon.js").default} */
1154
- t.getFlatInteriorPoint(), s.overflow || d.push(a[2] / this.resolution), h = 3;
1155
- break;
1156
- case "MultiPolygon":
1157
- const x = (
1158
- /** @type {import("../../geom/MultiPolygon.js").default} */
1159
- t.getFlatInteriorPoints()
1160
- );
1161
- a = [];
1162
- for (let y = 0, m = x.length; y < m; y += 3)
1163
- s.overflow || d.push(x[y + 2] / this.resolution), a.push(x[y], x[y + 1]);
1164
- if (a.length === 0)
1165
- return;
1166
- h = 2;
1167
- break;
1168
- }
1169
- const c = this.appendFlatPointCoordinates(a, h);
1170
- if (c === r)
1171
- return;
1172
- if (d && (c - r) / 2 !== a.length / h) {
1173
- let x = r / 2;
1174
- d = d.filter((y, m) => {
1175
- const C = o[(x + m) * 2] === a[m * h] && o[(x + m) * 2 + 1] === a[m * h + 1];
1176
- return C || --x, C;
1177
- });
1178
- }
1179
- this.saveTextStates_(), (s.backgroundFill || s.backgroundStroke) && (this.setFillStrokeStyle(
1180
- s.backgroundFill,
1181
- s.backgroundStroke
1182
- ), s.backgroundFill && this.updateFillStyle(this.state, this.createFill), s.backgroundStroke && (this.updateStrokeStyle(this.state, this.applyStroke), this.hitDetectionInstructions.push(this.createStroke(this.state)))), this.beginGeometry(t, e);
1183
- let f = s.padding;
1184
- if (f != lt && (s.scale[0] < 0 || s.scale[1] < 0)) {
1185
- let x = s.padding[0], y = s.padding[1], m = s.padding[2], C = s.padding[3];
1186
- s.scale[0] < 0 && (y = -y, C = -C), s.scale[1] < 0 && (x = -x, m = -m), f = [x, y, m, C];
1187
- }
1188
- const u = this.pixelRatio;
1189
- this.instructions.push([
1190
- I.DRAW_IMAGE,
1191
- r,
1192
- c,
1193
- null,
1194
- NaN,
1195
- NaN,
1196
- NaN,
1197
- 1,
1198
- 0,
1199
- 0,
1200
- this.textRotateWithView_,
1201
- this.textRotation_,
1202
- [1, 1],
1203
- NaN,
1204
- void 0,
1205
- this.declutterImageWithText_,
1206
- f == lt ? lt : f.map(function(x) {
1207
- return x * u;
1208
- }),
1209
- !!s.backgroundFill,
1210
- !!s.backgroundStroke,
1211
- this.text_,
1212
- this.textKey_,
1213
- this.strokeKey_,
1214
- this.fillKey_,
1215
- this.textOffsetX_,
1216
- this.textOffsetY_,
1217
- d
1218
- ]);
1219
- const _ = 1 / u, p = this.state.fillStyle;
1220
- s.backgroundFill && (this.state.fillStyle = V, this.hitDetectionInstructions.push(this.createFill(this.state))), this.hitDetectionInstructions.push([
1221
- I.DRAW_IMAGE,
1222
- r,
1223
- c,
1224
- null,
1225
- NaN,
1226
- NaN,
1227
- NaN,
1228
- 1,
1229
- 0,
1230
- 0,
1231
- this.textRotateWithView_,
1232
- this.textRotation_,
1233
- [_, _],
1234
- NaN,
1235
- void 0,
1236
- this.declutterImageWithText_,
1237
- f,
1238
- !!s.backgroundFill,
1239
- !!s.backgroundStroke,
1240
- this.text_,
1241
- this.textKey_,
1242
- this.strokeKey_,
1243
- this.fillKey_ ? V : this.fillKey_,
1244
- this.textOffsetX_,
1245
- this.textOffsetY_,
1246
- d
1247
- ]), s.backgroundFill && (this.state.fillStyle = p, this.hitDetectionInstructions.push(this.createFill(this.state))), this.endGeometry(e);
1248
- }
1249
- }
1250
- /**
1251
- * @private
1252
- */
1253
- saveTextStates_() {
1254
- const t = this.textStrokeState_, e = this.textState_, i = this.textFillState_, n = this.strokeKey_;
1255
- t && (n in this.strokeStates || (this.strokeStates[n] = {
1256
- strokeStyle: t.strokeStyle,
1257
- lineCap: t.lineCap,
1258
- lineDashOffset: t.lineDashOffset,
1259
- lineWidth: t.lineWidth,
1260
- lineJoin: t.lineJoin,
1261
- miterLimit: t.miterLimit,
1262
- lineDash: t.lineDash
1263
- }));
1264
- const s = this.textKey_;
1265
- s in this.textStates || (this.textStates[s] = {
1266
- font: e.font,
1267
- textAlign: e.textAlign || Tt,
1268
- justify: e.justify,
1269
- textBaseline: e.textBaseline || Ht,
1270
- scale: e.scale
1271
- });
1272
- const o = this.fillKey_;
1273
- i && (o in this.fillStates || (this.fillStates[o] = {
1274
- fillStyle: i.fillStyle
1275
- }));
1276
- }
1277
- /**
1278
- * @private
1279
- * @param {number} begin Begin.
1280
- * @param {number} end End.
1281
- */
1282
- drawChars_(t, e) {
1283
- const i = this.textStrokeState_, n = this.textState_, s = this.strokeKey_, o = this.textKey_, r = this.fillKey_;
1284
- this.saveTextStates_();
1285
- const l = this.pixelRatio, a = Jt[n.textBaseline], h = this.textOffsetY_ * l, d = this.text_, c = i ? i.lineWidth * Math.abs(n.scale[0]) / 2 : 0;
1286
- this.instructions.push([
1287
- I.DRAW_CHARS,
1288
- t,
1289
- e,
1290
- a,
1291
- n.overflow,
1292
- r,
1293
- n.maxAngle,
1294
- l,
1295
- h,
1296
- s,
1297
- c * l,
1298
- d,
1299
- o,
1300
- 1
1301
- ]), this.hitDetectionInstructions.push([
1302
- I.DRAW_CHARS,
1303
- t,
1304
- e,
1305
- a,
1306
- n.overflow,
1307
- r && V,
1308
- n.maxAngle,
1309
- 1,
1310
- h,
1311
- s,
1312
- c,
1313
- d,
1314
- o,
1315
- 1 / l
1316
- ]);
1317
- }
1318
- /**
1319
- * @param {import("../../style/Text.js").default} textStyle Text style.
1320
- * @param {Object} [sharedData] Shared data.
1321
- */
1322
- setTextStyle(t, e) {
1323
- let i, n, s;
1324
- if (!t)
1325
- this.text_ = "";
1326
- else {
1327
- const o = t.getFill();
1328
- o ? (n = this.textFillState_, n || (n = /** @type {import("../canvas.js").FillState} */
1329
- {}, this.textFillState_ = n), n.fillStyle = ot(
1330
- o.getColor() || V
1331
- )) : (n = null, this.textFillState_ = n);
1332
- const r = t.getStroke();
1333
- if (!r)
1334
- s = null, this.textStrokeState_ = s;
1335
- else {
1336
- s = this.textStrokeState_, s || (s = /** @type {import("../canvas.js").StrokeState} */
1337
- {}, this.textStrokeState_ = s);
1338
- const u = r.getLineDash(), _ = r.getLineDashOffset(), p = r.getWidth(), x = r.getMiterLimit();
1339
- s.lineCap = r.getLineCap() || Gt, s.lineDash = u ? u.slice() : et, s.lineDashOffset = _ === void 0 ? it : _, s.lineJoin = r.getLineJoin() || Yt, s.lineWidth = p === void 0 ? Xt : p, s.miterLimit = x === void 0 ? Nt : x, s.strokeStyle = ot(
1340
- r.getColor() || Bt
1341
- );
1342
- }
1343
- i = this.textState_;
1344
- const l = t.getFont() || Fe;
1345
- mi(l);
1346
- const a = t.getScaleArray();
1347
- i.overflow = t.getOverflow(), i.font = l, i.maxAngle = t.getMaxAngle(), i.placement = t.getPlacement(), i.textAlign = t.getTextAlign(), i.repeat = t.getRepeat(), i.justify = t.getJustify(), i.textBaseline = t.getTextBaseline() || Ht, i.backgroundFill = t.getBackgroundFill(), i.backgroundStroke = t.getBackgroundStroke(), i.padding = t.getPadding() || lt, i.scale = a === void 0 ? [1, 1] : a;
1348
- const h = t.getOffsetX(), d = t.getOffsetY(), c = t.getRotateWithView(), f = t.getRotation();
1349
- this.text_ = t.getText() || "", this.textOffsetX_ = h === void 0 ? 0 : h, this.textOffsetY_ = d === void 0 ? 0 : d, this.textRotateWithView_ = c === void 0 ? !1 : c, this.textRotation_ = f === void 0 ? 0 : f, this.strokeKey_ = s ? (typeof s.strokeStyle == "string" ? s.strokeStyle : It(s.strokeStyle)) + s.lineCap + s.lineDashOffset + "|" + s.lineWidth + s.lineJoin + s.miterLimit + "[" + s.lineDash.join() + "]" : "", this.textKey_ = i.font + i.scale + (i.textAlign || "?") + (i.repeat || "?") + (i.justify || "?") + (i.textBaseline || "?"), this.fillKey_ = n ? typeof n.fillStyle == "string" ? n.fillStyle : "|" + It(n.fillStyle) : "";
1350
- }
1351
- this.declutterImageWithText_ = e;
1352
- }
1353
- }
1354
- const Wi = {
1355
- Circle: Ee,
1356
- Default: kt,
1357
- Image: Di,
1358
- LineString: Oi,
1359
- Polygon: Ee,
1360
- Text: Fi
1361
- };
1362
- class Le {
1363
- /**
1364
- * @param {number} tolerance Tolerance.
1365
- * @param {import("../../extent.js").Extent} maxExtent Max extent.
1366
- * @param {number} resolution Resolution.
1367
- * @param {number} pixelRatio Pixel ratio.
1368
- */
1369
- constructor(t, e, i, n) {
1370
- this.tolerance_ = t, this.maxExtent_ = e, this.pixelRatio_ = n, this.resolution_ = i, this.buildersByZIndex_ = {};
1371
- }
1372
- /**
1373
- * @return {!Object<string, !Object<import("../canvas.js").BuilderType, import("./Builder.js").SerializableInstructions>>} The serializable instructions
1374
- */
1375
- finish() {
1376
- const t = {};
1377
- for (const e in this.buildersByZIndex_) {
1378
- t[e] = t[e] || {};
1379
- const i = this.buildersByZIndex_[e];
1380
- for (const n in i) {
1381
- const s = i[n].finish();
1382
- t[e][n] = s;
1383
- }
1384
- }
1385
- return t;
1386
- }
1387
- /**
1388
- * @param {number|undefined} zIndex Z index.
1389
- * @param {import("../canvas.js").BuilderType} builderType Replay type.
1390
- * @return {import("../VectorContext.js").default} Replay.
1391
- */
1392
- getBuilder(t, e) {
1393
- const i = t !== void 0 ? t.toString() : "0";
1394
- let n = this.buildersByZIndex_[i];
1395
- n === void 0 && (n = {}, this.buildersByZIndex_[i] = n);
1396
- let s = n[e];
1397
- if (s === void 0) {
1398
- const o = Wi[e];
1399
- s = new o(
1400
- this.tolerance_,
1401
- this.maxExtent_,
1402
- this.resolution_,
1403
- this.pixelRatio_
1404
- ), n[e] = s;
1405
- }
1406
- return s;
1407
- }
1408
- }
1409
- function Pi(g, t, e, i, n, s, o, r, l, a, h, d) {
1410
- let c = g[t], f = g[t + 1], u = 0, _ = 0, p = 0, x = 0;
1411
- function y() {
1412
- u = c, _ = f, t += i, c = g[t], f = g[t + 1], x += p, p = Math.sqrt((c - u) * (c - u) + (f - _) * (f - _));
1413
- }
1414
- do
1415
- y();
1416
- while (t < e - i && x + p < s);
1417
- let m = p === 0 ? 0 : (s - x) / p;
1418
- const C = K(u, c, m), T = K(_, f, m), L = t - i, O = x, k = s + r * l(a, n, h);
1419
- for (; t < e - i && x + p < k; )
1420
- y();
1421
- m = p === 0 ? 0 : (k - x) / p;
1422
- const D = K(u, c, m), b = K(_, f, m);
1423
- let P;
1424
- if (d) {
1425
- const E = [C, T, D, b];
1426
- ai(E, 0, 4, 2, d, E, E), P = E[0] > E[2];
1427
- } else
1428
- P = C > D;
1429
- const W = Math.PI, F = [], Y = L + i === t;
1430
- t = L, p = 0, x = O, c = g[t], f = g[t + 1];
1431
- let R;
1432
- if (Y) {
1433
- y(), R = Math.atan2(f - _, c - u), P && (R += R > 0 ? -W : W);
1434
- const E = (D + C) / 2, w = (b + T) / 2;
1435
- return F[0] = [E, w, (k - s) / 2, R, n], F;
1436
- }
1437
- n = n.replace(/\n/g, " ");
1438
- for (let E = 0, w = n.length; E < w; ) {
1439
- y();
1440
- let M = Math.atan2(f - _, c - u);
1441
- if (P && (M += M > 0 ? -W : W), R !== void 0) {
1442
- let j = M - R;
1443
- if (j += j > W ? -2 * W : j < -W ? 2 * W : 0, Math.abs(j) > o)
1444
- return null;
1445
- }
1446
- R = M;
1447
- const v = E;
1448
- let A = 0;
1449
- for (; E < w; ++E) {
1450
- const j = P ? w - E - 1 : E, ct = r * l(a, n[j], h);
1451
- if (t + i < e && x + p < s + A + ct / 2)
1452
- break;
1453
- A += ct;
1454
- }
1455
- if (E === v)
1456
- continue;
1457
- const Z = P ? n.substring(w - v, w - E) : n.substring(v, E);
1458
- m = p === 0 ? 0 : (s + A / 2 - x) / p;
1459
- const S = K(u, c, m), oe = K(_, f, m);
1460
- F.push([S, oe, A / 2, M, Z]), s += A;
1461
- }
1462
- return F;
1463
- }
1464
- const ft = At(), nt = [], $ = [], Q = [], st = [];
1465
- function De(g) {
1466
- return g[3].declutterBox;
1467
- }
1468
- const Oe = new RegExp(
1469
- /* eslint-disable prettier/prettier */
1470
- "[֑-ࣿיִ-﷿ﹰ-ﻼࠀ-࿿-]"
1471
- /* eslint-enable prettier/prettier */
1472
- );
1473
- function Qt(g, t) {
1474
- return t === "start" ? t = Oe.test(g) ? "right" : "left" : t === "end" && (t = Oe.test(g) ? "left" : "right"), Jt[t];
1475
- }
1476
- function vi(g, t, e) {
1477
- return e > 0 && g.push(`
1478
- `, ""), g.push(t, ""), g;
1479
- }
1480
- class Ai {
1481
- /**
1482
- * @param {number} resolution Resolution.
1483
- * @param {number} pixelRatio Pixel ratio.
1484
- * @param {boolean} overlaps The replay can have overlapping geometries.
1485
- * @param {import("../canvas.js").SerializableInstructions} instructions The serializable instructions
1486
- */
1487
- constructor(t, e, i, n) {
1488
- this.overlaps = i, this.pixelRatio = e, this.resolution = t, this.alignFill_, this.instructions = n.instructions, this.coordinates = n.coordinates, this.coordinateCache_ = {}, this.renderedTransform_ = ht(), this.hitDetectionInstructions = n.hitDetectionInstructions, this.pixelCoordinates_ = null, this.viewRotation_ = 0, this.fillStates = n.fillStates || {}, this.strokeStates = n.strokeStates || {}, this.textStates = n.textStates || {}, this.widths_ = {}, this.labels_ = {};
1489
- }
1490
- /**
1491
- * @param {string|Array<string>} text Text.
1492
- * @param {string} textKey Text style key.
1493
- * @param {string} fillKey Fill style key.
1494
- * @param {string} strokeKey Stroke style key.
1495
- * @return {import("../canvas.js").Label} Label.
1496
- */
1497
- createLabel(t, e, i, n) {
1498
- const s = t + e + i + n;
1499
- if (this.labels_[s])
1500
- return this.labels_[s];
1501
- const o = n ? this.strokeStates[n] : null, r = i ? this.fillStates[i] : null, l = this.textStates[e], a = this.pixelRatio, h = [
1502
- l.scale[0] * a,
1503
- l.scale[1] * a
1504
- ], d = Array.isArray(t), c = l.justify ? Jt[l.justify] : Qt(
1505
- Array.isArray(t) ? t[0] : t,
1506
- l.textAlign || Tt
1507
- ), f = n && o.lineWidth ? o.lineWidth : 0, u = d ? t : t.split(`
1508
- `).reduce(vi, []), { width: _, height: p, widths: x, heights: y, lineWidths: m } = yi(
1509
- l,
1510
- u
1511
- ), C = _ + f, T = [], L = (C + 2) * h[0], O = (p + f) * h[1], k = {
1512
- width: L < 0 ? Math.floor(L) : Math.ceil(L),
1513
- height: O < 0 ? Math.floor(O) : Math.ceil(O),
1514
- contextInstructions: T
1515
- };
1516
- (h[0] != 1 || h[1] != 1) && T.push("scale", h), n && (T.push("strokeStyle", o.strokeStyle), T.push("lineWidth", f), T.push("lineCap", o.lineCap), T.push("lineJoin", o.lineJoin), T.push("miterLimit", o.miterLimit), T.push("setLineDash", [o.lineDash]), T.push("lineDashOffset", o.lineDashOffset)), i && T.push("fillStyle", r.fillStyle), T.push("textBaseline", "middle"), T.push("textAlign", "center");
1517
- const D = 0.5 - c;
1518
- let b = c * C + D * f;
1519
- const P = [], W = [];
1520
- let F = 0, Y = 0, R = 0, E = 0, w;
1521
- for (let M = 0, v = u.length; M < v; M += 2) {
1522
- const A = u[M];
1523
- if (A === `
1524
- `) {
1525
- Y += F, F = 0, b = c * C + D * f, ++E;
1526
- continue;
1527
- }
1528
- const Z = u[M + 1] || l.font;
1529
- Z !== w && (n && P.push("font", Z), i && W.push("font", Z), w = Z), F = Math.max(F, y[R]);
1530
- const S = [
1531
- A,
1532
- b + D * x[R] + c * (x[R] - m[E]),
1533
- 0.5 * (f + F) + Y
1534
- ];
1535
- b += x[R], n && P.push("strokeText", S), i && W.push("fillText", S), ++R;
1536
- }
1537
- return Array.prototype.push.apply(T, P), Array.prototype.push.apply(T, W), this.labels_[s] = k, k;
1538
- }
1539
- /**
1540
- * @param {CanvasRenderingContext2D} context Context.
1541
- * @param {import("../../coordinate.js").Coordinate} p1 1st point of the background box.
1542
- * @param {import("../../coordinate.js").Coordinate} p2 2nd point of the background box.
1543
- * @param {import("../../coordinate.js").Coordinate} p3 3rd point of the background box.
1544
- * @param {import("../../coordinate.js").Coordinate} p4 4th point of the background box.
1545
- * @param {Array<*>} fillInstruction Fill instruction.
1546
- * @param {Array<*>} strokeInstruction Stroke instruction.
1547
- */
1548
- replayTextBackground_(t, e, i, n, s, o, r) {
1549
- t.beginPath(), t.moveTo.apply(t, e), t.lineTo.apply(t, i), t.lineTo.apply(t, n), t.lineTo.apply(t, s), t.lineTo.apply(t, e), o && (this.alignFill_ = /** @type {boolean} */
1550
- o[2], this.fill_(t)), r && (this.setStrokeStyle_(
1551
- t,
1552
- /** @type {Array<*>} */
1553
- r
1554
- ), t.stroke());
1555
- }
1556
- /**
1557
- * @private
1558
- * @param {number} sheetWidth Width of the sprite sheet.
1559
- * @param {number} sheetHeight Height of the sprite sheet.
1560
- * @param {number} centerX X.
1561
- * @param {number} centerY Y.
1562
- * @param {number} width Width.
1563
- * @param {number} height Height.
1564
- * @param {number} anchorX Anchor X.
1565
- * @param {number} anchorY Anchor Y.
1566
- * @param {number} originX Origin X.
1567
- * @param {number} originY Origin Y.
1568
- * @param {number} rotation Rotation.
1569
- * @param {import("../../size.js").Size} scale Scale.
1570
- * @param {boolean} snapToPixel Snap to pixel.
1571
- * @param {Array<number>} padding Padding.
1572
- * @param {boolean} fillStroke Background fill or stroke.
1573
- * @param {import("../../Feature.js").FeatureLike} feature Feature.
1574
- * @return {ImageOrLabelDimensions} Dimensions for positioning and decluttering the image or label.
1575
- */
1576
- calculateImageOrLabelDimensions_(t, e, i, n, s, o, r, l, a, h, d, c, f, u, _, p) {
1577
- r *= c[0], l *= c[1];
1578
- let x = i - r, y = n - l;
1579
- const m = s + a > t ? t - a : s, C = o + h > e ? e - h : o, T = u[3] + m * c[0] + u[1], L = u[0] + C * c[1] + u[2], O = x - u[3], k = y - u[0];
1580
- (_ || d !== 0) && (nt[0] = O, st[0] = O, nt[1] = k, $[1] = k, $[0] = O + T, Q[0] = $[0], Q[1] = k + L, st[1] = Q[1]);
1581
- let D;
1582
- return d !== 0 ? (D = Vt(
1583
- ht(),
1584
- i,
1585
- n,
1586
- 1,
1587
- 1,
1588
- d,
1589
- -i,
1590
- -n
1591
- ), G(D, nt), G(D, $), G(D, Q), G(D, st), Ce(
1592
- Math.min(nt[0], $[0], Q[0], st[0]),
1593
- Math.min(nt[1], $[1], Q[1], st[1]),
1594
- Math.max(nt[0], $[0], Q[0], st[0]),
1595
- Math.max(nt[1], $[1], Q[1], st[1]),
1596
- ft
1597
- )) : Ce(
1598
- Math.min(O, O + T),
1599
- Math.min(k, k + L),
1600
- Math.max(O, O + T),
1601
- Math.max(k, k + L),
1602
- ft
1603
- ), f && (x = Math.round(x), y = Math.round(y)), {
1604
- drawImageX: x,
1605
- drawImageY: y,
1606
- drawImageW: m,
1607
- drawImageH: C,
1608
- originX: a,
1609
- originY: h,
1610
- declutterBox: {
1611
- minX: ft[0],
1612
- minY: ft[1],
1613
- maxX: ft[2],
1614
- maxY: ft[3],
1615
- value: p
1616
- },
1617
- canvasTransform: D,
1618
- scale: c
1619
- };
1620
- }
1621
- /**
1622
- * @private
1623
- * @param {CanvasRenderingContext2D} context Context.
1624
- * @param {number} contextScale Scale of the context.
1625
- * @param {import("../canvas.js").Label|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} imageOrLabel Image.
1626
- * @param {ImageOrLabelDimensions} dimensions Dimensions.
1627
- * @param {number} opacity Opacity.
1628
- * @param {Array<*>} fillInstruction Fill instruction.
1629
- * @param {Array<*>} strokeInstruction Stroke instruction.
1630
- * @return {boolean} The image or label was rendered.
1631
- */
1632
- replayImageOrLabel_(t, e, i, n, s, o, r) {
1633
- const l = !!(o || r), a = n.declutterBox, h = t.canvas, d = r ? r[2] * n.scale[0] / 2 : 0;
1634
- return a.minX - d <= h.width / e && a.maxX + d >= 0 && a.minY - d <= h.height / e && a.maxY + d >= 0 && (l && this.replayTextBackground_(
1635
- t,
1636
- nt,
1637
- $,
1638
- Q,
1639
- st,
1640
- /** @type {Array<*>} */
1641
- o,
1642
- /** @type {Array<*>} */
1643
- r
1644
- ), Ci(
1645
- t,
1646
- n.canvasTransform,
1647
- s,
1648
- i,
1649
- n.originX,
1650
- n.originY,
1651
- n.drawImageW,
1652
- n.drawImageH,
1653
- n.drawImageX,
1654
- n.drawImageY,
1655
- n.scale
1656
- )), !0;
1657
- }
1658
- /**
1659
- * @private
1660
- * @param {CanvasRenderingContext2D} context Context.
1661
- */
1662
- fill_(t) {
1663
- if (this.alignFill_) {
1664
- const e = G(this.renderedTransform_, [0, 0]), i = 512 * this.pixelRatio;
1665
- t.save(), t.translate(e[0] % i, e[1] % i), t.rotate(this.viewRotation_);
1666
- }
1667
- t.fill(), this.alignFill_ && t.restore();
1668
- }
1669
- /**
1670
- * @private
1671
- * @param {CanvasRenderingContext2D} context Context.
1672
- * @param {Array<*>} instruction Instruction.
1673
- */
1674
- setStrokeStyle_(t, e) {
1675
- t.strokeStyle = /** @type {import("../../colorlike.js").ColorLike} */
1676
- e[1], t.lineWidth = /** @type {number} */
1677
- e[2], t.lineCap = /** @type {CanvasLineCap} */
1678
- e[3], t.lineJoin = /** @type {CanvasLineJoin} */
1679
- e[4], t.miterLimit = /** @type {number} */
1680
- e[5], t.lineDashOffset = /** @type {number} */
1681
- e[7], t.setLineDash(
1682
- /** @type {Array<number>} */
1683
- e[6]
1684
- );
1685
- }
1686
- /**
1687
- * @private
1688
- * @param {string|Array<string>} text The text to draw.
1689
- * @param {string} textKey The key of the text state.
1690
- * @param {string} strokeKey The key for the stroke state.
1691
- * @param {string} fillKey The key for the fill state.
1692
- * @return {{label: import("../canvas.js").Label, anchorX: number, anchorY: number}} The text image and its anchor.
1693
- */
1694
- drawLabelWithPointPlacement_(t, e, i, n) {
1695
- const s = this.textStates[e], o = this.createLabel(t, e, n, i), r = this.strokeStates[i], l = this.pixelRatio, a = Qt(
1696
- Array.isArray(t) ? t[0] : t,
1697
- s.textAlign || Tt
1698
- ), h = Jt[s.textBaseline || Ht], d = r && r.lineWidth ? r.lineWidth : 0, c = o.width / l - 2 * s.scale[0], f = a * c + 2 * (0.5 - a) * d, u = h * o.height / l + 2 * (0.5 - h) * d;
1699
- return {
1700
- label: o,
1701
- anchorX: f,
1702
- anchorY: u
1703
- };
1704
- }
1705
- /**
1706
- * @private
1707
- * @param {CanvasRenderingContext2D} context Context.
1708
- * @param {number} contextScale Scale of the context.
1709
- * @param {import("../../transform.js").Transform} transform Transform.
1710
- * @param {Array<*>} instructions Instructions array.
1711
- * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
1712
- * @param {FeatureCallback<T>} [featureCallback] Feature callback.
1713
- * @param {import("../../extent.js").Extent} [hitExtent] Only check
1714
- * features that intersect this extent.
1715
- * @param {import("rbush").default} [declutterTree] Declutter tree.
1716
- * @return {T|undefined} Callback result.
1717
- * @template T
1718
- */
1719
- execute_(t, e, i, n, s, o, r, l) {
1720
- let a;
1721
- this.pixelCoordinates_ && Rt(i, this.renderedTransform_) ? a = this.pixelCoordinates_ : (this.pixelCoordinates_ || (this.pixelCoordinates_ = []), a = yt(
1722
- this.coordinates,
1723
- 0,
1724
- this.coordinates.length,
1725
- 2,
1726
- i,
1727
- this.pixelCoordinates_
1728
- ), hi(this.renderedTransform_, i));
1729
- let h = 0;
1730
- const d = n.length;
1731
- let c = 0, f, u, _, p, x, y, m, C, T, L, O, k, D = 0, b = 0, P = null, W = null;
1732
- const F = this.coordinateCache_, Y = this.viewRotation_, R = Math.round(Math.atan2(-i[1], i[0]) * 1e12) / 1e12, E = (
1733
- /** @type {import("../../render.js").State} */
1734
- {
1735
- context: t,
1736
- pixelRatio: this.pixelRatio,
1737
- resolution: this.resolution,
1738
- rotation: Y
1739
- }
1740
- ), w = this.instructions != n || this.overlaps ? 0 : 200;
1741
- let M, v, A, Z;
1742
- for (; h < d; ) {
1743
- const S = n[h];
1744
- switch (
1745
- /** @type {import("./Instruction.js").default} */
1746
- S[0]
1747
- ) {
1748
- case I.BEGIN_GEOMETRY:
1749
- M = /** @type {import("../../Feature.js").FeatureLike} */
1750
- S[1], Z = S[3], M.getGeometry() ? r !== void 0 && !tt(r, Z.getExtent()) ? h = /** @type {number} */
1751
- S[2] + 1 : ++h : h = /** @type {number} */
1752
- S[2];
1753
- break;
1754
- case I.BEGIN_PATH:
1755
- D > w && (this.fill_(t), D = 0), b > w && (t.stroke(), b = 0), !D && !b && (t.beginPath(), p = NaN, x = NaN), ++h;
1756
- break;
1757
- case I.CIRCLE:
1758
- c = /** @type {number} */
1759
- S[1];
1760
- const j = a[c], ct = a[c + 1], Ae = a[c + 2], Be = a[c + 3], re = Ae - j, le = Be - ct, ae = Math.sqrt(re * re + le * le);
1761
- t.moveTo(j + ae, ct), t.arc(j, ct, ae, 0, 2 * Math.PI, !0), ++h;
1762
- break;
1763
- case I.CLOSE_PATH:
1764
- t.closePath(), ++h;
1765
- break;
1766
- case I.CUSTOM:
1767
- c = /** @type {number} */
1768
- S[1], f = S[2];
1769
- const Ge = (
1770
- /** @type {import("../../geom/SimpleGeometry.js").default} */
1771
- S[3]
1772
- ), Ye = S[4], he = S.length == 6 ? S[5] : void 0;
1773
- E.geometry = Ge, E.feature = M, h in F || (F[h] = []);
1774
- const _t = F[h];
1775
- he ? he(a, c, f, 2, _t) : (_t[0] = a[c], _t[1] = a[c + 1], _t.length = 2), Ye(_t, E), ++h;
1776
- break;
1777
- case I.DRAW_IMAGE:
1778
- c = /** @type {number} */
1779
- S[1], f = /** @type {number} */
1780
- S[2], C = /** @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} */
1781
- S[3], u = /** @type {number} */
1782
- S[4], _ = /** @type {number} */
1783
- S[5];
1784
- let Zt = (
1785
- /** @type {number} */
1786
- S[6]
1787
- );
1788
- const Xe = (
1789
- /** @type {number} */
1790
- S[7]
1791
- ), Ne = (
1792
- /** @type {number} */
1793
- S[8]
1794
- ), He = (
1795
- /** @type {number} */
1796
- S[9]
1797
- ), ce = (
1798
- /** @type {boolean} */
1799
- S[10]
1800
- );
1801
- let jt = (
1802
- /** @type {number} */
1803
- S[11]
1804
- );
1805
- const Je = (
1806
- /** @type {import("../../size.js").Size} */
1807
- S[12]
1808
- );
1809
- let wt = (
1810
- /** @type {number} */
1811
- S[13]
1812
- );
1813
- const de = (
1814
- /** @type {"declutter"|"obstacle"|"none"|undefined} */
1815
- S[14]
1816
- ), xt = (
1817
- /** @type {import("../canvas.js").DeclutterImageWithText} */
1818
- S[15]
1819
- );
1820
- if (!C && S.length >= 20) {
1821
- T = /** @type {string} */
1822
- S[19], L = /** @type {string} */
1823
- S[20], O = /** @type {string} */
1824
- S[21], k = /** @type {string} */
1825
- S[22];
1826
- const X = this.drawLabelWithPointPlacement_(
1827
- T,
1828
- L,
1829
- O,
1830
- k
1831
- );
1832
- C = X.label, S[3] = C;
1833
- const dt = (
1834
- /** @type {number} */
1835
- S[23]
1836
- );
1837
- u = (X.anchorX - dt) * this.pixelRatio, S[4] = u;
1838
- const H = (
1839
- /** @type {number} */
1840
- S[24]
1841
- );
1842
- _ = (X.anchorY - H) * this.pixelRatio, S[5] = _, Zt = C.height, S[6] = Zt, wt = C.width, S[13] = wt;
1843
- }
1844
- let Kt;
1845
- S.length > 25 && (Kt = /** @type {number} */
1846
- S[25]);
1847
- let zt, Et, Lt;
1848
- S.length > 17 ? (zt = /** @type {Array<number>} */
1849
- S[16], Et = /** @type {boolean} */
1850
- S[17], Lt = /** @type {boolean} */
1851
- S[18]) : (zt = lt, Et = !1, Lt = !1), ce && R ? jt += Y : !ce && !R && (jt -= Y);
1852
- let Ve = 0;
1853
- for (; c < f; c += 2) {
1854
- if (Kt && Kt[Ve++] < wt / this.pixelRatio)
1855
- continue;
1856
- const X = this.calculateImageOrLabelDimensions_(
1857
- C.width,
1858
- C.height,
1859
- a[c],
1860
- a[c + 1],
1861
- wt,
1862
- Zt,
1863
- u,
1864
- _,
1865
- Ne,
1866
- He,
1867
- jt,
1868
- Je,
1869
- s,
1870
- zt,
1871
- Et || Lt,
1872
- M
1873
- ), dt = [
1874
- t,
1875
- e,
1876
- C,
1877
- X,
1878
- Xe,
1879
- Et ? (
1880
- /** @type {Array<*>} */
1881
- P
1882
- ) : null,
1883
- Lt ? (
1884
- /** @type {Array<*>} */
1885
- W
1886
- ) : null
1887
- ];
1888
- if (l) {
1889
- if (de === "none")
1890
- continue;
1891
- if (de === "obstacle") {
1892
- l.insert(X.declutterBox);
1893
- continue;
1894
- } else {
1895
- let H, q;
1896
- if (xt) {
1897
- const N = f - c;
1898
- if (!xt[N]) {
1899
- xt[N] = dt;
1900
- continue;
1901
- }
1902
- if (H = xt[N], delete xt[N], q = De(H), l.collides(q))
1903
- continue;
1904
- }
1905
- if (l.collides(X.declutterBox))
1906
- continue;
1907
- H && (l.insert(q), this.replayImageOrLabel_.apply(this, H)), l.insert(X.declutterBox);
1908
- }
1909
- }
1910
- this.replayImageOrLabel_.apply(this, dt);
1911
- }
1912
- ++h;
1913
- break;
1914
- case I.DRAW_CHARS:
1915
- const fe = (
1916
- /** @type {number} */
1917
- S[1]
1918
- ), ue = (
1919
- /** @type {number} */
1920
- S[2]
1921
- ), qt = (
1922
- /** @type {number} */
1923
- S[3]
1924
- ), Ze = (
1925
- /** @type {number} */
1926
- S[4]
1927
- );
1928
- k = /** @type {string} */
1929
- S[5];
1930
- const je = (
1931
- /** @type {number} */
1932
- S[6]
1933
- ), ge = (
1934
- /** @type {number} */
1935
- S[7]
1936
- ), _e = (
1937
- /** @type {number} */
1938
- S[8]
1939
- );
1940
- O = /** @type {string} */
1941
- S[9];
1942
- const Ut = (
1943
- /** @type {number} */
1944
- S[10]
1945
- );
1946
- T = /** @type {string} */
1947
- S[11], L = /** @type {string} */
1948
- S[12];
1949
- const xe = [
1950
- /** @type {number} */
1951
- S[13],
1952
- /** @type {number} */
1953
- S[13]
1954
- ], $t = this.textStates[L], pt = $t.font, St = [
1955
- $t.scale[0] * ge,
1956
- $t.scale[1] * ge
1957
- ];
1958
- let mt;
1959
- pt in this.widths_ ? mt = this.widths_[pt] : (mt = {}, this.widths_[pt] = mt);
1960
- const pe = Ue(a, fe, ue, 2), Se = Math.abs(St[0]) * Ie(pt, T, mt);
1961
- if (Ze || Se <= pe) {
1962
- const X = this.textStates[L].textAlign, dt = (pe - Se) * Qt(T, X), H = Pi(
1963
- a,
1964
- fe,
1965
- ue,
1966
- 2,
1967
- T,
1968
- dt,
1969
- je,
1970
- Math.abs(St[0]),
1971
- Ie,
1972
- pt,
1973
- mt,
1974
- R ? 0 : this.viewRotation_
1975
- );
1976
- t: if (H) {
1977
- const q = [];
1978
- let N, Dt, Ot, B, J;
1979
- if (O)
1980
- for (N = 0, Dt = H.length; N < Dt; ++N) {
1981
- J = H[N], Ot = /** @type {string} */
1982
- J[4], B = this.createLabel(Ot, L, "", O), u = /** @type {number} */
1983
- J[2] + (St[0] < 0 ? -Ut : Ut), _ = qt * B.height + (0.5 - qt) * 2 * Ut * St[1] / St[0] - _e;
1984
- const U = this.calculateImageOrLabelDimensions_(
1985
- B.width,
1986
- B.height,
1987
- J[0],
1988
- J[1],
1989
- B.width,
1990
- B.height,
1991
- u,
1992
- _,
1993
- 0,
1994
- 0,
1995
- J[3],
1996
- xe,
1997
- !1,
1998
- lt,
1999
- !1,
2000
- M
2001
- );
2002
- if (l && l.collides(U.declutterBox))
2003
- break t;
2004
- q.push([
2005
- t,
2006
- e,
2007
- B,
2008
- U,
2009
- 1,
2010
- null,
2011
- null
2012
- ]);
2013
- }
2014
- if (k)
2015
- for (N = 0, Dt = H.length; N < Dt; ++N) {
2016
- J = H[N], Ot = /** @type {string} */
2017
- J[4], B = this.createLabel(Ot, L, k, ""), u = /** @type {number} */
2018
- J[2], _ = qt * B.height - _e;
2019
- const U = this.calculateImageOrLabelDimensions_(
2020
- B.width,
2021
- B.height,
2022
- J[0],
2023
- J[1],
2024
- B.width,
2025
- B.height,
2026
- u,
2027
- _,
2028
- 0,
2029
- 0,
2030
- J[3],
2031
- xe,
2032
- !1,
2033
- lt,
2034
- !1,
2035
- M
2036
- );
2037
- if (l && l.collides(U.declutterBox))
2038
- break t;
2039
- q.push([
2040
- t,
2041
- e,
2042
- B,
2043
- U,
2044
- 1,
2045
- null,
2046
- null
2047
- ]);
2048
- }
2049
- l && l.load(q.map(De));
2050
- for (let U = 0, Ke = q.length; U < Ke; ++U)
2051
- this.replayImageOrLabel_.apply(this, q[U]);
2052
- }
2053
- }
2054
- ++h;
2055
- break;
2056
- case I.END_GEOMETRY:
2057
- if (o !== void 0) {
2058
- M = /** @type {import("../../Feature.js").FeatureLike} */
2059
- S[1];
2060
- const X = o(M, Z);
2061
- if (X)
2062
- return X;
2063
- }
2064
- ++h;
2065
- break;
2066
- case I.FILL:
2067
- w ? D++ : this.fill_(t), ++h;
2068
- break;
2069
- case I.MOVE_TO_LINE_TO:
2070
- for (c = /** @type {number} */
2071
- S[1], f = /** @type {number} */
2072
- S[2], v = a[c], A = a[c + 1], y = v + 0.5 | 0, m = A + 0.5 | 0, (y !== p || m !== x) && (t.moveTo(v, A), p = y, x = m), c += 2; c < f; c += 2)
2073
- v = a[c], A = a[c + 1], y = v + 0.5 | 0, m = A + 0.5 | 0, (c == f - 2 || y !== p || m !== x) && (t.lineTo(v, A), p = y, x = m);
2074
- ++h;
2075
- break;
2076
- case I.SET_FILL_STYLE:
2077
- P = S, this.alignFill_ = S[2], D && (this.fill_(t), D = 0, b && (t.stroke(), b = 0)), t.fillStyle = /** @type {import("../../colorlike.js").ColorLike} */
2078
- S[1], ++h;
2079
- break;
2080
- case I.SET_STROKE_STYLE:
2081
- W = S, b && (t.stroke(), b = 0), this.setStrokeStyle_(
2082
- t,
2083
- /** @type {Array<*>} */
2084
- S
2085
- ), ++h;
2086
- break;
2087
- case I.STROKE:
2088
- w ? b++ : t.stroke(), ++h;
2089
- break;
2090
- default:
2091
- ++h;
2092
- break;
2093
- }
2094
- }
2095
- D && this.fill_(t), b && t.stroke();
2096
- }
2097
- /**
2098
- * @param {CanvasRenderingContext2D} context Context.
2099
- * @param {number} contextScale Scale of the context.
2100
- * @param {import("../../transform.js").Transform} transform Transform.
2101
- * @param {number} viewRotation View rotation.
2102
- * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
2103
- * @param {import("rbush").default} [declutterTree] Declutter tree.
2104
- */
2105
- execute(t, e, i, n, s, o) {
2106
- this.viewRotation_ = n, this.execute_(
2107
- t,
2108
- e,
2109
- i,
2110
- this.instructions,
2111
- s,
2112
- void 0,
2113
- void 0,
2114
- o
2115
- );
2116
- }
2117
- /**
2118
- * @param {CanvasRenderingContext2D} context Context.
2119
- * @param {import("../../transform.js").Transform} transform Transform.
2120
- * @param {number} viewRotation View rotation.
2121
- * @param {FeatureCallback<T>} [featureCallback] Feature callback.
2122
- * @param {import("../../extent.js").Extent} [hitExtent] Only check
2123
- * features that intersect this extent.
2124
- * @return {T|undefined} Callback result.
2125
- * @template T
2126
- */
2127
- executeHitDetection(t, e, i, n, s) {
2128
- return this.viewRotation_ = i, this.execute_(
2129
- t,
2130
- 1,
2131
- e,
2132
- this.hitDetectionInstructions,
2133
- !0,
2134
- n,
2135
- s
2136
- );
2137
- }
2138
- }
2139
- const te = ["Polygon", "Circle", "LineString", "Image", "Text", "Default"];
2140
- class be {
2141
- /**
2142
- * @param {import("../../extent.js").Extent} maxExtent Max extent for clipping. When a
2143
- * `maxExtent` was set on the Builder for this executor group, the same `maxExtent`
2144
- * should be set here, unless the target context does not exceed that extent (which
2145
- * can be the case when rendering to tiles).
2146
- * @param {number} resolution Resolution.
2147
- * @param {number} pixelRatio Pixel ratio.
2148
- * @param {boolean} overlaps The executor group can have overlapping geometries.
2149
- * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions
2150
- * The serializable instructions.
2151
- * @param {number} [renderBuffer] Optional rendering buffer.
2152
- */
2153
- constructor(t, e, i, n, s, o) {
2154
- this.maxExtent_ = t, this.overlaps_ = n, this.pixelRatio_ = i, this.resolution_ = e, this.renderBuffer_ = o, this.executorsByZIndex_ = {}, this.hitDetectionContext_ = null, this.hitDetectionTransform_ = ht(), this.createExecutors_(s);
2155
- }
2156
- /**
2157
- * @param {CanvasRenderingContext2D} context Context.
2158
- * @param {import("../../transform.js").Transform} transform Transform.
2159
- */
2160
- clip(t, e) {
2161
- const i = this.getClipCoords(e);
2162
- t.beginPath(), t.moveTo(i[0], i[1]), t.lineTo(i[2], i[3]), t.lineTo(i[4], i[5]), t.lineTo(i[6], i[7]), t.clip();
2163
- }
2164
- /**
2165
- * Create executors and populate them using the provided instructions.
2166
- * @private
2167
- * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions The serializable instructions
2168
- */
2169
- createExecutors_(t) {
2170
- for (const e in t) {
2171
- let i = this.executorsByZIndex_[e];
2172
- i === void 0 && (i = {}, this.executorsByZIndex_[e] = i);
2173
- const n = t[e];
2174
- for (const s in n) {
2175
- const o = n[s];
2176
- i[s] = new Ai(
2177
- this.resolution_,
2178
- this.pixelRatio_,
2179
- this.overlaps_,
2180
- o
2181
- );
2182
- }
2183
- }
2184
- }
2185
- /**
2186
- * @param {Array<import("../canvas.js").BuilderType>} executors Executors.
2187
- * @return {boolean} Has executors of the provided types.
2188
- */
2189
- hasExecutors(t) {
2190
- for (const e in this.executorsByZIndex_) {
2191
- const i = this.executorsByZIndex_[e];
2192
- for (let n = 0, s = t.length; n < s; ++n)
2193
- if (t[n] in i)
2194
- return !0;
2195
- }
2196
- return !1;
2197
- }
2198
- /**
2199
- * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
2200
- * @param {number} resolution Resolution.
2201
- * @param {number} rotation Rotation.
2202
- * @param {number} hitTolerance Hit tolerance in pixels.
2203
- * @param {function(import("../../Feature.js").FeatureLike, import("../../geom/SimpleGeometry.js").default, number): T} callback Feature callback.
2204
- * @param {Array<import("../../Feature.js").FeatureLike>} declutteredFeatures Decluttered features.
2205
- * @return {T|undefined} Callback result.
2206
- * @template T
2207
- */
2208
- forEachFeatureAtCoordinate(t, e, i, n, s, o) {
2209
- n = Math.round(n);
2210
- const r = n * 2 + 1, l = Vt(
2211
- this.hitDetectionTransform_,
2212
- n + 0.5,
2213
- n + 0.5,
2214
- 1 / e,
2215
- -1 / e,
2216
- -i,
2217
- -t[0],
2218
- -t[1]
2219
- ), a = !this.hitDetectionContext_;
2220
- a && (this.hitDetectionContext_ = gt(
2221
- r,
2222
- r,
2223
- void 0,
2224
- { willReadFrequently: !0 }
2225
- ));
2226
- const h = this.hitDetectionContext_;
2227
- h.canvas.width !== r || h.canvas.height !== r ? (h.canvas.width = r, h.canvas.height = r) : a || h.clearRect(0, 0, r, r);
2228
- let d;
2229
- this.renderBuffer_ !== void 0 && (d = At(), ci(d, t), se(
2230
- d,
2231
- e * (this.renderBuffer_ + n),
2232
- d
2233
- ));
2234
- const c = Bi(n);
2235
- let f;
2236
- function u(T, L) {
2237
- const O = h.getImageData(
2238
- 0,
2239
- 0,
2240
- r,
2241
- r
2242
- ).data;
2243
- for (let k = 0, D = c.length; k < D; k++)
2244
- if (O[c[k]] > 0) {
2245
- if (!o || f !== "Image" && f !== "Text" || o.includes(T)) {
2246
- const b = (c[k] - 3) / 4, P = n - b % r, W = n - (b / r | 0), F = s(T, L, P * P + W * W);
2247
- if (F)
2248
- return F;
2249
- }
2250
- h.clearRect(0, 0, r, r);
2251
- break;
2252
- }
2253
- }
2254
- const _ = Object.keys(this.executorsByZIndex_).map(Number);
2255
- _.sort(ie);
2256
- let p, x, y, m, C;
2257
- for (p = _.length - 1; p >= 0; --p) {
2258
- const T = _[p].toString();
2259
- for (y = this.executorsByZIndex_[T], x = te.length - 1; x >= 0; --x)
2260
- if (f = te[x], m = y[f], m !== void 0 && (C = m.executeHitDetection(
2261
- h,
2262
- l,
2263
- i,
2264
- u,
2265
- d
2266
- ), C))
2267
- return C;
2268
- }
2269
- }
2270
- /**
2271
- * @param {import("../../transform.js").Transform} transform Transform.
2272
- * @return {Array<number>|null} Clip coordinates.
2273
- */
2274
- getClipCoords(t) {
2275
- const e = this.maxExtent_;
2276
- if (!e)
2277
- return null;
2278
- const i = e[0], n = e[1], s = e[2], o = e[3], r = [i, n, i, o, s, o, s, n];
2279
- return yt(r, 0, 8, 2, t, r), r;
2280
- }
2281
- /**
2282
- * @return {boolean} Is empty.
2283
- */
2284
- isEmpty() {
2285
- return ki(this.executorsByZIndex_);
2286
- }
2287
- /**
2288
- * @param {CanvasRenderingContext2D} context Context.
2289
- * @param {number} contextScale Scale of the context.
2290
- * @param {import("../../transform.js").Transform} transform Transform.
2291
- * @param {number} viewRotation View rotation.
2292
- * @param {boolean} snapToPixel Snap point symbols and test to integer pixel.
2293
- * @param {Array<import("../canvas.js").BuilderType>} [builderTypes] Ordered replay types to replay.
2294
- * Default is {@link module:ol/render/replay~ORDER}
2295
- * @param {import("rbush").default} [declutterTree] Declutter tree.
2296
- */
2297
- execute(t, e, i, n, s, o, r) {
2298
- const l = Object.keys(this.executorsByZIndex_).map(Number);
2299
- l.sort(ie), this.maxExtent_ && (t.save(), this.clip(t, i)), o = o || te;
2300
- let a, h, d, c, f, u;
2301
- for (r && l.reverse(), a = 0, h = l.length; a < h; ++a) {
2302
- const _ = l[a].toString();
2303
- for (f = this.executorsByZIndex_[_], d = 0, c = o.length; d < c; ++d) {
2304
- const p = o[d];
2305
- u = f[p], u !== void 0 && u.execute(
2306
- t,
2307
- e,
2308
- i,
2309
- n,
2310
- s,
2311
- r
2312
- );
2313
- }
2314
- }
2315
- this.maxExtent_ && t.restore();
2316
- }
2317
- }
2318
- const ee = {};
2319
- function Bi(g) {
2320
- if (ee[g] !== void 0)
2321
- return ee[g];
2322
- const t = g * 2 + 1, e = g * g, i = new Array(e + 1);
2323
- for (let s = 0; s <= g; ++s)
2324
- for (let o = 0; o <= g; ++o) {
2325
- const r = s * s + o * o;
2326
- if (r > e)
2327
- break;
2328
- let l = i[r];
2329
- l || (l = [], i[r] = l), l.push(((g + s) * t + (g + o)) * 4 + 3), s > 0 && l.push(((g - s) * t + (g + o)) * 4 + 3), o > 0 && (l.push(((g + s) * t + (g - o)) * 4 + 3), s > 0 && l.push(((g - s) * t + (g - o)) * 4 + 3));
2330
- }
2331
- const n = [];
2332
- for (let s = 0, o = i.length; s < o; ++s)
2333
- i[s] && n.push(...i[s]);
2334
- return ee[g] = n, n;
2335
- }
2336
- class Gi extends We {
2337
- /**
2338
- * @param {CanvasRenderingContext2D} context Context.
2339
- * @param {number} pixelRatio Pixel ratio.
2340
- * @param {import("../../extent.js").Extent} extent Extent.
2341
- * @param {import("../../transform.js").Transform} transform Transform.
2342
- * @param {number} viewRotation View rotation.
2343
- * @param {number} [squaredTolerance] Optional squared tolerance for simplification.
2344
- * @param {import("../../proj.js").TransformFunction} [userTransform] Transform from user to view projection.
2345
- */
2346
- constructor(t, e, i, n, s, o, r) {
2347
- super(), this.context_ = t, this.pixelRatio_ = e, this.extent_ = i, this.transform_ = n, this.transformRotation_ = n ? wi(Math.atan2(n[1], n[0]), 10) : 0, this.viewRotation_ = s, this.squaredTolerance_ = o, this.userTransform_ = r, this.contextFillState_ = null, this.contextStrokeState_ = null, this.contextTextState_ = null, this.fillState_ = null, this.strokeState_ = null, this.image_ = null, this.imageAnchorX_ = 0, this.imageAnchorY_ = 0, this.imageHeight_ = 0, this.imageOpacity_ = 0, this.imageOriginX_ = 0, this.imageOriginY_ = 0, this.imageRotateWithView_ = !1, this.imageRotation_ = 0, this.imageScale_ = [0, 0], this.imageWidth_ = 0, this.text_ = "", this.textOffsetX_ = 0, this.textOffsetY_ = 0, this.textRotateWithView_ = !1, this.textRotation_ = 0, this.textScale_ = [0, 0], this.textFillState_ = null, this.textStrokeState_ = null, this.textState_ = null, this.pixelCoordinates_ = [], this.tmpLocalTransform_ = ht();
2348
- }
2349
- /**
2350
- * @param {Array<number>} flatCoordinates Flat coordinates.
2351
- * @param {number} offset Offset.
2352
- * @param {number} end End.
2353
- * @param {number} stride Stride.
2354
- * @private
2355
- */
2356
- drawImages_(t, e, i, n) {
2357
- if (!this.image_)
2358
- return;
2359
- const s = yt(
2360
- t,
2361
- e,
2362
- i,
2363
- n,
2364
- this.transform_,
2365
- this.pixelCoordinates_
2366
- ), o = this.context_, r = this.tmpLocalTransform_, l = o.globalAlpha;
2367
- this.imageOpacity_ != 1 && (o.globalAlpha = l * this.imageOpacity_);
2368
- let a = this.imageRotation_;
2369
- this.transformRotation_ === 0 && (a -= this.viewRotation_), this.imageRotateWithView_ && (a += this.viewRotation_);
2370
- for (let h = 0, d = s.length; h < d; h += 2) {
2371
- const c = s[h] - this.imageAnchorX_, f = s[h + 1] - this.imageAnchorY_;
2372
- if (a !== 0 || this.imageScale_[0] != 1 || this.imageScale_[1] != 1) {
2373
- const u = c + this.imageAnchorX_, _ = f + this.imageAnchorY_;
2374
- Vt(
2375
- r,
2376
- u,
2377
- _,
2378
- 1,
2379
- 1,
2380
- a,
2381
- -u,
2382
- -_
2383
- ), o.setTransform.apply(o, r), o.translate(u, _), o.scale(this.imageScale_[0], this.imageScale_[1]), o.drawImage(
2384
- this.image_,
2385
- this.imageOriginX_,
2386
- this.imageOriginY_,
2387
- this.imageWidth_,
2388
- this.imageHeight_,
2389
- -this.imageAnchorX_,
2390
- -this.imageAnchorY_,
2391
- this.imageWidth_,
2392
- this.imageHeight_
2393
- ), o.setTransform(1, 0, 0, 1, 0, 0);
2394
- } else
2395
- o.drawImage(
2396
- this.image_,
2397
- this.imageOriginX_,
2398
- this.imageOriginY_,
2399
- this.imageWidth_,
2400
- this.imageHeight_,
2401
- c,
2402
- f,
2403
- this.imageWidth_,
2404
- this.imageHeight_
2405
- );
2406
- }
2407
- this.imageOpacity_ != 1 && (o.globalAlpha = l);
2408
- }
2409
- /**
2410
- * @param {Array<number>} flatCoordinates Flat coordinates.
2411
- * @param {number} offset Offset.
2412
- * @param {number} end End.
2413
- * @param {number} stride Stride.
2414
- * @private
2415
- */
2416
- drawText_(t, e, i, n) {
2417
- if (!this.textState_ || this.text_ === "")
2418
- return;
2419
- this.textFillState_ && this.setContextFillState_(this.textFillState_), this.textStrokeState_ && this.setContextStrokeState_(this.textStrokeState_), this.setContextTextState_(this.textState_);
2420
- const s = yt(
2421
- t,
2422
- e,
2423
- i,
2424
- n,
2425
- this.transform_,
2426
- this.pixelCoordinates_
2427
- ), o = this.context_;
2428
- let r = this.textRotation_;
2429
- for (this.transformRotation_ === 0 && (r -= this.viewRotation_), this.textRotateWithView_ && (r += this.viewRotation_); e < i; e += n) {
2430
- const l = s[e] + this.textOffsetX_, a = s[e + 1] + this.textOffsetY_;
2431
- r !== 0 || this.textScale_[0] != 1 || this.textScale_[1] != 1 ? (o.translate(l - this.textOffsetX_, a - this.textOffsetY_), o.rotate(r), o.translate(this.textOffsetX_, this.textOffsetY_), o.scale(this.textScale_[0], this.textScale_[1]), this.textStrokeState_ && o.strokeText(this.text_, 0, 0), this.textFillState_ && o.fillText(this.text_, 0, 0), o.setTransform(1, 0, 0, 1, 0, 0)) : (this.textStrokeState_ && o.strokeText(this.text_, l, a), this.textFillState_ && o.fillText(this.text_, l, a));
2432
- }
2433
- }
2434
- /**
2435
- * @param {Array<number>} flatCoordinates Flat coordinates.
2436
- * @param {number} offset Offset.
2437
- * @param {number} end End.
2438
- * @param {number} stride Stride.
2439
- * @param {boolean} close Close.
2440
- * @private
2441
- * @return {number} end End.
2442
- */
2443
- moveToLineTo_(t, e, i, n, s) {
2444
- const o = this.context_, r = yt(
2445
- t,
2446
- e,
2447
- i,
2448
- n,
2449
- this.transform_,
2450
- this.pixelCoordinates_
2451
- );
2452
- o.moveTo(r[0], r[1]);
2453
- let l = r.length;
2454
- s && (l -= 2);
2455
- for (let a = 2; a < l; a += 2)
2456
- o.lineTo(r[a], r[a + 1]);
2457
- return s && o.closePath(), i;
2458
- }
2459
- /**
2460
- * @param {Array<number>} flatCoordinates Flat coordinates.
2461
- * @param {number} offset Offset.
2462
- * @param {Array<number>} ends Ends.
2463
- * @param {number} stride Stride.
2464
- * @private
2465
- * @return {number} End.
2466
- */
2467
- drawRings_(t, e, i, n) {
2468
- for (let s = 0, o = i.length; s < o; ++s)
2469
- e = this.moveToLineTo_(
2470
- t,
2471
- e,
2472
- i[s],
2473
- n,
2474
- !0
2475
- );
2476
- return e;
2477
- }
2478
- /**
2479
- * Render a circle geometry into the canvas. Rendering is immediate and uses
2480
- * the current fill and stroke styles.
2481
- *
2482
- * @param {import("../../geom/Circle.js").default} geometry Circle geometry.
2483
- * @api
2484
- */
2485
- drawCircle(t) {
2486
- if (this.squaredTolerance_ && (t = /** @type {import("../../geom/Circle.js").default} */
2487
- t.simplifyTransformed(
2488
- this.squaredTolerance_,
2489
- this.userTransform_
2490
- )), !!tt(this.extent_, t.getExtent())) {
2491
- if (this.fillState_ || this.strokeState_) {
2492
- this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_);
2493
- const e = di(
2494
- t,
2495
- this.transform_,
2496
- this.pixelCoordinates_
2497
- ), i = e[2] - e[0], n = e[3] - e[1], s = Math.sqrt(i * i + n * n), o = this.context_;
2498
- o.beginPath(), o.arc(
2499
- e[0],
2500
- e[1],
2501
- s,
2502
- 0,
2503
- 2 * Math.PI
2504
- ), this.fillState_ && o.fill(), this.strokeState_ && o.stroke();
2505
- }
2506
- this.text_ !== "" && this.drawText_(t.getCenter(), 0, 2, 2);
2507
- }
2508
- }
2509
- /**
2510
- * Set the rendering style. Note that since this is an immediate rendering API,
2511
- * any `zIndex` on the provided style will be ignored.
2512
- *
2513
- * @param {import("../../style/Style.js").default} style The rendering style.
2514
- * @api
2515
- */
2516
- setStyle(t) {
2517
- this.setFillStrokeStyle(t.getFill(), t.getStroke()), this.setImageStyle(t.getImage()), this.setTextStyle(t.getText());
2518
- }
2519
- /**
2520
- * @param {import("../../transform.js").Transform} transform Transform.
2521
- */
2522
- setTransform(t) {
2523
- this.transform_ = t;
2524
- }
2525
- /**
2526
- * Render a geometry into the canvas. Call
2527
- * {@link module:ol/render/canvas/Immediate~CanvasImmediateRenderer#setStyle renderer.setStyle()} first to set the rendering style.
2528
- *
2529
- * @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry The geometry to render.
2530
- * @api
2531
- */
2532
- drawGeometry(t) {
2533
- switch (t.getType()) {
2534
- case "Point":
2535
- this.drawPoint(
2536
- /** @type {import("../../geom/Point.js").default} */
2537
- t
2538
- );
2539
- break;
2540
- case "LineString":
2541
- this.drawLineString(
2542
- /** @type {import("../../geom/LineString.js").default} */
2543
- t
2544
- );
2545
- break;
2546
- case "Polygon":
2547
- this.drawPolygon(
2548
- /** @type {import("../../geom/Polygon.js").default} */
2549
- t
2550
- );
2551
- break;
2552
- case "MultiPoint":
2553
- this.drawMultiPoint(
2554
- /** @type {import("../../geom/MultiPoint.js").default} */
2555
- t
2556
- );
2557
- break;
2558
- case "MultiLineString":
2559
- this.drawMultiLineString(
2560
- /** @type {import("../../geom/MultiLineString.js").default} */
2561
- t
2562
- );
2563
- break;
2564
- case "MultiPolygon":
2565
- this.drawMultiPolygon(
2566
- /** @type {import("../../geom/MultiPolygon.js").default} */
2567
- t
2568
- );
2569
- break;
2570
- case "GeometryCollection":
2571
- this.drawGeometryCollection(
2572
- /** @type {import("../../geom/GeometryCollection.js").default} */
2573
- t
2574
- );
2575
- break;
2576
- case "Circle":
2577
- this.drawCircle(
2578
- /** @type {import("../../geom/Circle.js").default} */
2579
- t
2580
- );
2581
- break;
2582
- }
2583
- }
2584
- /**
2585
- * Render a feature into the canvas. Note that any `zIndex` on the provided
2586
- * style will be ignored - features are rendered immediately in the order that
2587
- * this method is called. If you need `zIndex` support, you should be using an
2588
- * {@link module:ol/layer/Vector~VectorLayer} instead.
2589
- *
2590
- * @param {import("../../Feature.js").default} feature Feature.
2591
- * @param {import("../../style/Style.js").default} style Style.
2592
- * @api
2593
- */
2594
- drawFeature(t, e) {
2595
- const i = e.getGeometryFunction()(t);
2596
- i && (this.setStyle(e), this.drawGeometry(i));
2597
- }
2598
- /**
2599
- * Render a GeometryCollection to the canvas. Rendering is immediate and
2600
- * uses the current styles appropriate for each geometry in the collection.
2601
- *
2602
- * @param {import("../../geom/GeometryCollection.js").default} geometry Geometry collection.
2603
- */
2604
- drawGeometryCollection(t) {
2605
- const e = t.getGeometriesArray();
2606
- for (let i = 0, n = e.length; i < n; ++i)
2607
- this.drawGeometry(e[i]);
2608
- }
2609
- /**
2610
- * Render a Point geometry into the canvas. Rendering is immediate and uses
2611
- * the current style.
2612
- *
2613
- * @param {import("../../geom/Point.js").default|import("../Feature.js").default} geometry Point geometry.
2614
- */
2615
- drawPoint(t) {
2616
- this.squaredTolerance_ && (t = /** @type {import("../../geom/Point.js").default} */
2617
- t.simplifyTransformed(
2618
- this.squaredTolerance_,
2619
- this.userTransform_
2620
- ));
2621
- const e = t.getFlatCoordinates(), i = t.getStride();
2622
- this.image_ && this.drawImages_(e, 0, e.length, i), this.text_ !== "" && this.drawText_(e, 0, e.length, i);
2623
- }
2624
- /**
2625
- * Render a MultiPoint geometry into the canvas. Rendering is immediate and
2626
- * uses the current style.
2627
- *
2628
- * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} geometry MultiPoint geometry.
2629
- */
2630
- drawMultiPoint(t) {
2631
- this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiPoint.js").default} */
2632
- t.simplifyTransformed(
2633
- this.squaredTolerance_,
2634
- this.userTransform_
2635
- ));
2636
- const e = t.getFlatCoordinates(), i = t.getStride();
2637
- this.image_ && this.drawImages_(e, 0, e.length, i), this.text_ !== "" && this.drawText_(e, 0, e.length, i);
2638
- }
2639
- /**
2640
- * Render a LineString into the canvas. Rendering is immediate and uses
2641
- * the current style.
2642
- *
2643
- * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} geometry LineString geometry.
2644
- */
2645
- drawLineString(t) {
2646
- if (this.squaredTolerance_ && (t = /** @type {import("../../geom/LineString.js").default} */
2647
- t.simplifyTransformed(
2648
- this.squaredTolerance_,
2649
- this.userTransform_
2650
- )), !!tt(this.extent_, t.getExtent())) {
2651
- if (this.strokeState_) {
2652
- this.setContextStrokeState_(this.strokeState_);
2653
- const e = this.context_, i = t.getFlatCoordinates();
2654
- e.beginPath(), this.moveToLineTo_(
2655
- i,
2656
- 0,
2657
- i.length,
2658
- t.getStride(),
2659
- !1
2660
- ), e.stroke();
2661
- }
2662
- if (this.text_ !== "") {
2663
- const e = t.getFlatMidpoint();
2664
- this.drawText_(e, 0, 2, 2);
2665
- }
2666
- }
2667
- }
2668
- /**
2669
- * Render a MultiLineString geometry into the canvas. Rendering is immediate
2670
- * and uses the current style.
2671
- *
2672
- * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} geometry MultiLineString geometry.
2673
- */
2674
- drawMultiLineString(t) {
2675
- this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiLineString.js").default} */
2676
- t.simplifyTransformed(
2677
- this.squaredTolerance_,
2678
- this.userTransform_
2679
- ));
2680
- const e = t.getExtent();
2681
- if (tt(this.extent_, e)) {
2682
- if (this.strokeState_) {
2683
- this.setContextStrokeState_(this.strokeState_);
2684
- const i = this.context_, n = t.getFlatCoordinates();
2685
- let s = 0;
2686
- const o = (
2687
- /** @type {Array<number>} */
2688
- t.getEnds()
2689
- ), r = t.getStride();
2690
- i.beginPath();
2691
- for (let l = 0, a = o.length; l < a; ++l)
2692
- s = this.moveToLineTo_(
2693
- n,
2694
- s,
2695
- o[l],
2696
- r,
2697
- !1
2698
- );
2699
- i.stroke();
2700
- }
2701
- if (this.text_ !== "") {
2702
- const i = t.getFlatMidpoints();
2703
- this.drawText_(i, 0, i.length, 2);
2704
- }
2705
- }
2706
- }
2707
- /**
2708
- * Render a Polygon geometry into the canvas. Rendering is immediate and uses
2709
- * the current style.
2710
- *
2711
- * @param {import("../../geom/Polygon.js").default|import("../Feature.js").default} geometry Polygon geometry.
2712
- */
2713
- drawPolygon(t) {
2714
- if (this.squaredTolerance_ && (t = /** @type {import("../../geom/Polygon.js").default} */
2715
- t.simplifyTransformed(
2716
- this.squaredTolerance_,
2717
- this.userTransform_
2718
- )), !!tt(this.extent_, t.getExtent())) {
2719
- if (this.strokeState_ || this.fillState_) {
2720
- this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_);
2721
- const e = this.context_;
2722
- e.beginPath(), this.drawRings_(
2723
- t.getOrientedFlatCoordinates(),
2724
- 0,
2725
- /** @type {Array<number>} */
2726
- t.getEnds(),
2727
- t.getStride()
2728
- ), this.fillState_ && e.fill(), this.strokeState_ && e.stroke();
2729
- }
2730
- if (this.text_ !== "") {
2731
- const e = t.getFlatInteriorPoint();
2732
- this.drawText_(e, 0, 2, 2);
2733
- }
2734
- }
2735
- }
2736
- /**
2737
- * Render MultiPolygon geometry into the canvas. Rendering is immediate and
2738
- * uses the current style.
2739
- * @param {import("../../geom/MultiPolygon.js").default} geometry MultiPolygon geometry.
2740
- */
2741
- drawMultiPolygon(t) {
2742
- if (this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiPolygon.js").default} */
2743
- t.simplifyTransformed(
2744
- this.squaredTolerance_,
2745
- this.userTransform_
2746
- )), !!tt(this.extent_, t.getExtent())) {
2747
- if (this.strokeState_ || this.fillState_) {
2748
- this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_);
2749
- const e = this.context_, i = t.getOrientedFlatCoordinates();
2750
- let n = 0;
2751
- const s = t.getEndss(), o = t.getStride();
2752
- e.beginPath();
2753
- for (let r = 0, l = s.length; r < l; ++r) {
2754
- const a = s[r];
2755
- n = this.drawRings_(i, n, a, o);
2756
- }
2757
- this.fillState_ && e.fill(), this.strokeState_ && e.stroke();
2758
- }
2759
- if (this.text_ !== "") {
2760
- const e = t.getFlatInteriorPoints();
2761
- this.drawText_(e, 0, e.length, 2);
2762
- }
2763
- }
2764
- }
2765
- /**
2766
- * @param {import("../canvas.js").FillState} fillState Fill state.
2767
- * @private
2768
- */
2769
- setContextFillState_(t) {
2770
- const e = this.context_, i = this.contextFillState_;
2771
- i ? i.fillStyle != t.fillStyle && (i.fillStyle = t.fillStyle, e.fillStyle = t.fillStyle) : (e.fillStyle = t.fillStyle, this.contextFillState_ = {
2772
- fillStyle: t.fillStyle
2773
- });
2774
- }
2775
- /**
2776
- * @param {import("../canvas.js").StrokeState} strokeState Stroke state.
2777
- * @private
2778
- */
2779
- setContextStrokeState_(t) {
2780
- const e = this.context_, i = this.contextStrokeState_;
2781
- i ? (i.lineCap != t.lineCap && (i.lineCap = t.lineCap, e.lineCap = t.lineCap), Rt(i.lineDash, t.lineDash) || e.setLineDash(
2782
- i.lineDash = t.lineDash
2783
- ), i.lineDashOffset != t.lineDashOffset && (i.lineDashOffset = t.lineDashOffset, e.lineDashOffset = t.lineDashOffset), i.lineJoin != t.lineJoin && (i.lineJoin = t.lineJoin, e.lineJoin = t.lineJoin), i.lineWidth != t.lineWidth && (i.lineWidth = t.lineWidth, e.lineWidth = t.lineWidth), i.miterLimit != t.miterLimit && (i.miterLimit = t.miterLimit, e.miterLimit = t.miterLimit), i.strokeStyle != t.strokeStyle && (i.strokeStyle = t.strokeStyle, e.strokeStyle = t.strokeStyle)) : (e.lineCap = t.lineCap, e.setLineDash(t.lineDash), e.lineDashOffset = t.lineDashOffset, e.lineJoin = t.lineJoin, e.lineWidth = t.lineWidth, e.miterLimit = t.miterLimit, e.strokeStyle = t.strokeStyle, this.contextStrokeState_ = {
2784
- lineCap: t.lineCap,
2785
- lineDash: t.lineDash,
2786
- lineDashOffset: t.lineDashOffset,
2787
- lineJoin: t.lineJoin,
2788
- lineWidth: t.lineWidth,
2789
- miterLimit: t.miterLimit,
2790
- strokeStyle: t.strokeStyle
2791
- });
2792
- }
2793
- /**
2794
- * @param {import("../canvas.js").TextState} textState Text state.
2795
- * @private
2796
- */
2797
- setContextTextState_(t) {
2798
- const e = this.context_, i = this.contextTextState_, n = t.textAlign ? t.textAlign : Tt;
2799
- i ? (i.font != t.font && (i.font = t.font, e.font = t.font), i.textAlign != n && (i.textAlign = n, e.textAlign = n), i.textBaseline != t.textBaseline && (i.textBaseline = t.textBaseline, e.textBaseline = t.textBaseline)) : (e.font = t.font, e.textAlign = n, e.textBaseline = t.textBaseline, this.contextTextState_ = {
2800
- font: t.font,
2801
- textAlign: n,
2802
- textBaseline: t.textBaseline
2803
- });
2804
- }
2805
- /**
2806
- * Set the fill and stroke style for subsequent draw operations. To clear
2807
- * either fill or stroke styles, pass null for the appropriate parameter.
2808
- *
2809
- * @param {import("../../style/Fill.js").default} fillStyle Fill style.
2810
- * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style.
2811
- */
2812
- setFillStrokeStyle(t, e) {
2813
- if (!t)
2814
- this.fillState_ = null;
2815
- else {
2816
- const i = t.getColor();
2817
- this.fillState_ = {
2818
- fillStyle: ot(
2819
- i || V
2820
- )
2821
- };
2822
- }
2823
- if (!e)
2824
- this.strokeState_ = null;
2825
- else {
2826
- const i = e.getColor(), n = e.getLineCap(), s = e.getLineDash(), o = e.getLineDashOffset(), r = e.getLineJoin(), l = e.getWidth(), a = e.getMiterLimit(), h = s || et;
2827
- this.strokeState_ = {
2828
- lineCap: n !== void 0 ? n : Gt,
2829
- lineDash: this.pixelRatio_ === 1 ? h : h.map((d) => d * this.pixelRatio_),
2830
- lineDashOffset: (o || it) * this.pixelRatio_,
2831
- lineJoin: r !== void 0 ? r : Yt,
2832
- lineWidth: (l !== void 0 ? l : Xt) * this.pixelRatio_,
2833
- miterLimit: a !== void 0 ? a : Nt,
2834
- strokeStyle: ot(
2835
- i || Bt
2836
- )
2837
- };
2838
- }
2839
- }
2840
- /**
2841
- * Set the image style for subsequent draw operations. Pass null to remove
2842
- * the image style.
2843
- *
2844
- * @param {import("../../style/Image.js").default} imageStyle Image style.
2845
- */
2846
- setImageStyle(t) {
2847
- let e;
2848
- if (!t || !(e = t.getSize())) {
2849
- this.image_ = null;
2850
- return;
2851
- }
2852
- const i = t.getPixelRatio(this.pixelRatio_), n = t.getAnchor(), s = t.getOrigin();
2853
- this.image_ = t.getImage(this.pixelRatio_), this.imageAnchorX_ = n[0] * i, this.imageAnchorY_ = n[1] * i, this.imageHeight_ = e[1] * i, this.imageOpacity_ = t.getOpacity(), this.imageOriginX_ = s[0], this.imageOriginY_ = s[1], this.imageRotateWithView_ = t.getRotateWithView(), this.imageRotation_ = t.getRotation();
2854
- const o = t.getScaleArray();
2855
- this.imageScale_ = [
2856
- o[0] * this.pixelRatio_ / i,
2857
- o[1] * this.pixelRatio_ / i
2858
- ], this.imageWidth_ = e[0] * i;
2859
- }
2860
- /**
2861
- * Set the text style for subsequent draw operations. Pass null to
2862
- * remove the text style.
2863
- *
2864
- * @param {import("../../style/Text.js").default} textStyle Text style.
2865
- */
2866
- setTextStyle(t) {
2867
- if (!t)
2868
- this.text_ = "";
2869
- else {
2870
- const e = t.getFill();
2871
- if (!e)
2872
- this.textFillState_ = null;
2873
- else {
2874
- const f = e.getColor();
2875
- this.textFillState_ = {
2876
- fillStyle: ot(
2877
- f || V
2878
- )
2879
- };
2880
- }
2881
- const i = t.getStroke();
2882
- if (!i)
2883
- this.textStrokeState_ = null;
2884
- else {
2885
- const f = i.getColor(), u = i.getLineCap(), _ = i.getLineDash(), p = i.getLineDashOffset(), x = i.getLineJoin(), y = i.getWidth(), m = i.getMiterLimit();
2886
- this.textStrokeState_ = {
2887
- lineCap: u !== void 0 ? u : Gt,
2888
- lineDash: _ || et,
2889
- lineDashOffset: p || it,
2890
- lineJoin: x !== void 0 ? x : Yt,
2891
- lineWidth: y !== void 0 ? y : Xt,
2892
- miterLimit: m !== void 0 ? m : Nt,
2893
- strokeStyle: ot(
2894
- f || Bt
2895
- )
2896
- };
2897
- }
2898
- const n = t.getFont(), s = t.getOffsetX(), o = t.getOffsetY(), r = t.getRotateWithView(), l = t.getRotation(), a = t.getScaleArray(), h = t.getText(), d = t.getTextAlign(), c = t.getTextBaseline();
2899
- this.textState_ = {
2900
- font: n !== void 0 ? n : Fe,
2901
- textAlign: d !== void 0 ? d : Tt,
2902
- textBaseline: c !== void 0 ? c : Ht
2903
- }, this.text_ = h !== void 0 ? Array.isArray(h) ? h.reduce((f, u, _) => f += _ % 2 ? " " : u, "") : h : "", this.textOffsetX_ = s !== void 0 ? this.pixelRatio_ * s : 0, this.textOffsetY_ = o !== void 0 ? this.pixelRatio_ * o : 0, this.textRotateWithView_ = r !== void 0 ? r : !1, this.textRotation_ = l !== void 0 ? l : 0, this.textScale_ = [
2904
- this.pixelRatio_ * a[0],
2905
- this.pixelRatio_ * a[1]
2906
- ];
2907
- }
2908
- }
2909
- }
2910
- const z = 0.5;
2911
- function Yi(g, t, e, i, n, s, o) {
2912
- const r = g[0] * z, l = g[1] * z, a = gt(r, l);
2913
- a.imageSmoothingEnabled = !1;
2914
- const h = a.canvas, d = new Gi(
2915
- a,
2916
- z,
2917
- n,
2918
- null,
2919
- o
2920
- ), c = e.length, f = Math.floor((256 * 256 * 256 - 1) / c), u = {};
2921
- for (let p = 1; p <= c; ++p) {
2922
- const x = e[p - 1], y = x.getStyleFunction() || i;
2923
- if (!y)
2924
- continue;
2925
- let m = y(x, s);
2926
- if (!m)
2927
- continue;
2928
- Array.isArray(m) || (m = [m]);
2929
- const T = (p * f).toString(16).padStart(7, "#00000");
2930
- for (let L = 0, O = m.length; L < O; ++L) {
2931
- const k = m[L], D = k.getGeometryFunction()(x);
2932
- if (!D || !tt(n, D.getExtent()))
2933
- continue;
2934
- const b = k.clone(), P = b.getFill();
2935
- P && P.setColor(T);
2936
- const W = b.getStroke();
2937
- W && (W.setColor(T), W.setLineDash(null)), b.setText(void 0);
2938
- const F = k.getImage();
2939
- if (F) {
2940
- const w = F.getImageSize();
2941
- if (!w)
2942
- continue;
2943
- const M = gt(
2944
- w[0],
2945
- w[1],
2946
- void 0,
2947
- { alpha: !1 }
2948
- ), v = M.canvas;
2949
- M.fillStyle = T, M.fillRect(0, 0, v.width, v.height), b.setImage(
2950
- new Ti({
2951
- img: v,
2952
- imgSize: w,
2953
- anchor: F.getAnchor(),
2954
- anchorXUnits: "pixels",
2955
- anchorYUnits: "pixels",
2956
- offset: F.getOrigin(),
2957
- opacity: 1,
2958
- size: F.getSize(),
2959
- scale: F.getScale(),
2960
- rotation: F.getRotation(),
2961
- rotateWithView: F.getRotateWithView()
2962
- })
2963
- );
2964
- }
2965
- const Y = b.getZIndex() || 0;
2966
- let R = u[Y];
2967
- R || (R = {}, u[Y] = R, R.Polygon = [], R.Circle = [], R.LineString = [], R.Point = []);
2968
- const E = D.getType();
2969
- if (E === "GeometryCollection") {
2970
- const w = (
2971
- /** @type {import("../../geom/GeometryCollection.js").default} */
2972
- D.getGeometriesArrayRecursive()
2973
- );
2974
- for (let M = 0, v = w.length; M < v; ++M) {
2975
- const A = w[M];
2976
- R[A.getType().replace("Multi", "")].push(
2977
- A,
2978
- b
2979
- );
2980
- }
2981
- } else
2982
- R[E.replace("Multi", "")].push(D, b);
2983
- }
2984
- }
2985
- const _ = Object.keys(u).map(Number).sort(ie);
2986
- for (let p = 0, x = _.length; p < x; ++p) {
2987
- const y = u[_[p]];
2988
- for (const m in y) {
2989
- const C = y[m];
2990
- for (let T = 0, L = C.length; T < L; T += 2) {
2991
- d.setStyle(C[T + 1]);
2992
- for (let O = 0, k = t.length; O < k; ++O)
2993
- d.setTransform(t[O]), d.drawGeometry(C[T]);
2994
- }
2995
- }
2996
- }
2997
- return a.getImageData(0, 0, h.width, h.height);
2998
- }
2999
- function Xi(g, t, e) {
3000
- const i = [];
3001
- if (e) {
3002
- const n = Math.floor(Math.round(g[0]) * z), s = Math.floor(Math.round(g[1]) * z), o = (Re(n, 0, e.width - 1) + Re(s, 0, e.height - 1) * e.width) * 4, r = e.data[o], l = e.data[o + 1], h = e.data[o + 2] + 256 * (l + 256 * r), d = Math.floor((256 * 256 * 256 - 1) / t.length);
3003
- h && h % d === 0 && i.push(t[h / d - 1]);
3004
- }
3005
- return i;
3006
- }
3007
- const Ni = 0.5, Pe = {
3008
- Point: Ui,
3009
- LineString: Ki,
3010
- Polygon: Qi,
3011
- MultiPoint: $i,
3012
- MultiLineString: zi,
3013
- MultiPolygon: qi,
3014
- GeometryCollection: ji,
3015
- Circle: Vi
3016
- };
3017
- function Hi(g, t) {
3018
- return parseInt(It(g), 10) - parseInt(It(t), 10);
3019
- }
3020
- function Ji(g, t) {
3021
- const e = ne(g, t);
3022
- return e * e;
3023
- }
3024
- function ne(g, t) {
3025
- return Ni * g / t;
3026
- }
3027
- function Vi(g, t, e, i, n) {
3028
- const s = e.getFill(), o = e.getStroke();
3029
- if (s || o) {
3030
- const l = g.getBuilder(e.getZIndex(), "Circle");
3031
- l.setFillStrokeStyle(s, o), l.drawCircle(t, i);
3032
- }
3033
- const r = e.getText();
3034
- if (r && r.getText()) {
3035
- const l = (n || g).getBuilder(
3036
- e.getZIndex(),
3037
- "Text"
3038
- );
3039
- l.setTextStyle(r), l.drawText(t, i);
3040
- }
3041
- }
3042
- function Me(g, t, e, i, n, s, o) {
3043
- let r = !1;
3044
- const l = e.getImage();
3045
- if (l) {
3046
- const a = l.getImageState();
3047
- a == Ct.LOADED || a == Ct.ERROR ? l.unlistenImageChange(n) : (a == Ct.IDLE && l.load(), l.listenImageChange(n), r = !0);
3048
- }
3049
- return Zi(
3050
- g,
3051
- t,
3052
- e,
3053
- i,
3054
- s,
3055
- o
3056
- ), r;
3057
- }
3058
- function Zi(g, t, e, i, n, s) {
3059
- const o = e.getGeometryFunction()(t);
3060
- if (!o)
3061
- return;
3062
- const r = o.simplifyTransformed(
3063
- i,
3064
- n
3065
- );
3066
- if (e.getRenderer())
3067
- ve(g, r, e, t);
3068
- else {
3069
- const a = Pe[r.getType()];
3070
- a(
3071
- g,
3072
- r,
3073
- e,
3074
- t,
3075
- s
3076
- );
3077
- }
3078
- }
3079
- function ve(g, t, e, i) {
3080
- if (t.getType() == "GeometryCollection") {
3081
- const s = (
3082
- /** @type {import("../geom/GeometryCollection.js").default} */
3083
- t.getGeometries()
3084
- );
3085
- for (let o = 0, r = s.length; o < r; ++o)
3086
- ve(g, s[o], e, i);
3087
- return;
3088
- }
3089
- g.getBuilder(e.getZIndex(), "Default").drawCustom(
3090
- /** @type {import("../geom/SimpleGeometry.js").default} */
3091
- t,
3092
- i,
3093
- e.getRenderer(),
3094
- e.getHitDetectionRenderer()
3095
- );
3096
- }
3097
- function ji(g, t, e, i, n) {
3098
- const s = t.getGeometriesArray();
3099
- let o, r;
3100
- for (o = 0, r = s.length; o < r; ++o) {
3101
- const l = Pe[s[o].getType()];
3102
- l(
3103
- g,
3104
- s[o],
3105
- e,
3106
- i,
3107
- n
3108
- );
3109
- }
3110
- }
3111
- function Ki(g, t, e, i, n) {
3112
- const s = e.getStroke();
3113
- if (s) {
3114
- const r = g.getBuilder(
3115
- e.getZIndex(),
3116
- "LineString"
3117
- );
3118
- r.setFillStrokeStyle(null, s), r.drawLineString(t, i);
3119
- }
3120
- const o = e.getText();
3121
- if (o && o.getText()) {
3122
- const r = (n || g).getBuilder(
3123
- e.getZIndex(),
3124
- "Text"
3125
- );
3126
- r.setTextStyle(o), r.drawText(t, i);
3127
- }
3128
- }
3129
- function zi(g, t, e, i, n) {
3130
- const s = e.getStroke();
3131
- if (s) {
3132
- const r = g.getBuilder(
3133
- e.getZIndex(),
3134
- "LineString"
3135
- );
3136
- r.setFillStrokeStyle(null, s), r.drawMultiLineString(t, i);
3137
- }
3138
- const o = e.getText();
3139
- if (o && o.getText()) {
3140
- const r = (n || g).getBuilder(
3141
- e.getZIndex(),
3142
- "Text"
3143
- );
3144
- r.setTextStyle(o), r.drawText(t, i);
3145
- }
3146
- }
3147
- function qi(g, t, e, i, n) {
3148
- const s = e.getFill(), o = e.getStroke();
3149
- if (o || s) {
3150
- const l = g.getBuilder(e.getZIndex(), "Polygon");
3151
- l.setFillStrokeStyle(s, o), l.drawMultiPolygon(t, i);
3152
- }
3153
- const r = e.getText();
3154
- if (r && r.getText()) {
3155
- const l = (n || g).getBuilder(
3156
- e.getZIndex(),
3157
- "Text"
3158
- );
3159
- l.setTextStyle(r), l.drawText(t, i);
3160
- }
3161
- }
3162
- function Ui(g, t, e, i, n) {
3163
- const s = e.getImage(), o = e.getText();
3164
- let r;
3165
- if (s) {
3166
- if (s.getImageState() != Ct.LOADED)
3167
- return;
3168
- let l = g;
3169
- if (n) {
3170
- const h = s.getDeclutterMode();
3171
- if (h !== "none")
3172
- if (l = n, h === "obstacle") {
3173
- const d = g.getBuilder(
3174
- e.getZIndex(),
3175
- "Image"
3176
- );
3177
- d.setImageStyle(s, r), d.drawPoint(t, i);
3178
- } else o && o.getText() && (r = {});
3179
- }
3180
- const a = l.getBuilder(
3181
- e.getZIndex(),
3182
- "Image"
3183
- );
3184
- a.setImageStyle(s, r), a.drawPoint(t, i);
3185
- }
3186
- if (o && o.getText()) {
3187
- let l = g;
3188
- n && (l = n);
3189
- const a = l.getBuilder(e.getZIndex(), "Text");
3190
- a.setTextStyle(o, r), a.drawText(t, i);
3191
- }
3192
- }
3193
- function $i(g, t, e, i, n) {
3194
- const s = e.getImage(), o = e.getText();
3195
- let r;
3196
- if (s) {
3197
- if (s.getImageState() != Ct.LOADED)
3198
- return;
3199
- let l = g;
3200
- if (n) {
3201
- const h = s.getDeclutterMode();
3202
- if (h !== "none")
3203
- if (l = n, h === "obstacle") {
3204
- const d = g.getBuilder(
3205
- e.getZIndex(),
3206
- "Image"
3207
- );
3208
- d.setImageStyle(s, r), d.drawMultiPoint(t, i);
3209
- } else o && o.getText() && (r = {});
3210
- }
3211
- const a = l.getBuilder(
3212
- e.getZIndex(),
3213
- "Image"
3214
- );
3215
- a.setImageStyle(s, r), a.drawMultiPoint(t, i);
3216
- }
3217
- if (o && o.getText()) {
3218
- let l = g;
3219
- n && (l = n);
3220
- const a = l.getBuilder(e.getZIndex(), "Text");
3221
- a.setTextStyle(o, r), a.drawText(t, i);
3222
- }
3223
- }
3224
- function Qi(g, t, e, i, n) {
3225
- const s = e.getFill(), o = e.getStroke();
3226
- if (s || o) {
3227
- const l = g.getBuilder(e.getZIndex(), "Polygon");
3228
- l.setFillStrokeStyle(s, o), l.drawPolygon(t, i);
3229
- }
3230
- const r = e.getText();
3231
- if (r && r.getText()) {
3232
- const l = (n || g).getBuilder(
3233
- e.getZIndex(),
3234
- "Text"
3235
- );
3236
- l.setTextStyle(r), l.drawText(t, i);
3237
- }
3238
- }
3239
- class tn extends Li {
3240
- /**
3241
- * @param {import("../../layer/BaseVector.js").default} vectorLayer Vector layer.
3242
- */
3243
- constructor(t) {
3244
- super(t), this.boundHandleStyleImageChange_ = this.handleStyleImageChange_.bind(this), this.animatingOrInteracting_, this.hitDetectionImageData_ = null, this.renderedFeatures_ = null, this.renderedRevision_ = -1, this.renderedResolution_ = NaN, this.renderedExtent_ = At(), this.wrappedRenderedExtent_ = At(), this.renderedRotation_, this.renderedCenter_ = null, this.renderedProjection_ = null, this.renderedRenderOrder_ = null, this.replayGroup_ = null, this.replayGroupChanged = !0, this.declutterExecutorGroup = null, this.clipping = !0, this.compositionContext_ = null, this.opacity_ = 1;
3245
- }
3246
- /**
3247
- * @param {ExecutorGroup} executorGroup Executor group.
3248
- * @param {import("../../Map.js").FrameState} frameState Frame state.
3249
- * @param {import("rbush").default} [declutterTree] Declutter tree.
3250
- */
3251
- renderWorlds(t, e, i) {
3252
- const n = e.extent, s = e.viewState, o = s.center, r = s.resolution, l = s.projection, a = s.rotation, h = l.getExtent(), d = this.getLayer().getSource(), c = e.pixelRatio, f = e.viewHints, u = !(f[Mt.ANIMATING] || f[Mt.INTERACTING]), _ = this.compositionContext_, p = Math.round(e.size[0] * c), x = Math.round(e.size[1] * c), y = d.getWrapX() && l.canWrapX(), m = y ? Ft(h) : null, C = y ? Math.ceil((n[2] - h[2]) / m) + 1 : 1;
3253
- let T = y ? Math.floor((n[0] - h[0]) / m) : 0;
3254
- do {
3255
- const L = this.getRenderTransform(
3256
- o,
3257
- r,
3258
- a,
3259
- c,
3260
- p,
3261
- x,
3262
- T * m
3263
- );
3264
- t.execute(
3265
- _,
3266
- 1,
3267
- L,
3268
- a,
3269
- u,
3270
- void 0,
3271
- i
3272
- );
3273
- } while (++T < C);
3274
- }
3275
- setupCompositionContext_() {
3276
- if (this.opacity_ !== 1) {
3277
- const t = gt(
3278
- this.context.canvas.width,
3279
- this.context.canvas.height,
3280
- ke
3281
- );
3282
- this.compositionContext_ = t;
3283
- } else
3284
- this.compositionContext_ = this.context;
3285
- }
3286
- releaseCompositionContext_() {
3287
- if (this.opacity_ !== 1) {
3288
- const t = this.context.globalAlpha;
3289
- this.context.globalAlpha = this.opacity_, this.context.drawImage(this.compositionContext_.canvas, 0, 0), this.context.globalAlpha = t, Ii(this.compositionContext_), ke.push(this.compositionContext_.canvas), this.compositionContext_ = null;
3290
- }
3291
- }
3292
- /**
3293
- * Render declutter items for this layer
3294
- * @param {import("../../Map.js").FrameState} frameState Frame state.
3295
- */
3296
- renderDeclutter(t) {
3297
- this.declutterExecutorGroup && (this.setupCompositionContext_(), this.renderWorlds(
3298
- this.declutterExecutorGroup,
3299
- t,
3300
- t.declutterTree
3301
- ), this.releaseCompositionContext_());
3302
- }
3303
- /**
3304
- * Render the layer.
3305
- * @param {import("../../Map.js").FrameState} frameState Frame state.
3306
- * @param {HTMLElement|null} target Target that may be used to render content to.
3307
- * @return {HTMLElement|null} The rendered element.
3308
- */
3309
- renderFrame(t, e) {
3310
- const i = t.pixelRatio, n = t.layerStatesArray[t.layerIndex];
3311
- fi(this.pixelTransform, 1 / i, 1 / i), ui(this.inversePixelTransform, this.pixelTransform);
3312
- const s = gi(this.pixelTransform);
3313
- this.useContainer(e, s, this.getBackground(t));
3314
- const o = this.context, r = o.canvas, l = this.replayGroup_, a = this.declutterExecutorGroup;
3315
- let h = l && !l.isEmpty() || a && !a.isEmpty();
3316
- if (!h && !(this.getLayer().hasListener(vt.PRERENDER) || this.getLayer().hasListener(vt.POSTRENDER)))
3317
- return null;
3318
- const d = Math.round(t.size[0] * i), c = Math.round(t.size[1] * i);
3319
- r.width != d || r.height != c ? (r.width = d, r.height = c, r.style.transform !== s && (r.style.transform = s)) : this.containerReused || o.clearRect(0, 0, d, c), this.preRender(o, t);
3320
- const f = t.viewState;
3321
- f.projection, this.opacity_ = n.opacity, this.setupCompositionContext_();
3322
- let u = !1;
3323
- if (h && n.extent && this.clipping) {
3324
- const _ = _i(n.extent);
3325
- h = tt(_, t.extent), u = h && !Wt(_, t.extent), u && this.clipUnrotated(this.compositionContext_, t, _);
3326
- }
3327
- return h && this.renderWorlds(l, t), u && this.compositionContext_.restore(), this.releaseCompositionContext_(), this.postRender(o, t), this.renderedRotation_ !== f.rotation && (this.renderedRotation_ = f.rotation, this.hitDetectionImageData_ = null), this.container;
3328
- }
3329
- /**
3330
- * Asynchronous layer level hit detection.
3331
- * @param {import("../../pixel.js").Pixel} pixel Pixel.
3332
- * @return {Promise<Array<import("../../Feature").default>>} Promise
3333
- * that resolves with an array of features.
3334
- */
3335
- getFeatures(t) {
3336
- return new Promise((e) => {
3337
- if (!this.hitDetectionImageData_ && !this.animatingOrInteracting_) {
3338
- const i = [this.context.canvas.width, this.context.canvas.height];
3339
- G(this.pixelTransform, i);
3340
- const n = this.renderedCenter_, s = this.renderedResolution_, o = this.renderedRotation_, r = this.renderedProjection_, l = this.wrappedRenderedExtent_, a = this.getLayer(), h = [], d = i[0] * z, c = i[1] * z;
3341
- h.push(
3342
- this.getRenderTransform(
3343
- n,
3344
- s,
3345
- o,
3346
- z,
3347
- d,
3348
- c,
3349
- 0
3350
- ).slice()
3351
- );
3352
- const f = a.getSource(), u = r.getExtent();
3353
- if (f.getWrapX() && r.canWrapX() && !Wt(u, l)) {
3354
- let _ = l[0];
3355
- const p = Ft(u);
3356
- let x = 0, y;
3357
- for (; _ < u[0]; )
3358
- --x, y = p * x, h.push(
3359
- this.getRenderTransform(
3360
- n,
3361
- s,
3362
- o,
3363
- z,
3364
- d,
3365
- c,
3366
- y
3367
- ).slice()
3368
- ), _ += p;
3369
- for (x = 0, _ = l[2]; _ > u[2]; )
3370
- ++x, y = p * x, h.push(
3371
- this.getRenderTransform(
3372
- n,
3373
- s,
3374
- o,
3375
- z,
3376
- d,
3377
- c,
3378
- y
3379
- ).slice()
3380
- ), _ -= p;
3381
- }
3382
- this.hitDetectionImageData_ = Yi(
3383
- i,
3384
- h,
3385
- this.renderedFeatures_,
3386
- a.getStyleFunction(),
3387
- l,
3388
- s,
3389
- o
3390
- );
3391
- }
3392
- e(
3393
- Xi(t, this.renderedFeatures_, this.hitDetectionImageData_)
3394
- );
3395
- });
3396
- }
3397
- /**
3398
- * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
3399
- * @param {import("../../Map.js").FrameState} frameState Frame state.
3400
- * @param {number} hitTolerance Hit tolerance in pixels.
3401
- * @param {import("../vector.js").FeatureCallback<T>} callback Feature callback.
3402
- * @param {Array<import("../Map.js").HitMatch<T>>} matches The hit detected matches with tolerance.
3403
- * @return {T|undefined} Callback result.
3404
- * @template T
3405
- */
3406
- forEachFeatureAtCoordinate(t, e, i, n, s) {
3407
- if (!this.replayGroup_)
3408
- return;
3409
- const o = e.viewState.resolution, r = e.viewState.rotation, l = this.getLayer(), a = {}, h = function(f, u, _) {
3410
- const p = It(f), x = a[p];
3411
- if (x) {
3412
- if (x !== !0 && _ < x.distanceSq) {
3413
- if (_ === 0)
3414
- return a[p] = !0, s.splice(s.lastIndexOf(x), 1), n(f, l, u);
3415
- x.geometry = u, x.distanceSq = _;
3416
- }
3417
- } else {
3418
- if (_ === 0)
3419
- return a[p] = !0, n(f, l, u);
3420
- s.push(
3421
- a[p] = {
3422
- feature: f,
3423
- layer: l,
3424
- geometry: u,
3425
- distanceSq: _,
3426
- callback: n
3427
- }
3428
- );
3429
- }
3430
- };
3431
- let d;
3432
- const c = [this.replayGroup_];
3433
- return this.declutterExecutorGroup && c.push(this.declutterExecutorGroup), c.some((f) => d = f.forEachFeatureAtCoordinate(
3434
- t,
3435
- o,
3436
- r,
3437
- i,
3438
- h,
3439
- f === this.declutterExecutorGroup && e.declutterTree ? e.declutterTree.all().map((u) => u.value) : null
3440
- )), d;
3441
- }
3442
- /**
3443
- * Perform action necessary to get the layer rendered after new fonts have loaded
3444
- */
3445
- handleFontsChanged() {
3446
- const t = this.getLayer();
3447
- t.getVisible() && this.replayGroup_ && t.changed();
3448
- }
3449
- /**
3450
- * Handle changes in image style state.
3451
- * @param {import("../../events/Event.js").default} event Image style change event.
3452
- * @private
3453
- */
3454
- handleStyleImageChange_(t) {
3455
- this.renderIfReadyAndVisible();
3456
- }
3457
- /**
3458
- * Determine whether render should be called.
3459
- * @param {import("../../Map.js").FrameState} frameState Frame state.
3460
- * @return {boolean} Layer is ready to be rendered.
3461
- */
3462
- prepareFrame(t) {
3463
- const e = this.getLayer(), i = e.getSource();
3464
- if (!i)
3465
- return !1;
3466
- const n = t.viewHints[Mt.ANIMATING], s = t.viewHints[Mt.INTERACTING], o = e.getUpdateWhileAnimating(), r = e.getUpdateWhileInteracting();
3467
- if (this.ready && !o && n || !r && s)
3468
- return this.animatingOrInteracting_ = !0, !0;
3469
- this.animatingOrInteracting_ = !1;
3470
- const l = t.extent, a = t.viewState, h = a.projection, d = a.resolution, c = t.pixelRatio, f = e.getRevision(), u = e.getRenderBuffer();
3471
- let _ = e.getRenderOrder();
3472
- _ === void 0 && (_ = Hi);
3473
- const p = a.center.slice(), x = se(
3474
- l,
3475
- u * d
3476
- ), y = x.slice(), m = [x.slice()], C = h.getExtent();
3477
- if (i.getWrapX() && h.canWrapX() && !Wt(C, t.extent)) {
3478
- const R = Ft(C), E = Math.max(Ft(x) / 2, R);
3479
- x[0] = C[0] - E, x[2] = C[2] + E, xi(p, h);
3480
- const w = pi(m[0], h);
3481
- w[0] < C[0] && w[2] < C[2] ? m.push([
3482
- w[0] + R,
3483
- w[1],
3484
- w[2] + R,
3485
- w[3]
3486
- ]) : w[0] > C[0] && w[2] > C[2] && m.push([
3487
- w[0] - R,
3488
- w[1],
3489
- w[2] - R,
3490
- w[3]
3491
- ]);
3492
- }
3493
- if (this.ready && this.renderedResolution_ == d && this.renderedRevision_ == f && this.renderedRenderOrder_ == _ && Wt(this.wrappedRenderedExtent_, x))
3494
- return Rt(this.renderedExtent_, y) || (this.hitDetectionImageData_ = null, this.renderedExtent_ = y), this.renderedCenter_ = p, this.replayGroupChanged = !1, !0;
3495
- this.replayGroup_ = null;
3496
- const T = new Le(
3497
- ne(d, c),
3498
- x,
3499
- d,
3500
- c
3501
- );
3502
- let L;
3503
- this.getLayer().getDeclutter() && (L = new Le(
3504
- ne(d, c),
3505
- x,
3506
- d,
3507
- c
3508
- ));
3509
- let O;
3510
- for (let R = 0, E = m.length; R < E; ++R)
3511
- i.loadFeatures(m[R], d, h);
3512
- const k = Ji(d, c);
3513
- let D = !0;
3514
- const b = (
3515
- /**
3516
- * @param {import("../../Feature.js").default} feature Feature.
3517
- */
3518
- (R) => {
3519
- let E;
3520
- const w = R.getStyleFunction() || e.getStyleFunction();
3521
- if (w && (E = w(R, d)), E) {
3522
- const M = this.renderFeature(
3523
- R,
3524
- k,
3525
- E,
3526
- T,
3527
- O,
3528
- L
3529
- );
3530
- D = D && !M;
3531
- }
3532
- }
3533
- ), P = Si(x), W = i.getFeaturesInExtent(P);
3534
- _ && W.sort(_);
3535
- for (let R = 0, E = W.length; R < E; ++R)
3536
- b(W[R]);
3537
- this.renderedFeatures_ = W, this.ready = D;
3538
- const F = T.finish(), Y = new be(
3539
- x,
3540
- d,
3541
- c,
3542
- i.getOverlaps(),
3543
- F,
3544
- e.getRenderBuffer()
3545
- );
3546
- return L && (this.declutterExecutorGroup = new be(
3547
- x,
3548
- d,
3549
- c,
3550
- i.getOverlaps(),
3551
- L.finish(),
3552
- e.getRenderBuffer()
3553
- )), this.renderedResolution_ = d, this.renderedRevision_ = f, this.renderedRenderOrder_ = _, this.renderedExtent_ = y, this.wrappedRenderedExtent_ = x, this.renderedCenter_ = p, this.renderedProjection_ = h, this.replayGroup_ = Y, this.hitDetectionImageData_ = null, this.replayGroupChanged = !0, !0;
3554
- }
3555
- /**
3556
- * @param {import("../../Feature.js").default} feature Feature.
3557
- * @param {number} squaredTolerance Squared render tolerance.
3558
- * @param {import("../../style/Style.js").default|Array<import("../../style/Style.js").default>} styles The style or array of styles.
3559
- * @param {import("../../render/canvas/BuilderGroup.js").default} builderGroup Builder group.
3560
- * @param {import("../../proj.js").TransformFunction} [transform] Transform from user to view projection.
3561
- * @param {import("../../render/canvas/BuilderGroup.js").default} [declutterBuilderGroup] Builder for decluttering.
3562
- * @return {boolean} `true` if an image is loading.
3563
- */
3564
- renderFeature(t, e, i, n, s, o) {
3565
- if (!i)
3566
- return !1;
3567
- let r = !1;
3568
- if (Array.isArray(i))
3569
- for (let l = 0, a = i.length; l < a; ++l)
3570
- r = Me(
3571
- n,
3572
- t,
3573
- i[l],
3574
- e,
3575
- this.boundHandleStyleImageChange_,
3576
- s,
3577
- o
3578
- ) || r;
3579
- else
3580
- r = Me(
3581
- n,
3582
- t,
3583
- i,
3584
- e,
3585
- this.boundHandleStyleImageChange_,
3586
- s,
3587
- o
3588
- );
3589
- return r;
3590
- }
3591
- }
3592
- class rn extends $e {
3593
- /**
3594
- * @param {import("./BaseVector.js").Options<VectorSourceType>} [options] Options.
3595
- */
3596
- constructor(t) {
3597
- super(t);
3598
- }
3599
- createRenderer() {
3600
- return new tn(this);
3601
- }
3602
- }
3603
- export {
3604
- Li as C,
3605
- rn as V
3606
- };