@vaadin/bundles 25.3.0-alpha9 → 25.3.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules_vaadin_map_node_modules_ol_control_MousePosition_js.js +6 -6
- package/node_modules_vaadin_map_node_modules_ol_control_MousePosition_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_control_ZoomToExtent_js.js +10 -1
- package/node_modules_vaadin_map_node_modules_ol_control_ZoomToExtent_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_events_SnapEvent_js.js +5 -0
- package/node_modules_vaadin_map_node_modules_ol_events_SnapEvent_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_featureloader_js.js +9 -8
- package/node_modules_vaadin_map_node_modules_ol_featureloader_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_geom_GeometryCollection_js.js +1 -1
- package/node_modules_vaadin_map_node_modules_ol_geom_GeometryCollection_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_clip_js.js +172 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_clip_js.js.map +1 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_length_js-_95bd5.js +58 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_length_js-_95bd5.js.map +1 -0
- package/{node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-node_modules_vaadin_map_node_-a1378d.js → node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640.js} +244 -5
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640.js.map +1 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-7a9288.js +383 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-7a9288.js.map +1 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js.js +243 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js.js.map +1 -0
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_textpath_js.js +18 -5
- package/node_modules_vaadin_map_node_modules_ol_geom_flat_textpath_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_interaction_DragAndDrop_js.js +8 -8
- package/node_modules_vaadin_map_node_modules_ol_interaction_DragAndDrop_js.js.map +1 -1
- package/{node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c0.js → node_modules_vaadin_map_node_modules_ol_render_VectorContext_js.js} +2 -2
- package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js.js.map +1 -0
- package/node_modules_vaadin_map_node_modules_ol_render_canvas_LineStringBuilder_js.js +17 -7
- package/node_modules_vaadin_map_node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc10.js +18 -15
- package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc10.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc11.js +18 -15
- package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc11.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_renderer_Layer_js.js +21 -1
- package/node_modules_vaadin_map_node_modules_ol_renderer_Layer_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_source_Source_js.js +34 -3
- package/node_modules_vaadin_map_node_modules_ol_source_Source_js.js.map +1 -1
- package/package.json +135 -135
- package/vaadin-bundle.json +2117 -2089
- package/vaadin.js +5086 -3072
- package/vaadin.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_Feature_js.js +30 -16
- package/vendors-node_modules_vaadin_map_node_modules_ol_Feature_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_Overlay_js.js +6 -6
- package/vendors-node_modules_vaadin_map_node_modules_ol_Overlay_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_FullScreen_js.js +7 -7
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_FullScreen_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_OverviewMap_js.js +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_OverviewMap_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_ScaleLine_js.js +6 -6
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_ScaleLine_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_ZoomSlider_js.js +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_ZoomSlider_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_js.js +34 -25
- package/vendors-node_modules_vaadin_map_node_modules_ol_control_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Draw_js.js +146 -943
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Draw_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Extent_js.js +111 -34
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Extent_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Link_js.js +3 -3
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Link_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Modify_js.js +1055 -219
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Modify_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js +129 -57
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js +74 -80
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Translate_js.js +11 -11
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Translate_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_js.js +54 -54
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js.js +801 -0
- package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js.js.map +1 -0
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_Feature_js.js +36 -20
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_Feature_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_BuilderGroup_js.js +17 -279
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Builder_js.js +16 -7
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Builder_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_ExecutorGroup_js.js +53 -17
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Executor_js.js +336 -38
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Executor_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Immediate_js.js +75 -42
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Immediate_js.js.map +1 -1
- package/{node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js → vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js} +77 -11
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_TextBuilder_js.js +210 -16
- package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_Layer_js.js +88 -32
- package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_Layer_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_VectorLayer_js.js +62 -22
- package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_vector_js.js +2 -2
- package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_vector_js.js.map +1 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_source_Vector_js.js +135 -81
- package/vendors-node_modules_vaadin_map_node_modules_ol_source_Vector_js.js.map +1 -1
- package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c0.js.map +0 -1
- package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c1.js +0 -144
- package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c1.js.map +0 -1
- package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-node_modules_vaadin_map_node_-a1378d.js.map +0 -1
- package/node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js.map +0 -1
- package/node_modules_vaadin_map_node_modules_ol_style_js.js +0 -48
- package/node_modules_vaadin_map_node_modules_ol_style_js.js.map +0 -1
- package/vendors-node_modules_vaadin_map_node_modules_ol_geom_js-node_modules_vaadin_map_node_modules_-f0f4bb.js +0 -769
- package/vendors-node_modules_vaadin_map_node_modules_ol_geom_js-node_modules_vaadin_map_node_modules_-f0f4bb.js.map +0 -1
|
@@ -1,4 +1,243 @@
|
|
|
1
|
-
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["
|
|
1
|
+
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640"],{
|
|
2
|
+
|
|
3
|
+
/***/ "./node_modules/@vaadin/map/node_modules/ol/geom/flat/lineoffset.js":
|
|
4
|
+
/*!**************************************************************************!*\
|
|
5
|
+
!*** ./node_modules/@vaadin/map/node_modules/ol/geom/flat/lineoffset.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 */ "offsetLineString": () => (/* binding */ offsetLineString),
|
|
12
|
+
/* harmony export */ "removeOffsetCycles": () => (/* binding */ removeOffsetCycles)
|
|
13
|
+
/* harmony export */ });
|
|
14
|
+
/* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../coordinate.js */ "./node_modules/@vaadin/map/node_modules/ol/coordinate.js");
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Offsets a line string to the left / right along its segments direction.
|
|
19
|
+
* Offset is applied to each segment of the line in the direciton of the segment normal (positive offset goes "right" relative to the line direction).
|
|
20
|
+
* For very sharp angles between segments, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.
|
|
21
|
+
*
|
|
22
|
+
* Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.
|
|
23
|
+
*
|
|
24
|
+
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
25
|
+
* @param {number} start Start index.
|
|
26
|
+
* @param {number} end End index.
|
|
27
|
+
* @param {number} stride Stride.
|
|
28
|
+
* @param {number} offset Offset distance along the segment normal direction.
|
|
29
|
+
* Positive values offset to the right relative to the direction of the line.
|
|
30
|
+
* Negative values offset to the left.
|
|
31
|
+
* @param {boolean} isClosedRing If coordinates build a closed circle (in this the first and the last coordinate offsets will consider previous / next ring coordinate)
|
|
32
|
+
* @param {Array<number>} [dest] Destination coordinate array. If not provided a new one will be created
|
|
33
|
+
* @param {number} [destinationStride] Stride of destination coordinates. If unspecified, assumed to be same as the source coordinates stride.
|
|
34
|
+
* @return {Array<number>} Result flat coordinates of the offset line.
|
|
35
|
+
*/
|
|
36
|
+
function offsetLineString(
|
|
37
|
+
flatCoordinates,
|
|
38
|
+
start,
|
|
39
|
+
end,
|
|
40
|
+
stride,
|
|
41
|
+
offset,
|
|
42
|
+
isClosedRing,
|
|
43
|
+
dest,
|
|
44
|
+
destinationStride,
|
|
45
|
+
) {
|
|
46
|
+
dest = dest ?? [];
|
|
47
|
+
destinationStride = destinationStride ?? stride;
|
|
48
|
+
|
|
49
|
+
const secondPointX = flatCoordinates[start + stride];
|
|
50
|
+
const secondPointY = flatCoordinates[start + stride + 1];
|
|
51
|
+
const secondToLastPointX = flatCoordinates[end - 2 * stride];
|
|
52
|
+
const secondToLastPointY = flatCoordinates[end - 2 * stride + 1];
|
|
53
|
+
let x, y, prevX, prevY, nextX, nextY, offsetX, offsetY;
|
|
54
|
+
|
|
55
|
+
let i = 0;
|
|
56
|
+
for (let j = start; j < end; j += stride) {
|
|
57
|
+
// 1. Detect previous and next coordinates of a current vertex
|
|
58
|
+
prevX = x;
|
|
59
|
+
prevY = y;
|
|
60
|
+
nextX = undefined;
|
|
61
|
+
nextY = undefined;
|
|
62
|
+
if (j + stride < end) {
|
|
63
|
+
nextX = flatCoordinates[j + stride];
|
|
64
|
+
nextY = flatCoordinates[j + stride + 1];
|
|
65
|
+
}
|
|
66
|
+
// First coordinate of a closed ring -> previous coordinate is the second to last one
|
|
67
|
+
if (isClosedRing && j === start) {
|
|
68
|
+
prevX = secondToLastPointX;
|
|
69
|
+
prevY = secondToLastPointY;
|
|
70
|
+
}
|
|
71
|
+
// Last coordinate of a closed ring -> next coordinate is the second vertex of a line string (the last one is same as the first one for a closed ring)
|
|
72
|
+
if (isClosedRing && j === end - stride) {
|
|
73
|
+
nextX = secondPointX;
|
|
74
|
+
nextY = secondPointY;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 2. Current vertex to offset
|
|
78
|
+
x = flatCoordinates[j];
|
|
79
|
+
y = flatCoordinates[j + 1];
|
|
80
|
+
|
|
81
|
+
// 3. Offset the vertex
|
|
82
|
+
[offsetX, offsetY] = offsetLineVertex(
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
prevX,
|
|
86
|
+
prevY,
|
|
87
|
+
nextX,
|
|
88
|
+
nextY,
|
|
89
|
+
offset,
|
|
90
|
+
);
|
|
91
|
+
dest[i++] = offsetX;
|
|
92
|
+
dest[i++] = offsetY;
|
|
93
|
+
|
|
94
|
+
// 4. Copy over other dimension values if any
|
|
95
|
+
for (let k = 2; k < destinationStride; k++) {
|
|
96
|
+
dest[i++] = flatCoordinates[j + k];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (dest.length != i) {
|
|
101
|
+
dest.length = i;
|
|
102
|
+
}
|
|
103
|
+
return dest;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Computes the offset of a single vertex of a line string.
|
|
108
|
+
*
|
|
109
|
+
* The function calculates a new vertex coordinate offset along the normal/miter direction of the line at this vertex.
|
|
110
|
+
* Offset is applied along the segment normal (positive offset goes "right" relative to the line direction).
|
|
111
|
+
* It handles first and last vertices (caps) as well as joins between two segments (mitering).
|
|
112
|
+
* For very sharp angles, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.
|
|
113
|
+
*
|
|
114
|
+
* Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.
|
|
115
|
+
*
|
|
116
|
+
* @param {number} x Vertex x-coordinate.
|
|
117
|
+
* @param {number} y Vertex y-coordinate.
|
|
118
|
+
* @param {number|undefined} prevX Previous vertex x-coordinate.
|
|
119
|
+
* Pass undefined if computing the offset for the first vertex (no previous vertex).
|
|
120
|
+
* @param {number|undefined} prevY Previous vertex y-coordinate.
|
|
121
|
+
* Pass undefined if computing the offset for the first vertex (no previous vertex).
|
|
122
|
+
* @param {number|undefined} nextX Next vertex x-coordinate.
|
|
123
|
+
* Pass undefined if computing the offset for the last vertex (no next vertex).
|
|
124
|
+
* @param {number|undefined} nextY Next vertex y-coordinate.
|
|
125
|
+
* Pass undefined if computing the offset for the last vertex (no next vertex).
|
|
126
|
+
* @param {number} offset Offset distance along the segment normal direction.
|
|
127
|
+
* Positive values offset to the right relative to the direction from previous to next vertex.
|
|
128
|
+
* Negative values offset to the left.
|
|
129
|
+
* @return {import("../../coordinate.js").Coordinate} Offset vertex coordinate as `[x, y]`.
|
|
130
|
+
*/
|
|
131
|
+
function offsetLineVertex(x, y, prevX, prevY, nextX, nextY, offset) {
|
|
132
|
+
// Compute segment direction
|
|
133
|
+
let nx, ny;
|
|
134
|
+
if (prevX !== undefined && prevY !== undefined) {
|
|
135
|
+
nx = x - prevX;
|
|
136
|
+
ny = y - prevY;
|
|
137
|
+
} else if (nextX !== undefined && nextY !== undefined) {
|
|
138
|
+
nx = nextX - x;
|
|
139
|
+
ny = nextY - y;
|
|
140
|
+
} else {
|
|
141
|
+
// no next, no previous point given -> just assume some default (horizontal) direction
|
|
142
|
+
nx = 1;
|
|
143
|
+
ny = 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Normalize -> tangent
|
|
147
|
+
const len = Math.hypot(nx, ny);
|
|
148
|
+
const tx = nx / len;
|
|
149
|
+
const ty = ny / len;
|
|
150
|
+
|
|
151
|
+
// Rotate tangent 90° -> normal
|
|
152
|
+
nx = -ty;
|
|
153
|
+
ny = tx;
|
|
154
|
+
|
|
155
|
+
// First / last vertex -> offset the point in the direction of the normal vector
|
|
156
|
+
if (prevX === undefined || prevY === undefined) {
|
|
157
|
+
return [x + nx * offset, y + ny * offset];
|
|
158
|
+
}
|
|
159
|
+
if (nextX === undefined || nextY === undefined) {
|
|
160
|
+
return [x + nx * offset, y + ny * offset];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Compute join angle - angle between 2 segments of the vertex.
|
|
164
|
+
const joinAngle = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_0__.angleBetween)([x, y], [prevX, prevY], [nextX, nextY]);
|
|
165
|
+
|
|
166
|
+
// Avoid huge or infinite miter joins for very sharp angles, offset in the segment direction in this case.
|
|
167
|
+
if (Math.cos(joinAngle) > 0.998) {
|
|
168
|
+
return [x + tx * offset, y + ty * offset];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Compute join offset direction.
|
|
172
|
+
// We rotate the normal vector by half of the join angle.
|
|
173
|
+
// This gives the direction of the miter at the vertex.
|
|
174
|
+
const cos = Math.cos(joinAngle / 2);
|
|
175
|
+
const sin = Math.sin(joinAngle / 2);
|
|
176
|
+
|
|
177
|
+
// Rotate the normal vector (nx, ny) by half of the join angle.
|
|
178
|
+
// bx/by = bisector direction before normalization
|
|
179
|
+
const bx = sin * nx + cos * ny;
|
|
180
|
+
const by = -cos * nx + sin * ny;
|
|
181
|
+
|
|
182
|
+
// Scale the bisector so that moving along it preserves the correct offset distance.
|
|
183
|
+
// Dividing by sin(half of angle) converts the bisector into the true miter vector.
|
|
184
|
+
// (This expands the miter for sharp angles and shortens it for wide ones.)
|
|
185
|
+
const dx = bx * (1 / sin);
|
|
186
|
+
const dy = by * (1 / sin);
|
|
187
|
+
|
|
188
|
+
// Offset final vertex along miter direction
|
|
189
|
+
return [x + dx * offset, y + dy * offset];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Removes self-intersection loops (cycles) from an offset line.
|
|
194
|
+
* When a polyline is offset, sharp turns can create self-intersecting loops.
|
|
195
|
+
* This function detects those crossings and splices out the looped portions,
|
|
196
|
+
* replacing them with the intersection point.
|
|
197
|
+
*
|
|
198
|
+
* @param {Array<number>} coords Flat offset coordinates (modified in-place).
|
|
199
|
+
* @param {number} stride Coordinate stride (typically 2).
|
|
200
|
+
* @param {boolean} [closedLine] Whether the original line is closed (first vertex === last vertex).
|
|
201
|
+
* When true, the first and last offset segments are not compared against each other to avoid
|
|
202
|
+
* false loop detection at the closure point.
|
|
203
|
+
* @return {Array<number>} The cleaned coordinate array.
|
|
204
|
+
*/
|
|
205
|
+
function removeOffsetCycles(coords, stride, closedLine = false) {
|
|
206
|
+
for (let i = 0, ii = coords.length - 2; i < ii; i += stride) {
|
|
207
|
+
const jMax =
|
|
208
|
+
closedLine && i === 0
|
|
209
|
+
? coords.length - 3 * stride
|
|
210
|
+
: coords.length - 2 * stride;
|
|
211
|
+
for (let j = jMax; j > i + stride; j -= stride) {
|
|
212
|
+
const p1x = coords[i];
|
|
213
|
+
const p1y = coords[i + 1];
|
|
214
|
+
const p2x = coords[i + stride];
|
|
215
|
+
const p2y = coords[i + stride + 1];
|
|
216
|
+
const p3x = coords[j];
|
|
217
|
+
const p3y = coords[j + 1];
|
|
218
|
+
const p4x = coords[j + stride];
|
|
219
|
+
const p4y = coords[j + stride + 1];
|
|
220
|
+
const d = (p4y - p3y) * (p2x - p1x) - (p4x - p3x) * (p2y - p1y);
|
|
221
|
+
if (d === 0) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const t = ((p4x - p3x) * (p1y - p3y) - (p4y - p3y) * (p1x - p3x)) / d;
|
|
225
|
+
const u = ((p2x - p1x) * (p1y - p3y) - (p2y - p1y) * (p1x - p3x)) / d;
|
|
226
|
+
if (t > 0 && t < 1 && u > 0 && u < 1) {
|
|
227
|
+
const ix = p1x + t * (p2x - p1x);
|
|
228
|
+
const iy = p1y + t * (p2y - p1y);
|
|
229
|
+
coords[i + stride] = ix;
|
|
230
|
+
coords[i + stride + 1] = iy;
|
|
231
|
+
coords.splice(i + 2 * stride, j - i - stride);
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return coords;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
/***/ }),
|
|
2
241
|
|
|
3
242
|
/***/ "./node_modules/@vaadin/map/node_modules/ol/render/VectorContext.js":
|
|
4
243
|
/*!**************************************************************************!*\
|
|
@@ -157,7 +396,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
157
396
|
/* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../extent.js */ "./node_modules/@vaadin/map/node_modules/ol/extent.js");
|
|
158
397
|
/* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../math.js */ "./node_modules/@vaadin/map/node_modules/ol/math.js");
|
|
159
398
|
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../proj.js */ "./node_modules/@vaadin/map/node_modules/ol/proj.js");
|
|
160
|
-
/* harmony import */ var
|
|
399
|
+
/* harmony import */ var _style_Icon_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../style/Icon.js */ "./node_modules/@vaadin/map/node_modules/ol/style/Icon.js");
|
|
161
400
|
/* harmony import */ var _Immediate_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Immediate.js */ "./node_modules/@vaadin/map/node_modules/ol/render/canvas/Immediate.js");
|
|
162
401
|
/**
|
|
163
402
|
* @module ol/render/canvas/hitdetect
|
|
@@ -270,7 +509,7 @@ function createHitDetectionImageData(
|
|
|
270
509
|
imgContext.fillStyle = color;
|
|
271
510
|
imgContext.fillRect(0, 0, img.width, img.height);
|
|
272
511
|
style.setImage(
|
|
273
|
-
new
|
|
512
|
+
new _style_Icon_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
|
|
274
513
|
img: img,
|
|
275
514
|
anchor: image.getAnchor(),
|
|
276
515
|
anchorXUnits: 'pixels',
|
|
@@ -331,7 +570,7 @@ function createHitDetectionImageData(
|
|
|
331
570
|
}
|
|
332
571
|
|
|
333
572
|
/**
|
|
334
|
-
* @param {import("../../pixel").Pixel} pixel Pixel coordinate on the hit
|
|
573
|
+
* @param {import("../../pixel.js").Pixel} pixel Pixel coordinate on the hit
|
|
335
574
|
* detection canvas in css pixels.
|
|
336
575
|
* @param {Array<F>} features Features. Has to
|
|
337
576
|
* match the `features` array that was passed to `createHitDetectionImageData()`.
|
|
@@ -369,4 +608,4 @@ function hitDetect(pixel, features, imageData) {
|
|
|
369
608
|
/***/ })
|
|
370
609
|
|
|
371
610
|
}])
|
|
372
|
-
//# sourceMappingURL=
|
|
611
|
+
//# sourceMappingURL=node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640.js","mappings":";;;;;;;;;;;;;;AAAiD;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,eAAe;AAC1B,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA;AACA,WAAW,SAAS;AACpB,WAAW,eAAe;AAC1B,WAAW,QAAQ;AACnB,YAAY,eAAe;AAC3B;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB,uBAAuB;AAC3C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,kBAAkB;AAC7B;AACA,WAAW,kBAAkB;AAC7B;AACA,WAAW,kBAAkB;AAC7B;AACA,WAAW,kBAAkB;AAC7B;AACA,WAAW,QAAQ;AACnB;AACA;AACA,YAAY,0CAA0C;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB,4DAAY;;AAEhC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,eAAe;AAC1B,WAAW,QAAQ;AACnB,WAAW,SAAS;AACpB;AACA;AACA,YAAY,eAAe;AAC3B;AACO;AACP,0CAA0C,QAAQ;AAClD;AACA;AACA;AACA;AACA,uBAAuB,gBAAgB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;AC9NA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,6CAA6C;AAC1D,aAAa,qCAAqC;AAClD,aAAa,UAAU;AACvB,aAAa,UAAU;AACvB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA,aAAa,uCAAuC;AACpD;AACA;;AAEA;AACA;AACA;AACA,aAAa,qCAAqC;AAClD;AACA;;AAEA;AACA,aAAa,qCAAqC;AAClD,aAAa,iCAAiC;AAC9C,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,iCAAiC;AAC9C,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,iDAAiD;AAC9D,aAAa,iCAAiC;AAC9C,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,wEAAwE;AACrF,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,6EAA6E;AAC1F,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,wEAAwE;AACrF,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,2CAA2C;AACxD,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,mEAAmE;AAChF,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,qEAAqE;AAClF,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,4EAA4E;AACzF,aAAa,qCAAqC;AAClD,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,aAAa,oCAAoC;AACjD,aAAa,sCAAsC;AACnD;AACA;;AAEA;AACA,aAAa,qCAAqC;AAClD,aAAa,sDAAsD;AACnE;AACA;;AAEA;AACA,aAAa,oCAAoC;AACjD,aAAa,sDAAsD;AACnE;AACA;AACA;;AAEA,iEAAe,aAAa,EAAC;;;;;;;;;;;;;;;;;;;;;;;;AC7H7B;AACA;AACA;;AAEyC;AACU;AACR;AACP;AAKb;AACgB;AACc;;AAE9C;;AAEP;AACA,WAAW,8BAA8B;AACzC,WAAW,+CAA+C;AAC1D;AACA;AACA,WAAW,+CAA+C;AAC1D;AACA,WAAW,wDAAwD;AACnE;AACA,WAAW,kCAAkC;AAC7C,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,4CAA4C;AACvD,YAAY,WAAW;AACvB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,sDAAY;AAC9C;AACA;AACA,kBAAkB,8DAAqB;AACvC;AACA;AACA,uBAAuB,qDAAuB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,qEAA2B,CAAC,2DAAiB;AACrD;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,mBAAmB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,QAAQ;AAChD;AACA;AACA,wBAAwB,sDAAU;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,2BAA2B,8DAAqB;AAChD;AACA;AACA;AACA,WAAW,aAAa;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc,sDAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,oDAAoD;AACzE;AACA;AACA,gDAAgD,QAAQ;AACxD;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA,oEAAoE,gDAAS;AAC7E,0CAA0C,QAAQ;AAClD;AACA;AACA;AACA,gDAAgD,QAAQ;AACxD;AACA,gDAAgD,QAAQ;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,WAAW,gCAAgC;AAC3C;AACA,WAAW,UAAU;AACrB;AACA,WAAW,WAAW;AACtB;AACA,YAAY,UAAU;AACtB,cAAc,wCAAwC;AACtD;AACO;AACP,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,+CAAK;AACZ,QAAQ,+CAAK;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":["webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/geom/flat/lineoffset.js","webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/render/VectorContext.js","webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/render/canvas/hitdetect.js"],"sourcesContent":["import {angleBetween} from '../../coordinate.js';\n\n/**\n * Offsets a line string to the left / right along its segments direction.\n * Offset is applied to each segment of the line in the direciton of the segment normal (positive offset goes \"right\" relative to the line direction).\n * For very sharp angles between segments, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.\n *\n * Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.\n *\n * @param {Array<number>} flatCoordinates Flat coordinates.\n * @param {number} start Start index.\n * @param {number} end End index.\n * @param {number} stride Stride.\n * @param {number} offset Offset distance along the segment normal direction.\n * Positive values offset to the right relative to the direction of the line.\n * Negative values offset to the left.\n * @param {boolean} isClosedRing If coordinates build a closed circle (in this the first and the last coordinate offsets will consider previous / next ring coordinate)\n * @param {Array<number>} [dest] Destination coordinate array. If not provided a new one will be created\n * @param {number} [destinationStride] Stride of destination coordinates. If unspecified, assumed to be same as the source coordinates stride.\n * @return {Array<number>} Result flat coordinates of the offset line.\n */\nexport function offsetLineString(\n flatCoordinates,\n start,\n end,\n stride,\n offset,\n isClosedRing,\n dest,\n destinationStride,\n) {\n dest = dest ?? [];\n destinationStride = destinationStride ?? stride;\n\n const secondPointX = flatCoordinates[start + stride];\n const secondPointY = flatCoordinates[start + stride + 1];\n const secondToLastPointX = flatCoordinates[end - 2 * stride];\n const secondToLastPointY = flatCoordinates[end - 2 * stride + 1];\n let x, y, prevX, prevY, nextX, nextY, offsetX, offsetY;\n\n let i = 0;\n for (let j = start; j < end; j += stride) {\n // 1. Detect previous and next coordinates of a current vertex\n prevX = x;\n prevY = y;\n nextX = undefined;\n nextY = undefined;\n if (j + stride < end) {\n nextX = flatCoordinates[j + stride];\n nextY = flatCoordinates[j + stride + 1];\n }\n // First coordinate of a closed ring -> previous coordinate is the second to last one\n if (isClosedRing && j === start) {\n prevX = secondToLastPointX;\n prevY = secondToLastPointY;\n }\n // Last coordinate of a closed ring -> next coordinate is the second vertex of a line string (the last one is same as the first one for a closed ring)\n if (isClosedRing && j === end - stride) {\n nextX = secondPointX;\n nextY = secondPointY;\n }\n\n // 2. Current vertex to offset\n x = flatCoordinates[j];\n y = flatCoordinates[j + 1];\n\n // 3. Offset the vertex\n [offsetX, offsetY] = offsetLineVertex(\n x,\n y,\n prevX,\n prevY,\n nextX,\n nextY,\n offset,\n );\n dest[i++] = offsetX;\n dest[i++] = offsetY;\n\n // 4. Copy over other dimension values if any\n for (let k = 2; k < destinationStride; k++) {\n dest[i++] = flatCoordinates[j + k];\n }\n }\n\n if (dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * Computes the offset of a single vertex of a line string.\n *\n * The function calculates a new vertex coordinate offset along the normal/miter direction of the line at this vertex.\n * Offset is applied along the segment normal (positive offset goes \"right\" relative to the line direction).\n * It handles first and last vertices (caps) as well as joins between two segments (mitering).\n * For very sharp angles, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.\n *\n * Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.\n *\n * @param {number} x Vertex x-coordinate.\n * @param {number} y Vertex y-coordinate.\n * @param {number|undefined} prevX Previous vertex x-coordinate.\n * Pass undefined if computing the offset for the first vertex (no previous vertex).\n * @param {number|undefined} prevY Previous vertex y-coordinate.\n * Pass undefined if computing the offset for the first vertex (no previous vertex).\n * @param {number|undefined} nextX Next vertex x-coordinate.\n * Pass undefined if computing the offset for the last vertex (no next vertex).\n * @param {number|undefined} nextY Next vertex y-coordinate.\n * Pass undefined if computing the offset for the last vertex (no next vertex).\n * @param {number} offset Offset distance along the segment normal direction.\n * Positive values offset to the right relative to the direction from previous to next vertex.\n * Negative values offset to the left.\n * @return {import(\"../../coordinate.js\").Coordinate} Offset vertex coordinate as `[x, y]`.\n */\nfunction offsetLineVertex(x, y, prevX, prevY, nextX, nextY, offset) {\n // Compute segment direction\n let nx, ny;\n if (prevX !== undefined && prevY !== undefined) {\n nx = x - prevX;\n ny = y - prevY;\n } else if (nextX !== undefined && nextY !== undefined) {\n nx = nextX - x;\n ny = nextY - y;\n } else {\n // no next, no previous point given -> just assume some default (horizontal) direction\n nx = 1;\n ny = 0;\n }\n\n // Normalize -> tangent\n const len = Math.hypot(nx, ny);\n const tx = nx / len;\n const ty = ny / len;\n\n // Rotate tangent 90° -> normal\n nx = -ty;\n ny = tx;\n\n // First / last vertex -> offset the point in the direction of the normal vector\n if (prevX === undefined || prevY === undefined) {\n return [x + nx * offset, y + ny * offset];\n }\n if (nextX === undefined || nextY === undefined) {\n return [x + nx * offset, y + ny * offset];\n }\n\n // Compute join angle - angle between 2 segments of the vertex.\n const joinAngle = angleBetween([x, y], [prevX, prevY], [nextX, nextY]);\n\n // Avoid huge or infinite miter joins for very sharp angles, offset in the segment direction in this case.\n if (Math.cos(joinAngle) > 0.998) {\n return [x + tx * offset, y + ty * offset];\n }\n\n // Compute join offset direction.\n // We rotate the normal vector by half of the join angle.\n // This gives the direction of the miter at the vertex.\n const cos = Math.cos(joinAngle / 2);\n const sin = Math.sin(joinAngle / 2);\n\n // Rotate the normal vector (nx, ny) by half of the join angle.\n // bx/by = bisector direction before normalization\n const bx = sin * nx + cos * ny;\n const by = -cos * nx + sin * ny;\n\n // Scale the bisector so that moving along it preserves the correct offset distance.\n // Dividing by sin(half of angle) converts the bisector into the true miter vector.\n // (This expands the miter for sharp angles and shortens it for wide ones.)\n const dx = bx * (1 / sin);\n const dy = by * (1 / sin);\n\n // Offset final vertex along miter direction\n return [x + dx * offset, y + dy * offset];\n}\n\n/**\n * Removes self-intersection loops (cycles) from an offset line.\n * When a polyline is offset, sharp turns can create self-intersecting loops.\n * This function detects those crossings and splices out the looped portions,\n * replacing them with the intersection point.\n *\n * @param {Array<number>} coords Flat offset coordinates (modified in-place).\n * @param {number} stride Coordinate stride (typically 2).\n * @param {boolean} [closedLine] Whether the original line is closed (first vertex === last vertex).\n * When true, the first and last offset segments are not compared against each other to avoid\n * false loop detection at the closure point.\n * @return {Array<number>} The cleaned coordinate array.\n */\nexport function removeOffsetCycles(coords, stride, closedLine = false) {\n for (let i = 0, ii = coords.length - 2; i < ii; i += stride) {\n const jMax =\n closedLine && i === 0\n ? coords.length - 3 * stride\n : coords.length - 2 * stride;\n for (let j = jMax; j > i + stride; j -= stride) {\n const p1x = coords[i];\n const p1y = coords[i + 1];\n const p2x = coords[i + stride];\n const p2y = coords[i + stride + 1];\n const p3x = coords[j];\n const p3y = coords[j + 1];\n const p4x = coords[j + stride];\n const p4y = coords[j + stride + 1];\n const d = (p4y - p3y) * (p2x - p1x) - (p4x - p3x) * (p2y - p1y);\n if (d === 0) {\n continue;\n }\n const t = ((p4x - p3x) * (p1y - p3y) - (p4y - p3y) * (p1x - p3x)) / d;\n const u = ((p2x - p1x) * (p1y - p3y) - (p2y - p1y) * (p1x - p3x)) / d;\n if (t > 0 && t < 1 && u > 0 && u < 1) {\n const ix = p1x + t * (p2x - p1x);\n const iy = p1y + t * (p2y - p1y);\n coords[i + stride] = ix;\n coords[i + stride + 1] = iy;\n coords.splice(i + 2 * stride, j - i - stride);\n break;\n }\n }\n }\n return coords;\n}\n","/**\n * @module ol/render/VectorContext\n */\n\n/**\n * @classdesc\n * Context for drawing geometries. A vector context is available on render\n * events and does not need to be constructed directly.\n * @api\n */\nclass VectorContext {\n /**\n * Render a geometry with a custom renderer.\n *\n * @param {import(\"../geom/SimpleGeometry.js\").default} geometry Geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {Function} renderer Renderer.\n * @param {Function} hitDetectionRenderer Renderer.\n * @param {number} [index] Render order index.\n */\n drawCustom(geometry, feature, renderer, hitDetectionRenderer, index) {}\n\n /**\n * Render a geometry.\n *\n * @param {import(\"../geom/Geometry.js\").default} geometry The geometry to render.\n */\n drawGeometry(geometry) {}\n\n /**\n * Set the rendering style.\n *\n * @param {import(\"../style/Style.js\").default} style The rendering style.\n */\n setStyle(style) {}\n\n /**\n * @param {import(\"../geom/Circle.js\").default} circleGeometry Circle geometry.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawCircle(circleGeometry, feature, index) {}\n\n /**\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"../style/Style.js\").default} style Style.\n * @param {number} [index] Render order index.\n */\n drawFeature(feature, style, index) {}\n\n /**\n * @param {import(\"../geom/GeometryCollection.js\").default} geometryCollectionGeometry Geometry collection.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawGeometryCollection(geometryCollectionGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/LineString.js\").default|import(\"./Feature.js\").default} lineStringGeometry Line string geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawLineString(lineStringGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/MultiLineString.js\").default|import(\"./Feature.js\").default} multiLineStringGeometry MultiLineString geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawMultiLineString(multiLineStringGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/MultiPoint.js\").default|import(\"./Feature.js\").default} multiPointGeometry MultiPoint geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawMultiPoint(multiPointGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/MultiPolygon.js\").default} multiPolygonGeometry MultiPolygon geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawMultiPolygon(multiPolygonGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/Point.js\").default|import(\"./Feature.js\").default} pointGeometry Point geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawPoint(pointGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/Polygon.js\").default|import(\"./Feature.js\").default} polygonGeometry Polygon geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawPolygon(polygonGeometry, feature, index) {}\n\n /**\n * @param {import(\"../geom/SimpleGeometry.js\").default|import(\"./Feature.js\").default} geometry Geometry.\n * @param {import(\"../Feature.js\").FeatureLike} feature Feature.\n * @param {number} [index] Render order index.\n */\n drawText(geometry, feature, index) {}\n\n /**\n * @param {import(\"../style/Fill.js\").default} fillStyle Fill style.\n * @param {import(\"../style/Stroke.js\").default} strokeStyle Stroke style.\n */\n setFillStrokeStyle(fillStyle, strokeStyle) {}\n\n /**\n * @param {import(\"../style/Image.js\").default} imageStyle Image style.\n * @param {import(\"../render/canvas.js\").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with a text style.\n */\n setImageStyle(imageStyle, declutterImageWithText) {}\n\n /**\n * @param {import(\"../style/Text.js\").default} textStyle Text style.\n * @param {import(\"../render/canvas.js\").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with an image style.\n */\n setTextStyle(textStyle, declutterImageWithText) {}\n}\n\nexport default VectorContext;\n","/**\n * @module ol/render/canvas/hitdetect\n */\n\nimport {ascending} from '../../array.js';\nimport {createCanvasContext2D} from '../../dom.js';\nimport {intersects} from '../../extent.js';\nimport {clamp} from '../../math.js';\nimport {\n getTransformFromProjections,\n getUserProjection,\n toUserExtent,\n} from '../../proj.js';\nimport Icon from '../../style/Icon.js';\nimport CanvasImmediateRenderer from './Immediate.js';\n\nexport const HIT_DETECT_RESOLUTION = 0.5;\n\n/**\n * @param {import(\"../../size.js\").Size} size Canvas size in css pixels.\n * @param {Array<import(\"../../transform.js\").Transform>} transforms Transforms\n * for rendering features to all worlds of the viewport, from coordinates to css\n * pixels.\n * @param {Array<import(\"../../Feature.js\").FeatureLike>} features\n * Features to consider for hit detection.\n * @param {import(\"../../style/Style.js\").StyleFunction|undefined} styleFunction\n * Layer style function.\n * @param {import(\"../../extent.js\").Extent} extent Extent in render projection.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {number} [squaredTolerance] Squared tolerance.\n * @param {import(\"../../proj/Projection.js\").default} [projection] Render projection.\n * @return {ImageData} Hit detection image data.\n */\nexport function createHitDetectionImageData(\n size,\n transforms,\n features,\n styleFunction,\n extent,\n resolution,\n rotation,\n squaredTolerance,\n projection,\n) {\n const userExtent = projection ? toUserExtent(extent, projection) : extent;\n const width = size[0] * HIT_DETECT_RESOLUTION;\n const height = size[1] * HIT_DETECT_RESOLUTION;\n const context = createCanvasContext2D(width, height);\n context.imageSmoothingEnabled = false;\n const canvas = context.canvas;\n const renderer = new CanvasImmediateRenderer(\n context,\n HIT_DETECT_RESOLUTION,\n extent,\n null,\n rotation,\n squaredTolerance,\n projection\n ? getTransformFromProjections(getUserProjection(), projection)\n : null,\n );\n const featureCount = features.length;\n // Stretch hit detection index to use the whole available color range\n const indexFactor = Math.floor((256 * 256 * 256 - 1) / featureCount);\n const featuresByZIndex = {};\n for (let i = 1; i <= featureCount; ++i) {\n const feature = features[i - 1];\n const featureStyleFunction = feature.getStyleFunction() || styleFunction;\n if (!featureStyleFunction) {\n continue;\n }\n let styles = featureStyleFunction(feature, resolution);\n if (!styles) {\n continue;\n }\n if (!Array.isArray(styles)) {\n styles = [styles];\n }\n const index = i * indexFactor;\n const color = index.toString(16).padStart(7, '#00000');\n for (let j = 0, jj = styles.length; j < jj; ++j) {\n const originalStyle = styles[j];\n const geometry = originalStyle.getGeometryFunction()(feature);\n if (!geometry || !intersects(userExtent, geometry.getExtent())) {\n continue;\n }\n const style = originalStyle.clone();\n const fill = style.getFill();\n if (fill) {\n fill.setColor(color);\n }\n const stroke = style.getStroke();\n if (stroke) {\n stroke.setColor(color);\n stroke.setLineDash(null);\n }\n style.setText(undefined);\n const image = originalStyle.getImage();\n if (image) {\n const imgSize = image.getImageSize();\n if (!imgSize) {\n continue;\n }\n\n const imgContext = createCanvasContext2D(\n imgSize[0],\n imgSize[1],\n undefined,\n {alpha: false},\n );\n const img = imgContext.canvas;\n imgContext.fillStyle = color;\n imgContext.fillRect(0, 0, img.width, img.height);\n style.setImage(\n new Icon({\n img: img,\n anchor: image.getAnchor(),\n anchorXUnits: 'pixels',\n anchorYUnits: 'pixels',\n offset: image.getOrigin(),\n opacity: 1,\n size: image.getSize(),\n scale: image.getScale(),\n rotation: image.getRotation(),\n rotateWithView: image.getRotateWithView(),\n }),\n );\n }\n const zIndex = style.getZIndex() || 0;\n let byGeometryType = featuresByZIndex[zIndex];\n if (!byGeometryType) {\n byGeometryType = {};\n featuresByZIndex[zIndex] = byGeometryType;\n byGeometryType['Polygon'] = [];\n byGeometryType['Circle'] = [];\n byGeometryType['LineString'] = [];\n byGeometryType['Point'] = [];\n }\n const type = geometry.getType();\n if (type === 'GeometryCollection') {\n const geometries =\n /** @type {import(\"../../geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometriesArrayRecursive();\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n const geometry = geometries[i];\n byGeometryType[geometry.getType().replace('Multi', '')].push(\n geometry,\n style,\n );\n }\n } else {\n byGeometryType[type.replace('Multi', '')].push(geometry, style);\n }\n }\n }\n\n const zIndexKeys = Object.keys(featuresByZIndex).map(Number).sort(ascending);\n for (let i = 0, ii = zIndexKeys.length; i < ii; ++i) {\n const byGeometryType = featuresByZIndex[zIndexKeys[i]];\n for (const type in byGeometryType) {\n const geomAndStyle = byGeometryType[type];\n for (let j = 0, jj = geomAndStyle.length; j < jj; j += 2) {\n renderer.setStyle(geomAndStyle[j + 1]);\n for (let k = 0, kk = transforms.length; k < kk; ++k) {\n renderer.setTransform(transforms[k]);\n renderer.drawGeometry(geomAndStyle[j]);\n }\n }\n }\n }\n return context.getImageData(0, 0, canvas.width, canvas.height);\n}\n\n/**\n * @param {import(\"../../pixel.js\").Pixel} pixel Pixel coordinate on the hit\n * detection canvas in css pixels.\n * @param {Array<F>} features Features. Has to\n * match the `features` array that was passed to `createHitDetectionImageData()`.\n * @param {ImageData} imageData Hit detection image data generated by\n * `createHitDetectionImageData()`.\n * @return {Array<F>} Features.\n * @template {import(\"../../Feature.js\").FeatureLike} F\n */\nexport function hitDetect(pixel, features, imageData) {\n /** @type {Array<F>} */\n const resultFeatures = [];\n if (imageData) {\n const x = Math.floor(Math.round(pixel[0]) * HIT_DETECT_RESOLUTION);\n const y = Math.floor(Math.round(pixel[1]) * HIT_DETECT_RESOLUTION);\n // The pixel coordinate is clamped down to the hit-detect canvas' size to account\n // for browsers returning coordinates slightly larger than the actual canvas size\n // due to a non-integer pixel ratio.\n const index =\n (clamp(x, 0, imageData.width - 1) +\n clamp(y, 0, imageData.height - 1) * imageData.width) *\n 4;\n const r = imageData.data[index];\n const g = imageData.data[index + 1];\n const b = imageData.data[index + 2];\n const i = b + 256 * (g + 256 * r);\n const indexFactor = Math.floor((256 * 256 * 256 - 1) / features.length);\n if (i && i % indexFactor === 0) {\n resultFeatures.push(features[i / indexFactor - 1]);\n }\n }\n return resultFeatures;\n}\n"],"names":[],"sourceRoot":""}
|