@hybridcore/ui 1.0.2 → 1.1.2
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/dist/ButtonBase-BYmh3G5j.js +967 -0
- package/dist/CardContent-C8PxkJz4.js +73 -0
- package/dist/Checkbox-DostZSwR.js +673 -0
- package/dist/DialogContent-2aPOjKE7.js +2025 -0
- package/dist/FormControl-BiAFm76F.js +1491 -0
- package/dist/IconButton-CQJ8wZE8.js +183 -0
- package/dist/Input-Bf5G3tFN.js +324 -0
- package/dist/OutlinedInput-BEVE8VZQ.js +452 -0
- package/dist/Paper-CaiWdndQ.js +162 -0
- package/dist/Select-DxpxZbJp.js +2526 -0
- package/dist/Source-CnCcu5UP.js +4374 -0
- package/dist/Text-BT5kPHOo.js +2192 -0
- package/dist/Typography-XIiVCSto.js +178 -0
- package/dist/assertThisInitialized-BUtkG-md.js +13 -0
- package/dist/assets/index.css +1 -0
- package/dist/assets/index2.css +1 -0
- package/dist/chainPropTypes-DtBfUj5o.js +96 -0
- package/dist/components/access/helpers.js +32 -0
- package/dist/components/access/index.js +15 -0
- package/dist/components/card/index.js +159 -469
- package/dist/components/card/styled.js +75 -7
- package/dist/components/conditional-wrapper/index.js +9 -0
- package/dist/components/confirm/dialog.js +151 -0
- package/dist/components/confirm/index.js +23 -0
- package/dist/components/container/index.js +270 -0
- package/dist/components/context-menu/index.js +973 -0
- package/dist/components/data-management/instance-form/components/composite-list/index.js +12 -0
- package/dist/components/data-management/instance-form/components/composite-list/styled.js +64 -0
- package/dist/components/data-management/instance-form/components/policy-list/index.js +86 -0
- package/dist/components/data-management/instance-form/components/variable/index.js +15 -0
- package/dist/components/data-management/instance-form/components/variables/index.js +39 -0
- package/dist/components/data-management/instance-form/index.js +437 -0
- package/dist/components/data-security-selectors/dissemination-list/index.js +3201 -0
- package/dist/components/data-security-selectors/security-level/index.js +81 -0
- package/dist/components/date-time-picker/index.js +103 -0
- package/dist/components/geometry-picker/coordinate/index.js +93 -0
- package/dist/components/geometry-picker/edit/index.js +71 -0
- package/dist/components/geometry-picker/geometry/index.js +160 -0
- package/dist/components/geometry-picker/geometry/map-overlay.js +22 -0
- package/dist/components/geometry-picker/index.js +140 -0
- package/dist/components/geometry-picker/kml/index.js +62 -0
- package/dist/components/geometry-picker/kml/select-input-method.js +75 -0
- package/dist/components/geometry-picker/logic.js +69 -0
- package/dist/components/geometry-picker/map/index.js +42 -0
- package/dist/components/geometry-picker/map/logic.js +2360 -0
- package/dist/components/geometry-picker/map/style.js +88 -0
- package/dist/components/geometry-picker/parser/coordinate-input/index.js +78 -0
- package/dist/components/geometry-picker/parser/coordinate-input/logic.js +1305 -0
- package/dist/components/geometry-picker/parser/index.js +179 -0
- package/dist/components/geometry-picker/parser/logic.js +84 -0
- package/dist/components/geometry-picker/parser/styled.js +25 -0
- package/dist/components/geometry-picker/styled.js +48 -0
- package/dist/components/geometry-picker/wkt/index.js +59 -0
- package/dist/components/geometry-picker/wkt/select-input-method.js +75 -0
- package/dist/components/icon-button/index.js +18 -0
- package/dist/components/icon-button/styled.js +51 -0
- package/dist/components/key-protection/index.js +4 -0
- package/dist/components/key-protection/menu.js +85 -0
- package/dist/components/key-protection/utils.js +10 -0
- package/dist/components/loading/index.js +7 -0
- package/dist/components/loading/styled.js +16 -0
- package/dist/components/map/helpers/kml.js +45 -0
- package/dist/components/map/helpers/mapbox.js +48 -0
- package/dist/components/map/helpers/ol.js +25 -0
- package/dist/components/map/helpers/wkt.js +29 -0
- package/dist/components/map/index.js +8 -0
- package/dist/components/map/logic.js +140 -0
- package/dist/components/map/styled.js +8 -0
- package/dist/components/phone-input/index.js +25 -0
- package/dist/components/phone-input/styled.js +26 -0
- package/dist/components/search-input/index.js +76 -0
- package/dist/components/tree-select/index.js +70 -0
- package/dist/components/tree-select/styled.js +64 -0
- package/dist/components/treeview-filter/index.js +621 -0
- package/dist/components/treeview-filter/item/index.js +7 -0
- package/dist/components/treeview-filter/item-label/index.js +44 -0
- package/dist/createTheme-agWfFD64.js +2392 -0
- package/dist/exactProp-CI8dagM-.js +36 -0
- package/dist/extends-C3382pL0.js +22 -0
- package/dist/has-9_asnBxn.js +688 -0
- package/dist/hooks/useMenuLogic.js +21 -0
- package/dist/hooks/useToggle.js +23 -0
- package/dist/index-Bw_m9ult.js +1105 -0
- package/dist/index-IvOfmM1F.js +34 -0
- package/dist/index-wW2D1aTG.js +957 -0
- package/dist/isHostComponent-kiaBvYVo.js +6 -0
- package/dist/isMuiElement-CxT3_ACP.js +13 -0
- package/dist/listItemTextClasses-BvXFz-Oc.js +132 -0
- package/dist/main.d.ts +1317 -0
- package/dist/main.js +41 -2
- package/dist/ol-DXmSLlWv.js +15041 -0
- package/dist/ownerDocument-CUrv0DIK.js +6 -0
- package/dist/ownerWindow-niciwP7I.js +7 -0
- package/dist/styled-C43K9x7T.js +229 -0
- package/dist/styled-Iq9jsO4F.js +1033 -0
- package/dist/useFormControl-CatNKXAi.js +10 -0
- package/dist/useId-BHG98T5I.js +26 -0
- package/dist/useTheme-C0Dky5rV.js +17 -0
- package/dist/useTheme-CeyGVuQP.js +10 -0
- package/dist/useThemeProps-CzAjOL6F.js +26 -0
- package/dist/utils/ontology.js +37 -0
- package/dist/utils-Bq0ye5vf.js +115 -0
- package/dist/utils-DLpkeyhZ.js +365 -0
- package/package.json +26 -5
- package/dist/styled-BG5UIpPU.js +0 -3459
|
@@ -0,0 +1,2360 @@
|
|
|
1
|
+
import k from "react";
|
|
2
|
+
import { createMapboxLayer as Xe } from "../../map/helpers/mapbox.js";
|
|
3
|
+
import { I as $e, s as ke, n as ge, e as ve, C as fe, f as v, V as se, F as L, P as me, p as Ze, h as ze, i as _e, R as Ge, j as ye, k as J, M as D, l as Je, m as Qe, o as et, q as tt, L as z, r as it, t as Ie, u as Re, G as st, v as nt, b as Fe, a as rt } from "../../../ol-DXmSLlWv.js";
|
|
4
|
+
import { T as Q, g as F, c as ot, e as Te, B as ne, E as ee, a as at, F as Ae, t as ht, s as be, b as ct, l as q, u as oe } from "../../../has-9_asnBxn.js";
|
|
5
|
+
import { c as xe } from "../../../Text-BT5kPHOo.js";
|
|
6
|
+
import { defaultStyle as lt, selectStyleFunction as dt, markerStyle as ut } from "./style.js";
|
|
7
|
+
import { c as E, d as ae, P as U, e as te, f as C, g as I, h as ie, i as gt, j as Oe, k as Ne, s as R, l as Ve, m as ft, n as Se, o as je, p as _t, q as mt, r as yt } from "../../../Source-CnCcu5UP.js";
|
|
8
|
+
import { alert as xt } from "../../confirm/index.js";
|
|
9
|
+
const pt = {
|
|
10
|
+
/**
|
|
11
|
+
* Triggered when feature(s) has been (de)selected.
|
|
12
|
+
* @event SelectEvent#select
|
|
13
|
+
* @api
|
|
14
|
+
*/
|
|
15
|
+
SELECT: "select"
|
|
16
|
+
};
|
|
17
|
+
class Ct extends ne {
|
|
18
|
+
/**
|
|
19
|
+
* @param {SelectEventType} type The event type.
|
|
20
|
+
* @param {Array<import("../Feature.js").default>} selected Selected features.
|
|
21
|
+
* @param {Array<import("../Feature.js").default>} deselected Deselected features.
|
|
22
|
+
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Associated
|
|
23
|
+
* {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
|
24
|
+
*/
|
|
25
|
+
constructor(e, t, s, i) {
|
|
26
|
+
super(e), this.selected = t, this.deselected = s, this.mapBrowserEvent = i;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const W = {};
|
|
30
|
+
class pe extends $e {
|
|
31
|
+
/**
|
|
32
|
+
* @param {Options} [options] Options.
|
|
33
|
+
*/
|
|
34
|
+
constructor(e) {
|
|
35
|
+
super(), this.on, this.once, this.un, e = e || {}, this.boundAddFeature_ = this.addFeature_.bind(this), this.boundRemoveFeature_ = this.removeFeature_.bind(this), this.condition_ = e.condition ? e.condition : ke, this.addCondition_ = e.addCondition ? e.addCondition : ge, this.removeCondition_ = e.removeCondition ? e.removeCondition : ge, this.toggleCondition_ = e.toggleCondition ? e.toggleCondition : ve, this.multi_ = e.multi ? e.multi : !1, this.filter_ = e.filter ? e.filter : Q, this.hitTolerance_ = e.hitTolerance ? e.hitTolerance : 0, this.style_ = e.style !== void 0 ? e.style : Ft(), this.features_ = e.features || new fe();
|
|
36
|
+
let t;
|
|
37
|
+
if (e.layers)
|
|
38
|
+
if (typeof e.layers == "function")
|
|
39
|
+
t = e.layers;
|
|
40
|
+
else {
|
|
41
|
+
const s = e.layers;
|
|
42
|
+
t = function(i) {
|
|
43
|
+
return s.includes(i);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
t = Q;
|
|
48
|
+
this.layerFilter_ = t, this.featureLayerAssociation_ = {};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @param {import("../Feature.js").default} feature Feature.
|
|
52
|
+
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
addFeatureLayerAssociation_(e, t) {
|
|
56
|
+
this.featureLayerAssociation_[F(e)] = t;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get the selected features.
|
|
60
|
+
* @return {Collection<Feature>} Features collection.
|
|
61
|
+
* @api
|
|
62
|
+
*/
|
|
63
|
+
getFeatures() {
|
|
64
|
+
return this.features_;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns the Hit-detection tolerance.
|
|
68
|
+
* @return {number} Hit tolerance in pixels.
|
|
69
|
+
* @api
|
|
70
|
+
*/
|
|
71
|
+
getHitTolerance() {
|
|
72
|
+
return this.hitTolerance_;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns the associated {@link module:ol/layer/Vector~VectorLayer vector layer} of
|
|
76
|
+
* a selected feature.
|
|
77
|
+
* @param {import("../Feature.js").default} feature Feature
|
|
78
|
+
* @return {import('../layer/Vector.js').default} Layer.
|
|
79
|
+
* @api
|
|
80
|
+
*/
|
|
81
|
+
getLayer(e) {
|
|
82
|
+
return (
|
|
83
|
+
/** @type {import('../layer/Vector.js').default} */
|
|
84
|
+
this.featureLayerAssociation_[F(e)]
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Hit-detection tolerance. Pixels inside the radius around the given position
|
|
89
|
+
* will be checked for features.
|
|
90
|
+
* @param {number} hitTolerance Hit tolerance in pixels.
|
|
91
|
+
* @api
|
|
92
|
+
*/
|
|
93
|
+
setHitTolerance(e) {
|
|
94
|
+
this.hitTolerance_ = e;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Remove the interaction from its current map, if any, and attach it to a new
|
|
98
|
+
* map, if any. Pass `null` to just remove the interaction from the current map.
|
|
99
|
+
* @param {import("../Map.js").default|null} map Map.
|
|
100
|
+
* @api
|
|
101
|
+
*/
|
|
102
|
+
setMap(e) {
|
|
103
|
+
this.getMap() && this.style_ && this.features_.forEach(this.restorePreviousStyle_.bind(this)), super.setMap(e), e ? (this.features_.addEventListener(
|
|
104
|
+
v.ADD,
|
|
105
|
+
this.boundAddFeature_
|
|
106
|
+
), this.features_.addEventListener(
|
|
107
|
+
v.REMOVE,
|
|
108
|
+
this.boundRemoveFeature_
|
|
109
|
+
), this.style_ && this.features_.forEach(this.applySelectedStyle_.bind(this))) : (this.features_.removeEventListener(
|
|
110
|
+
v.ADD,
|
|
111
|
+
this.boundAddFeature_
|
|
112
|
+
), this.features_.removeEventListener(
|
|
113
|
+
v.REMOVE,
|
|
114
|
+
this.boundRemoveFeature_
|
|
115
|
+
));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
addFeature_(e) {
|
|
122
|
+
const t = e.element;
|
|
123
|
+
if (this.style_ && this.applySelectedStyle_(t), !this.getLayer(t)) {
|
|
124
|
+
const s = (
|
|
125
|
+
/** @type {VectorLayer} */
|
|
126
|
+
this.getMap().getAllLayers().find(function(i) {
|
|
127
|
+
if (i instanceof se && i.getSource() && i.getSource().hasFeature(t))
|
|
128
|
+
return i;
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
s && this.addFeatureLayerAssociation_(t, s);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
removeFeature_(e) {
|
|
139
|
+
this.style_ && this.restorePreviousStyle_(e.element);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @return {import("../style/Style.js").StyleLike|null} Select style.
|
|
143
|
+
*/
|
|
144
|
+
getStyle() {
|
|
145
|
+
return this.style_;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @param {Feature} feature Feature
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
applySelectedStyle_(e) {
|
|
152
|
+
const t = F(e);
|
|
153
|
+
t in W || (W[t] = e.getStyle()), e.setStyle(this.style_);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @param {Feature} feature Feature
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
restorePreviousStyle_(e) {
|
|
160
|
+
const t = this.getMap().getInteractions().getArray();
|
|
161
|
+
for (let i = t.length - 1; i >= 0; --i) {
|
|
162
|
+
const n = t[i];
|
|
163
|
+
if (n !== this && n instanceof pe && n.getStyle() && n.getFeatures().getArray().lastIndexOf(e) !== -1) {
|
|
164
|
+
e.setStyle(n.getStyle());
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const s = F(e);
|
|
169
|
+
e.setStyle(W[s]), delete W[s];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @param {Feature} feature Feature.
|
|
173
|
+
* @private
|
|
174
|
+
*/
|
|
175
|
+
removeFeatureLayerAssociation_(e) {
|
|
176
|
+
delete this.featureLayerAssociation_[F(e)];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may change the
|
|
180
|
+
* selected state of features.
|
|
181
|
+
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
|
|
182
|
+
* @return {boolean} `false` to stop event propagation.
|
|
183
|
+
*/
|
|
184
|
+
handleEvent(e) {
|
|
185
|
+
if (!this.condition_(e))
|
|
186
|
+
return !0;
|
|
187
|
+
const t = this.addCondition_(e), s = this.removeCondition_(e), i = this.toggleCondition_(e), n = !t && !s && !i, r = e.map, o = this.getFeatures(), a = [], h = [];
|
|
188
|
+
if (n) {
|
|
189
|
+
ot(this.featureLayerAssociation_), r.forEachFeatureAtPixel(
|
|
190
|
+
e.pixel,
|
|
191
|
+
/**
|
|
192
|
+
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
|
193
|
+
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
194
|
+
* @return {boolean|undefined} Continue to iterate over the features.
|
|
195
|
+
*/
|
|
196
|
+
(c, d) => {
|
|
197
|
+
if (!(!(c instanceof L) || !this.filter_(c, d)))
|
|
198
|
+
return this.addFeatureLayerAssociation_(c, d), h.push(c), !this.multi_;
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
layerFilter: this.layerFilter_,
|
|
202
|
+
hitTolerance: this.hitTolerance_
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
for (let c = o.getLength() - 1; c >= 0; --c) {
|
|
206
|
+
const d = o.item(c), g = h.indexOf(d);
|
|
207
|
+
g > -1 ? h.splice(g, 1) : (o.remove(d), a.push(d));
|
|
208
|
+
}
|
|
209
|
+
h.length !== 0 && o.extend(h);
|
|
210
|
+
} else {
|
|
211
|
+
r.forEachFeatureAtPixel(
|
|
212
|
+
e.pixel,
|
|
213
|
+
/**
|
|
214
|
+
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
|
215
|
+
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
216
|
+
* @return {boolean|undefined} Continue to iterate over the features.
|
|
217
|
+
*/
|
|
218
|
+
(c, d) => {
|
|
219
|
+
if (!(!(c instanceof L) || !this.filter_(c, d)))
|
|
220
|
+
return (t || i) && !o.getArray().includes(c) ? (this.addFeatureLayerAssociation_(c, d), h.push(c)) : (s || i) && o.getArray().includes(c) && (a.push(c), this.removeFeatureLayerAssociation_(c)), !this.multi_;
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
layerFilter: this.layerFilter_,
|
|
224
|
+
hitTolerance: this.hitTolerance_
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
for (let c = a.length - 1; c >= 0; --c)
|
|
228
|
+
o.remove(a[c]);
|
|
229
|
+
o.extend(h);
|
|
230
|
+
}
|
|
231
|
+
return (h.length > 0 || a.length > 0) && this.dispatchEvent(
|
|
232
|
+
new Ct(
|
|
233
|
+
pt.SELECT,
|
|
234
|
+
h,
|
|
235
|
+
a,
|
|
236
|
+
e
|
|
237
|
+
)
|
|
238
|
+
), !0;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function Ft() {
|
|
242
|
+
const l = xe();
|
|
243
|
+
return Te(l.Polygon, l.LineString), Te(l.GeometryCollection, l.LineString), function(e) {
|
|
244
|
+
return e.getGeometry() ? l[e.getGeometry().getType()] : null;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const Pe = 0, K = 1, Ee = [0, 0, 0, 0], N = [], he = {
|
|
248
|
+
/**
|
|
249
|
+
* Triggered upon feature modification start
|
|
250
|
+
* @event ModifyEvent#modifystart
|
|
251
|
+
* @api
|
|
252
|
+
*/
|
|
253
|
+
MODIFYSTART: "modifystart",
|
|
254
|
+
/**
|
|
255
|
+
* Triggered upon feature modification end
|
|
256
|
+
* @event ModifyEvent#modifyend
|
|
257
|
+
* @api
|
|
258
|
+
*/
|
|
259
|
+
MODIFYEND: "modifyend"
|
|
260
|
+
};
|
|
261
|
+
class ce extends ne {
|
|
262
|
+
/**
|
|
263
|
+
* @param {ModifyEventType} type Type.
|
|
264
|
+
* @param {Collection<Feature>} features
|
|
265
|
+
* The features modified.
|
|
266
|
+
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent
|
|
267
|
+
* Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
|
268
|
+
*/
|
|
269
|
+
constructor(e, t, s) {
|
|
270
|
+
super(e), this.features = t, this.mapBrowserEvent = s;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
class Tt extends me {
|
|
274
|
+
/**
|
|
275
|
+
* @param {Options} options Options.
|
|
276
|
+
*/
|
|
277
|
+
constructor(e) {
|
|
278
|
+
super(
|
|
279
|
+
/** @type {import("./Pointer.js").Options} */
|
|
280
|
+
e
|
|
281
|
+
), this.on, this.once, this.un, this.boundHandleFeatureChange_ = this.handleFeatureChange_.bind(this), this.condition_ = e.condition ? e.condition : Ze, this.defaultDeleteCondition_ = function(s) {
|
|
282
|
+
return ze(s) && ke(s);
|
|
283
|
+
}, this.deleteCondition_ = e.deleteCondition ? e.deleteCondition : this.defaultDeleteCondition_, this.insertVertexCondition_ = e.insertVertexCondition ? e.insertVertexCondition : _e, this.vertexFeature_ = null, this.vertexSegments_ = null, this.lastPixel_ = [0, 0], this.ignoreNextSingleClick_ = !1, this.featuresBeingModified_ = null, this.rBush_ = new Ge(), this.pixelTolerance_ = e.pixelTolerance !== void 0 ? e.pixelTolerance : 10, this.snappedToVertex_ = !1, this.changingFeature_ = !1, this.dragSegments_ = [], this.overlay_ = new se({
|
|
284
|
+
source: new ye({
|
|
285
|
+
useSpatialIndex: !1,
|
|
286
|
+
wrapX: !!e.wrapX
|
|
287
|
+
}),
|
|
288
|
+
style: e.style ? e.style : Pt(),
|
|
289
|
+
updateWhileAnimating: !0,
|
|
290
|
+
updateWhileInteracting: !0
|
|
291
|
+
}), this.SEGMENT_WRITERS_ = {
|
|
292
|
+
Point: this.writePointGeometry_.bind(this),
|
|
293
|
+
LineString: this.writeLineStringGeometry_.bind(this),
|
|
294
|
+
LinearRing: this.writeLineStringGeometry_.bind(this),
|
|
295
|
+
Polygon: this.writePolygonGeometry_.bind(this),
|
|
296
|
+
MultiPoint: this.writeMultiPointGeometry_.bind(this),
|
|
297
|
+
MultiLineString: this.writeMultiLineStringGeometry_.bind(this),
|
|
298
|
+
MultiPolygon: this.writeMultiPolygonGeometry_.bind(this),
|
|
299
|
+
Circle: this.writeCircleGeometry_.bind(this),
|
|
300
|
+
GeometryCollection: this.writeGeometryCollectionGeometry_.bind(this)
|
|
301
|
+
}, this.source_ = null, this.hitDetection_ = null;
|
|
302
|
+
let t;
|
|
303
|
+
if (e.features ? t = e.features : e.source && (this.source_ = e.source, t = new fe(this.source_.getFeatures()), this.source_.addEventListener(
|
|
304
|
+
J.ADDFEATURE,
|
|
305
|
+
this.handleSourceAdd_.bind(this)
|
|
306
|
+
), this.source_.addEventListener(
|
|
307
|
+
J.REMOVEFEATURE,
|
|
308
|
+
this.handleSourceRemove_.bind(this)
|
|
309
|
+
)), !t)
|
|
310
|
+
throw new Error(
|
|
311
|
+
"The modify interaction requires features, a source or a layer"
|
|
312
|
+
);
|
|
313
|
+
e.hitDetection && (this.hitDetection_ = e.hitDetection), this.features_ = t, this.features_.forEach(this.addFeature_.bind(this)), this.features_.addEventListener(
|
|
314
|
+
v.ADD,
|
|
315
|
+
this.handleFeatureAdd_.bind(this)
|
|
316
|
+
), this.features_.addEventListener(
|
|
317
|
+
v.REMOVE,
|
|
318
|
+
this.handleFeatureRemove_.bind(this)
|
|
319
|
+
), this.lastPointerEvent_ = null, this.delta_ = [0, 0], this.snapToPointer_ = e.snapToPointer === void 0 ? !this.hitDetection_ : e.snapToPointer;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* @param {Feature} feature Feature.
|
|
323
|
+
* @private
|
|
324
|
+
*/
|
|
325
|
+
addFeature_(e) {
|
|
326
|
+
const t = e.getGeometry();
|
|
327
|
+
if (t) {
|
|
328
|
+
const i = this.SEGMENT_WRITERS_[t.getType()];
|
|
329
|
+
i && i(e, t);
|
|
330
|
+
}
|
|
331
|
+
const s = this.getMap();
|
|
332
|
+
s && s.isRendered() && this.getActive() && this.handlePointerAtPixel_(this.lastPixel_, s), e.addEventListener(ee.CHANGE, this.boundHandleFeatureChange_);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @param {import("../MapBrowserEvent.js").default} evt Map browser event.
|
|
336
|
+
* @param {Array<Array<SegmentData>>} segments The segments subject to modification.
|
|
337
|
+
* @private
|
|
338
|
+
*/
|
|
339
|
+
willModifyFeatures_(e, t) {
|
|
340
|
+
if (!this.featuresBeingModified_) {
|
|
341
|
+
this.featuresBeingModified_ = new fe();
|
|
342
|
+
const s = this.featuresBeingModified_.getArray();
|
|
343
|
+
for (let i = 0, n = t.length; i < n; ++i) {
|
|
344
|
+
const r = t[i];
|
|
345
|
+
for (let o = 0, a = r.length; o < a; ++o) {
|
|
346
|
+
const h = r[o].feature;
|
|
347
|
+
h && !s.includes(h) && this.featuresBeingModified_.push(h);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
this.featuresBeingModified_.getLength() === 0 ? this.featuresBeingModified_ = null : this.dispatchEvent(
|
|
351
|
+
new ce(
|
|
352
|
+
he.MODIFYSTART,
|
|
353
|
+
this.featuresBeingModified_,
|
|
354
|
+
e
|
|
355
|
+
)
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* @param {Feature} feature Feature.
|
|
361
|
+
* @private
|
|
362
|
+
*/
|
|
363
|
+
removeFeature_(e) {
|
|
364
|
+
this.removeFeatureSegmentData_(e), this.vertexFeature_ && this.features_.getLength() === 0 && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), e.removeEventListener(
|
|
365
|
+
ee.CHANGE,
|
|
366
|
+
this.boundHandleFeatureChange_
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* @param {Feature} feature Feature.
|
|
371
|
+
* @private
|
|
372
|
+
*/
|
|
373
|
+
removeFeatureSegmentData_(e) {
|
|
374
|
+
const t = this.rBush_, s = [];
|
|
375
|
+
t.forEach(
|
|
376
|
+
/**
|
|
377
|
+
* @param {SegmentData} node RTree node.
|
|
378
|
+
*/
|
|
379
|
+
function(i) {
|
|
380
|
+
e === i.feature && s.push(i);
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
for (let i = s.length - 1; i >= 0; --i) {
|
|
384
|
+
const n = s[i];
|
|
385
|
+
for (let r = this.dragSegments_.length - 1; r >= 0; --r)
|
|
386
|
+
this.dragSegments_[r][0] === n && this.dragSegments_.splice(r, 1);
|
|
387
|
+
t.remove(n);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Activate or deactivate the interaction.
|
|
392
|
+
* @param {boolean} active Active.
|
|
393
|
+
* @observable
|
|
394
|
+
* @api
|
|
395
|
+
*/
|
|
396
|
+
setActive(e) {
|
|
397
|
+
this.vertexFeature_ && !e && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), super.setActive(e);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Remove the interaction from its current map and attach it to the new map.
|
|
401
|
+
* Subclasses may set up event handlers to get notified about changes to
|
|
402
|
+
* the map here.
|
|
403
|
+
* @param {import("../Map.js").default} map Map.
|
|
404
|
+
*/
|
|
405
|
+
setMap(e) {
|
|
406
|
+
this.overlay_.setMap(e), super.setMap(e);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Get the overlay layer that this interaction renders the modification point or vertex to.
|
|
410
|
+
* @return {VectorLayer} Overlay layer.
|
|
411
|
+
* @api
|
|
412
|
+
*/
|
|
413
|
+
getOverlay() {
|
|
414
|
+
return this.overlay_;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* @param {import("../source/Vector.js").VectorSourceEvent} event Event.
|
|
418
|
+
* @private
|
|
419
|
+
*/
|
|
420
|
+
handleSourceAdd_(e) {
|
|
421
|
+
e.feature && this.features_.push(e.feature);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* @param {import("../source/Vector.js").VectorSourceEvent} event Event.
|
|
425
|
+
* @private
|
|
426
|
+
*/
|
|
427
|
+
handleSourceRemove_(e) {
|
|
428
|
+
e.feature && this.features_.remove(e.feature);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
432
|
+
* @private
|
|
433
|
+
*/
|
|
434
|
+
handleFeatureAdd_(e) {
|
|
435
|
+
this.addFeature_(e.element);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* @param {import("../events/Event.js").default} evt Event.
|
|
439
|
+
* @private
|
|
440
|
+
*/
|
|
441
|
+
handleFeatureChange_(e) {
|
|
442
|
+
if (!this.changingFeature_) {
|
|
443
|
+
const t = (
|
|
444
|
+
/** @type {Feature} */
|
|
445
|
+
e.target
|
|
446
|
+
);
|
|
447
|
+
this.removeFeature_(t), this.addFeature_(t);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
452
|
+
* @private
|
|
453
|
+
*/
|
|
454
|
+
handleFeatureRemove_(e) {
|
|
455
|
+
this.removeFeature_(e.element);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* @param {Feature} feature Feature
|
|
459
|
+
* @param {Point} geometry Geometry.
|
|
460
|
+
* @private
|
|
461
|
+
*/
|
|
462
|
+
writePointGeometry_(e, t) {
|
|
463
|
+
const s = t.getCoordinates(), i = {
|
|
464
|
+
feature: e,
|
|
465
|
+
geometry: t,
|
|
466
|
+
segment: [s, s]
|
|
467
|
+
};
|
|
468
|
+
this.rBush_.insert(t.getExtent(), i);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* @param {Feature} feature Feature
|
|
472
|
+
* @param {import("../geom/MultiPoint.js").default} geometry Geometry.
|
|
473
|
+
* @private
|
|
474
|
+
*/
|
|
475
|
+
writeMultiPointGeometry_(e, t) {
|
|
476
|
+
const s = t.getCoordinates();
|
|
477
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
478
|
+
const r = s[i], o = {
|
|
479
|
+
feature: e,
|
|
480
|
+
geometry: t,
|
|
481
|
+
depth: [i],
|
|
482
|
+
index: i,
|
|
483
|
+
segment: [r, r]
|
|
484
|
+
};
|
|
485
|
+
this.rBush_.insert(t.getExtent(), o);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* @param {Feature} feature Feature
|
|
490
|
+
* @param {import("../geom/LineString.js").default} geometry Geometry.
|
|
491
|
+
* @private
|
|
492
|
+
*/
|
|
493
|
+
writeLineStringGeometry_(e, t) {
|
|
494
|
+
const s = t.getCoordinates();
|
|
495
|
+
for (let i = 0, n = s.length - 1; i < n; ++i) {
|
|
496
|
+
const r = s.slice(i, i + 2), o = {
|
|
497
|
+
feature: e,
|
|
498
|
+
geometry: t,
|
|
499
|
+
index: i,
|
|
500
|
+
segment: r
|
|
501
|
+
};
|
|
502
|
+
this.rBush_.insert(E(r), o);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* @param {Feature} feature Feature
|
|
507
|
+
* @param {import("../geom/MultiLineString.js").default} geometry Geometry.
|
|
508
|
+
* @private
|
|
509
|
+
*/
|
|
510
|
+
writeMultiLineStringGeometry_(e, t) {
|
|
511
|
+
const s = t.getCoordinates();
|
|
512
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
513
|
+
const r = s[i];
|
|
514
|
+
for (let o = 0, a = r.length - 1; o < a; ++o) {
|
|
515
|
+
const h = r.slice(o, o + 2), c = {
|
|
516
|
+
feature: e,
|
|
517
|
+
geometry: t,
|
|
518
|
+
depth: [i],
|
|
519
|
+
index: o,
|
|
520
|
+
segment: h
|
|
521
|
+
};
|
|
522
|
+
this.rBush_.insert(E(h), c);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* @param {Feature} feature Feature
|
|
528
|
+
* @param {import("../geom/Polygon.js").default} geometry Geometry.
|
|
529
|
+
* @private
|
|
530
|
+
*/
|
|
531
|
+
writePolygonGeometry_(e, t) {
|
|
532
|
+
const s = t.getCoordinates();
|
|
533
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
534
|
+
const r = s[i];
|
|
535
|
+
for (let o = 0, a = r.length - 1; o < a; ++o) {
|
|
536
|
+
const h = r.slice(o, o + 2), c = {
|
|
537
|
+
feature: e,
|
|
538
|
+
geometry: t,
|
|
539
|
+
depth: [i],
|
|
540
|
+
index: o,
|
|
541
|
+
segment: h
|
|
542
|
+
};
|
|
543
|
+
this.rBush_.insert(E(h), c);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* @param {Feature} feature Feature
|
|
549
|
+
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
|
550
|
+
* @private
|
|
551
|
+
*/
|
|
552
|
+
writeMultiPolygonGeometry_(e, t) {
|
|
553
|
+
const s = t.getCoordinates();
|
|
554
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
555
|
+
const r = s[i];
|
|
556
|
+
for (let o = 0, a = r.length; o < a; ++o) {
|
|
557
|
+
const h = r[o];
|
|
558
|
+
for (let c = 0, d = h.length - 1; c < d; ++c) {
|
|
559
|
+
const g = h.slice(c, c + 2), u = {
|
|
560
|
+
feature: e,
|
|
561
|
+
geometry: t,
|
|
562
|
+
depth: [o, i],
|
|
563
|
+
index: c,
|
|
564
|
+
segment: g
|
|
565
|
+
};
|
|
566
|
+
this.rBush_.insert(E(g), u);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* We convert a circle into two segments. The segment at index
|
|
573
|
+
* {@link CIRCLE_CENTER_INDEX} is the
|
|
574
|
+
* circle's center (a point). The segment at index
|
|
575
|
+
* {@link CIRCLE_CIRCUMFERENCE_INDEX} is
|
|
576
|
+
* the circumference, and is not a line segment.
|
|
577
|
+
*
|
|
578
|
+
* @param {Feature} feature Feature.
|
|
579
|
+
* @param {import("../geom/Circle.js").default} geometry Geometry.
|
|
580
|
+
* @private
|
|
581
|
+
*/
|
|
582
|
+
writeCircleGeometry_(e, t) {
|
|
583
|
+
const s = t.getCenter(), i = {
|
|
584
|
+
feature: e,
|
|
585
|
+
geometry: t,
|
|
586
|
+
index: Pe,
|
|
587
|
+
segment: [s, s]
|
|
588
|
+
}, n = {
|
|
589
|
+
feature: e,
|
|
590
|
+
geometry: t,
|
|
591
|
+
index: K,
|
|
592
|
+
segment: [s, s]
|
|
593
|
+
}, r = [i, n];
|
|
594
|
+
i.featureSegments = r, n.featureSegments = r, this.rBush_.insert(ae(s), i);
|
|
595
|
+
let o = (
|
|
596
|
+
/** @type {import("../geom/Geometry.js").default} */
|
|
597
|
+
t
|
|
598
|
+
);
|
|
599
|
+
this.rBush_.insert(o.getExtent(), n);
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* @param {Feature} feature Feature
|
|
603
|
+
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
|
|
604
|
+
* @private
|
|
605
|
+
*/
|
|
606
|
+
writeGeometryCollectionGeometry_(e, t) {
|
|
607
|
+
const s = t.getGeometriesArray();
|
|
608
|
+
for (let i = 0; i < s.length; ++i) {
|
|
609
|
+
const n = s[i], r = this.SEGMENT_WRITERS_[n.getType()];
|
|
610
|
+
r(e, n);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
|
|
615
|
+
* @param {Array<Feature>} features The features being modified.
|
|
616
|
+
* @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified.
|
|
617
|
+
* @return {Feature} Vertex feature.
|
|
618
|
+
* @private
|
|
619
|
+
*/
|
|
620
|
+
createOrUpdateVertexFeature_(e, t, s) {
|
|
621
|
+
let i = this.vertexFeature_;
|
|
622
|
+
return i ? i.getGeometry().setCoordinates(e) : (i = new L(new U(e)), this.vertexFeature_ = i, this.overlay_.getSource().addFeature(i)), i.set("features", t), i.set("geometries", s), i;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may modify the geometry.
|
|
626
|
+
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
|
|
627
|
+
* @return {boolean} `false` to stop event propagation.
|
|
628
|
+
*/
|
|
629
|
+
handleEvent(e) {
|
|
630
|
+
if (!e.originalEvent)
|
|
631
|
+
return !0;
|
|
632
|
+
this.lastPointerEvent_ = e;
|
|
633
|
+
let t;
|
|
634
|
+
return !e.map.getView().getInteracting() && e.type == D.POINTERMOVE && !this.handlingDownUpSequence && this.handlePointerMove_(e), this.vertexFeature_ && this.deleteCondition_(e) && (e.type != D.SINGLECLICK || !this.ignoreNextSingleClick_ ? t = this.removePoint() : t = !0), e.type == D.SINGLECLICK && (this.ignoreNextSingleClick_ = !1), super.handleEvent(e) && !t;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Handle pointer drag events.
|
|
638
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
639
|
+
*/
|
|
640
|
+
handleDragEvent(e) {
|
|
641
|
+
this.ignoreNextSingleClick_ = !1, this.willModifyFeatures_(e, this.dragSegments_);
|
|
642
|
+
const t = [
|
|
643
|
+
e.coordinate[0] + this.delta_[0],
|
|
644
|
+
e.coordinate[1] + this.delta_[1]
|
|
645
|
+
], s = [], i = [];
|
|
646
|
+
for (let n = 0, r = this.dragSegments_.length; n < r; ++n) {
|
|
647
|
+
const o = this.dragSegments_[n], a = o[0], h = a.feature;
|
|
648
|
+
s.includes(h) || s.push(h);
|
|
649
|
+
const c = a.geometry;
|
|
650
|
+
i.includes(c) || i.push(c);
|
|
651
|
+
const d = a.depth;
|
|
652
|
+
let g;
|
|
653
|
+
const u = a.segment, f = o[1];
|
|
654
|
+
for (; t.length < c.getStride(); )
|
|
655
|
+
t.push(u[f][t.length]);
|
|
656
|
+
switch (c.getType()) {
|
|
657
|
+
case "Point":
|
|
658
|
+
g = t, u[0] = t, u[1] = t;
|
|
659
|
+
break;
|
|
660
|
+
case "MultiPoint":
|
|
661
|
+
g = c.getCoordinates(), g[a.index] = t, u[0] = t, u[1] = t;
|
|
662
|
+
break;
|
|
663
|
+
case "LineString":
|
|
664
|
+
g = c.getCoordinates(), g[a.index + f] = t, u[f] = t;
|
|
665
|
+
break;
|
|
666
|
+
case "MultiLineString":
|
|
667
|
+
g = c.getCoordinates(), g[d[0]][a.index + f] = t, u[f] = t;
|
|
668
|
+
break;
|
|
669
|
+
case "Polygon":
|
|
670
|
+
g = c.getCoordinates(), g[d[0]][a.index + f] = t, u[f] = t;
|
|
671
|
+
break;
|
|
672
|
+
case "MultiPolygon":
|
|
673
|
+
g = c.getCoordinates(), g[d[1]][d[0]][a.index + f] = t, u[f] = t;
|
|
674
|
+
break;
|
|
675
|
+
case "Circle":
|
|
676
|
+
if (u[0] = t, u[1] = t, a.index === Pe)
|
|
677
|
+
this.changingFeature_ = !0, c.setCenter(t), this.changingFeature_ = !1;
|
|
678
|
+
else {
|
|
679
|
+
this.changingFeature_ = !0, e.map.getView().getProjection();
|
|
680
|
+
let _ = te(
|
|
681
|
+
C(c.getCenter()),
|
|
682
|
+
C(t)
|
|
683
|
+
);
|
|
684
|
+
c.setRadius(_), this.changingFeature_ = !1;
|
|
685
|
+
}
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
g && this.setGeometryCoordinates_(c, g);
|
|
689
|
+
}
|
|
690
|
+
this.createOrUpdateVertexFeature_(t, s, i);
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Handle pointer down events.
|
|
694
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
695
|
+
* @return {boolean} If the event was consumed.
|
|
696
|
+
*/
|
|
697
|
+
handleDownEvent(e) {
|
|
698
|
+
if (!this.condition_(e))
|
|
699
|
+
return !1;
|
|
700
|
+
const t = e.coordinate;
|
|
701
|
+
this.handlePointerAtPixel_(e.pixel, e.map, t), this.dragSegments_.length = 0, this.featuresBeingModified_ = null;
|
|
702
|
+
const s = this.vertexFeature_;
|
|
703
|
+
if (s) {
|
|
704
|
+
e.map.getView().getProjection();
|
|
705
|
+
const i = [], n = s.getGeometry().getCoordinates(), r = E([n]), o = this.rBush_.getInExtent(r), a = {};
|
|
706
|
+
o.sort(St);
|
|
707
|
+
for (let h = 0, c = o.length; h < c; ++h) {
|
|
708
|
+
const d = o[h], g = d.segment;
|
|
709
|
+
let u = F(d.geometry);
|
|
710
|
+
const f = d.depth;
|
|
711
|
+
if (f && (u += "-" + f.join("-")), a[u] || (a[u] = new Array(2)), d.geometry.getType() === "Circle" && d.index === K) {
|
|
712
|
+
const _ = De(
|
|
713
|
+
t,
|
|
714
|
+
d
|
|
715
|
+
);
|
|
716
|
+
I(_, n) && !a[u][0] && (this.dragSegments_.push([d, 0]), a[u][0] = d);
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
if (I(g[0], n) && !a[u][0]) {
|
|
720
|
+
this.dragSegments_.push([d, 0]), a[u][0] = d;
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
if (I(g[1], n) && !a[u][1]) {
|
|
724
|
+
if (a[u][0] && a[u][0].index === 0) {
|
|
725
|
+
let _ = d.geometry.getCoordinates();
|
|
726
|
+
switch (d.geometry.getType()) {
|
|
727
|
+
case "LineString":
|
|
728
|
+
case "MultiLineString":
|
|
729
|
+
continue;
|
|
730
|
+
case "MultiPolygon":
|
|
731
|
+
_ = _[f[1]];
|
|
732
|
+
case "Polygon":
|
|
733
|
+
if (d.index !== _[f[0]].length - 2)
|
|
734
|
+
continue;
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
this.dragSegments_.push([d, 1]), a[u][1] = d;
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
F(g) in this.vertexSegments_ && !a[u][0] && !a[u][1] && this.insertVertexCondition_(e) && i.push(d);
|
|
742
|
+
}
|
|
743
|
+
i.length && this.willModifyFeatures_(e, [i]);
|
|
744
|
+
for (let h = i.length - 1; h >= 0; --h)
|
|
745
|
+
this.insertVertex_(i[h], n);
|
|
746
|
+
}
|
|
747
|
+
return !!this.vertexFeature_;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Handle pointer up events.
|
|
751
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
752
|
+
* @return {boolean} If the event was consumed.
|
|
753
|
+
*/
|
|
754
|
+
handleUpEvent(e) {
|
|
755
|
+
for (let t = this.dragSegments_.length - 1; t >= 0; --t) {
|
|
756
|
+
const s = this.dragSegments_[t][0], i = s.geometry;
|
|
757
|
+
if (i.getType() === "Circle") {
|
|
758
|
+
const n = i.getCenter(), r = s.featureSegments[0], o = s.featureSegments[1];
|
|
759
|
+
r.segment[0] = n, r.segment[1] = n, o.segment[0] = n, o.segment[1] = n, this.rBush_.update(ae(n), r);
|
|
760
|
+
let a = i;
|
|
761
|
+
this.rBush_.update(
|
|
762
|
+
a.getExtent(),
|
|
763
|
+
o
|
|
764
|
+
);
|
|
765
|
+
} else
|
|
766
|
+
this.rBush_.update(E(s.segment), s);
|
|
767
|
+
}
|
|
768
|
+
return this.featuresBeingModified_ && (this.dispatchEvent(
|
|
769
|
+
new ce(
|
|
770
|
+
he.MODIFYEND,
|
|
771
|
+
this.featuresBeingModified_,
|
|
772
|
+
e
|
|
773
|
+
)
|
|
774
|
+
), this.featuresBeingModified_ = null), !1;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
778
|
+
* @private
|
|
779
|
+
*/
|
|
780
|
+
handlePointerMove_(e) {
|
|
781
|
+
this.lastPixel_ = e.pixel, this.handlePointerAtPixel_(e.pixel, e.map, e.coordinate);
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* @param {import("../pixel.js").Pixel} pixel Pixel
|
|
785
|
+
* @param {import("../Map.js").default} map Map.
|
|
786
|
+
* @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate.
|
|
787
|
+
* @private
|
|
788
|
+
*/
|
|
789
|
+
handlePointerAtPixel_(e, t, s) {
|
|
790
|
+
const i = s || t.getCoordinateFromPixel(e);
|
|
791
|
+
t.getView().getProjection();
|
|
792
|
+
const n = function(a, h) {
|
|
793
|
+
return we(i, a) - we(i, h);
|
|
794
|
+
};
|
|
795
|
+
let r, o;
|
|
796
|
+
if (this.hitDetection_) {
|
|
797
|
+
const a = typeof this.hitDetection_ == "object" ? (h) => h === this.hitDetection_ : void 0;
|
|
798
|
+
t.forEachFeatureAtPixel(
|
|
799
|
+
e,
|
|
800
|
+
(h, c, d) => {
|
|
801
|
+
d && (d = new U(
|
|
802
|
+
ie(d.getCoordinates())
|
|
803
|
+
));
|
|
804
|
+
const g = d || h.getGeometry();
|
|
805
|
+
if (g.getType() === "Point" && h instanceof L && this.features_.getArray().includes(h)) {
|
|
806
|
+
o = /** @type {Point} */
|
|
807
|
+
g;
|
|
808
|
+
const u = (
|
|
809
|
+
/** @type {Point} */
|
|
810
|
+
h.getGeometry().getFlatCoordinates().slice(0, 2)
|
|
811
|
+
);
|
|
812
|
+
r = [
|
|
813
|
+
{
|
|
814
|
+
feature: h,
|
|
815
|
+
geometry: o,
|
|
816
|
+
segment: [u, u]
|
|
817
|
+
}
|
|
818
|
+
];
|
|
819
|
+
}
|
|
820
|
+
return !0;
|
|
821
|
+
},
|
|
822
|
+
{ layerFilter: a }
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
if (!r) {
|
|
826
|
+
const a = gt(
|
|
827
|
+
ae(i, Ee)
|
|
828
|
+
), h = t.getView().getResolution() * this.pixelTolerance_, c = Oe(
|
|
829
|
+
Ne(a, h, Ee)
|
|
830
|
+
);
|
|
831
|
+
r = this.rBush_.getInExtent(c);
|
|
832
|
+
}
|
|
833
|
+
if (r && r.length > 0) {
|
|
834
|
+
const a = r.sort(n)[0], h = a.segment;
|
|
835
|
+
let c = De(i, a);
|
|
836
|
+
const d = t.getPixelFromCoordinate(c);
|
|
837
|
+
let g = te(e, d);
|
|
838
|
+
if (o || g <= this.pixelTolerance_) {
|
|
839
|
+
const u = {};
|
|
840
|
+
if (u[F(h)] = !0, this.snapToPointer_ || (this.delta_[0] = c[0] - i[0], this.delta_[1] = c[1] - i[1]), a.geometry.getType() === "Circle" && a.index === K)
|
|
841
|
+
this.snappedToVertex_ = !0, this.createOrUpdateVertexFeature_(
|
|
842
|
+
c,
|
|
843
|
+
[a.feature],
|
|
844
|
+
[a.geometry]
|
|
845
|
+
);
|
|
846
|
+
else {
|
|
847
|
+
const f = t.getPixelFromCoordinate(h[0]), _ = t.getPixelFromCoordinate(h[1]), x = R(d, f), p = R(d, _);
|
|
848
|
+
g = Math.sqrt(Math.min(x, p)), this.snappedToVertex_ = g <= this.pixelTolerance_, this.snappedToVertex_ && (c = x > p ? h[1] : h[0]), this.createOrUpdateVertexFeature_(
|
|
849
|
+
c,
|
|
850
|
+
[a.feature],
|
|
851
|
+
[a.geometry]
|
|
852
|
+
);
|
|
853
|
+
const T = {};
|
|
854
|
+
T[F(a.geometry)] = !0;
|
|
855
|
+
for (let M = 1, V = r.length; M < V; ++M) {
|
|
856
|
+
const G = r[M].segment;
|
|
857
|
+
if (I(h[0], G[0]) && I(h[1], G[1]) || I(h[0], G[1]) && I(h[1], G[0])) {
|
|
858
|
+
const j = F(r[M].geometry);
|
|
859
|
+
j in T || (T[j] = !0, u[F(G)] = !0);
|
|
860
|
+
} else
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
this.vertexSegments_ = u;
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
this.vertexFeature_ && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* @param {SegmentData} segmentData Segment data.
|
|
872
|
+
* @param {import("../coordinate.js").Coordinate} vertex Vertex.
|
|
873
|
+
* @private
|
|
874
|
+
*/
|
|
875
|
+
insertVertex_(e, t) {
|
|
876
|
+
const s = e.segment, i = e.feature, n = e.geometry, r = e.depth, o = e.index;
|
|
877
|
+
let a;
|
|
878
|
+
for (; t.length < n.getStride(); )
|
|
879
|
+
t.push(0);
|
|
880
|
+
switch (n.getType()) {
|
|
881
|
+
case "MultiLineString":
|
|
882
|
+
a = n.getCoordinates(), a[r[0]].splice(o + 1, 0, t);
|
|
883
|
+
break;
|
|
884
|
+
case "Polygon":
|
|
885
|
+
a = n.getCoordinates(), a[r[0]].splice(o + 1, 0, t);
|
|
886
|
+
break;
|
|
887
|
+
case "MultiPolygon":
|
|
888
|
+
a = n.getCoordinates(), a[r[1]][r[0]].splice(o + 1, 0, t);
|
|
889
|
+
break;
|
|
890
|
+
case "LineString":
|
|
891
|
+
a = n.getCoordinates(), a.splice(o + 1, 0, t);
|
|
892
|
+
break;
|
|
893
|
+
default:
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
this.setGeometryCoordinates_(n, a);
|
|
897
|
+
const h = this.rBush_;
|
|
898
|
+
h.remove(e), this.updateSegmentIndices_(n, o, r, 1);
|
|
899
|
+
const c = {
|
|
900
|
+
segment: [s[0], t],
|
|
901
|
+
feature: i,
|
|
902
|
+
geometry: n,
|
|
903
|
+
depth: r,
|
|
904
|
+
index: o
|
|
905
|
+
};
|
|
906
|
+
h.insert(E(c.segment), c), this.dragSegments_.push([c, 1]);
|
|
907
|
+
const d = {
|
|
908
|
+
segment: [t, s[1]],
|
|
909
|
+
feature: i,
|
|
910
|
+
geometry: n,
|
|
911
|
+
depth: r,
|
|
912
|
+
index: o + 1
|
|
913
|
+
};
|
|
914
|
+
h.insert(E(d.segment), d), this.dragSegments_.push([d, 0]), this.ignoreNextSingleClick_ = !0;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Removes the vertex currently being pointed.
|
|
918
|
+
* @return {boolean} True when a vertex was removed.
|
|
919
|
+
* @api
|
|
920
|
+
*/
|
|
921
|
+
removePoint() {
|
|
922
|
+
if (this.lastPointerEvent_ && this.lastPointerEvent_.type != D.POINTERDRAG) {
|
|
923
|
+
const e = this.lastPointerEvent_;
|
|
924
|
+
this.willModifyFeatures_(e, this.dragSegments_);
|
|
925
|
+
const t = this.removeVertex_();
|
|
926
|
+
return this.featuresBeingModified_ && this.dispatchEvent(
|
|
927
|
+
new ce(
|
|
928
|
+
he.MODIFYEND,
|
|
929
|
+
this.featuresBeingModified_,
|
|
930
|
+
e
|
|
931
|
+
)
|
|
932
|
+
), this.featuresBeingModified_ = null, t;
|
|
933
|
+
}
|
|
934
|
+
return !1;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Removes a vertex from all matching features.
|
|
938
|
+
* @return {boolean} True when a vertex was removed.
|
|
939
|
+
* @private
|
|
940
|
+
*/
|
|
941
|
+
removeVertex_() {
|
|
942
|
+
const e = this.dragSegments_, t = {};
|
|
943
|
+
let s = !1, i, n, r, o, a, h, c, d, g, u, f;
|
|
944
|
+
for (a = e.length - 1; a >= 0; --a)
|
|
945
|
+
r = e[a], u = r[0], f = F(u.feature), u.depth && (f += "-" + u.depth.join("-")), f in t || (t[f] = {}), r[1] === 0 ? (t[f].right = u, t[f].index = u.index) : r[1] == 1 && (t[f].left = u, t[f].index = u.index + 1);
|
|
946
|
+
for (f in t) {
|
|
947
|
+
switch (g = t[f].right, c = t[f].left, h = t[f].index, d = h - 1, c !== void 0 ? u = c : u = g, d < 0 && (d = 0), o = u.geometry, n = o.getCoordinates(), i = n, s = !1, o.getType()) {
|
|
948
|
+
case "MultiLineString":
|
|
949
|
+
n[u.depth[0]].length > 2 && (n[u.depth[0]].splice(h, 1), s = !0);
|
|
950
|
+
break;
|
|
951
|
+
case "LineString":
|
|
952
|
+
n.length > 2 && (n.splice(h, 1), s = !0);
|
|
953
|
+
break;
|
|
954
|
+
case "MultiPolygon":
|
|
955
|
+
i = i[u.depth[1]];
|
|
956
|
+
case "Polygon":
|
|
957
|
+
i = i[u.depth[0]], i.length > 4 && (h == i.length - 1 && (h = 0), i.splice(h, 1), s = !0, h === 0 && (i.pop(), i.push(i[0]), d = i.length - 1));
|
|
958
|
+
break;
|
|
959
|
+
}
|
|
960
|
+
if (s) {
|
|
961
|
+
this.setGeometryCoordinates_(o, n);
|
|
962
|
+
const _ = [];
|
|
963
|
+
if (c !== void 0 && (this.rBush_.remove(c), _.push(c.segment[0])), g !== void 0 && (this.rBush_.remove(g), _.push(g.segment[1])), c !== void 0 && g !== void 0) {
|
|
964
|
+
const x = {
|
|
965
|
+
depth: u.depth,
|
|
966
|
+
feature: u.feature,
|
|
967
|
+
geometry: u.geometry,
|
|
968
|
+
index: d,
|
|
969
|
+
segment: _
|
|
970
|
+
};
|
|
971
|
+
this.rBush_.insert(
|
|
972
|
+
E(x.segment),
|
|
973
|
+
x
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
this.updateSegmentIndices_(o, h, u.depth, -1), this.vertexFeature_ && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), e.length = 0;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return s;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
983
|
+
* @param {Array} coordinates Coordinates.
|
|
984
|
+
* @private
|
|
985
|
+
*/
|
|
986
|
+
setGeometryCoordinates_(e, t) {
|
|
987
|
+
this.changingFeature_ = !0, e.setCoordinates(t), this.changingFeature_ = !1;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
991
|
+
* @param {number} index Index.
|
|
992
|
+
* @param {Array<number>|undefined} depth Depth.
|
|
993
|
+
* @param {number} delta Delta (1 or -1).
|
|
994
|
+
* @private
|
|
995
|
+
*/
|
|
996
|
+
updateSegmentIndices_(e, t, s, i) {
|
|
997
|
+
this.rBush_.forEachInExtent(
|
|
998
|
+
e.getExtent(),
|
|
999
|
+
function(n) {
|
|
1000
|
+
n.geometry === e && (s === void 0 || n.depth === void 0 || at(n.depth, s)) && n.index > t && (n.index += i);
|
|
1001
|
+
}
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
function St(l, e) {
|
|
1006
|
+
return l.index - e.index;
|
|
1007
|
+
}
|
|
1008
|
+
function we(l, e, t) {
|
|
1009
|
+
const s = e.geometry;
|
|
1010
|
+
if (s.getType() === "Circle") {
|
|
1011
|
+
let n = (
|
|
1012
|
+
/** @type {import("../geom/Circle.js").default} */
|
|
1013
|
+
s
|
|
1014
|
+
);
|
|
1015
|
+
if (e.index === K) {
|
|
1016
|
+
const r = R(
|
|
1017
|
+
n.getCenter(),
|
|
1018
|
+
C(l)
|
|
1019
|
+
), o = Math.sqrt(r) - n.getRadius();
|
|
1020
|
+
return o * o;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
const i = C(l);
|
|
1024
|
+
return N[0] = C(e.segment[0]), N[1] = C(e.segment[1]), ft(i, N);
|
|
1025
|
+
}
|
|
1026
|
+
function De(l, e, t) {
|
|
1027
|
+
const s = e.geometry;
|
|
1028
|
+
if (s.getType() === "Circle" && e.index === K)
|
|
1029
|
+
return ie(
|
|
1030
|
+
/** @type {import("../geom/Circle.js").default} */
|
|
1031
|
+
s.getClosestPoint(
|
|
1032
|
+
C(l)
|
|
1033
|
+
)
|
|
1034
|
+
);
|
|
1035
|
+
const i = C(l);
|
|
1036
|
+
return N[0] = C(e.segment[0]), N[1] = C(e.segment[1]), ie(
|
|
1037
|
+
Ve(i, N)
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
function Pt() {
|
|
1041
|
+
const l = xe();
|
|
1042
|
+
return function(e, t) {
|
|
1043
|
+
return l.Point;
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
const H = {
|
|
1047
|
+
/**
|
|
1048
|
+
* Triggered upon feature draw start
|
|
1049
|
+
* @event DrawEvent#drawstart
|
|
1050
|
+
* @api
|
|
1051
|
+
*/
|
|
1052
|
+
DRAWSTART: "drawstart",
|
|
1053
|
+
/**
|
|
1054
|
+
* Triggered upon feature draw end
|
|
1055
|
+
* @event DrawEvent#drawend
|
|
1056
|
+
* @api
|
|
1057
|
+
*/
|
|
1058
|
+
DRAWEND: "drawend",
|
|
1059
|
+
/**
|
|
1060
|
+
* Triggered upon feature draw abortion
|
|
1061
|
+
* @event DrawEvent#drawabort
|
|
1062
|
+
* @api
|
|
1063
|
+
*/
|
|
1064
|
+
DRAWABORT: "drawabort"
|
|
1065
|
+
};
|
|
1066
|
+
class Y extends ne {
|
|
1067
|
+
/**
|
|
1068
|
+
* @param {DrawEventType} type Type.
|
|
1069
|
+
* @param {Feature} feature The feature drawn.
|
|
1070
|
+
*/
|
|
1071
|
+
constructor(e, t) {
|
|
1072
|
+
super(e), this.feature = t;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
function Et(l, e) {
|
|
1076
|
+
const t = [];
|
|
1077
|
+
for (let s = 0; s < e.length; ++s) {
|
|
1078
|
+
const n = e[s].getGeometry();
|
|
1079
|
+
Be(l, n, t);
|
|
1080
|
+
}
|
|
1081
|
+
return t;
|
|
1082
|
+
}
|
|
1083
|
+
function X(l, e) {
|
|
1084
|
+
return be(l[0], l[1], e[0], e[1]);
|
|
1085
|
+
}
|
|
1086
|
+
function b(l, e) {
|
|
1087
|
+
const t = l.length;
|
|
1088
|
+
return e < 0 ? l[e + t] : e >= t ? l[e - t] : l[e];
|
|
1089
|
+
}
|
|
1090
|
+
function $(l, e, t) {
|
|
1091
|
+
let s, i;
|
|
1092
|
+
e < t ? (s = e, i = t) : (s = t, i = e);
|
|
1093
|
+
const n = Math.ceil(s), r = Math.floor(i);
|
|
1094
|
+
if (n > r) {
|
|
1095
|
+
const a = O(l, s), h = O(l, i);
|
|
1096
|
+
return X(a, h);
|
|
1097
|
+
}
|
|
1098
|
+
let o = 0;
|
|
1099
|
+
if (s < n) {
|
|
1100
|
+
const a = O(l, s), h = b(l, n);
|
|
1101
|
+
o += X(a, h);
|
|
1102
|
+
}
|
|
1103
|
+
if (r < i) {
|
|
1104
|
+
const a = b(l, r), h = O(l, i);
|
|
1105
|
+
o += X(a, h);
|
|
1106
|
+
}
|
|
1107
|
+
for (let a = n; a < r - 1; ++a) {
|
|
1108
|
+
const h = b(l, a), c = b(l, a + 1);
|
|
1109
|
+
o += X(h, c);
|
|
1110
|
+
}
|
|
1111
|
+
return o;
|
|
1112
|
+
}
|
|
1113
|
+
function Be(l, e, t) {
|
|
1114
|
+
if (e instanceof z) {
|
|
1115
|
+
Z(l, e.getCoordinates(), !1, t);
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
if (e instanceof Ie) {
|
|
1119
|
+
const s = e.getCoordinates();
|
|
1120
|
+
for (let i = 0, n = s.length; i < n; ++i)
|
|
1121
|
+
Z(l, s[i], !1, t);
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
if (e instanceof je) {
|
|
1125
|
+
const s = e.getCoordinates();
|
|
1126
|
+
for (let i = 0, n = s.length; i < n; ++i)
|
|
1127
|
+
Z(l, s[i], !0, t);
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
if (e instanceof Re) {
|
|
1131
|
+
const s = e.getCoordinates();
|
|
1132
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
1133
|
+
const r = s[i];
|
|
1134
|
+
for (let o = 0, a = r.length; o < a; ++o)
|
|
1135
|
+
Z(l, r[o], !0, t);
|
|
1136
|
+
}
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
if (e instanceof st) {
|
|
1140
|
+
const s = e.getGeometries();
|
|
1141
|
+
for (let i = 0; i < s.length; ++i)
|
|
1142
|
+
Be(l, s[i], t);
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
const le = { index: -1, endIndex: NaN };
|
|
1147
|
+
function wt(l, e, t, s) {
|
|
1148
|
+
const i = l[0], n = l[1];
|
|
1149
|
+
let r = 1 / 0, o = -1, a = NaN;
|
|
1150
|
+
for (let d = 0; d < e.targets.length; ++d) {
|
|
1151
|
+
const g = e.targets[d], u = g.coordinates;
|
|
1152
|
+
let f = 1 / 0, _;
|
|
1153
|
+
for (let x = 0; x < u.length - 1; ++x) {
|
|
1154
|
+
const p = u[x], T = u[x + 1], M = qe(i, n, p, T);
|
|
1155
|
+
M.squaredDistance < f && (f = M.squaredDistance, _ = x + M.along);
|
|
1156
|
+
}
|
|
1157
|
+
f < r && (r = f, g.ring && e.targetIndex === d && (g.endIndex > g.startIndex ? _ < g.startIndex && (_ += u.length) : g.endIndex < g.startIndex && _ > g.startIndex && (_ -= u.length)), a = _, o = d);
|
|
1158
|
+
}
|
|
1159
|
+
const h = e.targets[o];
|
|
1160
|
+
let c = h.ring;
|
|
1161
|
+
if (e.targetIndex === o && c) {
|
|
1162
|
+
const d = O(
|
|
1163
|
+
h.coordinates,
|
|
1164
|
+
a
|
|
1165
|
+
), g = t.getPixelFromCoordinate(d);
|
|
1166
|
+
te(g, e.startPx) > s && (c = !1);
|
|
1167
|
+
}
|
|
1168
|
+
if (c) {
|
|
1169
|
+
const d = h.coordinates, g = d.length, u = h.startIndex, f = a;
|
|
1170
|
+
if (u < f) {
|
|
1171
|
+
const _ = $(
|
|
1172
|
+
d,
|
|
1173
|
+
u,
|
|
1174
|
+
f
|
|
1175
|
+
);
|
|
1176
|
+
$(
|
|
1177
|
+
d,
|
|
1178
|
+
u,
|
|
1179
|
+
f - g
|
|
1180
|
+
) < _ && (a -= g);
|
|
1181
|
+
} else {
|
|
1182
|
+
const _ = $(
|
|
1183
|
+
d,
|
|
1184
|
+
u,
|
|
1185
|
+
f
|
|
1186
|
+
);
|
|
1187
|
+
$(
|
|
1188
|
+
d,
|
|
1189
|
+
u,
|
|
1190
|
+
f + g
|
|
1191
|
+
) < _ && (a += g);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
return le.index = o, le.endIndex = a, le;
|
|
1195
|
+
}
|
|
1196
|
+
function Z(l, e, t, s) {
|
|
1197
|
+
const i = l[0], n = l[1];
|
|
1198
|
+
for (let r = 0, o = e.length - 1; r < o; ++r) {
|
|
1199
|
+
const a = e[r], h = e[r + 1], c = qe(i, n, a, h);
|
|
1200
|
+
if (c.squaredDistance === 0) {
|
|
1201
|
+
const d = r + c.along;
|
|
1202
|
+
s.push({
|
|
1203
|
+
coordinates: e,
|
|
1204
|
+
ring: t,
|
|
1205
|
+
startIndex: d,
|
|
1206
|
+
endIndex: d
|
|
1207
|
+
});
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
const de = { along: 0, squaredDistance: 0 };
|
|
1213
|
+
function qe(l, e, t, s) {
|
|
1214
|
+
const i = t[0], n = t[1], r = s[0], o = s[1], a = r - i, h = o - n;
|
|
1215
|
+
let c = 0, d = i, g = n;
|
|
1216
|
+
return (a !== 0 || h !== 0) && (c = ct(((l - i) * a + (e - n) * h) / (a * a + h * h), 0, 1), d += a * c, g += h * c), de.along = c, de.squaredDistance = ht(be(l, e, d, g), 10), de;
|
|
1217
|
+
}
|
|
1218
|
+
function O(l, e) {
|
|
1219
|
+
const t = l.length;
|
|
1220
|
+
let s = Math.floor(e);
|
|
1221
|
+
const i = e - s;
|
|
1222
|
+
s >= t ? s -= t : s < 0 && (s += t);
|
|
1223
|
+
let n = s + 1;
|
|
1224
|
+
n >= t && (n -= t);
|
|
1225
|
+
const r = l[s], o = r[0], a = r[1], h = l[n], c = h[0] - o, d = h[1] - a;
|
|
1226
|
+
return [o + c * i, a + d * i];
|
|
1227
|
+
}
|
|
1228
|
+
class Dt extends me {
|
|
1229
|
+
/**
|
|
1230
|
+
* @param {Options} options Options.
|
|
1231
|
+
*/
|
|
1232
|
+
constructor(e) {
|
|
1233
|
+
const t = (
|
|
1234
|
+
/** @type {import("./Pointer.js").Options} */
|
|
1235
|
+
e
|
|
1236
|
+
);
|
|
1237
|
+
t.stopDown || (t.stopDown = Ae), super(t), this.on, this.once, this.un, this.shouldHandle_ = !1, this.downPx_ = null, this.downTimeout_, this.lastDragTime_, this.pointerType_, this.freehand_ = !1, this.source_ = e.source ? e.source : null, this.features_ = e.features ? e.features : null, this.snapTolerance_ = e.snapTolerance ? e.snapTolerance : 12, this.type_ = /** @type {import("../geom/Geometry.js").Type} */
|
|
1238
|
+
e.type, this.mode_ = Lt(this.type_), this.stopClick_ = !!e.stopClick, this.minPoints_ = e.minPoints ? e.minPoints : this.mode_ === "Polygon" ? 3 : 2, this.maxPoints_ = this.mode_ === "Circle" ? 2 : e.maxPoints ? e.maxPoints : 1 / 0, this.finishCondition_ = e.finishCondition ? e.finishCondition : Q, this.geometryLayout_ = e.geometryLayout ? e.geometryLayout : "XY";
|
|
1239
|
+
let s = e.geometryFunction;
|
|
1240
|
+
if (!s) {
|
|
1241
|
+
const i = this.mode_;
|
|
1242
|
+
if (i === "Circle")
|
|
1243
|
+
s = function(n, r, o) {
|
|
1244
|
+
const a = r || new Je([NaN, NaN]), h = C(n[0]), c = R(
|
|
1245
|
+
h,
|
|
1246
|
+
C(n[n.length - 1])
|
|
1247
|
+
);
|
|
1248
|
+
return a.setCenterAndRadius(
|
|
1249
|
+
h,
|
|
1250
|
+
Math.sqrt(c),
|
|
1251
|
+
this.geometryLayout_
|
|
1252
|
+
), a;
|
|
1253
|
+
};
|
|
1254
|
+
else {
|
|
1255
|
+
let n;
|
|
1256
|
+
i === "Point" ? n = U : i === "LineString" ? n = z : i === "Polygon" && (n = je), s = function(r, o, a) {
|
|
1257
|
+
return o ? i === "Polygon" ? r[0].length ? o.setCoordinates(
|
|
1258
|
+
[r[0].concat([r[0][0]])],
|
|
1259
|
+
this.geometryLayout_
|
|
1260
|
+
) : o.setCoordinates([], this.geometryLayout_) : o.setCoordinates(r, this.geometryLayout_) : o = new n(r, this.geometryLayout_), o;
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
this.geometryFunction_ = s, this.dragVertexDelay_ = e.dragVertexDelay !== void 0 ? e.dragVertexDelay : 500, this.finishCoordinate_ = null, this.sketchFeature_ = null, this.sketchPoint_ = null, this.sketchCoords_ = null, this.sketchLine_ = null, this.sketchLineCoords_ = null, this.squaredClickTolerance_ = e.clickTolerance ? e.clickTolerance * e.clickTolerance : 36, this.overlay_ = new se({
|
|
1265
|
+
source: new ye({
|
|
1266
|
+
useSpatialIndex: !1,
|
|
1267
|
+
wrapX: e.wrapX ? e.wrapX : !1
|
|
1268
|
+
}),
|
|
1269
|
+
style: e.style ? e.style : Mt(),
|
|
1270
|
+
updateWhileInteracting: !0
|
|
1271
|
+
}), this.geometryName_ = e.geometryName, this.condition_ = e.condition ? e.condition : Qe, this.freehandCondition_, e.freehand ? this.freehandCondition_ = _e : this.freehandCondition_ = e.freehandCondition ? e.freehandCondition : ve, this.traceCondition_, this.setTrace(e.trace || !1), this.traceState_ = { active: !1 }, this.traceSource_ = e.traceSource || e.source || null, this.addChangeListener(et.ACTIVE, this.updateState_);
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Toggle tracing mode or set a tracing condition.
|
|
1275
|
+
*
|
|
1276
|
+
* @param {boolean|import("../events/condition.js").Condition} trace A boolean to toggle tracing mode or an event
|
|
1277
|
+
* condition that will be checked when a feature is clicked to determine if tracing should be active.
|
|
1278
|
+
*/
|
|
1279
|
+
setTrace(e) {
|
|
1280
|
+
let t;
|
|
1281
|
+
e ? e === !0 ? t = _e : t = e : t = ge, this.traceCondition_ = t;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Remove the interaction from its current map and attach it to the new map.
|
|
1285
|
+
* Subclasses may set up event handlers to get notified about changes to
|
|
1286
|
+
* the map here.
|
|
1287
|
+
* @param {import("../Map.js").default} map Map.
|
|
1288
|
+
*/
|
|
1289
|
+
setMap(e) {
|
|
1290
|
+
super.setMap(e), this.updateState_();
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Get the overlay layer that this interaction renders sketch features to.
|
|
1294
|
+
* @return {VectorLayer} Overlay layer.
|
|
1295
|
+
* @api
|
|
1296
|
+
*/
|
|
1297
|
+
getOverlay() {
|
|
1298
|
+
return this.overlay_;
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may actually draw or finish the drawing.
|
|
1302
|
+
* @param {import("../MapBrowserEvent.js").default} event Map browser event.
|
|
1303
|
+
* @return {boolean} `false` to stop event propagation.
|
|
1304
|
+
* @api
|
|
1305
|
+
*/
|
|
1306
|
+
handleEvent(e) {
|
|
1307
|
+
e.originalEvent.type === ee.CONTEXTMENU && e.originalEvent.preventDefault(), this.freehand_ = this.mode_ !== "Point" && this.freehandCondition_(e);
|
|
1308
|
+
let t = e.type === D.POINTERMOVE, s = !0;
|
|
1309
|
+
return !this.freehand_ && this.lastDragTime_ && e.type === D.POINTERDRAG && (Date.now() - this.lastDragTime_ >= this.dragVertexDelay_ ? (this.downPx_ = e.pixel, this.shouldHandle_ = !this.freehand_, t = !0) : this.lastDragTime_ = void 0, this.shouldHandle_ && this.downTimeout_ !== void 0 && (clearTimeout(this.downTimeout_), this.downTimeout_ = void 0)), this.freehand_ && e.type === D.POINTERDRAG && this.sketchFeature_ !== null ? (this.addToDrawing_(e.coordinate), s = !1) : this.freehand_ && e.type === D.POINTERDOWN ? s = !1 : t && this.getPointerCount() < 2 ? (s = e.type === D.POINTERMOVE, s && this.freehand_ ? (this.handlePointerMove_(e), this.shouldHandle_ && e.originalEvent.preventDefault()) : (e.originalEvent.pointerType === "mouse" || e.type === D.POINTERDRAG && this.downTimeout_ === void 0) && this.handlePointerMove_(e)) : e.type === D.DBLCLICK && (s = !1), super.handleEvent(e) && s;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Handle pointer down events.
|
|
1313
|
+
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1314
|
+
* @return {boolean} If the event was consumed.
|
|
1315
|
+
*/
|
|
1316
|
+
handleDownEvent(e) {
|
|
1317
|
+
return this.shouldHandle_ = !this.freehand_, this.freehand_ ? (this.downPx_ = e.pixel, this.finishCoordinate_ || this.startDrawing_(e.coordinate), !0) : this.condition_(e) ? (this.lastDragTime_ = Date.now(), this.downTimeout_ = setTimeout(() => {
|
|
1318
|
+
this.handlePointerMove_(
|
|
1319
|
+
new tt(
|
|
1320
|
+
D.POINTERMOVE,
|
|
1321
|
+
e.map,
|
|
1322
|
+
e.originalEvent,
|
|
1323
|
+
!1,
|
|
1324
|
+
e.frameState
|
|
1325
|
+
)
|
|
1326
|
+
);
|
|
1327
|
+
}, this.dragVertexDelay_), this.downPx_ = e.pixel, !0) : (this.lastDragTime_ = void 0, !1);
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* @private
|
|
1331
|
+
*/
|
|
1332
|
+
deactivateTrace_() {
|
|
1333
|
+
this.traceState_ = { active: !1 };
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Activate or deactivate trace state based on a browser event.
|
|
1337
|
+
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1338
|
+
* @private
|
|
1339
|
+
*/
|
|
1340
|
+
toggleTraceState_(e) {
|
|
1341
|
+
if (!this.traceSource_ || !this.traceCondition_(e))
|
|
1342
|
+
return;
|
|
1343
|
+
if (this.traceState_.active) {
|
|
1344
|
+
this.deactivateTrace_();
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
const t = this.getMap(), s = t.getCoordinateFromPixel([
|
|
1348
|
+
e.pixel[0] - this.snapTolerance_,
|
|
1349
|
+
e.pixel[1] + this.snapTolerance_
|
|
1350
|
+
]), i = t.getCoordinateFromPixel([
|
|
1351
|
+
e.pixel[0] + this.snapTolerance_,
|
|
1352
|
+
e.pixel[1] - this.snapTolerance_
|
|
1353
|
+
]), n = E([s, i]), r = this.traceSource_.getFeaturesInExtent(n);
|
|
1354
|
+
if (r.length === 0)
|
|
1355
|
+
return;
|
|
1356
|
+
const o = Et(e.coordinate, r);
|
|
1357
|
+
o.length && (this.traceState_ = {
|
|
1358
|
+
active: !0,
|
|
1359
|
+
startPx: e.pixel.slice(),
|
|
1360
|
+
targets: o,
|
|
1361
|
+
targetIndex: -1
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* @param {TraceTarget} target The trace target.
|
|
1366
|
+
* @param {number} endIndex The new end index of the trace.
|
|
1367
|
+
* @private
|
|
1368
|
+
*/
|
|
1369
|
+
addOrRemoveTracedCoordinates_(e, t) {
|
|
1370
|
+
const s = e.startIndex <= e.endIndex, i = e.startIndex <= t;
|
|
1371
|
+
s === i ? s && t > e.endIndex || !s && t < e.endIndex ? this.addTracedCoordinates_(e, e.endIndex, t) : (s && t < e.endIndex || !s && t > e.endIndex) && this.removeTracedCoordinates_(t, e.endIndex) : (this.removeTracedCoordinates_(e.startIndex, e.endIndex), this.addTracedCoordinates_(e, e.startIndex, t));
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* @param {number} fromIndex The start index.
|
|
1375
|
+
* @param {number} toIndex The end index.
|
|
1376
|
+
* @private
|
|
1377
|
+
*/
|
|
1378
|
+
removeTracedCoordinates_(e, t) {
|
|
1379
|
+
if (e === t)
|
|
1380
|
+
return;
|
|
1381
|
+
let s = 0;
|
|
1382
|
+
if (e < t) {
|
|
1383
|
+
const i = Math.ceil(e);
|
|
1384
|
+
let n = Math.floor(t);
|
|
1385
|
+
n === t && (n -= 1), s = n - i + 1;
|
|
1386
|
+
} else {
|
|
1387
|
+
const i = Math.floor(e);
|
|
1388
|
+
let n = Math.ceil(t);
|
|
1389
|
+
n === t && (n += 1), s = i - n + 1;
|
|
1390
|
+
}
|
|
1391
|
+
s > 0 && this.removeLastPoints_(s);
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* @param {TraceTarget} target The trace target.
|
|
1395
|
+
* @param {number} fromIndex The start index.
|
|
1396
|
+
* @param {number} toIndex The end index.
|
|
1397
|
+
* @private
|
|
1398
|
+
*/
|
|
1399
|
+
addTracedCoordinates_(e, t, s) {
|
|
1400
|
+
if (t === s)
|
|
1401
|
+
return;
|
|
1402
|
+
const i = [];
|
|
1403
|
+
if (t < s) {
|
|
1404
|
+
const n = Math.ceil(t);
|
|
1405
|
+
let r = Math.floor(s);
|
|
1406
|
+
r === s && (r -= 1);
|
|
1407
|
+
for (let o = n; o <= r; ++o)
|
|
1408
|
+
i.push(b(e.coordinates, o));
|
|
1409
|
+
} else {
|
|
1410
|
+
const n = Math.floor(t);
|
|
1411
|
+
let r = Math.ceil(s);
|
|
1412
|
+
r === s && (r += 1);
|
|
1413
|
+
for (let o = n; o >= r; --o)
|
|
1414
|
+
i.push(b(e.coordinates, o));
|
|
1415
|
+
}
|
|
1416
|
+
i.length && this.appendCoordinates(i);
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Update the trace.
|
|
1420
|
+
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1421
|
+
* @private
|
|
1422
|
+
*/
|
|
1423
|
+
updateTrace_(e) {
|
|
1424
|
+
const t = this.traceState_;
|
|
1425
|
+
if (!t.active || t.targetIndex === -1 && te(t.startPx, e.pixel) < this.snapTolerance_)
|
|
1426
|
+
return;
|
|
1427
|
+
const s = wt(
|
|
1428
|
+
e.coordinate,
|
|
1429
|
+
t,
|
|
1430
|
+
this.getMap(),
|
|
1431
|
+
this.snapTolerance_
|
|
1432
|
+
);
|
|
1433
|
+
if (t.targetIndex !== s.index) {
|
|
1434
|
+
if (t.targetIndex !== -1) {
|
|
1435
|
+
const a = t.targets[t.targetIndex];
|
|
1436
|
+
this.removeTracedCoordinates_(a.startIndex, a.endIndex);
|
|
1437
|
+
}
|
|
1438
|
+
const o = t.targets[s.index];
|
|
1439
|
+
this.addTracedCoordinates_(
|
|
1440
|
+
o,
|
|
1441
|
+
o.startIndex,
|
|
1442
|
+
s.endIndex
|
|
1443
|
+
);
|
|
1444
|
+
} else {
|
|
1445
|
+
const o = t.targets[t.targetIndex];
|
|
1446
|
+
this.addOrRemoveTracedCoordinates_(o, s.endIndex);
|
|
1447
|
+
}
|
|
1448
|
+
t.targetIndex = s.index;
|
|
1449
|
+
const i = t.targets[t.targetIndex];
|
|
1450
|
+
i.endIndex = s.endIndex;
|
|
1451
|
+
const n = O(
|
|
1452
|
+
i.coordinates,
|
|
1453
|
+
i.endIndex
|
|
1454
|
+
), r = this.getMap().getPixelFromCoordinate(n);
|
|
1455
|
+
e.coordinate = n, e.pixel = [Math.round(r[0]), Math.round(r[1])];
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Handle pointer up events.
|
|
1459
|
+
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1460
|
+
* @return {boolean} If the event was consumed.
|
|
1461
|
+
*/
|
|
1462
|
+
handleUpEvent(e) {
|
|
1463
|
+
let t = !0;
|
|
1464
|
+
if (this.getPointerCount() === 0) {
|
|
1465
|
+
this.downTimeout_ && (clearTimeout(this.downTimeout_), this.downTimeout_ = void 0), this.handlePointerMove_(e);
|
|
1466
|
+
const s = this.traceState_.active;
|
|
1467
|
+
if (this.toggleTraceState_(e), this.shouldHandle_) {
|
|
1468
|
+
const i = !this.finishCoordinate_;
|
|
1469
|
+
i && this.startDrawing_(e.coordinate), !i && this.freehand_ ? this.finishDrawing() : !this.freehand_ && (!i || this.mode_ === "Point") && (this.atFinish_(e.pixel, s) ? this.finishCondition_(e) && this.finishDrawing() : this.addToDrawing_(e.coordinate)), t = !1;
|
|
1470
|
+
} else this.freehand_ && this.abortDrawing();
|
|
1471
|
+
}
|
|
1472
|
+
return !t && this.stopClick_ && e.preventDefault(), t;
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Handle move events.
|
|
1476
|
+
* @param {import("../MapBrowserEvent.js").default} event A move event.
|
|
1477
|
+
* @private
|
|
1478
|
+
*/
|
|
1479
|
+
handlePointerMove_(e) {
|
|
1480
|
+
if (this.pointerType_ = e.originalEvent.pointerType, this.downPx_ && (!this.freehand_ && this.shouldHandle_ || this.freehand_ && !this.shouldHandle_)) {
|
|
1481
|
+
const t = this.downPx_, s = e.pixel, i = t[0] - s[0], n = t[1] - s[1], r = i * i + n * n;
|
|
1482
|
+
if (this.shouldHandle_ = this.freehand_ ? r > this.squaredClickTolerance_ : r <= this.squaredClickTolerance_, !this.shouldHandle_)
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
if (!this.finishCoordinate_) {
|
|
1486
|
+
this.createOrUpdateSketchPoint_(e.coordinate.slice());
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
this.updateTrace_(e), this.modifyDrawing_(e.coordinate);
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Determine if an event is within the snapping tolerance of the start coord.
|
|
1493
|
+
* @param {import("../pixel.js").Pixel} pixel Pixel.
|
|
1494
|
+
* @param {boolean} [tracing] Drawing in trace mode (only stop if at the starting point).
|
|
1495
|
+
* @return {boolean} The event is within the snapping tolerance of the start.
|
|
1496
|
+
* @private
|
|
1497
|
+
*/
|
|
1498
|
+
atFinish_(e, t) {
|
|
1499
|
+
let s = !1;
|
|
1500
|
+
if (this.sketchFeature_) {
|
|
1501
|
+
let i = !1, n = [this.finishCoordinate_];
|
|
1502
|
+
const r = this.mode_;
|
|
1503
|
+
if (r === "Point")
|
|
1504
|
+
s = !0;
|
|
1505
|
+
else if (r === "Circle")
|
|
1506
|
+
s = this.sketchCoords_.length === 2;
|
|
1507
|
+
else if (r === "LineString")
|
|
1508
|
+
i = !t && this.sketchCoords_.length > this.minPoints_;
|
|
1509
|
+
else if (r === "Polygon") {
|
|
1510
|
+
const o = (
|
|
1511
|
+
/** @type {PolyCoordType} */
|
|
1512
|
+
this.sketchCoords_
|
|
1513
|
+
);
|
|
1514
|
+
i = o[0].length > this.minPoints_, n = [
|
|
1515
|
+
o[0][0],
|
|
1516
|
+
o[0][o[0].length - 2]
|
|
1517
|
+
], t ? n = [o[0][0]] : n = [
|
|
1518
|
+
o[0][0],
|
|
1519
|
+
o[0][o[0].length - 2]
|
|
1520
|
+
];
|
|
1521
|
+
}
|
|
1522
|
+
if (i) {
|
|
1523
|
+
const o = this.getMap();
|
|
1524
|
+
for (let a = 0, h = n.length; a < h; a++) {
|
|
1525
|
+
const c = n[a], d = o.getPixelFromCoordinate(c), g = e[0] - d[0], u = e[1] - d[1], f = this.freehand_ ? 1 : this.snapTolerance_;
|
|
1526
|
+
if (s = Math.sqrt(g * g + u * u) <= f, s) {
|
|
1527
|
+
this.finishCoordinate_ = c;
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
return s;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* @param {import("../coordinate").Coordinate} coordinates Coordinate.
|
|
1537
|
+
* @private
|
|
1538
|
+
*/
|
|
1539
|
+
createOrUpdateSketchPoint_(e) {
|
|
1540
|
+
this.sketchPoint_ ? this.sketchPoint_.getGeometry().setCoordinates(e) : (this.sketchPoint_ = new L(new U(e)), this.updateSketchFeatures_());
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* @param {import("../geom/Polygon.js").default} geometry Polygon geometry.
|
|
1544
|
+
* @private
|
|
1545
|
+
*/
|
|
1546
|
+
createOrUpdateCustomSketchLine_(e) {
|
|
1547
|
+
this.sketchLine_ || (this.sketchLine_ = new L());
|
|
1548
|
+
const t = e.getLinearRing(0);
|
|
1549
|
+
let s = this.sketchLine_.getGeometry();
|
|
1550
|
+
s ? (s.setFlatCoordinates(
|
|
1551
|
+
t.getLayout(),
|
|
1552
|
+
t.getFlatCoordinates()
|
|
1553
|
+
), s.changed()) : (s = new z(
|
|
1554
|
+
t.getFlatCoordinates(),
|
|
1555
|
+
t.getLayout()
|
|
1556
|
+
), this.sketchLine_.setGeometry(s));
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Start the drawing.
|
|
1560
|
+
* @param {import("../coordinate.js").Coordinate} start Start coordinate.
|
|
1561
|
+
* @private
|
|
1562
|
+
*/
|
|
1563
|
+
startDrawing_(e) {
|
|
1564
|
+
const t = this.getMap().getView().getProjection(), s = Se(this.geometryLayout_);
|
|
1565
|
+
for (; e.length < s; )
|
|
1566
|
+
e.push(0);
|
|
1567
|
+
this.finishCoordinate_ = e, this.mode_ === "Point" ? this.sketchCoords_ = e.slice() : this.mode_ === "Polygon" ? (this.sketchCoords_ = [[e.slice(), e.slice()]], this.sketchLineCoords_ = this.sketchCoords_[0]) : this.sketchCoords_ = [e.slice(), e.slice()], this.sketchLineCoords_ && (this.sketchLine_ = new L(new z(this.sketchLineCoords_)));
|
|
1568
|
+
const i = this.geometryFunction_(
|
|
1569
|
+
this.sketchCoords_,
|
|
1570
|
+
void 0,
|
|
1571
|
+
t
|
|
1572
|
+
);
|
|
1573
|
+
this.sketchFeature_ = new L(), this.geometryName_ && this.sketchFeature_.setGeometryName(this.geometryName_), this.sketchFeature_.setGeometry(i), this.updateSketchFeatures_(), this.dispatchEvent(
|
|
1574
|
+
new Y(H.DRAWSTART, this.sketchFeature_)
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Modify the drawing.
|
|
1579
|
+
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
|
|
1580
|
+
* @private
|
|
1581
|
+
*/
|
|
1582
|
+
modifyDrawing_(e) {
|
|
1583
|
+
const t = this.getMap(), s = this.sketchFeature_.getGeometry(), i = t.getView().getProjection(), n = Se(this.geometryLayout_);
|
|
1584
|
+
let r, o;
|
|
1585
|
+
for (; e.length < n; )
|
|
1586
|
+
e.push(0);
|
|
1587
|
+
this.mode_ === "Point" ? o = this.sketchCoords_ : this.mode_ === "Polygon" ? (r = /** @type {PolyCoordType} */
|
|
1588
|
+
this.sketchCoords_[0], o = r[r.length - 1], this.atFinish_(t.getPixelFromCoordinate(e)) && (e = this.finishCoordinate_.slice())) : (r = this.sketchCoords_, o = r[r.length - 1]), o[0] = e[0], o[1] = e[1], this.geometryFunction_(
|
|
1589
|
+
/** @type {!LineCoordType} */
|
|
1590
|
+
this.sketchCoords_,
|
|
1591
|
+
s,
|
|
1592
|
+
i
|
|
1593
|
+
), this.sketchPoint_ && this.sketchPoint_.getGeometry().setCoordinates(e), s.getType() === "Polygon" && this.mode_ !== "Polygon" ? this.createOrUpdateCustomSketchLine_(
|
|
1594
|
+
/** @type {Polygon} */
|
|
1595
|
+
s
|
|
1596
|
+
) : this.sketchLineCoords_ && this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_), this.updateSketchFeatures_();
|
|
1597
|
+
}
|
|
1598
|
+
/**
|
|
1599
|
+
* Add a new coordinate to the drawing.
|
|
1600
|
+
* @param {!PointCoordType} coordinate Coordinate
|
|
1601
|
+
* @private
|
|
1602
|
+
*/
|
|
1603
|
+
addToDrawing_(e) {
|
|
1604
|
+
const t = this.sketchFeature_.getGeometry(), s = this.getMap().getView().getProjection();
|
|
1605
|
+
let i, n;
|
|
1606
|
+
const r = this.mode_;
|
|
1607
|
+
r === "LineString" || r === "Circle" ? (this.finishCoordinate_ = e.slice(), n = /** @type {LineCoordType} */
|
|
1608
|
+
this.sketchCoords_, n.length >= this.maxPoints_ && (this.freehand_ ? n.pop() : i = !0), n.push(e.slice()), this.geometryFunction_(n, t, s)) : r === "Polygon" && (n = /** @type {PolyCoordType} */
|
|
1609
|
+
this.sketchCoords_[0], n.length >= this.maxPoints_ && (this.freehand_ ? n.pop() : i = !0), n.push(e.slice()), i && (this.finishCoordinate_ = n[0]), this.geometryFunction_(this.sketchCoords_, t, s)), this.createOrUpdateSketchPoint_(e.slice()), this.updateSketchFeatures_(), i && this.finishDrawing();
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* @param {number} n The number of points to remove.
|
|
1613
|
+
*/
|
|
1614
|
+
removeLastPoints_(e) {
|
|
1615
|
+
if (!this.sketchFeature_)
|
|
1616
|
+
return;
|
|
1617
|
+
const t = this.sketchFeature_.getGeometry(), s = this.getMap().getView().getProjection(), i = this.mode_;
|
|
1618
|
+
for (let n = 0; n < e; ++n) {
|
|
1619
|
+
let r;
|
|
1620
|
+
if (i === "LineString" || i === "Circle") {
|
|
1621
|
+
if (r = /** @type {LineCoordType} */
|
|
1622
|
+
this.sketchCoords_, r.splice(-2, 1), r.length >= 2) {
|
|
1623
|
+
this.finishCoordinate_ = r[r.length - 2].slice();
|
|
1624
|
+
const o = this.finishCoordinate_.slice();
|
|
1625
|
+
r[r.length - 1] = o, this.createOrUpdateSketchPoint_(o);
|
|
1626
|
+
}
|
|
1627
|
+
this.geometryFunction_(r, t, s), t.getType() === "Polygon" && this.sketchLine_ && this.createOrUpdateCustomSketchLine_(
|
|
1628
|
+
/** @type {Polygon} */
|
|
1629
|
+
t
|
|
1630
|
+
);
|
|
1631
|
+
} else if (i === "Polygon") {
|
|
1632
|
+
r = /** @type {PolyCoordType} */
|
|
1633
|
+
this.sketchCoords_[0], r.splice(-2, 1);
|
|
1634
|
+
const o = this.sketchLine_.getGeometry();
|
|
1635
|
+
if (r.length >= 2) {
|
|
1636
|
+
const a = r[r.length - 2].slice();
|
|
1637
|
+
r[r.length - 1] = a, this.createOrUpdateSketchPoint_(a);
|
|
1638
|
+
}
|
|
1639
|
+
o.setCoordinates(r), this.geometryFunction_(this.sketchCoords_, t, s);
|
|
1640
|
+
}
|
|
1641
|
+
if (r.length === 1) {
|
|
1642
|
+
this.abortDrawing();
|
|
1643
|
+
break;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
this.updateSketchFeatures_();
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* Remove last point of the feature currently being drawn. Does not do anything when
|
|
1650
|
+
* drawing POINT or MULTI_POINT geometries.
|
|
1651
|
+
* @api
|
|
1652
|
+
*/
|
|
1653
|
+
removeLastPoint() {
|
|
1654
|
+
this.removeLastPoints_(1);
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Stop drawing and add the sketch feature to the target layer.
|
|
1658
|
+
* The {@link module:ol/interaction/Draw~DrawEventType.DRAWEND} event is
|
|
1659
|
+
* dispatched before inserting the feature.
|
|
1660
|
+
* @api
|
|
1661
|
+
*/
|
|
1662
|
+
finishDrawing() {
|
|
1663
|
+
const e = this.abortDrawing_();
|
|
1664
|
+
if (!e)
|
|
1665
|
+
return;
|
|
1666
|
+
let t = this.sketchCoords_;
|
|
1667
|
+
const s = e.getGeometry(), i = this.getMap().getView().getProjection();
|
|
1668
|
+
this.mode_ === "LineString" ? (t.pop(), this.geometryFunction_(t, s, i)) : this.mode_ === "Polygon" && (t[0].pop(), this.geometryFunction_(t, s, i), t = s.getCoordinates()), this.type_ === "MultiPoint" ? e.setGeometry(
|
|
1669
|
+
new it([
|
|
1670
|
+
/** @type {PointCoordType} */
|
|
1671
|
+
t
|
|
1672
|
+
])
|
|
1673
|
+
) : this.type_ === "MultiLineString" ? e.setGeometry(
|
|
1674
|
+
new Ie([
|
|
1675
|
+
/** @type {LineCoordType} */
|
|
1676
|
+
t
|
|
1677
|
+
])
|
|
1678
|
+
) : this.type_ === "MultiPolygon" && e.setGeometry(
|
|
1679
|
+
new Re([
|
|
1680
|
+
/** @type {PolyCoordType} */
|
|
1681
|
+
t
|
|
1682
|
+
])
|
|
1683
|
+
), this.dispatchEvent(new Y(H.DRAWEND, e)), this.features_ && this.features_.push(e), this.source_ && this.source_.addFeature(e);
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Stop drawing without adding the sketch feature to the target layer.
|
|
1687
|
+
* @return {Feature<import("../geom/SimpleGeometry.js").default>|null} The sketch feature (or null if none).
|
|
1688
|
+
* @private
|
|
1689
|
+
*/
|
|
1690
|
+
abortDrawing_() {
|
|
1691
|
+
this.finishCoordinate_ = null;
|
|
1692
|
+
const e = this.sketchFeature_;
|
|
1693
|
+
return this.sketchFeature_ = null, this.sketchPoint_ = null, this.sketchLine_ = null, this.overlay_.getSource().clear(!0), this.deactivateTrace_(), e;
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Stop drawing without adding the sketch feature to the target layer.
|
|
1697
|
+
* @api
|
|
1698
|
+
*/
|
|
1699
|
+
abortDrawing() {
|
|
1700
|
+
const e = this.abortDrawing_();
|
|
1701
|
+
e && this.dispatchEvent(new Y(H.DRAWABORT, e));
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Append coordinates to the end of the geometry that is currently being drawn.
|
|
1705
|
+
* This can be used when drawing LineStrings or Polygons. Coordinates will
|
|
1706
|
+
* either be appended to the current LineString or the outer ring of the current
|
|
1707
|
+
* Polygon. If no geometry is being drawn, a new one will be created.
|
|
1708
|
+
* @param {!LineCoordType} coordinates Linear coordinates to be appended to
|
|
1709
|
+
* the coordinate array.
|
|
1710
|
+
* @api
|
|
1711
|
+
*/
|
|
1712
|
+
appendCoordinates(e) {
|
|
1713
|
+
const t = this.mode_, s = !this.sketchFeature_;
|
|
1714
|
+
s && this.startDrawing_(e[0]);
|
|
1715
|
+
let i;
|
|
1716
|
+
if (t === "LineString" || t === "Circle")
|
|
1717
|
+
i = /** @type {LineCoordType} */
|
|
1718
|
+
this.sketchCoords_;
|
|
1719
|
+
else if (t === "Polygon")
|
|
1720
|
+
i = this.sketchCoords_ && this.sketchCoords_.length ? (
|
|
1721
|
+
/** @type {PolyCoordType} */
|
|
1722
|
+
this.sketchCoords_[0]
|
|
1723
|
+
) : [];
|
|
1724
|
+
else
|
|
1725
|
+
return;
|
|
1726
|
+
s && i.shift(), i.pop();
|
|
1727
|
+
for (let r = 0; r < e.length; r++)
|
|
1728
|
+
this.addToDrawing_(e[r]);
|
|
1729
|
+
const n = e[e.length - 1];
|
|
1730
|
+
this.addToDrawing_(n), this.modifyDrawing_(n);
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Initiate draw mode by starting from an existing geometry which will
|
|
1734
|
+
* receive new additional points. This only works on features with
|
|
1735
|
+
* `LineString` geometries, where the interaction will extend lines by adding
|
|
1736
|
+
* points to the end of the coordinates array.
|
|
1737
|
+
* This will change the original feature, instead of drawing a copy.
|
|
1738
|
+
*
|
|
1739
|
+
* The function will dispatch a `drawstart` event.
|
|
1740
|
+
*
|
|
1741
|
+
* @param {!Feature<LineString>} feature Feature to be extended.
|
|
1742
|
+
* @api
|
|
1743
|
+
*/
|
|
1744
|
+
extend(e) {
|
|
1745
|
+
const s = e.getGeometry();
|
|
1746
|
+
this.sketchFeature_ = e, this.sketchCoords_ = s.getCoordinates();
|
|
1747
|
+
const i = this.sketchCoords_[this.sketchCoords_.length - 1];
|
|
1748
|
+
this.finishCoordinate_ = i.slice(), this.sketchCoords_.push(i.slice()), this.sketchPoint_ = new L(new U(i)), this.updateSketchFeatures_(), this.dispatchEvent(
|
|
1749
|
+
new Y(H.DRAWSTART, this.sketchFeature_)
|
|
1750
|
+
);
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Redraw the sketch features.
|
|
1754
|
+
* @private
|
|
1755
|
+
*/
|
|
1756
|
+
updateSketchFeatures_() {
|
|
1757
|
+
const e = [];
|
|
1758
|
+
this.sketchFeature_ && e.push(this.sketchFeature_), this.sketchLine_ && e.push(this.sketchLine_), this.sketchPoint_ && e.push(this.sketchPoint_);
|
|
1759
|
+
const t = this.overlay_.getSource();
|
|
1760
|
+
t.clear(!0), t.addFeatures(e);
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* @private
|
|
1764
|
+
*/
|
|
1765
|
+
updateState_() {
|
|
1766
|
+
const e = this.getMap(), t = this.getActive();
|
|
1767
|
+
(!e || !t) && this.abortDrawing(), this.overlay_.setMap(t ? e : null);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
function Mt() {
|
|
1771
|
+
const l = xe();
|
|
1772
|
+
return function(e, t) {
|
|
1773
|
+
return l[e.getGeometry().getType()];
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
function Lt(l) {
|
|
1777
|
+
switch (l) {
|
|
1778
|
+
case "Point":
|
|
1779
|
+
case "MultiPoint":
|
|
1780
|
+
return "Point";
|
|
1781
|
+
case "LineString":
|
|
1782
|
+
case "MultiLineString":
|
|
1783
|
+
return "LineString";
|
|
1784
|
+
case "Polygon":
|
|
1785
|
+
case "MultiPolygon":
|
|
1786
|
+
return "Polygon";
|
|
1787
|
+
case "Circle":
|
|
1788
|
+
return "Circle";
|
|
1789
|
+
default:
|
|
1790
|
+
throw new Error("Invalid type: " + l);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
const kt = {
|
|
1794
|
+
/**
|
|
1795
|
+
* Triggered upon snapping to vertex or edge
|
|
1796
|
+
* @event SnapEvent#snap
|
|
1797
|
+
* @api
|
|
1798
|
+
*/
|
|
1799
|
+
SNAP: "snap"
|
|
1800
|
+
};
|
|
1801
|
+
class vt extends ne {
|
|
1802
|
+
/**
|
|
1803
|
+
* @param {SnapEventType} type Type.
|
|
1804
|
+
* @param {Object} options Options.
|
|
1805
|
+
* @param {import("../coordinate.js").Coordinate} options.vertex The snapped vertex.
|
|
1806
|
+
* @param {import("../coordinate.js").Coordinate} options.vertexPixel The pixel of the snapped vertex.
|
|
1807
|
+
* @param {import("../Feature.js").default} options.feature The feature being snapped.
|
|
1808
|
+
*/
|
|
1809
|
+
constructor(e, t) {
|
|
1810
|
+
super(e), this.vertex = t.vertex, this.vertexPixel = t.vertexPixel, this.feature = t.feature;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
function Me(l) {
|
|
1814
|
+
return (
|
|
1815
|
+
/** @type {import("../source/Vector.js").VectorSourceEvent} */
|
|
1816
|
+
l.feature ? (
|
|
1817
|
+
/** @type {import("../source/Vector.js").VectorSourceEvent} */
|
|
1818
|
+
l.feature
|
|
1819
|
+
) : (
|
|
1820
|
+
/** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */
|
|
1821
|
+
l.element ? (
|
|
1822
|
+
/** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */
|
|
1823
|
+
l.element
|
|
1824
|
+
) : null
|
|
1825
|
+
)
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
const ue = [];
|
|
1829
|
+
class Gt extends me {
|
|
1830
|
+
/**
|
|
1831
|
+
* @param {Options} [options] Options.
|
|
1832
|
+
*/
|
|
1833
|
+
constructor(e) {
|
|
1834
|
+
e = e || {};
|
|
1835
|
+
const t = (
|
|
1836
|
+
/** @type {import("./Pointer.js").Options} */
|
|
1837
|
+
e
|
|
1838
|
+
);
|
|
1839
|
+
t.handleDownEvent || (t.handleDownEvent = Q), t.stopDown || (t.stopDown = Ae), super(t), this.on, this.once, this.un, this.source_ = e.source ? e.source : null, this.vertex_ = e.vertex !== void 0 ? e.vertex : !0, this.edge_ = e.edge !== void 0 ? e.edge : !0, this.features_ = e.features ? e.features : null, this.featuresListenerKeys_ = [], this.featureChangeListenerKeys_ = {}, this.indexedFeaturesExtents_ = {}, this.pendingFeatures_ = {}, this.pixelTolerance_ = e.pixelTolerance !== void 0 ? e.pixelTolerance : 10, this.rBush_ = new Ge(), this.GEOMETRY_SEGMENTERS_ = {
|
|
1840
|
+
Point: this.segmentPointGeometry_.bind(this),
|
|
1841
|
+
LineString: this.segmentLineStringGeometry_.bind(this),
|
|
1842
|
+
LinearRing: this.segmentLineStringGeometry_.bind(this),
|
|
1843
|
+
Polygon: this.segmentPolygonGeometry_.bind(this),
|
|
1844
|
+
MultiPoint: this.segmentMultiPointGeometry_.bind(this),
|
|
1845
|
+
MultiLineString: this.segmentMultiLineStringGeometry_.bind(this),
|
|
1846
|
+
MultiPolygon: this.segmentMultiPolygonGeometry_.bind(this),
|
|
1847
|
+
GeometryCollection: this.segmentGeometryCollectionGeometry_.bind(this),
|
|
1848
|
+
Circle: this.segmentCircleGeometry_.bind(this)
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Add a feature to the collection of features that we may snap to.
|
|
1853
|
+
* @param {import("../Feature.js").default} feature Feature.
|
|
1854
|
+
* @param {boolean} [register] Whether to listen to the feature change or not
|
|
1855
|
+
* Defaults to `true`.
|
|
1856
|
+
* @api
|
|
1857
|
+
*/
|
|
1858
|
+
addFeature(e, t) {
|
|
1859
|
+
t = t !== void 0 ? t : !0;
|
|
1860
|
+
const s = F(e), i = e.getGeometry();
|
|
1861
|
+
if (i) {
|
|
1862
|
+
const n = this.GEOMETRY_SEGMENTERS_[i.getType()];
|
|
1863
|
+
if (n) {
|
|
1864
|
+
this.indexedFeaturesExtents_[s] = i.getExtent(
|
|
1865
|
+
_t()
|
|
1866
|
+
);
|
|
1867
|
+
const r = (
|
|
1868
|
+
/** @type {Array<Array<import('../coordinate.js').Coordinate>>} */
|
|
1869
|
+
[]
|
|
1870
|
+
);
|
|
1871
|
+
if (n(r, i), r.length === 1)
|
|
1872
|
+
this.rBush_.insert(E(r[0]), {
|
|
1873
|
+
feature: e,
|
|
1874
|
+
segment: r[0]
|
|
1875
|
+
});
|
|
1876
|
+
else if (r.length > 1) {
|
|
1877
|
+
const o = r.map((h) => E(h)), a = r.map((h) => ({
|
|
1878
|
+
feature: e,
|
|
1879
|
+
segment: h
|
|
1880
|
+
}));
|
|
1881
|
+
this.rBush_.load(o, a);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
t && (this.featureChangeListenerKeys_[s] = q(
|
|
1886
|
+
e,
|
|
1887
|
+
ee.CHANGE,
|
|
1888
|
+
this.handleFeatureChange_,
|
|
1889
|
+
this
|
|
1890
|
+
));
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* @return {import("../Collection.js").default<import("../Feature.js").default>|Array<import("../Feature.js").default>} Features.
|
|
1894
|
+
* @private
|
|
1895
|
+
*/
|
|
1896
|
+
getFeatures_() {
|
|
1897
|
+
let e;
|
|
1898
|
+
return this.features_ ? e = this.features_ : this.source_ && (e = this.source_.getFeatures()), e;
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* @param {import("../MapBrowserEvent.js").default} evt Map browser event.
|
|
1902
|
+
* @return {boolean} `false` to stop event propagation.
|
|
1903
|
+
* @api
|
|
1904
|
+
*/
|
|
1905
|
+
handleEvent(e) {
|
|
1906
|
+
const t = this.snapTo(e.pixel, e.coordinate, e.map);
|
|
1907
|
+
return t && (e.coordinate = t.vertex.slice(0, 2), e.pixel = t.vertexPixel, this.dispatchEvent(
|
|
1908
|
+
new vt(kt.SNAP, {
|
|
1909
|
+
vertex: e.coordinate,
|
|
1910
|
+
vertexPixel: e.pixel,
|
|
1911
|
+
feature: t.feature
|
|
1912
|
+
})
|
|
1913
|
+
)), super.handleEvent(e);
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
|
|
1917
|
+
* @private
|
|
1918
|
+
*/
|
|
1919
|
+
handleFeatureAdd_(e) {
|
|
1920
|
+
const t = Me(e);
|
|
1921
|
+
t && this.addFeature(t);
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
|
|
1925
|
+
* @private
|
|
1926
|
+
*/
|
|
1927
|
+
handleFeatureRemove_(e) {
|
|
1928
|
+
const t = Me(e);
|
|
1929
|
+
t && this.removeFeature(t);
|
|
1930
|
+
}
|
|
1931
|
+
/**
|
|
1932
|
+
* @param {import("../events/Event.js").default} evt Event.
|
|
1933
|
+
* @private
|
|
1934
|
+
*/
|
|
1935
|
+
handleFeatureChange_(e) {
|
|
1936
|
+
const t = (
|
|
1937
|
+
/** @type {import("../Feature.js").default} */
|
|
1938
|
+
e.target
|
|
1939
|
+
);
|
|
1940
|
+
if (this.handlingDownUpSequence) {
|
|
1941
|
+
const s = F(t);
|
|
1942
|
+
s in this.pendingFeatures_ || (this.pendingFeatures_[s] = t);
|
|
1943
|
+
} else
|
|
1944
|
+
this.updateFeature_(t);
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* Handle pointer up events.
|
|
1948
|
+
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
1949
|
+
* @return {boolean} If the event was consumed.
|
|
1950
|
+
*/
|
|
1951
|
+
handleUpEvent(e) {
|
|
1952
|
+
const t = Object.values(this.pendingFeatures_);
|
|
1953
|
+
return t.length && (t.forEach(this.updateFeature_.bind(this)), this.pendingFeatures_ = {}), !1;
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* Remove a feature from the collection of features that we may snap to.
|
|
1957
|
+
* @param {import("../Feature.js").default} feature Feature
|
|
1958
|
+
* @param {boolean} [unlisten] Whether to unlisten to the feature change
|
|
1959
|
+
* or not. Defaults to `true`.
|
|
1960
|
+
* @api
|
|
1961
|
+
*/
|
|
1962
|
+
removeFeature(e, t) {
|
|
1963
|
+
const s = t !== void 0 ? t : !0, i = F(e), n = this.indexedFeaturesExtents_[i];
|
|
1964
|
+
if (n) {
|
|
1965
|
+
const r = this.rBush_, o = [];
|
|
1966
|
+
r.forEachInExtent(n, function(a) {
|
|
1967
|
+
e === a.feature && o.push(a);
|
|
1968
|
+
});
|
|
1969
|
+
for (let a = o.length - 1; a >= 0; --a)
|
|
1970
|
+
r.remove(o[a]);
|
|
1971
|
+
}
|
|
1972
|
+
s && (oe(this.featureChangeListenerKeys_[i]), delete this.featureChangeListenerKeys_[i]);
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Remove the interaction from its current map and attach it to the new map.
|
|
1976
|
+
* Subclasses may set up event handlers to get notified about changes to
|
|
1977
|
+
* the map here.
|
|
1978
|
+
* @param {import("../Map.js").default} map Map.
|
|
1979
|
+
*/
|
|
1980
|
+
setMap(e) {
|
|
1981
|
+
const t = this.getMap(), s = this.featuresListenerKeys_, i = (
|
|
1982
|
+
/** @type {Array<import("../Feature.js").default>} */
|
|
1983
|
+
this.getFeatures_()
|
|
1984
|
+
);
|
|
1985
|
+
t && (s.forEach(oe), s.length = 0, this.rBush_.clear(), Object.values(this.featureChangeListenerKeys_).forEach(oe), this.featureChangeListenerKeys_ = {}), super.setMap(e), e && (this.features_ ? s.push(
|
|
1986
|
+
q(
|
|
1987
|
+
this.features_,
|
|
1988
|
+
v.ADD,
|
|
1989
|
+
this.handleFeatureAdd_,
|
|
1990
|
+
this
|
|
1991
|
+
),
|
|
1992
|
+
q(
|
|
1993
|
+
this.features_,
|
|
1994
|
+
v.REMOVE,
|
|
1995
|
+
this.handleFeatureRemove_,
|
|
1996
|
+
this
|
|
1997
|
+
)
|
|
1998
|
+
) : this.source_ && s.push(
|
|
1999
|
+
q(
|
|
2000
|
+
this.source_,
|
|
2001
|
+
J.ADDFEATURE,
|
|
2002
|
+
this.handleFeatureAdd_,
|
|
2003
|
+
this
|
|
2004
|
+
),
|
|
2005
|
+
q(
|
|
2006
|
+
this.source_,
|
|
2007
|
+
J.REMOVEFEATURE,
|
|
2008
|
+
this.handleFeatureRemove_,
|
|
2009
|
+
this
|
|
2010
|
+
)
|
|
2011
|
+
), i.forEach((n) => this.addFeature(n)));
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* @param {import("../pixel.js").Pixel} pixel Pixel
|
|
2015
|
+
* @param {import("../coordinate.js").Coordinate} pixelCoordinate Coordinate
|
|
2016
|
+
* @param {import("../Map.js").default} map Map.
|
|
2017
|
+
* @return {Result|null} Snap result
|
|
2018
|
+
*/
|
|
2019
|
+
snapTo(e, t, s) {
|
|
2020
|
+
s.getView().getProjection();
|
|
2021
|
+
const i = C(t), n = Oe(
|
|
2022
|
+
Ne(
|
|
2023
|
+
E([i]),
|
|
2024
|
+
s.getView().getResolution() * this.pixelTolerance_
|
|
2025
|
+
)
|
|
2026
|
+
), r = this.rBush_.getInExtent(n), o = r.length;
|
|
2027
|
+
if (o === 0)
|
|
2028
|
+
return null;
|
|
2029
|
+
let a, h = 1 / 0, c;
|
|
2030
|
+
const d = this.pixelTolerance_ * this.pixelTolerance_, g = () => {
|
|
2031
|
+
if (a) {
|
|
2032
|
+
const u = s.getPixelFromCoordinate(a);
|
|
2033
|
+
if (R(e, u) <= d)
|
|
2034
|
+
return {
|
|
2035
|
+
vertex: a,
|
|
2036
|
+
vertexPixel: [
|
|
2037
|
+
Math.round(u[0]),
|
|
2038
|
+
Math.round(u[1])
|
|
2039
|
+
],
|
|
2040
|
+
feature: c
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
return null;
|
|
2044
|
+
};
|
|
2045
|
+
if (this.vertex_) {
|
|
2046
|
+
for (let f = 0; f < o; ++f) {
|
|
2047
|
+
const _ = r[f];
|
|
2048
|
+
_.feature.getGeometry().getType() !== "Circle" && _.segment.forEach((x) => {
|
|
2049
|
+
const p = C(x), T = R(i, p);
|
|
2050
|
+
T < h && (a = x, h = T, c = _.feature);
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
const u = g();
|
|
2054
|
+
if (u)
|
|
2055
|
+
return u;
|
|
2056
|
+
}
|
|
2057
|
+
if (this.edge_) {
|
|
2058
|
+
for (let f = 0; f < o; ++f) {
|
|
2059
|
+
let _ = null;
|
|
2060
|
+
const x = r[f];
|
|
2061
|
+
if (x.feature.getGeometry().getType() === "Circle") {
|
|
2062
|
+
let p = x.feature.getGeometry();
|
|
2063
|
+
_ = mt(
|
|
2064
|
+
i,
|
|
2065
|
+
/** @type {import("../geom/Circle.js").default} */
|
|
2066
|
+
p
|
|
2067
|
+
);
|
|
2068
|
+
} else {
|
|
2069
|
+
const [p, T] = x.segment;
|
|
2070
|
+
T && (ue[0] = C(p), ue[1] = C(T), _ = Ve(i, ue));
|
|
2071
|
+
}
|
|
2072
|
+
if (_) {
|
|
2073
|
+
const p = R(i, _);
|
|
2074
|
+
p < h && (a = ie(_), h = p);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
const u = g();
|
|
2078
|
+
if (u)
|
|
2079
|
+
return u;
|
|
2080
|
+
}
|
|
2081
|
+
return null;
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* @param {import("../Feature.js").default} feature Feature
|
|
2085
|
+
* @private
|
|
2086
|
+
*/
|
|
2087
|
+
updateFeature_(e) {
|
|
2088
|
+
this.removeFeature(e, !1), this.addFeature(e, !1);
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2092
|
+
* @param {import("../geom/Circle.js").default} geometry Geometry.
|
|
2093
|
+
* @private
|
|
2094
|
+
*/
|
|
2095
|
+
segmentCircleGeometry_(e, t) {
|
|
2096
|
+
this.getMap().getView().getProjection();
|
|
2097
|
+
const n = yt(t).getCoordinates()[0];
|
|
2098
|
+
for (let r = 0, o = n.length - 1; r < o; ++r)
|
|
2099
|
+
e.push(n.slice(r, r + 2));
|
|
2100
|
+
}
|
|
2101
|
+
/**
|
|
2102
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2103
|
+
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
|
|
2104
|
+
* @private
|
|
2105
|
+
*/
|
|
2106
|
+
segmentGeometryCollectionGeometry_(e, t) {
|
|
2107
|
+
const s = t.getGeometriesArray();
|
|
2108
|
+
for (let i = 0; i < s.length; ++i) {
|
|
2109
|
+
const n = this.GEOMETRY_SEGMENTERS_[s[i].getType()];
|
|
2110
|
+
n && n(e, s[i]);
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
/**
|
|
2114
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2115
|
+
* @param {import("../geom/LineString.js").default} geometry Geometry.
|
|
2116
|
+
* @private
|
|
2117
|
+
*/
|
|
2118
|
+
segmentLineStringGeometry_(e, t) {
|
|
2119
|
+
const s = t.getCoordinates();
|
|
2120
|
+
for (let i = 0, n = s.length - 1; i < n; ++i)
|
|
2121
|
+
e.push(s.slice(i, i + 2));
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2125
|
+
* @param {import("../geom/MultiLineString.js").default} geometry Geometry.
|
|
2126
|
+
* @private
|
|
2127
|
+
*/
|
|
2128
|
+
segmentMultiLineStringGeometry_(e, t) {
|
|
2129
|
+
const s = t.getCoordinates();
|
|
2130
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
2131
|
+
const r = s[i];
|
|
2132
|
+
for (let o = 0, a = r.length - 1; o < a; ++o)
|
|
2133
|
+
e.push(r.slice(o, o + 2));
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2138
|
+
* @param {import("../geom/MultiPoint.js").default} geometry Geometry.
|
|
2139
|
+
* @private
|
|
2140
|
+
*/
|
|
2141
|
+
segmentMultiPointGeometry_(e, t) {
|
|
2142
|
+
t.getCoordinates().forEach((s) => {
|
|
2143
|
+
e.push([s]);
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
/**
|
|
2147
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2148
|
+
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
|
2149
|
+
* @private
|
|
2150
|
+
*/
|
|
2151
|
+
segmentMultiPolygonGeometry_(e, t) {
|
|
2152
|
+
const s = t.getCoordinates();
|
|
2153
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
2154
|
+
const r = s[i];
|
|
2155
|
+
for (let o = 0, a = r.length; o < a; ++o) {
|
|
2156
|
+
const h = r[o];
|
|
2157
|
+
for (let c = 0, d = h.length - 1; c < d; ++c)
|
|
2158
|
+
e.push(h.slice(c, c + 2));
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
/**
|
|
2163
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2164
|
+
* @param {import("../geom/Point.js").default} geometry Geometry.
|
|
2165
|
+
* @private
|
|
2166
|
+
*/
|
|
2167
|
+
segmentPointGeometry_(e, t) {
|
|
2168
|
+
e.push([t.getCoordinates()]);
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2172
|
+
* @param {import("../geom/Polygon.js").default} geometry Geometry.
|
|
2173
|
+
* @private
|
|
2174
|
+
*/
|
|
2175
|
+
segmentPolygonGeometry_(e, t) {
|
|
2176
|
+
const s = t.getCoordinates();
|
|
2177
|
+
for (let i = 0, n = s.length; i < n; ++i) {
|
|
2178
|
+
const r = s[i];
|
|
2179
|
+
for (let o = 0, a = r.length - 1; o < a; ++o)
|
|
2180
|
+
e.push(r.slice(o, o + 2));
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
let Le = null, w = new ye(), P = {
|
|
2185
|
+
layer: new se({
|
|
2186
|
+
source: w,
|
|
2187
|
+
style: lt
|
|
2188
|
+
}),
|
|
2189
|
+
modify: new Tt({ source: w }),
|
|
2190
|
+
draw: null,
|
|
2191
|
+
snap: null,
|
|
2192
|
+
select: new pe({
|
|
2193
|
+
condition: nt,
|
|
2194
|
+
style: dt
|
|
2195
|
+
})
|
|
2196
|
+
};
|
|
2197
|
+
function qt(l) {
|
|
2198
|
+
const e = k.useRef(null), [t, s] = k.useState("Pointer"), [i, n] = k.useState(!1), [r, o] = k.useState({
|
|
2199
|
+
open: !1,
|
|
2200
|
+
buttons: [],
|
|
2201
|
+
position: void 0
|
|
2202
|
+
});
|
|
2203
|
+
k.useEffect(() => (a(), h(), c(), V(), () => {
|
|
2204
|
+
}), []), k.useEffect(() => {
|
|
2205
|
+
if (t !== "Pointer") {
|
|
2206
|
+
if (t === "KML") {
|
|
2207
|
+
re();
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2210
|
+
return x(t), () => {
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
}, [t]), k.useEffect(() => (l.drawingKMLData && T(l.drawingKMLData), () => {
|
|
2214
|
+
}), [l.drawingKMLData]), k.useEffect(() => (l.drawingWKTData && (V(), l.drawingWKTData !== "GEOMETRYCOLLECTION()" && M(l.drawingWKTData)), () => {
|
|
2215
|
+
}), [l.drawingWKTData]);
|
|
2216
|
+
const a = () => {
|
|
2217
|
+
d(), g();
|
|
2218
|
+
}, h = () => {
|
|
2219
|
+
u(), f();
|
|
2220
|
+
}, c = () => {
|
|
2221
|
+
_();
|
|
2222
|
+
}, d = () => {
|
|
2223
|
+
var y;
|
|
2224
|
+
Le = Xe({
|
|
2225
|
+
id: l.id,
|
|
2226
|
+
center: [0, 0],
|
|
2227
|
+
style: "mapbox://styles/mapbox/streets-v11",
|
|
2228
|
+
accessToken: l.mapboxAccessToken
|
|
2229
|
+
}).layer, (y = e.current) == null || y.addLayer(Le);
|
|
2230
|
+
}, g = () => {
|
|
2231
|
+
var m;
|
|
2232
|
+
(m = e.current) == null || m.addLayer(P.layer);
|
|
2233
|
+
}, u = () => {
|
|
2234
|
+
var m;
|
|
2235
|
+
(m = e.current) == null || m.addInteraction(P.select), P.select.on("select", function() {
|
|
2236
|
+
l.onSelect && l.onSelect(P.select.getFeatures().getArray());
|
|
2237
|
+
});
|
|
2238
|
+
}, f = () => {
|
|
2239
|
+
var m;
|
|
2240
|
+
(m = e.current) == null || m.addInteraction(P.modify), P.modify.on("modifyend", () => {
|
|
2241
|
+
setTimeout(() => {
|
|
2242
|
+
l.onDrawEnd && l.onDrawEnd(w.getFeatures());
|
|
2243
|
+
}, 250), p();
|
|
2244
|
+
});
|
|
2245
|
+
}, _ = async () => {
|
|
2246
|
+
var m;
|
|
2247
|
+
(m = e.current) == null || m.on(
|
|
2248
|
+
"contextmenu",
|
|
2249
|
+
async (y) => {
|
|
2250
|
+
var B;
|
|
2251
|
+
y.preventDefault();
|
|
2252
|
+
const S = (B = e.current) == null ? void 0 : B.getEventPixel(y.originalEvent);
|
|
2253
|
+
if (S) {
|
|
2254
|
+
const A = await P.layer.getFeatures(S);
|
|
2255
|
+
if (A && A.length > 0) {
|
|
2256
|
+
o({
|
|
2257
|
+
open: !0,
|
|
2258
|
+
buttons: [
|
|
2259
|
+
{
|
|
2260
|
+
label: "Delete",
|
|
2261
|
+
onClick: () => {
|
|
2262
|
+
A.forEach(
|
|
2263
|
+
(Ye) => G(Ye)
|
|
2264
|
+
), j(), setTimeout(() => {
|
|
2265
|
+
l.onDrawEnd && l.onDrawEnd(w.getFeatures());
|
|
2266
|
+
}, 250);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
],
|
|
2270
|
+
position: {
|
|
2271
|
+
top: S[1],
|
|
2272
|
+
left: S[0]
|
|
2273
|
+
}
|
|
2274
|
+
});
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
j();
|
|
2279
|
+
}
|
|
2280
|
+
);
|
|
2281
|
+
}, x = (m) => {
|
|
2282
|
+
var B, A;
|
|
2283
|
+
p();
|
|
2284
|
+
const y = new Dt({
|
|
2285
|
+
source: w,
|
|
2286
|
+
type: m
|
|
2287
|
+
}), S = new Gt({ source: w });
|
|
2288
|
+
y.on("drawend", () => {
|
|
2289
|
+
setTimeout(() => {
|
|
2290
|
+
l.onDrawEnd && l.onDrawEnd(w.getFeatures());
|
|
2291
|
+
}, 250), p(), s("Pointer");
|
|
2292
|
+
}), P.draw = y, P.snap = S, (B = e.current) == null || B.addInteraction(y), (A = e.current) == null || A.addInteraction(S);
|
|
2293
|
+
}, p = () => {
|
|
2294
|
+
var m, y;
|
|
2295
|
+
P.draw && ((m = e.current) == null || m.removeInteraction(P.draw)), P.snap && ((y = e.current) == null || y.removeInteraction(P.snap));
|
|
2296
|
+
}, T = (m) => {
|
|
2297
|
+
const y = Fe(m);
|
|
2298
|
+
y && w.addFeatures(y);
|
|
2299
|
+
}, M = (m) => {
|
|
2300
|
+
const y = rt(m, ut);
|
|
2301
|
+
y && w.addFeatures(y);
|
|
2302
|
+
}, V = () => {
|
|
2303
|
+
w.clear();
|
|
2304
|
+
}, G = (m) => {
|
|
2305
|
+
w.removeFeature(m);
|
|
2306
|
+
}, j = () => {
|
|
2307
|
+
o({
|
|
2308
|
+
open: !1,
|
|
2309
|
+
buttons: []
|
|
2310
|
+
});
|
|
2311
|
+
}, re = () => {
|
|
2312
|
+
n((m) => !m);
|
|
2313
|
+
}, Ue = (m) => {
|
|
2314
|
+
var S;
|
|
2315
|
+
const y = Fe(m);
|
|
2316
|
+
y ? (re(), w.addFeatures(y), (S = e.current) == null || S.centerToFeature(y[0]), l.onDrawEnd && l.onDrawEnd(y)) : xt("Error!", "Feature(s) could not be loaded! Check your KML data!");
|
|
2317
|
+
}, Ke = (m) => {
|
|
2318
|
+
var y;
|
|
2319
|
+
(y = e.current) == null || y.setCenter(m);
|
|
2320
|
+
}, We = (m) => {
|
|
2321
|
+
var y;
|
|
2322
|
+
(y = e.current) == null || y.setZoomLevel(m);
|
|
2323
|
+
}, He = (m, y = [0, 0, 0, 0]) => {
|
|
2324
|
+
var S;
|
|
2325
|
+
(S = e.current) == null || S.centerToFeature(m, y);
|
|
2326
|
+
}, Ce = (m) => {
|
|
2327
|
+
var y;
|
|
2328
|
+
(y = e.current) == null || y.centerToExtent(m);
|
|
2329
|
+
};
|
|
2330
|
+
return {
|
|
2331
|
+
refs: {
|
|
2332
|
+
mapRef: e
|
|
2333
|
+
},
|
|
2334
|
+
state: {
|
|
2335
|
+
activeDrawingTool: t,
|
|
2336
|
+
openAddKMLText: i,
|
|
2337
|
+
contextMenu: r
|
|
2338
|
+
},
|
|
2339
|
+
action: {
|
|
2340
|
+
setActiveDrawingTool: s,
|
|
2341
|
+
addInteractions: x,
|
|
2342
|
+
addDrawingSourceKMLData: T,
|
|
2343
|
+
addDrawingSourceWKTData: M,
|
|
2344
|
+
clearDrawingSource: V,
|
|
2345
|
+
toggleAddKMLText: re,
|
|
2346
|
+
addKMLText: Ue,
|
|
2347
|
+
setContextMenu: o,
|
|
2348
|
+
setCenter: Ke,
|
|
2349
|
+
setZoomLevel: We,
|
|
2350
|
+
centerToFeature: He,
|
|
2351
|
+
centerToExtent: Ce,
|
|
2352
|
+
onMapInit: () => {
|
|
2353
|
+
l.defaultExtent && Ce(l.defaultExtent);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2358
|
+
export {
|
|
2359
|
+
qt as default
|
|
2360
|
+
};
|