@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.
Files changed (105) hide show
  1. package/node_modules_vaadin_map_node_modules_ol_control_MousePosition_js.js +6 -6
  2. package/node_modules_vaadin_map_node_modules_ol_control_MousePosition_js.js.map +1 -1
  3. package/node_modules_vaadin_map_node_modules_ol_control_ZoomToExtent_js.js +10 -1
  4. package/node_modules_vaadin_map_node_modules_ol_control_ZoomToExtent_js.js.map +1 -1
  5. package/node_modules_vaadin_map_node_modules_ol_events_SnapEvent_js.js +5 -0
  6. package/node_modules_vaadin_map_node_modules_ol_events_SnapEvent_js.js.map +1 -1
  7. package/node_modules_vaadin_map_node_modules_ol_featureloader_js.js +9 -8
  8. package/node_modules_vaadin_map_node_modules_ol_featureloader_js.js.map +1 -1
  9. package/node_modules_vaadin_map_node_modules_ol_geom_GeometryCollection_js.js +1 -1
  10. package/node_modules_vaadin_map_node_modules_ol_geom_GeometryCollection_js.js.map +1 -1
  11. package/node_modules_vaadin_map_node_modules_ol_geom_flat_clip_js.js +172 -0
  12. package/node_modules_vaadin_map_node_modules_ol_geom_flat_clip_js.js.map +1 -0
  13. package/node_modules_vaadin_map_node_modules_ol_geom_flat_length_js-_95bd5.js +58 -0
  14. package/node_modules_vaadin_map_node_modules_ol_geom_flat_length_js-_95bd5.js.map +1 -0
  15. 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
  16. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-304640.js.map +1 -0
  17. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-7a9288.js +383 -0
  18. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js-node_modules_vaadin_map_node_-7a9288.js.map +1 -0
  19. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js.js +243 -0
  20. package/node_modules_vaadin_map_node_modules_ol_geom_flat_lineoffset_js.js.map +1 -0
  21. package/node_modules_vaadin_map_node_modules_ol_geom_flat_textpath_js.js +18 -5
  22. package/node_modules_vaadin_map_node_modules_ol_geom_flat_textpath_js.js.map +1 -1
  23. package/node_modules_vaadin_map_node_modules_ol_interaction_DragAndDrop_js.js +8 -8
  24. package/node_modules_vaadin_map_node_modules_ol_interaction_DragAndDrop_js.js.map +1 -1
  25. 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
  26. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js.js.map +1 -0
  27. package/node_modules_vaadin_map_node_modules_ol_render_canvas_LineStringBuilder_js.js +17 -7
  28. package/node_modules_vaadin_map_node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -1
  29. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc10.js +18 -15
  30. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc10.js.map +1 -1
  31. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc11.js +18 -15
  32. package/node_modules_vaadin_map_node_modules_ol_render_canvas_ZIndexContext_js-_abc11.js.map +1 -1
  33. package/node_modules_vaadin_map_node_modules_ol_renderer_Layer_js.js +21 -1
  34. package/node_modules_vaadin_map_node_modules_ol_renderer_Layer_js.js.map +1 -1
  35. package/node_modules_vaadin_map_node_modules_ol_source_Source_js.js +34 -3
  36. package/node_modules_vaadin_map_node_modules_ol_source_Source_js.js.map +1 -1
  37. package/package.json +135 -135
  38. package/vaadin-bundle.json +1824 -1812
  39. package/vaadin.js +2725 -1726
  40. package/vaadin.js.map +1 -1
  41. package/vendors-node_modules_vaadin_map_node_modules_ol_Feature_js.js +30 -16
  42. package/vendors-node_modules_vaadin_map_node_modules_ol_Feature_js.js.map +1 -1
  43. package/vendors-node_modules_vaadin_map_node_modules_ol_Overlay_js.js +6 -6
  44. package/vendors-node_modules_vaadin_map_node_modules_ol_Overlay_js.js.map +1 -1
  45. package/vendors-node_modules_vaadin_map_node_modules_ol_control_FullScreen_js.js +7 -7
  46. package/vendors-node_modules_vaadin_map_node_modules_ol_control_FullScreen_js.js.map +1 -1
  47. package/vendors-node_modules_vaadin_map_node_modules_ol_control_OverviewMap_js.js +1 -1
  48. package/vendors-node_modules_vaadin_map_node_modules_ol_control_OverviewMap_js.js.map +1 -1
  49. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ScaleLine_js.js +6 -6
  50. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ScaleLine_js.js.map +1 -1
  51. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ZoomSlider_js.js +1 -1
  52. package/vendors-node_modules_vaadin_map_node_modules_ol_control_ZoomSlider_js.js.map +1 -1
  53. package/vendors-node_modules_vaadin_map_node_modules_ol_control_js.js +34 -25
  54. package/vendors-node_modules_vaadin_map_node_modules_ol_control_js.js.map +1 -1
  55. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Draw_js.js +146 -943
  56. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Draw_js.js.map +1 -1
  57. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Extent_js.js +111 -34
  58. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Extent_js.js.map +1 -1
  59. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Link_js.js +3 -3
  60. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Link_js.js.map +1 -1
  61. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Modify_js.js +1055 -219
  62. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Modify_js.js.map +1 -1
  63. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js +129 -57
  64. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Select_js.js.map +1 -1
  65. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js +74 -80
  66. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js.map +1 -1
  67. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Translate_js.js +11 -11
  68. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_Translate_js.js.map +1 -1
  69. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_js.js +54 -54
  70. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_js.js.map +1 -1
  71. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js.js +801 -0
  72. package/vendors-node_modules_vaadin_map_node_modules_ol_interaction_tracing_js.js.map +1 -0
  73. package/vendors-node_modules_vaadin_map_node_modules_ol_render_Feature_js.js +36 -20
  74. package/vendors-node_modules_vaadin_map_node_modules_ol_render_Feature_js.js.map +1 -1
  75. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_BuilderGroup_js.js +17 -279
  76. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -1
  77. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Builder_js.js +16 -7
  78. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Builder_js.js.map +1 -1
  79. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_ExecutorGroup_js.js +53 -17
  80. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -1
  81. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Executor_js.js +336 -38
  82. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Executor_js.js.map +1 -1
  83. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Immediate_js.js +75 -42
  84. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_Immediate_js.js.map +1 -1
  85. 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
  86. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
  87. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_TextBuilder_js.js +210 -16
  88. package/vendors-node_modules_vaadin_map_node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -1
  89. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_Layer_js.js +88 -32
  90. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_Layer_js.js.map +1 -1
  91. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_VectorLayer_js.js +62 -22
  92. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -1
  93. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_vector_js.js +2 -2
  94. package/vendors-node_modules_vaadin_map_node_modules_ol_renderer_vector_js.js.map +1 -1
  95. package/vendors-node_modules_vaadin_map_node_modules_ol_source_Vector_js.js +135 -81
  96. package/vendors-node_modules_vaadin_map_node_modules_ol_source_Vector_js.js.map +1 -1
  97. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c0.js.map +0 -1
  98. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c1.js +0 -144
  99. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-_279c1.js.map +0 -1
  100. package/node_modules_vaadin_map_node_modules_ol_render_VectorContext_js-node_modules_vaadin_map_node_-a1378d.js.map +0 -1
  101. package/node_modules_vaadin_map_node_modules_ol_render_canvas_PolygonBuilder_js.js.map +0 -1
  102. package/node_modules_vaadin_map_node_modules_ol_style_js.js +0 -48
  103. package/node_modules_vaadin_map_node_modules_ol_style_js.js.map +0 -1
  104. package/vendors-node_modules_vaadin_map_node_modules_ol_geom_js-node_modules_vaadin_map_node_modules_-f0f4bb.js +0 -769
  105. package/vendors-node_modules_vaadin_map_node_modules_ol_geom_js-node_modules_vaadin_map_node_modules_-f0f4bb.js.map +0 -1
@@ -27,6 +27,11 @@ const SnapEventType = {
27
27
  * @api
28
28
  */
29
29
  SNAP: 'snap',
30
+ /**
31
+ * Triggered if no longer snapped
32
+ * @event SnapEvent#unsnap
33
+ * @api
34
+ */
30
35
  UNSNAP: 'unsnap',
31
36
  };
32
37
 
@@ -85,17 +90,18 @@ __webpack_require__.r(__webpack_exports__);
85
90
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
86
91
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
87
92
  /* harmony export */ });
88
- /* harmony import */ var _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../CollectionEventType.js */ "./node_modules/@vaadin/map/node_modules/ol/CollectionEventType.js");
89
- /* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/@vaadin/map/node_modules/ol/coordinate.js");
93
+ /* harmony import */ var _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../CollectionEventType.js */ "./node_modules/@vaadin/map/node_modules/ol/CollectionEventType.js");
94
+ /* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/@vaadin/map/node_modules/ol/coordinate.js");
95
+ /* harmony import */ var _events_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../events.js */ "./node_modules/@vaadin/map/node_modules/ol/events.js");
90
96
  /* harmony import */ var _events_EventType_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../events/EventType.js */ "./node_modules/@vaadin/map/node_modules/ol/events/EventType.js");
91
97
  /* harmony import */ var _events_SnapEvent_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../events/SnapEvent.js */ "./node_modules/@vaadin/map/node_modules/ol/events/SnapEvent.js");
92
- /* harmony import */ var _events_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../events.js */ "./node_modules/@vaadin/map/node_modules/ol/events.js");
93
98
  /* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../extent.js */ "./node_modules/@vaadin/map/node_modules/ol/extent.js");
94
99
  /* harmony import */ var _functions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../functions.js */ "./node_modules/@vaadin/map/node_modules/ol/functions.js");
95
100
  /* harmony import */ var _geom_Polygon_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geom/Polygon.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/Polygon.js");
96
101
  /* harmony import */ var _geom_flat_segments_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../geom/flat/segments.js */ "./node_modules/@vaadin/map/node_modules/ol/geom/flat/segments.js");
102
+ /* harmony import */ var _obj_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../obj.js */ "./node_modules/@vaadin/map/node_modules/ol/obj.js");
97
103
  /* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../proj.js */ "./node_modules/@vaadin/map/node_modules/ol/proj.js");
98
- /* harmony import */ var _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../source/VectorEventType.js */ "./node_modules/@vaadin/map/node_modules/ol/source/VectorEventType.js");
104
+ /* harmony import */ var _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../source/VectorEventType.js */ "./node_modules/@vaadin/map/node_modules/ol/source/VectorEventType.js");
99
105
  /* harmony import */ var _structs_RBush_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../structs/RBush.js */ "./node_modules/@vaadin/map/node_modules/ol/structs/RBush.js");
100
106
  /* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util.js */ "./node_modules/@vaadin/map/node_modules/ol/util.js");
101
107
  /* harmony import */ var _Pointer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Pointer.js */ "./node_modules/@vaadin/map/node_modules/ol/interaction/Pointer.js");
@@ -117,6 +123,7 @@ __webpack_require__.r(__webpack_exports__);
117
123
 
118
124
 
119
125
 
126
+
120
127
  /**
121
128
  * @typedef {Array<import("../coordinate.js").Coordinate>} Segment
122
129
  * An array of two coordinates representing a line segment, or an array of one
@@ -126,8 +133,8 @@ __webpack_require__.r(__webpack_exports__);
126
133
  /**
127
134
  * @typedef {Object} SegmentData
128
135
  * @property {import("../Feature.js").default} feature Feature.
136
+ * @property {import("../Feature.js").default} [intersectionFeature] Feature which intersects.
129
137
  * @property {Segment} segment Segment.
130
- * @property {boolean} [isIntersection] Is intersection.
131
138
  */
