@vaadin/bundles 25.3.0-alpha13 → 25.3.0-alpha14
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 +1824 -1812
- package/vaadin.js +2725 -1726
- 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
|
@@ -0,0 +1,801 @@
|
|
|
1
|
+
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js"],{
|
|
2
|
+
|
|
3
|
+
/***/ "./node_modules/@vaadin/map/node_modules/ol/geom/GeometryCollection.js":
|
|
4
|
+
/*!*****************************************************************************!*\
|
|
5
|
+
!*** ./node_modules/@vaadin/map/node_modules/ol/geom/GeometryCollection.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 */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
12
|
+
/* harmony export */ });
|
|
13
|
+
/* harmony import */ var _events_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../events.js */ "./node_modules/@vaadin/map/node_modules/ol/events.js");
|
|
14
|
+
/* harmony import */ var _events_EventType_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../events/EventType.js */ "./node_modules/@vaadin/map/node_modules/ol/events/EventType.js");
|
|
15
|
+
/* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../extent.js */ "./node_modules/@vaadin/map/node_modules/ol/extent.js");
|
|
16
|
+
/* harmony import */ var _Geometry_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Geometry.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/Geometry.js");
|
|
17
|
+
/**
|
|
18
|
+
* @module ol/geom/GeometryCollection
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @classdesc
|
|
27
|
+
* An array of {@link module:ol/geom/Geometry~Geometry} objects.
|
|
28
|
+
*
|
|
29
|
+
* @api
|
|
30
|
+
*/
|
|
31
|
+
class GeometryCollection extends _Geometry_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
32
|
+
/**
|
|
33
|
+
* @param {Array<Geometry>} geometries Geometries.
|
|
34
|
+
*/
|
|
35
|
+
constructor(geometries) {
|
|
36
|
+
super();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
* @type {Array<Geometry>}
|
|
41
|
+
*/
|
|
42
|
+
this.geometries_ = geometries;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
* @type {Array<import("../events.js").EventsKey>}
|
|
47
|
+
*/
|
|
48
|
+
this.changeEventsKeys_ = [];
|
|
49
|
+
|
|
50
|
+
this.listenGeometriesChange_();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
unlistenGeometriesChange_() {
|
|
57
|
+
this.changeEventsKeys_.forEach(_events_js__WEBPACK_IMPORTED_MODULE_1__.unlistenByKey);
|
|
58
|
+
this.changeEventsKeys_.length = 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
listenGeometriesChange_() {
|
|
65
|
+
const geometries = this.geometries_;
|
|
66
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
67
|
+
this.changeEventsKeys_.push(
|
|
68
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_1__.listen)(geometries[i], _events_EventType_js__WEBPACK_IMPORTED_MODULE_2__["default"].CHANGE, this.changed, this),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Make a complete copy of the geometry.
|
|
75
|
+
* @return {!GeometryCollection} Clone.
|
|
76
|
+
* @api
|
|
77
|
+
* @override
|
|
78
|
+
*/
|
|
79
|
+
clone() {
|
|
80
|
+
const geometryCollection = new GeometryCollection(
|
|
81
|
+
cloneGeometries(this.geometries_),
|
|
82
|
+
);
|
|
83
|
+
geometryCollection.applyProperties(this);
|
|
84
|
+
return geometryCollection;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {number} x X.
|
|
89
|
+
* @param {number} y Y.
|
|
90
|
+
* @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
|
|
91
|
+
* @param {number} minSquaredDistance Minimum squared distance.
|
|
92
|
+
* @return {number} Minimum squared distance.
|
|
93
|
+
* @override
|
|
94
|
+
*/
|
|
95
|
+
closestPointXY(x, y, closestPoint, minSquaredDistance) {
|
|
96
|
+
if (minSquaredDistance < (0,_extent_js__WEBPACK_IMPORTED_MODULE_3__.closestSquaredDistanceXY)(this.getExtent(), x, y)) {
|
|
97
|
+
return minSquaredDistance;
|
|
98
|
+
}
|
|
99
|
+
const geometries = this.geometries_;
|
|
100
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
101
|
+
minSquaredDistance = geometries[i].closestPointXY(
|
|
102
|
+
x,
|
|
103
|
+
y,
|
|
104
|
+
closestPoint,
|
|
105
|
+
minSquaredDistance,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return minSquaredDistance;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {number} x X.
|
|
113
|
+
* @param {number} y Y.
|
|
114
|
+
* @return {boolean} Contains (x, y).
|
|
115
|
+
* @override
|
|
116
|
+
*/
|
|
117
|
+
containsXY(x, y) {
|
|
118
|
+
const geometries = this.geometries_;
|
|
119
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
120
|
+
if (geometries[i].containsXY(x, y)) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
129
|
+
* @protected
|
|
130
|
+
* @return {import("../extent.js").Extent} extent Extent.
|
|
131
|
+
* @override
|
|
132
|
+
*/
|
|
133
|
+
computeExtent(extent) {
|
|
134
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_3__.createOrUpdateEmpty)(extent);
|
|
135
|
+
const geometries = this.geometries_;
|
|
136
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
137
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_3__.extend)(extent, geometries[i].getExtent());
|
|
138
|
+
}
|
|
139
|
+
return extent;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Return the geometries that make up this geometry collection.
|
|
144
|
+
* @return {Array<Geometry>} Geometries.
|
|
145
|
+
* @api
|
|
146
|
+
*/
|
|
147
|
+
getGeometries() {
|
|
148
|
+
return cloneGeometries(this.geometries_);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @return {Array<Geometry>} Geometries.
|
|
153
|
+
*/
|
|
154
|
+
getGeometriesArray() {
|
|
155
|
+
return this.geometries_;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @return {Array<Geometry>} Geometries.
|
|
160
|
+
*/
|
|
161
|
+
getGeometriesArrayRecursive() {
|
|
162
|
+
/** @type {Array<Geometry>} */
|
|
163
|
+
let geometriesArray = [];
|
|
164
|
+
const geometries = this.geometries_;
|
|
165
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
166
|
+
if (geometries[i].getType() === this.getType()) {
|
|
167
|
+
geometriesArray = geometriesArray.concat(
|
|
168
|
+
/** @type {GeometryCollection} */ (
|
|
169
|
+
geometries[i]
|
|
170
|
+
).getGeometriesArrayRecursive(),
|
|
171
|
+
);
|
|
172
|
+
} else {
|
|
173
|
+
geometriesArray.push(geometries[i]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return geometriesArray;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Create a simplified version of this geometry using the Douglas Peucker algorithm.
|
|
181
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
182
|
+
* @return {GeometryCollection} Simplified GeometryCollection.
|
|
183
|
+
* @override
|
|
184
|
+
*/
|
|
185
|
+
getSimplifiedGeometry(squaredTolerance) {
|
|
186
|
+
if (this.simplifiedGeometryRevision !== this.getRevision()) {
|
|
187
|
+
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
|
|
188
|
+
this.simplifiedGeometryRevision = this.getRevision();
|
|
189
|
+
}
|
|
190
|
+
if (
|
|
191
|
+
squaredTolerance < 0 ||
|
|
192
|
+
(this.simplifiedGeometryMaxMinSquaredTolerance !== 0 &&
|
|
193
|
+
squaredTolerance < this.simplifiedGeometryMaxMinSquaredTolerance)
|
|
194
|
+
) {
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const simplifiedGeometries = [];
|
|
199
|
+
const geometries = this.geometries_;
|
|
200
|
+
let simplified = false;
|
|
201
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
202
|
+
const geometry = geometries[i];
|
|
203
|
+
const simplifiedGeometry =
|
|
204
|
+
geometry.getSimplifiedGeometry(squaredTolerance);
|
|
205
|
+
simplifiedGeometries.push(simplifiedGeometry);
|
|
206
|
+
if (simplifiedGeometry !== geometry) {
|
|
207
|
+
simplified = true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (simplified) {
|
|
211
|
+
const simplifiedGeometryCollection = new GeometryCollection(
|
|
212
|
+
simplifiedGeometries,
|
|
213
|
+
);
|
|
214
|
+
return simplifiedGeometryCollection;
|
|
215
|
+
}
|
|
216
|
+
this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get the type of this geometry.
|
|
222
|
+
* @return {import("./Geometry.js").Type} Geometry type.
|
|
223
|
+
* @api
|
|
224
|
+
* @override
|
|
225
|
+
*/
|
|
226
|
+
getType() {
|
|
227
|
+
return 'GeometryCollection';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Test if the geometry and the passed extent intersect.
|
|
232
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
233
|
+
* @return {boolean} `true` if the geometry and the extent intersect.
|
|
234
|
+
* @api
|
|
235
|
+
* @override
|
|
236
|
+
*/
|
|
237
|
+
intersectsExtent(extent) {
|
|
238
|
+
const geometries = this.geometries_;
|
|
239
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
240
|
+
if (geometries[i].intersectsExtent(extent)) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @return {boolean} Is empty.
|
|
249
|
+
*/
|
|
250
|
+
isEmpty() {
|
|
251
|
+
return this.geometries_.length === 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Rotate the geometry around a given coordinate. This modifies the geometry
|
|
256
|
+
* coordinates in place.
|
|
257
|
+
* @param {number} angle Rotation angle in radians.
|
|
258
|
+
* @param {import("../coordinate.js").Coordinate} anchor The rotation center.
|
|
259
|
+
* @api
|
|
260
|
+
* @override
|
|
261
|
+
*/
|
|
262
|
+
rotate(angle, anchor) {
|
|
263
|
+
const geometries = this.geometries_;
|
|
264
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
265
|
+
geometries[i].rotate(angle, anchor);
|
|
266
|
+
}
|
|
267
|
+
this.changed();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Scale the geometry (with an optional origin). This modifies the geometry
|
|
272
|
+
* coordinates in place.
|
|
273
|
+
* @abstract
|
|
274
|
+
* @param {number} sx The scaling factor in the x-direction.
|
|
275
|
+
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
|
|
276
|
+
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
|
|
277
|
+
* of the geometry extent).
|
|
278
|
+
* @api
|
|
279
|
+
* @override
|
|
280
|
+
*/
|
|
281
|
+
scale(sx, sy, anchor) {
|
|
282
|
+
if (!anchor) {
|
|
283
|
+
anchor = (0,_extent_js__WEBPACK_IMPORTED_MODULE_3__.getCenter)(this.getExtent());
|
|
284
|
+
}
|
|
285
|
+
const geometries = this.geometries_;
|
|
286
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
287
|
+
geometries[i].scale(sx, sy, anchor);
|
|
288
|
+
}
|
|
289
|
+
this.changed();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Set the geometries that make up this geometry collection.
|
|
294
|
+
* @param {Array<Geometry>} geometries Geometries.
|
|
295
|
+
* @api
|
|
296
|
+
*/
|
|
297
|
+
setGeometries(geometries) {
|
|
298
|
+
this.setGeometriesArray(cloneGeometries(geometries));
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* @param {Array<Geometry>} geometries Geometries.
|
|
303
|
+
*/
|
|
304
|
+
setGeometriesArray(geometries) {
|
|
305
|
+
this.unlistenGeometriesChange_();
|
|
306
|
+
this.geometries_ = geometries;
|
|
307
|
+
this.listenGeometriesChange_();
|
|
308
|
+
this.changed();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Apply a transform function to the coordinates of the geometry.
|
|
313
|
+
* The geometry is modified in place.
|
|
314
|
+
* If you do not want the geometry modified in place, first `clone()` it and
|
|
315
|
+
* then use this function on the clone.
|
|
316
|
+
* @param {import("../proj.js").TransformFunction} transformFn Transform function.
|
|
317
|
+
* Called with a flat array of geometry coordinates.
|
|
318
|
+
* @api
|
|
319
|
+
* @override
|
|
320
|
+
*/
|
|
321
|
+
applyTransform(transformFn) {
|
|
322
|
+
const geometries = this.geometries_;
|
|
323
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
324
|
+
geometries[i].applyTransform(transformFn);
|
|
325
|
+
}
|
|
326
|
+
this.changed();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Translate the geometry. This modifies the geometry coordinates in place. If
|
|
331
|
+
* instead you want a new geometry, first `clone()` this geometry.
|
|
332
|
+
* @param {number} deltaX Delta X.
|
|
333
|
+
* @param {number} deltaY Delta Y.
|
|
334
|
+
* @api
|
|
335
|
+
* @override
|
|
336
|
+
*/
|
|
337
|
+
translate(deltaX, deltaY) {
|
|
338
|
+
const geometries = this.geometries_;
|
|
339
|
+
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
|
340
|
+
geometries[i].translate(deltaX, deltaY);
|
|
341
|
+
}
|
|
342
|
+
this.changed();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Clean up.
|
|
347
|
+
* @override
|
|
348
|
+
*/
|
|
349
|
+
disposeInternal() {
|
|
350
|
+
this.unlistenGeometriesChange_();
|
|
351
|
+
super.disposeInternal();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* @param {Array<Geometry>} geometries Geometries.
|
|
357
|
+
* @return {Array<Geometry>} Cloned geometries.
|
|
358
|
+
*/
|
|
359
|
+
function cloneGeometries(geometries) {
|
|
360
|
+
return geometries.map((geometry) => geometry.clone());
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (GeometryCollection);
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
/***/ }),
|
|
367
|
+
|
|
368
|
+
/***/ "./node_modules/@vaadin/map/node_modules/ol/interaction/tracing.js":
|
|
369
|
+
/*!*************************************************************************!*\
|
|
370
|
+
!*** ./node_modules/@vaadin/map/node_modules/ol/interaction/tracing.js ***!
|
|
371
|
+
\*************************************************************************/
|
|
372
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
373
|
+
|
|
374
|
+
__webpack_require__.r(__webpack_exports__);
|
|
375
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
376
|
+
/* harmony export */ "getCoordinate": () => (/* binding */ getCoordinate),
|
|
377
|
+
/* harmony export */ "getPointSegmentRelationship": () => (/* binding */ getPointSegmentRelationship),
|
|
378
|
+
/* harmony export */ "getTraceTargetUpdate": () => (/* binding */ getTraceTargetUpdate),
|
|
379
|
+
/* harmony export */ "getTraceTargets": () => (/* binding */ getTraceTargets),
|
|
380
|
+
/* harmony export */ "interpolateCoordinate": () => (/* binding */ interpolateCoordinate)
|
|
381
|
+
/* harmony export */ });
|
|
382
|
+
/* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/@vaadin/map/node_modules/ol/coordinate.js");
|
|
383
|
+
/* harmony import */ var _geom_GeometryCollection_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../geom/GeometryCollection.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/GeometryCollection.js");
|
|
384
|
+
/* harmony import */ var _geom_LineString_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geom/LineString.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/LineString.js");
|
|
385
|
+
/* harmony import */ var _geom_MultiLineString_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../geom/MultiLineString.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/MultiLineString.js");
|
|
386
|
+
/* harmony import */ var _geom_MultiPolygon_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../geom/MultiPolygon.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/MultiPolygon.js");
|
|
387
|
+
/* harmony import */ var _geom_Polygon_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../geom/Polygon.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/Polygon.js");
|
|
388
|
+
/* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../math.js */ "./node_modules/@vaadin/map/node_modules/ol/math.js");
|
|
389
|
+
/**
|
|
390
|
+
* Coordinate type when drawing lines.
|
|
391
|
+
* @typedef {Array<import("../coordinate.js").Coordinate>} LineCoordType
|
|
392
|
+
*/
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* @param {LineCoordType} coordinates The ring coordinates.
|
|
404
|
+
* @param {number} index The index. May be wrapped.
|
|
405
|
+
* @return {import("../coordinate.js").Coordinate} The coordinate.
|
|
406
|
+
*/
|
|
407
|
+
function getCoordinate(coordinates, index) {
|
|
408
|
+
const count = coordinates.length;
|
|
409
|
+
if (index < 0) {
|
|
410
|
+
return coordinates[index + count];
|
|
411
|
+
}
|
|
412
|
+
if (index >= count) {
|
|
413
|
+
return coordinates[index - count];
|
|
414
|
+
}
|
|
415
|
+
return coordinates[index];
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* @param {LineCoordType} coordinates The coordinates.
|
|
420
|
+
* @param {number} index The index. May be fractional and may wrap.
|
|
421
|
+
* @return {import("../coordinate.js").Coordinate} The interpolated coordinate.
|
|
422
|
+
*/
|
|
423
|
+
function interpolateCoordinate(coordinates, index) {
|
|
424
|
+
const count = coordinates.length;
|
|
425
|
+
|
|
426
|
+
let startIndex = Math.floor(index);
|
|
427
|
+
const along = index - startIndex;
|
|
428
|
+
if (startIndex >= count) {
|
|
429
|
+
startIndex -= count;
|
|
430
|
+
} else if (startIndex < 0) {
|
|
431
|
+
startIndex += count;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
let endIndex = startIndex + 1;
|
|
435
|
+
if (endIndex >= count) {
|
|
436
|
+
endIndex -= count;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const start = coordinates[startIndex];
|
|
440
|
+
const x0 = start[0];
|
|
441
|
+
const y0 = start[1];
|
|
442
|
+
const end = coordinates[endIndex];
|
|
443
|
+
const dx = end[0] - x0;
|
|
444
|
+
const dy = end[1] - y0;
|
|
445
|
+
|
|
446
|
+
return [x0 + dx * along, y0 + dy * along];
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @typedef {Object} TraceTarget
|
|
451
|
+
* @property {Array<import("../coordinate.js").Coordinate>} coordinates Target coordinates.
|
|
452
|
+
* @property {boolean} ring The target coordinates are a linear ring.
|
|
453
|
+
* @property {number} startIndex The index of first traced coordinate. A fractional index represents an
|
|
454
|
+
* edge intersection. Index values for rings will wrap (may be negative or larger than coordinates length).
|
|
455
|
+
* @property {number} endIndex The index of last traced coordinate. Details from startIndex also apply here.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* @typedef {Object} TraceState
|
|
460
|
+
* @property {boolean} active Tracing active.
|
|
461
|
+
* @property {import("../coordinate.js").Coordinate} [startCoord] The initially clicked coordinate.
|
|
462
|
+
* @property {Array<TraceTarget>} [targets] Targets available for tracing.
|
|
463
|
+
* @property {number} [targetIndex] The index of the currently traced target. A value of -1 indicates
|
|
464
|
+
* that no trace target is active.
|
|
465
|
+
*/
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* @typedef {Object} TraceTargetUpdateInfo
|
|
469
|
+
* @property {number} index The new target index.
|
|
470
|
+
* @property {number} endIndex The new segment end index.
|
|
471
|
+
* @property {number} closestTargetDistance The squared distance to the closest target.
|
|
472
|
+
*/
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @type {TraceTargetUpdateInfo}
|
|
476
|
+
*/
|
|
477
|
+
const sharedUpdateInfo = {
|
|
478
|
+
index: -1,
|
|
479
|
+
endIndex: NaN,
|
|
480
|
+
closestTargetDistance: Infinity,
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @param {import("../coordinate.js").Coordinate} coordinate The coordinate.
|
|
485
|
+
* @param {TraceState} traceState The trace state.
|
|
486
|
+
* @param {import("../Map.js").default} map The map.
|
|
487
|
+
* @param {number} snapTolerance The snap tolerance.
|
|
488
|
+
* @return {TraceTargetUpdateInfo} Information about the new trace target. The returned
|
|
489
|
+
* object is reused between calls and must not be modified by the caller.
|
|
490
|
+
*/
|
|
491
|
+
function getTraceTargetUpdate(
|
|
492
|
+
coordinate,
|
|
493
|
+
traceState,
|
|
494
|
+
map,
|
|
495
|
+
snapTolerance,
|
|
496
|
+
) {
|
|
497
|
+
const x = coordinate[0];
|
|
498
|
+
const y = coordinate[1];
|
|
499
|
+
|
|
500
|
+
let closestTargetDistance = Infinity;
|
|
501
|
+
|
|
502
|
+
let newTargetIndex = -1;
|
|
503
|
+
let newEndIndex = NaN;
|
|
504
|
+
|
|
505
|
+
for (
|
|
506
|
+
let targetIndex = 0;
|
|
507
|
+
targetIndex < traceState.targets.length;
|
|
508
|
+
++targetIndex
|
|
509
|
+
) {
|
|
510
|
+
const target = traceState.targets[targetIndex];
|
|
511
|
+
const coordinates = target.coordinates;
|
|
512
|
+
|
|
513
|
+
let minSegmentDistance = Infinity;
|
|
514
|
+
let endIndex;
|
|
515
|
+
for (
|
|
516
|
+
let coordinateIndex = 0;
|
|
517
|
+
coordinateIndex < coordinates.length - 1;
|
|
518
|
+
++coordinateIndex
|
|
519
|
+
) {
|
|
520
|
+
const start = coordinates[coordinateIndex];
|
|
521
|
+
const end = coordinates[coordinateIndex + 1];
|
|
522
|
+
const rel = getPointSegmentRelationship(x, y, start, end);
|
|
523
|
+
if (rel.squaredDistance < minSegmentDistance) {
|
|
524
|
+
minSegmentDistance = rel.squaredDistance;
|
|
525
|
+
endIndex = coordinateIndex + rel.along;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (minSegmentDistance < closestTargetDistance) {
|
|
530
|
+
closestTargetDistance = minSegmentDistance;
|
|
531
|
+
if (target.ring && traceState.targetIndex === targetIndex) {
|
|
532
|
+
// same target, maintain the same trace direction
|
|
533
|
+
if (target.endIndex > target.startIndex) {
|
|
534
|
+
// forward trace
|
|
535
|
+
if (endIndex < target.startIndex) {
|
|
536
|
+
endIndex += coordinates.length;
|
|
537
|
+
}
|
|
538
|
+
} else if (target.endIndex < target.startIndex) {
|
|
539
|
+
// reverse trace
|
|
540
|
+
if (endIndex > target.startIndex) {
|
|
541
|
+
endIndex -= coordinates.length;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
newEndIndex = endIndex;
|
|
546
|
+
newTargetIndex = targetIndex;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const newTarget = traceState.targets[newTargetIndex];
|
|
551
|
+
let considerBothDirections = newTarget.ring;
|
|
552
|
+
if (traceState.targetIndex === newTargetIndex && considerBothDirections) {
|
|
553
|
+
// only consider switching trace direction if close to the start
|
|
554
|
+
const newCoordinate = interpolateCoordinate(
|
|
555
|
+
newTarget.coordinates,
|
|
556
|
+
newEndIndex,
|
|
557
|
+
);
|
|
558
|
+
const pixel = map.getPixelFromCoordinate(newCoordinate);
|
|
559
|
+
const startPx = map.getPixelFromCoordinate(traceState.startCoord);
|
|
560
|
+
if ((0,_coordinate_js__WEBPACK_IMPORTED_MODULE_0__.distance)(pixel, startPx) > snapTolerance) {
|
|
561
|
+
considerBothDirections = false;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (considerBothDirections) {
|
|
566
|
+
const coordinates = newTarget.coordinates;
|
|
567
|
+
const count = coordinates.length;
|
|
568
|
+
const startIndex = newTarget.startIndex;
|
|
569
|
+
const endIndex = newEndIndex;
|
|
570
|
+
if (startIndex < endIndex) {
|
|
571
|
+
const forwardDistance = getCumulativeSquaredDistance(
|
|
572
|
+
coordinates,
|
|
573
|
+
startIndex,
|
|
574
|
+
endIndex,
|
|
575
|
+
);
|
|
576
|
+
const reverseDistance = getCumulativeSquaredDistance(
|
|
577
|
+
coordinates,
|
|
578
|
+
startIndex,
|
|
579
|
+
endIndex - count,
|
|
580
|
+
);
|
|
581
|
+
if (reverseDistance < forwardDistance) {
|
|
582
|
+
newEndIndex -= count;
|
|
583
|
+
}
|
|
584
|
+
} else {
|
|
585
|
+
const reverseDistance = getCumulativeSquaredDistance(
|
|
586
|
+
coordinates,
|
|
587
|
+
startIndex,
|
|
588
|
+
endIndex,
|
|
589
|
+
);
|
|
590
|
+
const forwardDistance = getCumulativeSquaredDistance(
|
|
591
|
+
coordinates,
|
|
592
|
+
startIndex,
|
|
593
|
+
endIndex + count,
|
|
594
|
+
);
|
|
595
|
+
if (forwardDistance < reverseDistance) {
|
|
596
|
+
newEndIndex += count;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
sharedUpdateInfo.index = newTargetIndex;
|
|
602
|
+
sharedUpdateInfo.endIndex = newEndIndex;
|
|
603
|
+
sharedUpdateInfo.closestTargetDistance = closestTargetDistance;
|
|
604
|
+
return sharedUpdateInfo;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* @param {import("../coordinate.js").Coordinate} coordinate The coordinate.
|
|
609
|
+
* @param {Array<import("../Feature.js").default>} features The candidate features.
|
|
610
|
+
* @return {Array<TraceTarget>} The trace targets.
|
|
611
|
+
*/
|
|
612
|
+
function getTraceTargets(coordinate, features) {
|
|
613
|
+
/**
|
|
614
|
+
* @type {Array<TraceTarget>}
|
|
615
|
+
*/
|
|
616
|
+
const targets = [];
|
|
617
|
+
|
|
618
|
+
for (let i = 0; i < features.length; ++i) {
|
|
619
|
+
const feature = features[i];
|
|
620
|
+
const geometry = feature.getGeometry();
|
|
621
|
+
appendGeometryTraceTargets(coordinate, geometry, targets);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return targets;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* @param {import("../coordinate.js").Coordinate} coordinate The coordinate.
|
|
629
|
+
* @param {import("../geom/Geometry.js").default} geometry The candidate geometry.
|
|
630
|
+
* @param {Array<TraceTarget>} targets The trace targets.
|
|
631
|
+
*/
|
|
632
|
+
function appendGeometryTraceTargets(coordinate, geometry, targets) {
|
|
633
|
+
if (geometry instanceof _geom_LineString_js__WEBPACK_IMPORTED_MODULE_1__["default"]) {
|
|
634
|
+
appendTraceTarget(coordinate, geometry.getCoordinates(), false, targets);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
if (geometry instanceof _geom_MultiLineString_js__WEBPACK_IMPORTED_MODULE_2__["default"]) {
|
|
638
|
+
const coordinates = geometry.getCoordinates();
|
|
639
|
+
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
|
640
|
+
appendTraceTarget(coordinate, coordinates[i], false, targets);
|
|
641
|
+
}
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
if (geometry instanceof _geom_Polygon_js__WEBPACK_IMPORTED_MODULE_3__["default"]) {
|
|
645
|
+
const coordinates = geometry.getCoordinates();
|
|
646
|
+
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
|
647
|
+
appendTraceTarget(coordinate, coordinates[i], true, targets);
|
|
648
|
+
}
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
if (geometry instanceof _geom_MultiPolygon_js__WEBPACK_IMPORTED_MODULE_4__["default"]) {
|
|
652
|
+
const polys = geometry.getCoordinates();
|
|
653
|
+
for (let i = 0, ii = polys.length; i < ii; ++i) {
|
|
654
|
+
const coordinates = polys[i];
|
|
655
|
+
for (let j = 0, jj = coordinates.length; j < jj; ++j) {
|
|
656
|
+
appendTraceTarget(coordinate, coordinates[j], true, targets);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
if (geometry instanceof _geom_GeometryCollection_js__WEBPACK_IMPORTED_MODULE_5__["default"]) {
|
|
662
|
+
const geometries = geometry.getGeometries();
|
|
663
|
+
for (let i = 0; i < geometries.length; ++i) {
|
|
664
|
+
appendGeometryTraceTargets(coordinate, geometries[i], targets);
|
|
665
|
+
}
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
// other types cannot be traced
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* @param {import("../coordinate.js").Coordinate} coordinate The clicked coordinate.
|
|
673
|
+
* @param {Array<import("../coordinate.js").Coordinate>} coordinates The geometry component coordinates.
|
|
674
|
+
* @param {boolean} ring The coordinates represent a linear ring.
|
|
675
|
+
* @param {Array<TraceTarget>} targets The trace targets.
|
|
676
|
+
*/
|
|
677
|
+
function appendTraceTarget(coordinate, coordinates, ring, targets) {
|
|
678
|
+
const x = coordinate[0];
|
|
679
|
+
const y = coordinate[1];
|
|
680
|
+
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
|
681
|
+
const start = coordinates[i];
|
|
682
|
+
const end = coordinates[i + 1];
|
|
683
|
+
const rel = getPointSegmentRelationship(x, y, start, end);
|
|
684
|
+
if (rel.squaredDistance === 0) {
|
|
685
|
+
const index = i + rel.along;
|
|
686
|
+
targets.push({
|
|
687
|
+
coordinates: coordinates,
|
|
688
|
+
ring: ring,
|
|
689
|
+
startIndex: index,
|
|
690
|
+
endIndex: index,
|
|
691
|
+
});
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* @param {import("../coordinate.js").Coordinate} a One coordinate.
|
|
699
|
+
* @param {import("../coordinate.js").Coordinate} b Another coordinate.
|
|
700
|
+
* @return {number} The squared distance between the two coordinates.
|
|
701
|
+
*/
|
|
702
|
+
function getSquaredDistance(a, b) {
|
|
703
|
+
return (0,_math_js__WEBPACK_IMPORTED_MODULE_6__.squaredDistance)(a[0], a[1], b[0], b[1]);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Get the cumulative squared distance along a ring path. The end index index may be "wrapped" and it may
|
|
708
|
+
* be less than the start index to indicate the direction of travel. The start and end index may have
|
|
709
|
+
* a fractional part to indicate a point between two coordinates.
|
|
710
|
+
* @param {LineCoordType} coordinates Ring coordinates.
|
|
711
|
+
* @param {number} startIndex The start index.
|
|
712
|
+
* @param {number} endIndex The end index.
|
|
713
|
+
* @return {number} The cumulative squared distance along the ring path.
|
|
714
|
+
*/
|
|
715
|
+
function getCumulativeSquaredDistance(coordinates, startIndex, endIndex) {
|
|
716
|
+
let lowIndex, highIndex;
|
|
717
|
+
if (startIndex < endIndex) {
|
|
718
|
+
lowIndex = startIndex;
|
|
719
|
+
highIndex = endIndex;
|
|
720
|
+
} else {
|
|
721
|
+
lowIndex = endIndex;
|
|
722
|
+
highIndex = startIndex;
|
|
723
|
+
}
|
|
724
|
+
const lowWholeIndex = Math.ceil(lowIndex);
|
|
725
|
+
const highWholeIndex = Math.floor(highIndex);
|
|
726
|
+
|
|
727
|
+
if (lowWholeIndex > highWholeIndex) {
|
|
728
|
+
// both start and end are on the same segment
|
|
729
|
+
const start = interpolateCoordinate(coordinates, lowIndex);
|
|
730
|
+
const end = interpolateCoordinate(coordinates, highIndex);
|
|
731
|
+
return getSquaredDistance(start, end);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
let sd = 0;
|
|
735
|
+
|
|
736
|
+
if (lowIndex < lowWholeIndex) {
|
|
737
|
+
const start = interpolateCoordinate(coordinates, lowIndex);
|
|
738
|
+
const end = getCoordinate(coordinates, lowWholeIndex);
|
|
739
|
+
sd += getSquaredDistance(start, end);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
if (highWholeIndex < highIndex) {
|
|
743
|
+
const start = getCoordinate(coordinates, highWholeIndex);
|
|
744
|
+
const end = interpolateCoordinate(coordinates, highIndex);
|
|
745
|
+
sd += getSquaredDistance(start, end);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
for (let i = lowWholeIndex; i < highWholeIndex - 1; ++i) {
|
|
749
|
+
const start = getCoordinate(coordinates, i);
|
|
750
|
+
const end = getCoordinate(coordinates, i + 1);
|
|
751
|
+
sd += getSquaredDistance(start, end);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
return sd;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* @typedef {Object} PointSegmentRelationship
|
|
759
|
+
* @property {number} along The closest point expressed as a fraction along the segment length.
|
|
760
|
+
* @property {number} squaredDistance The squared distance of the point to the segment.
|
|
761
|
+
*/
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* @type {PointSegmentRelationship}
|
|
765
|
+
*/
|
|
766
|
+
const sharedRel = {along: 0, squaredDistance: 0};
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* @param {number} x The point x.
|
|
770
|
+
* @param {number} y The point y.
|
|
771
|
+
* @param {import("../coordinate.js").Coordinate} start The segment start.
|
|
772
|
+
* @param {import("../coordinate.js").Coordinate} end The segment end.
|
|
773
|
+
* @return {PointSegmentRelationship} The point segment relationship. The returned object is
|
|
774
|
+
* shared between calls and must not be modified by the caller.
|
|
775
|
+
*/
|
|
776
|
+
function getPointSegmentRelationship(x, y, start, end) {
|
|
777
|
+
const x1 = start[0];
|
|
778
|
+
const y1 = start[1];
|
|
779
|
+
const x2 = end[0];
|
|
780
|
+
const y2 = end[1];
|
|
781
|
+
const dx = x2 - x1;
|
|
782
|
+
const dy = y2 - y1;
|
|
783
|
+
let along = 0;
|
|
784
|
+
let px = x1;
|
|
785
|
+
let py = y1;
|
|
786
|
+
if (dx !== 0 || dy !== 0) {
|
|
787
|
+
along = (0,_math_js__WEBPACK_IMPORTED_MODULE_6__.clamp)(((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy), 0, 1);
|
|
788
|
+
px += dx * along;
|
|
789
|
+
py += dy * along;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
sharedRel.along = along;
|
|
793
|
+
sharedRel.squaredDistance = (0,_math_js__WEBPACK_IMPORTED_MODULE_6__.toFixed)((0,_math_js__WEBPACK_IMPORTED_MODULE_6__.squaredDistance)(x, y, px, py), 10);
|
|
794
|
+
return sharedRel;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
/***/ })
|
|
799
|
+
|
|
800
|
+
}])
|
|
801
|
+
//# sourceMappingURL=vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js.js.map
|