@vaadin/bundles 25.0.0-alpha3 → 25.0.0-alpha5

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 (192) hide show
  1. package/node_modules_ol_ImageCanvas_js.js +76 -83
  2. package/node_modules_ol_ImageCanvas_js.js.map +1 -1
  3. package/node_modules_ol_TileRange_js.js +128 -110
  4. package/node_modules_ol_TileRange_js.js.map +1 -1
  5. package/node_modules_ol_Tile_js.js +279 -0
  6. package/node_modules_ol_Tile_js.js.map +1 -0
  7. package/node_modules_ol_VectorRenderTile_js.js +428 -143
  8. package/node_modules_ol_VectorRenderTile_js.js.map +1 -1
  9. package/node_modules_ol_VectorTile_js.js +405 -119
  10. package/node_modules_ol_VectorTile_js.js.map +1 -1
  11. package/node_modules_ol_control_MousePosition_js.js +327 -0
  12. package/node_modules_ol_control_MousePosition_js.js.map +1 -0
  13. package/node_modules_ol_control_ZoomToExtent_js.js +118 -0
  14. package/node_modules_ol_control_ZoomToExtent_js.js.map +1 -0
  15. package/node_modules_ol_events_SnapEvent_js.js +79 -0
  16. package/node_modules_ol_events_SnapEvent_js.js.map +1 -0
  17. package/node_modules_ol_featureloader_js.js +205 -0
  18. package/node_modules_ol_featureloader_js.js.map +1 -0
  19. package/node_modules_ol_geom_Circle_js.js +300 -0
  20. package/node_modules_ol_geom_Circle_js.js.map +1 -0
  21. package/node_modules_ol_geom_GeometryCollection_js.js +369 -0
  22. package/node_modules_ol_geom_GeometryCollection_js.js.map +1 -0
  23. package/node_modules_ol_geom_MultiPoint_js.js +228 -0
  24. package/node_modules_ol_geom_MultiPoint_js.js.map +1 -0
  25. package/node_modules_ol_geom_flat_center_js.js +47 -0
  26. package/node_modules_ol_geom_flat_center_js.js.map +1 -0
  27. package/node_modules_ol_geom_flat_geodesic_js.js +123 -88
  28. package/node_modules_ol_geom_flat_geodesic_js.js.map +1 -1
  29. package/node_modules_ol_geom_flat_interpolate_js.js +230 -0
  30. package/node_modules_ol_geom_flat_interpolate_js.js.map +1 -0
  31. package/node_modules_ol_geom_flat_length_js-_375a0.js +58 -0
  32. package/node_modules_ol_geom_flat_length_js-_375a0.js.map +1 -0
  33. package/node_modules_ol_geom_flat_length_js-_375a1.js +58 -0
  34. package/node_modules_ol_geom_flat_length_js-_375a1.js.map +1 -0
  35. package/node_modules_ol_geom_flat_length_js-_375a2.js +58 -0
  36. package/node_modules_ol_geom_flat_length_js-_375a2.js.map +1 -0
  37. package/node_modules_ol_geom_flat_length_js-_375a3.js +58 -0
  38. package/node_modules_ol_geom_flat_length_js-_375a3.js.map +1 -0
  39. package/node_modules_ol_geom_flat_length_js-_375a4.js +58 -0
  40. package/node_modules_ol_geom_flat_length_js-_375a4.js.map +1 -0
  41. package/node_modules_ol_geom_flat_linechunk_js.js +76 -0
  42. package/node_modules_ol_geom_flat_linechunk_js.js.map +1 -0
  43. package/node_modules_ol_geom_flat_straightchunk_js.js +68 -0
  44. package/node_modules_ol_geom_flat_straightchunk_js.js.map +1 -0
  45. package/node_modules_ol_geom_flat_textpath_js.js +178 -0
  46. package/node_modules_ol_geom_flat_textpath_js.js.map +1 -0
  47. package/node_modules_ol_interaction_DblClickDragZoom_js.js +285 -0
  48. package/node_modules_ol_interaction_DblClickDragZoom_js.js.map +1 -0
  49. package/node_modules_ol_interaction_DragAndDrop_js.js +351 -0
  50. package/node_modules_ol_interaction_DragAndDrop_js.js.map +1 -0
  51. package/node_modules_ol_interaction_DragRotateAndZoom_js.js +159 -0
  52. package/node_modules_ol_interaction_DragRotateAndZoom_js.js.map +1 -0
  53. package/node_modules_ol_layer_Vector_js-_49290.js +110 -0
  54. package/node_modules_ol_layer_Vector_js-_49290.js.map +1 -0
  55. package/node_modules_ol_layer_Vector_js-_49291.js +110 -0
  56. package/node_modules_ol_layer_Vector_js-_49291.js.map +1 -0
  57. package/node_modules_ol_layer_Vector_js-_49292.js +110 -0
  58. package/node_modules_ol_layer_Vector_js-_49292.js.map +1 -0
  59. package/node_modules_ol_layer_Vector_js-_49293.js +110 -0
  60. package/node_modules_ol_layer_Vector_js-_49293.js.map +1 -0
  61. package/node_modules_ol_loadingstrategy_js.js +95 -0
  62. package/node_modules_ol_loadingstrategy_js.js.map +1 -0
  63. package/node_modules_ol_render_VectorContext_js-_3ad60.js +144 -0
  64. package/node_modules_ol_render_VectorContext_js-_3ad60.js.map +1 -0
  65. package/node_modules_ol_render_VectorContext_js-_3ad61.js +144 -0
  66. package/node_modules_ol_render_VectorContext_js-_3ad61.js.map +1 -0
  67. package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js +372 -0
  68. package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js.map +1 -0
  69. package/node_modules_ol_render_canvas_ImageBuilder_js.js +318 -0
  70. package/node_modules_ol_render_canvas_ImageBuilder_js.js.map +1 -0
  71. package/node_modules_ol_render_canvas_Instruction_js.js +66 -0
  72. package/node_modules_ol_render_canvas_Instruction_js.js.map +1 -0
  73. package/node_modules_ol_render_canvas_LineStringBuilder_js.js +187 -0
  74. package/node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -0
  75. package/node_modules_ol_render_canvas_PolygonBuilder_js.js +276 -0
  76. package/node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
  77. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js +156 -0
  78. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js.map +1 -0
  79. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js +156 -0
  80. package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js.map +1 -0
  81. package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js +301 -0
  82. package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js.map +1 -0
  83. package/node_modules_ol_renderer_Layer_js.js +219 -0
  84. package/node_modules_ol_renderer_Layer_js.js.map +1 -0
  85. package/node_modules_ol_source_Source_js.js +256 -0
  86. package/node_modules_ol_source_Source_js.js.map +1 -0
  87. package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js +318 -0
  88. package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js.map +1 -0
  89. package/node_modules_ol_source_VectorEventType_js.js +80 -0
  90. package/node_modules_ol_source_VectorEventType_js.js.map +1 -0
  91. package/node_modules_ol_structs_RBush_js.js +242 -0
  92. package/node_modules_ol_structs_RBush_js.js.map +1 -0
  93. package/node_modules_ol_style_js.js +2 -1
  94. package/node_modules_ol_style_js.js.map +1 -1
  95. package/node_modules_rbush_rbush_min_js.js +16 -0
  96. package/node_modules_rbush_rbush_min_js.js.map +1 -0
  97. package/package.json +142 -146
  98. package/vaadin-bundle.json +2447 -2352
  99. package/vaadin.js +52246 -63791
  100. package/vaadin.js.map +1 -1
  101. package/vendors-node_modules_dompurify_dist_purify_es_mjs.js +1364 -0
  102. package/vendors-node_modules_dompurify_dist_purify_es_mjs.js.map +1 -0
  103. package/vendors-node_modules_dompurify_dist_purify_js.js +26 -21
  104. package/vendors-node_modules_dompurify_dist_purify_js.js.map +1 -1
  105. package/vendors-node_modules_marked_lib_marked_esm_js.js +2205 -0
  106. package/vendors-node_modules_marked_lib_marked_esm_js.js.map +1 -0
  107. package/vendors-node_modules_marked_lib_marked_umd_js.js +2164 -2556
  108. package/vendors-node_modules_marked_lib_marked_umd_js.js.map +1 -1
  109. package/vendors-node_modules_ol_Feature_js.js +360 -0
  110. package/vendors-node_modules_ol_Feature_js.js.map +1 -0
  111. package/vendors-node_modules_ol_Geolocation_js.js +352 -293
  112. package/vendors-node_modules_ol_Geolocation_js.js.map +1 -1
  113. package/vendors-node_modules_ol_ImageTile_js.js +494 -0
  114. package/vendors-node_modules_ol_ImageTile_js.js.map +1 -0
  115. package/vendors-node_modules_ol_Overlay_js.js +606 -0
  116. package/vendors-node_modules_ol_Overlay_js.js.map +1 -0
  117. package/vendors-node_modules_ol_control_FullScreen_js.js +417 -0
  118. package/vendors-node_modules_ol_control_FullScreen_js.js.map +1 -0
  119. package/vendors-node_modules_ol_control_OverviewMap_js.js +711 -0
  120. package/vendors-node_modules_ol_control_OverviewMap_js.js.map +1 -0
  121. package/vendors-node_modules_ol_control_ScaleLine_js.js +509 -0
  122. package/vendors-node_modules_ol_control_ScaleLine_js.js.map +1 -0
  123. package/vendors-node_modules_ol_control_ZoomSlider_js.js +418 -0
  124. package/vendors-node_modules_ol_control_ZoomSlider_js.js.map +1 -0
  125. package/vendors-node_modules_ol_control_js.js +490 -0
  126. package/vendors-node_modules_ol_control_js.js.map +1 -0
  127. package/vendors-node_modules_ol_geom_LineString_js.js +574 -0
  128. package/vendors-node_modules_ol_geom_LineString_js.js.map +1 -0
  129. package/vendors-node_modules_ol_geom_MultiLineString_js.js +405 -0
  130. package/vendors-node_modules_ol_geom_MultiLineString_js.js.map +1 -0
  131. package/vendors-node_modules_ol_geom_MultiPolygon_js.js +773 -0
  132. package/vendors-node_modules_ol_geom_MultiPolygon_js.js.map +1 -0
  133. package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js +769 -0
  134. package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js.map +1 -0
  135. package/vendors-node_modules_ol_index_js.js +526 -675
  136. package/vendors-node_modules_ol_index_js.js.map +1 -1
  137. package/vendors-node_modules_ol_interaction_Draw_js.js +2777 -0
  138. package/vendors-node_modules_ol_interaction_Draw_js.js.map +1 -0
  139. package/vendors-node_modules_ol_interaction_Extent_js.js +586 -0
  140. package/vendors-node_modules_ol_interaction_Extent_js.js.map +1 -0
  141. package/vendors-node_modules_ol_interaction_Link_js.js +489 -0
  142. package/vendors-node_modules_ol_interaction_Link_js.js.map +1 -0
  143. package/vendors-node_modules_ol_interaction_Modify_js.js +1841 -0
  144. package/vendors-node_modules_ol_interaction_Modify_js.js.map +1 -0
  145. package/vendors-node_modules_ol_interaction_Select_js.js +623 -0
  146. package/vendors-node_modules_ol_interaction_Select_js.js.map +1 -0
  147. package/vendors-node_modules_ol_interaction_Snap_js.js +982 -0
  148. package/vendors-node_modules_ol_interaction_Snap_js.js.map +1 -0
  149. package/vendors-node_modules_ol_interaction_Translate_js.js +466 -0
  150. package/vendors-node_modules_ol_interaction_Translate_js.js.map +1 -0
  151. package/vendors-node_modules_ol_interaction_js.js +872 -0
  152. package/vendors-node_modules_ol_interaction_js.js.map +1 -0
  153. package/vendors-node_modules_ol_layer_Graticule_js.js +1374 -989
  154. package/vendors-node_modules_ol_layer_Graticule_js.js.map +1 -1
  155. package/vendors-node_modules_ol_render_Feature_js.js +546 -0
  156. package/vendors-node_modules_ol_render_Feature_js.js.map +1 -0
  157. package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js +897 -0
  158. package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -0
  159. package/vendors-node_modules_ol_render_canvas_Builder_js.js +907 -0
  160. package/vendors-node_modules_ol_render_canvas_Builder_js.js.map +1 -0
  161. package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js +539 -0
  162. package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -0
  163. package/vendors-node_modules_ol_render_canvas_Executor_js.js +1715 -0
  164. package/vendors-node_modules_ol_render_canvas_Executor_js.js.map +1 -0
  165. package/vendors-node_modules_ol_render_canvas_Immediate_js.js +1208 -0
  166. package/vendors-node_modules_ol_render_canvas_Immediate_js.js.map +1 -0
  167. package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js +825 -0
  168. package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -0
  169. package/vendors-node_modules_ol_renderer_canvas_Layer_js.js +654 -0
  170. package/vendors-node_modules_ol_renderer_canvas_Layer_js.js.map +1 -0
  171. package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js +1044 -0
  172. package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -0
  173. package/vendors-node_modules_ol_renderer_vector_js.js +460 -0
  174. package/vendors-node_modules_ol_renderer_vector_js.js.map +1 -0
  175. package/vendors-node_modules_ol_source_Vector_js.js +2091 -0
  176. package/vendors-node_modules_ol_source_Vector_js.js.map +1 -0
  177. package/node_modules_ol_ImageTile_js.js +0 -177
  178. package/node_modules_ol_ImageTile_js.js.map +0 -1
  179. package/node_modules_ol_render_js.js +0 -131
  180. package/node_modules_ol_render_js.js.map +0 -1
  181. package/node_modules_ol_structs_LRUCache_js.js +0 -275
  182. package/node_modules_ol_structs_LRUCache_js.js.map +0 -1
  183. package/node_modules_ol_tilecoord_js.js +0 -115
  184. package/node_modules_ol_tilecoord_js.js.map +0 -1
  185. package/vendors-node_modules_ol_TileCache_js.js +0 -461
  186. package/vendors-node_modules_ol_TileCache_js.js.map +0 -1
  187. package/vendors-node_modules_ol_Tile_js.js +0 -330
  188. package/vendors-node_modules_ol_Tile_js.js.map +0 -1
  189. package/vendors-node_modules_ol_style_Text_js.js +0 -509
  190. package/vendors-node_modules_ol_style_Text_js.js.map +0 -1
  191. package/vendors-node_modules_rbush_index_js.js +0 -531
  192. package/vendors-node_modules_rbush_index_js.js.map +0 -1