132
139
 
133
140
  /**
@@ -215,7 +222,7 @@ const GEOMETRY_SEGMENTERS = {
215
222
  const segments = [];
216
223
  const geometries = geometry.getGeometriesArray();
217
224
  for (let i = 0; i < geometries.length; ++i) {
218
- const segmenter = GEOMETRY_SEGMENTERS[geometries[i].getType()];
225
+ const segmenter = this[geometries[i].getType()];
219
226
  if (segmenter) {
220
227
  segments.push(segmenter(geometries[i], projection));
221
228
  }
@@ -371,11 +378,11 @@ const tempSegmentData = [];
371
378
 
372
379
  /***
373
380
  * @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|
381
+ * @typedef {import("../Observable.js").OnSignature<import("../Observable.js").EventTypes, import("../events/Event.js").default, Return> &
382
+ * import("../Observable.js").OnSignature<import("../ObjectEventType.js").Types|
383
+ * 'change:active', import("../Object.js").ObjectEvent, Return> &
384
+ * import("../Observable.js").OnSignature<'snap'|'unsnap', SnapEvent, Return> &
385
+ * import("../Observable.js").CombinedOnSignature<import("../Observable.js").EventTypes|import("../ObjectEventType.js").Types|
379
386
  * 'change:active'|'snap'|'unsnap', Return>} SnapOnSignature
380
387
  */
381
388
 
@@ -410,27 +417,18 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
410
417
  constructor(options) {
411
418
  options = options ? options : {};
412
419
 
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);
420
+ super({
421
+ handleDownEvent: _functions_js__WEBPACK_IMPORTED_MODULE_3__.TRUE,
422
+ stopDown: _functions_js__WEBPACK_IMPORTED_MODULE_3__.FALSE,
423
+ });
426
424
 
427
425
  /***
428
- * @type {SnapOnSignature<import("../events").EventsKey>}
426
+ * @type {SnapOnSignature<import("../events.js").EventsKey>}
429
427
  */
430
428
  this.on;
431
429
 
432
430
  /***
433
- * @type {SnapOnSignature<import("../events").EventsKey>}
431
+ * @type {SnapOnSignature<import("../events.js").EventsKey>}
434
432
  */
435
433
  this.once;
436
434
 
@@ -547,7 +545,8 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
547
545
  if (segmenter) {
548
546
  this.indexedFeaturesExtents_[feature_uid] =
549
547
  geometry.getExtent((0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.createEmpty)());
550
- const segments = segmenter(
548
+ const segments = segmenter.call(
549
+ this.segmenters_,
551
550
  geometry,
552
551
  this.getMap().getView().getProjection(),
553
552
  );
@@ -560,8 +559,6 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
560
559
  segment: segment,
561
560
  };
562
561
  }
563
- tempExtents.length = segmentCount;
564
- tempSegmentData.length = segmentCount;
565
562
 
566
563
  if (this.intersection_) {
567
564
  for (let j = 0, jj = segments.length; j < jj; ++j) {
@@ -570,14 +567,14 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
570
567
  continue;
571
568
  }
572
569
  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
- }
570
+ // Calculate intersections with own segments excluding self and
571
+ // neighbors
572
+ for (let k = 0, kk = j - 1; k < kk; ++k) {
579
573
  const otherSegment = segments[k];
580
- if (!(0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.intersects)(extent, tempExtents[k])) {
574
+ if (
575
+ otherSegment.length === 1 ||
576
+ !(0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.intersects)(extent, tempExtents[k])
577
+ ) {
581
578
  continue;
582
579
  }
583
580
  const intersection = (0,_geom_flat_segments_js__WEBPACK_IMPORTED_MODULE_7__.getIntersectionPoint)(segment, otherSegment);
@@ -588,13 +585,14 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
588
585
  tempExtents[segmentCount] = (0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.boundingExtent)(intersectionSegment);
589
586
  tempSegmentData[segmentCount++] = {
590
587
  feature,
588
+ intersectionFeature: feature,
591
589
  segment: intersectionSegment,
592
- isIntersection: true,
593
590
  };
594
591
  }
595
592
  // Calculate intersections with existing segments
596
593
  const otherSegments = this.rBush_.getInExtent(tempExtents[j]);
597
- for (const {segment: otherSegment} of otherSegments) {
594
+ for (let k = 0, kk = otherSegments.length; k < kk; ++k) {
595
+ const otherSegment = otherSegments[k].segment;
598
596
  if (otherSegment.length === 1) {
599
597
  continue;
600
598
  }
@@ -606,8 +604,8 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
606
604
  tempExtents[segmentCount] = (0,_extent_js__WEBPACK_IMPORTED_MODULE_6__.boundingExtent)(intersectionSegment);
607
605
  tempSegmentData[segmentCount++] = {
608
606
  feature,
607
+ intersectionFeature: otherSegments[k].feature,
609
608
  segment: intersectionSegment,
610
- isIntersection: true,
611
609
  };
612
610
  }
613
611
  }
@@ -616,12 +614,17 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
616
614
  if (segmentCount === 1) {
617
615
  this.rBush_.insert(tempExtents[0], tempSegmentData[0]);
618
616
  } else {
617
+ tempExtents.length = segmentCount;
618
+ tempSegmentData.length = segmentCount;
619
619
  this.rBush_.load(tempExtents, tempSegmentData);
620
620
  }
621
621
  }
622
622
  }
623
623
 
624
624
  if (register) {
625
+ if (this.featureChangeListenerKeys_[feature_uid]) {
626
+ (0,_events_js__WEBPACK_IMPORTED_MODULE_8__.unlistenByKey)(this.featureChangeListenerKeys_[feature_uid]);
627
+ }
625
628
  this.featureChangeListenerKeys_[feature_uid] = (0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
626
629
  feature,
627
630
  _events_EventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].CHANGE,
@@ -712,6 +715,7 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
712
715
  const feature = getFeatureFromEvent(evt);
713
716
  if (feature) {
714
717
  this.removeFeature(feature);
718
+ delete this.pendingFeatures_[(0,_util_js__WEBPACK_IMPORTED_MODULE_5__.getUid)(feature)];
715
719
  }
716
720
  }
717
721
 
@@ -722,10 +726,7 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
722
726
  handleFeatureChange_(evt) {
723
727
  const feature = /** @type {import("../Feature.js").default} */ (evt.target);
724
728
  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
+ this.pendingFeatures_[(0,_util_js__WEBPACK_IMPORTED_MODULE_5__.getUid)(feature)] = feature;
729
730
  } else {
730
731
  this.updateFeature_(feature);
731
732
  }
@@ -743,6 +744,7 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
743
744
  for (const feature of featuresToUpdate) {
744
745
  this.updateFeature_(feature);
745
746
  }
747
+ (0,_obj_js__WEBPACK_IMPORTED_MODULE_11__.clear)(this.pendingFeatures_);
746
748
  }
747
749
  return false;
748
750
  }
@@ -760,15 +762,11 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
760
762
  const extent = this.indexedFeaturesExtents_[feature_uid];
761
763
  if (extent) {
762
764
  const rBush = this.rBush_;
763
- const nodesToRemove = [];
764
- rBush.forEachInExtent(extent, function (node) {
765
- if (feature === node.feature) {
766
- nodesToRemove.push(node);
765
+ rBush.getInExtent(extent).forEach((node) => {
766
+ if (feature === node.feature || feature === node.intersectionFeature) {
767
+ rBush.remove(node);
767
768
  }
768
769
  });
769
- for (let i = nodesToRemove.length - 1; i >= 0; --i) {
770
- rBush.remove(nodesToRemove[i]);
771
- }
772
770
  }
773
771
 
774
772
  if (unregister) {
@@ -806,13 +804,13 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
806
804
  keys.push(
807
805
  (0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
808
806
  this.features_,
809
- _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_11__["default"].ADD,
807
+ _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_12__["default"].ADD,
810
808
  this.handleFeatureAdd_,
811
809
  this,
812
810
  ),
813
811
  (0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
814
812
  this.features_,
815
- _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_11__["default"].REMOVE,
813
+ _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_12__["default"].REMOVE,
816
814
  this.handleFeatureRemove_,
817
815
  this,
818
816
  ),
@@ -821,13 +819,13 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
821
819
  keys.push(
822
820
  (0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
823
821
  this.source_,
824
- _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_12__["default"].ADDFEATURE,
822
+ _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_13__["default"].ADDFEATURE,
825
823
  this.handleFeatureAdd_,
826
824
  this,
827
825
  ),
828
826
  (0,_events_js__WEBPACK_IMPORTED_MODULE_8__.listen)(
829
827
  this.source_,
830
- _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_12__["default"].REMOVEFEATURE,
828
+ _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_13__["default"].REMOVEFEATURE,
831
829
  this.handleFeatureRemove_,
832
830
  this,
833
831
  ),
@@ -867,30 +865,23 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
867
865
  let minSquaredDistance = Infinity;
868
866
  let closestFeature;
869
867
  let closestSegment = null;
870
- let isIntersection;
871
868
 
872
869
  const squaredPixelTolerance = this.pixelTolerance_ * this.pixelTolerance_;
873
870
  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
- }
871
+ if (!closestVertex) {
872
+ return null;
892
873
  }
893
- return null;
874
+ const vertexPixel = map.getPixelFromCoordinate(closestVertex);
875
+ const squaredPixelDistance = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_14__.squaredDistance)(pixel, vertexPixel);
876
+ if (squaredPixelDistance > squaredPixelTolerance) {
877
+ return null;
878
+ }
879
+ return {
880
+ vertex: closestVertex,
881
+ vertexPixel: [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])],
882
+ feature: closestFeature,
883
+ segment: closestSegment,
884
+ };
894
885
  };
895
886
 
896
887
  if (this.vertex_ || this.intersection_) {
@@ -899,12 +890,15 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
899
890
  if (segmentData.feature.getGeometry().getType() !== 'Circle') {
900
891
  for (const vertex of segmentData.segment) {
901
892
  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) {
893
+ const delta = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_14__.squaredDistance)(projectedCoordinate, tempVertexCoord);
894
+ if (
895
+ delta < minSquaredDistance &&
896
+ ((this.intersection_ && segmentData.intersectionFeature) ||
897
+ (this.vertex_ && !segmentData.intersectionFeature))
898
+ ) {
904
899
  closestVertex = vertex;
905
900
  minSquaredDistance = delta;
906
901
  closestFeature = segmentData.feature;
907
- isIntersection = segmentData.isIntersection;
908
902
  }
909
903
  }
910
904
  }
@@ -927,7 +921,7 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
927
921
  .clone()
928
922
  .transform(userProjection, projection);
929
923
  }
930
- vertex = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.closestOnCircle)(
924
+ vertex = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_14__.closestOnCircle)(
931
925
  projectedCoordinate,
932
926
  /** @type {import("../geom/Circle.js").default} */ (circleGeometry),
933
927
  );
@@ -937,11 +931,11 @@ class Snap extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
937
931
  if (segmentEnd) {
938
932
  tempSegment[0] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentStart, projection);
939
933
  tempSegment[1] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentEnd, projection);
940
- vertex = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.closestOnSegment)(projectedCoordinate, tempSegment);
934
+ vertex = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_14__.closestOnSegment)(projectedCoordinate, tempSegment);
941
935
  }
942
936
  }
943
937
  if (vertex) {
944
- const delta = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_13__.squaredDistance)(projectedCoordinate, vertex);
938
+ const delta = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_14__.squaredDistance)(projectedCoordinate, vertex);
945
939
  if (delta < minSquaredDistance) {
946
940
  closestVertex = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserCoordinate)(vertex, projection);
947
941
  closestSegment =
