@vaadin/bundles 25.0.0-alpha3 → 25.0.0-alpha5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules_ol_ImageCanvas_js.js +76 -83
- package/node_modules_ol_ImageCanvas_js.js.map +1 -1
- package/node_modules_ol_TileRange_js.js +128 -110
- package/node_modules_ol_TileRange_js.js.map +1 -1
- package/node_modules_ol_Tile_js.js +279 -0
- package/node_modules_ol_Tile_js.js.map +1 -0
- package/node_modules_ol_VectorRenderTile_js.js +428 -143
- package/node_modules_ol_VectorRenderTile_js.js.map +1 -1
- package/node_modules_ol_VectorTile_js.js +405 -119
- package/node_modules_ol_VectorTile_js.js.map +1 -1
- package/node_modules_ol_control_MousePosition_js.js +327 -0
- package/node_modules_ol_control_MousePosition_js.js.map +1 -0
- package/node_modules_ol_control_ZoomToExtent_js.js +118 -0
- package/node_modules_ol_control_ZoomToExtent_js.js.map +1 -0
- package/node_modules_ol_events_SnapEvent_js.js +79 -0
- package/node_modules_ol_events_SnapEvent_js.js.map +1 -0
- package/node_modules_ol_featureloader_js.js +205 -0
- package/node_modules_ol_featureloader_js.js.map +1 -0
- package/node_modules_ol_geom_Circle_js.js +300 -0
- package/node_modules_ol_geom_Circle_js.js.map +1 -0
- package/node_modules_ol_geom_GeometryCollection_js.js +369 -0
- package/node_modules_ol_geom_GeometryCollection_js.js.map +1 -0
- package/node_modules_ol_geom_MultiPoint_js.js +228 -0
- package/node_modules_ol_geom_MultiPoint_js.js.map +1 -0
- package/node_modules_ol_geom_flat_center_js.js +47 -0
- package/node_modules_ol_geom_flat_center_js.js.map +1 -0
- package/node_modules_ol_geom_flat_geodesic_js.js +123 -88
- package/node_modules_ol_geom_flat_geodesic_js.js.map +1 -1
- package/node_modules_ol_geom_flat_interpolate_js.js +230 -0
- package/node_modules_ol_geom_flat_interpolate_js.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a0.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a0.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a1.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a1.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a2.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a2.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a3.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a3.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a4.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a4.js.map +1 -0
- package/node_modules_ol_geom_flat_linechunk_js.js +76 -0
- package/node_modules_ol_geom_flat_linechunk_js.js.map +1 -0
- package/node_modules_ol_geom_flat_straightchunk_js.js +68 -0
- package/node_modules_ol_geom_flat_straightchunk_js.js.map +1 -0
- package/node_modules_ol_geom_flat_textpath_js.js +178 -0
- package/node_modules_ol_geom_flat_textpath_js.js.map +1 -0
- package/node_modules_ol_interaction_DblClickDragZoom_js.js +285 -0
- package/node_modules_ol_interaction_DblClickDragZoom_js.js.map +1 -0
- package/node_modules_ol_interaction_DragAndDrop_js.js +351 -0
- package/node_modules_ol_interaction_DragAndDrop_js.js.map +1 -0
- package/node_modules_ol_interaction_DragRotateAndZoom_js.js +159 -0
- package/node_modules_ol_interaction_DragRotateAndZoom_js.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49290.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49290.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49291.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49291.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49292.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49292.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49293.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49293.js.map +1 -0
- package/node_modules_ol_loadingstrategy_js.js +95 -0
- package/node_modules_ol_loadingstrategy_js.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-_3ad60.js +144 -0
- package/node_modules_ol_render_VectorContext_js-_3ad60.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-_3ad61.js +144 -0
- package/node_modules_ol_render_VectorContext_js-_3ad61.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js +372 -0
- package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js.map +1 -0
- package/node_modules_ol_render_canvas_ImageBuilder_js.js +318 -0
- package/node_modules_ol_render_canvas_ImageBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_Instruction_js.js +66 -0
- package/node_modules_ol_render_canvas_Instruction_js.js.map +1 -0
- package/node_modules_ol_render_canvas_LineStringBuilder_js.js +187 -0
- package/node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_PolygonBuilder_js.js +276 -0
- package/node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js +156 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js.map +1 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js +156 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js.map +1 -0
- package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js +301 -0
- package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js.map +1 -0
- package/node_modules_ol_renderer_Layer_js.js +219 -0
- package/node_modules_ol_renderer_Layer_js.js.map +1 -0
- package/node_modules_ol_source_Source_js.js +256 -0
- package/node_modules_ol_source_Source_js.js.map +1 -0
- package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js +318 -0
- package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js.map +1 -0
- package/node_modules_ol_source_VectorEventType_js.js +80 -0
- package/node_modules_ol_source_VectorEventType_js.js.map +1 -0
- package/node_modules_ol_structs_RBush_js.js +242 -0
- package/node_modules_ol_structs_RBush_js.js.map +1 -0
- package/node_modules_ol_style_js.js +2 -1
- package/node_modules_ol_style_js.js.map +1 -1
- package/node_modules_rbush_rbush_min_js.js +16 -0
- package/node_modules_rbush_rbush_min_js.js.map +1 -0
- package/package.json +142 -146
- package/vaadin-bundle.json +2447 -2352
- package/vaadin.js +52246 -63791
- package/vaadin.js.map +1 -1
- package/vendors-node_modules_dompurify_dist_purify_es_mjs.js +1364 -0
- package/vendors-node_modules_dompurify_dist_purify_es_mjs.js.map +1 -0
- package/vendors-node_modules_dompurify_dist_purify_js.js +26 -21
- package/vendors-node_modules_dompurify_dist_purify_js.js.map +1 -1
- package/vendors-node_modules_marked_lib_marked_esm_js.js +2205 -0
- package/vendors-node_modules_marked_lib_marked_esm_js.js.map +1 -0
- package/vendors-node_modules_marked_lib_marked_umd_js.js +2164 -2556
- package/vendors-node_modules_marked_lib_marked_umd_js.js.map +1 -1
- package/vendors-node_modules_ol_Feature_js.js +360 -0
- package/vendors-node_modules_ol_Feature_js.js.map +1 -0
- package/vendors-node_modules_ol_Geolocation_js.js +352 -293
- package/vendors-node_modules_ol_Geolocation_js.js.map +1 -1
- package/vendors-node_modules_ol_ImageTile_js.js +494 -0
- package/vendors-node_modules_ol_ImageTile_js.js.map +1 -0
- package/vendors-node_modules_ol_Overlay_js.js +606 -0
- package/vendors-node_modules_ol_Overlay_js.js.map +1 -0
- package/vendors-node_modules_ol_control_FullScreen_js.js +417 -0
- package/vendors-node_modules_ol_control_FullScreen_js.js.map +1 -0
- package/vendors-node_modules_ol_control_OverviewMap_js.js +711 -0
- package/vendors-node_modules_ol_control_OverviewMap_js.js.map +1 -0
- package/vendors-node_modules_ol_control_ScaleLine_js.js +509 -0
- package/vendors-node_modules_ol_control_ScaleLine_js.js.map +1 -0
- package/vendors-node_modules_ol_control_ZoomSlider_js.js +418 -0
- package/vendors-node_modules_ol_control_ZoomSlider_js.js.map +1 -0
- package/vendors-node_modules_ol_control_js.js +490 -0
- package/vendors-node_modules_ol_control_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_LineString_js.js +574 -0
- package/vendors-node_modules_ol_geom_LineString_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_MultiLineString_js.js +405 -0
- package/vendors-node_modules_ol_geom_MultiLineString_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_MultiPolygon_js.js +773 -0
- package/vendors-node_modules_ol_geom_MultiPolygon_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js +769 -0
- package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js.map +1 -0
- package/vendors-node_modules_ol_index_js.js +526 -675
- package/vendors-node_modules_ol_index_js.js.map +1 -1
- package/vendors-node_modules_ol_interaction_Draw_js.js +2777 -0
- package/vendors-node_modules_ol_interaction_Draw_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Extent_js.js +586 -0
- package/vendors-node_modules_ol_interaction_Extent_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Link_js.js +489 -0
- package/vendors-node_modules_ol_interaction_Link_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Modify_js.js +1841 -0
- package/vendors-node_modules_ol_interaction_Modify_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Select_js.js +623 -0
- package/vendors-node_modules_ol_interaction_Select_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Snap_js.js +982 -0
- package/vendors-node_modules_ol_interaction_Snap_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Translate_js.js +466 -0
- package/vendors-node_modules_ol_interaction_Translate_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_js.js +872 -0
- package/vendors-node_modules_ol_interaction_js.js.map +1 -0
- package/vendors-node_modules_ol_layer_Graticule_js.js +1374 -989
- package/vendors-node_modules_ol_layer_Graticule_js.js.map +1 -1
- package/vendors-node_modules_ol_render_Feature_js.js +546 -0
- package/vendors-node_modules_ol_render_Feature_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js +897 -0
- package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Builder_js.js +907 -0
- package/vendors-node_modules_ol_render_canvas_Builder_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js +539 -0
- package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Executor_js.js +1715 -0
- package/vendors-node_modules_ol_render_canvas_Executor_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Immediate_js.js +1208 -0
- package/vendors-node_modules_ol_render_canvas_Immediate_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js +825 -0
- package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_canvas_Layer_js.js +654 -0
- package/vendors-node_modules_ol_renderer_canvas_Layer_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js +1044 -0
- package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_vector_js.js +460 -0
- package/vendors-node_modules_ol_renderer_vector_js.js.map +1 -0
- package/vendors-node_modules_ol_source_Vector_js.js +2091 -0
- package/vendors-node_modules_ol_source_Vector_js.js.map +1 -0
- package/node_modules_ol_ImageTile_js.js +0 -177
- package/node_modules_ol_ImageTile_js.js.map +0 -1
- package/node_modules_ol_render_js.js +0 -131
- package/node_modules_ol_render_js.js.map +0 -1
- package/node_modules_ol_structs_LRUCache_js.js +0 -275
- package/node_modules_ol_structs_LRUCache_js.js.map +0 -1
- package/node_modules_ol_tilecoord_js.js +0 -115
- package/node_modules_ol_tilecoord_js.js.map +0 -1
- package/vendors-node_modules_ol_TileCache_js.js +0 -461
- package/vendors-node_modules_ol_TileCache_js.js.map +0 -1
- package/vendors-node_modules_ol_Tile_js.js +0 -330
- package/vendors-node_modules_ol_Tile_js.js.map +0 -1
- package/vendors-node_modules_ol_style_Text_js.js +0 -509
- package/vendors-node_modules_ol_style_Text_js.js.map +0 -1
- package/vendors-node_modules_rbush_index_js.js +0 -531
- package/vendors-node_modules_rbush_index_js.js.map +0 -1
|
@@ -0,0 +1,1841 @@
|
|
|
1
|
+
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_ol_interaction_Modify_js"],{
|
|
2
|
+
|
|
3
|
+
/***/ "./node_modules/ol/interaction/Modify.js":
|
|
4
|
+
/*!***********************************************!*\
|
|
5
|
+
!*** ./node_modules/ol/interaction/Modify.js ***!
|
|
6
|
+
\***********************************************/
|
|
7
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
8
|
+
|
|
9
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
/* harmony export */ "ModifyEvent": () => (/* binding */ ModifyEvent),
|
|
12
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
13
|
+
/* harmony export */ });
|
|
14
|
+
/* harmony import */ var _Collection_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Collection.js */ "./node_modules/ol/Collection.js");
|
|
15
|
+
/* harmony import */ var _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../CollectionEventType.js */ "./node_modules/ol/CollectionEventType.js");
|
|
16
|
+
/* harmony import */ var _Feature_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Feature.js */ "./node_modules/ol/Feature.js");
|
|
17
|
+
/* harmony import */ var _MapBrowserEventType_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../MapBrowserEventType.js */ "./node_modules/ol/MapBrowserEventType.js");
|
|
18
|
+
/* harmony import */ var _array_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../array.js */ "./node_modules/ol/array.js");
|
|
19
|
+
/* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/ol/coordinate.js");
|
|
20
|
+
/* harmony import */ var _events_Event_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../events/Event.js */ "./node_modules/ol/events/Event.js");
|
|
21
|
+
/* harmony import */ var _events_EventType_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../events/EventType.js */ "./node_modules/ol/events/EventType.js");
|
|
22
|
+
/* harmony import */ var _events_condition_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../events/condition.js */ "./node_modules/ol/events/condition.js");
|
|
23
|
+
/* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../extent.js */ "./node_modules/ol/extent.js");
|
|
24
|
+
/* harmony import */ var _geom_Point_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../geom/Point.js */ "./node_modules/ol/geom/Point.js");
|
|
25
|
+
/* harmony import */ var _geom_Polygon_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../geom/Polygon.js */ "./node_modules/ol/geom/Polygon.js");
|
|
26
|
+
/* harmony import */ var _layer_Vector_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../layer/Vector.js */ "./node_modules/ol/layer/Vector.js");
|
|
27
|
+
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../proj.js */ "./node_modules/ol/proj.js");
|
|
28
|
+
/* harmony import */ var _source_Vector_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../source/Vector.js */ "./node_modules/ol/source/Vector.js");
|
|
29
|
+
/* harmony import */ var _source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../source/VectorEventType.js */ "./node_modules/ol/source/VectorEventType.js");
|
|
30
|
+
/* harmony import */ var _structs_RBush_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../structs/RBush.js */ "./node_modules/ol/structs/RBush.js");
|
|
31
|
+
/* harmony import */ var _style_Style_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../style/Style.js */ "./node_modules/ol/style/Style.js");
|
|
32
|
+
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../util.js */ "./node_modules/ol/util.js");
|
|
33
|
+
/* harmony import */ var _Pointer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Pointer.js */ "./node_modules/ol/interaction/Pointer.js");
|
|
34
|
+
/**
|
|
35
|
+
* @module ol/interaction/Modify
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The segment index assigned to a circle's center when
|
|
60
|
+
* breaking up a circle into ModifySegmentDataType segments.
|
|
61
|
+
* @type {number}
|
|
62
|
+
*/
|
|
63
|
+
const CIRCLE_CENTER_INDEX = 0;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The segment index assigned to a circle's circumference when
|
|
67
|
+
* breaking up a circle into ModifySegmentDataType segments.
|
|
68
|
+
* @type {number}
|
|
69
|
+
*/
|
|
70
|
+
const CIRCLE_CIRCUMFERENCE_INDEX = 1;
|
|
71
|
+
|
|
72
|
+
const tempExtent = [0, 0, 0, 0];
|
|
73
|
+
const tempSegment = [];
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @enum {string}
|
|
77
|
+
*/
|
|
78
|
+
const ModifyEventType = {
|
|
79
|
+
/**
|
|
80
|
+
* Triggered upon feature modification start
|
|
81
|
+
* @event ModifyEvent#modifystart
|
|
82
|
+
* @api
|
|
83
|
+
*/
|
|
84
|
+
MODIFYSTART: 'modifystart',
|
|
85
|
+
/**
|
|
86
|
+
* Triggered upon feature modification end
|
|
87
|
+
* @event ModifyEvent#modifyend
|
|
88
|
+
* @api
|
|
89
|
+
*/
|
|
90
|
+
MODIFYEND: 'modifyend',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {Object} SegmentData
|
|
95
|
+
* @property {Array<number>} [depth] Depth.
|
|
96
|
+
* @property {Feature} feature Feature.
|
|
97
|
+
* @property {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
98
|
+
* @property {number} [index] Index.
|
|
99
|
+
* @property {Array<Array<number>>} segment Segment.
|
|
100
|
+
* @property {Array<SegmentData>} [featureSegments] FeatureSegments.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @typedef {[SegmentData, number]} DragSegment
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @typedef {Object} Options
|
|
109
|
+
* @property {import("../events/condition.js").Condition} [condition] A function that
|
|
110
|
+
* takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
|
|
111
|
+
* boolean to indicate whether that event will be considered to add or move a
|
|
112
|
+
* vertex to the sketch. Default is
|
|
113
|
+
* {@link module:ol/events/condition.primaryAction}.
|
|
114
|
+
* @property {import("../events/condition.js").Condition} [deleteCondition] A function
|
|
115
|
+
* that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
|
|
116
|
+
* boolean to indicate whether that event should be handled. By default,
|
|
117
|
+
* {@link module:ol/events/condition.singleClick} with
|
|
118
|
+
* {@link module:ol/events/condition.altKeyOnly} results in a vertex deletion.
|
|
119
|
+
* @property {import("../events/condition.js").Condition} [insertVertexCondition] A
|
|
120
|
+
* function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and
|
|
121
|
+
* returns a boolean to indicate whether a new vertex should be added to the sketch
|
|
122
|
+
* features. Default is {@link module:ol/events/condition.always}.
|
|
123
|
+
* @property {number} [pixelTolerance=10] Pixel tolerance for considering the
|
|
124
|
+
* pointer close enough to a segment or vertex for editing.
|
|
125
|
+
* @property {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike} [style]
|
|
126
|
+
* Style used for the modification point or vertex. For linestrings and polygons, this will
|
|
127
|
+
* be the affected vertex, for circles a point along the circle, and for points the actual
|
|
128
|
+
* point. If not configured, the default edit style is used (see {@link module:ol/style/Style~Style}).
|
|
129
|
+
* When using a style function, the point feature passed to the function will have an `existing` property -
|
|
130
|
+
* indicating whether there is an existing vertex underneath or not, a `features`
|
|
131
|
+
* property - an array whose entries are the features that are being modified, and a `geometries`
|
|
132
|
+
* property - an array whose entries are the geometries that are being modified. Both arrays are
|
|
133
|
+
* in the same order. The `geometries` are only useful when modifying geometry collections, where
|
|
134
|
+
* the geometry will be the particular geometry from the collection that is being modified.
|
|
135
|
+
* @property {VectorSource} [source] The vector source with
|
|
136
|
+
* features to modify. If a vector source is not provided, a feature collection
|
|
137
|
+
* must be provided with the `features` option.
|
|
138
|
+
* @property {boolean|import("../layer/BaseVector").default} [hitDetection] When configured, point
|
|
139
|
+
* features will be considered for modification based on their visual appearance, instead of being within
|
|
140
|
+
* the `pixelTolerance` from the pointer location. When a {@link module:ol/layer/BaseVector~BaseVectorLayer} is
|
|
141
|
+
* provided, only the rendered representation of the features on that layer will be considered.
|
|
142
|
+
* @property {Collection<Feature>} [features]
|
|
143
|
+
* The features the interaction works on. If a feature collection is not
|
|
144
|
+
* provided, a vector source must be provided with the `source` option.
|
|
145
|
+
* @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch
|
|
146
|
+
* overlay.
|
|
147
|
+
* @property {boolean} [snapToPointer=!hitDetection] The vertex, point or segment being modified snaps to the
|
|
148
|
+
* pointer coordinate when clicked within the `pixelTolerance`.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @classdesc
|
|
153
|
+
* Events emitted by {@link module:ol/interaction/Modify~Modify} instances are
|
|
154
|
+
* instances of this type.
|
|
155
|
+
*/
|
|
156
|
+
class ModifyEvent extends _events_Event_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
157
|
+
/**
|
|
158
|
+
* @param {ModifyEventType} type Type.
|
|
159
|
+
* @param {Collection<Feature>} features
|
|
160
|
+
* The features modified.
|
|
161
|
+
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent
|
|
162
|
+
* Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
|
163
|
+
*/
|
|
164
|
+
constructor(type, features, mapBrowserEvent) {
|
|
165
|
+
super(type);
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The features being modified.
|
|
169
|
+
* @type {Collection<Feature>}
|
|
170
|
+
* @api
|
|
171
|
+
*/
|
|
172
|
+
this.features = features;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
|
176
|
+
* @type {import("../MapBrowserEvent.js").default}
|
|
177
|
+
* @api
|
|
178
|
+
*/
|
|
179
|
+
this.mapBrowserEvent = mapBrowserEvent;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/***
|
|
184
|
+
* @template Return
|
|
185
|
+
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
|
|
186
|
+
* import("../Observable").OnSignature<import("../ObjectEventType").Types|
|
|
187
|
+
* 'change:active', import("../Object").ObjectEvent, Return> &
|
|
188
|
+
* import("../Observable").OnSignature<'modifyend'|'modifystart', ModifyEvent, Return> &
|
|
189
|
+
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
|
|
190
|
+
* 'change:active'|'modifyend'|'modifystart', Return>} ModifyOnSignature
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @classdesc
|
|
195
|
+
* Interaction for modifying feature geometries. To modify features that have
|
|
196
|
+
* been added to an existing source, construct the modify interaction with the
|
|
197
|
+
* `source` option. If you want to modify features in a collection (for example,
|
|
198
|
+
* the collection used by a select interaction), construct the interaction with
|
|
199
|
+
* the `features` option. The interaction must be constructed with either a
|
|
200
|
+
* `source` or `features` option.
|
|
201
|
+
*
|
|
202
|
+
* Cartesian distance from the pointer is used to determine the features that
|
|
203
|
+
* will be modified. This means that geometries will only be considered for
|
|
204
|
+
* modification when they are within the configured `pixelTolerance`. For point
|
|
205
|
+
* geometries, the `hitDetection` option can be used to match their visual
|
|
206
|
+
* appearance.
|
|
207
|
+
*
|
|
208
|
+
* By default, the interaction will allow deletion of vertices when the `alt`
|
|
209
|
+
* key is pressed. To configure the interaction with a different condition
|
|
210
|
+
* for deletion, use the `deleteCondition` option.
|
|
211
|
+
* @fires ModifyEvent
|
|
212
|
+
* @api
|
|
213
|
+
*/
|
|
214
|
+
class Modify extends _Pointer_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
|
|
215
|
+
/**
|
|
216
|
+
* @param {Options} options Options.
|
|
217
|
+
*/
|
|
218
|
+
constructor(options) {
|
|
219
|
+
super(/** @type {import("./Pointer.js").Options} */ (options));
|
|
220
|
+
|
|
221
|
+
/***
|
|
222
|
+
* @type {ModifyOnSignature<import("../events").EventsKey>}
|
|
223
|
+
*/
|
|
224
|
+
this.on;
|
|
225
|
+
|
|
226
|
+
/***
|
|
227
|
+
* @type {ModifyOnSignature<import("../events").EventsKey>}
|
|
228
|
+
*/
|
|
229
|
+
this.once;
|
|
230
|
+
|
|
231
|
+
/***
|
|
232
|
+
* @type {ModifyOnSignature<void>}
|
|
233
|
+
*/
|
|
234
|
+
this.un;
|
|
235
|
+
|
|
236
|
+
/** @private */
|
|
237
|
+
this.boundHandleFeatureChange_ = this.handleFeatureChange_.bind(this);
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* @private
|
|
241
|
+
* @type {import("../events/condition.js").Condition}
|
|
242
|
+
*/
|
|
243
|
+
this.condition_ = options.condition ? options.condition : _events_condition_js__WEBPACK_IMPORTED_MODULE_3__.primaryAction;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @private
|
|
247
|
+
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Browser event.
|
|
248
|
+
* @return {boolean} Combined condition result.
|
|
249
|
+
*/
|
|
250
|
+
this.defaultDeleteCondition_ = function (mapBrowserEvent) {
|
|
251
|
+
return (0,_events_condition_js__WEBPACK_IMPORTED_MODULE_3__.altKeyOnly)(mapBrowserEvent) && (0,_events_condition_js__WEBPACK_IMPORTED_MODULE_3__.singleClick)(mapBrowserEvent);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @type {import("../events/condition.js").Condition}
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
this.deleteCondition_ = options.deleteCondition
|
|
259
|
+
? options.deleteCondition
|
|
260
|
+
: this.defaultDeleteCondition_;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @type {import("../events/condition.js").Condition}
|
|
264
|
+
* @private
|
|
265
|
+
*/
|
|
266
|
+
this.insertVertexCondition_ = options.insertVertexCondition
|
|
267
|
+
? options.insertVertexCondition
|
|
268
|
+
: _events_condition_js__WEBPACK_IMPORTED_MODULE_3__.always;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Editing vertex.
|
|
272
|
+
* @type {Feature<Point>}
|
|
273
|
+
* @private
|
|
274
|
+
*/
|
|
275
|
+
this.vertexFeature_ = null;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Segments intersecting {@link this.vertexFeature_} by segment uid.
|
|
279
|
+
* @type {Object<string, boolean>}
|
|
280
|
+
* @private
|
|
281
|
+
*/
|
|
282
|
+
this.vertexSegments_ = null;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @type {import("../pixel.js").Pixel}
|
|
286
|
+
* @private
|
|
287
|
+
*/
|
|
288
|
+
this.lastPixel_ = [0, 0];
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Tracks if the next `singleclick` event should be ignored to prevent
|
|
292
|
+
* accidental deletion right after vertex creation.
|
|
293
|
+
* @type {boolean}
|
|
294
|
+
* @private
|
|
295
|
+
*/
|
|
296
|
+
this.ignoreNextSingleClick_ = false;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @type {Collection<Feature>}
|
|
300
|
+
* @private
|
|
301
|
+
*/
|
|
302
|
+
this.featuresBeingModified_ = null;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Segment RTree for each layer
|
|
306
|
+
* @type {RBush<SegmentData>}
|
|
307
|
+
* @private
|
|
308
|
+
*/
|
|
309
|
+
this.rBush_ = new _structs_RBush_js__WEBPACK_IMPORTED_MODULE_4__["default"]();
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @type {number}
|
|
313
|
+
* @private
|
|
314
|
+
*/
|
|
315
|
+
this.pixelTolerance_ =
|
|
316
|
+
options.pixelTolerance !== undefined ? options.pixelTolerance : 10;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @type {boolean}
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
this.snappedToVertex_ = false;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Indicate whether the interaction is currently changing a feature's
|
|
326
|
+
* coordinates.
|
|
327
|
+
* @type {boolean}
|
|
328
|
+
* @private
|
|
329
|
+
*/
|
|
330
|
+
this.changingFeature_ = false;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* @type {Array<DragSegment>}
|
|
334
|
+
* @private
|
|
335
|
+
*/
|
|
336
|
+
this.dragSegments_ = [];
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Draw overlay where sketch features are drawn.
|
|
340
|
+
* @type {VectorLayer}
|
|
341
|
+
* @private
|
|
342
|
+
*/
|
|
343
|
+
this.overlay_ = new _layer_Vector_js__WEBPACK_IMPORTED_MODULE_5__["default"]({
|
|
344
|
+
source: new _source_Vector_js__WEBPACK_IMPORTED_MODULE_6__["default"]({
|
|
345
|
+
useSpatialIndex: false,
|
|
346
|
+
wrapX: !!options.wrapX,
|
|
347
|
+
}),
|
|
348
|
+
style: options.style ? options.style : getDefaultStyleFunction(),
|
|
349
|
+
updateWhileAnimating: true,
|
|
350
|
+
updateWhileInteracting: true,
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @const
|
|
355
|
+
* @private
|
|
356
|
+
* @type {!Object<string, function(Feature, import("../geom/Geometry.js").default): void>}
|
|
357
|
+
*/
|
|
358
|
+
this.SEGMENT_WRITERS_ = {
|
|
359
|
+
'Point': this.writePointGeometry_.bind(this),
|
|
360
|
+
'LineString': this.writeLineStringGeometry_.bind(this),
|
|
361
|
+
'LinearRing': this.writeLineStringGeometry_.bind(this),
|
|
362
|
+
'Polygon': this.writePolygonGeometry_.bind(this),
|
|
363
|
+
'MultiPoint': this.writeMultiPointGeometry_.bind(this),
|
|
364
|
+
'MultiLineString': this.writeMultiLineStringGeometry_.bind(this),
|
|
365
|
+
'MultiPolygon': this.writeMultiPolygonGeometry_.bind(this),
|
|
366
|
+
'Circle': this.writeCircleGeometry_.bind(this),
|
|
367
|
+
'GeometryCollection': this.writeGeometryCollectionGeometry_.bind(this),
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* @type {VectorSource}
|
|
372
|
+
* @private
|
|
373
|
+
*/
|
|
374
|
+
this.source_ = null;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* @type {boolean|import("../layer/BaseVector").default}
|
|
378
|
+
* @private
|
|
379
|
+
*/
|
|
380
|
+
this.hitDetection_ = null;
|
|
381
|
+
|
|
382
|
+
/** @type {Collection<Feature>} */
|
|
383
|
+
let features;
|
|
384
|
+
if (options.features) {
|
|
385
|
+
features = options.features;
|
|
386
|
+
} else if (options.source) {
|
|
387
|
+
this.source_ = options.source;
|
|
388
|
+
features = new _Collection_js__WEBPACK_IMPORTED_MODULE_7__["default"](this.source_.getFeatures());
|
|
389
|
+
this.source_.addEventListener(
|
|
390
|
+
_source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_8__["default"].ADDFEATURE,
|
|
391
|
+
this.handleSourceAdd_.bind(this),
|
|
392
|
+
);
|
|
393
|
+
this.source_.addEventListener(
|
|
394
|
+
_source_VectorEventType_js__WEBPACK_IMPORTED_MODULE_8__["default"].REMOVEFEATURE,
|
|
395
|
+
this.handleSourceRemove_.bind(this),
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
if (!features) {
|
|
399
|
+
throw new Error(
|
|
400
|
+
'The modify interaction requires features, a source or a layer',
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
if (options.hitDetection) {
|
|
404
|
+
this.hitDetection_ = options.hitDetection;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @type {Collection<Feature>}
|
|
409
|
+
* @private
|
|
410
|
+
*/
|
|
411
|
+
this.features_ = features;
|
|
412
|
+
|
|
413
|
+
this.features_.forEach(this.addFeature_.bind(this));
|
|
414
|
+
this.features_.addEventListener(
|
|
415
|
+
_CollectionEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].ADD,
|
|
416
|
+
this.handleFeatureAdd_.bind(this),
|
|
417
|
+
);
|
|
418
|
+
this.features_.addEventListener(
|
|
419
|
+
_CollectionEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].REMOVE,
|
|
420
|
+
this.handleFeatureRemove_.bind(this),
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @type {import("../MapBrowserEvent.js").default}
|
|
425
|
+
* @private
|
|
426
|
+
*/
|
|
427
|
+
this.lastPointerEvent_ = null;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Delta (x, y in map units) between matched rtree vertex and pointer vertex.
|
|
431
|
+
* @type {Array<number>}
|
|
432
|
+
* @private
|
|
433
|
+
*/
|
|
434
|
+
this.delta_ = [0, 0];
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @private
|
|
438
|
+
*/
|
|
439
|
+
this.snapToPointer_ =
|
|
440
|
+
options.snapToPointer === undefined
|
|
441
|
+
? !this.hitDetection_
|
|
442
|
+
: options.snapToPointer;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @param {Feature} feature Feature.
|
|
447
|
+
* @private
|
|
448
|
+
*/
|
|
449
|
+
addFeature_(feature) {
|
|
450
|
+
const geometry = feature.getGeometry();
|
|
451
|
+
if (geometry) {
|
|
452
|
+
const writer = this.SEGMENT_WRITERS_[geometry.getType()];
|
|
453
|
+
if (writer) {
|
|
454
|
+
writer(feature, geometry);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const map = this.getMap();
|
|
458
|
+
if (map && map.isRendered() && this.getActive()) {
|
|
459
|
+
this.handlePointerAtPixel_(map.getCoordinateFromPixel(this.lastPixel_));
|
|
460
|
+
}
|
|
461
|
+
feature.addEventListener(_events_EventType_js__WEBPACK_IMPORTED_MODULE_10__["default"].CHANGE, this.boundHandleFeatureChange_);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @param {import("../MapBrowserEvent.js").default} evt Map browser event.
|
|
466
|
+
* @param {Array<SegmentData>} segments The segments subject to modification.
|
|
467
|
+
* @private
|
|
468
|
+
*/
|
|
469
|
+
willModifyFeatures_(evt, segments) {
|
|
470
|
+
if (!this.featuresBeingModified_) {
|
|
471
|
+
this.featuresBeingModified_ = new _Collection_js__WEBPACK_IMPORTED_MODULE_7__["default"]();
|
|
472
|
+
const features = this.featuresBeingModified_.getArray();
|
|
473
|
+
for (let i = 0, ii = segments.length; i < ii; ++i) {
|
|
474
|
+
const feature = segments[i].feature;
|
|
475
|
+
if (feature && !features.includes(feature)) {
|
|
476
|
+
this.featuresBeingModified_.push(feature);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (this.featuresBeingModified_.getLength() === 0) {
|
|
480
|
+
this.featuresBeingModified_ = null;
|
|
481
|
+
} else {
|
|
482
|
+
this.dispatchEvent(
|
|
483
|
+
new ModifyEvent(
|
|
484
|
+
ModifyEventType.MODIFYSTART,
|
|
485
|
+
this.featuresBeingModified_,
|
|
486
|
+
evt,
|
|
487
|
+
),
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* @param {Feature} feature Feature.
|
|
495
|
+
* @private
|
|
496
|
+
*/
|
|
497
|
+
removeFeature_(feature) {
|
|
498
|
+
this.removeFeatureSegmentData_(feature);
|
|
499
|
+
// Remove the vertex feature if the collection of candidate features is empty.
|
|
500
|
+
if (this.vertexFeature_ && this.features_.getLength() === 0) {
|
|
501
|
+
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
|
502
|
+
this.vertexFeature_ = null;
|
|
503
|
+
}
|
|
504
|
+
feature.removeEventListener(
|
|
505
|
+
_events_EventType_js__WEBPACK_IMPORTED_MODULE_10__["default"].CHANGE,
|
|
506
|
+
this.boundHandleFeatureChange_,
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @param {Feature} feature Feature.
|
|
512
|
+
* @private
|
|
513
|
+
*/
|
|
514
|
+
removeFeatureSegmentData_(feature) {
|
|
515
|
+
const rBush = this.rBush_;
|
|
516
|
+
/** @type {Array<SegmentData>} */
|
|
517
|
+
const nodesToRemove = [];
|
|
518
|
+
rBush.forEach(
|
|
519
|
+
/**
|
|
520
|
+
* @param {SegmentData} node RTree node.
|
|
521
|
+
*/
|
|
522
|
+
function (node) {
|
|
523
|
+
if (feature === node.feature) {
|
|
524
|
+
nodesToRemove.push(node);
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
);
|
|
528
|
+
for (let i = nodesToRemove.length - 1; i >= 0; --i) {
|
|
529
|
+
const nodeToRemove = nodesToRemove[i];
|
|
530
|
+
for (let j = this.dragSegments_.length - 1; j >= 0; --j) {
|
|
531
|
+
if (this.dragSegments_[j][0] === nodeToRemove) {
|
|
532
|
+
this.dragSegments_.splice(j, 1);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
rBush.remove(nodeToRemove);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Activate or deactivate the interaction.
|
|
541
|
+
* @param {boolean} active Active.
|
|
542
|
+
* @observable
|
|
543
|
+
* @api
|
|
544
|
+
* @override
|
|
545
|
+
*/
|
|
546
|
+
setActive(active) {
|
|
547
|
+
if (this.vertexFeature_ && !active) {
|
|
548
|
+
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
|
549
|
+
this.vertexFeature_ = null;
|
|
550
|
+
}
|
|
551
|
+
super.setActive(active);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Remove the interaction from its current map and attach it to the new map.
|
|
556
|
+
* Subclasses may set up event handlers to get notified about changes to
|
|
557
|
+
* the map here.
|
|
558
|
+
* @param {import("../Map.js").default} map Map.
|
|
559
|
+
* @override
|
|
560
|
+
*/
|
|
561
|
+
setMap(map) {
|
|
562
|
+
this.overlay_.setMap(map);
|
|
563
|
+
super.setMap(map);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Get the overlay layer that this interaction renders the modification point or vertex to.
|
|
568
|
+
* @return {VectorLayer} Overlay layer.
|
|
569
|
+
* @api
|
|
570
|
+
*/
|
|
571
|
+
getOverlay() {
|
|
572
|
+
return this.overlay_;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* @param {import("../source/Vector.js").VectorSourceEvent} event Event.
|
|
577
|
+
* @private
|
|
578
|
+
*/
|
|
579
|
+
handleSourceAdd_(event) {
|
|
580
|
+
if (event.feature) {
|
|
581
|
+
this.features_.push(event.feature);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* @param {import("../source/Vector.js").VectorSourceEvent} event Event.
|
|
587
|
+
* @private
|
|
588
|
+
*/
|
|
589
|
+
handleSourceRemove_(event) {
|
|
590
|
+
if (event.feature) {
|
|
591
|
+
this.features_.remove(event.feature);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
597
|
+
* @private
|
|
598
|
+
*/
|
|
599
|
+
handleFeatureAdd_(evt) {
|
|
600
|
+
this.addFeature_(evt.element);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @param {import("../events/Event.js").default} evt Event.
|
|
605
|
+
* @private
|
|
606
|
+
*/
|
|
607
|
+
handleFeatureChange_(evt) {
|
|
608
|
+
if (!this.changingFeature_) {
|
|
609
|
+
const feature = /** @type {Feature} */ (evt.target);
|
|
610
|
+
this.removeFeature_(feature);
|
|
611
|
+
this.addFeature_(feature);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
617
|
+
* @private
|
|
618
|
+
*/
|
|
619
|
+
handleFeatureRemove_(evt) {
|
|
620
|
+
this.removeFeature_(evt.element);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* @param {Feature} feature Feature
|
|
625
|
+
* @param {Point} geometry Geometry.
|
|
626
|
+
* @private
|
|
627
|
+
*/
|
|
628
|
+
writePointGeometry_(feature, geometry) {
|
|
629
|
+
const coordinates = geometry.getCoordinates();
|
|
630
|
+
|
|
631
|
+
/** @type {SegmentData} */
|
|
632
|
+
const segmentData = {
|
|
633
|
+
feature: feature,
|
|
634
|
+
geometry: geometry,
|
|
635
|
+
segment: [coordinates, coordinates],
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
this.rBush_.insert(geometry.getExtent(), segmentData);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* @param {Feature} feature Feature
|
|
643
|
+
* @param {import("../geom/MultiPoint.js").default} geometry Geometry.
|
|
644
|
+
* @private
|
|
645
|
+
*/
|
|
646
|
+
writeMultiPointGeometry_(feature, geometry) {
|
|
647
|
+
const points = geometry.getCoordinates();
|
|
648
|
+
for (let i = 0, ii = points.length; i < ii; ++i) {
|
|
649
|
+
const coordinates = points[i];
|
|
650
|
+
|
|
651
|
+
/** @type {SegmentData} */
|
|
652
|
+
const segmentData = {
|
|
653
|
+
feature: feature,
|
|
654
|
+
geometry: geometry,
|
|
655
|
+
depth: [i],
|
|
656
|
+
index: i,
|
|
657
|
+
segment: [coordinates, coordinates],
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
this.rBush_.insert(geometry.getExtent(), segmentData);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* @param {Feature} feature Feature
|
|
666
|
+
* @param {import("../geom/LineString.js").default} geometry Geometry.
|
|
667
|
+
* @private
|
|
668
|
+
*/
|
|
669
|
+
writeLineStringGeometry_(feature, geometry) {
|
|
670
|
+
const coordinates = geometry.getCoordinates();
|
|
671
|
+
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
|
672
|
+
const segment = coordinates.slice(i, i + 2);
|
|
673
|
+
|
|
674
|
+
/** @type {SegmentData} */
|
|
675
|
+
const segmentData = {
|
|
676
|
+
feature: feature,
|
|
677
|
+
geometry: geometry,
|
|
678
|
+
index: i,
|
|
679
|
+
segment: segment,
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
this.rBush_.insert((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(segment), segmentData);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* @param {Feature} feature Feature
|
|
688
|
+
* @param {import("../geom/MultiLineString.js").default} geometry Geometry.
|
|
689
|
+
* @private
|
|
690
|
+
*/
|
|
691
|
+
writeMultiLineStringGeometry_(feature, geometry) {
|
|
692
|
+
const lines = geometry.getCoordinates();
|
|
693
|
+
for (let j = 0, jj = lines.length; j < jj; ++j) {
|
|
694
|
+
const coordinates = lines[j];
|
|
695
|
+
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
|
696
|
+
const segment = coordinates.slice(i, i + 2);
|
|
697
|
+
|
|
698
|
+
/** @type {SegmentData} */
|
|
699
|
+
const segmentData = {
|
|
700
|
+
feature: feature,
|
|
701
|
+
geometry: geometry,
|
|
702
|
+
depth: [j],
|
|
703
|
+
index: i,
|
|
704
|
+
segment: segment,
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
this.rBush_.insert((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(segment), segmentData);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* @param {Feature} feature Feature
|
|
714
|
+
* @param {import("../geom/Polygon.js").default} geometry Geometry.
|
|
715
|
+
* @private
|
|
716
|
+
*/
|
|
717
|
+
writePolygonGeometry_(feature, geometry) {
|
|
718
|
+
const rings = geometry.getCoordinates();
|
|
719
|
+
for (let j = 0, jj = rings.length; j < jj; ++j) {
|
|
720
|
+
const coordinates = rings[j];
|
|
721
|
+
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
|
722
|
+
const segment = coordinates.slice(i, i + 2);
|
|
723
|
+
|
|
724
|
+
/** @type {SegmentData} */
|
|
725
|
+
const segmentData = {
|
|
726
|
+
feature: feature,
|
|
727
|
+
geometry: geometry,
|
|
728
|
+
depth: [j],
|
|
729
|
+
index: i,
|
|
730
|
+
segment: segment,
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
this.rBush_.insert((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(segment), segmentData);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* @param {Feature} feature Feature
|
|
740
|
+
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
|
741
|
+
* @private
|
|
742
|
+
*/
|
|
743
|
+
writeMultiPolygonGeometry_(feature, geometry) {
|
|
744
|
+
const polygons = geometry.getCoordinates();
|
|
745
|
+
for (let k = 0, kk = polygons.length; k < kk; ++k) {
|
|
746
|
+
const rings = polygons[k];
|
|
747
|
+
for (let j = 0, jj = rings.length; j < jj; ++j) {
|
|
748
|
+
const coordinates = rings[j];
|
|
749
|
+
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
|
750
|
+
const segment = coordinates.slice(i, i + 2);
|
|
751
|
+
|
|
752
|
+
/** @type {SegmentData} */
|
|
753
|
+
const segmentData = {
|
|
754
|
+
feature: feature,
|
|
755
|
+
geometry: geometry,
|
|
756
|
+
depth: [j, k],
|
|
757
|
+
index: i,
|
|
758
|
+
segment: segment,
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
this.rBush_.insert((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(segment), segmentData);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* We convert a circle into two segments. The segment at index
|
|
769
|
+
* {@link CIRCLE_CENTER_INDEX} is the
|
|
770
|
+
* circle's center (a point). The segment at index
|
|
771
|
+
* {@link CIRCLE_CIRCUMFERENCE_INDEX} is
|
|
772
|
+
* the circumference, and is not a line segment.
|
|
773
|
+
*
|
|
774
|
+
* @param {Feature} feature Feature.
|
|
775
|
+
* @param {import("../geom/Circle.js").default} geometry Geometry.
|
|
776
|
+
* @private
|
|
777
|
+
*/
|
|
778
|
+
writeCircleGeometry_(feature, geometry) {
|
|
779
|
+
const coordinates = geometry.getCenter();
|
|
780
|
+
|
|
781
|
+
/** @type {SegmentData} */
|
|
782
|
+
const centerSegmentData = {
|
|
783
|
+
feature: feature,
|
|
784
|
+
geometry: geometry,
|
|
785
|
+
index: CIRCLE_CENTER_INDEX,
|
|
786
|
+
segment: [coordinates, coordinates],
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
/** @type {SegmentData} */
|
|
790
|
+
const circumferenceSegmentData = {
|
|
791
|
+
feature: feature,
|
|
792
|
+
geometry: geometry,
|
|
793
|
+
index: CIRCLE_CIRCUMFERENCE_INDEX,
|
|
794
|
+
segment: [coordinates, coordinates],
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
const featureSegments = [centerSegmentData, circumferenceSegmentData];
|
|
798
|
+
centerSegmentData.featureSegments = featureSegments;
|
|
799
|
+
circumferenceSegmentData.featureSegments = featureSegments;
|
|
800
|
+
this.rBush_.insert((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.createOrUpdateFromCoordinate)(coordinates), centerSegmentData);
|
|
801
|
+
let circleGeometry = /** @type {import("../geom/Geometry.js").default} */ (
|
|
802
|
+
geometry
|
|
803
|
+
);
|
|
804
|
+
const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
805
|
+
if (userProjection && this.getMap()) {
|
|
806
|
+
const projection = this.getMap().getView().getProjection();
|
|
807
|
+
circleGeometry = circleGeometry
|
|
808
|
+
.clone()
|
|
809
|
+
.transform(userProjection, projection);
|
|
810
|
+
circleGeometry = (0,_geom_Polygon_js__WEBPACK_IMPORTED_MODULE_12__.fromCircle)(
|
|
811
|
+
/** @type {import("../geom/Circle.js").default} */ (circleGeometry),
|
|
812
|
+
).transform(projection, userProjection);
|
|
813
|
+
}
|
|
814
|
+
this.rBush_.insert(circleGeometry.getExtent(), circumferenceSegmentData);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* @param {Feature} feature Feature
|
|
819
|
+
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
|
|
820
|
+
* @private
|
|
821
|
+
*/
|
|
822
|
+
writeGeometryCollectionGeometry_(feature, geometry) {
|
|
823
|
+
const geometries = geometry.getGeometriesArray();
|
|
824
|
+
for (let i = 0; i < geometries.length; ++i) {
|
|
825
|
+
const geometry = geometries[i];
|
|
826
|
+
const writer = this.SEGMENT_WRITERS_[geometry.getType()];
|
|
827
|
+
writer(feature, geometry);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
|
|
833
|
+
* @param {Array<Feature>} features The features being modified.
|
|
834
|
+
* @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified.
|
|
835
|
+
* @param {boolean} existing The vertex represents an existing vertex.
|
|
836
|
+
* @return {Feature} Vertex feature.
|
|
837
|
+
* @private
|
|
838
|
+
*/
|
|
839
|
+
createOrUpdateVertexFeature_(coordinates, features, geometries, existing) {
|
|
840
|
+
let vertexFeature = this.vertexFeature_;
|
|
841
|
+
if (!vertexFeature) {
|
|
842
|
+
vertexFeature = new _Feature_js__WEBPACK_IMPORTED_MODULE_13__["default"](new _geom_Point_js__WEBPACK_IMPORTED_MODULE_14__["default"](coordinates));
|
|
843
|
+
this.vertexFeature_ = vertexFeature;
|
|
844
|
+
this.overlay_.getSource().addFeature(vertexFeature);
|
|
845
|
+
} else {
|
|
846
|
+
const geometry = vertexFeature.getGeometry();
|
|
847
|
+
geometry.setCoordinates(coordinates);
|
|
848
|
+
}
|
|
849
|
+
vertexFeature.set('features', features);
|
|
850
|
+
vertexFeature.set('geometries', geometries);
|
|
851
|
+
vertexFeature.set('existing', existing);
|
|
852
|
+
return vertexFeature;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may modify the geometry.
|
|
857
|
+
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
|
|
858
|
+
* @return {boolean} `false` to stop event propagation.
|
|
859
|
+
* @override
|
|
860
|
+
*/
|
|
861
|
+
handleEvent(mapBrowserEvent) {
|
|
862
|
+
if (!mapBrowserEvent.originalEvent) {
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
this.lastPointerEvent_ = mapBrowserEvent;
|
|
866
|
+
|
|
867
|
+
let handled;
|
|
868
|
+
if (
|
|
869
|
+
!mapBrowserEvent.map.getView().getInteracting() &&
|
|
870
|
+
mapBrowserEvent.type == _MapBrowserEventType_js__WEBPACK_IMPORTED_MODULE_15__["default"].POINTERMOVE &&
|
|
871
|
+
!this.handlingDownUpSequence
|
|
872
|
+
) {
|
|
873
|
+
this.handlePointerMove_(mapBrowserEvent);
|
|
874
|
+
}
|
|
875
|
+
if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
|
|
876
|
+
if (
|
|
877
|
+
mapBrowserEvent.type != _MapBrowserEventType_js__WEBPACK_IMPORTED_MODULE_15__["default"].SINGLECLICK ||
|
|
878
|
+
!this.ignoreNextSingleClick_
|
|
879
|
+
) {
|
|
880
|
+
handled = this.removePoint();
|
|
881
|
+
} else {
|
|
882
|
+
handled = true;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
if (mapBrowserEvent.type == _MapBrowserEventType_js__WEBPACK_IMPORTED_MODULE_15__["default"].SINGLECLICK) {
|
|
887
|
+
this.ignoreNextSingleClick_ = false;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
return super.handleEvent(mapBrowserEvent) && !handled;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
findInsertVerticesAndUpdateDragSegments_(pixelCoordinate) {
|
|
894
|
+
this.handlePointerAtPixel_(pixelCoordinate);
|
|
895
|
+
this.dragSegments_.length = 0;
|
|
896
|
+
this.featuresBeingModified_ = null;
|
|
897
|
+
const vertexFeature = this.vertexFeature_;
|
|
898
|
+
if (!vertexFeature) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const projection = this.getMap().getView().getProjection();
|
|
903
|
+
const insertVertices = [];
|
|
904
|
+
const vertex = vertexFeature.getGeometry().getCoordinates();
|
|
905
|
+
const vertexExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)([vertex]);
|
|
906
|
+
const segmentDataMatches = this.rBush_.getInExtent(vertexExtent);
|
|
907
|
+
const componentSegments = {};
|
|
908
|
+
segmentDataMatches.sort(compareIndexes);
|
|
909
|
+
for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
|
|
910
|
+
const segmentDataMatch = segmentDataMatches[i];
|
|
911
|
+
const segment = segmentDataMatch.segment;
|
|
912
|
+
let uid = (0,_util_js__WEBPACK_IMPORTED_MODULE_16__.getUid)(segmentDataMatch.geometry);
|
|
913
|
+
const depth = segmentDataMatch.depth;
|
|
914
|
+
if (depth) {
|
|
915
|
+
uid += '-' + depth.join('-'); // separate feature components
|
|
916
|
+
}
|
|
917
|
+
if (!componentSegments[uid]) {
|
|
918
|
+
componentSegments[uid] = new Array(2);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
if (
|
|
922
|
+
segmentDataMatch.geometry.getType() === 'Circle' &&
|
|
923
|
+
segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX
|
|
924
|
+
) {
|
|
925
|
+
const closestVertex = closestOnSegmentData(
|
|
926
|
+
pixelCoordinate,
|
|
927
|
+
segmentDataMatch,
|
|
928
|
+
projection,
|
|
929
|
+
);
|
|
930
|
+
if (
|
|
931
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(closestVertex, vertex) &&
|
|
932
|
+
!componentSegments[uid][0]
|
|
933
|
+
) {
|
|
934
|
+
this.dragSegments_.push([segmentDataMatch, 0]);
|
|
935
|
+
componentSegments[uid][0] = segmentDataMatch;
|
|
936
|
+
}
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if ((0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(segment[0], vertex) && !componentSegments[uid][0]) {
|
|
941
|
+
this.dragSegments_.push([segmentDataMatch, 0]);
|
|
942
|
+
componentSegments[uid][0] = segmentDataMatch;
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
if ((0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(segment[1], vertex) && !componentSegments[uid][1]) {
|
|
947
|
+
if (
|
|
948
|
+
componentSegments[uid][0] &&
|
|
949
|
+
componentSegments[uid][0].index === 0
|
|
950
|
+
) {
|
|
951
|
+
let coordinates = segmentDataMatch.geometry.getCoordinates();
|
|
952
|
+
switch (segmentDataMatch.geometry.getType()) {
|
|
953
|
+
// prevent dragging closed linestrings by the connecting node
|
|
954
|
+
case 'LineString':
|
|
955
|
+
case 'MultiLineString':
|
|
956
|
+
continue;
|
|
957
|
+
// if dragging the first vertex of a polygon, ensure the other segment
|
|
958
|
+
// belongs to the closing vertex of the linear ring
|
|
959
|
+
case 'MultiPolygon':
|
|
960
|
+
coordinates = coordinates[depth[1]];
|
|
961
|
+
/* falls through */
|
|
962
|
+
case 'Polygon':
|
|
963
|
+
if (segmentDataMatch.index !== coordinates[depth[0]].length - 2) {
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
break;
|
|
967
|
+
default:
|
|
968
|
+
// pass
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
this.dragSegments_.push([segmentDataMatch, 1]);
|
|
973
|
+
componentSegments[uid][1] = segmentDataMatch;
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
if (
|
|
978
|
+
(0,_util_js__WEBPACK_IMPORTED_MODULE_16__.getUid)(segment) in this.vertexSegments_ &&
|
|
979
|
+
!componentSegments[uid][0] &&
|
|
980
|
+
!componentSegments[uid][1]
|
|
981
|
+
) {
|
|
982
|
+
insertVertices.push(segmentDataMatch);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
return insertVertices;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Handle pointer drag events.
|
|
991
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
992
|
+
* @override
|
|
993
|
+
*/
|
|
994
|
+
handleDragEvent(evt) {
|
|
995
|
+
this.ignoreNextSingleClick_ = false;
|
|
996
|
+
this.willModifyFeatures_(
|
|
997
|
+
evt,
|
|
998
|
+
this.dragSegments_.map(([segment]) => segment),
|
|
999
|
+
);
|
|
1000
|
+
|
|
1001
|
+
const vertex = [
|
|
1002
|
+
evt.coordinate[0] + this.delta_[0],
|
|
1003
|
+
evt.coordinate[1] + this.delta_[1],
|
|
1004
|
+
];
|
|
1005
|
+
const features = [];
|
|
1006
|
+
const geometries = [];
|
|
1007
|
+
for (let i = 0, ii = this.dragSegments_.length; i < ii; ++i) {
|
|
1008
|
+
const dragSegment = this.dragSegments_[i];
|
|
1009
|
+
const segmentData = dragSegment[0];
|
|
1010
|
+
const feature = segmentData.feature;
|
|
1011
|
+
if (!features.includes(feature)) {
|
|
1012
|
+
features.push(feature);
|
|
1013
|
+
}
|
|
1014
|
+
const geometry = segmentData.geometry;
|
|
1015
|
+
if (!geometries.includes(geometry)) {
|
|
1016
|
+
geometries.push(geometry);
|
|
1017
|
+
}
|
|
1018
|
+
const depth = segmentData.depth;
|
|
1019
|
+
let coordinates;
|
|
1020
|
+
const segment = segmentData.segment;
|
|
1021
|
+
const index = dragSegment[1];
|
|
1022
|
+
|
|
1023
|
+
while (vertex.length < geometry.getStride()) {
|
|
1024
|
+
vertex.push(segment[index][vertex.length]);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
switch (geometry.getType()) {
|
|
1028
|
+
case 'Point':
|
|
1029
|
+
coordinates = vertex;
|
|
1030
|
+
segment[0] = vertex;
|
|
1031
|
+
segment[1] = vertex;
|
|
1032
|
+
break;
|
|
1033
|
+
case 'MultiPoint':
|
|
1034
|
+
coordinates = geometry.getCoordinates();
|
|
1035
|
+
coordinates[segmentData.index] = vertex;
|
|
1036
|
+
segment[0] = vertex;
|
|
1037
|
+
segment[1] = vertex;
|
|
1038
|
+
break;
|
|
1039
|
+
case 'LineString':
|
|
1040
|
+
coordinates = geometry.getCoordinates();
|
|
1041
|
+
coordinates[segmentData.index + index] = vertex;
|
|
1042
|
+
segment[index] = vertex;
|
|
1043
|
+
break;
|
|
1044
|
+
case 'MultiLineString':
|
|
1045
|
+
coordinates = geometry.getCoordinates();
|
|
1046
|
+
coordinates[depth[0]][segmentData.index + index] = vertex;
|
|
1047
|
+
segment[index] = vertex;
|
|
1048
|
+
break;
|
|
1049
|
+
case 'Polygon':
|
|
1050
|
+
coordinates = geometry.getCoordinates();
|
|
1051
|
+
coordinates[depth[0]][segmentData.index + index] = vertex;
|
|
1052
|
+
segment[index] = vertex;
|
|
1053
|
+
break;
|
|
1054
|
+
case 'MultiPolygon':
|
|
1055
|
+
coordinates = geometry.getCoordinates();
|
|
1056
|
+
coordinates[depth[1]][depth[0]][segmentData.index + index] = vertex;
|
|
1057
|
+
segment[index] = vertex;
|
|
1058
|
+
break;
|
|
1059
|
+
case 'Circle':
|
|
1060
|
+
const circle = /** @type {import("../geom/Circle.js").default} */ (
|
|
1061
|
+
geometry
|
|
1062
|
+
);
|
|
1063
|
+
segment[0] = vertex;
|
|
1064
|
+
segment[1] = vertex;
|
|
1065
|
+
if (segmentData.index === CIRCLE_CENTER_INDEX) {
|
|
1066
|
+
this.changingFeature_ = true;
|
|
1067
|
+
circle.setCenter(vertex);
|
|
1068
|
+
this.changingFeature_ = false;
|
|
1069
|
+
} else {
|
|
1070
|
+
// We're dragging the circle's circumference:
|
|
1071
|
+
this.changingFeature_ = true;
|
|
1072
|
+
const projection = evt.map.getView().getProjection();
|
|
1073
|
+
let radius = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.distance)(
|
|
1074
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(circle.getCenter(), projection),
|
|
1075
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(vertex, projection),
|
|
1076
|
+
);
|
|
1077
|
+
const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
1078
|
+
if (userProjection) {
|
|
1079
|
+
const circleGeometry = circle
|
|
1080
|
+
.clone()
|
|
1081
|
+
.transform(userProjection, projection);
|
|
1082
|
+
circleGeometry.setRadius(radius);
|
|
1083
|
+
radius = circleGeometry
|
|
1084
|
+
.transform(projection, userProjection)
|
|
1085
|
+
.getRadius();
|
|
1086
|
+
}
|
|
1087
|
+
circle.setRadius(radius);
|
|
1088
|
+
this.changingFeature_ = false;
|
|
1089
|
+
}
|
|
1090
|
+
break;
|
|
1091
|
+
default:
|
|
1092
|
+
// pass
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
if (coordinates) {
|
|
1096
|
+
this.setGeometryCoordinates_(geometry, coordinates);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
this.createOrUpdateVertexFeature_(vertex, features, geometries, true);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Handle pointer down events.
|
|
1104
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
1105
|
+
* @return {boolean} If the event was consumed.
|
|
1106
|
+
* @override
|
|
1107
|
+
*/
|
|
1108
|
+
handleDownEvent(evt) {
|
|
1109
|
+
if (!this.condition_(evt)) {
|
|
1110
|
+
return false;
|
|
1111
|
+
}
|
|
1112
|
+
const pixelCoordinate = evt.coordinate;
|
|
1113
|
+
const insertVertices =
|
|
1114
|
+
this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
|
|
1115
|
+
|
|
1116
|
+
if (insertVertices?.length && this.insertVertexCondition_(evt)) {
|
|
1117
|
+
this.willModifyFeatures_(evt, insertVertices);
|
|
1118
|
+
|
|
1119
|
+
if (this.vertexFeature_) {
|
|
1120
|
+
const vertex = this.vertexFeature_.getGeometry().getCoordinates();
|
|
1121
|
+
for (let j = insertVertices.length - 1; j >= 0; --j) {
|
|
1122
|
+
this.insertVertex_(insertVertices[j], vertex);
|
|
1123
|
+
}
|
|
1124
|
+
this.ignoreNextSingleClick_ = true;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
return !!this.vertexFeature_;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Handle pointer up events.
|
|
1133
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
1134
|
+
* @return {boolean} If the event was consumed.
|
|
1135
|
+
* @override
|
|
1136
|
+
*/
|
|
1137
|
+
handleUpEvent(evt) {
|
|
1138
|
+
for (let i = this.dragSegments_.length - 1; i >= 0; --i) {
|
|
1139
|
+
const segmentData = this.dragSegments_[i][0];
|
|
1140
|
+
const geometry = segmentData.geometry;
|
|
1141
|
+
if (geometry.getType() === 'Circle') {
|
|
1142
|
+
const circle = /** @type {import("../geom/Circle.js").default} */ (
|
|
1143
|
+
geometry
|
|
1144
|
+
);
|
|
1145
|
+
// Update a circle object in the R* bush:
|
|
1146
|
+
const coordinates = circle.getCenter();
|
|
1147
|
+
const centerSegmentData = segmentData.featureSegments[0];
|
|
1148
|
+
const circumferenceSegmentData = segmentData.featureSegments[1];
|
|
1149
|
+
centerSegmentData.segment[0] = coordinates;
|
|
1150
|
+
centerSegmentData.segment[1] = coordinates;
|
|
1151
|
+
circumferenceSegmentData.segment[0] = coordinates;
|
|
1152
|
+
circumferenceSegmentData.segment[1] = coordinates;
|
|
1153
|
+
this.rBush_.update((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.createOrUpdateFromCoordinate)(coordinates), centerSegmentData);
|
|
1154
|
+
/** @type {import("../geom/Circle.js").default | import("../geom/Polygon.js").default} */
|
|
1155
|
+
let circleGeometry = circle;
|
|
1156
|
+
const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
1157
|
+
if (userProjection) {
|
|
1158
|
+
const projection = evt.map.getView().getProjection();
|
|
1159
|
+
circleGeometry = circleGeometry
|
|
1160
|
+
.clone()
|
|
1161
|
+
.transform(userProjection, projection);
|
|
1162
|
+
circleGeometry = (0,_geom_Polygon_js__WEBPACK_IMPORTED_MODULE_12__.fromCircle)(circleGeometry).transform(
|
|
1163
|
+
projection,
|
|
1164
|
+
userProjection,
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
this.rBush_.update(
|
|
1168
|
+
circleGeometry.getExtent(),
|
|
1169
|
+
circumferenceSegmentData,
|
|
1170
|
+
);
|
|
1171
|
+
} else {
|
|
1172
|
+
this.rBush_.update((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(segmentData.segment), segmentData);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
if (this.featuresBeingModified_) {
|
|
1176
|
+
this.dispatchEvent(
|
|
1177
|
+
new ModifyEvent(
|
|
1178
|
+
ModifyEventType.MODIFYEND,
|
|
1179
|
+
this.featuresBeingModified_,
|
|
1180
|
+
evt,
|
|
1181
|
+
),
|
|
1182
|
+
);
|
|
1183
|
+
this.featuresBeingModified_ = null;
|
|
1184
|
+
}
|
|
1185
|
+
return false;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
1190
|
+
* @private
|
|
1191
|
+
*/
|
|
1192
|
+
handlePointerMove_(evt) {
|
|
1193
|
+
this.lastPixel_ = evt.pixel;
|
|
1194
|
+
this.handlePointerAtPixel_(evt.coordinate);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* @param {import("../coordinate.js").Coordinate} pixelCoordinate The pixel Coordinate.
|
|
1199
|
+
* @private
|
|
1200
|
+
*/
|
|
1201
|
+
handlePointerAtPixel_(pixelCoordinate) {
|
|
1202
|
+
const map = this.getMap();
|
|
1203
|
+
const pixel = map.getPixelFromCoordinate(pixelCoordinate);
|
|
1204
|
+
const projection = map.getView().getProjection();
|
|
1205
|
+
const sortByDistance = function (a, b) {
|
|
1206
|
+
return (
|
|
1207
|
+
projectedDistanceToSegmentDataSquared(pixelCoordinate, a, projection) -
|
|
1208
|
+
projectedDistanceToSegmentDataSquared(pixelCoordinate, b, projection)
|
|
1209
|
+
);
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
/** @type {Array<SegmentData>|undefined} */
|
|
1213
|
+
let nodes;
|
|
1214
|
+
/** @type {Point|undefined} */
|
|
1215
|
+
let hitPointGeometry;
|
|
1216
|
+
if (this.hitDetection_) {
|
|
1217
|
+
const layerFilter =
|
|
1218
|
+
typeof this.hitDetection_ === 'object'
|
|
1219
|
+
? (layer) => layer === this.hitDetection_
|
|
1220
|
+
: undefined;
|
|
1221
|
+
map.forEachFeatureAtPixel(
|
|
1222
|
+
pixel,
|
|
1223
|
+
(feature, layer, geometry) => {
|
|
1224
|
+
if (geometry && geometry.getType() === 'Point') {
|
|
1225
|
+
geometry = new _geom_Point_js__WEBPACK_IMPORTED_MODULE_14__["default"](
|
|
1226
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserCoordinate)(geometry.getCoordinates(), projection),
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
const geom = geometry || feature.getGeometry();
|
|
1230
|
+
|
|
1231
|
+
if (
|
|
1232
|
+
geom &&
|
|
1233
|
+
geom.getType() === 'Point' &&
|
|
1234
|
+
feature instanceof _Feature_js__WEBPACK_IMPORTED_MODULE_13__["default"] &&
|
|
1235
|
+
this.features_.getArray().includes(feature)
|
|
1236
|
+
) {
|
|
1237
|
+
hitPointGeometry = /** @type {Point} */ (geom);
|
|
1238
|
+
const coordinate = /** @type {Point} */ (feature.getGeometry())
|
|
1239
|
+
.getFlatCoordinates()
|
|
1240
|
+
.slice(0, 2);
|
|
1241
|
+
nodes = [
|
|
1242
|
+
{
|
|
1243
|
+
feature,
|
|
1244
|
+
geometry: hitPointGeometry,
|
|
1245
|
+
segment: [coordinate, coordinate],
|
|
1246
|
+
},
|
|
1247
|
+
];
|
|
1248
|
+
}
|
|
1249
|
+
return true;
|
|
1250
|
+
},
|
|
1251
|
+
{layerFilter},
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
if (!nodes) {
|
|
1255
|
+
const viewExtent = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserExtent)(
|
|
1256
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.createOrUpdateFromCoordinate)(pixelCoordinate, tempExtent),
|
|
1257
|
+
projection,
|
|
1258
|
+
);
|
|
1259
|
+
const buffer = map.getView().getResolution() * this.pixelTolerance_;
|
|
1260
|
+
const box = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserExtent)(
|
|
1261
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.buffer)(viewExtent, buffer, tempExtent),
|
|
1262
|
+
projection,
|
|
1263
|
+
);
|
|
1264
|
+
nodes = this.rBush_.getInExtent(box);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
if (nodes && nodes.length > 0) {
|
|
1268
|
+
const node = nodes.sort(sortByDistance)[0];
|
|
1269
|
+
const closestSegment = node.segment;
|
|
1270
|
+
let vertex = closestOnSegmentData(pixelCoordinate, node, projection);
|
|
1271
|
+
const vertexPixel = map.getPixelFromCoordinate(vertex);
|
|
1272
|
+
let dist = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.distance)(pixel, vertexPixel);
|
|
1273
|
+
if (hitPointGeometry || dist <= this.pixelTolerance_) {
|
|
1274
|
+
/** @type {Object<string, boolean>} */
|
|
1275
|
+
const vertexSegments = {};
|
|
1276
|
+
vertexSegments[(0,_util_js__WEBPACK_IMPORTED_MODULE_16__.getUid)(closestSegment)] = true;
|
|
1277
|
+
|
|
1278
|
+
if (!this.snapToPointer_) {
|
|
1279
|
+
this.delta_[0] = vertex[0] - pixelCoordinate[0];
|
|
1280
|
+
this.delta_[1] = vertex[1] - pixelCoordinate[1];
|
|
1281
|
+
}
|
|
1282
|
+
if (
|
|
1283
|
+
node.geometry.getType() === 'Circle' &&
|
|
1284
|
+
node.index === CIRCLE_CIRCUMFERENCE_INDEX
|
|
1285
|
+
) {
|
|
1286
|
+
this.snappedToVertex_ = true;
|
|
1287
|
+
this.createOrUpdateVertexFeature_(
|
|
1288
|
+
vertex,
|
|
1289
|
+
[node.feature],
|
|
1290
|
+
[node.geometry],
|
|
1291
|
+
this.snappedToVertex_,
|
|
1292
|
+
);
|
|
1293
|
+
} else {
|
|
1294
|
+
const pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
|
1295
|
+
const pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
|
|
1296
|
+
const squaredDist1 = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.squaredDistance)(vertexPixel, pixel1);
|
|
1297
|
+
const squaredDist2 = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.squaredDistance)(vertexPixel, pixel2);
|
|
1298
|
+
dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
|
|
1299
|
+
this.snappedToVertex_ = dist <= this.pixelTolerance_;
|
|
1300
|
+
// Stop and cleanup overlay vertex feature if a segment was hit and new vertex creation is not allowed by the insertVertexCondition
|
|
1301
|
+
if (
|
|
1302
|
+
!this.snappedToVertex_ &&
|
|
1303
|
+
!this.insertVertexCondition_(this.lastPointerEvent_)
|
|
1304
|
+
) {
|
|
1305
|
+
if (this.vertexFeature_) {
|
|
1306
|
+
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
|
1307
|
+
this.vertexFeature_ = null;
|
|
1308
|
+
}
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
if (this.snappedToVertex_) {
|
|
1312
|
+
vertex =
|
|
1313
|
+
squaredDist1 > squaredDist2
|
|
1314
|
+
? closestSegment[1]
|
|
1315
|
+
: closestSegment[0];
|
|
1316
|
+
}
|
|
1317
|
+
this.createOrUpdateVertexFeature_(
|
|
1318
|
+
vertex,
|
|
1319
|
+
[node.feature],
|
|
1320
|
+
[node.geometry],
|
|
1321
|
+
this.snappedToVertex_,
|
|
1322
|
+
);
|
|
1323
|
+
const geometries = {};
|
|
1324
|
+
geometries[(0,_util_js__WEBPACK_IMPORTED_MODULE_16__.getUid)(node.geometry)] = true;
|
|
1325
|
+
for (let i = 1, ii = nodes.length; i < ii; ++i) {
|
|
1326
|
+
const segment = nodes[i].segment;
|
|
1327
|
+
if (
|
|
1328
|
+
((0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(closestSegment[0], segment[0]) &&
|
|
1329
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(closestSegment[1], segment[1])) ||
|
|
1330
|
+
((0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(closestSegment[0], segment[1]) &&
|
|
1331
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(closestSegment[1], segment[0]))
|
|
1332
|
+
) {
|
|
1333
|
+
const geometryUid = (0,_util_js__WEBPACK_IMPORTED_MODULE_16__.getUid)(nodes[i].geometry);
|
|
1334
|
+
if (!(geometryUid in geometries)) {
|
|
1335
|
+
geometries[geometryUid] = true;
|
|
1336
|
+
vertexSegments[(0,_util_js__WEBPACK_IMPORTED_MODULE_16__.getUid)(segment)] = true;
|
|
1337
|
+
}
|
|
1338
|
+
} else {
|
|
1339
|
+
break;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
this.vertexSegments_ = vertexSegments;
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (this.vertexFeature_) {
|
|
1349
|
+
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
|
1350
|
+
this.vertexFeature_ = null;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* @param {SegmentData} segmentData Segment data.
|
|
1356
|
+
* @param {import("../coordinate.js").Coordinate} vertex Vertex.
|
|
1357
|
+
* @return {boolean} A vertex was inserted.
|
|
1358
|
+
* @private
|
|
1359
|
+
*/
|
|
1360
|
+
insertVertex_(segmentData, vertex) {
|
|
1361
|
+
const segment = segmentData.segment;
|
|
1362
|
+
const feature = segmentData.feature;
|
|
1363
|
+
const geometry = segmentData.geometry;
|
|
1364
|
+
const depth = segmentData.depth;
|
|
1365
|
+
const index = segmentData.index;
|
|
1366
|
+
let coordinates;
|
|
1367
|
+
|
|
1368
|
+
while (vertex.length < geometry.getStride()) {
|
|
1369
|
+
vertex.push(0);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
switch (geometry.getType()) {
|
|
1373
|
+
case 'MultiLineString':
|
|
1374
|
+
coordinates = geometry.getCoordinates();
|
|
1375
|
+
coordinates[depth[0]].splice(index + 1, 0, vertex);
|
|
1376
|
+
break;
|
|
1377
|
+
case 'Polygon':
|
|
1378
|
+
coordinates = geometry.getCoordinates();
|
|
1379
|
+
coordinates[depth[0]].splice(index + 1, 0, vertex);
|
|
1380
|
+
break;
|
|
1381
|
+
case 'MultiPolygon':
|
|
1382
|
+
coordinates = geometry.getCoordinates();
|
|
1383
|
+
coordinates[depth[1]][depth[0]].splice(index + 1, 0, vertex);
|
|
1384
|
+
break;
|
|
1385
|
+
case 'LineString':
|
|
1386
|
+
coordinates = geometry.getCoordinates();
|
|
1387
|
+
coordinates.splice(index + 1, 0, vertex);
|
|
1388
|
+
break;
|
|
1389
|
+
default:
|
|
1390
|
+
return false;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
this.setGeometryCoordinates_(geometry, coordinates);
|
|
1394
|
+
const rTree = this.rBush_;
|
|
1395
|
+
rTree.remove(segmentData);
|
|
1396
|
+
this.updateSegmentIndices_(geometry, index, depth, 1);
|
|
1397
|
+
|
|
1398
|
+
/** @type {SegmentData} */
|
|
1399
|
+
const newSegmentData = {
|
|
1400
|
+
segment: [segment[0], vertex],
|
|
1401
|
+
feature: feature,
|
|
1402
|
+
geometry: geometry,
|
|
1403
|
+
depth: depth,
|
|
1404
|
+
index: index,
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
rTree.insert((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(newSegmentData.segment), newSegmentData);
|
|
1408
|
+
this.dragSegments_.push([newSegmentData, 1]);
|
|
1409
|
+
|
|
1410
|
+
/** @type {SegmentData} */
|
|
1411
|
+
const newSegmentData2 = {
|
|
1412
|
+
segment: [vertex, segment[1]],
|
|
1413
|
+
feature: feature,
|
|
1414
|
+
geometry: geometry,
|
|
1415
|
+
depth: depth,
|
|
1416
|
+
index: index + 1,
|
|
1417
|
+
};
|
|
1418
|
+
|
|
1419
|
+
rTree.insert((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(newSegmentData2.segment), newSegmentData2);
|
|
1420
|
+
this.dragSegments_.push([newSegmentData2, 0]);
|
|
1421
|
+
return true;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
updatePointer_(coordinate) {
|
|
1425
|
+
if (coordinate) {
|
|
1426
|
+
this.findInsertVerticesAndUpdateDragSegments_(coordinate);
|
|
1427
|
+
}
|
|
1428
|
+
return this.vertexFeature_?.getGeometry().getCoordinates();
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* Get the current pointer position.
|
|
1433
|
+
* @return {import("../coordinate.js").Coordinate | null} The current pointer coordinate.
|
|
1434
|
+
*/
|
|
1435
|
+
getPoint() {
|
|
1436
|
+
const coordinate = this.vertexFeature_?.getGeometry().getCoordinates();
|
|
1437
|
+
if (!coordinate) {
|
|
1438
|
+
return null;
|
|
1439
|
+
}
|
|
1440
|
+
return (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserCoordinate)(
|
|
1441
|
+
coordinate,
|
|
1442
|
+
this.getMap().getView().getProjection(),
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Check if a point can be removed from the current linestring or polygon at the current
|
|
1448
|
+
* pointer position.
|
|
1449
|
+
* @return {boolean} A point can be deleted at the current pointer position.
|
|
1450
|
+
* @api
|
|
1451
|
+
*/
|
|
1452
|
+
canRemovePoint() {
|
|
1453
|
+
if (!this.vertexFeature_) {
|
|
1454
|
+
return false;
|
|
1455
|
+
}
|
|
1456
|
+
if (
|
|
1457
|
+
this.vertexFeature_
|
|
1458
|
+
.get('geometries')
|
|
1459
|
+
.every(
|
|
1460
|
+
(geometry) =>
|
|
1461
|
+
geometry.getType() === 'Circle' ||
|
|
1462
|
+
geometry.getType().endsWith('Point'),
|
|
1463
|
+
)
|
|
1464
|
+
) {
|
|
1465
|
+
return false;
|
|
1466
|
+
}
|
|
1467
|
+
const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
|
|
1468
|
+
const segments = this.rBush_.getInExtent((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)([coordinate]));
|
|
1469
|
+
return segments.some(
|
|
1470
|
+
({segment}) =>
|
|
1471
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(segment[0], coordinate) ||
|
|
1472
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(segment[1], coordinate),
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* Removes the vertex currently being pointed from the current linestring or polygon.
|
|
1478
|
+
* @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
|
|
1479
|
+
* will be set to the provided coordinate. If not, the current pointer coordinate will be used.
|
|
1480
|
+
* @return {boolean} True when a vertex was removed.
|
|
1481
|
+
* @api
|
|
1482
|
+
*/
|
|
1483
|
+
removePoint(coordinate) {
|
|
1484
|
+
if (coordinate) {
|
|
1485
|
+
coordinate = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(
|
|
1486
|
+
coordinate,
|
|
1487
|
+
this.getMap().getView().getProjection(),
|
|
1488
|
+
);
|
|
1489
|
+
this.updatePointer_(coordinate);
|
|
1490
|
+
}
|
|
1491
|
+
if (
|
|
1492
|
+
!this.lastPointerEvent_ ||
|
|
1493
|
+
(this.lastPointerEvent_ &&
|
|
1494
|
+
this.lastPointerEvent_.type != _MapBrowserEventType_js__WEBPACK_IMPORTED_MODULE_15__["default"].POINTERDRAG)
|
|
1495
|
+
) {
|
|
1496
|
+
const evt = this.lastPointerEvent_;
|
|
1497
|
+
this.willModifyFeatures_(
|
|
1498
|
+
evt,
|
|
1499
|
+
this.dragSegments_.map(([segment]) => segment),
|
|
1500
|
+
);
|
|
1501
|
+
const removed = this.removeVertex_();
|
|
1502
|
+
if (this.featuresBeingModified_) {
|
|
1503
|
+
this.dispatchEvent(
|
|
1504
|
+
new ModifyEvent(
|
|
1505
|
+
ModifyEventType.MODIFYEND,
|
|
1506
|
+
this.featuresBeingModified_,
|
|
1507
|
+
evt,
|
|
1508
|
+
),
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
this.featuresBeingModified_ = null;
|
|
1513
|
+
return removed;
|
|
1514
|
+
}
|
|
1515
|
+
return false;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* Removes a vertex from all matching features.
|
|
1520
|
+
* @return {boolean} True when a vertex was removed.
|
|
1521
|
+
* @private
|
|
1522
|
+
*/
|
|
1523
|
+
removeVertex_() {
|
|
1524
|
+
const dragSegments = this.dragSegments_;
|
|
1525
|
+
const segmentsByFeature = {};
|
|
1526
|
+
let deleted = false;
|
|
1527
|
+
let component, coordinates, dragSegment, geometry, i, index, left;
|
|
1528
|
+
let newIndex, right, segmentData, uid;
|
|
1529
|
+
for (i = dragSegments.length - 1; i >= 0; --i) {
|
|
1530
|
+
dragSegment = dragSegments[i];
|
|
1531
|
+
segmentData = dragSegment[0];
|
|
1532
|
+
uid = (0,_util_js__WEBPACK_IMPORTED_MODULE_16__.getUid)(segmentData.feature);
|
|
1533
|
+
if (segmentData.depth) {
|
|
1534
|
+
// separate feature components
|
|
1535
|
+
uid += '-' + segmentData.depth.join('-');
|
|
1536
|
+
}
|
|
1537
|
+
if (!(uid in segmentsByFeature)) {
|
|
1538
|
+
segmentsByFeature[uid] = {};
|
|
1539
|
+
}
|
|
1540
|
+
if (dragSegment[1] === 0) {
|
|
1541
|
+
segmentsByFeature[uid].right = segmentData;
|
|
1542
|
+
segmentsByFeature[uid].index = segmentData.index;
|
|
1543
|
+
} else if (dragSegment[1] == 1) {
|
|
1544
|
+
segmentsByFeature[uid].left = segmentData;
|
|
1545
|
+
segmentsByFeature[uid].index = segmentData.index + 1;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
for (uid in segmentsByFeature) {
|
|
1549
|
+
right = segmentsByFeature[uid].right;
|
|
1550
|
+
left = segmentsByFeature[uid].left;
|
|
1551
|
+
index = segmentsByFeature[uid].index;
|
|
1552
|
+
newIndex = index - 1;
|
|
1553
|
+
if (left !== undefined) {
|
|
1554
|
+
segmentData = left;
|
|
1555
|
+
} else {
|
|
1556
|
+
segmentData = right;
|
|
1557
|
+
}
|
|
1558
|
+
if (newIndex < 0) {
|
|
1559
|
+
newIndex = 0;
|
|
1560
|
+
}
|
|
1561
|
+
geometry = segmentData.geometry;
|
|
1562
|
+
coordinates = geometry.getCoordinates();
|
|
1563
|
+
component = coordinates;
|
|
1564
|
+
deleted = false;
|
|
1565
|
+
switch (geometry.getType()) {
|
|
1566
|
+
case 'MultiLineString':
|
|
1567
|
+
if (coordinates[segmentData.depth[0]].length > 2) {
|
|
1568
|
+
coordinates[segmentData.depth[0]].splice(index, 1);
|
|
1569
|
+
deleted = true;
|
|
1570
|
+
}
|
|
1571
|
+
break;
|
|
1572
|
+
case 'LineString':
|
|
1573
|
+
if (coordinates.length > 2) {
|
|
1574
|
+
coordinates.splice(index, 1);
|
|
1575
|
+
deleted = true;
|
|
1576
|
+
}
|
|
1577
|
+
break;
|
|
1578
|
+
case 'MultiPolygon':
|
|
1579
|
+
component = component[segmentData.depth[1]];
|
|
1580
|
+
/* falls through */
|
|
1581
|
+
case 'Polygon':
|
|
1582
|
+
component = component[segmentData.depth[0]];
|
|
1583
|
+
if (component.length > 4) {
|
|
1584
|
+
if (index == component.length - 1) {
|
|
1585
|
+
index = 0;
|
|
1586
|
+
}
|
|
1587
|
+
component.splice(index, 1);
|
|
1588
|
+
deleted = true;
|
|
1589
|
+
if (index === 0) {
|
|
1590
|
+
// close the ring again
|
|
1591
|
+
component.pop();
|
|
1592
|
+
component.push(component[0]);
|
|
1593
|
+
newIndex = component.length - 1;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
break;
|
|
1597
|
+
default:
|
|
1598
|
+
// pass
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
if (deleted) {
|
|
1602
|
+
this.setGeometryCoordinates_(geometry, coordinates);
|
|
1603
|
+
const segments = [];
|
|
1604
|
+
if (left !== undefined) {
|
|
1605
|
+
this.rBush_.remove(left);
|
|
1606
|
+
segments.push(left.segment[0]);
|
|
1607
|
+
}
|
|
1608
|
+
if (right !== undefined) {
|
|
1609
|
+
this.rBush_.remove(right);
|
|
1610
|
+
segments.push(right.segment[1]);
|
|
1611
|
+
}
|
|
1612
|
+
if (left !== undefined && right !== undefined) {
|
|
1613
|
+
/** @type {SegmentData} */
|
|
1614
|
+
const newSegmentData = {
|
|
1615
|
+
depth: segmentData.depth,
|
|
1616
|
+
feature: segmentData.feature,
|
|
1617
|
+
geometry: segmentData.geometry,
|
|
1618
|
+
index: newIndex,
|
|
1619
|
+
segment: segments,
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
this.rBush_.insert(
|
|
1623
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)(newSegmentData.segment),
|
|
1624
|
+
newSegmentData,
|
|
1625
|
+
);
|
|
1626
|
+
}
|
|
1627
|
+
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
|
|
1628
|
+
if (this.vertexFeature_) {
|
|
1629
|
+
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
|
1630
|
+
this.vertexFeature_ = null;
|
|
1631
|
+
}
|
|
1632
|
+
dragSegments.length = 0;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
return deleted;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* Check if a point can be inserted to the current linestring or polygon at the current
|
|
1640
|
+
* pointer position.
|
|
1641
|
+
* @return {boolean} A point can be inserted at the current pointer position.
|
|
1642
|
+
* @api
|
|
1643
|
+
*/
|
|
1644
|
+
canInsertPoint() {
|
|
1645
|
+
if (!this.vertexFeature_) {
|
|
1646
|
+
return false;
|
|
1647
|
+
}
|
|
1648
|
+
if (
|
|
1649
|
+
this.vertexFeature_
|
|
1650
|
+
.get('geometries')
|
|
1651
|
+
.every(
|
|
1652
|
+
(geometry) =>
|
|
1653
|
+
geometry.getType() === 'Circle' ||
|
|
1654
|
+
geometry.getType().endsWith('Point'),
|
|
1655
|
+
)
|
|
1656
|
+
) {
|
|
1657
|
+
return false;
|
|
1658
|
+
}
|
|
1659
|
+
const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
|
|
1660
|
+
const segments = this.rBush_.getInExtent((0,_extent_js__WEBPACK_IMPORTED_MODULE_11__.boundingExtent)([coordinate]));
|
|
1661
|
+
return segments.some(
|
|
1662
|
+
({segment}) =>
|
|
1663
|
+
!(
|
|
1664
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(segment[0], coordinate) ||
|
|
1665
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.equals)(segment[1], coordinate)
|
|
1666
|
+
),
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* Inserts the vertex currently being pointed to the current linestring or polygon.
|
|
1672
|
+
* @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
|
|
1673
|
+
* will be set to the provided coordinate. If not, the current pointer coordinate will be used.
|
|
1674
|
+
* @return {boolean} A vertex was inserted.
|
|
1675
|
+
* @api
|
|
1676
|
+
*/
|
|
1677
|
+
insertPoint(coordinate) {
|
|
1678
|
+
const pixelCoordinate = coordinate
|
|
1679
|
+
? (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(coordinate, this.getMap().getView().getProjection())
|
|
1680
|
+
: this.vertexFeature_?.getGeometry().getCoordinates();
|
|
1681
|
+
if (!pixelCoordinate) {
|
|
1682
|
+
return false;
|
|
1683
|
+
}
|
|
1684
|
+
const insertVertices =
|
|
1685
|
+
this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
|
|
1686
|
+
return insertVertices.reduce(
|
|
1687
|
+
(prev, segmentData) =>
|
|
1688
|
+
prev || this.insertVertex_(segmentData, pixelCoordinate),
|
|
1689
|
+
false,
|
|
1690
|
+
);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
1695
|
+
* @param {Array} coordinates Coordinates.
|
|
1696
|
+
* @private
|
|
1697
|
+
*/
|
|
1698
|
+
setGeometryCoordinates_(geometry, coordinates) {
|
|
1699
|
+
this.changingFeature_ = true;
|
|
1700
|
+
geometry.setCoordinates(coordinates);
|
|
1701
|
+
this.changingFeature_ = false;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
/**
|
|
1705
|
+
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
1706
|
+
* @param {number} index Index.
|
|
1707
|
+
* @param {Array<number>|undefined} depth Depth.
|
|
1708
|
+
* @param {number} delta Delta (1 or -1).
|
|
1709
|
+
* @private
|
|
1710
|
+
*/
|
|
1711
|
+
updateSegmentIndices_(geometry, index, depth, delta) {
|
|
1712
|
+
this.rBush_.forEachInExtent(
|
|
1713
|
+
geometry.getExtent(),
|
|
1714
|
+
function (segmentDataMatch) {
|
|
1715
|
+
if (
|
|
1716
|
+
segmentDataMatch.geometry === geometry &&
|
|
1717
|
+
(depth === undefined ||
|
|
1718
|
+
segmentDataMatch.depth === undefined ||
|
|
1719
|
+
(0,_array_js__WEBPACK_IMPORTED_MODULE_18__.equals)(segmentDataMatch.depth, depth)) &&
|
|
1720
|
+
segmentDataMatch.index > index
|
|
1721
|
+
) {
|
|
1722
|
+
segmentDataMatch.index += delta;
|
|
1723
|
+
}
|
|
1724
|
+
},
|
|
1725
|
+
);
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
* @param {SegmentData} a The first segment data.
|
|
1731
|
+
* @param {SegmentData} b The second segment data.
|
|
1732
|
+
* @return {number} The difference in indexes.
|
|
1733
|
+
*/
|
|
1734
|
+
function compareIndexes(a, b) {
|
|
1735
|
+
return a.index - b.index;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* Returns the distance from a point to a line segment.
|
|
1740
|
+
*
|
|
1741
|
+
* @param {import("../coordinate.js").Coordinate} pointCoordinates The coordinates of the point from
|
|
1742
|
+
* which to calculate the distance.
|
|
1743
|
+
* @param {SegmentData} segmentData The object describing the line
|
|
1744
|
+
* segment we are calculating the distance to.
|
|
1745
|
+
* @param {import("../proj/Projection.js").default} projection The view projection.
|
|
1746
|
+
* @return {number} The square of the distance between a point and a line segment.
|
|
1747
|
+
*/
|
|
1748
|
+
function projectedDistanceToSegmentDataSquared(
|
|
1749
|
+
pointCoordinates,
|
|
1750
|
+
segmentData,
|
|
1751
|
+
projection,
|
|
1752
|
+
) {
|
|
1753
|
+
const geometry = segmentData.geometry;
|
|
1754
|
+
|
|
1755
|
+
if (geometry.getType() === 'Circle') {
|
|
1756
|
+
let circleGeometry = /** @type {import("../geom/Circle.js").default} */ (
|
|
1757
|
+
geometry
|
|
1758
|
+
);
|
|
1759
|
+
|
|
1760
|
+
if (segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
|
|
1761
|
+
const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
1762
|
+
if (userProjection) {
|
|
1763
|
+
circleGeometry = circleGeometry
|
|
1764
|
+
.clone()
|
|
1765
|
+
.transform(userProjection, projection);
|
|
1766
|
+
}
|
|
1767
|
+
const distanceToCenterSquared = (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.squaredDistance)(
|
|
1768
|
+
circleGeometry.getCenter(),
|
|
1769
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(pointCoordinates, projection),
|
|
1770
|
+
);
|
|
1771
|
+
const distanceToCircumference =
|
|
1772
|
+
Math.sqrt(distanceToCenterSquared) - circleGeometry.getRadius();
|
|
1773
|
+
return distanceToCircumference * distanceToCircumference;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
const coordinate = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(pointCoordinates, projection);
|
|
1778
|
+
tempSegment[0] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentData.segment[0], projection);
|
|
1779
|
+
tempSegment[1] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentData.segment[1], projection);
|
|
1780
|
+
return (0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.squaredDistanceToSegment)(coordinate, tempSegment);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
/**
|
|
1784
|
+
* Returns the point closest to a given line segment.
|
|
1785
|
+
*
|
|
1786
|
+
* @param {import("../coordinate.js").Coordinate} pointCoordinates The point to which a closest point
|
|
1787
|
+
* should be found.
|
|
1788
|
+
* @param {SegmentData} segmentData The object describing the line
|
|
1789
|
+
* segment which should contain the closest point.
|
|
1790
|
+
* @param {import("../proj/Projection.js").default} projection The view projection.
|
|
1791
|
+
* @return {import("../coordinate.js").Coordinate} The point closest to the specified line segment.
|
|
1792
|
+
*/
|
|
1793
|
+
function closestOnSegmentData(pointCoordinates, segmentData, projection) {
|
|
1794
|
+
const geometry = segmentData.geometry;
|
|
1795
|
+
|
|
1796
|
+
if (
|
|
1797
|
+
geometry.getType() === 'Circle' &&
|
|
1798
|
+
segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX
|
|
1799
|
+
) {
|
|
1800
|
+
let circleGeometry = /** @type {import("../geom/Circle.js").default} */ (
|
|
1801
|
+
geometry
|
|
1802
|
+
);
|
|
1803
|
+
const userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
1804
|
+
if (userProjection) {
|
|
1805
|
+
circleGeometry = circleGeometry
|
|
1806
|
+
.clone()
|
|
1807
|
+
.transform(userProjection, projection);
|
|
1808
|
+
}
|
|
1809
|
+
return (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserCoordinate)(
|
|
1810
|
+
circleGeometry.getClosestPoint(
|
|
1811
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(pointCoordinates, projection),
|
|
1812
|
+
),
|
|
1813
|
+
projection,
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
const coordinate = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(pointCoordinates, projection);
|
|
1817
|
+
tempSegment[0] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentData.segment[0], projection);
|
|
1818
|
+
tempSegment[1] = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserCoordinate)(segmentData.segment[1], projection);
|
|
1819
|
+
return (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserCoordinate)(
|
|
1820
|
+
(0,_coordinate_js__WEBPACK_IMPORTED_MODULE_17__.closestOnSegment)(coordinate, tempSegment),
|
|
1821
|
+
projection,
|
|
1822
|
+
);
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* @return {import("../style/Style.js").StyleFunction} Styles.
|
|
1827
|
+
*/
|
|
1828
|
+
function getDefaultStyleFunction() {
|
|
1829
|
+
const style = (0,_style_Style_js__WEBPACK_IMPORTED_MODULE_19__.createEditingStyle)();
|
|
1830
|
+
return function (feature, resolution) {
|
|
1831
|
+
return style['Point'];
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Modify);
|
|
1836
|
+
|
|
1837
|
+
|
|
1838
|
+
/***/ })
|
|
1839
|
+
|
|
1840
|
+
}])
|
|
1841
|
+
//# sourceMappingURL=vendors-node_modules_ol_interaction_Modify_js.js.map
|