@@ -0,0 +1,1715 @@
1
+ (self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_ol_render_canvas_Executor_js"],{
2
+
3
+ /***/ "./node_modules/ol/geom/flat/length.js":
4
+ /*!*********************************************!*\
5
+ !*** ./node_modules/ol/geom/flat/length.js ***!
6
+ \*********************************************/
7
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8
+
9
+ __webpack_require__.r(__webpack_exports__);
10
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11
+ /* harmony export */ "lineStringLength": () => (/* binding */ lineStringLength),
12
+ /* harmony export */ "linearRingLength": () => (/* binding */ linearRingLength)
13
+ /* harmony export */ });
14
+ /**
15
+ * @module ol/geom/flat/length
16
+ */
17
+
18
+ /**
19
+ * @param {Array<number>} flatCoordinates Flat coordinates.
20
+ * @param {number} offset Offset.
21
+ * @param {number} end End.
22
+ * @param {number} stride Stride.
23
+ * @return {number} Length.
24
+ */
25
+ function lineStringLength(flatCoordinates, offset, end, stride) {
26
+ let x1 = flatCoordinates[offset];
27
+ let y1 = flatCoordinates[offset + 1];
28
+ let length = 0;
29
+ for (let i = offset + stride; i < end; i += stride) {
30
+ const x2 = flatCoordinates[i];
31
+ const y2 = flatCoordinates[i + 1];
32
+ length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
33
+ x1 = x2;
34
+ y1 = y2;
35
+ }
36
+ return length;
37
+ }
38
+
39
+ /**
40
+ * @param {Array<number>} flatCoordinates Flat coordinates.
41
+ * @param {number} offset Offset.
42
+ * @param {number} end End.
43
+ * @param {number} stride Stride.
44
+ * @return {number} Perimeter.
45
+ */
46
+ function linearRingLength(flatCoordinates, offset, end, stride) {
47
+ let perimeter = lineStringLength(flatCoordinates, offset, end, stride);
48
+ const dx = flatCoordinates[end - stride] - flatCoordinates[offset];
49
+ const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];
50
+ perimeter += Math.sqrt(dx * dx + dy * dy);
51
+ return perimeter;
52
+ }
53
+
54
+
55
+ /***/ }),
56
+
57
+ /***/ "./node_modules/ol/geom/flat/textpath.js":
58
+ /*!***********************************************!*\
59
+ !*** ./node_modules/ol/geom/flat/textpath.js ***!
60
+ \***********************************************/
61
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
62
+
63
+ __webpack_require__.r(__webpack_exports__);
64
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
65
+ /* harmony export */ "drawTextOnPath": () => (/* binding */ drawTextOnPath)
66
+ /* harmony export */ });
67
+ /* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../math.js */ "./node_modules/ol/math.js");
68
+ /* harmony import */ var _transform_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./transform.js */ "./node_modules/ol/geom/flat/transform.js");
69
+ /**
70
+ * @module ol/geom/flat/textpath
71
+ */
72
+
73
+
74
+
75
+ /**
76
+ * @param {Array<number>} flatCoordinates Path to put text on.
77
+ * @param {number} offset Start offset of the `flatCoordinates`.
78
+ * @param {number} end End offset of the `flatCoordinates`.
79
+ * @param {number} stride Stride.
80
+ * @param {string} text Text to place on the path.
81
+ * @param {number} startM m along the path where the text starts.
82
+ * @param {number} maxAngle Max angle between adjacent chars in radians.
83
+ * @param {number} scale The product of the text scale and the device pixel ratio.
84
+ * @param {function(string, string, Object<string, number>):number} measureAndCacheTextWidth Measure and cache text width.
85
+ * @param {string} font The font.
86
+ * @param {Object<string, number>} cache A cache of measured widths.
87
+ * @param {number} rotation Rotation to apply to the flatCoordinates to determine whether text needs to be reversed.
88
+ * @param {boolean} keepUpright Whether the text needs to be kept upright
89
+ * @return {Array<Array<*>>|null} The result array (or null if `maxAngle` was
90
+ * exceeded). Entries of the array are x, y, anchorX, angle, chunk.
91
+ */
92
+ function drawTextOnPath(
93
+ flatCoordinates,
94
+ offset,
95
+ end,
96
+ stride,
97
+ text,
98
+ startM,
99
+ maxAngle,
100
+ scale,
101
+ measureAndCacheTextWidth,
102
+ font,
103
+ cache,
104
+ rotation,
105
+ keepUpright = true,
106
+ ) {
107
+ let x2 = flatCoordinates[offset];
108
+ let y2 = flatCoordinates[offset + 1];
109
+ let x1 = 0;
110
+ let y1 = 0;
111
+ let segmentLength = 0;
112
+ let segmentM = 0;
113
+
114
+ function advance() {
115
+ x1 = x2;
116
+ y1 = y2;
117
+ offset += stride;
118
+ x2 = flatCoordinates[offset];
119
+ y2 = flatCoordinates[offset + 1];
120
+ segmentM += segmentLength;
121
+ segmentLength = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
122
+ }
123
+ do {
124
+ advance();
125
+ } while (offset < end - stride && segmentM + segmentLength < startM);
126
+
127
+ let interpolate =
128
+ segmentLength === 0 ? 0 : (startM - segmentM) / segmentLength;
129
+ const beginX = (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.lerp)(x1, x2, interpolate);
130
+ const beginY = (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.lerp)(y1, y2, interpolate);
131
+
132
+ const startOffset = offset - stride;
133
+ const startLength = segmentM;
134
+ const endM = startM + scale * measureAndCacheTextWidth(font, text, cache);
135
+ while (offset < end - stride && segmentM + segmentLength < endM) {
136
+ advance();
137
+ }
138
+ interpolate = segmentLength === 0 ? 0 : (endM - segmentM) / segmentLength;
139
+ const endX = (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.lerp)(x1, x2, interpolate);
140
+ const endY = (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.lerp)(y1, y2, interpolate);
141
+
142
+ // Keep text upright if the option is selected
143
+ let reverse = false;
144
+ if (keepUpright) {
145
+ if (rotation) {
146
+ const flat = [beginX, beginY, endX, endY];
147
+ (0,_transform_js__WEBPACK_IMPORTED_MODULE_1__.rotate)(flat, 0, 4, 2, rotation, flat, flat);
148
+ reverse = flat[0] > flat[2];
149
+ } else {
150
+ reverse = beginX > endX;
151
+ }
152
+ }
153
+
154
+ const PI = Math.PI;
155
+ const result = [];
156
+ const singleSegment = startOffset + stride === offset;
157
+
158
+ offset = startOffset;
159
+ segmentLength = 0;
160
+ segmentM = startLength;
161
+ x2 = flatCoordinates[offset];
162
+ y2 = flatCoordinates[offset + 1];
163
+
164
+ let previousAngle;
165
+ // All on the same segment
166
+ if (singleSegment) {
167
+ advance();
168
+
169
+ previousAngle = Math.atan2(y2 - y1, x2 - x1);
170
+ if (reverse) {
171
+ previousAngle += previousAngle > 0 ? -PI : PI;
172
+ }
173
+ const x = (endX + beginX) / 2;
174
+ const y = (endY + beginY) / 2;
175
+ result[0] = [x, y, (endM - startM) / 2, previousAngle, text];
176
+ return result;
177
+ }
178
+
179
+ // rendering across line segments
180
+ text = text.replace(/\n/g, ' '); // ensure rendering in single-line as all calculations below don't handle multi-lines
181
+
182
+ for (let i = 0, ii = text.length; i < ii; ) {
183
+ advance();
184
+ let angle = Math.atan2(y2 - y1, x2 - x1);
185
+ if (reverse) {
186
+ angle += angle > 0 ? -PI : PI;
187
+ }
188
+ if (previousAngle !== undefined) {
189
+ let delta = angle - previousAngle;
190
+ delta += delta > PI ? -2 * PI : delta < -PI ? 2 * PI : 0;
191
+ if (Math.abs(delta) > maxAngle) {
192
+ return null;
193
+ }
194
+ }
195
+ previousAngle = angle;
196
+
197
+ const iStart = i;
198
+ let charLength = 0;
199
+ for (; i < ii; ++i) {
200
+ const index = reverse ? ii - i - 1 : i;
201
+ const len = scale * measureAndCacheTextWidth(font, text[index], cache);
202
+ if (
203
+ offset + stride < end &&
204
+ segmentM + segmentLength < startM + charLength + len / 2
205
+ ) {
206
+ break;
207
+ }
208
+ charLength += len;
209
+ }
210
+ if (i === iStart) {
211
+ continue;
212
+ }
213
+ const chars = reverse
214
+ ? text.substring(ii - iStart, ii - i)
215
+ : text.substring(iStart, i);
216
+ interpolate =
217
+ segmentLength === 0
218
+ ? 0
219
+ : (startM + charLength / 2 - segmentM) / segmentLength;
220
+ const x = (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.lerp)(x1, x2, interpolate);
221
+ const y = (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.lerp)(y1, y2, interpolate);
222
+ result.push([x, y, charLength / 2, angle, chars]);
223
+ startM += charLength;
224
+ }
225
+ return result;
226
+ }
227
+
228
+
229
+ /***/ }),
230
+
231
+ /***/ "./node_modules/ol/render/canvas/Executor.js":
232
+ /*!***************************************************!*\
233
+ !*** ./node_modules/ol/render/canvas/Executor.js ***!
234
+ \***************************************************/
235
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
236
+
237
+ __webpack_require__.r(__webpack_exports__);
238
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
239
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
240
+ /* harmony export */ });
241
+ /* harmony import */ var _array_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../array.js */ "./node_modules/ol/array.js");
242
+ /* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../extent.js */ "./node_modules/ol/extent.js");
243
+ /* harmony import */ var _geom_flat_length_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../geom/flat/length.js */ "./node_modules/ol/geom/flat/length.js");
244
+ /* harmony import */ var _geom_flat_textpath_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../geom/flat/textpath.js */ "./node_modules/ol/geom/flat/textpath.js");
245
+ /* harmony import */ var _geom_flat_transform_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../geom/flat/transform.js */ "./node_modules/ol/geom/flat/transform.js");
246
+ /* harmony import */ var _transform_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../transform.js */ "./node_modules/ol/transform.js");
247
+ /* harmony import */ var _canvas_ZIndexContext_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../canvas/ZIndexContext.js */ "./node_modules/ol/render/canvas/ZIndexContext.js");
248
+ /* harmony import */ var _canvas_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../canvas.js */ "./node_modules/ol/render/canvas.js");
249
+ /* harmony import */ var _Instruction_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Instruction.js */ "./node_modules/ol/render/canvas/Instruction.js");
250
+ /* harmony import */ var _TextBuilder_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TextBuilder.js */ "./node_modules/ol/render/canvas/TextBuilder.js");
251
+ /**
252
+ * @module ol/render/canvas/Executor
253
+ */
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+ /**
266
+ * @typedef {import('../../structs/RBush.js').Entry<import('../../Feature.js').FeatureLike>} DeclutterEntry
267
+ */
268
+
269
+ /**
270
+ * @typedef {Object} ImageOrLabelDimensions
271
+ * @property {number} drawImageX DrawImageX.
272
+ * @property {number} drawImageY DrawImageY.
273
+ * @property {number} drawImageW DrawImageW.
274
+ * @property {number} drawImageH DrawImageH.
275
+ * @property {number} originX OriginX.
276
+ * @property {number} originY OriginY.
277
+ * @property {Array<number>} scale Scale.
278
+ * @property {DeclutterEntry} declutterBox DeclutterBox.
279
+ * @property {import("../../transform.js").Transform} canvasTransform CanvasTransform.
280
+ */
281
+
282
+ /**
283
+ * @typedef {{0: CanvasRenderingContext2D, 1: import('../../size.js').Size, 2: import("../canvas.js").Label|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement, 3: ImageOrLabelDimensions, 4: number, 5: Array<*>, 6: Array<*>}} ReplayImageOrLabelArgs
284
+ */
285
+
286
+ /**
287
+ * @template T
288
+ * @typedef {function(import("../../Feature.js").FeatureLike, import("../../geom/SimpleGeometry.js").default, import("../../style/Style.js").DeclutterMode): T} FeatureCallback
289
+ */
290
+
291
+ /**
292
+ * @type {import("../../extent.js").Extent}
293
+ */
294
+ const tmpExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_0__.createEmpty)();
295
+
296
+ /** @type {import("../../coordinate.js").Coordinate} */
297
+ const p1 = [];
298
+ /** @type {import("../../coordinate.js").Coordinate} */
299
+ const p2 = [];
300
+ /** @type {import("../../coordinate.js").Coordinate} */
301
+ const p3 = [];
302
+ /** @type {import("../../coordinate.js").Coordinate} */
303
+ const p4 = [];
304
+
305
+ /**
306
+ * @param {ReplayImageOrLabelArgs} replayImageOrLabelArgs Arguments to replayImageOrLabel
307
+ * @return {DeclutterEntry} Declutter rbush entry.
308
+ */
309
+ function getDeclutterBox(replayImageOrLabelArgs) {
310
+ return replayImageOrLabelArgs[3].declutterBox;
311
+ }
312
+
313
+ const rtlRegEx = new RegExp(
314
+ /* eslint-disable prettier/prettier */
315
+ '[' +
316
+ String.fromCharCode(0x00591) + '-' + String.fromCharCode(0x008ff) +
317
+ String.fromCharCode(0x0fb1d) + '-' + String.fromCharCode(0x0fdff) +
318
+ String.fromCharCode(0x0fe70) + '-' + String.fromCharCode(0x0fefc) +
319
+ String.fromCharCode(0x10800) + '-' + String.fromCharCode(0x10fff) +
320
+ String.fromCharCode(0x1e800) + '-' + String.fromCharCode(0x1efff) +
321
+ ']'
322
+ /* eslint-enable prettier/prettier */
323
+ );
324
+
325
+ /**
326
+ * @param {string} text Text.
327
+ * @param {CanvasTextAlign} align Alignment.
328
+ * @return {number} Text alignment.
329
+ */
330
+ function horizontalTextAlign(text, align) {
331
+ if (align === 'start') {
332
+ align = rtlRegEx.test(text) ? 'right' : 'left';
333
+ } else if (align === 'end') {
334
+ align = rtlRegEx.test(text) ? 'left' : 'right';
335
+ }
336
+ return _TextBuilder_js__WEBPACK_IMPORTED_MODULE_1__.TEXT_ALIGN[align];
337
+ }
338
+
339
+ /**
340
+ * @param {Array<string>} acc Accumulator.
341
+ * @param {string} line Line of text.
342
+ * @param {number} i Index
343
+ * @return {Array<string>} Accumulator.
344
+ */
345
+ function createTextChunks(acc, line, i) {
346
+ if (i > 0) {
347
+ acc.push('\n', '');
348
+ }
349
+ acc.push(line, '');
350
+ return acc;
351
+ }
352
+
353
+ /**
354
+ * Converts rich text to plain text for text along lines.
355
+ * @param {string} result The resulting plain text.
356
+ * @param {string} part Item of the rich text array.
357
+ * @param {number} index Index of the item in the rich text array.
358
+ * @return {string} The resulting plain text.
359
+ */
360
+ function richTextToPlainText(result, part, index) {
361
+ if (index % 2 === 0) {
362
+ result += part;
363
+ }
364
+ return result;
365
+ }
366
+
367
+ class Executor {
368
+ /**
369
+ * @param {number} resolution Resolution.
370
+ * @param {number} pixelRatio Pixel ratio.
371
+ * @param {boolean} overlaps The replay can have overlapping geometries.
372
+ * @param {import("../canvas.js").SerializableInstructions} instructions The serializable instructions.
373
+ * @param {boolean} [deferredRendering] Enable deferred rendering.
374
+ */
375
+ constructor(
376
+ resolution,
377
+ pixelRatio,
378
+ overlaps,
379
+ instructions,
380
+ deferredRendering,
381
+ ) {
382
+ /**
383
+ * @protected
384
+ * @type {boolean}
385
+ */
386
+ this.overlaps = overlaps;
387
+
388
+ /**
389
+ * @protected
390
+ * @type {number}
391
+ */
392
+ this.pixelRatio = pixelRatio;
393
+
394
+ /**
395
+ * @protected
396
+ * @const
397
+ * @type {number}
398
+ */
399
+ this.resolution = resolution;
400
+
401
+ /**
402
+ * @private
403
+ * @type {number}
404
+ */
405
+ this.alignAndScaleFill_;
406
+
407
+ /**
408
+ * @protected
409
+ * @type {Array<*>}
410
+ */
411
+ this.instructions = instructions.instructions;
412
+
413
+ /**
414
+ * @protected
415
+ * @type {Array<number>}
416
+ */
417
+ this.coordinates = instructions.coordinates;
418
+
419
+ /**
420
+ * @private
421
+ * @type {!Object<number,import("../../coordinate.js").Coordinate|Array<import("../../coordinate.js").Coordinate>|Array<Array<import("../../coordinate.js").Coordinate>>>}
422
+ */
423
+ this.coordinateCache_ = {};
424
+
425
+ /**
426
+ * @private
427
+ * @type {!import("../../transform.js").Transform}
428
+ */
429
+ this.renderedTransform_ = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.create)();
430
+
431
+ /**
432
+ * @protected
433
+ * @type {Array<*>}
434
+ */
435
+ this.hitDetectionInstructions = instructions.hitDetectionInstructions;
436
+
437
+ /**
438
+ * @private
439
+ * @type {Array<number>}
440
+ */
441
+ this.pixelCoordinates_ = null;
442
+
443
+ /**
444
+ * @private
445
+ * @type {number}
446
+ */
447
+ this.viewRotation_ = 0;
448
+
449
+ /**
450
+ * @type {!Object<string, import("../canvas.js").FillState>}
451
+ */
452
+ this.fillStates = instructions.fillStates || {};
453
+
454
+ /**
455
+ * @type {!Object<string, import("../canvas.js").StrokeState>}
456
+ */
457
+ this.strokeStates = instructions.strokeStates || {};
458
+
459
+ /**
460
+ * @type {!Object<string, import("../canvas.js").TextState>}
461
+ */
462
+ this.textStates = instructions.textStates || {};
463
+
464
+ /**
465
+ * @private
466
+ * @type {Object<string, Object<string, number>>}
467
+ */
468
+ this.widths_ = {};
469
+
470
+ /**
471
+ * @private
472
+ * @type {Object<string, import("../canvas.js").Label>}
473
+ */
474
+ this.labels_ = {};
475
+
476
+ /**
477
+ * @private
478
+ * @type {import("../canvas/ZIndexContext.js").default}
479
+ */
480
+ this.zIndexContext_ = deferredRendering ? new _canvas_ZIndexContext_js__WEBPACK_IMPORTED_MODULE_3__["default"]() : null;
481
+ }
482
+
483
+ /**
484
+ * @return {ZIndexContext} ZIndex context.
485
+ */
486
+ getZIndexContext() {
487
+ return this.zIndexContext_;
488
+ }
489
+
490
+ /**
491
+ * @param {string|Array<string>} text Text.
492
+ * @param {string} textKey Text style key.
493
+ * @param {string} fillKey Fill style key.
494
+ * @param {string} strokeKey Stroke style key.
495
+ * @return {import("../canvas.js").Label} Label.
496
+ */
497
+ createLabel(text, textKey, fillKey, strokeKey) {
498
+ const key = text + textKey + fillKey + strokeKey;
499
+ if (this.labels_[key]) {
500
+ return this.labels_[key];
501
+ }
502
+ const strokeState = strokeKey ? this.strokeStates[strokeKey] : null;
503
+ const fillState = fillKey ? this.fillStates[fillKey] : null;
504
+ const textState = this.textStates[textKey];
505
+ const pixelRatio = this.pixelRatio;
506
+ const scale = [
507
+ textState.scale[0] * pixelRatio,
508
+ textState.scale[1] * pixelRatio,
509
+ ];
510
+ const align = textState.justify
511
+ ? _TextBuilder_js__WEBPACK_IMPORTED_MODULE_1__.TEXT_ALIGN[textState.justify]
512
+ : horizontalTextAlign(
513
+ Array.isArray(text) ? text[0] : text,
514
+ textState.textAlign || _canvas_js__WEBPACK_IMPORTED_MODULE_4__.defaultTextAlign,
515
+ );
516
+ const strokeWidth =
517
+ strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
518
+
519
+ const chunks = Array.isArray(text)
520
+ ? text
521
+ : String(text).split('\n').reduce(createTextChunks, []);
522
+
523
+ const {width, height, widths, heights, lineWidths} = (0,_canvas_js__WEBPACK_IMPORTED_MODULE_4__.getTextDimensions)(
524
+ textState,
525
+ chunks,
526
+ );
527
+ const renderWidth = width + strokeWidth;
528
+ const contextInstructions = [];
529
+ // make canvas 2 pixels wider to account for italic text width measurement errors
530
+ const w = (renderWidth + 2) * scale[0];
531
+ const h = (height + strokeWidth) * scale[1];
532
+ /** @type {import("../canvas.js").Label} */
533
+ const label = {
534
+ width: w < 0 ? Math.floor(w) : Math.ceil(w),
535
+ height: h < 0 ? Math.floor(h) : Math.ceil(h),
536
+ contextInstructions: contextInstructions,
537
+ };
538
+ if (scale[0] != 1 || scale[1] != 1) {
539
+ contextInstructions.push('scale', scale);
540
+ }
541
+ if (strokeKey) {
542
+ contextInstructions.push('strokeStyle', strokeState.strokeStyle);
543
+ contextInstructions.push('lineWidth', strokeWidth);
544
+ contextInstructions.push('lineCap', strokeState.lineCap);
545
+ contextInstructions.push('lineJoin', strokeState.lineJoin);
546
+ contextInstructions.push('miterLimit', strokeState.miterLimit);
547
+ contextInstructions.push('setLineDash', [strokeState.lineDash]);
548
+ contextInstructions.push('lineDashOffset', strokeState.lineDashOffset);
549
+ }
550
+ if (fillKey) {
551
+ contextInstructions.push('fillStyle', fillState.fillStyle);
552
+ }
553
+ contextInstructions.push('textBaseline', 'middle');
554
+ contextInstructions.push('textAlign', 'center');
555
+ const leftRight = 0.5 - align;
556
+ let x = align * renderWidth + leftRight * strokeWidth;
557
+ const strokeInstructions = [];
558
+ const fillInstructions = [];
559
+ let lineHeight = 0;
560
+ let lineOffset = 0;
561
+ let widthHeightIndex = 0;
562
+ let lineWidthIndex = 0;
563
+ let previousFont;
564
+ for (let i = 0, ii = chunks.length; i < ii; i += 2) {
565
+ const text = chunks[i];
566
+ if (text === '\n') {
567
+ lineOffset += lineHeight;
568
+ lineHeight = 0;
569
+ x = align * renderWidth + leftRight * strokeWidth;
570
+ ++lineWidthIndex;
571
+ continue;
572
+ }
573
+ const font = chunks[i + 1] || textState.font;
574
+ if (font !== previousFont) {
575
+ if (strokeKey) {
576
+ strokeInstructions.push('font', font);
577
+ }
578
+ if (fillKey) {
579
+ fillInstructions.push('font', font);
580
+ }
581
+ previousFont = font;
582
+ }
583
+ lineHeight = Math.max(lineHeight, heights[widthHeightIndex]);
584
+ const fillStrokeArgs = [
585
+ text,
586
+ x +
587
+ leftRight * widths[widthHeightIndex] +
588
+ align * (widths[widthHeightIndex] - lineWidths[lineWidthIndex]),
589
+ 0.5 * (strokeWidth + lineHeight) + lineOffset,
590
+ ];
591
+ x += widths[widthHeightIndex];
592
+ if (strokeKey) {
593
+ strokeInstructions.push('strokeText', fillStrokeArgs);
594
+ }
595
+ if (fillKey) {
596
+ fillInstructions.push('fillText', fillStrokeArgs);
597
+ }
598
+ ++widthHeightIndex;
599
+ }
600
+ Array.prototype.push.apply(contextInstructions, strokeInstructions);
601
+ Array.prototype.push.apply(contextInstructions, fillInstructions);
602
+ this.labels_[key] = label;
603
+ return label;
604
+ }
605
+
606
+ /**
607
+ * @param {CanvasRenderingContext2D} context Context.
608
+ * @param {import("../../coordinate.js").Coordinate} p1 1st point of the background box.
609
+ * @param {import("../../coordinate.js").Coordinate} p2 2nd point of the background box.
610
+ * @param {import("../../coordinate.js").Coordinate} p3 3rd point of the background box.
611
+ * @param {import("../../coordinate.js").Coordinate} p4 4th point of the background box.
612
+ * @param {Array<*>} fillInstruction Fill instruction.
613
+ * @param {Array<*>} strokeInstruction Stroke instruction.
614
+ */
615
+ replayTextBackground_(
616
+ context,
617
+ p1,
618
+ p2,
619
+ p3,
620
+ p4,
621
+ fillInstruction,
622
+ strokeInstruction,
623
+ ) {
624
+ context.beginPath();
625
+ context.moveTo.apply(context, p1);
626
+ context.lineTo.apply(context, p2);
627
+ context.lineTo.apply(context, p3);
628
+ context.lineTo.apply(context, p4);
629
+ context.lineTo.apply(context, p1);
630
+ if (fillInstruction) {
631
+ this.alignAndScaleFill_ = /** @type {number} */ (fillInstruction[2]);
632
+ context.fillStyle = /** @type {string} */ (fillInstruction[1]);
633
+ this.fill_(context);
634
+ }
635
+ if (strokeInstruction) {
636
+ this.setStrokeStyle_(
637
+ context,
638
+ /** @type {Array<*>} */ (strokeInstruction),
639
+ );
640
+ context.stroke();
641
+ }
642
+ }
643
+
644
+ /**
645
+ * @private
646
+ * @param {number} sheetWidth Width of the sprite sheet.
647
+ * @param {number} sheetHeight Height of the sprite sheet.
648
+ * @param {number} centerX X.
649
+ * @param {number} centerY Y.
650
+ * @param {number} width Width.
651
+ * @param {number} height Height.
652
+ * @param {number} anchorX Anchor X.
653
+ * @param {number} anchorY Anchor Y.
654
+ * @param {number} originX Origin X.
655
+ * @param {number} originY Origin Y.
656
+ * @param {number} rotation Rotation.
657
+ * @param {import("../../size.js").Size} scale Scale.
658
+ * @param {boolean} snapToPixel Snap to pixel.
659
+ * @param {Array<number>} padding Padding.
660
+ * @param {boolean} fillStroke Background fill or stroke.
661
+ * @param {import("../../Feature.js").FeatureLike} feature Feature.
662
+ * @return {ImageOrLabelDimensions} Dimensions for positioning and decluttering the image or label.
663
+ */
664
+ calculateImageOrLabelDimensions_(
665
+ sheetWidth,
666
+ sheetHeight,
667
+ centerX,
668
+ centerY,
669
+ width,
670
+ height,
671
+ anchorX,
672
+ anchorY,
673
+ originX,
674
+ originY,
675
+ rotation,
676
+ scale,
677
+ snapToPixel,
678
+ padding,
679
+ fillStroke,
680
+ feature,
681
+ ) {
682
+ anchorX *= scale[0];
683
+ anchorY *= scale[1];
684
+ let x = centerX - anchorX;
685
+ let y = centerY - anchorY;
686
+
687
+ const w = width + originX > sheetWidth ? sheetWidth - originX : width;
688
+ const h = height + originY > sheetHeight ? sheetHeight - originY : height;
689
+ const boxW = padding[3] + w * scale[0] + padding[1];
690
+ const boxH = padding[0] + h * scale[1] + padding[2];
691
+ const boxX = x - padding[3];
692
+ const boxY = y - padding[0];
693
+
694
+ if (fillStroke || rotation !== 0) {
695
+ p1[0] = boxX;
696
+ p4[0] = boxX;
697
+ p1[1] = boxY;
698
+ p2[1] = boxY;
699
+ p2[0] = boxX + boxW;
700
+ p3[0] = p2[0];
701
+ p3[1] = boxY + boxH;
702
+ p4[1] = p3[1];
703
+ }
704
+
705
+ let transform;
706
+ if (rotation !== 0) {
707
+ transform = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.compose)(
708
+ (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.create)(),
709
+ centerX,
710
+ centerY,
711
+ 1,
712
+ 1,
713
+ rotation,
714
+ -centerX,
715
+ -centerY,
716
+ );
717
+
718
+ (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(transform, p1);
719
+ (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(transform, p2);
720
+ (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(transform, p3);
721
+ (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(transform, p4);
722
+ (0,_extent_js__WEBPACK_IMPORTED_MODULE_0__.createOrUpdate)(
723
+ Math.min(p1[0], p2[0], p3[0], p4[0]),
724
+ Math.min(p1[1], p2[1], p3[1], p4[1]),
725
+ Math.max(p1[0], p2[0], p3[0], p4[0]),
726
+ Math.max(p1[1], p2[1], p3[1], p4[1]),
727
+ tmpExtent,
728
+ );
729
+ } else {
730
+ (0,_extent_js__WEBPACK_IMPORTED_MODULE_0__.createOrUpdate)(
731
+ Math.min(boxX, boxX + boxW),
732
+ Math.min(boxY, boxY + boxH),
733
+ Math.max(boxX, boxX + boxW),
734
+ Math.max(boxY, boxY + boxH),
735
+ tmpExtent,
736
+ );
737
+ }
738
+ if (snapToPixel) {
739
+ x = Math.round(x);
740
+ y = Math.round(y);
741
+ }
742
+ return {
743
+ drawImageX: x,
744
+ drawImageY: y,
745
+ drawImageW: w,
746
+ drawImageH: h,
747
+ originX: originX,
748
+ originY: originY,
749
+ declutterBox: {
750
+ minX: tmpExtent[0],
751
+ minY: tmpExtent[1],
752
+ maxX: tmpExtent[2],
753
+ maxY: tmpExtent[3],
754
+ value: feature,
755
+ },
756
+ canvasTransform: transform,
757
+ scale: scale,
758
+ };
759
+ }
760
+
761
+ /**
762
+ * @private
763
+ * @param {CanvasRenderingContext2D} context Context.
764
+ * @param {import('../../size.js').Size} scaledCanvasSize Scaled canvas size.
765
+ * @param {import("../canvas.js").Label|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} imageOrLabel Image.
766
+ * @param {ImageOrLabelDimensions} dimensions Dimensions.
767
+ * @param {number} opacity Opacity.
768
+ * @param {Array<*>} fillInstruction Fill instruction.
769
+ * @param {Array<*>} strokeInstruction Stroke instruction.
770
+ * @return {boolean} The image or label was rendered.
771
+ */
772
+ replayImageOrLabel_(
773
+ context,
774
+ scaledCanvasSize,
775
+ imageOrLabel,
776
+ dimensions,
777
+ opacity,
778
+ fillInstruction,
779
+ strokeInstruction,
780
+ ) {
781
+ const fillStroke = !!(fillInstruction || strokeInstruction);
782
+
783
+ const box = dimensions.declutterBox;
784
+ const strokePadding = strokeInstruction
785
+ ? (strokeInstruction[2] * dimensions.scale[0]) / 2
786
+ : 0;
787
+ const intersects =
788
+ box.minX - strokePadding <= scaledCanvasSize[0] &&
789
+ box.maxX + strokePadding >= 0 &&
790
+ box.minY - strokePadding <= scaledCanvasSize[1] &&
791
+ box.maxY + strokePadding >= 0;
792
+
793
+ if (intersects) {
794
+ if (fillStroke) {
795
+ this.replayTextBackground_(
796
+ context,
797
+ p1,
798
+ p2,
799
+ p3,
800
+ p4,
801
+ /** @type {Array<*>} */ (fillInstruction),
802
+ /** @type {Array<*>} */ (strokeInstruction),
803
+ );
804
+ }
805
+ (0,_canvas_js__WEBPACK_IMPORTED_MODULE_4__.drawImageOrLabel)(
806
+ context,
807
+ dimensions.canvasTransform,
808
+ opacity,
809
+ imageOrLabel,
810
+ dimensions.originX,
811
+ dimensions.originY,
812
+ dimensions.drawImageW,
813
+ dimensions.drawImageH,
814
+ dimensions.drawImageX,
815
+ dimensions.drawImageY,
816
+ dimensions.scale,
817
+ );
818
+ }
819
+ return true;
820
+ }
821
+
822
+ /**
823
+ * @private
824
+ * @param {CanvasRenderingContext2D} context Context.
825
+ */
826
+ fill_(context) {
827
+ const alignAndScale = this.alignAndScaleFill_;
828
+ if (alignAndScale) {
829
+ const origin = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(this.renderedTransform_, [0, 0]);
830
+ const repeatSize = 512 * this.pixelRatio;
831
+ context.save();
832
+ context.translate(origin[0] % repeatSize, origin[1] % repeatSize);
833
+ if (alignAndScale !== 1) {
834
+ context.scale(alignAndScale, alignAndScale);
835
+ }
836
+ context.rotate(this.viewRotation_);
837
+ }
838
+ context.fill();
839
+ if (alignAndScale) {
840
+ context.restore();
841
+ }
842
+ }
843
+
844
+ /**
845
+ * @private
846
+ * @param {CanvasRenderingContext2D} context Context.
847
+ * @param {Array<*>} instruction Instruction.
848
+ */
849
+ setStrokeStyle_(context, instruction) {
850
+ context.strokeStyle =
851
+ /** @type {import("../../colorlike.js").ColorLike} */ (instruction[1]);
852
+ if (!instruction[1]) {
853
+ return;
854
+ }
855
+ context.lineWidth = /** @type {number} */ (instruction[2]);
856
+ context.lineCap = /** @type {CanvasLineCap} */ (instruction[3]);
857
+ context.lineJoin = /** @type {CanvasLineJoin} */ (instruction[4]);
858
+ context.miterLimit = /** @type {number} */ (instruction[5]);
859
+ context.lineDashOffset = /** @type {number} */ (instruction[7]);
860
+ context.setLineDash(/** @type {Array<number>} */ (instruction[6]));
861
+ }
862
+
863
+ /**
864
+ * @private
865
+ * @param {string|Array<string>} text The text to draw.
866
+ * @param {string} textKey The key of the text state.
867
+ * @param {string} strokeKey The key for the stroke state.
868
+ * @param {string} fillKey The key for the fill state.
869
+ * @return {{label: import("../canvas.js").Label, anchorX: number, anchorY: number}} The text image and its anchor.
870
+ */
871
+ drawLabelWithPointPlacement_(text, textKey, strokeKey, fillKey) {
872
+ const textState = this.textStates[textKey];
873
+
874
+ const label = this.createLabel(text, textKey, fillKey, strokeKey);
875
+
876
+ const strokeState = this.strokeStates[strokeKey];
877
+ const pixelRatio = this.pixelRatio;
878
+ const align = horizontalTextAlign(
879
+ Array.isArray(text) ? text[0] : text,
880
+ textState.textAlign || _canvas_js__WEBPACK_IMPORTED_MODULE_4__.defaultTextAlign,
881
+ );
882
+ const baseline = _TextBuilder_js__WEBPACK_IMPORTED_MODULE_1__.TEXT_ALIGN[textState.textBaseline || _canvas_js__WEBPACK_IMPORTED_MODULE_4__.defaultTextBaseline];
883
+ const strokeWidth =
884
+ strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
885
+
886
+ // Remove the 2 pixels we added in createLabel() for the anchor
887
+ const width = label.width / pixelRatio - 2 * textState.scale[0];
888
+ const anchorX = align * width + 2 * (0.5 - align) * strokeWidth;
889
+ const anchorY =
890
+ (baseline * label.height) / pixelRatio +
891
+ 2 * (0.5 - baseline) * strokeWidth;
892
+
893
+ return {
894
+ label: label,
895
+ anchorX: anchorX,
896
+ anchorY: anchorY,
897
+ };
898
+ }
899
+
900
+ /**
901
+ * @private
902
+ * @param {CanvasRenderingContext2D} context Context.
903
+ * @param {import('../../size.js').Size} scaledCanvasSize Scaled canvas size
904
+ * @param {import("../../transform.js").Transform} transform Transform.
905
+ * @param {Array<*>} instructions Instructions array.
906
+ * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
907
+ * @param {FeatureCallback<T>} [featureCallback] Feature callback.
908
+ * @param {import("../../extent.js").Extent} [hitExtent] Only check
909
+ * features that intersect this extent.
910
+ * @param {import("rbush").default<DeclutterEntry>} [declutterTree] Declutter tree.
911
+ * @return {T|undefined} Callback result.
912
+ * @template T
913
+ */
914
+ execute_(
915
+ context,
916
+ scaledCanvasSize,
917
+ transform,
918
+ instructions,
919
+ snapToPixel,
920
+ featureCallback,
921
+ hitExtent,
922
+ declutterTree,
923
+ ) {
924
+ const zIndexContext = this.zIndexContext_;
925
+ /** @type {Array<number>} */
926
+ let pixelCoordinates;
927
+ if (this.pixelCoordinates_ && (0,_array_js__WEBPACK_IMPORTED_MODULE_5__.equals)(transform, this.renderedTransform_)) {
928
+ pixelCoordinates = this.pixelCoordinates_;
929
+ } else {
930
+ if (!this.pixelCoordinates_) {
931
+ this.pixelCoordinates_ = [];
932
+ }
933
+ pixelCoordinates = (0,_geom_flat_transform_js__WEBPACK_IMPORTED_MODULE_6__.transform2D)(
934
+ this.coordinates,
935
+ 0,
936
+ this.coordinates.length,
937
+ 2,
938
+ transform,
939
+ this.pixelCoordinates_,
940
+ );
941
+ (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.setFromArray)(this.renderedTransform_, transform);
942
+ }
943
+ let i = 0; // instruction index
944
+ const ii = instructions.length; // end of instructions
945
+ let d = 0; // data index
946
+ let dd; // end of per-instruction data
947
+ let anchorX,
948
+ anchorY,
949
+ /** @type {import('../../style/Style.js').DeclutterMode} */
950
+ declutterMode,
951
+ prevX,
952
+ prevY,
953
+ roundX,
954
+ roundY,
955
+ image,
956
+ text,
957
+ textKey,
958
+ strokeKey,
959
+ fillKey;
960
+ let pendingFill = 0;
961
+ let pendingStroke = 0;
962
+ const coordinateCache = this.coordinateCache_;
963
+ const viewRotation = this.viewRotation_;
964
+ const viewRotationFromTransform =
965
+ Math.round(Math.atan2(-transform[1], transform[0]) * 1e12) / 1e12;
966
+
967
+ const state = /** @type {import("../../render.js").State} */ ({
968
+ context: context,
969
+ pixelRatio: this.pixelRatio,
970
+ resolution: this.resolution,
971
+ rotation: viewRotation,
972
+ });
973
+
974
+ // When the batch size gets too big, performance decreases. 200 is a good
975
+ // balance between batch size and number of fill/stroke instructions.
976
+ const batchSize =
977
+ this.instructions != instructions || this.overlaps ? 0 : 200;
978
+ let /** @type {import("../../Feature.js").FeatureLike} */ feature;
979
+ let x, y, currentGeometry;
980
+ while (i < ii) {
981
+ const instruction = instructions[i];
982
+ const type = /** @type {import("./Instruction.js").default} */ (
983
+ instruction[0]
984
+ );
985
+ switch (type) {
986
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].BEGIN_GEOMETRY:
987
+ feature = /** @type {import("../../Feature.js").FeatureLike} */ (
988
+ instruction[1]
989
+ );
990
+ currentGeometry = instruction[3];
991
+ if (!feature.getGeometry()) {
992
+ i = /** @type {number} */ (instruction[2]);
993
+ } else if (
994
+ hitExtent !== undefined &&
995
+ !(0,_extent_js__WEBPACK_IMPORTED_MODULE_0__.intersects)(hitExtent, currentGeometry.getExtent())
996
+ ) {
997
+ i = /** @type {number} */ (instruction[2]) + 1;
998
+ } else {
999
+ ++i;
1000
+ }
1001
+ if (zIndexContext) {
1002
+ zIndexContext.zIndex = instruction[4];
1003
+ }
1004
+ break;
1005
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].BEGIN_PATH:
1006
+ if (pendingFill > batchSize) {
1007
+ this.fill_(context);
1008
+ pendingFill = 0;
1009
+ }
1010
+ if (pendingStroke > batchSize) {
1011
+ context.stroke();
1012
+ pendingStroke = 0;
1013
+ }
1014
+ if (!pendingFill && !pendingStroke) {
1015
+ context.beginPath();
1016
+ prevX = NaN;
1017
+ prevY = NaN;
1018
+ }
1019
+ ++i;
1020
+ break;
1021
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].CIRCLE:
1022
+ d = /** @type {number} */ (instruction[1]);
1023
+ const x1 = pixelCoordinates[d];
1024
+ const y1 = pixelCoordinates[d + 1];
1025
+ const x2 = pixelCoordinates[d + 2];
1026
+ const y2 = pixelCoordinates[d + 3];
1027
+ const dx = x2 - x1;
1028
+ const dy = y2 - y1;
1029
+ const r = Math.sqrt(dx * dx + dy * dy);
1030
+ context.moveTo(x1 + r, y1);
1031
+ context.arc(x1, y1, r, 0, 2 * Math.PI, true);
1032
+ ++i;
1033
+ break;
1034
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].CLOSE_PATH:
1035
+ context.closePath();
1036
+ ++i;
1037
+ break;
1038
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].CUSTOM:
1039
+ d = /** @type {number} */ (instruction[1]);
1040
+ dd = instruction[2];
1041
+ const geometry =
1042
+ /** @type {import("../../geom/SimpleGeometry.js").default} */ (
1043
+ instruction[3]
1044
+ );
1045
+ const renderer = instruction[4];
1046
+ const fn = instruction[5];
1047
+ state.geometry = geometry;
1048
+ state.feature = feature;
1049
+ if (!(i in coordinateCache)) {
1050
+ coordinateCache[i] = [];
1051
+ }
1052
+ const coords = coordinateCache[i];
1053
+ if (fn) {
1054
+ fn(pixelCoordinates, d, dd, 2, coords);
1055
+ } else {
1056
+ coords[0] = pixelCoordinates[d];
1057
+ coords[1] = pixelCoordinates[d + 1];
1058
+ coords.length = 2;
1059
+ }
1060
+ if (zIndexContext) {
1061
+ zIndexContext.zIndex = instruction[6];
1062
+ }
1063
+ renderer(coords, state);
1064
+ ++i;
1065
+ break;
1066
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].DRAW_IMAGE:
1067
+ d = /** @type {number} */ (instruction[1]);
1068
+ dd = /** @type {number} */ (instruction[2]);
1069
+ image =
1070
+ /** @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} */ (
1071
+ instruction[3]
1072
+ );
1073
+
1074
+ // Remaining arguments in DRAW_IMAGE are in alphabetical order
1075
+ anchorX = /** @type {number} */ (instruction[4]);
1076
+ anchorY = /** @type {number} */ (instruction[5]);
1077
+ let height = /** @type {number} */ (instruction[6]);
1078
+ const opacity = /** @type {number} */ (instruction[7]);
1079
+ const originX = /** @type {number} */ (instruction[8]);
1080
+ const originY = /** @type {number} */ (instruction[9]);
1081
+ const rotateWithView = /** @type {boolean} */ (instruction[10]);
1082
+ let rotation = /** @type {number} */ (instruction[11]);
1083
+ const scale = /** @type {import("../../size.js").Size} */ (
1084
+ instruction[12]
1085
+ );
1086
+ let width = /** @type {number} */ (instruction[13]);
1087
+ declutterMode = instruction[14] || 'declutter';
1088
+ const declutterImageWithText =
1089
+ /** @type {{args: import("../canvas.js").DeclutterImageWithText, declutterMode: import('../../style/Style.js').DeclutterMode}} */ (
1090
+ instruction[15]
1091
+ );
1092
+
1093
+ if (!image && instruction.length >= 20) {
1094
+ // create label images
1095
+ text = /** @type {string} */ (instruction[19]);
1096
+ textKey = /** @type {string} */ (instruction[20]);
1097
+ strokeKey = /** @type {string} */ (instruction[21]);
1098
+ fillKey = /** @type {string} */ (instruction[22]);
1099
+ const labelWithAnchor = this.drawLabelWithPointPlacement_(
1100
+ text,
1101
+ textKey,
1102
+ strokeKey,
1103
+ fillKey,
1104
+ );
1105
+ image = labelWithAnchor.label;
1106
+ instruction[3] = image;
1107
+ const textOffsetX = /** @type {number} */ (instruction[23]);
1108
+ anchorX = (labelWithAnchor.anchorX - textOffsetX) * this.pixelRatio;
1109
+ instruction[4] = anchorX;
1110
+ const textOffsetY = /** @type {number} */ (instruction[24]);
1111
+ anchorY = (labelWithAnchor.anchorY - textOffsetY) * this.pixelRatio;
1112
+ instruction[5] = anchorY;
1113
+ height = image.height;
1114
+ instruction[6] = height;
1115
+ width = image.width;
1116
+ instruction[13] = width;
1117
+ }
1118
+
1119
+ let geometryWidths;
1120
+ if (instruction.length > 25) {
1121
+ geometryWidths = /** @type {number} */ (instruction[25]);
1122
+ }
1123
+
1124
+ let padding, backgroundFillInstruction, backgroundStrokeInstruction;
1125
+ if (instruction.length > 17) {
1126
+ padding = /** @type {Array<number>} */ (instruction[16]);
1127
+ backgroundFillInstruction = /** @type {Array<*>} */ (
1128
+ instruction[17]
1129
+ );
1130
+ backgroundStrokeInstruction = /** @type {Array<*>} */ (
1131
+ instruction[18]
1132
+ );
1133
+ } else {
1134
+ padding = _canvas_js__WEBPACK_IMPORTED_MODULE_4__.defaultPadding;
1135
+ backgroundFillInstruction = null;
1136
+ backgroundStrokeInstruction = null;
1137
+ }
1138
+
1139
+ if (rotateWithView && viewRotationFromTransform) {
1140
+ // Canvas is expected to be rotated to reverse view rotation.
1141
+ rotation += viewRotation;
1142
+ } else if (!rotateWithView && !viewRotationFromTransform) {
1143
+ // Canvas is not rotated, images need to be rotated back to be north-up.
1144
+ rotation -= viewRotation;
1145
+ }
1146
+ let widthIndex = 0;
1147
+ for (; d < dd; d += 2) {
1148
+ if (
1149
+ geometryWidths &&
1150
+ geometryWidths[widthIndex++] < width / this.pixelRatio
1151
+ ) {
1152
+ continue;
1153
+ }
1154
+ const dimensions = this.calculateImageOrLabelDimensions_(
1155
+ image.width,
1156
+ image.height,
1157
+ pixelCoordinates[d],
1158
+ pixelCoordinates[d + 1],
1159
+ width,
1160
+ height,
1161
+ anchorX,
1162
+ anchorY,
1163
+ originX,
1164
+ originY,
1165
+ rotation,
1166
+ scale,
1167
+ snapToPixel,
1168
+ padding,
1169
+ !!backgroundFillInstruction || !!backgroundStrokeInstruction,
1170
+ feature,
1171
+ );
1172
+ /** @type {ReplayImageOrLabelArgs} */
1173
+ const args = [
1174
+ context,
1175
+ scaledCanvasSize,
1176
+ image,
1177
+ dimensions,
1178
+ opacity,
1179
+ backgroundFillInstruction,
1180
+ backgroundStrokeInstruction,
1181
+ ];
1182
+ if (declutterTree) {
1183
+ let imageArgs, imageDeclutterMode, imageDeclutterBox;
1184
+ if (declutterImageWithText) {
1185
+ const index = dd - d;
1186
+ if (!declutterImageWithText[index]) {
1187
+ // We now have the image for an image+text combination.
1188
+ declutterImageWithText[index] = {args, declutterMode};
1189
+ // Don't render anything for now, wait for the text.
1190
+ continue;
1191
+ }
1192
+ const imageDeclutter = declutterImageWithText[index];
1193
+ imageArgs = imageDeclutter.args;
1194
+ imageDeclutterMode = imageDeclutter.declutterMode;
1195
+ delete declutterImageWithText[index];
1196
+ imageDeclutterBox = getDeclutterBox(imageArgs);
1197
+ }
1198
+ // We now have image and text for an image+text combination.
1199
+ let renderImage, renderText;
1200
+ if (
1201
+ imageArgs &&
1202
+ (imageDeclutterMode !== 'declutter' ||
1203
+ !declutterTree.collides(imageDeclutterBox))
1204
+ ) {
1205
+ renderImage = true;
1206
+ }
1207
+ if (
1208
+ declutterMode !== 'declutter' ||
1209
+ !declutterTree.collides(dimensions.declutterBox)
1210
+ ) {
1211
+ renderText = true;
1212
+ }
1213
+ if (
1214
+ imageDeclutterMode === 'declutter' &&
1215
+ declutterMode === 'declutter'
1216
+ ) {
1217
+ const render = renderImage && renderText;
1218
+ renderImage = render;
1219
+ renderText = render;
1220
+ }
1221
+ if (renderImage) {
1222
+ if (imageDeclutterMode !== 'none') {
1223
+ declutterTree.insert(imageDeclutterBox);
1224
+ }
1225
+ this.replayImageOrLabel_.apply(this, imageArgs);
1226
+ }
1227
+ if (renderText) {
1228
+ if (declutterMode !== 'none') {
1229
+ declutterTree.insert(dimensions.declutterBox);
1230
+ }
1231
+ this.replayImageOrLabel_.apply(this, args);
1232
+ }
1233
+ } else {
1234
+ this.replayImageOrLabel_.apply(this, args);
1235
+ }
1236
+ }
1237
+ ++i;
1238
+ break;
1239
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].DRAW_CHARS:
1240
+ const begin = /** @type {number} */ (instruction[1]);
1241
+ const end = /** @type {number} */ (instruction[2]);
1242
+ const baseline = /** @type {number} */ (instruction[3]);
1243
+ const overflow = /** @type {number} */ (instruction[4]);
1244
+ fillKey = /** @type {string} */ (instruction[5]);
1245
+ const maxAngle = /** @type {number} */ (instruction[6]);
1246
+ const measurePixelRatio = /** @type {number} */ (instruction[7]);
1247
+ const offsetY = /** @type {number} */ (instruction[8]);
1248
+ strokeKey = /** @type {string} */ (instruction[9]);
1249
+ const strokeWidth = /** @type {number} */ (instruction[10]);
1250
+ text = /** @type {string|Array<string>} */ (instruction[11]);
1251
+ if (Array.isArray(text)) {
1252
+ //FIXME Add support for rich text along lines
1253
+ text = text.reduce(richTextToPlainText, '');
1254
+ }
1255
+ textKey = /** @type {string} */ (instruction[12]);
1256
+ const pixelRatioScale = [
1257
+ /** @type {number} */ (instruction[13]),
1258
+ /** @type {number} */ (instruction[13]),
1259
+ ];
1260
+ declutterMode = instruction[14] || 'declutter';
1261
+
1262
+ const textKeepUpright = /** @type {boolean} */ (instruction[15]);
1263
+ const textState = this.textStates[textKey];
1264
+ const font = textState.font;
1265
+ const textScale = [
1266
+ textState.scale[0] * measurePixelRatio,
1267
+ textState.scale[1] * measurePixelRatio,
1268
+ ];
1269
+
1270
+ let cachedWidths;
1271
+ if (font in this.widths_) {
1272
+ cachedWidths = this.widths_[font];
1273
+ } else {
1274
+ cachedWidths = {};
1275
+ this.widths_[font] = cachedWidths;
1276
+ }
1277
+
1278
+ const pathLength = (0,_geom_flat_length_js__WEBPACK_IMPORTED_MODULE_8__.lineStringLength)(pixelCoordinates, begin, end, 2);
1279
+ const textLength =
1280
+ Math.abs(textScale[0]) *
1281
+ (0,_canvas_js__WEBPACK_IMPORTED_MODULE_4__.measureAndCacheTextWidth)(font, text, cachedWidths);
1282
+ if (overflow || textLength <= pathLength) {
1283
+ const textAlign = this.textStates[textKey].textAlign;
1284
+ const startM =
1285
+ (pathLength - textLength) * horizontalTextAlign(text, textAlign);
1286
+ const parts = (0,_geom_flat_textpath_js__WEBPACK_IMPORTED_MODULE_9__.drawTextOnPath)(
1287
+ pixelCoordinates,
1288
+ begin,
1289
+ end,
1290
+ 2,
1291
+ text,
1292
+ startM,
1293
+ maxAngle,
1294
+ Math.abs(textScale[0]),
1295
+ _canvas_js__WEBPACK_IMPORTED_MODULE_4__.measureAndCacheTextWidth,
1296
+ font,
1297
+ cachedWidths,
1298
+ viewRotationFromTransform ? 0 : this.viewRotation_,
1299
+ textKeepUpright,
1300
+ );
1301
+ drawChars: if (parts) {
1302
+ /** @type {Array<ReplayImageOrLabelArgs>} */
1303
+ const replayImageOrLabelArgs = [];
1304
+ let c, cc, chars, label, part;
1305
+ if (strokeKey) {
1306
+ for (c = 0, cc = parts.length; c < cc; ++c) {
1307
+ part = parts[c]; // x, y, anchorX, rotation, chunk
1308
+ chars = /** @type {string} */ (part[4]);
1309
+ label = this.createLabel(chars, textKey, '', strokeKey);
1310
+ anchorX =
1311
+ /** @type {number} */ (part[2]) +
1312
+ (textScale[0] < 0 ? -strokeWidth : strokeWidth);
1313
+ anchorY =
1314
+ baseline * label.height +
1315
+ ((0.5 - baseline) * 2 * strokeWidth * textScale[1]) /
1316
+ textScale[0] -
1317
+ offsetY;
1318
+ const dimensions = this.calculateImageOrLabelDimensions_(
1319
+ label.width,
1320
+ label.height,
1321
+ part[0],
1322
+ part[1],
1323
+ label.width,
1324
+ label.height,
1325
+ anchorX,
1326
+ anchorY,
1327
+ 0,
1328
+ 0,
1329
+ part[3],
1330
+ pixelRatioScale,
1331
+ false,
1332
+ _canvas_js__WEBPACK_IMPORTED_MODULE_4__.defaultPadding,
1333
+ false,
1334
+ feature,
1335
+ );
1336
+ if (
1337
+ declutterTree &&
1338
+ declutterMode === 'declutter' &&
1339
+ declutterTree.collides(dimensions.declutterBox)
1340
+ ) {
1341
+ break drawChars;
1342
+ }
1343
+ replayImageOrLabelArgs.push([
1344
+ context,
1345
+ scaledCanvasSize,
1346
+ label,
1347
+ dimensions,
1348
+ 1,
1349
+ null,
1350
+ null,
1351
+ ]);
1352
+ }
1353
+ }
1354
+ if (fillKey) {
1355
+ for (c = 0, cc = parts.length; c < cc; ++c) {
1356
+ part = parts[c]; // x, y, anchorX, rotation, chunk
1357
+ chars = /** @type {string} */ (part[4]);
1358
+ label = this.createLabel(chars, textKey, fillKey, '');
1359
+ anchorX = /** @type {number} */ (part[2]);
1360
+ anchorY = baseline * label.height - offsetY;
1361
+ const dimensions = this.calculateImageOrLabelDimensions_(
1362
+ label.width,
1363
+ label.height,
1364
+ part[0],
1365
+ part[1],
1366
+ label.width,
1367
+ label.height,
1368
+ anchorX,
1369
+ anchorY,
1370
+ 0,
1371
+ 0,
1372
+ part[3],
1373
+ pixelRatioScale,
1374
+ false,
1375
+ _canvas_js__WEBPACK_IMPORTED_MODULE_4__.defaultPadding,
1376
+ false,
1377
+ feature,
1378
+ );
1379
+ if (
1380
+ declutterTree &&
1381
+ declutterMode === 'declutter' &&
1382
+ declutterTree.collides(dimensions.declutterBox)
1383
+ ) {
1384
+ break drawChars;
1385
+ }
1386
+ replayImageOrLabelArgs.push([
1387
+ context,
1388
+ scaledCanvasSize,
1389
+ label,
1390
+ dimensions,
1391
+ 1,
1392
+ null,
1393
+ null,
1394
+ ]);
1395
+ }
1396
+ }
1397
+ if (declutterTree && declutterMode !== 'none') {
1398
+ declutterTree.load(replayImageOrLabelArgs.map(getDeclutterBox));
1399
+ }
1400
+ for (let i = 0, ii = replayImageOrLabelArgs.length; i < ii; ++i) {
1401
+ this.replayImageOrLabel_.apply(this, replayImageOrLabelArgs[i]);
1402
+ }
1403
+ }
1404
+ }
1405
+ ++i;
1406
+ break;
1407
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].END_GEOMETRY:
1408
+ if (featureCallback !== undefined) {
1409
+ feature = /** @type {import("../../Feature.js").FeatureLike} */ (
1410
+ instruction[1]
1411
+ );
1412
+ const result = featureCallback(
1413
+ feature,
1414
+ currentGeometry,
1415
+ declutterMode,
1416
+ );
1417
+ if (result) {
1418
+ return result;
1419
+ }
1420
+ }
1421
+ ++i;
1422
+ break;
1423
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].FILL:
1424
+ if (batchSize) {
1425
+ pendingFill++;
1426
+ } else {
1427
+ this.fill_(context);
1428
+ }
1429
+ ++i;
1430
+ break;
1431
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].MOVE_TO_LINE_TO:
1432
+ d = /** @type {number} */ (instruction[1]);
1433
+ dd = /** @type {number} */ (instruction[2]);
1434
+ x = pixelCoordinates[d];
1435
+ y = pixelCoordinates[d + 1];
1436
+ context.moveTo(x, y);
1437
+ prevX = (x + 0.5) | 0;
1438
+ prevY = (y + 0.5) | 0;
1439
+ for (d += 2; d < dd; d += 2) {
1440
+ x = pixelCoordinates[d];
1441
+ y = pixelCoordinates[d + 1];
1442
+ roundX = (x + 0.5) | 0;
1443
+ roundY = (y + 0.5) | 0;
1444
+ if (d == dd - 2 || roundX !== prevX || roundY !== prevY) {
1445
+ context.lineTo(x, y);
1446
+ prevX = roundX;
1447
+ prevY = roundY;
1448
+ }
1449
+ }
1450
+ ++i;
1451
+ break;
1452
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].SET_FILL_STYLE:
1453
+ this.alignAndScaleFill_ = instruction[2];
1454
+
1455
+ if (pendingFill) {
1456
+ this.fill_(context);
1457
+ pendingFill = 0;
1458
+ if (pendingStroke) {
1459
+ context.stroke();
1460
+ pendingStroke = 0;
1461
+ }
1462
+ }
1463
+
1464
+ /** @type {import("../../colorlike.js").ColorLike} */
1465
+ context.fillStyle = instruction[1];
1466
+ ++i;
1467
+ break;
1468
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].SET_STROKE_STYLE:
1469
+ if (pendingStroke) {
1470
+ context.stroke();
1471
+ pendingStroke = 0;
1472
+ }
1473
+ this.setStrokeStyle_(context, /** @type {Array<*>} */ (instruction));
1474
+ ++i;
1475
+ break;
1476
+ case _Instruction_js__WEBPACK_IMPORTED_MODULE_7__["default"].STROKE:
1477
+ if (batchSize) {
1478
+ pendingStroke++;
1479
+ } else {
1480
+ context.stroke();
1481
+ }
1482
+ ++i;
1483
+ break;
1484
+ default: // consume the instruction anyway, to avoid an infinite loop
1485
+ ++i;
1486
+ break;
1487
+ }
1488
+ }
1489
+ if (pendingFill) {
1490
+ this.fill_(context);
1491
+ }
1492
+ if (pendingStroke) {
1493
+ context.stroke();
1494
+ }
1495
+ return undefined;
1496
+ }
1497
+
1498
+ /**
1499
+ * @param {CanvasRenderingContext2D} context Context.
1500
+ * @param {import('../../size.js').Size} scaledCanvasSize Scaled canvas size.
1501
+ * @param {import("../../transform.js").Transform} transform Transform.
1502
+ * @param {number} viewRotation View rotation.
1503
+ * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
1504
+ * @param {import("rbush").default<DeclutterEntry>} [declutterTree] Declutter tree.
1505
+ */
1506
+ execute(
1507
+ context,
1508
+ scaledCanvasSize,
1509
+ transform,
1510
+ viewRotation,
1511
+ snapToPixel,
1512
+ declutterTree,
1513
+ ) {
1514
+ this.viewRotation_ = viewRotation;
1515
+ this.execute_(
1516
+ context,
1517
+ scaledCanvasSize,
1518
+ transform,
1519
+ this.instructions,
1520
+ snapToPixel,
1521
+ undefined,
1522
+ undefined,
1523
+ declutterTree,
1524
+ );
1525
+ }
1526
+
1527
+ /**
1528
+ * @param {CanvasRenderingContext2D} context Context.
1529
+ * @param {import("../../transform.js").Transform} transform Transform.
1530
+ * @param {number} viewRotation View rotation.
1531
+ * @param {FeatureCallback<T>} [featureCallback] Feature callback.
1532
+ * @param {import("../../extent.js").Extent} [hitExtent] Only check
1533
+ * features that intersect this extent.
1534
+ * @return {T|undefined} Callback result.
1535
+ * @template T
1536
+ */
1537
+ executeHitDetection(
1538
+ context,
1539
+ transform,
1540
+ viewRotation,
1541
+ featureCallback,
1542
+ hitExtent,
1543
+ ) {
1544
+ this.viewRotation_ = viewRotation;
1545
+ return this.execute_(
1546
+ context,
1547
+ [context.canvas.width, context.canvas.height],
1548
+ transform,
1549
+ this.hitDetectionInstructions,
1550
+ true,
1551
+ featureCallback,
1552
+ hitExtent,
1553
+ );
1554
+ }
1555
+ }
1556
+
1557
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Executor);
1558
+
1559
+
1560
+ /***/ }),
1561
+
1562
+ /***/ "./node_modules/ol/render/canvas/ZIndexContext.js":
1563
+ /*!********************************************************!*\
1564
+ !*** ./node_modules/ol/render/canvas/ZIndexContext.js ***!
1565
+ \********************************************************/
1566
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1567
+
1568
+ __webpack_require__.r(__webpack_exports__);
1569
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1570
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1571
+ /* harmony export */ });
1572
+ /* harmony import */ var _dom_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../dom.js */ "./node_modules/ol/dom.js");
1573
+ /**
1574
+ * @module ol/render/canvas/ZIndexContext
1575
+ */
1576
+
1577
+
1578
+
1579
+ /** @typedef {CanvasRenderingContext2D & {globalAlpha: any}} ZIndexContextProxy */
1580
+
1581
+ /**
1582
+ * @extends {CanvasRenderingContext2D}
1583
+ */
1584
+ class ZIndexContext {
1585
+ constructor() {
1586
+ /**
1587
+ * @private
1588
+ * @type {Array<Array<*>>}
1589
+ */
1590
+ this.instructions_ = [];
1591
+ /**
1592
+ * @type {number}
1593
+ */
1594
+ this.zIndex = 0;
1595
+ /**
1596
+ * @private
1597
+ * @type {number}
1598
+ */
1599
+ this.offset_ = 0;
1600
+
1601
+ /**
1602
+ * @private
1603
+ * @type {ZIndexContextProxy}
1604
+ */
1605
+ this.context_ = /** @type {ZIndexContextProxy} */ (
1606
+ new Proxy((0,_dom_js__WEBPACK_IMPORTED_MODULE_0__.getSharedCanvasContext2D)(), {
1607
+ get: (target, property) => {
1608
+ if (
1609
+ typeof (/** @type {*} */ ((0,_dom_js__WEBPACK_IMPORTED_MODULE_0__.getSharedCanvasContext2D)())[property]) !==
1610
+ 'function'
1611
+ ) {
1612
+ // we only accept calling functions on the proxy, not accessing properties
1613
+ return undefined;
1614
+ }
1615
+ this.push_(property);
1616
+ return this.pushMethodArgs_;
1617
+ },
1618
+ set: (target, property, value) => {
1619
+ this.push_(property, value);
1620
+ return true;
1621
+ },
1622
+ })
1623
+ );
1624
+ }
1625
+
1626
+ /**
1627
+ * @param {...*} args Arguments to push to the instructions array.
1628
+ * @private
1629
+ */
1630
+ push_(...args) {
1631
+ const instructions = this.instructions_;
1632
+ const index = this.zIndex + this.offset_;
1633
+ if (!instructions[index]) {
1634
+ instructions[index] = [];
1635
+ }
1636
+ instructions[index].push(...args);
1637
+ }
1638
+
1639
+ /**
1640
+ * @private
1641
+ * @param {...*} args Args.
1642
+ * @return {ZIndexContext} This.
1643
+ */
1644
+ pushMethodArgs_ = (...args) => {
1645
+ this.push_(args);
1646
+ return this;
1647
+ };
1648
+
1649
+ /**
1650
+ * Push a function that renders to the context directly.
1651
+ * @param {function(CanvasRenderingContext2D): void} render Function.
1652
+ */
1653
+ pushFunction(render) {
1654
+ this.push_(render);
1655
+ }
1656
+
1657
+ /**
1658
+ * Get a proxy for CanvasRenderingContext2D which does not support getting state
1659
+ * (e.g. `context.globalAlpha`, which will return `undefined`). To set state, if it relies on a
1660
+ * previous state (e.g. `context.globalAlpha = context.globalAlpha / 2`), set a function,
1661
+ * e.g. `context.globalAlpha = (context) => context.globalAlpha / 2`.
1662
+ * @return {ZIndexContextProxy} Context.
1663
+ */
1664
+ getContext() {
1665
+ return this.context_;
1666
+ }
1667
+
1668
+ /**
1669
+ * @param {CanvasRenderingContext2D} context Context.
1670
+ */
1671
+ draw(context) {
1672
+ this.instructions_.forEach((instructionsAtIndex) => {
1673
+ for (let i = 0, ii = instructionsAtIndex.length; i < ii; ++i) {
1674
+ const property = instructionsAtIndex[i];
1675
+ if (typeof property === 'function') {
1676
+ property(context);
1677
+ continue;
1678
+ }
1679
+ const instructionAtIndex = instructionsAtIndex[++i];
1680
+ if (typeof (/** @type {*} */ (context)[property]) === 'function') {
1681
+ /** @type {*} */ (context)[property](...instructionAtIndex);
1682
+ } else {
1683
+ if (typeof instructionAtIndex === 'function') {
1684
+ /** @type {*} */ (context)[property] = instructionAtIndex(context);
1685
+ continue;
1686
+ }
1687
+ /** @type {*} */ (context)[property] = instructionAtIndex;
1688
+ }
1689
+ }
1690
+ });
1691
+ }
1692
+
1693
+ clear() {
1694
+ this.instructions_.length = 0;
1695
+ this.zIndex = 0;
1696
+ this.offset_ = 0;
1697
+ }
1698
+
1699
+ /**
1700
+ * Offsets the zIndex by the highest current zIndex. Useful for rendering multiple worlds or tiles, to
1701
+ * avoid conflicting context.clip() or context.save()/restore() calls.
1702
+ */
1703
+ offset() {
1704
+ this.offset_ = this.instructions_.length;
1705
+ this.zIndex = 0;
1706
+ }
1707
+ }
1708
+
1709
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ZIndexContext);
1710
+
1711
+
1712
+ /***/ })
1713
+
1714
+ }])
1715
+ //# sourceMappingURL=vendors-node_modules_ol_render_canvas_Executor_js.js.map