@@ -1 +1 @@
1
- {"version":3,"file":"vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js","mappings":"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AAgB;AAC/B;AACA;AACA;AACA;AACA;AACA,sCAAsC,QAAQ;AAC9C;AACA,8CAA8C,QAAQ;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA,YAAY,6HAA6H;AACzI,YAAY,sCAAsC;AAClD;AACA;AACA;AACA,eAAe,iDAAiD;AAChE;AACA,sBAAsB,iDAAiD;AACvE;AACA;AACA;AACA,eAAe,6EAA6E;AAC5F;AACA;AACA;AACA,sBAAsB,6EAA6E;AACnG;AACA;AACA;AACA;AACA;;AAEA;AACA,WAAW,sCAAsC;AACjD;AACA,WAAW,oBAAoB;AAC/B;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,iDAAiD;AACjD;;AAEA;AACA;AACA;AACA,6BAA6B,4CAA4C,IAAI;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,mDAAkB;AACrC;AACA,aAAa,SAAS;AACtB;AACA;AACA;;AAEA,sCAAsC,gCAAgC;AACtE;AACA;;AAEA;AACA,uCAAuC,+CAAI;AAC3C;;AAEA;AACA,gCAAgC,gDAAK;AACrC;;AAEA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA,sBAAsB,yDAAK;;AAE3B;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iCAAiC;AAC9C,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA,wBAAwB,gDAAM;AAC9B;AACA;AACA;AACA;AACA;AACA,6BAA6B,uDAAW;AACxC;AACA;AACA;AACA;AACA;AACA,wBAAwB,kBAAkB;AAC1C;AACA,2BAA2B,0DAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,QAAQ;AACxD;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,QAAQ;AAC1D;AACA;AACA;AACA;AACA;AACA,mBAAmB,sDAAgB;AACnC;AACA;AACA,mCAAmC,4EAAoB;AACvD;AACA;AACA;AACA;AACA,0CAA0C,0DAAc;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,uBAAuB;AAC/C;AACA;AACA;AACA,mCAAmC,4EAAoB;AACvD;AACA;AACA;AACA;AACA,0CAA0C,0DAAc;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA,qDAAqD,kDAAM;AAC3D;AACA,QAAQ,mEAAgB;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,4GAA4G;AAC1H;AACA;AACA;AACA,eAAe,4GAA4G;AAC3H;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,aAAa;AAC1B,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,yCAAyC;AACtD,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,+BAA+B,4DAAS,CAAC,uEAAoB;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,4DAAS,CAAC,qEAAkB;AACzD,MAAM;AACN;AACA,6BAA6B,4DAAS,CAAC,uEAAoB;AAC3D;AACA;;AAEA;AACA;;AAEA;AACA,aAAa,6HAA6H;AAC1I;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,6HAA6H;AAC1I;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,sCAAsC;AACnD;AACA;AACA;AACA,+BAA+B,iCAAiC;AAChE;AACA,kBAAkB,gDAAM;AACxB;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,aAAa,yCAAyC;AACtD,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iCAAiC;AAC9C,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA,wBAAwB,gDAAM;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,6CAA6C,QAAQ;AACrD;AACA;AACA;;AAEA;AACA,MAAM,yDAAa;AACnB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,6BAA6B;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,qDAAa;AAChC;AACA;AACA,6DAA6D,qDAAa;AAC1E;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,oEAAuB;AACnC;AACA;AACA;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,uEAA0B;AACtC;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,8EAA0B;AACtC;AACA;AACA;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,iFAA6B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,6BAA6B;AAC1C,aAAa,uCAAuC;AACpD,aAAa,6BAA6B;AAC1C,cAAc,kBAAkB;AAChC;AACA;AACA;AACA,gCAAgC,4DAAkB;;AAElD,gBAAgB,sDAAY;AAC5B,MAAM,kDAAM;AACZ,QAAQ,0DAAc;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qCAAqC,gEAAe;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sBAAsB,oBAAoB;AAC1C;AACA;AACA;AACA,oCAAoC,4DAAkB;AACtD,0BAA0B,gEAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sBAAsB,oBAAoB;AAC1C;AACA;AACA;AACA;AACA,iCAAiC,2DAAiB;AAClD;AACA;AACA;AACA;AACA;AACA,mBAAmB,gEAAe;AAClC;AACA,uBAAuB,qCAAqC;AAC5D;AACA,UAAU;AACV;AACA;AACA;AACA,6BAA6B,4DAAkB;AAC/C,6BAA6B,4DAAkB;AAC/C,qBAAqB,iEAAgB;AACrC;AACA;AACA;AACA,wBAAwB,gEAAe;AACvC;AACA,4BAA4B,0DAAgB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,aAAa,iCAAiC;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,IAAI,EAAC","sources":["webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/events/SnapEvent.js","webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/interaction/Snap.js"],"sourcesContent":["/**\n * @module ol/events/SnapEvent\n */\nimport Event from './Event.js';\n\n/**\n * @enum {string}\n */\nexport const SnapEventType = {\n /**\n * Triggered upon snapping to vertex or edge\n * @event SnapEvent#snap\n * @api\n */\n SNAP: 'snap',\n UNSNAP: 'unsnap',\n};\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/interaction/Snap~Snap} instances are instances of this\n */\nexport class SnapEvent extends Event {\n /**\n * @param {SnapEventType} type Type.\n * @param {Object} options Options.\n * @param {import(\"../coordinate.js\").Coordinate} options.vertex The snapped vertex.\n * @param {import(\"../coordinate.js\").Coordinate} options.vertexPixel The pixel of the snapped vertex.\n * @param {import(\"../Feature.js\").default} options.feature The feature being snapped.\n * @param {Array<import(\"../coordinate.js\").Coordinate>|null} options.segment Segment, or `null` if snapped to a vertex.\n */\n constructor(type, options) {\n super(type);\n /**\n * The Map coordinate of the snapped point.\n * @type {import(\"../coordinate.js\").Coordinate}\n * @api\n */\n this.vertex = options.vertex;\n /**\n * The Map pixel of the snapped point.\n * @type {Array<number>&Array<number>}\n * @api\n */\n this.vertexPixel = options.vertexPixel;\n /**\n * The feature closest to the snapped point.\n * @type {import(\"../Feature.js\").default<import(\"../geom/Geometry.js\").default>}\n * @api\n */\n this.feature = options.feature;\n /**\n * The segment closest to the snapped point, if snapped to a segment.\n * @type {Array<import(\"../coordinate.js\").Coordinate>|null}\n * @api\n */\n this.segment = options.segment;\n }\n}\n","/**\n * @module ol/interaction/Snap\n */\nimport CollectionEventType from '../CollectionEventType.js';\nimport {\n closestOnCircle,\n closestOnSegment,\n squaredDistance,\n} from '../coordinate.js';\nimport EventType from '../events/EventType.js';\nimport {SnapEvent, SnapEventType} from '../events/SnapEvent.js';\nimport {listen, unlistenByKey} from '../events.js';\nimport {\n boundingExtent,\n buffer,\n createEmpty,\n intersects as intersectsExtent,\n} from '../extent.js';\nimport {FALSE, TRUE} from '../functions.js';\nimport {fromCircle} from '../geom/Polygon.js';\nimport {getIntersectionPoint} from '../geom/flat/segments.js';\nimport {\n fromUserCoordinate,\n getUserProjection,\n toUserCoordinate,\n toUserExtent,\n} from '../proj.js';\nimport VectorEventType from '../source/VectorEventType.js';\nimport RBush from '../structs/RBush.js';\nimport {getUid} from '../util.js';\nimport PointerInteraction from './Pointer.js';\n\n/**\n * @typedef {Array<import(\"../coordinate.js\").Coordinate>} Segment\n * An array of two coordinates representing a line segment, or an array of one\n * coordinate representing a point.\n */\n\n/**\n * @typedef {Object} SegmentData\n * @property {import(\"../Feature.js\").default} feature Feature.\n * @property {Segment} segment Segment.\n * @property {boolean} [isIntersection] Is intersection.\n */\n\n/**\n * @template {import(\"../geom/Geometry.js\").default} [GeometryType=import(\"../geom/Geometry.js\").default]\n * @typedef {(geometry: GeometryType, projection?: import(\"../proj/Projection.js\").default) => Array<Segment>} Segmenter\n * A function taking a {@link module:ol/geom/Geometry~Geometry} as argument and returning an array of {@link Segment}s.\n */\n\n/**\n * Each segmenter specified here will override the default segmenter for the\n * corresponding geometry type. To exclude all geometries of a specific geometry type from being snapped to,\n * set the segmenter to `null`.\n * @typedef {Object} Segmenters\n * @property {Segmenter<import(\"../geom/Point.js\").default>|null} [Point] Point segmenter.\n * @property {Segmenter<import(\"../geom/LineString.js\").default>|null} [LineString] LineString segmenter.\n * @property {Segmenter<import(\"../geom/Polygon.js\").default>|null} [Polygon] Polygon segmenter.\n * @property {Segmenter<import(\"../geom/Circle.js\").default>|null} [Circle] Circle segmenter.\n * @property {Segmenter<import(\"../geom/GeometryCollection.js\").default>|null} [GeometryCollection] GeometryCollection segmenter.\n * @property {Segmenter<import(\"../geom/MultiPoint.js\").default>|null} [MultiPoint] MultiPoint segmenter.\n * @property {Segmenter<import(\"../geom/MultiLineString.js\").default>|null} [MultiLineString] MultiLineString segmenter.\n * @property {Segmenter<import(\"../geom/MultiPolygon.js\").default>|null} [MultiPolygon] MultiPolygon segmenter.\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../Collection.js\").default<import(\"../Feature.js\").default>} [features] Snap to these features. Either this option or source should be provided.\n * @property {import(\"../source/Vector.js\").default} [source] Snap to features from this source. Either this option or features should be provided\n * @property {boolean} [edge=true] Snap to edges.\n * @property {boolean} [vertex=true] Snap to vertices.\n * @property {boolean} [intersection=false] Snap to intersections between segments.\n * @property {number} [pixelTolerance=10] Pixel tolerance for considering the pointer close enough to a segment or\n * vertex for snapping.\n * @property {Segmenters} [segmenters] Custom segmenters by {@link module:ol/geom/Geometry~Type}. By default, the\n * following segmenters are used:\n * - `Point`: A one-dimensional segment (e.g. `[[10, 20]]`) representing the point.\n * - `LineString`: One two-dimensional segment (e.g. `[[10, 20], [30, 40]]`) for each segment of the linestring.\n * - `Polygon`: One two-dimensional segment for each segment of the exterior ring and the interior rings.\n * - `Circle`: One two-dimensional segment for each segment of a regular polygon with 32 points representing the circle circumference.\n * - `GeometryCollection`: All segments of the contained geometries.\n * - `MultiPoint`: One one-dimensional segment for each point.\n * - `MultiLineString`: One two-dimensional segment for each segment of the linestrings.\n * - `MultiPolygon`: One two-dimensional segment for each segment of the polygons.\n */\n\n/**\n * Information about the last snapped state.\n * @typedef {Object} SnappedInfo\n * @property {import(\"../coordinate.js\").Coordinate|null} vertex - The snapped vertex.\n * @property {import(\"../pixel.js\").Pixel|null} vertexPixel - The pixel of the snapped vertex.\n * @property {import(\"../Feature.js\").default|null} feature - The feature being snapped.\n * @property {Segment|null} segment - Segment, or `null` if snapped to a vertex.\n */\n\n/***\n * @type {Object<string, Segmenter>}\n */\nconst GEOMETRY_SEGMENTERS = {\n /**\n * @param {import(\"../geom/Circle.js\").default} geometry Geometry.\n * @param {import(\"../proj/Projection.js\").default} projection Projection.\n * @return {Array<Segment>} Segments\n */\n Circle(geometry, projection) {\n let circleGeometry = geometry;\n const userProjection = getUserProjection();\n if (userProjection) {\n circleGeometry = circleGeometry\n .clone()\n .transform(userProjection, projection);\n }\n const polygon = fromCircle(circleGeometry);\n if (userProjection) {\n polygon.transform(projection, userProjection);\n }\n return GEOMETRY_SEGMENTERS.Polygon(polygon);\n },\n\n /**\n * @param {import(\"../geom/GeometryCollection.js\").default} geometry Geometry.\n * @param {import(\"../proj/Projection.js\").default} projection Projection.\n * @return {Array<Segment>} Segments\n */\n GeometryCollection(geometry, projection) {\n /** @type {Array<Array<Segment>>} */\n const segments = [];\n const geometries = geometry.getGeometriesArray();\n for (let i = 0; i < geometries.length; ++i) {\n const segmenter = GEOMETRY_SEGMENTERS[geometries[i].getType()];\n if (segmenter) {\n segments.push(segmenter(geometries[i], projection));\n }\n }\n return segments.flat();\n },\n\n /**\n * @param {import(\"../geom/LineString.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n LineString(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n for (let i = 0, ii = coordinates.length - stride; i < ii; i += stride) {\n segments.push([\n coordinates.slice(i, i + 2),\n coordinates.slice(i + stride, i + stride + 2),\n ]);\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/MultiLineString.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n MultiLineString(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n const ends = geometry.getEnds();\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n for (let j = offset, jj = end - stride; j < jj; j += stride) {\n segments.push([\n coordinates.slice(j, j + 2),\n coordinates.slice(j + stride, j + stride + 2),\n ]);\n }\n offset = end;\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/MultiPoint.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n MultiPoint(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n for (let i = 0, ii = coordinates.length; i < ii; i += stride) {\n segments.push([coordinates.slice(i, i + 2)]);\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/MultiPolygon.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n MultiPolygon(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n const endss = geometry.getEndss();\n let offset = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n const end = ends[j];\n for (let k = offset, kk = end - stride; k < kk; k += stride) {\n segments.push([\n coordinates.slice(k, k + 2),\n coordinates.slice(k + stride, k + stride + 2),\n ]);\n }\n offset = end;\n }\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/Point.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n Point(geometry) {\n return [[geometry.getFlatCoordinates().slice(0, 2)]];\n },\n\n /**\n * @param {import(\"../geom/Polygon.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n Polygon(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n const ends = geometry.getEnds();\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n for (let j = offset, jj = end - stride; j < jj; j += stride) {\n segments.push([\n coordinates.slice(j, j + 2),\n coordinates.slice(j + stride, j + stride + 2),\n ]);\n }\n offset = end;\n }\n return segments;\n },\n};\n\n/**\n * @param {import(\"../source/Vector.js\").VectorSourceEvent|import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} evt Event.\n * @return {import(\"../Feature.js\").default|null} Feature.\n */\nfunction getFeatureFromEvent(evt) {\n if (\n /** @type {import(\"../source/Vector.js\").VectorSourceEvent} */ (evt).feature\n ) {\n return /** @type {import(\"../source/Vector.js\").VectorSourceEvent} */ (evt)\n .feature;\n }\n if (\n /** @type {import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} */ (\n evt\n ).element\n ) {\n return /** @type {import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} */ (\n evt\n ).element;\n }\n return null;\n}\n\nconst tempSegment = [];\n/** @type {Array<import('../extent.js').Extent>} */\nconst tempExtents = [];\n/** @type {Array<SegmentData>} */\nconst tempSegmentData = [];\n\n/***\n * @template Return\n * @typedef {import(\"../Observable\").OnSignature<import(\"../Observable\").EventTypes, import(\"../events/Event.js\").default, Return> &\n * import(\"../Observable\").OnSignature<import(\"../ObjectEventType\").Types|\n * 'change:active', import(\"../Object\").ObjectEvent, Return> &\n * import(\"../Observable\").OnSignature<'snap'|'unsnap', SnapEvent, Return> &\n * import(\"../Observable\").CombinedOnSignature<import(\"../Observable\").EventTypes|import(\"../ObjectEventType\").Types|\n * 'change:active'|'snap'|'unsnap', Return>} SnapOnSignature\n */\n\n/**\n * @classdesc\n * Handles snapping of vector features while modifying or drawing them. The\n * features can come from a {@link module:ol/source/Vector~VectorSource} or {@link module:ol/Collection~Collection}\n * Any interaction object that allows the user to interact\n * with the features using the mouse can benefit from the snapping, as long\n * as it is added before.\n *\n * The snap interaction modifies map browser event `coordinate` and `pixel`\n * properties to force the snap to occur to any interaction that uses them.\n *\n * Example:\n *\n * import Snap from 'ol/interaction/Snap.js';\n *\n * const snap = new Snap({\n * source: source\n * });\n *\n * map.addInteraction(snap);\n *\n * @fires SnapEvent\n * @api\n */\nclass Snap extends PointerInteraction {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options ? options : {};\n\n const pointerOptions = /** @type {import(\"./Pointer.js\").Options} */ (\n options\n );\n\n if (!pointerOptions.handleDownEvent) {\n pointerOptions.handleDownEvent = TRUE;\n }\n\n if (!pointerOptions.stopDown) {\n pointerOptions.stopDown = FALSE;\n }\n\n super(pointerOptions);\n\n /***\n * @type {SnapOnSignature<import(\"../events\").EventsKey>}\n */\n this.on;\n\n /***\n * @type {SnapOnSignature<import(\"../events\").EventsKey>}\n */\n this.once;\n\n /***\n * @type {SnapOnSignature<void>}\n */\n this.un;\n\n /**\n * @type {import(\"../source/Vector.js\").default|null}\n * @private\n */\n this.source_ = options.source ? options.source : null;\n\n /**\n * @private\n * @type {boolean}\n */\n this.vertex_ = options.vertex !== undefined ? options.vertex : true;\n\n /**\n * @private\n * @type {boolean}\n */\n this.edge_ = options.edge !== undefined ? options.edge : true;\n\n /**\n * @private\n * @type {boolean}\n */\n this.intersection_ =\n options.intersection !== undefined ? options.intersection : false;\n\n /**\n * @type {import(\"../Collection.js\").default<import(\"../Feature.js\").default>|null}\n * @private\n */\n this.features_ = options.features ? options.features : null;\n\n /**\n * @type {Array<import(\"../events.js\").EventsKey>}\n * @private\n */\n this.featuresListenerKeys_ = [];\n\n /**\n * @type {Object<string, import(\"../events.js\").EventsKey>}\n * @private\n */\n this.featureChangeListenerKeys_ = {};\n\n /**\n * Extents are preserved so indexed segment can be quickly removed\n * when its feature geometry changes\n * @type {Object<string, import(\"../extent.js\").Extent>}\n * @private\n */\n this.indexedFeaturesExtents_ = {};\n\n /**\n * If a feature geometry changes while a pointer drag|move event occurs, the\n * feature doesn't get updated right away. It will be at the next 'pointerup'\n * event fired.\n * @type {!Object<string, import(\"../Feature.js\").default>}\n * @private\n */\n this.pendingFeatures_ = {};\n\n /**\n * @type {number}\n * @private\n */\n this.pixelTolerance_ =\n options.pixelTolerance !== undefined ? options.pixelTolerance : 10;\n\n /**\n * Segment RTree for each layer\n * @type {import(\"../structs/RBush.js\").default<SegmentData>}\n * @private\n */\n this.rBush_ = new RBush();\n\n /**\n * Holds information about the last snapped state.\n * @type {SnappedInfo|null}\n * @private\n */\n this.snapped_ = null;\n\n /**\n * @type {Object<string, Segmenter>}\n * @private\n */\n this.segmenters_ = Object.assign(\n {},\n GEOMETRY_SEGMENTERS,\n options.segmenters,\n );\n }\n\n /**\n * Add a feature to the collection of features that we may snap to.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {boolean} [register] Whether to listen to the feature change or not\n * Defaults to `true`.\n * @api\n */\n addFeature(feature, register) {\n register = register !== undefined ? register : true;\n const feature_uid = getUid(feature);\n const geometry = feature.getGeometry();\n if (geometry) {\n const segmenter = this.segmenters_[geometry.getType()];\n if (segmenter) {\n this.indexedFeaturesExtents_[feature_uid] =\n geometry.getExtent(createEmpty());\n const segments = segmenter(\n geometry,\n this.getMap().getView().getProjection(),\n );\n let segmentCount = segments.length;\n for (let i = 0; i < segmentCount; ++i) {\n const segment = segments[i];\n tempExtents[i] = boundingExtent(segment);\n tempSegmentData[i] = {\n feature: feature,\n segment: segment,\n };\n }\n tempExtents.length = segmentCount;\n tempSegmentData.length = segmentCount;\n\n if (this.intersection_) {\n for (let j = 0, jj = segments.length; j < jj; ++j) {\n const segment = segments[j];\n if (segment.length === 1) {\n continue;\n }\n const extent = tempExtents[j];\n // Calculate intersections with own segments\n for (let k = 0, kk = segments.length; k < kk; ++k) {\n if (j === k || j - 1 === k || j + 1 === k) {\n // Exclude self and neighbours\n continue;\n }\n const otherSegment = segments[k];\n if (!intersectsExtent(extent, tempExtents[k])) {\n continue;\n }\n const intersection = getIntersectionPoint(segment, otherSegment);\n if (!intersection) {\n continue;\n }\n const intersectionSegment = [intersection];\n tempExtents[segmentCount] = boundingExtent(intersectionSegment);\n tempSegmentData[segmentCount++] = {\n feature,\n segment: intersectionSegment,\n isIntersection: true,\n };\n }\n // Calculate intersections with existing segments\n const otherSegments = this.rBush_.getInExtent(tempExtents[j]);\n for (const {segment: otherSegment} of otherSegments) {\n if (otherSegment.length === 1) {\n continue;\n }\n const intersection = getIntersectionPoint(segment, otherSegment);\n if (!intersection) {\n continue;\n }\n const intersectionSegment = [intersection];\n tempExtents[segmentCount] = boundingExtent(intersectionSegment);\n tempSegmentData[segmentCount++] = {\n feature,\n segment: intersectionSegment,\n isIntersection: true,\n };\n }\n }\n }\n\n if (segmentCount === 1) {\n this.rBush_.insert(tempExtents[0], tempSegmentData[0]);\n } else {\n this.rBush_.load(tempExtents, tempSegmentData);\n }\n }\n }\n\n if (register) {\n this.featureChangeListenerKeys_[feature_uid] = listen(\n feature,\n EventType.CHANGE,\n this.handleFeatureChange_,\n this,\n );\n }\n }\n\n /**\n * @return {import(\"../Collection.js\").default<import(\"../Feature.js\").default>|Array<import(\"../Feature.js\").default>} Features.\n * @private\n */\n getFeatures_() {\n /** @type {import(\"../Collection.js\").default<import(\"../Feature.js\").default>|Array<import(\"../Feature.js\").default>} */\n let features;\n if (this.features_) {\n features = this.features_;\n } else if (this.source_) {\n features = this.source_.getFeatures();\n }\n return features;\n }\n\n /**\n * Checks if two snap data sets are equal.\n * Compares the segment and the feature.\n *\n * @param {SnappedInfo} data1 The first snap data set.\n * @param {SnappedInfo} data2 The second snap data set.\n * @return {boolean} `true` if the data sets are equal, otherwise `false`.\n * @private\n */\n areSnapDataEqual_(data1, data2) {\n return data1.segment === data2.segment && data1.feature === data2.feature;\n }\n\n /**\n * @param {import(\"../MapBrowserEvent.js\").default} evt Map browser event.\n * @return {boolean} `false` to stop event propagation.\n * @api\n * @override\n */\n handleEvent(evt) {\n const result = this.snapTo(evt.pixel, evt.coordinate, evt.map);\n\n if (result) {\n evt.coordinate = result.vertex.slice(0, 2);\n evt.pixel = result.vertexPixel;\n\n // Dispatch UNSNAP event if already snapped\n if (this.snapped_ && !this.areSnapDataEqual_(this.snapped_, result)) {\n this.dispatchEvent(new SnapEvent(SnapEventType.UNSNAP, this.snapped_));\n }\n\n this.snapped_ = {\n vertex: evt.coordinate,\n vertexPixel: evt.pixel,\n feature: result.feature,\n segment: result.segment,\n };\n this.dispatchEvent(new SnapEvent(SnapEventType.SNAP, this.snapped_));\n } else if (this.snapped_) {\n // Dispatch UNSNAP event if no longer snapped\n this.dispatchEvent(new SnapEvent(SnapEventType.UNSNAP, this.snapped_));\n this.snapped_ = null;\n }\n\n return super.handleEvent(evt);\n }\n\n /**\n * @param {import(\"../source/Vector.js\").VectorSourceEvent|import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} evt Event.\n * @private\n */\n handleFeatureAdd_(evt) {\n const feature = getFeatureFromEvent(evt);\n if (feature) {\n this.addFeature(feature);\n }\n }\n\n /**\n * @param {import(\"../source/Vector.js\").VectorSourceEvent|import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} evt Event.\n * @private\n */\n handleFeatureRemove_(evt) {\n const feature = getFeatureFromEvent(evt);\n if (feature) {\n this.removeFeature(feature);\n }\n }\n\n /**\n * @param {import(\"../events/Event.js\").default} evt Event.\n * @private\n */\n handleFeatureChange_(evt) {\n const feature = /** @type {import(\"../Feature.js\").default} */ (evt.target);\n if (this.handlingDownUpSequence) {\n const uid = getUid(feature);\n if (!(uid in this.pendingFeatures_)) {\n this.pendingFeatures_[uid] = feature;\n }\n } else {\n this.updateFeature_(feature);\n }\n }\n\n /**\n * Handle pointer up events.\n * @param {import(\"../MapBrowserEvent.js\").default} evt Event.\n * @return {boolean} If the event was consumed.\n * @override\n */\n handleUpEvent(evt) {\n const featuresToUpdate = Object.values(this.pendingFeatures_);\n if (featuresToUpdate.length) {\n for (const feature of featuresToUpdate) {\n this.updateFeature_(feature);\n }\n }\n return false;\n }\n\n /**\n * Remove a feature from the collection of features that we may snap to.\n * @param {import(\"../Feature.js\").default} feature Feature\n * @param {boolean} [unlisten] Whether to unlisten to the feature change\n * or not. Defaults to `true`.\n * @api\n */\n removeFeature(feature, unlisten) {\n const unregister = unlisten !== undefined ? unlisten : true;\n const feature_uid = getUid(feature);\n const extent = this.indexedFeaturesExtents_[feature_uid];\n if (extent) {\n const rBush = this.rBush_;\n const nodesToRemove = [];\n rBush.forEachInExtent(extent, function (node) {\n if (feature === node.feature) {\n nodesToRemove.push(node);\n }\n });\n for (let i = nodesToRemove.length - 1; i >= 0; --i) {\n rBush.remove(nodesToRemove[i]);\n }\n }\n\n if (unregister) {\n unlistenByKey(this.featureChangeListenerKeys_[feature_uid]);\n delete this.featureChangeListenerKeys_[feature_uid];\n }\n }\n\n /**\n * Remove the interaction from its current map and attach it to the new map.\n * Subclasses may set up event handlers to get notified about changes to\n * the map here.\n * @param {import(\"../Map.js\").default} map Map.\n * @override\n */\n setMap(map) {\n const currentMap = this.getMap();\n const keys = this.featuresListenerKeys_;\n let features = this.getFeatures_();\n if (!Array.isArray(features)) {\n features = features.getArray();\n }\n\n if (currentMap) {\n keys.forEach(unlistenByKey);\n keys.length = 0;\n this.rBush_.clear();\n Object.values(this.featureChangeListenerKeys_).forEach(unlistenByKey);\n this.featureChangeListenerKeys_ = {};\n }\n super.setMap(map);\n\n if (map) {\n if (this.features_) {\n keys.push(\n listen(\n this.features_,\n CollectionEventType.ADD,\n this.handleFeatureAdd_,\n this,\n ),\n listen(\n this.features_,\n CollectionEventType.REMOVE,\n this.handleFeatureRemove_,\n this,\n ),\n );\n } else if (this.source_) {\n keys.push(\n listen(\n this.source_,\n VectorEventType.ADDFEATURE,\n this.handleFeatureAdd_,\n this,\n ),\n listen(\n this.source_,\n VectorEventType.REMOVEFEATURE,\n this.handleFeatureRemove_,\n this,\n ),\n );\n }\n for (const feature of features) {\n this.addFeature(feature);\n }\n }\n }\n\n /**\n * @param {import(\"../pixel.js\").Pixel} pixel Pixel\n * @param {import(\"../coordinate.js\").Coordinate} pixelCoordinate Coordinate\n * @param {import(\"../Map.js\").default} map Map.\n * @return {SnappedInfo|null} Snap result\n */\n snapTo(pixel, pixelCoordinate, map) {\n const projection = map.getView().getProjection();\n const projectedCoordinate = fromUserCoordinate(pixelCoordinate, projection);\n\n const box = toUserExtent(\n buffer(\n boundingExtent([projectedCoordinate]),\n map.getView().getResolution() * this.pixelTolerance_,\n ),\n projection,\n );\n\n const segments = this.rBush_.getInExtent(box);\n const segmentsLength = segments.length;\n if (segmentsLength === 0) {\n return null;\n }\n\n let closestVertex;\n let minSquaredDistance = Infinity;\n let closestFeature;\n let closestSegment = null;\n let isIntersection;\n\n const squaredPixelTolerance = this.pixelTolerance_ * this.pixelTolerance_;\n const getResult = () => {\n if (closestVertex) {\n const vertexPixel = map.getPixelFromCoordinate(closestVertex);\n const squaredPixelDistance = squaredDistance(pixel, vertexPixel);\n if (\n squaredPixelDistance <= squaredPixelTolerance &&\n ((isIntersection && this.intersection_) ||\n (!isIntersection && (this.vertex_ || this.edge_)))\n ) {\n return {\n vertex: closestVertex,\n vertexPixel: [\n Math.round(vertexPixel[0]),\n Math.round(vertexPixel[1]),\n ],\n feature: closestFeature,\n segment: closestSegment,\n };\n }\n }\n return null;\n };\n\n if (this.vertex_ || this.intersection_) {\n for (let i = 0; i < segmentsLength; ++i) {\n const segmentData = segments[i];\n if (segmentData.feature.getGeometry().getType() !== 'Circle') {\n for (const vertex of segmentData.segment) {\n const tempVertexCoord = fromUserCoordinate(vertex, projection);\n const delta = squaredDistance(projectedCoordinate, tempVertexCoord);\n if (delta < minSquaredDistance) {\n closestVertex = vertex;\n minSquaredDistance = delta;\n closestFeature = segmentData.feature;\n isIntersection = segmentData.isIntersection;\n }\n }\n }\n }\n const result = getResult();\n if (result) {\n return result;\n }\n }\n\n if (this.edge_) {\n for (let i = 0; i < segmentsLength; ++i) {\n let vertex = null;\n const segmentData = segments[i];\n if (segmentData.feature.getGeometry().getType() === 'Circle') {\n let circleGeometry = segmentData.feature.getGeometry();\n const userProjection = getUserProjection();\n if (userProjection) {\n circleGeometry = circleGeometry\n .clone()\n .transform(userProjection, projection);\n }\n vertex = closestOnCircle(\n projectedCoordinate,\n /** @type {import(\"../geom/Circle.js\").default} */ (circleGeometry),\n );\n } else {\n const [segmentStart, segmentEnd] = segmentData.segment;\n // points have only one coordinate\n if (segmentEnd) {\n tempSegment[0] = fromUserCoordinate(segmentStart, projection);\n tempSegment[1] = fromUserCoordinate(segmentEnd, projection);\n vertex = closestOnSegment(projectedCoordinate, tempSegment);\n }\n }\n if (vertex) {\n const delta = squaredDistance(projectedCoordinate, vertex);\n if (delta < minSquaredDistance) {\n closestVertex = toUserCoordinate(vertex, projection);\n closestSegment =\n segmentData.feature.getGeometry().getType() === 'Circle'\n ? null\n : segmentData.segment;\n minSquaredDistance = delta;\n closestFeature = segmentData.feature;\n }\n }\n }\n\n const result = getResult();\n if (result) {\n return result;\n }\n }\n\n return null;\n }\n\n /**\n * @param {import(\"../Feature.js\").default} feature Feature\n * @private\n */\n updateFeature_(feature) {\n this.removeFeature(feature, false);\n this.addFeature(feature, false);\n }\n}\n\nexport default Snap;\n"],"names":[],"sourceRoot":""}
1
+ {"version":3,"file":"vendors-node_modules_vaadin_map_node_modules_ol_interaction_Snap_js.js","mappings":"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Ac,gBAAgB;AAC9B;AACA;AACA,eAAe,gBAAgB;AAC/B;AACA;AACA;AACA;AACA;AACA,sCAAsC,QAAQ;AAC9C;AACA,8CAA8C,QAAQ;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA,YAAY,6HAA6H;AACzI,YAAY,sCAAsC;AAClD;AACA;AACA;AACA,eAAe,iDAAiD;AAChE;AACA,sBAAsB,iDAAiD;AACvE;AACA;AACA;AACA,eAAe,6EAA6E;AAC5F;AACA;AACA;AACA,sBAAsB,6EAA6E;AACnG;AACA;AACA;AACA;AACA;;AAEA;AACA,WAAW,sCAAsC;AACjD;AACA,WAAW,oBAAoB;AAC/B;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,iDAAiD;AACjD;;AAEA;AACA;AACA;AACA,6BAA6B,4CAA4C,IAAI;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,mDAAkB;AACrC;AACA,aAAa,SAAS;AACtB;AACA;AACA;;AAEA;AACA,uBAAuB,+CAAI;AAC3B,gBAAgB,gDAAK;AACrB,KAAK;;AAEL;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA,sBAAsB,yDAAK;;AAE3B;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iCAAiC;AAC9C,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA,wBAAwB,gDAAM;AAC9B;AACA;AACA;AACA;AACA;AACA,6BAA6B,uDAAW;AACxC;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,kBAAkB;AAC1C;AACA,2BAA2B,0DAAc;AACzC;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,QAAQ;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,QAAQ;AAChD;AACA;AACA;AACA,iBAAiB,sDAAgB;AACjC;AACA;AACA;AACA,mCAAmC,4EAAoB;AACvD;AACA;AACA;AACA;AACA,0CAA0C,0DAAc;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD,QAAQ;AAC/D;AACA;AACA;AACA;AACA,mCAAmC,4EAAoB;AACvD;AACA;AACA;AACA;AACA,0CAA0C,0DAAc;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,QAAQ,yDAAa;AACrB;AACA,qDAAqD,kDAAM;AAC3D;AACA,QAAQ,mEAAgB;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,4GAA4G;AAC1H;AACA;AACA;AACA,eAAe,4GAA4G;AAC3H;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,aAAa;AAC1B,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,yCAAyC;AACtD,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,+BAA+B,4DAAS,CAAC,uEAAoB;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,4DAAS,CAAC,qEAAkB;AACzD,MAAM;AACN;AACA,6BAA6B,4DAAS,CAAC,uEAAoB;AAC3D;AACA;;AAEA;AACA;;AAEA;AACA,aAAa,6HAA6H;AAC1I;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,6HAA6H;AAC1I;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gDAAM;AACzC;AACA;;AAEA;AACA,aAAa,sCAAsC;AACnD;AACA;AACA;AACA,+BAA+B,iCAAiC;AAChE;AACA,4BAA4B,gDAAM;AAClC,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,aAAa,yCAAyC;AACtD,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,+CAAK;AACX;AACA;AACA;;AAEA;AACA;AACA,aAAa,iCAAiC;AAC9C,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA,wBAAwB,gDAAM;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA,MAAM,yDAAa;AACnB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,6BAA6B;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,qDAAa;AAChC;AACA;AACA,6DAA6D,qDAAa;AAC1E;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,oEAAuB;AACnC;AACA;AACA;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,uEAA0B;AACtC;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,8EAA0B;AACtC;AACA;AACA;AACA,UAAU,kDAAM;AAChB;AACA,YAAY,iFAA6B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,6BAA6B;AAC1C,aAAa,uCAAuC;AACpD,aAAa,6BAA6B;AAC1C,cAAc,kBAAkB;AAChC;AACA;AACA;AACA,gCAAgC,4DAAkB;;AAElD,gBAAgB,sDAAY;AAC5B,MAAM,kDAAM;AACZ,QAAQ,0DAAc;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gEAAe;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sBAAsB,oBAAoB;AAC1C;AACA;AACA;AACA,oCAAoC,4DAAkB;AACtD,0BAA0B,gEAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sBAAsB,oBAAoB;AAC1C;AACA;AACA;AACA;AACA,iCAAiC,2DAAiB;AAClD;AACA;AACA;AACA;AACA;AACA,mBAAmB,gEAAe;AAClC;AACA,uBAAuB,qCAAqC;AAC5D;AACA,UAAU;AACV;AACA;AACA;AACA,6BAA6B,4DAAkB;AAC/C,6BAA6B,4DAAkB;AAC/C,qBAAqB,iEAAgB;AACrC;AACA;AACA;AACA,wBAAwB,gEAAe;AACvC;AACA,4BAA4B,0DAAgB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,aAAa,iCAAiC;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,IAAI,EAAC","sources":["webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/events/SnapEvent.js","webpack://@vaadin/bundles/./node_modules/@vaadin/map/node_modules/ol/interaction/Snap.js"],"sourcesContent":["/**\n * @module ol/events/SnapEvent\n */\nimport Event from './Event.js';\n\n/**\n * @enum {string}\n */\nexport const SnapEventType = {\n /**\n * Triggered upon snapping to vertex or edge\n * @event SnapEvent#snap\n * @api\n */\n SNAP: 'snap',\n /**\n * Triggered if no longer snapped\n * @event SnapEvent#unsnap\n * @api\n */\n UNSNAP: 'unsnap',\n};\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/interaction/Snap~Snap} instances are instances of this\n */\nexport class SnapEvent extends Event {\n /**\n * @param {SnapEventType} type Type.\n * @param {Object} options Options.\n * @param {import(\"../coordinate.js\").Coordinate} options.vertex The snapped vertex.\n * @param {import(\"../coordinate.js\").Coordinate} options.vertexPixel The pixel of the snapped vertex.\n * @param {import(\"../Feature.js\").default} options.feature The feature being snapped.\n * @param {Array<import(\"../coordinate.js\").Coordinate>|null} options.segment Segment, or `null` if snapped to a vertex.\n */\n constructor(type, options) {\n super(type);\n /**\n * The Map coordinate of the snapped point.\n * @type {import(\"../coordinate.js\").Coordinate}\n * @api\n */\n this.vertex = options.vertex;\n /**\n * The Map pixel of the snapped point.\n * @type {Array<number>&Array<number>}\n * @api\n */\n this.vertexPixel = options.vertexPixel;\n /**\n * The feature closest to the snapped point.\n * @type {import(\"../Feature.js\").default<import(\"../geom/Geometry.js\").default>}\n * @api\n */\n this.feature = options.feature;\n /**\n * The segment closest to the snapped point, if snapped to a segment.\n * @type {Array<import(\"../coordinate.js\").Coordinate>|null}\n * @api\n */\n this.segment = options.segment;\n }\n}\n","/**\n * @module ol/interaction/Snap\n */\nimport CollectionEventType from '../CollectionEventType.js';\nimport {\n closestOnCircle,\n closestOnSegment,\n squaredDistance,\n} from '../coordinate.js';\nimport {listen, unlistenByKey} from '../events.js';\nimport EventType from '../events/EventType.js';\nimport {SnapEvent, SnapEventType} from '../events/SnapEvent.js';\nimport {\n boundingExtent,\n buffer,\n createEmpty,\n intersects as intersectsExtent,\n} from '../extent.js';\nimport {FALSE, TRUE} from '../functions.js';\nimport {fromCircle} from '../geom/Polygon.js';\nimport {getIntersectionPoint} from '../geom/flat/segments.js';\nimport {clear} from '../obj.js';\nimport {\n fromUserCoordinate,\n getUserProjection,\n toUserCoordinate,\n toUserExtent,\n} from '../proj.js';\nimport VectorEventType from '../source/VectorEventType.js';\nimport RBush from '../structs/RBush.js';\nimport {getUid} from '../util.js';\nimport PointerInteraction from './Pointer.js';\n\n/**\n * @typedef {Array<import(\"../coordinate.js\").Coordinate>} Segment\n * An array of two coordinates representing a line segment, or an array of one\n * coordinate representing a point.\n */\n\n/**\n * @typedef {Object} SegmentData\n * @property {import(\"../Feature.js\").default} feature Feature.\n * @property {import(\"../Feature.js\").default} [intersectionFeature] Feature which intersects.\n * @property {Segment} segment Segment.\n */\n\n/**\n * @template {import(\"../geom/Geometry.js\").default} [GeometryType=import(\"../geom/Geometry.js\").default]\n * @typedef {(geometry: GeometryType, projection?: import(\"../proj/Projection.js\").default) => Array<Segment>} Segmenter\n * A function taking a {@link module:ol/geom/Geometry~Geometry} as argument and returning an array of {@link Segment}s.\n */\n\n/**\n * Each segmenter specified here will override the default segmenter for the\n * corresponding geometry type. To exclude all geometries of a specific geometry type from being snapped to,\n * set the segmenter to `null`.\n * @typedef {Object} Segmenters\n * @property {Segmenter<import(\"../geom/Point.js\").default>|null} [Point] Point segmenter.\n * @property {Segmenter<import(\"../geom/LineString.js\").default>|null} [LineString] LineString segmenter.\n * @property {Segmenter<import(\"../geom/Polygon.js\").default>|null} [Polygon] Polygon segmenter.\n * @property {Segmenter<import(\"../geom/Circle.js\").default>|null} [Circle] Circle segmenter.\n * @property {Segmenter<import(\"../geom/GeometryCollection.js\").default>|null} [GeometryCollection] GeometryCollection segmenter.\n * @property {Segmenter<import(\"../geom/MultiPoint.js\").default>|null} [MultiPoint] MultiPoint segmenter.\n * @property {Segmenter<import(\"../geom/MultiLineString.js\").default>|null} [MultiLineString] MultiLineString segmenter.\n * @property {Segmenter<import(\"../geom/MultiPolygon.js\").default>|null} [MultiPolygon] MultiPolygon segmenter.\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../Collection.js\").default<import(\"../Feature.js\").default>} [features] Snap to these features. Either this option or source should be provided.\n * @property {import(\"../source/Vector.js\").default} [source] Snap to features from this source. Either this option or features should be provided\n * @property {boolean} [edge=true] Snap to edges.\n * @property {boolean} [vertex=true] Snap to vertices.\n * @property {boolean} [intersection=false] Snap to intersections between segments.\n * @property {number} [pixelTolerance=10] Pixel tolerance for considering the pointer close enough to a segment or\n * vertex for snapping.\n * @property {Segmenters} [segmenters] Custom segmenters by {@link module:ol/geom/Geometry~Type}. By default, the\n * following segmenters are used:\n * - `Point`: A one-dimensional segment (e.g. `[[10, 20]]`) representing the point.\n * - `LineString`: One two-dimensional segment (e.g. `[[10, 20], [30, 40]]`) for each segment of the linestring.\n * - `Polygon`: One two-dimensional segment for each segment of the exterior ring and the interior rings.\n * - `Circle`: One two-dimensional segment for each segment of a regular polygon with 32 points representing the circle circumference.\n * - `GeometryCollection`: All segments of the contained geometries.\n * - `MultiPoint`: One one-dimensional segment for each point.\n * - `MultiLineString`: One two-dimensional segment for each segment of the linestrings.\n * - `MultiPolygon`: One two-dimensional segment for each segment of the polygons.\n */\n\n/**\n * Information about the last snapped state.\n * @typedef {Object} SnappedInfo\n * @property {import(\"../coordinate.js\").Coordinate|null} vertex - The snapped vertex.\n * @property {import(\"../pixel.js\").Pixel|null} vertexPixel - The pixel of the snapped vertex.\n * @property {import(\"../Feature.js\").default|null} feature - The feature being snapped.\n * @property {Segment|null} segment - Segment, or `null` if snapped to a vertex.\n */\n\n/***\n * @type {Object<string, Segmenter>}\n */\nconst GEOMETRY_SEGMENTERS = {\n /**\n * @param {import(\"../geom/Circle.js\").default} geometry Geometry.\n * @param {import(\"../proj/Projection.js\").default} projection Projection.\n * @return {Array<Segment>} Segments\n */\n Circle(geometry, projection) {\n let circleGeometry = geometry;\n const userProjection = getUserProjection();\n if (userProjection) {\n circleGeometry = circleGeometry\n .clone()\n .transform(userProjection, projection);\n }\n const polygon = fromCircle(circleGeometry);\n if (userProjection) {\n polygon.transform(projection, userProjection);\n }\n return GEOMETRY_SEGMENTERS.Polygon(polygon);\n },\n\n /**\n * @param {import(\"../geom/GeometryCollection.js\").default} geometry Geometry.\n * @param {import(\"../proj/Projection.js\").default} projection Projection.\n * @return {Array<Segment>} Segments\n */\n GeometryCollection(geometry, projection) {\n /** @type {Array<Array<Segment>>} */\n const segments = [];\n const geometries = geometry.getGeometriesArray();\n for (let i = 0; i < geometries.length; ++i) {\n const segmenter = this[geometries[i].getType()];\n if (segmenter) {\n segments.push(segmenter(geometries[i], projection));\n }\n }\n return segments.flat();\n },\n\n /**\n * @param {import(\"../geom/LineString.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n LineString(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n for (let i = 0, ii = coordinates.length - stride; i < ii; i += stride) {\n segments.push([\n coordinates.slice(i, i + 2),\n coordinates.slice(i + stride, i + stride + 2),\n ]);\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/MultiLineString.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n MultiLineString(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n const ends = geometry.getEnds();\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n for (let j = offset, jj = end - stride; j < jj; j += stride) {\n segments.push([\n coordinates.slice(j, j + 2),\n coordinates.slice(j + stride, j + stride + 2),\n ]);\n }\n offset = end;\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/MultiPoint.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n MultiPoint(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n for (let i = 0, ii = coordinates.length; i < ii; i += stride) {\n segments.push([coordinates.slice(i, i + 2)]);\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/MultiPolygon.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n MultiPolygon(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n const endss = geometry.getEndss();\n let offset = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n const end = ends[j];\n for (let k = offset, kk = end - stride; k < kk; k += stride) {\n segments.push([\n coordinates.slice(k, k + 2),\n coordinates.slice(k + stride, k + stride + 2),\n ]);\n }\n offset = end;\n }\n }\n return segments;\n },\n\n /**\n * @param {import(\"../geom/Point.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n Point(geometry) {\n return [[geometry.getFlatCoordinates().slice(0, 2)]];\n },\n\n /**\n * @param {import(\"../geom/Polygon.js\").default} geometry Geometry.\n * @return {Array<Segment>} Segments\n */\n Polygon(geometry) {\n /** @type {Array<Segment>} */\n const segments = [];\n const coordinates = geometry.getFlatCoordinates();\n const stride = geometry.getStride();\n const ends = geometry.getEnds();\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n for (let j = offset, jj = end - stride; j < jj; j += stride) {\n segments.push([\n coordinates.slice(j, j + 2),\n coordinates.slice(j + stride, j + stride + 2),\n ]);\n }\n offset = end;\n }\n return segments;\n },\n};\n\n/**\n * @param {import(\"../source/Vector.js\").VectorSourceEvent|import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} evt Event.\n * @return {import(\"../Feature.js\").default|null} Feature.\n */\nfunction getFeatureFromEvent(evt) {\n if (\n /** @type {import(\"../source/Vector.js\").VectorSourceEvent} */ (evt).feature\n ) {\n return /** @type {import(\"../source/Vector.js\").VectorSourceEvent} */ (evt)\n .feature;\n }\n if (\n /** @type {import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} */ (\n evt\n ).element\n ) {\n return /** @type {import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} */ (\n evt\n ).element;\n }\n return null;\n}\n\nconst tempSegment = [];\n/** @type {Array<import('../extent.js').Extent>} */\nconst tempExtents = [];\n/** @type {Array<SegmentData>} */\nconst tempSegmentData = [];\n\n/***\n * @template Return\n * @typedef {import(\"../Observable.js\").OnSignature<import(\"../Observable.js\").EventTypes, import(\"../events/Event.js\").default, Return> &\n * import(\"../Observable.js\").OnSignature<import(\"../ObjectEventType.js\").Types|\n * 'change:active', import(\"../Object.js\").ObjectEvent, Return> &\n * import(\"../Observable.js\").OnSignature<'snap'|'unsnap', SnapEvent, Return> &\n * import(\"../Observable.js\").CombinedOnSignature<import(\"../Observable.js\").EventTypes|import(\"../ObjectEventType.js\").Types|\n * 'change:active'|'snap'|'unsnap', Return>} SnapOnSignature\n */\n\n/**\n * @classdesc\n * Handles snapping of vector features while modifying or drawing them. The\n * features can come from a {@link module:ol/source/Vector~VectorSource} or {@link module:ol/Collection~Collection}\n * Any interaction object that allows the user to interact\n * with the features using the mouse can benefit from the snapping, as long\n * as it is added before.\n *\n * The snap interaction modifies map browser event `coordinate` and `pixel`\n * properties to force the snap to occur to any interaction that uses them.\n *\n * Example:\n *\n * import Snap from 'ol/interaction/Snap.js';\n *\n * const snap = new Snap({\n * source: source\n * });\n *\n * map.addInteraction(snap);\n *\n * @fires SnapEvent\n * @api\n */\nclass Snap extends PointerInteraction {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options ? options : {};\n\n super({\n handleDownEvent: TRUE,\n stopDown: FALSE,\n });\n\n /***\n * @type {SnapOnSignature<import(\"../events.js\").EventsKey>}\n */\n this.on;\n\n /***\n * @type {SnapOnSignature<import(\"../events.js\").EventsKey>}\n */\n this.once;\n\n /***\n * @type {SnapOnSignature<void>}\n */\n this.un;\n\n /**\n * @type {import(\"../source/Vector.js\").default|null}\n * @private\n */\n this.source_ = options.source ? options.source : null;\n\n /**\n * @private\n * @type {boolean}\n */\n this.vertex_ = options.vertex !== undefined ? options.vertex : true;\n\n /**\n * @private\n * @type {boolean}\n */\n this.edge_ = options.edge !== undefined ? options.edge : true;\n\n /**\n * @private\n * @type {boolean}\n */\n this.intersection_ =\n options.intersection !== undefined ? options.intersection : false;\n\n /**\n * @type {import(\"../Collection.js\").default<import(\"../Feature.js\").default>|null}\n * @private\n */\n this.features_ = options.features ? options.features : null;\n\n /**\n * @type {Array<import(\"../events.js\").EventsKey>}\n * @private\n */\n this.featuresListenerKeys_ = [];\n\n /**\n * @type {Object<string, import(\"../events.js\").EventsKey>}\n * @private\n */\n this.featureChangeListenerKeys_ = {};\n\n /**\n * Extents are preserved so indexed segment can be quickly removed\n * when its feature geometry changes\n * @type {Object<string, import(\"../extent.js\").Extent>}\n * @private\n */\n this.indexedFeaturesExtents_ = {};\n\n /**\n * If a feature geometry changes while a pointer drag|move event occurs, the\n * feature doesn't get updated right away. It will be at the next 'pointerup'\n * event fired.\n * @type {!Object<string, import(\"../Feature.js\").default>}\n * @private\n */\n this.pendingFeatures_ = {};\n\n /**\n * @type {number}\n * @private\n */\n this.pixelTolerance_ =\n options.pixelTolerance !== undefined ? options.pixelTolerance : 10;\n\n /**\n * Segment RTree for each layer\n * @type {import(\"../structs/RBush.js\").default<SegmentData>}\n * @private\n */\n this.rBush_ = new RBush();\n\n /**\n * Holds information about the last snapped state.\n * @type {SnappedInfo|null}\n * @private\n */\n this.snapped_ = null;\n\n /**\n * @type {Object<string, Segmenter>}\n * @private\n */\n this.segmenters_ = Object.assign(\n {},\n GEOMETRY_SEGMENTERS,\n options.segmenters,\n );\n }\n\n /**\n * Add a feature to the collection of features that we may snap to.\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {boolean} [register] Whether to listen to the feature change or not\n * Defaults to `true`.\n * @api\n */\n addFeature(feature, register) {\n register = register !== undefined ? register : true;\n const feature_uid = getUid(feature);\n const geometry = feature.getGeometry();\n if (geometry) {\n const segmenter = this.segmenters_[geometry.getType()];\n if (segmenter) {\n this.indexedFeaturesExtents_[feature_uid] =\n geometry.getExtent(createEmpty());\n const segments = segmenter.call(\n this.segmenters_,\n geometry,\n this.getMap().getView().getProjection(),\n );\n let segmentCount = segments.length;\n for (let i = 0; i < segmentCount; ++i) {\n const segment = segments[i];\n tempExtents[i] = boundingExtent(segment);\n tempSegmentData[i] = {\n feature: feature,\n segment: segment,\n };\n }\n\n if (this.intersection_) {\n for (let j = 0, jj = segments.length; j < jj; ++j) {\n const segment = segments[j];\n if (segment.length === 1) {\n continue;\n }\n const extent = tempExtents[j];\n // Calculate intersections with own segments excluding self and\n // neighbors\n for (let k = 0, kk = j - 1; k < kk; ++k) {\n const otherSegment = segments[k];\n if (\n otherSegment.length === 1 ||\n !intersectsExtent(extent, tempExtents[k])\n ) {\n continue;\n }\n const intersection = getIntersectionPoint(segment, otherSegment);\n if (!intersection) {\n continue;\n }\n const intersectionSegment = [intersection];\n tempExtents[segmentCount] = boundingExtent(intersectionSegment);\n tempSegmentData[segmentCount++] = {\n feature,\n intersectionFeature: feature,\n segment: intersectionSegment,\n };\n }\n // Calculate intersections with existing segments\n const otherSegments = this.rBush_.getInExtent(tempExtents[j]);\n for (let k = 0, kk = otherSegments.length; k < kk; ++k) {\n const otherSegment = otherSegments[k].segment;\n if (otherSegment.length === 1) {\n continue;\n }\n const intersection = getIntersectionPoint(segment, otherSegment);\n if (!intersection) {\n continue;\n }\n const intersectionSegment = [intersection];\n tempExtents[segmentCount] = boundingExtent(intersectionSegment);\n tempSegmentData[segmentCount++] = {\n feature,\n intersectionFeature: otherSegments[k].feature,\n segment: intersectionSegment,\n };\n }\n }\n }\n\n if (segmentCount === 1) {\n this.rBush_.insert(tempExtents[0], tempSegmentData[0]);\n } else {\n tempExtents.length = segmentCount;\n tempSegmentData.length = segmentCount;\n this.rBush_.load(tempExtents, tempSegmentData);\n }\n }\n }\n\n if (register) {\n if (this.featureChangeListenerKeys_[feature_uid]) {\n unlistenByKey(this.featureChangeListenerKeys_[feature_uid]);\n }\n this.featureChangeListenerKeys_[feature_uid] = listen(\n feature,\n EventType.CHANGE,\n this.handleFeatureChange_,\n this,\n );\n }\n }\n\n /**\n * @return {import(\"../Collection.js\").default<import(\"../Feature.js\").default>|Array<import(\"../Feature.js\").default>} Features.\n * @private\n */\n getFeatures_() {\n /** @type {import(\"../Collection.js\").default<import(\"../Feature.js\").default>|Array<import(\"../Feature.js\").default>} */\n let features;\n if (this.features_) {\n features = this.features_;\n } else if (this.source_) {\n features = this.source_.getFeatures();\n }\n return features;\n }\n\n /**\n * Checks if two snap data sets are equal.\n * Compares the segment and the feature.\n *\n * @param {SnappedInfo} data1 The first snap data set.\n * @param {SnappedInfo} data2 The second snap data set.\n * @return {boolean} `true` if the data sets are equal, otherwise `false`.\n * @private\n */\n areSnapDataEqual_(data1, data2) {\n return data1.segment === data2.segment && data1.feature === data2.feature;\n }\n\n /**\n * @param {import(\"../MapBrowserEvent.js\").default} evt Map browser event.\n * @return {boolean} `false` to stop event propagation.\n * @api\n * @override\n */\n handleEvent(evt) {\n const result = this.snapTo(evt.pixel, evt.coordinate, evt.map);\n\n if (result) {\n evt.coordinate = result.vertex.slice(0, 2);\n evt.pixel = result.vertexPixel;\n\n // Dispatch UNSNAP event if already snapped\n if (this.snapped_ && !this.areSnapDataEqual_(this.snapped_, result)) {\n this.dispatchEvent(new SnapEvent(SnapEventType.UNSNAP, this.snapped_));\n }\n\n this.snapped_ = {\n vertex: evt.coordinate,\n vertexPixel: evt.pixel,\n feature: result.feature,\n segment: result.segment,\n };\n this.dispatchEvent(new SnapEvent(SnapEventType.SNAP, this.snapped_));\n } else if (this.snapped_) {\n // Dispatch UNSNAP event if no longer snapped\n this.dispatchEvent(new SnapEvent(SnapEventType.UNSNAP, this.snapped_));\n this.snapped_ = null;\n }\n\n return super.handleEvent(evt);\n }\n\n /**\n * @param {import(\"../source/Vector.js\").VectorSourceEvent|import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} evt Event.\n * @private\n */\n handleFeatureAdd_(evt) {\n const feature = getFeatureFromEvent(evt);\n if (feature) {\n this.addFeature(feature);\n }\n }\n\n /**\n * @param {import(\"../source/Vector.js\").VectorSourceEvent|import(\"../Collection.js\").CollectionEvent<import(\"../Feature.js\").default>} evt Event.\n * @private\n */\n handleFeatureRemove_(evt) {\n const feature = getFeatureFromEvent(evt);\n if (feature) {\n this.removeFeature(feature);\n delete this.pendingFeatures_[getUid(feature)];\n }\n }\n\n /**\n * @param {import(\"../events/Event.js\").default} evt Event.\n * @private\n */\n handleFeatureChange_(evt) {\n const feature = /** @type {import(\"../Feature.js\").default} */ (evt.target);\n if (this.handlingDownUpSequence) {\n this.pendingFeatures_[getUid(feature)] = feature;\n } else {\n this.updateFeature_(feature);\n }\n }\n\n /**\n * Handle pointer up events.\n * @param {import(\"../MapBrowserEvent.js\").default} evt Event.\n * @return {boolean} If the event was consumed.\n * @override\n */\n handleUpEvent(evt) {\n const featuresToUpdate = Object.values(this.pendingFeatures_);\n if (featuresToUpdate.length) {\n for (const feature of featuresToUpdate) {\n this.updateFeature_(feature);\n }\n clear(this.pendingFeatures_);\n }\n return false;\n }\n\n /**\n * Remove a feature from the collection of features that we may snap to.\n * @param {import(\"../Feature.js\").default} feature Feature\n * @param {boolean} [unlisten] Whether to unlisten to the feature change\n * or not. Defaults to `true`.\n * @api\n */\n removeFeature(feature, unlisten) {\n const unregister = unlisten !== undefined ? unlisten : true;\n const feature_uid = getUid(feature);\n const extent = this.indexedFeaturesExtents_[feature_uid];\n if (extent) {\n const rBush = this.rBush_;\n rBush.getInExtent(extent).forEach((node) => {\n if (feature === node.feature || feature === node.intersectionFeature) {\n rBush.remove(node);\n }\n });\n }\n\n if (unregister) {\n unlistenByKey(this.featureChangeListenerKeys_[feature_uid]);\n delete this.featureChangeListenerKeys_[feature_uid];\n }\n }\n\n /**\n * Remove the interaction from its current map and attach it to the new map.\n * Subclasses may set up event handlers to get notified about changes to\n * the map here.\n * @param {import(\"../Map.js\").default} map Map.\n * @override\n */\n setMap(map) {\n const currentMap = this.getMap();\n const keys = this.featuresListenerKeys_;\n let features = this.getFeatures_();\n if (!Array.isArray(features)) {\n features = features.getArray();\n }\n\n if (currentMap) {\n keys.forEach(unlistenByKey);\n keys.length = 0;\n this.rBush_.clear();\n Object.values(this.featureChangeListenerKeys_).forEach(unlistenByKey);\n this.featureChangeListenerKeys_ = {};\n }\n super.setMap(map);\n\n if (map) {\n if (this.features_) {\n keys.push(\n listen(\n this.features_,\n CollectionEventType.ADD,\n this.handleFeatureAdd_,\n this,\n ),\n listen(\n this.features_,\n CollectionEventType.REMOVE,\n this.handleFeatureRemove_,\n this,\n ),\n );\n } else if (this.source_) {\n keys.push(\n listen(\n this.source_,\n VectorEventType.ADDFEATURE,\n this.handleFeatureAdd_,\n this,\n ),\n listen(\n this.source_,\n VectorEventType.REMOVEFEATURE,\n this.handleFeatureRemove_,\n this,\n ),\n );\n }\n for (const feature of features) {\n this.addFeature(feature);\n }\n }\n }\n\n /**\n * @param {import(\"../pixel.js\").Pixel} pixel Pixel\n * @param {import(\"../coordinate.js\").Coordinate} pixelCoordinate Coordinate\n * @param {import(\"../Map.js\").default} map Map.\n * @return {SnappedInfo|null} Snap result\n */\n snapTo(pixel, pixelCoordinate, map) {\n const projection = map.getView().getProjection();\n const projectedCoordinate = fromUserCoordinate(pixelCoordinate, projection);\n\n const box = toUserExtent(\n buffer(\n boundingExtent([projectedCoordinate]),\n map.getView().getResolution() * this.pixelTolerance_,\n ),\n projection,\n );\n\n const segments = this.rBush_.getInExtent(box);\n const segmentsLength = segments.length;\n if (segmentsLength === 0) {\n return null;\n }\n\n let closestVertex;\n let minSquaredDistance = Infinity;\n let closestFeature;\n let closestSegment = null;\n\n const squaredPixelTolerance = this.pixelTolerance_ * this.pixelTolerance_;\n const getResult = () => {\n if (!closestVertex) {\n return null;\n }\n const vertexPixel = map.getPixelFromCoordinate(closestVertex);\n const squaredPixelDistance = squaredDistance(pixel, vertexPixel);\n if (squaredPixelDistance > squaredPixelTolerance) {\n return null;\n }\n return {\n vertex: closestVertex,\n vertexPixel: [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])],\n feature: closestFeature,\n segment: closestSegment,\n };\n };\n\n if (this.vertex_ || this.intersection_) {\n for (let i = 0; i < segmentsLength; ++i) {\n const segmentData = segments[i];\n if (segmentData.feature.getGeometry().getType() !== 'Circle') {\n for (const vertex of segmentData.segment) {\n const tempVertexCoord = fromUserCoordinate(vertex, projection);\n const delta = squaredDistance(projectedCoordinate, tempVertexCoord);\n if (\n delta < minSquaredDistance &&\n ((this.intersection_ && segmentData.intersectionFeature) ||\n (this.vertex_ && !segmentData.intersectionFeature))\n ) {\n closestVertex = vertex;\n minSquaredDistance = delta;\n closestFeature = segmentData.feature;\n }\n }\n }\n }\n const result = getResult();\n if (result) {\n return result;\n }\n }\n\n if (this.edge_) {\n for (let i = 0; i < segmentsLength; ++i) {\n let vertex = null;\n const segmentData = segments[i];\n if (segmentData.feature.getGeometry().getType() === 'Circle') {\n let circleGeometry = segmentData.feature.getGeometry();\n const userProjection = getUserProjection();\n if (userProjection) {\n circleGeometry = circleGeometry\n .clone()\n .transform(userProjection, projection);\n }\n vertex = closestOnCircle(\n projectedCoordinate,\n /** @type {import(\"../geom/Circle.js\").default} */ (circleGeometry),\n );\n } else {\n const [segmentStart, segmentEnd] = segmentData.segment;\n // points have only one coordinate\n if (segmentEnd) {\n tempSegment[0] = fromUserCoordinate(segmentStart, projection);\n tempSegment[1] = fromUserCoordinate(segmentEnd, projection);\n vertex = closestOnSegment(projectedCoordinate, tempSegment);\n }\n }\n if (vertex) {\n const delta = squaredDistance(projectedCoordinate, vertex);\n if (delta < minSquaredDistance) {\n closestVertex = toUserCoordinate(vertex, projection);\n closestSegment =\n segmentData.feature.getGeometry().getType() === 'Circle'\n ? null\n : segmentData.segment;\n minSquaredDistance = delta;\n closestFeature = segmentData.feature;\n }\n }\n }\n\n const result = getResult();\n if (result) {\n return result;\n }\n }\n\n return null;\n }\n\n /**\n * @param {import(\"../Feature.js\").default} feature Feature\n * @private\n */\n updateFeature_(feature) {\n this.removeFeature(feature, false);\n this.addFeature(feature, false);\n }\n}\n\nexport default Snap;\n"],"names":[],"sourceRoot":""}
@@ -60,7 +60,7 @@ const TranslateEventType = {
60
60
  * {@link module:ol/render/Feature~RenderFeature} and a
61
61
  * {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be
62
62
  * translated or `false` otherwise.
63
- * @typedef {function(Feature, import("../layer/Layer.js").default<import("../source/Source").default>):boolean} FilterFunction
63
+ * @typedef {function(Feature, import("../layer/Layer.js").default<import("../source/Source.js").default>):boolean} FilterFunction
64
64
  */
65
65
 
66
66
  /**
@@ -70,7 +70,7 @@ const TranslateEventType = {
70
70
  * boolean to indicate whether that event should be handled.
71
71
  * Default is {@link module:ol/events/condition.always}.
72
72
  * @property {Collection<Feature>} [features] Features contained in this collection will be able to be translated together.
73
- * @property {Array<import("../layer/Layer.js").default>|function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean} [layers] A list of layers from which features should be
73
+ * @property {Array<import("../layer/Layer.js").default>|function(import("../layer/Layer.js").default<import("../source/Source.js").default>): boolean} [layers] A list of layers from which features should be
74
74
  * translated. Alternatively, a filter function can be provided. The
75
75
  * function will be called for each layer in the map and should return
76
76
  * `true` for layers that you want to be translatable. If the option is
@@ -134,11 +134,11 @@ class TranslateEvent extends _events_Event_js__WEBPACK_IMPORTED_MODULE_1__["defa
134
134
 
135
135
  /***
136
136
  * @template Return
137
- * @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
138
- * import("../Observable").OnSignature<import("../ObjectEventType").Types|
139
- * 'change:active', import("../Object").ObjectEvent, Return> &
140
- * import("../Observable").OnSignature<'translateend'|'translatestart'|'translating', TranslateEvent, Return> &
141
- * import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
137
+ * @typedef {import("../Observable.js").OnSignature<import("../Observable.js").EventTypes, import("../events/Event.js").default, Return> &
138
+ * import("../Observable.js").OnSignature<import("../ObjectEventType.js").Types|
139
+ * 'change:active', import("../Object.js").ObjectEvent, Return> &
140
+ * import("../Observable.js").OnSignature<'translateend'|'translatestart'|'translating', TranslateEvent, Return> &
141
+ * import("../Observable.js").CombinedOnSignature<import("../Observable.js").EventTypes|import("../ObjectEventType.js").Types|
142
142
  * 'change:active'|'translateend'|'translatestart'|'translating', Return>} TranslateOnSignature
143
143
  */
144
144
 
@@ -162,12 +162,12 @@ class Translate extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
162
162
  super(/** @type {import("./Pointer.js").Options} */ (options));
163
163
 
164
164
  /***
165
- * @type {TranslateOnSignature<import("../events").EventsKey>}
165
+ * @type {TranslateOnSignature<import("../events.js").EventsKey>}
166
166
  */
167
167
  this.on;
168
168
 
169
169
  /***
170
- * @type {TranslateOnSignature<import("../events").EventsKey>}
170
+ * @type {TranslateOnSignature<import("../events.js").EventsKey>}
171
171
  */
172
172
  this.once;
173
173
 
@@ -196,7 +196,7 @@ class Translate extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
196
196
  */
197
197
  this.features_ = options.features !== undefined ? options.features : null;
198
198
 
199
- /** @type {function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean} */
199
+ /** @type {function(import("../layer/Layer.js").default<import("../source/Source.js").default>): boolean} */
200
200
  let layerFilter;
201
201
  if (options.layers && !this.features_) {
202
202
  if (typeof options.layers === 'function') {
@@ -213,7 +213,7 @@ class Translate extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
213
213
 
214
214
  /**
215
215
  * @private
216
- * @type {function(import("../layer/Layer.js").default<import("../source/Source").default>): boolean}
216
+ * @type {function(import("../layer/Layer.js").default<import("../source/Source.js").default>): boolean}
217
217
  */
218
218
  this.layerFilter_ = layerFilter;
219
219