@vaadin/bundles 25.0.0-alpha3 → 25.0.0-alpha5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules_ol_ImageCanvas_js.js +76 -83
- package/node_modules_ol_ImageCanvas_js.js.map +1 -1
- package/node_modules_ol_TileRange_js.js +128 -110
- package/node_modules_ol_TileRange_js.js.map +1 -1
- package/node_modules_ol_Tile_js.js +279 -0
- package/node_modules_ol_Tile_js.js.map +1 -0
- package/node_modules_ol_VectorRenderTile_js.js +428 -143
- package/node_modules_ol_VectorRenderTile_js.js.map +1 -1
- package/node_modules_ol_VectorTile_js.js +405 -119
- package/node_modules_ol_VectorTile_js.js.map +1 -1
- package/node_modules_ol_control_MousePosition_js.js +327 -0
- package/node_modules_ol_control_MousePosition_js.js.map +1 -0
- package/node_modules_ol_control_ZoomToExtent_js.js +118 -0
- package/node_modules_ol_control_ZoomToExtent_js.js.map +1 -0
- package/node_modules_ol_events_SnapEvent_js.js +79 -0
- package/node_modules_ol_events_SnapEvent_js.js.map +1 -0
- package/node_modules_ol_featureloader_js.js +205 -0
- package/node_modules_ol_featureloader_js.js.map +1 -0
- package/node_modules_ol_geom_Circle_js.js +300 -0
- package/node_modules_ol_geom_Circle_js.js.map +1 -0
- package/node_modules_ol_geom_GeometryCollection_js.js +369 -0
- package/node_modules_ol_geom_GeometryCollection_js.js.map +1 -0
- package/node_modules_ol_geom_MultiPoint_js.js +228 -0
- package/node_modules_ol_geom_MultiPoint_js.js.map +1 -0
- package/node_modules_ol_geom_flat_center_js.js +47 -0
- package/node_modules_ol_geom_flat_center_js.js.map +1 -0
- package/node_modules_ol_geom_flat_geodesic_js.js +123 -88
- package/node_modules_ol_geom_flat_geodesic_js.js.map +1 -1
- package/node_modules_ol_geom_flat_interpolate_js.js +230 -0
- package/node_modules_ol_geom_flat_interpolate_js.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a0.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a0.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a1.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a1.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a2.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a2.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a3.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a3.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a4.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a4.js.map +1 -0
- package/node_modules_ol_geom_flat_linechunk_js.js +76 -0
- package/node_modules_ol_geom_flat_linechunk_js.js.map +1 -0
- package/node_modules_ol_geom_flat_straightchunk_js.js +68 -0
- package/node_modules_ol_geom_flat_straightchunk_js.js.map +1 -0
- package/node_modules_ol_geom_flat_textpath_js.js +178 -0
- package/node_modules_ol_geom_flat_textpath_js.js.map +1 -0
- package/node_modules_ol_interaction_DblClickDragZoom_js.js +285 -0
- package/node_modules_ol_interaction_DblClickDragZoom_js.js.map +1 -0
- package/node_modules_ol_interaction_DragAndDrop_js.js +351 -0
- package/node_modules_ol_interaction_DragAndDrop_js.js.map +1 -0
- package/node_modules_ol_interaction_DragRotateAndZoom_js.js +159 -0
- package/node_modules_ol_interaction_DragRotateAndZoom_js.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49290.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49290.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49291.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49291.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49292.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49292.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49293.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49293.js.map +1 -0
- package/node_modules_ol_loadingstrategy_js.js +95 -0
- package/node_modules_ol_loadingstrategy_js.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-_3ad60.js +144 -0
- package/node_modules_ol_render_VectorContext_js-_3ad60.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-_3ad61.js +144 -0
- package/node_modules_ol_render_VectorContext_js-_3ad61.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js +372 -0
- package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js.map +1 -0
- package/node_modules_ol_render_canvas_ImageBuilder_js.js +318 -0
- package/node_modules_ol_render_canvas_ImageBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_Instruction_js.js +66 -0
- package/node_modules_ol_render_canvas_Instruction_js.js.map +1 -0
- package/node_modules_ol_render_canvas_LineStringBuilder_js.js +187 -0
- package/node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_PolygonBuilder_js.js +276 -0
- package/node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js +156 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js.map +1 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js +156 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js.map +1 -0
- package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js +301 -0
- package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js.map +1 -0
- package/node_modules_ol_renderer_Layer_js.js +219 -0
- package/node_modules_ol_renderer_Layer_js.js.map +1 -0
- package/node_modules_ol_source_Source_js.js +256 -0
- package/node_modules_ol_source_Source_js.js.map +1 -0
- package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js +318 -0
- package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js.map +1 -0
- package/node_modules_ol_source_VectorEventType_js.js +80 -0
- package/node_modules_ol_source_VectorEventType_js.js.map +1 -0
- package/node_modules_ol_structs_RBush_js.js +242 -0
- package/node_modules_ol_structs_RBush_js.js.map +1 -0
- package/node_modules_ol_style_js.js +2 -1
- package/node_modules_ol_style_js.js.map +1 -1
- package/node_modules_rbush_rbush_min_js.js +16 -0
- package/node_modules_rbush_rbush_min_js.js.map +1 -0
- package/package.json +142 -146
- package/vaadin-bundle.json +2447 -2352
- package/vaadin.js +52246 -63791
- package/vaadin.js.map +1 -1
- package/vendors-node_modules_dompurify_dist_purify_es_mjs.js +1364 -0
- package/vendors-node_modules_dompurify_dist_purify_es_mjs.js.map +1 -0
- package/vendors-node_modules_dompurify_dist_purify_js.js +26 -21
- package/vendors-node_modules_dompurify_dist_purify_js.js.map +1 -1
- package/vendors-node_modules_marked_lib_marked_esm_js.js +2205 -0
- package/vendors-node_modules_marked_lib_marked_esm_js.js.map +1 -0
- package/vendors-node_modules_marked_lib_marked_umd_js.js +2164 -2556
- package/vendors-node_modules_marked_lib_marked_umd_js.js.map +1 -1
- package/vendors-node_modules_ol_Feature_js.js +360 -0
- package/vendors-node_modules_ol_Feature_js.js.map +1 -0
- package/vendors-node_modules_ol_Geolocation_js.js +352 -293
- package/vendors-node_modules_ol_Geolocation_js.js.map +1 -1
- package/vendors-node_modules_ol_ImageTile_js.js +494 -0
- package/vendors-node_modules_ol_ImageTile_js.js.map +1 -0
- package/vendors-node_modules_ol_Overlay_js.js +606 -0
- package/vendors-node_modules_ol_Overlay_js.js.map +1 -0
- package/vendors-node_modules_ol_control_FullScreen_js.js +417 -0
- package/vendors-node_modules_ol_control_FullScreen_js.js.map +1 -0
- package/vendors-node_modules_ol_control_OverviewMap_js.js +711 -0
- package/vendors-node_modules_ol_control_OverviewMap_js.js.map +1 -0
- package/vendors-node_modules_ol_control_ScaleLine_js.js +509 -0
- package/vendors-node_modules_ol_control_ScaleLine_js.js.map +1 -0
- package/vendors-node_modules_ol_control_ZoomSlider_js.js +418 -0
- package/vendors-node_modules_ol_control_ZoomSlider_js.js.map +1 -0
- package/vendors-node_modules_ol_control_js.js +490 -0
- package/vendors-node_modules_ol_control_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_LineString_js.js +574 -0
- package/vendors-node_modules_ol_geom_LineString_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_MultiLineString_js.js +405 -0
- package/vendors-node_modules_ol_geom_MultiLineString_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_MultiPolygon_js.js +773 -0
- package/vendors-node_modules_ol_geom_MultiPolygon_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js +769 -0
- package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js.map +1 -0
- package/vendors-node_modules_ol_index_js.js +526 -675
- package/vendors-node_modules_ol_index_js.js.map +1 -1
- package/vendors-node_modules_ol_interaction_Draw_js.js +2777 -0
- package/vendors-node_modules_ol_interaction_Draw_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Extent_js.js +586 -0
- package/vendors-node_modules_ol_interaction_Extent_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Link_js.js +489 -0
- package/vendors-node_modules_ol_interaction_Link_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Modify_js.js +1841 -0
- package/vendors-node_modules_ol_interaction_Modify_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Select_js.js +623 -0
- package/vendors-node_modules_ol_interaction_Select_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Snap_js.js +982 -0
- package/vendors-node_modules_ol_interaction_Snap_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Translate_js.js +466 -0
- package/vendors-node_modules_ol_interaction_Translate_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_js.js +872 -0
- package/vendors-node_modules_ol_interaction_js.js.map +1 -0
- package/vendors-node_modules_ol_layer_Graticule_js.js +1374 -989
- package/vendors-node_modules_ol_layer_Graticule_js.js.map +1 -1
- package/vendors-node_modules_ol_render_Feature_js.js +546 -0
- package/vendors-node_modules_ol_render_Feature_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js +897 -0
- package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Builder_js.js +907 -0
- package/vendors-node_modules_ol_render_canvas_Builder_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js +539 -0
- package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Executor_js.js +1715 -0
- package/vendors-node_modules_ol_render_canvas_Executor_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Immediate_js.js +1208 -0
- package/vendors-node_modules_ol_render_canvas_Immediate_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js +825 -0
- package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_canvas_Layer_js.js +654 -0
- package/vendors-node_modules_ol_renderer_canvas_Layer_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js +1044 -0
- package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_vector_js.js +460 -0
- package/vendors-node_modules_ol_renderer_vector_js.js.map +1 -0
- package/vendors-node_modules_ol_source_Vector_js.js +2091 -0
- package/vendors-node_modules_ol_source_Vector_js.js.map +1 -0
- package/node_modules_ol_ImageTile_js.js +0 -177
- package/node_modules_ol_ImageTile_js.js.map +0 -1
- package/node_modules_ol_render_js.js +0 -131
- package/node_modules_ol_render_js.js.map +0 -1
- package/node_modules_ol_structs_LRUCache_js.js +0 -275
- package/node_modules_ol_structs_LRUCache_js.js.map +0 -1
- package/node_modules_ol_tilecoord_js.js +0 -115
- package/node_modules_ol_tilecoord_js.js.map +0 -1
- package/vendors-node_modules_ol_TileCache_js.js +0 -461
- package/vendors-node_modules_ol_TileCache_js.js.map +0 -1
- package/vendors-node_modules_ol_Tile_js.js +0 -330
- package/vendors-node_modules_ol_Tile_js.js.map +0 -1
- package/vendors-node_modules_ol_style_Text_js.js +0 -509
- package/vendors-node_modules_ol_style_Text_js.js.map +0 -1
- package/vendors-node_modules_rbush_index_js.js +0 -531
- package/vendors-node_modules_rbush_index_js.js.map +0 -1
|
@@ -0,0 +1,982 @@
|
|
|
1
|
+
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_ol_interaction_Snap_js"],{
|
|
2
|
+
|
|
3
|
+
/***/ "./node_modules/ol/events/SnapEvent.js":
|
|
4
|
+
/*!*********************************************!*\
|
|
5
|
+
!*** ./node_modules/ol/events/SnapEvent.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 */ "SnapEvent": () => (/* binding */ SnapEvent),
|
|
12
|
+
/* harmony export */ "SnapEventType": () => (/* binding */ SnapEventType)
|
|
13
|
+
/* harmony export */ });
|
|
14
|
+
/* harmony import */ var _Event_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Event.js */ "./node_modules/ol/events/Event.js");
|
|
15
|
+
/**
|
|
16
|
+
* @module ol/events/SnapEvent
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @enum {string}
|
|
22
|
+
*/
|
|
23
|
+
const SnapEventType = {
|
|
24
|
+
/**
|
|
25
|
+
* Triggered upon snapping to vertex or edge
|
|
26
|
+
* @event SnapEvent#snap
|
|
27
|
+
* @api
|
|
28
|
+
*/
|
|
29
|
+
SNAP: 'snap',
|
|
30
|
+
UNSNAP: 'unsnap',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @classdesc
|
|
35
|
+
* Events emitted by {@link module:ol/interaction/Snap~Snap} instances are instances of this
|
|
36
|
+
*/
|
|
37
|
+
class SnapEvent extends _Event_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
38
|
+
/**
|
|
39
|
+
* @param {SnapEventType} type Type.
|
|
40
|
+
* @param {Object} options Options.
|
|
41
|
+
* @param {import("../coordinate.js").Coordinate} options.vertex The snapped vertex.
|
|
42
|
+
* @param {import("../coordinate.js").Coordinate} options.vertexPixel The pixel of the snapped vertex.
|
|
43
|
+
* @param {import("../Feature.js").default} options.feature The feature being snapped.
|
|
44
|
+
* @param {Array<import("../coordinate.js").Coordinate>|null} options.segment Segment, or `null` if snapped to a vertex.
|
|
45
|
+
*/
|
|
46
|
+
constructor(type, options) {
|
|
47
|
+
super(type);
|
|
48
|
+
/**
|
|
49
|
+
* The Map coordinate of the snapped point.
|
|
50
|
+
* @type {import("../coordinate.js").Coordinate}
|
|
51
|
+
* @api
|
|
52
|
+
*/
|
|
53
|
+
this.vertex = options.vertex;
|
|
54
|
+
/**
|
|
55
|
+
* The Map pixel of the snapped point.
|
|
56
|
+
* @type {Array<number>&Array<number>}
|
|
57
|
+
* @api
|
|
58
|
+
*/
|
|
59
|
+
this.vertexPixel = options.vertexPixel;
|
|
60
|
+
/**
|
|
61
|
+
* The feature closest to the snapped point.
|
|
62
|
+
* @type {import("../Feature.js").default<import("../geom/Geometry.js").default>}
|
|
63
|
+
* @api
|
|
64
|
+
*/
|
|
65
|
+
this.feature = options.feature;
|
|
66
|
+
/**
|
|
67
|
+
* The segment closest to the snapped point, if snapped to a segment.
|
|
68
|
+
* @type {Array<import("../coordinate.js").Coordinate>|null}
|
|
69
|
+
* @api
|
|
70
|
+
*/
|
|
71
|
+
this.segment = options.segment;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/***/ }),
|
|
77
|
+
|
|
78
|
+
/***/ "./node_modules/ol/interaction/Snap.js":
|
|
79
|
+
/*!*********************************************!*\
|
|
80
|
+
!*** ./node_modules/ol/interaction/Snap.js ***!
|
|
81
|
+
\*********************************************/
|
|
82
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
83
|
+
|
|
84
|
+
__webpack_require__.r(__webpack_exports__);
|
|
85
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
86
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
87
|
+
/* harmony export */ });
|
|
88
|
+
/* harmony import */ var _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../CollectionEventType.js */ "./node_modules/ol/CollectionEventType.js");
|
|
89
|
+
/* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/ol/coordinate.js");
|
|
90
|
+
/* harmony import */ var _events_EventType_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../events/EventType.js */ "./node_modules/ol/events/EventType.js");
|
|
91
|
+
/* harmony import */ var _events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../events/SnapEvent.js */ "./node_modules/ol/events/SnapEvent.js");
|
|
92
|
+
/* harmony import */ var _events_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../events.js */ "./node_modules/ol/events.js");
|
|
93
|
+
/* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../extent.js */ "./node_modules/ol/extent.js");
|
|
94
|
+
/* harmony import */ var _functions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../functions.js */ "./node_modules/ol/functions.js");
|
|
95
|
+
/* harmony import */ var _geom_Polygon_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geom/Polygon.js */ "./node_modules/ol/geom/Polygon.js");
|
|
96
|
+
/* harmony import */ var _geom_flat_segments_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../geom/flat/segments.js */ "./node_modules/ol/geom/flat/segments.js");
|
|
97
|
+
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../proj.js */ "./node_modules/ol/proj.js");
|
|
98
|
+
/* harmony import */ var _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../source/VectorEventType.js */ "./node_modules/ol/source/VectorEventType.js");
|
|
99
|
+
/* harmony import */ var _structs_RBush_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../structs/RBush.js */ "./node_modules/ol/structs/RBush.js");
|
|
100
|
+
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util.js */ "./node_modules/ol/util.js");
|
|
101
|
+
/* harmony import */ var _Pointer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Pointer.js */ "./node_modules/ol/interaction/Pointer.js");
|
|
102
|
+
/**
|
|
103
|
+
* @module ol/interaction/Snap
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @typedef {Array<import("../coordinate.js").Coordinate>} Segment
|
|
122
|
+
* An array of two coordinates representing a line segment, or an array of one
|
|
123
|
+
* coordinate representing a point.
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @typedef {Object} SegmentData
|
|
128
|
+
* @property {import("../Feature.js").default} feature Feature.
|
|
129
|
+
* @property {Segment} segment Segment.
|
|
130
|
+
* @property {boolean} [isIntersection] Is intersection.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @template {import("../geom/Geometry.js").default} [GeometryType=import("../geom/Geometry.js").default]
|
|
135
|
+
* @typedef {(geometry: GeometryType, projection?: import("../proj/Projection.js").default) => Array<Segment>} Segmenter
|
|
136
|
+
* A function taking a {@link module:ol/geom/Geometry~Geometry} as argument and returning an array of {@link Segment}s.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Each segmenter specified here will override the default segmenter for the
|
|
141
|
+
* corresponding geometry type. To exclude all geometries of a specific geometry type from being snapped to,
|
|
142
|
+
* set the segmenter to `null`.
|
|
143
|
+
* @typedef {Object} Segmenters
|
|
144
|
+
* @property {Segmenter<import("../geom/Point.js").default>|null} [Point] Point segmenter.
|
|
145
|
+
* @property {Segmenter<import("../geom/LineString.js").default>|null} [LineString] LineString segmenter.
|
|
146
|
+
* @property {Segmenter<import("../geom/Polygon.js").default>|null} [Polygon] Polygon segmenter.
|
|
147
|
+
* @property {Segmenter<import("../geom/Circle.js").default>|null} [Circle] Circle segmenter.
|
|
148
|
+
* @property {Segmenter<import("../geom/GeometryCollection.js").default>|null} [GeometryCollection] GeometryCollection segmenter.
|
|
149
|
+
* @property {Segmenter<import("../geom/MultiPoint.js").default>|null} [MultiPoint] MultiPoint segmenter.
|
|
150
|
+
* @property {Segmenter<import("../geom/MultiLineString.js").default>|null} [MultiLineString] MultiLineString segmenter.
|
|
151
|
+
* @property {Segmenter<import("../geom/MultiPolygon.js").default>|null} [MultiPolygon] MultiPolygon segmenter.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @typedef {Object} Options
|
|
156
|
+
* @property {import("../Collection.js").default<import("../Feature.js").default>} [features] Snap to these features. Either this option or source should be provided.
|
|
157
|
+
* @property {import("../source/Vector.js").default} [source] Snap to features from this source. Either this option or features should be provided
|
|
158
|
+
* @property {boolean} [edge=true] Snap to edges.
|
|
159
|
+
* @property {boolean} [vertex=true] Snap to vertices.
|
|
160
|
+
* @property {boolean} [intersection=false] Snap to intersections between segments.
|
|
161
|
+
* @property {number} [pixelTolerance=10] Pixel tolerance for considering the pointer close enough to a segment or
|
|
162
|
+
* vertex for snapping.
|
|
163
|
+
* @property {Segmenters} [segmenters] Custom segmenters by {@link module:ol/geom/Geometry~Type}. By default, the
|
|
164
|
+
* following segmenters are used:
|
|
165
|
+
* - `Point`: A one-dimensional segment (e.g. `[[10, 20]]`) representing the point.
|
|
166
|
+
* - `LineString`: One two-dimensional segment (e.g. `[[10, 20], [30, 40]]`) for each segment of the linestring.
|
|
167
|
+
* - `Polygon`: One two-dimensional segment for each segment of the exterior ring and the interior rings.
|
|
168
|
+
* - `Circle`: One two-dimensional segment for each segment of a regular polygon with 32 points representing the circle circumference.
|
|
169
|
+
* - `GeometryCollection`: All segments of the contained geometries.
|
|
170
|
+
* - `MultiPoint`: One one-dimensional segment for each point.
|
|
171
|
+
* - `MultiLineString`: One two-dimensional segment for each segment of the linestrings.
|
|
172
|
+
* - `MultiPolygon`: One two-dimensional segment for each segment of the polygons.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Information about the last snapped state.
|
|
177
|
+
* @typedef {Object} SnappedInfo
|
|
178
|
+
* @property {import("../coordinate.js").Coordinate|null} vertex - The snapped vertex.
|
|
179
|
+
* @property {import("../pixel.js").Pixel|null} vertexPixel - The pixel of the snapped vertex.
|
|
180
|
+
* @property {import("../Feature.js").default|null} feature - The feature being snapped.
|
|
181
|
+
* @property {Segment|null} segment - Segment, or `null` if snapped to a vertex.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/***
|
|
185
|
+
* @type {Object<string, Segmenter>}
|
|
186
|
+
*/
|
|
187
|
+
const GEOMETRY_SEGMENTERS = {
|
|
188
|
+
/**
|
|
189
|
+
* @param {import("../geom/Circle.js").default} geometry Geometry.
|
|
190
|
+
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
191
|
+
* @return {Array<Segment>} Segments
|
|
192
|
+
*/
|
|
193
|
+
Circle(geometry, projection) {
|
|
194
|
+
let circleGeometry = geometry;
|
|
195
|
+
const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
196
|
+
if (userProjection) {
|
|
197
|
+
circleGeometry = circleGeometry
|
|
198
|
+
.clone()
|
|
199
|
+
.transform(userProjection, projection);
|
|
200
|
+
}
|
|
201
|
+
const polygon = (0,_geom_Polygon_js__WEBPACK_IMPORTED_MODULE_1__.fromCircle)(circleGeometry);
|
|
202
|
+
if (userProjection) {
|
|
203
|
+
polygon.transform(projection, userProjection);
|
|
204
|
+
}
|
|
205
|
+
return GEOMETRY_SEGMENTERS.Polygon(polygon);
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
|
|
210
|
+
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
211
|
+
* @return {Array<Segment>} Segments
|
|
212
|
+
*/
|
|
213
|
+
GeometryCollection(geometry, projection) {
|
|
214
|
+
/** @type {Array<Array<Segment>>} */
|
|
215
|
+
const segments = [];
|
|
216
|
+
const geometries = geometry.getGeometriesArray();
|
|
217
|
+
for (let i = 0; i < geometries.length; ++i) {
|
|
218
|
+
const segmenter = GEOMETRY_SEGMENTERS[geometries[i].getType()];
|
|
219
|
+
if (segmenter) {
|
|
220
|
+
segments.push(segmenter(geometries[i], projection));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return segments.flat();
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @param {import("../geom/LineString.js").default} geometry Geometry.
|
|
228
|
+
* @return {Array<Segment>} Segments
|
|
229
|
+
*/
|
|
230
|
+
LineString(geometry) {
|
|
231
|
+
/** @type {Array<Segment>} */
|
|
232
|
+
const segments = [];
|
|
233
|
+
const coordinates = geometry.getFlatCoordinates();
|
|
234
|
+
const stride = geometry.getStride();
|
|
235
|
+
for (let i = 0, ii = coordinates.length - stride; i < ii; i += stride) {
|
|
236
|
+
segments.push([
|
|
237
|
+
coordinates.slice(i, i + 2),
|
|
238
|
+
coordinates.slice(i + stride, i + stride + 2),
|
|
239
|
+
]);
|
|
240
|
+
}
|
|
241
|
+
return segments;
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @param {import("../geom/MultiLineString.js").default} geometry Geometry.
|
|
246
|
+
* @return {Array<Segment>} Segments
|
|
247
|
+
*/
|
|
248
|
+
MultiLineString(geometry) {
|
|
249
|
+
/** @type {Array<Segment>} */
|
|
250
|
+
const segments = [];
|
|
251
|
+
const coordinates = geometry.getFlatCoordinates();
|
|
252
|
+
const stride = geometry.getStride();
|
|
253
|
+
const ends = geometry.getEnds();
|
|
254
|
+
let offset = 0;
|
|
255
|
+
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
|
256
|
+
const end = ends[i];
|
|
257
|
+
for (let j = offset, jj = end - stride; j < jj; j += stride) {
|
|
258
|
+
segments.push([
|
|
259
|
+
coordinates.slice(j, j + 2),
|
|
260
|
+
coordinates.slice(j + stride, j + stride + 2),
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
offset = end;
|
|
264
|
+
}
|
|
265
|
+
return segments;
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @param {import("../geom/MultiPoint.js").default} geometry Geometry.
|
|
270
|
+
* @return {Array<Segment>} Segments
|
|
271
|
+
*/
|
|
272
|
+
MultiPoint(geometry) {
|
|
273
|
+
/** @type {Array<Segment>} */
|
|
274
|
+
const segments = [];
|
|
275
|
+
const coordinates = geometry.getFlatCoordinates();
|
|
276
|
+
const stride = geometry.getStride();
|
|
277
|
+
for (let i = 0, ii = coordinates.length; i < ii; i += stride) {
|
|
278
|
+
segments.push([coordinates.slice(i, i + 2)]);
|
|
279
|
+
}
|
|
280
|
+
return segments;
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
|
285
|
+
* @return {Array<Segment>} Segments
|
|
286
|
+
*/
|
|
287
|
+
MultiPolygon(geometry) {
|
|
288
|
+
/** @type {Array<Segment>} */
|
|
289
|
+
const segments = [];
|
|
290
|
+
const coordinates = geometry.getFlatCoordinates();
|
|
291
|
+
const stride = geometry.getStride();
|
|
292
|
+
const endss = geometry.getEndss();
|
|
293
|
+
let offset = 0;
|
|
294
|
+
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
|
295
|
+
const ends = endss[i];
|
|
296
|
+
for (let j = 0, jj = ends.length; j < jj; ++j) {
|
|
297
|
+
const end = ends[j];
|
|
298
|
+
for (let k = offset, kk = end - stride; k < kk; k += stride) {
|
|
299
|
+
segments.push([
|
|
300
|
+
coordinates.slice(k, k + 2),
|
|
301
|
+
coordinates.slice(k + stride, k + stride + 2),
|
|
302
|
+
]);
|
|
303
|
+
}
|
|
304
|
+
offset = end;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return segments;
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @param {import("../geom/Point.js").default} geometry Geometry.
|
|
312
|
+
* @return {Array<Segment>} Segments
|
|
313
|
+
*/
|
|
314
|
+
Point(geometry) {
|
|
315
|
+
return [[geometry.getFlatCoordinates().slice(0, 2)]];
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @param {import("../geom/Polygon.js").default} geometry Geometry.
|
|
320
|
+
* @return {Array<Segment>} Segments
|
|
321
|
+
*/
|
|
322
|
+
Polygon(geometry) {
|
|
323
|
+
/** @type {Array<Segment>} */
|
|
324
|
+
const segments = [];
|
|
325
|
+
const coordinates = geometry.getFlatCoordinates();
|
|
326
|
+
const stride = geometry.getStride();
|
|
327
|
+
const ends = geometry.getEnds();
|
|
328
|
+
let offset = 0;
|
|
329
|
+
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
|
330
|
+
const end = ends[i];
|
|
331
|
+
for (let j = offset, jj = end - stride; j < jj; j += stride) {
|
|
332
|
+
segments.push([
|
|
333
|
+
coordinates.slice(j, j + 2),
|
|
334
|
+
coordinates.slice(j + stride, j + stride + 2),
|
|
335
|
+
]);
|
|
336
|
+
}
|
|
337
|
+
offset = end;
|
|
338
|
+
}
|
|
339
|
+
return segments;
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
|
|
345
|
+
* @return {import("../Feature.js").default|null} Feature.
|
|
346
|
+
*/
|
|
347
|
+
function getFeatureFromEvent(evt) {
|
|
348
|
+
if (
|
|
349
|
+
/** @type {import("../source/Vector.js").VectorSourceEvent} */ (evt).feature
|
|
350
|
+
) {
|
|
351
|
+
return /** @type {import("../source/Vector.js").VectorSourceEvent} */ (evt)
|
|
352
|
+
.feature;
|
|
353
|
+
}
|
|
354
|
+
if (
|
|
355
|
+
/** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */ (
|
|
356
|
+
evt
|
|
357
|
+
).element
|
|
358
|
+
) {
|
|
359
|
+
return /** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */ (
|
|
360
|
+
evt
|
|
361
|
+
).element;
|
|
362
|
+
}
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const tempSegment = [];
|
|
367
|
+
/** @type {Array<import('../extent.js').Extent>} */
|
|
368
|
+
const tempExtents = [];
|
|
369
|
+
/** @type {Array<SegmentData>} */
|
|
370
|
+
const tempSegmentData = [];
|
|
371
|
+
|
|
372
|
+
/***
|
|
373
|
+
* @template Return
|
|
374
|
+
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
|
|
375
|
+
* import("../Observable").OnSignature<import("../ObjectEventType").Types|
|
|
376
|
+
* 'change:active', import("../Object").ObjectEvent, Return> &
|
|
377
|
+
* import("../Observable").OnSignature<'snap'|'unsnap', SnapEvent, Return> &
|
|
378
|
+
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
|
|
379
|
+
* 'change:active'|'snap'|'unsnap', Return>} SnapOnSignature
|
|
380
|
+
*/
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* @classdesc
|
|
384
|
+
* Handles snapping of vector features while modifying or drawing them. The
|
|
385
|
+
* features can come from a {@link module:ol/source/Vector~VectorSource} or {@link module:ol/Collection~Collection}
|
|
386
|
+
* Any interaction object that allows the user to interact
|
|
387
|
+
* with the features using the mouse can benefit from the snapping, as long
|
|
388
|
+
* as it is added before.
|
|
389
|
+
*
|
|
390
|
+
* The snap interaction modifies map browser event `coordinate` and `pixel`
|
|
391
|
+
* properties to force the snap to occur to any interaction that uses them.
|
|
392
|
+
*
|
|
393
|
+
* Example:
|
|
394
|
+
*
|
|
395
|
+
* import Snap from 'ol/interaction/Snap.js';
|
|
396
|
+
*
|
|
397
|
+
* const snap = new Snap({
|
|
398
|
+
* source: source
|
|
399
|
+
* });
|
|
400
|
+
*
|
|
401
|
+
* map.addInteraction(snap);
|
|
402
|
+
*
|
|
403
|
+
* @fires SnapEvent
|
|
404
|
+
* @api
|
|
405
|
+
*/
|
|
406
|
+
class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
|
|
407
|
+
/**
|
|
408
|
+
* @param {Options} [options] Options.
|
|
409
|
+
*/
|
|
410
|
+
constructor(options) {
|
|
411
|
+
options = options ? options : {};
|
|
412
|
+
|
|
413
|
+
const pointerOptions = /** @type {import("./Pointer.js").Options} */ (
|
|
414
|
+
options
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
if (!pointerOptions.handleDownEvent) {
|
|
418
|
+
pointerOptions.handleDownEvent = _functions_js__WEBPACK_IMPORTED_MODULE_3__.TRUE;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (!pointerOptions.stopDown) {
|
|
422
|
+
pointerOptions.stopDown = _functions_js__WEBPACK_IMPORTED_MODULE_3__.FALSE;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
super(pointerOptions);
|
|
426
|
+
|
|
427
|
+
/***
|
|
428
|
+
* @type {SnapOnSignature<import("../events").EventsKey>}
|
|
429
|
+
*/
|
|
430
|
+
this.on;
|
|
431
|
+
|
|
432
|
+
/***
|
|
433
|
+
* @type {SnapOnSignature<import("../events").EventsKey>}
|
|
434
|
+
*/
|
|
435
|
+
this.once;
|
|
436
|
+
|
|
437
|
+
/***
|
|
438
|
+
* @type {SnapOnSignature<void>}
|
|
439
|
+
*/
|
|
440
|
+
this.un;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* @type {import("../source/Vector.js").default|null}
|
|
444
|
+
* @private
|
|
445
|
+
*/
|
|
446
|
+
this.source_ = options.source ? options.source : null;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @private
|
|
450
|
+
* @type {boolean}
|
|
451
|
+
*/
|
|
452
|
+
this.vertex_ = options.vertex !== undefined ? options.vertex : true;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* @private
|
|
456
|
+
* @type {boolean}
|
|
457
|
+
*/
|
|
458
|
+
this.edge_ = options.edge !== undefined ? options.edge : true;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @private
|
|
462
|
+
* @type {boolean}
|
|
463
|
+
*/
|
|
464
|
+
this.intersection_ =
|
|
465
|
+
options.intersection !== undefined ? options.intersection : false;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* @type {import("../Collection.js").default<import("../Feature.js").default>|null}
|
|
469
|
+
* @private
|
|
470
|
+
*/
|
|
471
|
+
this.features_ = options.features ? options.features : null;
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @type {Array<import("../events.js").EventsKey>}
|
|
475
|
+
* @private
|
|
476
|
+
*/
|
|
477
|
+
this.featuresListenerKeys_ = [];
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* @type {Object<string, import("../events.js").EventsKey>}
|
|
481
|
+
* @private
|
|
482
|
+
*/
|
|
483
|
+
this.featureChangeListenerKeys_ = {};
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Extents are preserved so indexed segment can be quickly removed
|
|
487
|
+
* when its feature geometry changes
|
|
488
|
+
* @type {Object<string, import("../extent.js").Extent>}
|
|
489
|
+
* @private
|
|
490
|
+
*/
|
|
491
|
+
this.indexedFeaturesExtents_ = {};
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* If a feature geometry changes while a pointer drag|move event occurs, the
|
|
495
|
+
* feature doesn't get updated right away. It will be at the next 'pointerup'
|
|
496
|
+
* event fired.
|
|
497
|
+
* @type {!Object<string, import("../Feature.js").default>}
|
|
498
|
+
* @private
|
|
499
|
+
*/
|
|
500
|
+
this.pendingFeatures_ = {};
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* @type {number}
|
|
504
|
+
* @private
|
|
505
|
+
*/
|
|
506
|
+
this.pixelTolerance_ =
|
|
507
|
+
options.pixelTolerance !== undefined ? options.pixelTolerance : 10;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Segment RTree for each layer
|
|
511
|
+
* @type {import("../structs/RBush.js").default<SegmentData>}
|
|
512
|
+
* @private
|
|
513
|
+
*/
|
|
514
|
+
this.rBush_ = new _structs_RBush_js__WEBPACK_IMPORTED_MODULE_4__["default"]();
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Holds information about the last snapped state.
|
|
518
|
+
* @type {SnappedInfo|null}
|
|
519
|
+
* @private
|
|
520
|
+
*/
|
|
521
|
+
this.snapped_ = null;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* @type {Object<string, Segmenter>}
|
|
525
|
+
* @private
|
|
526
|
+
*/
|
|
527
|
+
this.segmenters_ = Object.assign(
|
|
528
|
+
{},
|
|
529
|
+
GEOMETRY_SEGMENTERS,
|
|
530
|
+
options.segmenters,
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Add a feature to the collection of features that we may snap to.
|
|
536
|
+
* @param {import("../Feature.js").default} feature Feature.
|
|
537
|
+
* @param {boolean} [register] Whether to listen to the feature change or not
|
|
538
|
+
* Defaults to `true`.
|
|
539
|
+
* @api
|
|
540
|
+
*/
|
|
541
|
+
addFeature(feature, register) {
|
|
542
|
+
register = register !== undefined ? register : true;
|
|
543
|
+
const feature_uid = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.getUid)(feature);
|
|
544
|
+
const geometry = feature.getGeometry();
|
|
545
|
+
if (geometry) {
|
|
546
|
+
const segmenter = this.segmenters_[geometry.getType()];
|
|
547
|
+
if (segmenter) {
|
|
548
|
+
this.indexedFeaturesExtents_[feature_uid] =
|
|
549
|
+
geometry.getExtent((0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.createEmpty)());
|
|
550
|
+
const segments = segmenter(
|
|
551
|
+
geometry,
|
|
552
|
+
this.getMap().getView().getProjection(),
|
|
553
|
+
);
|
|
554
|
+
let segmentCount = segments.length;
|
|
555
|
+
for (let i = 0; i < segmentCount; ++i) {
|
|
556
|
+
const segment = segments[i];
|
|
557
|
+
tempExtents[i] = (0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.boundingExtent)(segment);
|
|
558
|
+
tempSegmentData[i] = {
|
|
559
|
+
feature: feature,
|
|
560
|
+
segment: segment,
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
tempExtents.length = segmentCount;
|
|
564
|
+
tempSegmentData.length = segmentCount;
|
|
565
|
+
|
|
566
|
+
if (this.intersection_) {
|
|
567
|
+
for (let j = 0, jj = segments.length; j < jj; ++j) {
|
|
568
|
+
const segment = segments[j];
|
|
569
|
+
if (segment.length === 1) {
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
const extent = tempExtents[j];
|
|
573
|
+
// Calculate intersections with own segments
|
|
574
|
+
for (let k = 0, kk = segments.length; k < kk; ++k) {
|
|
575
|
+
if (j === k || j - 1 === k || j + 1 === k) {
|
|
576
|
+
// Exclude self and neighbours
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
const otherSegment = segments[k];
|
|
580
|
+
if (!(0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.intersects)(extent, tempExtents[k])) {
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
const intersection = (0,_geom_flat_segments_js__WEBPACK_IMPORTED_MODULE_7__.getIntersectionPoint)(segment, otherSegment);
|
|
584
|
+
if (!intersection) {
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
const intersectionSegment = [intersection];
|
|
588
|
+
tempExtents[segmentCount] = (0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.boundingExtent)(intersectionSegment);
|
|
589
|
+
tempSegmentData[segmentCount++] = {
|
|
590
|
+
feature,
|
|
591
|
+
segment: intersectionSegment,
|
|
592
|
+
isIntersection: true,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
// Calculate intersections with existing segments
|
|
596
|
+
const otherSegments = this.rBush_.getInExtent(tempExtents[j]);
|
|
597
|
+
for (const {segment: otherSegment} of otherSegments) {
|
|
598
|
+
if (otherSegment.length === 1) {
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
const intersection = (0,_geom_flat_segments_js__WEBPACK_IMPORTED_MODULE_7__.getIntersectionPoint)(segment, otherSegment);
|
|
602
|
+
if (!intersection) {
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
const intersectionSegment = [intersection];
|
|
606
|
+
tempExtents[segmentCount] = (0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.boundingExtent)(intersectionSegment);
|
|
607
|
+
tempSegmentData[segmentCount++] = {
|
|
608
|
+
feature,
|
|
609
|
+
segment: intersectionSegment,
|
|
610
|
+
isIntersection: true,
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (segmentCount === 1) {
|
|
617
|
+
this.rBush_.insert(tempExtents[0], tempSegmentData[0]);
|
|
618
|
+
} else {
|
|
619
|
+
this.rBush_.load(tempExtents, tempSegmentData);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (register) {
|
|
625
|
+
this.featureChangeListenerKeys_[feature_uid] = (0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
|
|
626
|
+
feature,
|
|
627
|
+
_events_EventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].CHANGE,
|
|
628
|
+
this.handleFeatureChange_,
|
|
629
|
+
this,
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* @return {import("../Collection.js").default<import("../Feature.js").default>|Array<import("../Feature.js").default>} Features.
|
|
636
|
+
* @private
|
|
637
|
+
*/
|
|
638
|
+
getFeatures_() {
|
|
639
|
+
/** @type {import("../Collection.js").default<import("../Feature.js").default>|Array<import("../Feature.js").default>} */
|
|
640
|
+
let features;
|
|
641
|
+
if (this.features_) {
|
|
642
|
+
features = this.features_;
|
|
643
|
+
} else if (this.source_) {
|
|
644
|
+
features = this.source_.getFeatures();
|
|
645
|
+
}
|
|
646
|
+
return features;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Checks if two snap data sets are equal.
|
|
651
|
+
* Compares the segment and the feature.
|
|
652
|
+
*
|
|
653
|
+
* @param {SnappedInfo} data1 The first snap data set.
|
|
654
|
+
* @param {SnappedInfo} data2 The second snap data set.
|
|
655
|
+
* @return {boolean} `true` if the data sets are equal, otherwise `false`.
|
|
656
|
+
* @private
|
|
657
|
+
*/
|
|
658
|
+
areSnapDataEqual_(data1, data2) {
|
|
659
|
+
return data1.segment === data2.segment && data1.feature === data2.feature;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* @param {import("../MapBrowserEvent.js").default} evt Map browser event.
|
|
664
|
+
* @return {boolean} `false` to stop event propagation.
|
|
665
|
+
* @api
|
|
666
|
+
* @override
|
|
667
|
+
*/
|
|
668
|
+
handleEvent(evt) {
|
|
669
|
+
const result = this.snapTo(evt.pixel, evt.coordinate, evt.map);
|
|
670
|
+
|
|
671
|
+
if (result) {
|
|
672
|
+
evt.coordinate = result.vertex.slice(0, 2);
|
|
673
|
+
evt.pixel = result.vertexPixel;
|
|
674
|
+
|
|
675
|
+
// Dispatch UNSNAP event if already snapped
|
|
676
|
+
if (this.snapped_ && !this.areSnapDataEqual_(this.snapped_, result)) {
|
|
677
|
+
this.dispatchEvent(new _events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__.SnapEvent(_events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__.SnapEventType.UNSNAP, this.snapped_));
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
this.snapped_ = {
|
|
681
|
+
vertex: evt.coordinate,
|
|
682
|
+
vertexPixel: evt.pixel,
|
|
683
|
+
feature: result.feature,
|
|
684
|
+
segment: result.segment,
|
|
685
|
+
};
|
|
686
|
+
this.dispatchEvent(new _events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__.SnapEvent(_events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__.SnapEventType.SNAP, this.snapped_));
|
|
687
|
+
} else if (this.snapped_) {
|
|
688
|
+
// Dispatch UNSNAP event if no longer snapped
|
|
689
|
+
this.dispatchEvent(new _events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__.SnapEvent(_events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__.SnapEventType.UNSNAP, this.snapped_));
|
|
690
|
+
this.snapped_ = null;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
return super.handleEvent(evt);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
|
|
698
|
+
* @private
|
|
699
|
+
*/
|
|
700
|
+
handleFeatureAdd_(evt) {
|
|
701
|
+
const feature = getFeatureFromEvent(evt);
|
|
702
|
+
if (feature) {
|
|
703
|
+
this.addFeature(feature);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
|
|
709
|
+
* @private
|
|
710
|
+
*/
|
|
711
|
+
handleFeatureRemove_(evt) {
|
|
712
|
+
const feature = getFeatureFromEvent(evt);
|
|
713
|
+
if (feature) {
|
|
714
|
+
this.removeFeature(feature);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* @param {import("../events/Event.js").default} evt Event.
|
|
720
|
+
* @private
|
|
721
|
+
*/
|
|
722
|
+
handleFeatureChange_(evt) {
|
|
723
|
+
const feature = /** @type {import("../Feature.js").default} */ (evt.target);
|
|
724
|
+
if (this.handlingDownUpSequence) {
|
|
725
|
+
const uid = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.getUid)(feature);
|
|
726
|
+
if (!(uid in this.pendingFeatures_)) {
|
|
727
|
+
this.pendingFeatures_[uid] = feature;
|
|
728
|
+
}
|
|
729
|
+
} else {
|
|
730
|
+
this.updateFeature_(feature);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Handle pointer up events.
|
|
736
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
737
|
+
* @return {boolean} If the event was consumed.
|
|
738
|
+
* @override
|
|
739
|
+
*/
|
|
740
|
+
handleUpEvent(evt) {
|
|
741
|
+
const featuresToUpdate = Object.values(this.pendingFeatures_);
|
|
742
|
+
if (featuresToUpdate.length) {
|
|
743
|
+
for (const feature of featuresToUpdate) {
|
|
744
|
+
this.updateFeature_(feature);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Remove a feature from the collection of features that we may snap to.
|
|
752
|
+
* @param {import("../Feature.js").default} feature Feature
|
|
753
|
+
* @param {boolean} [unlisten] Whether to unlisten to the feature change
|
|
754
|
+
* or not. Defaults to `true`.
|
|
755
|
+
* @api
|
|
756
|
+
*/
|
|
757
|
+
removeFeature(feature, unlisten) {
|
|
758
|
+
const unregister = unlisten !== undefined ? unlisten : true;
|
|
759
|
+
const feature_uid = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.getUid)(feature);
|
|
760
|
+
const extent = this.indexedFeaturesExtents_[feature_uid];
|
|
761
|
+
if (extent) {
|
|
762
|
+
const rBush = this.rBush_;
|
|
763
|
+
const nodesToRemove = [];
|
|
764
|
+
rBush.forEachInExtent(extent, function (node) {
|
|
765
|
+
if (feature === node.feature) {
|
|
766
|
+
nodesToRemove.push(node);
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
for (let i = nodesToRemove.length - 1; i >= 0; --i) {
|
|
770
|
+
rBush.remove(nodesToRemove[i]);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
if (unregister) {
|
|
775
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_8__.unlistenByKey)(this.featureChangeListenerKeys_[feature_uid]);
|
|
776
|
+
delete this.featureChangeListenerKeys_[feature_uid];
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Remove the interaction from its current map and attach it to the new map.
|
|
782
|
+
* Subclasses may set up event handlers to get notified about changes to
|
|
783
|
+
* the map here.
|
|
784
|
+
* @param {import("../Map.js").default} map Map.
|
|
785
|
+
* @override
|
|
786
|
+
*/
|
|
787
|
+
setMap(map) {
|
|
788
|
+
const currentMap = this.getMap();
|
|
789
|
+
const keys = this.featuresListenerKeys_;
|
|
790
|
+
let features = this.getFeatures_();
|
|
791
|
+
if (!Array.isArray(features)) {
|
|
792
|
+
features = features.getArray();
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (currentMap) {
|
|
796
|
+
keys.forEach(_events_js__WEBPACK_IMPORTED_MODULE_8__.unlistenByKey);
|
|
797
|
+
keys.length = 0;
|
|
798
|
+
this.rBush_.clear();
|
|
799
|
+
Object.values(this.featureChangeListenerKeys_).forEach(_events_js__WEBPACK_IMPORTED_MODULE_8__.unlistenByKey);
|
|
800
|
+
this.featureChangeListenerKeys_ = {};
|
|
801
|
+
}
|
|
802
|
+
super.setMap(map);
|
|
803
|
+
|
|
804
|
+
if (map) {
|
|
805
|
+
if (this.features_) {
|
|
806
|
+
keys.push(
|
|
807
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
|
|
808
|
+
this.features_,
|
|
809
|
+
_CollectionEventType_js__WEBPACK_IMPORTED_MODULE_11__["default"].ADD,
|
|
810
|
+
this.handleFeatureAdd_,
|
|
811
|
+
this,
|
|
812
|
+
),
|
|
813
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
|
|
814
|
+
this.features_,
|
|
815
|
+
_CollectionEventType_js__WEBPACK_IMPORTED_MODULE_11__["default"].REMOVE,
|
|
816
|
+
this.handleFeatureRemove_,
|
|
817
|
+
this,
|
|
818
|
+
),
|
|
819
|
+
);
|
|
820
|
+
} else if (this.source_) {
|
|
821
|
+
keys.push(
|
|
822
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
|
|
823
|
+
this.source_,
|
|
824
|
+
_source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_12__["default"].ADDFEATURE,
|
|
825
|
+
this.handleFeatureAdd_,
|
|
826
|
+
this,
|
|
827
|
+
),
|
|
828
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
|
|
829
|
+
this.source_,
|
|
830
|
+
_source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_12__["default"].REMOVEFEATURE,
|
|
831
|
+
this.handleFeatureRemove_,
|
|
832
|
+
this,
|
|
833
|
+
),
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
for (const feature of features) {
|
|
837
|
+
this.addFeature(feature);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* @param {import("../pixel.js").Pixel} pixel Pixel
|
|
844
|
+
* @param {import("../coordinate.js").Coordinate} pixelCoordinate Coordinate
|
|
845
|
+
* @param {import("../Map.js").default} map Map.
|
|
846
|
+
* @return {SnappedInfo|null} Snap result
|
|
847
|
+
*/
|
|
848
|
+
snapTo(pixel, pixelCoordinate, map) {
|
|
849
|
+
const projection = map.getView().getProjection();
|
|
850
|
+
const projectedCoordinate = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(pixelCoordinate, projection);
|
|
851
|
+
|
|
852
|
+
const box = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserExtent)(
|
|
853
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.buffer)(
|
|
854
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.boundingExtent)([projectedCoordinate]),
|
|
855
|
+
map.getView().getResolution() * this.pixelTolerance_,
|
|
856
|
+
),
|
|
857
|
+
projection,
|
|
858
|
+
);
|
|
859
|
+
|
|
860
|
+
const segments = this.rBush_.getInExtent(box);
|
|
861
|
+
const segmentsLength = segments.length;
|
|
862
|
+
if (segmentsLength === 0) {
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
let closestVertex;
|
|
867
|
+
let minSquaredDistance = Infinity;
|
|
868
|
+
let closestFeature;
|
|
869
|
+
let closestSegment = null;
|
|
870
|
+
let isIntersection;
|
|
871
|
+
|
|
872
|
+
const squaredPixelTolerance = this.pixelTolerance_ * this.pixelTolerance_;
|
|
873
|
+
const getResult = () => {
|
|
874
|
+
if (closestVertex) {
|
|
875
|
+
const vertexPixel = map.getPixelFromCoordinate(closestVertex);
|
|
876
|
+
const squaredPixelDistance = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.squaredDistance)(pixel, vertexPixel);
|
|
877
|
+
if (
|
|
878
|
+
squaredPixelDistance <= squaredPixelTolerance &&
|
|
879
|
+
((isIntersection && this.intersection_) ||
|
|
880
|
+
(!isIntersection && (this.vertex_ || this.edge_)))
|
|
881
|
+
) {
|
|
882
|
+
return {
|
|
883
|
+
vertex: closestVertex,
|
|
884
|
+
vertexPixel: [
|
|
885
|
+
Math.round(vertexPixel[0]),
|
|
886
|
+
Math.round(vertexPixel[1]),
|
|
887
|
+
],
|
|
888
|
+
feature: closestFeature,
|
|
889
|
+
segment: closestSegment,
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
return null;
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
if (this.vertex_ || this.intersection_) {
|
|
897
|
+
for (let i = 0; i < segmentsLength; ++i) {
|
|
898
|
+
const segmentData = segments[i];
|
|
899
|
+
if (segmentData.feature.getGeometry().getType() !== 'Circle') {
|
|
900
|
+
for (const vertex of segmentData.segment) {
|
|
901
|
+
const tempVertexCoord = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(vertex, projection);
|
|
902
|
+
const delta = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.squaredDistance)(projectedCoordinate, tempVertexCoord);
|
|
903
|
+
if (delta < minSquaredDistance) {
|
|
904
|
+
closestVertex = vertex;
|
|
905
|
+
minSquaredDistance = delta;
|
|
906
|
+
closestFeature = segmentData.feature;
|
|
907
|
+
isIntersection = segmentData.isIntersection;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
const result = getResult();
|
|
913
|
+
if (result) {
|
|
914
|
+
return result;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (this.edge_) {
|
|
919
|
+
for (let i = 0; i < segmentsLength; ++i) {
|
|
920
|
+
let vertex = null;
|
|
921
|
+
const segmentData = segments[i];
|
|
922
|
+
if (segmentData.feature.getGeometry().getType() === 'Circle') {
|
|
923
|
+
let circleGeometry = segmentData.feature.getGeometry();
|
|
924
|
+
const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
925
|
+
if (userProjection) {
|
|
926
|
+
circleGeometry = circleGeometry
|
|
927
|
+
.clone()
|
|
928
|
+
.transform(userProjection, projection);
|
|
929
|
+
}
|
|
930
|
+
vertex = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.closestOnCircle)(
|
|
931
|
+
projectedCoordinate,
|
|
932
|
+
/** @type {import("../geom/Circle.js").default} */ (circleGeometry),
|
|
933
|
+
);
|
|
934
|
+
} else {
|
|
935
|
+
const [segmentStart, segmentEnd] = segmentData.segment;
|
|
936
|
+
// points have only one coordinate
|
|
937
|
+
if (segmentEnd) {
|
|
938
|
+
tempSegment[0] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentStart, projection);
|
|
939
|
+
tempSegment[1] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentEnd, projection);
|
|
940
|
+
vertex = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.closestOnSegment)(projectedCoordinate, tempSegment);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (vertex) {
|
|
944
|
+
const delta = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.squaredDistance)(projectedCoordinate, vertex);
|
|
945
|
+
if (delta < minSquaredDistance) {
|
|
946
|
+
closestVertex = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserCoordinate)(vertex, projection);
|
|
947
|
+
closestSegment =
|
|
948
|
+
segmentData.feature.getGeometry().getType() === 'Circle'
|
|
949
|
+
? null
|
|
950
|
+
: segmentData.segment;
|
|
951
|
+
minSquaredDistance = delta;
|
|
952
|
+
closestFeature = segmentData.feature;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
const result = getResult();
|
|
958
|
+
if (result) {
|
|
959
|
+
return result;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
return null;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* @param {import("../Feature.js").default} feature Feature
|
|
968
|
+
* @private
|
|
969
|
+
*/
|
|
970
|
+
updateFeature_(feature) {
|
|
971
|
+
this.removeFeature(feature, false);
|
|
972
|
+
this.addFeature(feature, false);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Snap);
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
/***/ })
|
|
980
|
+
|
|
981
|
+
}])
|
|
982
|
+
//# sourceMappingURL=vendors-node_modules_ol_interaction_Snap_js.js.map
|