@hybridcore/ui 1.6.11 → 1.6.13
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/{AnimatedTheme-D3VZKKNV.js → AnimatedTheme-ktdO3Bel.js} +6 -6
- package/dist/{AxisRenderer-Doyw-FTI.js → AxisRenderer-BCQoUJw6.js} +6 -6
- package/dist/{AxisRendererY-BylCU67e.js → AxisRendererY-AXWvGU6r.js} +3 -3
- package/dist/{Bullet-C6357hTv.js → Bullet-Djj7Vs9T.js} +1 -1
- package/dist/{Button-DGOT8RcT.js → Button-BLY4PVJC.js} +3 -3
- package/dist/{CategoryAxis-B5uTZjhL.js → CategoryAxis-B6NqW8qd.js} +3 -3
- package/dist/{Circle-DhzVdFBd.js → Circle-BnfBNKBD.js} +1 -1
- package/dist/{ColorSet-DGLMpbL3.js → ColorSet-cyPmWGwh.js} +1 -1
- package/dist/{ColumnSeries-CqJ-563p.js → ColumnSeries-CtRTsn-E.js} +28 -28
- package/dist/{DateAxis-lJZjbAS-.js → DateAxis-DEXKps1S.js} +4 -4
- package/dist/{Entity-4Lr2piVN.js → Entity-BJCuhdq_.js} +14 -14
- package/dist/GaplessDateAxis-B2g2jgSG.js +376 -0
- package/dist/{Hierarchy-DPEcTr0v.js → Hierarchy-CEOK8Gzh.js} +4 -4
- package/dist/{Legend-CTb6rZz_.js → Legend-CFvQiIfn.js} +4 -4
- package/dist/{LineSeries-Dg1aytHA.js → LineSeries-D_IL2qGF.js} +4 -4
- package/dist/{LinearGradient-D1hzMjaW.js → LinearGradient-CxQyCSEB.js} +2 -2
- package/dist/{PieSeries-C9YUWMnA.js → PieSeries-CMH0Z7pz.js} +8 -8
- package/dist/{RoundedRectangle-B23Oh_r6.js → RoundedRectangle-BKLX1LKM.js} +2 -2
- package/dist/{Scrollbar-CSoXoZSe.js → Scrollbar-CTI7_8Qw.js} +4 -4
- package/dist/{Slice-CIP7Vmzu.js → Slice-BUncQh1B.js} +11 -11
- package/dist/{Tick-CRu6rQQy.js → Tick--VhF0xlz.js} +2 -2
- package/dist/{Tooltip-RhAldW7s.js → Tooltip-vyZRZWih.js} +1 -1
- package/dist/{XYCursor-Z-Ral42q.js → XYCursor-CVUSpqb9.js} +3 -3
- package/dist/{ZoomableContainer-D1laxHnA.js → ZoomableContainer-Ca_pDVYQ.js} +2 -2
- package/dist/assets/index.css +1 -1
- package/dist/assets/index2.css +1 -1
- package/dist/components/button/styled.js +1 -1
- package/dist/components/charts/_common/format.js +149 -41
- package/dist/components/charts/_common/tooltip.js +2 -2
- package/dist/components/charts/_common/utils.js +16 -11
- package/dist/components/charts/candlestick/logic.js +34 -35
- package/dist/components/charts/column-line-mix/logic.js +40 -41
- package/dist/components/charts/donut-chart/logic.js +4 -4
- package/dist/components/charts/drill-down-treemap/logic.js +5 -5
- package/dist/components/charts/drill-down-voronoi-treemap/logic.js +5 -5
- package/dist/components/charts/forecast-cone/logic.js +134 -120
- package/dist/components/charts/heatmap/logic.js +9 -9
- package/dist/components/charts/highlighting-line-data/logic.js +10 -10
- package/dist/components/charts/line/logic.js +19 -20
- package/dist/components/charts/logaritmic-scale/logic.js +30 -31
- package/dist/components/charts/multiple-value-axes/logic.js +18 -19
- package/dist/components/charts/nested-pie/logic.js +3 -3
- package/dist/components/charts/packed-circles/logic.js +7 -7
- package/dist/components/charts/pie-chart/logic.js +4 -4
- package/dist/components/charts/stacked-area-radar/logic.js +9 -9
- package/dist/components/charts/stacked-column-chart/logic.js +10 -10
- package/dist/components/charts/xy-chart/logic.js +28 -29
- package/dist/components/collapsible-card/index.js +21 -30
- package/dist/components/collapsible-card/styled.js +16 -14
- package/dist/components/color-picker/index.js +2227 -3357
- package/dist/components/color-picker/styled.js +87 -7
- package/dist/components/confirm/dialog.js +89 -8
- package/dist/components/confirm/index.js +1 -1
- package/dist/components/data-map/index.js +1 -1
- package/dist/components/data-map/logic.js +20 -20
- package/dist/components/data-security-selectors/dissemination-list/index.js +32 -3117
- package/dist/components/date-picker-with-custom-range/index.js +86 -7
- package/dist/components/date-range-picker/index.js +464 -452
- package/dist/components/document-viewer/components/viewer/index.js +1 -1
- package/dist/components/duration-select/index.js +10 -10
- package/dist/components/duration-select/styled.js +1 -1
- package/dist/components/geometry-picker/coordinate/index.js +14 -14
- package/dist/components/geometry-picker/edit/index.js +1 -1
- package/dist/components/geometry-picker/geometry/index.js +1 -1
- package/dist/components/geometry-picker/kml/index.js +11 -11
- package/dist/components/geometry-picker/map/logic.js +145 -3656
- package/dist/components/geometry-picker/map/style.js +18 -17
- package/dist/components/geometry-picker/parser/coordinate-input/logic.js +43 -1255
- package/dist/components/heat-map/index.js +1 -1
- package/dist/components/heat-map/logic.js +77 -1924
- package/dist/components/instance-hierarchy-table/styled.js +18 -16
- package/dist/components/map/helpers/mapbox.js +17 -15
- package/dist/components/map/helpers/ol.js +386 -27
- package/dist/components/map/index.js +11 -10
- package/dist/components/map/logic.js +22 -22
- package/dist/components/map/styled.js +31 -27
- package/dist/components/metric-card/MetricChart.js +9 -9
- package/dist/components/metric-card/logic.js +46 -49
- package/dist/components/phone-input/index.js +10 -9
- package/dist/components/property-mapping/index.js +1 -1
- package/dist/components/prr-map/index.js +1 -1
- package/dist/components/prr-map/logic.js +27 -26
- package/dist/components/range-selector/styled.js +65 -4228
- package/dist/components/raster-grid-map/index.js +1 -1
- package/dist/components/raster-grid-map/logic.js +60 -57
- package/dist/components/simple-pivot-table/index.js +17 -17
- package/dist/components/simple-pivot-table/logic.js +67 -76
- package/dist/components/sortable-list/index.js +1091 -1264
- package/dist/components/template-form/components/property-list/index.js +36 -33
- package/dist/components/template-form/components/property-list/property-list-columns.js +19 -18
- package/dist/components/template-form/components/property-list/property-list-form.js +137 -601
- package/dist/components/template-form/components/recognition-property-list/index.js +40 -37
- package/dist/components/template-form/components/recognition-property-list/recognition-property-list-columns.js +11 -10
- package/dist/components/template-form/components/recognition-property-list/recognition-property-list-form.js +55 -63
- package/dist/components/tree-select/index.js +16 -16
- package/dist/index.esm-UfGMjYOL.js +197 -0
- package/dist/main.d.ts +67 -8
- package/dist/main.js +176 -175
- package/package.json +1 -1
- package/dist/AccordionSummary-CJppWeqF.js +0 -781
- package/dist/Add-CqcD1PWb.js +0 -403
- package/dist/Box-DqUMmZjL.js +0 -31
- package/dist/Button-C5yquWAB.js +0 -357
- package/dist/ButtonBase-BEF7oTOe.js +0 -887
- package/dist/DataProcessor-WXzhvIg6.js +0 -83
- package/dist/Delete-BdyYpINH.js +0 -23
- package/dist/DialogContent-BvVjD9z3.js +0 -523
- package/dist/FormGroup-CpBsIyYR.js +0 -89
- package/dist/GaplessDateAxis-DowssQ6y.js +0 -296
- package/dist/IconButton-BoGwbvrP.js +0 -184
- package/dist/InputLabel-Dd8RrneV.js +0 -341
- package/dist/MenuItem-DwqJqzuM.js +0 -233
- package/dist/Modal-MUZygjmQ.js +0 -1158
- package/dist/Paper-BkQLdsCI.js +0 -582
- package/dist/Select-DHUl_uG3.js +0 -3916
- package/dist/Source-BSZST_GH.js +0 -4410
- package/dist/SwitchBase-DTndTqI8.js +0 -235
- package/dist/Text-ChJRuaD8.js +0 -2197
- package/dist/TextField-e2oKaUN1.js +0 -669
- package/dist/TransitionGroupContext-BDAp2T0O.js +0 -96
- package/dist/Typography-DgsSLCFC.js +0 -178
- package/dist/Vector-BmuhQO4p.js +0 -3606
- package/dist/Vector-DfTqQEln.js +0 -1735
- package/dist/WKT-2wsDT-nq.js +0 -2310
- package/dist/assertThisInitialized-C1dAyb4j.js +0 -7
- package/dist/assets/index3.css +0 -1
- package/dist/assets/index4.css +0 -1
- package/dist/clsx-OuTLNxxd.js +0 -16
- package/dist/createChainedFunction-C0nujS3O.js +0 -9
- package/dist/createSvgIcon-Ch_cT8az.js +0 -185
- package/dist/createSvgIcon-DuDuASu1.js +0 -62
- package/dist/debounce-46wSf_lW.js +0 -15
- package/dist/dialog-BYRnCztH.js +0 -154
- package/dist/formControlState-vgaj2ksH.js +0 -10
- package/dist/generateUtilityClasses-C3ivN9Ie.js +0 -2973
- package/dist/index-DH6qsPBn.js +0 -153
- package/dist/index-e9xTIYWt.js +0 -1934
- package/dist/index.esm-BLLrbTzY.js +0 -318
- package/dist/math-Bvt2Ubuz.js +0 -704
- package/dist/objectWithoutPropertiesLoose-DJteAcBH.js +0 -22
- package/dist/ol-yOE-NV0X.js +0 -7465
- package/dist/ownerWindow-wg6foiOE.js +0 -10
- package/dist/setPrototypeOf-NPgp4cYc.js +0 -8
- package/dist/styled-SoqbyrkW.js +0 -350
- package/dist/unsupportedProp-DuqR2hj9.js +0 -36
- package/dist/useControlled-BYdyS7Pn.js +0 -31
- package/dist/useFormControl-CatNKXAi.js +0 -10
- package/dist/useId-BW-oWmul.js +0 -19
- package/dist/useMobilePicker-CY8ndYRL.js +0 -8279
- package/dist/useSlot-B_Q4vnX5.js +0 -42
|
@@ -1,3709 +1,198 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createMapboxLayer as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class ai extends J {
|
|
21
|
-
/**
|
|
22
|
-
* @param {SelectEventType} type The event type.
|
|
23
|
-
* @param {Array<import("../Feature.js").default>} selected Selected features.
|
|
24
|
-
* @param {Array<import("../Feature.js").default>} deselected Deselected features.
|
|
25
|
-
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Associated
|
|
26
|
-
* {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
|
27
|
-
*/
|
|
28
|
-
constructor(e, t, i, n) {
|
|
29
|
-
super(e), this.selected = t, this.deselected = i, this.mapBrowserEvent = n;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const ie = {};
|
|
33
|
-
class ve extends kt {
|
|
34
|
-
/**
|
|
35
|
-
* @param {Options} [options] Options.
|
|
36
|
-
*/
|
|
37
|
-
constructor(e) {
|
|
38
|
-
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 : et, this.addCondition_ = e.addCondition ? e.addCondition : Pe, this.removeCondition_ = e.removeCondition ? e.removeCondition : Pe, this.toggleCondition_ = e.toggleCondition ? e.toggleCondition : tt, this.multi_ = e.multi ? e.multi : !1, this.filter_ = e.filter ? e.filter : ce, this.hitTolerance_ = e.hitTolerance ? e.hitTolerance : 0, this.style_ = e.style !== void 0 ? e.style : li(), this.features_ = e.features || new we();
|
|
39
|
-
let t;
|
|
40
|
-
if (e.layers)
|
|
41
|
-
if (typeof e.layers == "function")
|
|
42
|
-
t = e.layers;
|
|
43
|
-
else {
|
|
44
|
-
const i = e.layers;
|
|
45
|
-
t = function(n) {
|
|
46
|
-
return i.includes(n);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
else
|
|
50
|
-
t = ce;
|
|
51
|
-
this.layerFilter_ = t, this.featureLayerAssociation_ = {};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @param {import("../Feature.js").default} feature Feature.
|
|
55
|
-
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
addFeatureLayerAssociation_(e, t) {
|
|
59
|
-
this.featureLayerAssociation_[C(e)] = t;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get the selected features.
|
|
63
|
-
* @return {Collection<Feature>} Features collection.
|
|
64
|
-
* @api
|
|
65
|
-
*/
|
|
66
|
-
getFeatures() {
|
|
67
|
-
return this.features_;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Returns the Hit-detection tolerance.
|
|
71
|
-
* @return {number} Hit tolerance in pixels.
|
|
72
|
-
* @api
|
|
73
|
-
*/
|
|
74
|
-
getHitTolerance() {
|
|
75
|
-
return this.hitTolerance_;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Returns the associated {@link module:ol/layer/Vector~VectorLayer vector layer} of
|
|
79
|
-
* a selected feature.
|
|
80
|
-
* @param {import("../Feature.js").default} feature Feature
|
|
81
|
-
* @return {import('../layer/Vector.js').default} Layer.
|
|
82
|
-
* @api
|
|
83
|
-
*/
|
|
84
|
-
getLayer(e) {
|
|
85
|
-
return (
|
|
86
|
-
/** @type {import('../layer/Vector.js').default} */
|
|
87
|
-
this.featureLayerAssociation_[C(e)]
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Hit-detection tolerance. Pixels inside the radius around the given position
|
|
92
|
-
* will be checked for features.
|
|
93
|
-
* @param {number} hitTolerance Hit tolerance in pixels.
|
|
94
|
-
* @api
|
|
95
|
-
*/
|
|
96
|
-
setHitTolerance(e) {
|
|
97
|
-
this.hitTolerance_ = e;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Remove the interaction from its current map, if any, and attach it to a new
|
|
101
|
-
* map, if any. Pass `null` to just remove the interaction from the current map.
|
|
102
|
-
* @param {import("../Map.js").default|null} map Map.
|
|
103
|
-
* @api
|
|
104
|
-
*/
|
|
105
|
-
setMap(e) {
|
|
106
|
-
this.getMap() && this.style_ && this.features_.forEach(this.restorePreviousStyle_.bind(this)), super.setMap(e), e ? (this.features_.addEventListener(
|
|
107
|
-
A.ADD,
|
|
108
|
-
this.boundAddFeature_
|
|
109
|
-
), this.features_.addEventListener(
|
|
110
|
-
A.REMOVE,
|
|
111
|
-
this.boundRemoveFeature_
|
|
112
|
-
), this.style_ && this.features_.forEach(this.applySelectedStyle_.bind(this))) : (this.features_.removeEventListener(
|
|
113
|
-
A.ADD,
|
|
114
|
-
this.boundAddFeature_
|
|
115
|
-
), this.features_.removeEventListener(
|
|
116
|
-
A.REMOVE,
|
|
117
|
-
this.boundRemoveFeature_
|
|
118
|
-
));
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
122
|
-
* @private
|
|
123
|
-
*/
|
|
124
|
-
addFeature_(e) {
|
|
125
|
-
const t = e.element;
|
|
126
|
-
if (this.style_ && this.applySelectedStyle_(t), !this.getLayer(t)) {
|
|
127
|
-
const i = (
|
|
128
|
-
/** @type {VectorLayer} */
|
|
129
|
-
this.getMap().getAllLayers().find(function(n) {
|
|
130
|
-
if (n instanceof ge && n.getSource() && n.getSource().hasFeature(t))
|
|
131
|
-
return n;
|
|
132
|
-
})
|
|
133
|
-
);
|
|
134
|
-
i && this.addFeatureLayerAssociation_(t, i);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
139
|
-
* @private
|
|
140
|
-
*/
|
|
141
|
-
removeFeature_(e) {
|
|
142
|
-
this.style_ && this.restorePreviousStyle_(e.element);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* @return {import("../style/Style.js").StyleLike|null} Select style.
|
|
146
|
-
*/
|
|
147
|
-
getStyle() {
|
|
148
|
-
return this.style_;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* @param {Feature} feature Feature
|
|
152
|
-
* @private
|
|
153
|
-
*/
|
|
154
|
-
applySelectedStyle_(e) {
|
|
155
|
-
const t = C(e);
|
|
156
|
-
t in ie || (ie[t] = e.getStyle()), e.setStyle(this.style_);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* @param {Feature} feature Feature
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
restorePreviousStyle_(e) {
|
|
163
|
-
const t = this.getMap().getInteractions().getArray();
|
|
164
|
-
for (let n = t.length - 1; n >= 0; --n) {
|
|
165
|
-
const s = t[n];
|
|
166
|
-
if (s !== this && s instanceof ve && s.getStyle() && s.getFeatures().getArray().lastIndexOf(e) !== -1) {
|
|
167
|
-
e.setStyle(s.getStyle());
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const i = C(e);
|
|
172
|
-
e.setStyle(ie[i]), delete ie[i];
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* @param {Feature} feature Feature.
|
|
176
|
-
* @private
|
|
177
|
-
*/
|
|
178
|
-
removeFeatureLayerAssociation_(e) {
|
|
179
|
-
delete this.featureLayerAssociation_[C(e)];
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may change the
|
|
183
|
-
* selected state of features.
|
|
184
|
-
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
|
|
185
|
-
* @return {boolean} `false` to stop event propagation.
|
|
186
|
-
*/
|
|
187
|
-
handleEvent(e) {
|
|
188
|
-
if (!this.condition_(e))
|
|
189
|
-
return !0;
|
|
190
|
-
const t = this.addCondition_(e), i = this.removeCondition_(e), n = this.toggleCondition_(e), s = !t && !i && !n, r = e.map, o = this.getFeatures(), a = [], h = [];
|
|
191
|
-
if (s) {
|
|
192
|
-
Ft(this.featureLayerAssociation_), r.forEachFeatureAtPixel(
|
|
193
|
-
e.pixel,
|
|
194
|
-
/**
|
|
195
|
-
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
|
196
|
-
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
197
|
-
* @return {boolean|undefined} Continue to iterate over the features.
|
|
198
|
-
*/
|
|
199
|
-
(c, u) => {
|
|
200
|
-
if (!(!(c instanceof G) || !this.filter_(c, u)))
|
|
201
|
-
return this.addFeatureLayerAssociation_(c, u), h.push(c), !this.multi_;
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
layerFilter: this.layerFilter_,
|
|
205
|
-
hitTolerance: this.hitTolerance_
|
|
206
|
-
}
|
|
207
|
-
);
|
|
208
|
-
for (let c = o.getLength() - 1; c >= 0; --c) {
|
|
209
|
-
const u = o.item(c), g = h.indexOf(u);
|
|
210
|
-
g > -1 ? h.splice(g, 1) : (o.remove(u), a.push(u));
|
|
211
|
-
}
|
|
212
|
-
h.length !== 0 && o.extend(h);
|
|
213
|
-
} else {
|
|
214
|
-
r.forEachFeatureAtPixel(
|
|
215
|
-
e.pixel,
|
|
216
|
-
/**
|
|
217
|
-
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
|
218
|
-
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
219
|
-
* @return {boolean|undefined} Continue to iterate over the features.
|
|
220
|
-
*/
|
|
221
|
-
(c, u) => {
|
|
222
|
-
if (!(!(c instanceof G) || !this.filter_(c, u)))
|
|
223
|
-
return (t || n) && !o.getArray().includes(c) ? (this.addFeatureLayerAssociation_(c, u), h.push(c)) : (i || n) && o.getArray().includes(c) && (a.push(c), this.removeFeatureLayerAssociation_(c)), !this.multi_;
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
layerFilter: this.layerFilter_,
|
|
227
|
-
hitTolerance: this.hitTolerance_
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
for (let c = a.length - 1; c >= 0; --c)
|
|
231
|
-
o.remove(a[c]);
|
|
232
|
-
o.extend(h);
|
|
233
|
-
}
|
|
234
|
-
return (h.length > 0 || a.length > 0) && this.dispatchEvent(
|
|
235
|
-
new ai(
|
|
236
|
-
oi.SELECT,
|
|
237
|
-
h,
|
|
238
|
-
a,
|
|
239
|
-
e
|
|
240
|
-
)
|
|
241
|
-
), !0;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
function li() {
|
|
245
|
-
const l = ke();
|
|
246
|
-
return Oe(l.Polygon, l.LineString), Oe(l.GeometryCollection, l.LineString), function(e) {
|
|
247
|
-
return e.getGeometry() ? l[e.getGeometry().getType()] : null;
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
const Ne = 0, H = 1, Ve = [0, 0, 0, 0], Z = [], xe = {
|
|
251
|
-
/**
|
|
252
|
-
* Triggered upon feature modification start
|
|
253
|
-
* @event ModifyEvent#modifystart
|
|
254
|
-
* @api
|
|
255
|
-
*/
|
|
256
|
-
MODIFYSTART: "modifystart",
|
|
257
|
-
/**
|
|
258
|
-
* Triggered upon feature modification end
|
|
259
|
-
* @event ModifyEvent#modifyend
|
|
260
|
-
* @api
|
|
261
|
-
*/
|
|
262
|
-
MODIFYEND: "modifyend"
|
|
263
|
-
};
|
|
264
|
-
class Ce extends J {
|
|
265
|
-
/**
|
|
266
|
-
* @param {ModifyEventType} type Type.
|
|
267
|
-
* @param {Collection<Feature>} features
|
|
268
|
-
* The features modified.
|
|
269
|
-
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent
|
|
270
|
-
* Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
|
271
|
-
*/
|
|
272
|
-
constructor(e, t, i) {
|
|
273
|
-
super(e), this.features = t, this.mapBrowserEvent = i;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
class hi extends Me {
|
|
277
|
-
/**
|
|
278
|
-
* @param {Options} options Options.
|
|
279
|
-
*/
|
|
280
|
-
constructor(e) {
|
|
281
|
-
super(
|
|
282
|
-
/** @type {import("./Pointer.js").Options} */
|
|
283
|
-
e
|
|
284
|
-
), this.on, this.once, this.un, this.boundHandleFeatureChange_ = this.handleFeatureChange_.bind(this), this.condition_ = e.condition ? e.condition : Gt, this.defaultDeleteCondition_ = function(i) {
|
|
285
|
-
return vt(i) && et(i);
|
|
286
|
-
}, this.deleteCondition_ = e.deleteCondition ? e.deleteCondition : this.defaultDeleteCondition_, this.insertVertexCondition_ = e.insertVertexCondition ? e.insertVertexCondition : Le, this.vertexFeature_ = null, this.vertexSegments_ = null, this.lastPixel_ = [0, 0], this.ignoreNextSingleClick_ = !1, this.featuresBeingModified_ = null, this.rBush_ = new Be(), this.pixelTolerance_ = e.pixelTolerance !== void 0 ? e.pixelTolerance : 10, this.snappedToVertex_ = !1, this.changingFeature_ = !1, this.dragSegments_ = [], this.overlay_ = new ge({
|
|
287
|
-
source: new De({
|
|
288
|
-
useSpatialIndex: !1,
|
|
289
|
-
wrapX: !!e.wrapX
|
|
290
|
-
}),
|
|
291
|
-
style: e.style ? e.style : ui(),
|
|
292
|
-
updateWhileAnimating: !0,
|
|
293
|
-
updateWhileInteracting: !0
|
|
294
|
-
}), this.SEGMENT_WRITERS_ = {
|
|
295
|
-
Point: this.writePointGeometry_.bind(this),
|
|
296
|
-
LineString: this.writeLineStringGeometry_.bind(this),
|
|
297
|
-
LinearRing: this.writeLineStringGeometry_.bind(this),
|
|
298
|
-
Polygon: this.writePolygonGeometry_.bind(this),
|
|
299
|
-
MultiPoint: this.writeMultiPointGeometry_.bind(this),
|
|
300
|
-
MultiLineString: this.writeMultiLineStringGeometry_.bind(this),
|
|
301
|
-
MultiPolygon: this.writeMultiPolygonGeometry_.bind(this),
|
|
302
|
-
Circle: this.writeCircleGeometry_.bind(this),
|
|
303
|
-
GeometryCollection: this.writeGeometryCollectionGeometry_.bind(this)
|
|
304
|
-
}, this.source_ = null, this.hitDetection_ = null;
|
|
305
|
-
let t;
|
|
306
|
-
if (e.features ? t = e.features : e.source && (this.source_ = e.source, t = new we(this.source_.getFeatures()), this.source_.addEventListener(
|
|
307
|
-
he.ADDFEATURE,
|
|
308
|
-
this.handleSourceAdd_.bind(this)
|
|
309
|
-
), this.source_.addEventListener(
|
|
310
|
-
he.REMOVEFEATURE,
|
|
311
|
-
this.handleSourceRemove_.bind(this)
|
|
312
|
-
)), !t)
|
|
313
|
-
throw new Error(
|
|
314
|
-
"The modify interaction requires features, a source or a layer"
|
|
315
|
-
);
|
|
316
|
-
e.hitDetection && (this.hitDetection_ = e.hitDetection), this.features_ = t, this.features_.forEach(this.addFeature_.bind(this)), this.features_.addEventListener(
|
|
317
|
-
A.ADD,
|
|
318
|
-
this.handleFeatureAdd_.bind(this)
|
|
319
|
-
), this.features_.addEventListener(
|
|
320
|
-
A.REMOVE,
|
|
321
|
-
this.handleFeatureRemove_.bind(this)
|
|
322
|
-
), this.lastPointerEvent_ = null, this.delta_ = [0, 0], this.snapToPointer_ = e.snapToPointer === void 0 ? !this.hitDetection_ : e.snapToPointer;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* @param {Feature} feature Feature.
|
|
326
|
-
* @private
|
|
327
|
-
*/
|
|
328
|
-
addFeature_(e) {
|
|
329
|
-
const t = e.getGeometry();
|
|
330
|
-
if (t) {
|
|
331
|
-
const n = this.SEGMENT_WRITERS_[t.getType()];
|
|
332
|
-
n && n(e, t);
|
|
333
|
-
}
|
|
334
|
-
const i = this.getMap();
|
|
335
|
-
i && i.isRendered() && this.getActive() && this.handlePointerAtPixel_(this.lastPixel_, i), e.addEventListener($.CHANGE, this.boundHandleFeatureChange_);
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* @param {import("../MapBrowserEvent.js").default} evt Map browser event.
|
|
339
|
-
* @param {Array<Array<SegmentData>>} segments The segments subject to modification.
|
|
340
|
-
* @private
|
|
341
|
-
*/
|
|
342
|
-
willModifyFeatures_(e, t) {
|
|
343
|
-
if (!this.featuresBeingModified_) {
|
|
344
|
-
this.featuresBeingModified_ = new we();
|
|
345
|
-
const i = this.featuresBeingModified_.getArray();
|
|
346
|
-
for (let n = 0, s = t.length; n < s; ++n) {
|
|
347
|
-
const r = t[n];
|
|
348
|
-
for (let o = 0, a = r.length; o < a; ++o) {
|
|
349
|
-
const h = r[o].feature;
|
|
350
|
-
h && !i.includes(h) && this.featuresBeingModified_.push(h);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
this.featuresBeingModified_.getLength() === 0 ? this.featuresBeingModified_ = null : this.dispatchEvent(
|
|
354
|
-
new Ce(
|
|
355
|
-
xe.MODIFYSTART,
|
|
356
|
-
this.featuresBeingModified_,
|
|
357
|
-
e
|
|
358
|
-
)
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* @param {Feature} feature Feature.
|
|
364
|
-
* @private
|
|
365
|
-
*/
|
|
366
|
-
removeFeature_(e) {
|
|
367
|
-
this.removeFeatureSegmentData_(e), this.vertexFeature_ && this.features_.getLength() === 0 && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), e.removeEventListener(
|
|
368
|
-
$.CHANGE,
|
|
369
|
-
this.boundHandleFeatureChange_
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* @param {Feature} feature Feature.
|
|
374
|
-
* @private
|
|
375
|
-
*/
|
|
376
|
-
removeFeatureSegmentData_(e) {
|
|
377
|
-
const t = this.rBush_, i = [];
|
|
378
|
-
t.forEach(
|
|
379
|
-
/**
|
|
380
|
-
* @param {SegmentData} node RTree node.
|
|
381
|
-
*/
|
|
382
|
-
function(n) {
|
|
383
|
-
e === n.feature && i.push(n);
|
|
384
|
-
}
|
|
385
|
-
);
|
|
386
|
-
for (let n = i.length - 1; n >= 0; --n) {
|
|
387
|
-
const s = i[n];
|
|
388
|
-
for (let r = this.dragSegments_.length - 1; r >= 0; --r)
|
|
389
|
-
this.dragSegments_[r][0] === s && this.dragSegments_.splice(r, 1);
|
|
390
|
-
t.remove(s);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Activate or deactivate the interaction.
|
|
395
|
-
* @param {boolean} active Active.
|
|
396
|
-
* @observable
|
|
397
|
-
* @api
|
|
398
|
-
*/
|
|
399
|
-
setActive(e) {
|
|
400
|
-
this.vertexFeature_ && !e && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), super.setActive(e);
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Remove the interaction from its current map and attach it to the new map.
|
|
404
|
-
* Subclasses may set up event handlers to get notified about changes to
|
|
405
|
-
* the map here.
|
|
406
|
-
* @param {import("../Map.js").default} map Map.
|
|
407
|
-
*/
|
|
408
|
-
setMap(e) {
|
|
409
|
-
this.overlay_.setMap(e), super.setMap(e);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Get the overlay layer that this interaction renders the modification point or vertex to.
|
|
413
|
-
* @return {VectorLayer} Overlay layer.
|
|
414
|
-
* @api
|
|
415
|
-
*/
|
|
416
|
-
getOverlay() {
|
|
417
|
-
return this.overlay_;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* @param {import("../source/Vector.js").VectorSourceEvent} event Event.
|
|
421
|
-
* @private
|
|
422
|
-
*/
|
|
423
|
-
handleSourceAdd_(e) {
|
|
424
|
-
e.feature && this.features_.push(e.feature);
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* @param {import("../source/Vector.js").VectorSourceEvent} event Event.
|
|
428
|
-
* @private
|
|
429
|
-
*/
|
|
430
|
-
handleSourceRemove_(e) {
|
|
431
|
-
e.feature && this.features_.remove(e.feature);
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
435
|
-
* @private
|
|
436
|
-
*/
|
|
437
|
-
handleFeatureAdd_(e) {
|
|
438
|
-
this.addFeature_(e.element);
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* @param {import("../events/Event.js").default} evt Event.
|
|
442
|
-
* @private
|
|
443
|
-
*/
|
|
444
|
-
handleFeatureChange_(e) {
|
|
445
|
-
if (!this.changingFeature_) {
|
|
446
|
-
const t = (
|
|
447
|
-
/** @type {Feature} */
|
|
448
|
-
e.target
|
|
449
|
-
);
|
|
450
|
-
this.removeFeature_(t), this.addFeature_(t);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
|
|
455
|
-
* @private
|
|
456
|
-
*/
|
|
457
|
-
handleFeatureRemove_(e) {
|
|
458
|
-
this.removeFeature_(e.element);
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* @param {Feature} feature Feature
|
|
462
|
-
* @param {Point} geometry Geometry.
|
|
463
|
-
* @private
|
|
464
|
-
*/
|
|
465
|
-
writePointGeometry_(e, t) {
|
|
466
|
-
const i = t.getCoordinates(), n = {
|
|
467
|
-
feature: e,
|
|
468
|
-
geometry: t,
|
|
469
|
-
segment: [i, i]
|
|
470
|
-
};
|
|
471
|
-
this.rBush_.insert(t.getExtent(), n);
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* @param {Feature} feature Feature
|
|
475
|
-
* @param {import("../geom/MultiPoint.js").default} geometry Geometry.
|
|
476
|
-
* @private
|
|
477
|
-
*/
|
|
478
|
-
writeMultiPointGeometry_(e, t) {
|
|
479
|
-
const i = t.getCoordinates();
|
|
480
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
481
|
-
const r = i[n], o = {
|
|
482
|
-
feature: e,
|
|
483
|
-
geometry: t,
|
|
484
|
-
depth: [n],
|
|
485
|
-
index: n,
|
|
486
|
-
segment: [r, r]
|
|
487
|
-
};
|
|
488
|
-
this.rBush_.insert(t.getExtent(), o);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* @param {Feature} feature Feature
|
|
493
|
-
* @param {import("../geom/LineString.js").default} geometry Geometry.
|
|
494
|
-
* @private
|
|
495
|
-
*/
|
|
496
|
-
writeLineStringGeometry_(e, t) {
|
|
497
|
-
const i = t.getCoordinates();
|
|
498
|
-
for (let n = 0, s = i.length - 1; n < s; ++n) {
|
|
499
|
-
const r = i.slice(n, n + 2), o = {
|
|
500
|
-
feature: e,
|
|
501
|
-
geometry: t,
|
|
502
|
-
index: n,
|
|
503
|
-
segment: r
|
|
504
|
-
};
|
|
505
|
-
this.rBush_.insert(P(r), o);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* @param {Feature} feature Feature
|
|
510
|
-
* @param {import("../geom/MultiLineString.js").default} geometry Geometry.
|
|
511
|
-
* @private
|
|
512
|
-
*/
|
|
513
|
-
writeMultiLineStringGeometry_(e, t) {
|
|
514
|
-
const i = t.getCoordinates();
|
|
515
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
516
|
-
const r = i[n];
|
|
517
|
-
for (let o = 0, a = r.length - 1; o < a; ++o) {
|
|
518
|
-
const h = r.slice(o, o + 2), c = {
|
|
519
|
-
feature: e,
|
|
520
|
-
geometry: t,
|
|
521
|
-
depth: [n],
|
|
522
|
-
index: o,
|
|
523
|
-
segment: h
|
|
524
|
-
};
|
|
525
|
-
this.rBush_.insert(P(h), c);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* @param {Feature} feature Feature
|
|
531
|
-
* @param {import("../geom/Polygon.js").default} geometry Geometry.
|
|
532
|
-
* @private
|
|
533
|
-
*/
|
|
534
|
-
writePolygonGeometry_(e, t) {
|
|
535
|
-
const i = t.getCoordinates();
|
|
536
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
537
|
-
const r = i[n];
|
|
538
|
-
for (let o = 0, a = r.length - 1; o < a; ++o) {
|
|
539
|
-
const h = r.slice(o, o + 2), c = {
|
|
540
|
-
feature: e,
|
|
541
|
-
geometry: t,
|
|
542
|
-
depth: [n],
|
|
543
|
-
index: o,
|
|
544
|
-
segment: h
|
|
545
|
-
};
|
|
546
|
-
this.rBush_.insert(P(h), c);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* @param {Feature} feature Feature
|
|
552
|
-
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
|
553
|
-
* @private
|
|
554
|
-
*/
|
|
555
|
-
writeMultiPolygonGeometry_(e, t) {
|
|
556
|
-
const i = t.getCoordinates();
|
|
557
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
558
|
-
const r = i[n];
|
|
559
|
-
for (let o = 0, a = r.length; o < a; ++o) {
|
|
560
|
-
const h = r[o];
|
|
561
|
-
for (let c = 0, u = h.length - 1; c < u; ++c) {
|
|
562
|
-
const g = h.slice(c, c + 2), d = {
|
|
563
|
-
feature: e,
|
|
564
|
-
geometry: t,
|
|
565
|
-
depth: [o, n],
|
|
566
|
-
index: c,
|
|
567
|
-
segment: g
|
|
568
|
-
};
|
|
569
|
-
this.rBush_.insert(P(g), d);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* We convert a circle into two segments. The segment at index
|
|
576
|
-
* {@link CIRCLE_CENTER_INDEX} is the
|
|
577
|
-
* circle's center (a point). The segment at index
|
|
578
|
-
* {@link CIRCLE_CIRCUMFERENCE_INDEX} is
|
|
579
|
-
* the circumference, and is not a line segment.
|
|
580
|
-
*
|
|
581
|
-
* @param {Feature} feature Feature.
|
|
582
|
-
* @param {import("../geom/Circle.js").default} geometry Geometry.
|
|
583
|
-
* @private
|
|
584
|
-
*/
|
|
585
|
-
writeCircleGeometry_(e, t) {
|
|
586
|
-
const i = t.getCenter(), n = {
|
|
587
|
-
feature: e,
|
|
588
|
-
geometry: t,
|
|
589
|
-
index: Ne,
|
|
590
|
-
segment: [i, i]
|
|
591
|
-
}, s = {
|
|
592
|
-
feature: e,
|
|
593
|
-
geometry: t,
|
|
594
|
-
index: H,
|
|
595
|
-
segment: [i, i]
|
|
596
|
-
}, r = [n, s];
|
|
597
|
-
n.featureSegments = r, s.featureSegments = r, this.rBush_.insert(ye(i), n);
|
|
598
|
-
let o = (
|
|
599
|
-
/** @type {import("../geom/Geometry.js").default} */
|
|
600
|
-
t
|
|
601
|
-
);
|
|
602
|
-
this.rBush_.insert(o.getExtent(), s);
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* @param {Feature} feature Feature
|
|
606
|
-
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
|
|
607
|
-
* @private
|
|
608
|
-
*/
|
|
609
|
-
writeGeometryCollectionGeometry_(e, t) {
|
|
610
|
-
const i = t.getGeometriesArray();
|
|
611
|
-
for (let n = 0; n < i.length; ++n) {
|
|
612
|
-
const s = i[n], r = this.SEGMENT_WRITERS_[s.getType()];
|
|
613
|
-
r(e, s);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
|
|
618
|
-
* @param {Array<Feature>} features The features being modified.
|
|
619
|
-
* @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified.
|
|
620
|
-
* @return {Feature} Vertex feature.
|
|
621
|
-
* @private
|
|
622
|
-
*/
|
|
623
|
-
createOrUpdateVertexFeature_(e, t, i) {
|
|
624
|
-
let n = this.vertexFeature_;
|
|
625
|
-
return n ? n.getGeometry().setCoordinates(e) : (n = new G(new W(e)), this.vertexFeature_ = n, this.overlay_.getSource().addFeature(n)), n.set("features", t), n.set("geometries", i), n;
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may modify the geometry.
|
|
629
|
-
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
|
|
630
|
-
* @return {boolean} `false` to stop event propagation.
|
|
631
|
-
*/
|
|
632
|
-
handleEvent(e) {
|
|
633
|
-
if (!e.originalEvent)
|
|
634
|
-
return !0;
|
|
635
|
-
this.lastPointerEvent_ = e;
|
|
636
|
-
let t;
|
|
637
|
-
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;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Handle pointer drag events.
|
|
641
|
-
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
642
|
-
*/
|
|
643
|
-
handleDragEvent(e) {
|
|
644
|
-
this.ignoreNextSingleClick_ = !1, this.willModifyFeatures_(e, this.dragSegments_);
|
|
645
|
-
const t = [
|
|
646
|
-
e.coordinate[0] + this.delta_[0],
|
|
647
|
-
e.coordinate[1] + this.delta_[1]
|
|
648
|
-
], i = [], n = [];
|
|
649
|
-
for (let s = 0, r = this.dragSegments_.length; s < r; ++s) {
|
|
650
|
-
const o = this.dragSegments_[s], a = o[0], h = a.feature;
|
|
651
|
-
i.includes(h) || i.push(h);
|
|
652
|
-
const c = a.geometry;
|
|
653
|
-
n.includes(c) || n.push(c);
|
|
654
|
-
const u = a.depth;
|
|
655
|
-
let g;
|
|
656
|
-
const d = a.segment, f = o[1];
|
|
657
|
-
for (; t.length < c.getStride(); )
|
|
658
|
-
t.push(d[f][t.length]);
|
|
659
|
-
switch (c.getType()) {
|
|
660
|
-
case "Point":
|
|
661
|
-
g = t, d[0] = t, d[1] = t;
|
|
662
|
-
break;
|
|
663
|
-
case "MultiPoint":
|
|
664
|
-
g = c.getCoordinates(), g[a.index] = t, d[0] = t, d[1] = t;
|
|
665
|
-
break;
|
|
666
|
-
case "LineString":
|
|
667
|
-
g = c.getCoordinates(), g[a.index + f] = t, d[f] = t;
|
|
668
|
-
break;
|
|
669
|
-
case "MultiLineString":
|
|
670
|
-
g = c.getCoordinates(), g[u[0]][a.index + f] = t, d[f] = t;
|
|
671
|
-
break;
|
|
672
|
-
case "Polygon":
|
|
673
|
-
g = c.getCoordinates(), g[u[0]][a.index + f] = t, d[f] = t;
|
|
674
|
-
break;
|
|
675
|
-
case "MultiPolygon":
|
|
676
|
-
g = c.getCoordinates(), g[u[1]][u[0]][a.index + f] = t, d[f] = t;
|
|
677
|
-
break;
|
|
678
|
-
case "Circle":
|
|
679
|
-
if (d[0] = t, d[1] = t, a.index === Ne)
|
|
680
|
-
this.changingFeature_ = !0, c.setCenter(t), this.changingFeature_ = !1;
|
|
681
|
-
else {
|
|
682
|
-
this.changingFeature_ = !0, e.map.getView().getProjection();
|
|
683
|
-
let _ = ue(
|
|
684
|
-
p(c.getCenter()),
|
|
685
|
-
p(t)
|
|
686
|
-
);
|
|
687
|
-
c.setRadius(_), this.changingFeature_ = !1;
|
|
688
|
-
}
|
|
689
|
-
break;
|
|
690
|
-
}
|
|
691
|
-
g && this.setGeometryCoordinates_(c, g);
|
|
692
|
-
}
|
|
693
|
-
this.createOrUpdateVertexFeature_(t, i, n);
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* Handle pointer down events.
|
|
697
|
-
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
698
|
-
* @return {boolean} If the event was consumed.
|
|
699
|
-
*/
|
|
700
|
-
handleDownEvent(e) {
|
|
701
|
-
if (!this.condition_(e))
|
|
702
|
-
return !1;
|
|
703
|
-
const t = e.coordinate;
|
|
704
|
-
this.handlePointerAtPixel_(e.pixel, e.map, t), this.dragSegments_.length = 0, this.featuresBeingModified_ = null;
|
|
705
|
-
const i = this.vertexFeature_;
|
|
706
|
-
if (i) {
|
|
707
|
-
e.map.getView().getProjection();
|
|
708
|
-
const n = [], s = i.getGeometry().getCoordinates(), r = P([s]), o = this.rBush_.getInExtent(r), a = {};
|
|
709
|
-
o.sort(ci);
|
|
710
|
-
for (let h = 0, c = o.length; h < c; ++h) {
|
|
711
|
-
const u = o[h], g = u.segment;
|
|
712
|
-
let d = C(u.geometry);
|
|
713
|
-
const f = u.depth;
|
|
714
|
-
if (f && (d += "-" + f.join("-")), a[d] || (a[d] = new Array(2)), u.geometry.getType() === "Circle" && u.index === H) {
|
|
715
|
-
const _ = Ze(
|
|
716
|
-
t,
|
|
717
|
-
u
|
|
718
|
-
);
|
|
719
|
-
b(_, s) && !a[d][0] && (this.dragSegments_.push([u, 0]), a[d][0] = u);
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
722
|
-
if (b(g[0], s) && !a[d][0]) {
|
|
723
|
-
this.dragSegments_.push([u, 0]), a[d][0] = u;
|
|
724
|
-
continue;
|
|
725
|
-
}
|
|
726
|
-
if (b(g[1], s) && !a[d][1]) {
|
|
727
|
-
if (a[d][0] && a[d][0].index === 0) {
|
|
728
|
-
let _ = u.geometry.getCoordinates();
|
|
729
|
-
switch (u.geometry.getType()) {
|
|
730
|
-
case "LineString":
|
|
731
|
-
case "MultiLineString":
|
|
732
|
-
continue;
|
|
733
|
-
case "MultiPolygon":
|
|
734
|
-
_ = _[f[1]];
|
|
735
|
-
case "Polygon":
|
|
736
|
-
if (u.index !== _[f[0]].length - 2)
|
|
737
|
-
continue;
|
|
738
|
-
break;
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
this.dragSegments_.push([u, 1]), a[d][1] = u;
|
|
742
|
-
continue;
|
|
743
|
-
}
|
|
744
|
-
C(g) in this.vertexSegments_ && !a[d][0] && !a[d][1] && this.insertVertexCondition_(e) && n.push(u);
|
|
745
|
-
}
|
|
746
|
-
n.length && this.willModifyFeatures_(e, [n]);
|
|
747
|
-
for (let h = n.length - 1; h >= 0; --h)
|
|
748
|
-
this.insertVertex_(n[h], s);
|
|
749
|
-
}
|
|
750
|
-
return !!this.vertexFeature_;
|
|
751
|
-
}
|
|
752
|
-
/**
|
|
753
|
-
* Handle pointer up events.
|
|
754
|
-
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
755
|
-
* @return {boolean} If the event was consumed.
|
|
756
|
-
*/
|
|
757
|
-
handleUpEvent(e) {
|
|
758
|
-
for (let t = this.dragSegments_.length - 1; t >= 0; --t) {
|
|
759
|
-
const i = this.dragSegments_[t][0], n = i.geometry;
|
|
760
|
-
if (n.getType() === "Circle") {
|
|
761
|
-
const s = n.getCenter(), r = i.featureSegments[0], o = i.featureSegments[1];
|
|
762
|
-
r.segment[0] = s, r.segment[1] = s, o.segment[0] = s, o.segment[1] = s, this.rBush_.update(ye(s), r);
|
|
763
|
-
let a = n;
|
|
764
|
-
this.rBush_.update(
|
|
765
|
-
a.getExtent(),
|
|
766
|
-
o
|
|
767
|
-
);
|
|
768
|
-
} else
|
|
769
|
-
this.rBush_.update(P(i.segment), i);
|
|
770
|
-
}
|
|
771
|
-
return this.featuresBeingModified_ && (this.dispatchEvent(
|
|
772
|
-
new Ce(
|
|
773
|
-
xe.MODIFYEND,
|
|
774
|
-
this.featuresBeingModified_,
|
|
775
|
-
e
|
|
776
|
-
)
|
|
777
|
-
), this.featuresBeingModified_ = null), !1;
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
781
|
-
* @private
|
|
782
|
-
*/
|
|
783
|
-
handlePointerMove_(e) {
|
|
784
|
-
this.lastPixel_ = e.pixel, this.handlePointerAtPixel_(e.pixel, e.map, e.coordinate);
|
|
785
|
-
}
|
|
786
|
-
/**
|
|
787
|
-
* @param {import("../pixel.js").Pixel} pixel Pixel
|
|
788
|
-
* @param {import("../Map.js").default} map Map.
|
|
789
|
-
* @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate.
|
|
790
|
-
* @private
|
|
791
|
-
*/
|
|
792
|
-
handlePointerAtPixel_(e, t, i) {
|
|
793
|
-
const n = i || t.getCoordinateFromPixel(e);
|
|
794
|
-
t.getView().getProjection();
|
|
795
|
-
const s = function(a, h) {
|
|
796
|
-
return Xe(n, a) - Xe(n, h);
|
|
797
|
-
};
|
|
798
|
-
let r, o;
|
|
799
|
-
if (this.hitDetection_) {
|
|
800
|
-
const a = typeof this.hitDetection_ == "object" ? (h) => h === this.hitDetection_ : void 0;
|
|
801
|
-
t.forEachFeatureAtPixel(
|
|
802
|
-
e,
|
|
803
|
-
(h, c, u) => {
|
|
804
|
-
u && (u = new W(
|
|
805
|
-
de(u.getCoordinates())
|
|
806
|
-
));
|
|
807
|
-
const g = u || h.getGeometry();
|
|
808
|
-
if (g.getType() === "Point" && h instanceof G && this.features_.getArray().includes(h)) {
|
|
809
|
-
o = /** @type {Point} */
|
|
810
|
-
g;
|
|
811
|
-
const d = (
|
|
812
|
-
/** @type {Point} */
|
|
813
|
-
h.getGeometry().getFlatCoordinates().slice(0, 2)
|
|
814
|
-
);
|
|
815
|
-
r = [
|
|
816
|
-
{
|
|
817
|
-
feature: h,
|
|
818
|
-
geometry: o,
|
|
819
|
-
segment: [d, d]
|
|
820
|
-
}
|
|
821
|
-
];
|
|
822
|
-
}
|
|
823
|
-
return !0;
|
|
824
|
-
},
|
|
825
|
-
{ layerFilter: a }
|
|
826
|
-
);
|
|
827
|
-
}
|
|
828
|
-
if (!r) {
|
|
829
|
-
const a = qt(
|
|
830
|
-
ye(n, Ve)
|
|
831
|
-
), h = t.getView().getResolution() * this.pixelTolerance_, c = it(
|
|
832
|
-
nt(a, h, Ve)
|
|
833
|
-
);
|
|
834
|
-
r = this.rBush_.getInExtent(c);
|
|
835
|
-
}
|
|
836
|
-
if (r && r.length > 0) {
|
|
837
|
-
const a = r.sort(s)[0], h = a.segment;
|
|
838
|
-
let c = Ze(n, a);
|
|
839
|
-
const u = t.getPixelFromCoordinate(c);
|
|
840
|
-
let g = ue(e, u);
|
|
841
|
-
if (o || g <= this.pixelTolerance_) {
|
|
842
|
-
const d = {};
|
|
843
|
-
if (d[C(h)] = !0, this.snapToPointer_ || (this.delta_[0] = c[0] - n[0], this.delta_[1] = c[1] - n[1]), a.geometry.getType() === "Circle" && a.index === H)
|
|
844
|
-
this.snappedToVertex_ = !0, this.createOrUpdateVertexFeature_(
|
|
845
|
-
c,
|
|
846
|
-
[a.feature],
|
|
847
|
-
[a.geometry]
|
|
848
|
-
);
|
|
849
|
-
else {
|
|
850
|
-
const f = t.getPixelFromCoordinate(h[0]), _ = t.getPixelFromCoordinate(h[1]), x = O(u, f), T = O(u, _);
|
|
851
|
-
g = Math.sqrt(Math.min(x, T)), this.snappedToVertex_ = g <= this.pixelTolerance_, this.snappedToVertex_ && (c = x > T ? h[1] : h[0]), this.createOrUpdateVertexFeature_(
|
|
852
|
-
c,
|
|
853
|
-
[a.feature],
|
|
854
|
-
[a.geometry]
|
|
855
|
-
);
|
|
856
|
-
const F = {};
|
|
857
|
-
F[C(a.geometry)] = !0;
|
|
858
|
-
for (let E = 1, q = r.length; E < q; ++E) {
|
|
859
|
-
const k = r[E].segment;
|
|
860
|
-
if (b(h[0], k[0]) && b(h[1], k[1]) || b(h[0], k[1]) && b(h[1], k[0])) {
|
|
861
|
-
const Q = C(r[E].geometry);
|
|
862
|
-
Q in F || (F[Q] = !0, d[C(k)] = !0);
|
|
863
|
-
} else
|
|
864
|
-
break;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
this.vertexSegments_ = d;
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
this.vertexFeature_ && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null);
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* @param {SegmentData} segmentData Segment data.
|
|
875
|
-
* @param {import("../coordinate.js").Coordinate} vertex Vertex.
|
|
876
|
-
* @private
|
|
877
|
-
*/
|
|
878
|
-
insertVertex_(e, t) {
|
|
879
|
-
const i = e.segment, n = e.feature, s = e.geometry, r = e.depth, o = e.index;
|
|
880
|
-
let a;
|
|
881
|
-
for (; t.length < s.getStride(); )
|
|
882
|
-
t.push(0);
|
|
883
|
-
switch (s.getType()) {
|
|
884
|
-
case "MultiLineString":
|
|
885
|
-
a = s.getCoordinates(), a[r[0]].splice(o + 1, 0, t);
|
|
886
|
-
break;
|
|
887
|
-
case "Polygon":
|
|
888
|
-
a = s.getCoordinates(), a[r[0]].splice(o + 1, 0, t);
|
|
889
|
-
break;
|
|
890
|
-
case "MultiPolygon":
|
|
891
|
-
a = s.getCoordinates(), a[r[1]][r[0]].splice(o + 1, 0, t);
|
|
892
|
-
break;
|
|
893
|
-
case "LineString":
|
|
894
|
-
a = s.getCoordinates(), a.splice(o + 1, 0, t);
|
|
895
|
-
break;
|
|
896
|
-
default:
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
this.setGeometryCoordinates_(s, a);
|
|
900
|
-
const h = this.rBush_;
|
|
901
|
-
h.remove(e), this.updateSegmentIndices_(s, o, r, 1);
|
|
902
|
-
const c = {
|
|
903
|
-
segment: [i[0], t],
|
|
904
|
-
feature: n,
|
|
905
|
-
geometry: s,
|
|
906
|
-
depth: r,
|
|
907
|
-
index: o
|
|
908
|
-
};
|
|
909
|
-
h.insert(P(c.segment), c), this.dragSegments_.push([c, 1]);
|
|
910
|
-
const u = {
|
|
911
|
-
segment: [t, i[1]],
|
|
912
|
-
feature: n,
|
|
913
|
-
geometry: s,
|
|
914
|
-
depth: r,
|
|
915
|
-
index: o + 1
|
|
916
|
-
};
|
|
917
|
-
h.insert(P(u.segment), u), this.dragSegments_.push([u, 0]), this.ignoreNextSingleClick_ = !0;
|
|
918
|
-
}
|
|
919
|
-
/**
|
|
920
|
-
* Removes the vertex currently being pointed.
|
|
921
|
-
* @return {boolean} True when a vertex was removed.
|
|
922
|
-
* @api
|
|
923
|
-
*/
|
|
924
|
-
removePoint() {
|
|
925
|
-
if (this.lastPointerEvent_ && this.lastPointerEvent_.type != D.POINTERDRAG) {
|
|
926
|
-
const e = this.lastPointerEvent_;
|
|
927
|
-
this.willModifyFeatures_(e, this.dragSegments_);
|
|
928
|
-
const t = this.removeVertex_();
|
|
929
|
-
return this.featuresBeingModified_ && this.dispatchEvent(
|
|
930
|
-
new Ce(
|
|
931
|
-
xe.MODIFYEND,
|
|
932
|
-
this.featuresBeingModified_,
|
|
933
|
-
e
|
|
934
|
-
)
|
|
935
|
-
), this.featuresBeingModified_ = null, t;
|
|
936
|
-
}
|
|
937
|
-
return !1;
|
|
938
|
-
}
|
|
939
|
-
/**
|
|
940
|
-
* Removes a vertex from all matching features.
|
|
941
|
-
* @return {boolean} True when a vertex was removed.
|
|
942
|
-
* @private
|
|
943
|
-
*/
|
|
944
|
-
removeVertex_() {
|
|
945
|
-
const e = this.dragSegments_, t = {};
|
|
946
|
-
let i = !1, n, s, r, o, a, h, c, u, g, d, f;
|
|
947
|
-
for (a = e.length - 1; a >= 0; --a)
|
|
948
|
-
r = e[a], d = r[0], f = C(d.feature), d.depth && (f += "-" + d.depth.join("-")), f in t || (t[f] = {}), r[1] === 0 ? (t[f].right = d, t[f].index = d.index) : r[1] == 1 && (t[f].left = d, t[f].index = d.index + 1);
|
|
949
|
-
for (f in t) {
|
|
950
|
-
switch (g = t[f].right, c = t[f].left, h = t[f].index, u = h - 1, c !== void 0 ? d = c : d = g, u < 0 && (u = 0), o = d.geometry, s = o.getCoordinates(), n = s, i = !1, o.getType()) {
|
|
951
|
-
case "MultiLineString":
|
|
952
|
-
s[d.depth[0]].length > 2 && (s[d.depth[0]].splice(h, 1), i = !0);
|
|
953
|
-
break;
|
|
954
|
-
case "LineString":
|
|
955
|
-
s.length > 2 && (s.splice(h, 1), i = !0);
|
|
956
|
-
break;
|
|
957
|
-
case "MultiPolygon":
|
|
958
|
-
n = n[d.depth[1]];
|
|
959
|
-
case "Polygon":
|
|
960
|
-
n = n[d.depth[0]], n.length > 4 && (h == n.length - 1 && (h = 0), n.splice(h, 1), i = !0, h === 0 && (n.pop(), n.push(n[0]), u = n.length - 1));
|
|
961
|
-
break;
|
|
962
|
-
}
|
|
963
|
-
if (i) {
|
|
964
|
-
this.setGeometryCoordinates_(o, s);
|
|
965
|
-
const _ = [];
|
|
966
|
-
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) {
|
|
967
|
-
const x = {
|
|
968
|
-
depth: d.depth,
|
|
969
|
-
feature: d.feature,
|
|
970
|
-
geometry: d.geometry,
|
|
971
|
-
index: u,
|
|
972
|
-
segment: _
|
|
973
|
-
};
|
|
974
|
-
this.rBush_.insert(
|
|
975
|
-
P(x.segment),
|
|
976
|
-
x
|
|
977
|
-
);
|
|
978
|
-
}
|
|
979
|
-
this.updateSegmentIndices_(o, h, d.depth, -1), this.vertexFeature_ && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), e.length = 0;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return i;
|
|
983
|
-
}
|
|
984
|
-
/**
|
|
985
|
-
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
986
|
-
* @param {Array} coordinates Coordinates.
|
|
987
|
-
* @private
|
|
988
|
-
*/
|
|
989
|
-
setGeometryCoordinates_(e, t) {
|
|
990
|
-
this.changingFeature_ = !0, e.setCoordinates(t), this.changingFeature_ = !1;
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
|
|
994
|
-
* @param {number} index Index.
|
|
995
|
-
* @param {Array<number>|undefined} depth Depth.
|
|
996
|
-
* @param {number} delta Delta (1 or -1).
|
|
997
|
-
* @private
|
|
998
|
-
*/
|
|
999
|
-
updateSegmentIndices_(e, t, i, n) {
|
|
1000
|
-
this.rBush_.forEachInExtent(
|
|
1001
|
-
e.getExtent(),
|
|
1002
|
-
function(s) {
|
|
1003
|
-
s.geometry === e && (i === void 0 || s.depth === void 0 || pt(s.depth, i)) && s.index > t && (s.index += n);
|
|
1004
|
-
}
|
|
1005
|
-
);
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
function ci(l, e) {
|
|
1009
|
-
return l.index - e.index;
|
|
1010
|
-
}
|
|
1011
|
-
function Xe(l, e, t) {
|
|
1012
|
-
const i = e.geometry;
|
|
1013
|
-
if (i.getType() === "Circle") {
|
|
1014
|
-
let s = (
|
|
1015
|
-
/** @type {import("../geom/Circle.js").default} */
|
|
1016
|
-
i
|
|
1017
|
-
);
|
|
1018
|
-
if (e.index === H) {
|
|
1019
|
-
const r = O(
|
|
1020
|
-
s.getCenter(),
|
|
1021
|
-
p(l)
|
|
1022
|
-
), o = Math.sqrt(r) - s.getRadius();
|
|
1023
|
-
return o * o;
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
const n = p(l);
|
|
1027
|
-
return Z[0] = p(e.segment[0]), Z[1] = p(e.segment[1]), Yt(n, Z);
|
|
1028
|
-
}
|
|
1029
|
-
function Ze(l, e, t) {
|
|
1030
|
-
const i = e.geometry;
|
|
1031
|
-
if (i.getType() === "Circle" && e.index === H)
|
|
1032
|
-
return de(
|
|
1033
|
-
/** @type {import("../geom/Circle.js").default} */
|
|
1034
|
-
i.getClosestPoint(
|
|
1035
|
-
p(l)
|
|
1036
|
-
)
|
|
1037
|
-
);
|
|
1038
|
-
const n = p(l);
|
|
1039
|
-
return Z[0] = p(e.segment[0]), Z[1] = p(e.segment[1]), de(
|
|
1040
|
-
st(n, Z)
|
|
1041
|
-
);
|
|
1042
|
-
}
|
|
1043
|
-
function ui() {
|
|
1044
|
-
const l = ke();
|
|
1045
|
-
return function(e, t) {
|
|
1046
|
-
return l.Point;
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
const ne = {
|
|
1050
|
-
/**
|
|
1051
|
-
* Triggered upon feature draw start
|
|
1052
|
-
* @event DrawEvent#drawstart
|
|
1053
|
-
* @api
|
|
1054
|
-
*/
|
|
1055
|
-
DRAWSTART: "drawstart",
|
|
1056
|
-
/**
|
|
1057
|
-
* Triggered upon feature draw end
|
|
1058
|
-
* @event DrawEvent#drawend
|
|
1059
|
-
* @api
|
|
1060
|
-
*/
|
|
1061
|
-
DRAWEND: "drawend",
|
|
1062
|
-
/**
|
|
1063
|
-
* Triggered upon feature draw abortion
|
|
1064
|
-
* @event DrawEvent#drawabort
|
|
1065
|
-
* @api
|
|
1066
|
-
*/
|
|
1067
|
-
DRAWABORT: "drawabort"
|
|
1068
|
-
};
|
|
1069
|
-
class se extends J {
|
|
1070
|
-
/**
|
|
1071
|
-
* @param {DrawEventType} type Type.
|
|
1072
|
-
* @param {Feature} feature The feature drawn.
|
|
1073
|
-
*/
|
|
1074
|
-
constructor(e, t) {
|
|
1075
|
-
super(e), this.feature = t;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
function di(l, e) {
|
|
1079
|
-
const t = [];
|
|
1080
|
-
for (let i = 0; i < e.length; ++i) {
|
|
1081
|
-
const s = e[i].getGeometry();
|
|
1082
|
-
ht(l, s, t);
|
|
1083
|
-
}
|
|
1084
|
-
return t;
|
|
1085
|
-
}
|
|
1086
|
-
function re(l, e) {
|
|
1087
|
-
return He(l[0], l[1], e[0], e[1]);
|
|
1088
|
-
}
|
|
1089
|
-
function V(l, e) {
|
|
1090
|
-
const t = l.length;
|
|
1091
|
-
return e < 0 ? l[e + t] : e >= t ? l[e - t] : l[e];
|
|
1092
|
-
}
|
|
1093
|
-
function oe(l, e, t) {
|
|
1094
|
-
let i, n;
|
|
1095
|
-
e < t ? (i = e, n = t) : (i = t, n = e);
|
|
1096
|
-
const s = Math.ceil(i), r = Math.floor(n);
|
|
1097
|
-
if (s > r) {
|
|
1098
|
-
const a = X(l, i), h = X(l, n);
|
|
1099
|
-
return re(a, h);
|
|
1100
|
-
}
|
|
1101
|
-
let o = 0;
|
|
1102
|
-
if (i < s) {
|
|
1103
|
-
const a = X(l, i), h = V(l, s);
|
|
1104
|
-
o += re(a, h);
|
|
1105
|
-
}
|
|
1106
|
-
if (r < n) {
|
|
1107
|
-
const a = V(l, r), h = X(l, n);
|
|
1108
|
-
o += re(a, h);
|
|
1109
|
-
}
|
|
1110
|
-
for (let a = s; a < r - 1; ++a) {
|
|
1111
|
-
const h = V(l, a), c = V(l, a + 1);
|
|
1112
|
-
o += re(h, c);
|
|
1113
|
-
}
|
|
1114
|
-
return o;
|
|
1115
|
-
}
|
|
1116
|
-
function ht(l, e, t) {
|
|
1117
|
-
if (e instanceof le) {
|
|
1118
|
-
ae(l, e.getCoordinates(), !1, t);
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
if (e instanceof Je) {
|
|
1122
|
-
const i = e.getCoordinates();
|
|
1123
|
-
for (let n = 0, s = i.length; n < s; ++n)
|
|
1124
|
-
ae(l, i[n], !1, t);
|
|
1125
|
-
return;
|
|
1126
|
-
}
|
|
1127
|
-
if (e instanceof rt) {
|
|
1128
|
-
const i = e.getCoordinates();
|
|
1129
|
-
for (let n = 0, s = i.length; n < s; ++n)
|
|
1130
|
-
ae(l, i[n], !0, t);
|
|
1131
|
-
return;
|
|
1132
|
-
}
|
|
1133
|
-
if (e instanceof Qe) {
|
|
1134
|
-
const i = e.getCoordinates();
|
|
1135
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
1136
|
-
const r = i[n];
|
|
1137
|
-
for (let o = 0, a = r.length; o < a; ++o)
|
|
1138
|
-
ae(l, r[o], !0, t);
|
|
1139
|
-
}
|
|
1140
|
-
return;
|
|
1141
|
-
}
|
|
1142
|
-
if (e instanceof Mt) {
|
|
1143
|
-
const i = e.getGeometries();
|
|
1144
|
-
for (let n = 0; n < i.length; ++n)
|
|
1145
|
-
ht(l, i[n], t);
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
const Te = { index: -1, endIndex: NaN };
|
|
1150
|
-
function gi(l, e, t, i) {
|
|
1151
|
-
const n = l[0], s = l[1];
|
|
1152
|
-
let r = 1 / 0, o = -1, a = NaN;
|
|
1153
|
-
for (let u = 0; u < e.targets.length; ++u) {
|
|
1154
|
-
const g = e.targets[u], d = g.coordinates;
|
|
1155
|
-
let f = 1 / 0, _;
|
|
1156
|
-
for (let x = 0; x < d.length - 1; ++x) {
|
|
1157
|
-
const T = d[x], F = d[x + 1], E = ct(n, s, T, F);
|
|
1158
|
-
E.squaredDistance < f && (f = E.squaredDistance, _ = x + E.along);
|
|
1159
|
-
}
|
|
1160
|
-
f < r && (r = f, g.ring && e.targetIndex === u && (g.endIndex > g.startIndex ? _ < g.startIndex && (_ += d.length) : g.endIndex < g.startIndex && _ > g.startIndex && (_ -= d.length)), a = _, o = u);
|
|
1161
|
-
}
|
|
1162
|
-
const h = e.targets[o];
|
|
1163
|
-
let c = h.ring;
|
|
1164
|
-
if (e.targetIndex === o && c) {
|
|
1165
|
-
const u = X(
|
|
1166
|
-
h.coordinates,
|
|
1167
|
-
a
|
|
1168
|
-
), g = t.getPixelFromCoordinate(u);
|
|
1169
|
-
ue(g, e.startPx) > i && (c = !1);
|
|
1170
|
-
}
|
|
1171
|
-
if (c) {
|
|
1172
|
-
const u = h.coordinates, g = u.length, d = h.startIndex, f = a;
|
|
1173
|
-
if (d < f) {
|
|
1174
|
-
const _ = oe(
|
|
1175
|
-
u,
|
|
1176
|
-
d,
|
|
1177
|
-
f
|
|
1178
|
-
);
|
|
1179
|
-
oe(
|
|
1180
|
-
u,
|
|
1181
|
-
d,
|
|
1182
|
-
f - g
|
|
1183
|
-
) < _ && (a -= g);
|
|
1184
|
-
} else {
|
|
1185
|
-
const _ = oe(
|
|
1186
|
-
u,
|
|
1187
|
-
d,
|
|
1188
|
-
f
|
|
1189
|
-
);
|
|
1190
|
-
oe(
|
|
1191
|
-
u,
|
|
1192
|
-
d,
|
|
1193
|
-
f + g
|
|
1194
|
-
) < _ && (a += g);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
return Te.index = o, Te.endIndex = a, Te;
|
|
1198
|
-
}
|
|
1199
|
-
function ae(l, e, t, i) {
|
|
1200
|
-
const n = l[0], s = l[1];
|
|
1201
|
-
for (let r = 0, o = e.length - 1; r < o; ++r) {
|
|
1202
|
-
const a = e[r], h = e[r + 1], c = ct(n, s, a, h);
|
|
1203
|
-
if (c.squaredDistance === 0) {
|
|
1204
|
-
const u = r + c.along;
|
|
1205
|
-
i.push({
|
|
1206
|
-
coordinates: e,
|
|
1207
|
-
ring: t,
|
|
1208
|
-
startIndex: u,
|
|
1209
|
-
endIndex: u
|
|
1210
|
-
});
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
const Fe = { along: 0, squaredDistance: 0 };
|
|
1216
|
-
function ct(l, e, t, i) {
|
|
1217
|
-
const n = t[0], s = t[1], r = i[0], o = i[1], a = r - n, h = o - s;
|
|
1218
|
-
let c = 0, u = n, g = s;
|
|
1219
|
-
return (a !== 0 || h !== 0) && (c = $e(((l - n) * a + (e - s) * h) / (a * a + h * h), 0, 1), u += a * c, g += h * c), Fe.along = c, Fe.squaredDistance = Et(He(l, e, u, g), 10), Fe;
|
|
1220
|
-
}
|
|
1221
|
-
function X(l, e) {
|
|
1222
|
-
const t = l.length;
|
|
1223
|
-
let i = Math.floor(e);
|
|
1224
|
-
const n = e - i;
|
|
1225
|
-
i >= t ? i -= t : i < 0 && (i += t);
|
|
1226
|
-
let s = i + 1;
|
|
1227
|
-
s >= t && (s -= t);
|
|
1228
|
-
const r = l[i], o = r[0], a = r[1], h = l[s], c = h[0] - o, u = h[1] - a;
|
|
1229
|
-
return [o + c * n, a + u * n];
|
|
1230
|
-
}
|
|
1231
|
-
class fi extends Me {
|
|
1232
|
-
/**
|
|
1233
|
-
* @param {Options} options Options.
|
|
1234
|
-
*/
|
|
1235
|
-
constructor(e) {
|
|
1236
|
-
const t = (
|
|
1237
|
-
/** @type {import("./Pointer.js").Options} */
|
|
1238
|
-
e
|
|
1239
|
-
);
|
|
1240
|
-
t.stopDown || (t.stopDown = We), 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} */
|
|
1241
|
-
e.type, this.mode_ = mi(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 : ce, this.geometryLayout_ = e.geometryLayout ? e.geometryLayout : "XY";
|
|
1242
|
-
let i = e.geometryFunction;
|
|
1243
|
-
if (!i) {
|
|
1244
|
-
const n = this.mode_;
|
|
1245
|
-
if (n === "Circle")
|
|
1246
|
-
i = function(s, r, o) {
|
|
1247
|
-
const a = r || new Rt([NaN, NaN]), h = p(s[0]), c = O(
|
|
1248
|
-
h,
|
|
1249
|
-
p(s[s.length - 1])
|
|
1250
|
-
);
|
|
1251
|
-
return a.setCenterAndRadius(
|
|
1252
|
-
h,
|
|
1253
|
-
Math.sqrt(c),
|
|
1254
|
-
this.geometryLayout_
|
|
1255
|
-
), a;
|
|
1256
|
-
};
|
|
1257
|
-
else {
|
|
1258
|
-
let s;
|
|
1259
|
-
n === "Point" ? s = W : n === "LineString" ? s = le : n === "Polygon" && (s = rt), i = function(r, o, a) {
|
|
1260
|
-
return o ? n === "Polygon" ? r[0].length ? o.setCoordinates(
|
|
1261
|
-
[r[0].concat([r[0][0]])],
|
|
1262
|
-
this.geometryLayout_
|
|
1263
|
-
) : o.setCoordinates([], this.geometryLayout_) : o.setCoordinates(r, this.geometryLayout_) : o = new s(r, this.geometryLayout_), o;
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
this.geometryFunction_ = i, 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 ge({
|
|
1268
|
-
source: new De({
|
|
1269
|
-
useSpatialIndex: !1,
|
|
1270
|
-
wrapX: e.wrapX ? e.wrapX : !1
|
|
1271
|
-
}),
|
|
1272
|
-
style: e.style ? e.style : _i(),
|
|
1273
|
-
updateWhileInteracting: !0
|
|
1274
|
-
}), this.geometryName_ = e.geometryName, this.condition_ = e.condition ? e.condition : At, this.freehandCondition_, e.freehand ? this.freehandCondition_ = Le : this.freehandCondition_ = e.freehandCondition ? e.freehandCondition : tt, this.traceCondition_, this.setTrace(e.trace || !1), this.traceState_ = { active: !1 }, this.traceSource_ = e.traceSource || e.source || null, this.addChangeListener(bt.ACTIVE, this.updateState_);
|
|
1275
|
-
}
|
|
1276
|
-
/**
|
|
1277
|
-
* Toggle tracing mode or set a tracing condition.
|
|
1278
|
-
*
|
|
1279
|
-
* @param {boolean|import("../events/condition.js").Condition} trace A boolean to toggle tracing mode or an event
|
|
1280
|
-
* condition that will be checked when a feature is clicked to determine if tracing should be active.
|
|
1281
|
-
*/
|
|
1282
|
-
setTrace(e) {
|
|
1283
|
-
let t;
|
|
1284
|
-
e ? e === !0 ? t = Le : t = e : t = Pe, this.traceCondition_ = t;
|
|
1285
|
-
}
|
|
1286
|
-
/**
|
|
1287
|
-
* Remove the interaction from its current map and attach it to the new map.
|
|
1288
|
-
* Subclasses may set up event handlers to get notified about changes to
|
|
1289
|
-
* the map here.
|
|
1290
|
-
* @param {import("../Map.js").default} map Map.
|
|
1291
|
-
*/
|
|
1292
|
-
setMap(e) {
|
|
1293
|
-
super.setMap(e), this.updateState_();
|
|
1294
|
-
}
|
|
1295
|
-
/**
|
|
1296
|
-
* Get the overlay layer that this interaction renders sketch features to.
|
|
1297
|
-
* @return {VectorLayer} Overlay layer.
|
|
1298
|
-
* @api
|
|
1299
|
-
*/
|
|
1300
|
-
getOverlay() {
|
|
1301
|
-
return this.overlay_;
|
|
1302
|
-
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may actually draw or finish the drawing.
|
|
1305
|
-
* @param {import("../MapBrowserEvent.js").default} event Map browser event.
|
|
1306
|
-
* @return {boolean} `false` to stop event propagation.
|
|
1307
|
-
* @api
|
|
1308
|
-
*/
|
|
1309
|
-
handleEvent(e) {
|
|
1310
|
-
e.originalEvent.type === $.CONTEXTMENU && e.originalEvent.preventDefault(), this.freehand_ = this.mode_ !== "Point" && this.freehandCondition_(e);
|
|
1311
|
-
let t = e.type === D.POINTERMOVE, i = !0;
|
|
1312
|
-
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), i = !1) : this.freehand_ && e.type === D.POINTERDOWN ? i = !1 : t && this.getPointerCount() < 2 ? (i = e.type === D.POINTERMOVE, i && 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 && (i = !1), super.handleEvent(e) && i;
|
|
1313
|
-
}
|
|
1314
|
-
/**
|
|
1315
|
-
* Handle pointer down events.
|
|
1316
|
-
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1317
|
-
* @return {boolean} If the event was consumed.
|
|
1318
|
-
*/
|
|
1319
|
-
handleDownEvent(e) {
|
|
1320
|
-
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(() => {
|
|
1321
|
-
this.handlePointerMove_(
|
|
1322
|
-
new It(
|
|
1323
|
-
D.POINTERMOVE,
|
|
1324
|
-
e.map,
|
|
1325
|
-
e.originalEvent,
|
|
1326
|
-
!1,
|
|
1327
|
-
e.frameState
|
|
1328
|
-
)
|
|
1329
|
-
);
|
|
1330
|
-
}, this.dragVertexDelay_), this.downPx_ = e.pixel, !0) : (this.lastDragTime_ = void 0, !1);
|
|
1331
|
-
}
|
|
1332
|
-
/**
|
|
1333
|
-
* @private
|
|
1334
|
-
*/
|
|
1335
|
-
deactivateTrace_() {
|
|
1336
|
-
this.traceState_ = { active: !1 };
|
|
1337
|
-
}
|
|
1338
|
-
/**
|
|
1339
|
-
* Activate or deactivate trace state based on a browser event.
|
|
1340
|
-
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1341
|
-
* @private
|
|
1342
|
-
*/
|
|
1343
|
-
toggleTraceState_(e) {
|
|
1344
|
-
if (!this.traceSource_ || !this.traceCondition_(e))
|
|
1345
|
-
return;
|
|
1346
|
-
if (this.traceState_.active) {
|
|
1347
|
-
this.deactivateTrace_();
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
const t = this.getMap(), i = t.getCoordinateFromPixel([
|
|
1351
|
-
e.pixel[0] - this.snapTolerance_,
|
|
1352
|
-
e.pixel[1] + this.snapTolerance_
|
|
1353
|
-
]), n = t.getCoordinateFromPixel([
|
|
1354
|
-
e.pixel[0] + this.snapTolerance_,
|
|
1355
|
-
e.pixel[1] - this.snapTolerance_
|
|
1356
|
-
]), s = P([i, n]), r = this.traceSource_.getFeaturesInExtent(s);
|
|
1357
|
-
if (r.length === 0)
|
|
1358
|
-
return;
|
|
1359
|
-
const o = di(e.coordinate, r);
|
|
1360
|
-
o.length && (this.traceState_ = {
|
|
1361
|
-
active: !0,
|
|
1362
|
-
startPx: e.pixel.slice(),
|
|
1363
|
-
targets: o,
|
|
1364
|
-
targetIndex: -1
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
/**
|
|
1368
|
-
* @param {TraceTarget} target The trace target.
|
|
1369
|
-
* @param {number} endIndex The new end index of the trace.
|
|
1370
|
-
* @private
|
|
1371
|
-
*/
|
|
1372
|
-
addOrRemoveTracedCoordinates_(e, t) {
|
|
1373
|
-
const i = e.startIndex <= e.endIndex, n = e.startIndex <= t;
|
|
1374
|
-
i === n ? i && t > e.endIndex || !i && t < e.endIndex ? this.addTracedCoordinates_(e, e.endIndex, t) : (i && t < e.endIndex || !i && t > e.endIndex) && this.removeTracedCoordinates_(t, e.endIndex) : (this.removeTracedCoordinates_(e.startIndex, e.endIndex), this.addTracedCoordinates_(e, e.startIndex, t));
|
|
1375
|
-
}
|
|
1376
|
-
/**
|
|
1377
|
-
* @param {number} fromIndex The start index.
|
|
1378
|
-
* @param {number} toIndex The end index.
|
|
1379
|
-
* @private
|
|
1380
|
-
*/
|
|
1381
|
-
removeTracedCoordinates_(e, t) {
|
|
1382
|
-
if (e === t)
|
|
1383
|
-
return;
|
|
1384
|
-
let i = 0;
|
|
1385
|
-
if (e < t) {
|
|
1386
|
-
const n = Math.ceil(e);
|
|
1387
|
-
let s = Math.floor(t);
|
|
1388
|
-
s === t && (s -= 1), i = s - n + 1;
|
|
1389
|
-
} else {
|
|
1390
|
-
const n = Math.floor(e);
|
|
1391
|
-
let s = Math.ceil(t);
|
|
1392
|
-
s === t && (s += 1), i = n - s + 1;
|
|
1393
|
-
}
|
|
1394
|
-
i > 0 && this.removeLastPoints_(i);
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* @param {TraceTarget} target The trace target.
|
|
1398
|
-
* @param {number} fromIndex The start index.
|
|
1399
|
-
* @param {number} toIndex The end index.
|
|
1400
|
-
* @private
|
|
1401
|
-
*/
|
|
1402
|
-
addTracedCoordinates_(e, t, i) {
|
|
1403
|
-
if (t === i)
|
|
1404
|
-
return;
|
|
1405
|
-
const n = [];
|
|
1406
|
-
if (t < i) {
|
|
1407
|
-
const s = Math.ceil(t);
|
|
1408
|
-
let r = Math.floor(i);
|
|
1409
|
-
r === i && (r -= 1);
|
|
1410
|
-
for (let o = s; o <= r; ++o)
|
|
1411
|
-
n.push(V(e.coordinates, o));
|
|
1412
|
-
} else {
|
|
1413
|
-
const s = Math.floor(t);
|
|
1414
|
-
let r = Math.ceil(i);
|
|
1415
|
-
r === i && (r += 1);
|
|
1416
|
-
for (let o = s; o >= r; --o)
|
|
1417
|
-
n.push(V(e.coordinates, o));
|
|
1418
|
-
}
|
|
1419
|
-
n.length && this.appendCoordinates(n);
|
|
1420
|
-
}
|
|
1421
|
-
/**
|
|
1422
|
-
* Update the trace.
|
|
1423
|
-
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1424
|
-
* @private
|
|
1425
|
-
*/
|
|
1426
|
-
updateTrace_(e) {
|
|
1427
|
-
const t = this.traceState_;
|
|
1428
|
-
if (!t.active || t.targetIndex === -1 && ue(t.startPx, e.pixel) < this.snapTolerance_)
|
|
1429
|
-
return;
|
|
1430
|
-
const i = gi(
|
|
1431
|
-
e.coordinate,
|
|
1432
|
-
t,
|
|
1433
|
-
this.getMap(),
|
|
1434
|
-
this.snapTolerance_
|
|
1435
|
-
);
|
|
1436
|
-
if (t.targetIndex !== i.index) {
|
|
1437
|
-
if (t.targetIndex !== -1) {
|
|
1438
|
-
const a = t.targets[t.targetIndex];
|
|
1439
|
-
this.removeTracedCoordinates_(a.startIndex, a.endIndex);
|
|
1440
|
-
}
|
|
1441
|
-
const o = t.targets[i.index];
|
|
1442
|
-
this.addTracedCoordinates_(
|
|
1443
|
-
o,
|
|
1444
|
-
o.startIndex,
|
|
1445
|
-
i.endIndex
|
|
1446
|
-
);
|
|
1447
|
-
} else {
|
|
1448
|
-
const o = t.targets[t.targetIndex];
|
|
1449
|
-
this.addOrRemoveTracedCoordinates_(o, i.endIndex);
|
|
1450
|
-
}
|
|
1451
|
-
t.targetIndex = i.index;
|
|
1452
|
-
const n = t.targets[t.targetIndex];
|
|
1453
|
-
n.endIndex = i.endIndex;
|
|
1454
|
-
const s = X(
|
|
1455
|
-
n.coordinates,
|
|
1456
|
-
n.endIndex
|
|
1457
|
-
), r = this.getMap().getPixelFromCoordinate(s);
|
|
1458
|
-
e.coordinate = s, e.pixel = [Math.round(r[0]), Math.round(r[1])];
|
|
1459
|
-
}
|
|
1460
|
-
/**
|
|
1461
|
-
* Handle pointer up events.
|
|
1462
|
-
* @param {import("../MapBrowserEvent.js").default} event Event.
|
|
1463
|
-
* @return {boolean} If the event was consumed.
|
|
1464
|
-
*/
|
|
1465
|
-
handleUpEvent(e) {
|
|
1466
|
-
let t = !0;
|
|
1467
|
-
if (this.getPointerCount() === 0) {
|
|
1468
|
-
this.downTimeout_ && (clearTimeout(this.downTimeout_), this.downTimeout_ = void 0), this.handlePointerMove_(e);
|
|
1469
|
-
const i = this.traceState_.active;
|
|
1470
|
-
if (this.toggleTraceState_(e), this.shouldHandle_) {
|
|
1471
|
-
const n = !this.finishCoordinate_;
|
|
1472
|
-
n && this.startDrawing_(e.coordinate), !n && this.freehand_ ? this.finishDrawing() : !this.freehand_ && (!n || this.mode_ === "Point") && (this.atFinish_(e.pixel, i) ? this.finishCondition_(e) && this.finishDrawing() : this.addToDrawing_(e.coordinate)), t = !1;
|
|
1473
|
-
} else this.freehand_ && this.abortDrawing();
|
|
1474
|
-
}
|
|
1475
|
-
return !t && this.stopClick_ && e.preventDefault(), t;
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* Handle move events.
|
|
1479
|
-
* @param {import("../MapBrowserEvent.js").default} event A move event.
|
|
1480
|
-
* @private
|
|
1481
|
-
*/
|
|
1482
|
-
handlePointerMove_(e) {
|
|
1483
|
-
if (this.pointerType_ = e.originalEvent.pointerType, this.downPx_ && (!this.freehand_ && this.shouldHandle_ || this.freehand_ && !this.shouldHandle_)) {
|
|
1484
|
-
const t = this.downPx_, i = e.pixel, n = t[0] - i[0], s = t[1] - i[1], r = n * n + s * s;
|
|
1485
|
-
if (this.shouldHandle_ = this.freehand_ ? r > this.squaredClickTolerance_ : r <= this.squaredClickTolerance_, !this.shouldHandle_)
|
|
1486
|
-
return;
|
|
1487
|
-
}
|
|
1488
|
-
if (!this.finishCoordinate_) {
|
|
1489
|
-
this.createOrUpdateSketchPoint_(e.coordinate.slice());
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
this.updateTrace_(e), this.modifyDrawing_(e.coordinate);
|
|
1493
|
-
}
|
|
1494
|
-
/**
|
|
1495
|
-
* Determine if an event is within the snapping tolerance of the start coord.
|
|
1496
|
-
* @param {import("../pixel.js").Pixel} pixel Pixel.
|
|
1497
|
-
* @param {boolean} [tracing] Drawing in trace mode (only stop if at the starting point).
|
|
1498
|
-
* @return {boolean} The event is within the snapping tolerance of the start.
|
|
1499
|
-
* @private
|
|
1500
|
-
*/
|
|
1501
|
-
atFinish_(e, t) {
|
|
1502
|
-
let i = !1;
|
|
1503
|
-
if (this.sketchFeature_) {
|
|
1504
|
-
let n = !1, s = [this.finishCoordinate_];
|
|
1505
|
-
const r = this.mode_;
|
|
1506
|
-
if (r === "Point")
|
|
1507
|
-
i = !0;
|
|
1508
|
-
else if (r === "Circle")
|
|
1509
|
-
i = this.sketchCoords_.length === 2;
|
|
1510
|
-
else if (r === "LineString")
|
|
1511
|
-
n = !t && this.sketchCoords_.length > this.minPoints_;
|
|
1512
|
-
else if (r === "Polygon") {
|
|
1513
|
-
const o = (
|
|
1514
|
-
/** @type {PolyCoordType} */
|
|
1515
|
-
this.sketchCoords_
|
|
1516
|
-
);
|
|
1517
|
-
n = o[0].length > this.minPoints_, s = [
|
|
1518
|
-
o[0][0],
|
|
1519
|
-
o[0][o[0].length - 2]
|
|
1520
|
-
], t ? s = [o[0][0]] : s = [
|
|
1521
|
-
o[0][0],
|
|
1522
|
-
o[0][o[0].length - 2]
|
|
1523
|
-
];
|
|
1524
|
-
}
|
|
1525
|
-
if (n) {
|
|
1526
|
-
const o = this.getMap();
|
|
1527
|
-
for (let a = 0, h = s.length; a < h; a++) {
|
|
1528
|
-
const c = s[a], u = o.getPixelFromCoordinate(c), g = e[0] - u[0], d = e[1] - u[1], f = this.freehand_ ? 1 : this.snapTolerance_;
|
|
1529
|
-
if (i = Math.sqrt(g * g + d * d) <= f, i) {
|
|
1530
|
-
this.finishCoordinate_ = c;
|
|
1531
|
-
break;
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
return i;
|
|
1537
|
-
}
|
|
1538
|
-
/**
|
|
1539
|
-
* @param {import("../coordinate").Coordinate} coordinates Coordinate.
|
|
1540
|
-
* @private
|
|
1541
|
-
*/
|
|
1542
|
-
createOrUpdateSketchPoint_(e) {
|
|
1543
|
-
this.sketchPoint_ ? this.sketchPoint_.getGeometry().setCoordinates(e) : (this.sketchPoint_ = new G(new W(e)), this.updateSketchFeatures_());
|
|
1544
|
-
}
|
|
1545
|
-
/**
|
|
1546
|
-
* @param {import("../geom/Polygon.js").default} geometry Polygon geometry.
|
|
1547
|
-
* @private
|
|
1548
|
-
*/
|
|
1549
|
-
createOrUpdateCustomSketchLine_(e) {
|
|
1550
|
-
this.sketchLine_ || (this.sketchLine_ = new G());
|
|
1551
|
-
const t = e.getLinearRing(0);
|
|
1552
|
-
let i = this.sketchLine_.getGeometry();
|
|
1553
|
-
i ? (i.setFlatCoordinates(
|
|
1554
|
-
t.getLayout(),
|
|
1555
|
-
t.getFlatCoordinates()
|
|
1556
|
-
), i.changed()) : (i = new le(
|
|
1557
|
-
t.getFlatCoordinates(),
|
|
1558
|
-
t.getLayout()
|
|
1559
|
-
), this.sketchLine_.setGeometry(i));
|
|
1560
|
-
}
|
|
1561
|
-
/**
|
|
1562
|
-
* Start the drawing.
|
|
1563
|
-
* @param {import("../coordinate.js").Coordinate} start Start coordinate.
|
|
1564
|
-
* @private
|
|
1565
|
-
*/
|
|
1566
|
-
startDrawing_(e) {
|
|
1567
|
-
const t = this.getMap().getView().getProjection(), i = Ke(this.geometryLayout_);
|
|
1568
|
-
for (; e.length < i; )
|
|
1569
|
-
e.push(0);
|
|
1570
|
-
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 G(new le(this.sketchLineCoords_)));
|
|
1571
|
-
const n = this.geometryFunction_(
|
|
1572
|
-
this.sketchCoords_,
|
|
1573
|
-
void 0,
|
|
1574
|
-
t
|
|
1575
|
-
);
|
|
1576
|
-
this.sketchFeature_ = new G(), this.geometryName_ && this.sketchFeature_.setGeometryName(this.geometryName_), this.sketchFeature_.setGeometry(n), this.updateSketchFeatures_(), this.dispatchEvent(
|
|
1577
|
-
new se(ne.DRAWSTART, this.sketchFeature_)
|
|
1578
|
-
);
|
|
1579
|
-
}
|
|
1580
|
-
/**
|
|
1581
|
-
* Modify the drawing.
|
|
1582
|
-
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
|
|
1583
|
-
* @private
|
|
1584
|
-
*/
|
|
1585
|
-
modifyDrawing_(e) {
|
|
1586
|
-
const t = this.getMap(), i = this.sketchFeature_.getGeometry(), n = t.getView().getProjection(), s = Ke(this.geometryLayout_);
|
|
1587
|
-
let r, o;
|
|
1588
|
-
for (; e.length < s; )
|
|
1589
|
-
e.push(0);
|
|
1590
|
-
this.mode_ === "Point" ? o = this.sketchCoords_ : this.mode_ === "Polygon" ? (r = /** @type {PolyCoordType} */
|
|
1591
|
-
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_(
|
|
1592
|
-
/** @type {!LineCoordType} */
|
|
1593
|
-
this.sketchCoords_,
|
|
1594
|
-
i,
|
|
1595
|
-
n
|
|
1596
|
-
), this.sketchPoint_ && this.sketchPoint_.getGeometry().setCoordinates(e), i.getType() === "Polygon" && this.mode_ !== "Polygon" ? this.createOrUpdateCustomSketchLine_(
|
|
1597
|
-
/** @type {Polygon} */
|
|
1598
|
-
i
|
|
1599
|
-
) : this.sketchLineCoords_ && this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_), this.updateSketchFeatures_();
|
|
1600
|
-
}
|
|
1601
|
-
/**
|
|
1602
|
-
* Add a new coordinate to the drawing.
|
|
1603
|
-
* @param {!PointCoordType} coordinate Coordinate
|
|
1604
|
-
* @private
|
|
1605
|
-
*/
|
|
1606
|
-
addToDrawing_(e) {
|
|
1607
|
-
const t = this.sketchFeature_.getGeometry(), i = this.getMap().getView().getProjection();
|
|
1608
|
-
let n, s;
|
|
1609
|
-
const r = this.mode_;
|
|
1610
|
-
r === "LineString" || r === "Circle" ? (this.finishCoordinate_ = e.slice(), s = /** @type {LineCoordType} */
|
|
1611
|
-
this.sketchCoords_, s.length >= this.maxPoints_ && (this.freehand_ ? s.pop() : n = !0), s.push(e.slice()), this.geometryFunction_(s, t, i)) : r === "Polygon" && (s = /** @type {PolyCoordType} */
|
|
1612
|
-
this.sketchCoords_[0], s.length >= this.maxPoints_ && (this.freehand_ ? s.pop() : n = !0), s.push(e.slice()), n && (this.finishCoordinate_ = s[0]), this.geometryFunction_(this.sketchCoords_, t, i)), this.createOrUpdateSketchPoint_(e.slice()), this.updateSketchFeatures_(), n && this.finishDrawing();
|
|
1613
|
-
}
|
|
1614
|
-
/**
|
|
1615
|
-
* @param {number} n The number of points to remove.
|
|
1616
|
-
*/
|
|
1617
|
-
removeLastPoints_(e) {
|
|
1618
|
-
if (!this.sketchFeature_)
|
|
1619
|
-
return;
|
|
1620
|
-
const t = this.sketchFeature_.getGeometry(), i = this.getMap().getView().getProjection(), n = this.mode_;
|
|
1621
|
-
for (let s = 0; s < e; ++s) {
|
|
1622
|
-
let r;
|
|
1623
|
-
if (n === "LineString" || n === "Circle") {
|
|
1624
|
-
if (r = /** @type {LineCoordType} */
|
|
1625
|
-
this.sketchCoords_, r.splice(-2, 1), r.length >= 2) {
|
|
1626
|
-
this.finishCoordinate_ = r[r.length - 2].slice();
|
|
1627
|
-
const o = this.finishCoordinate_.slice();
|
|
1628
|
-
r[r.length - 1] = o, this.createOrUpdateSketchPoint_(o);
|
|
1629
|
-
}
|
|
1630
|
-
this.geometryFunction_(r, t, i), t.getType() === "Polygon" && this.sketchLine_ && this.createOrUpdateCustomSketchLine_(
|
|
1631
|
-
/** @type {Polygon} */
|
|
1632
|
-
t
|
|
1633
|
-
);
|
|
1634
|
-
} else if (n === "Polygon") {
|
|
1635
|
-
r = /** @type {PolyCoordType} */
|
|
1636
|
-
this.sketchCoords_[0], r.splice(-2, 1);
|
|
1637
|
-
const o = this.sketchLine_.getGeometry();
|
|
1638
|
-
if (r.length >= 2) {
|
|
1639
|
-
const a = r[r.length - 2].slice();
|
|
1640
|
-
r[r.length - 1] = a, this.createOrUpdateSketchPoint_(a);
|
|
1641
|
-
}
|
|
1642
|
-
o.setCoordinates(r), this.geometryFunction_(this.sketchCoords_, t, i);
|
|
1643
|
-
}
|
|
1644
|
-
if (r.length === 1) {
|
|
1645
|
-
this.abortDrawing();
|
|
1646
|
-
break;
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
this.updateSketchFeatures_();
|
|
1650
|
-
}
|
|
1651
|
-
/**
|
|
1652
|
-
* Remove last point of the feature currently being drawn. Does not do anything when
|
|
1653
|
-
* drawing POINT or MULTI_POINT geometries.
|
|
1654
|
-
* @api
|
|
1655
|
-
*/
|
|
1656
|
-
removeLastPoint() {
|
|
1657
|
-
this.removeLastPoints_(1);
|
|
1658
|
-
}
|
|
1659
|
-
/**
|
|
1660
|
-
* Stop drawing and add the sketch feature to the target layer.
|
|
1661
|
-
* The {@link module:ol/interaction/Draw~DrawEventType.DRAWEND} event is
|
|
1662
|
-
* dispatched before inserting the feature.
|
|
1663
|
-
* @api
|
|
1664
|
-
*/
|
|
1665
|
-
finishDrawing() {
|
|
1666
|
-
const e = this.abortDrawing_();
|
|
1667
|
-
if (!e)
|
|
1668
|
-
return;
|
|
1669
|
-
let t = this.sketchCoords_;
|
|
1670
|
-
const i = e.getGeometry(), n = this.getMap().getView().getProjection();
|
|
1671
|
-
this.mode_ === "LineString" ? (t.pop(), this.geometryFunction_(t, i, n)) : this.mode_ === "Polygon" && (t[0].pop(), this.geometryFunction_(t, i, n), t = i.getCoordinates()), this.type_ === "MultiPoint" ? e.setGeometry(
|
|
1672
|
-
new Dt([
|
|
1673
|
-
/** @type {PointCoordType} */
|
|
1674
|
-
t
|
|
1675
|
-
])
|
|
1676
|
-
) : this.type_ === "MultiLineString" ? e.setGeometry(
|
|
1677
|
-
new Je([
|
|
1678
|
-
/** @type {LineCoordType} */
|
|
1679
|
-
t
|
|
1680
|
-
])
|
|
1681
|
-
) : this.type_ === "MultiPolygon" && e.setGeometry(
|
|
1682
|
-
new Qe([
|
|
1683
|
-
/** @type {PolyCoordType} */
|
|
1684
|
-
t
|
|
1685
|
-
])
|
|
1686
|
-
), this.dispatchEvent(new se(ne.DRAWEND, e)), this.features_ && this.features_.push(e), this.source_ && this.source_.addFeature(e);
|
|
1687
|
-
}
|
|
1688
|
-
/**
|
|
1689
|
-
* Stop drawing without adding the sketch feature to the target layer.
|
|
1690
|
-
* @return {Feature<import("../geom/SimpleGeometry.js").default>|null} The sketch feature (or null if none).
|
|
1691
|
-
* @private
|
|
1692
|
-
*/
|
|
1693
|
-
abortDrawing_() {
|
|
1694
|
-
this.finishCoordinate_ = null;
|
|
1695
|
-
const e = this.sketchFeature_;
|
|
1696
|
-
return this.sketchFeature_ = null, this.sketchPoint_ = null, this.sketchLine_ = null, this.overlay_.getSource().clear(!0), this.deactivateTrace_(), e;
|
|
1697
|
-
}
|
|
1698
|
-
/**
|
|
1699
|
-
* Stop drawing without adding the sketch feature to the target layer.
|
|
1700
|
-
* @api
|
|
1701
|
-
*/
|
|
1702
|
-
abortDrawing() {
|
|
1703
|
-
const e = this.abortDrawing_();
|
|
1704
|
-
e && this.dispatchEvent(new se(ne.DRAWABORT, e));
|
|
1705
|
-
}
|
|
1706
|
-
/**
|
|
1707
|
-
* Append coordinates to the end of the geometry that is currently being drawn.
|
|
1708
|
-
* This can be used when drawing LineStrings or Polygons. Coordinates will
|
|
1709
|
-
* either be appended to the current LineString or the outer ring of the current
|
|
1710
|
-
* Polygon. If no geometry is being drawn, a new one will be created.
|
|
1711
|
-
* @param {!LineCoordType} coordinates Linear coordinates to be appended to
|
|
1712
|
-
* the coordinate array.
|
|
1713
|
-
* @api
|
|
1714
|
-
*/
|
|
1715
|
-
appendCoordinates(e) {
|
|
1716
|
-
const t = this.mode_, i = !this.sketchFeature_;
|
|
1717
|
-
i && this.startDrawing_(e[0]);
|
|
1718
|
-
let n;
|
|
1719
|
-
if (t === "LineString" || t === "Circle")
|
|
1720
|
-
n = /** @type {LineCoordType} */
|
|
1721
|
-
this.sketchCoords_;
|
|
1722
|
-
else if (t === "Polygon")
|
|
1723
|
-
n = this.sketchCoords_ && this.sketchCoords_.length ? (
|
|
1724
|
-
/** @type {PolyCoordType} */
|
|
1725
|
-
this.sketchCoords_[0]
|
|
1726
|
-
) : [];
|
|
1727
|
-
else
|
|
1728
|
-
return;
|
|
1729
|
-
i && n.shift(), n.pop();
|
|
1730
|
-
for (let r = 0; r < e.length; r++)
|
|
1731
|
-
this.addToDrawing_(e[r]);
|
|
1732
|
-
const s = e[e.length - 1];
|
|
1733
|
-
this.addToDrawing_(s), this.modifyDrawing_(s);
|
|
1734
|
-
}
|
|
1735
|
-
/**
|
|
1736
|
-
* Initiate draw mode by starting from an existing geometry which will
|
|
1737
|
-
* receive new additional points. This only works on features with
|
|
1738
|
-
* `LineString` geometries, where the interaction will extend lines by adding
|
|
1739
|
-
* points to the end of the coordinates array.
|
|
1740
|
-
* This will change the original feature, instead of drawing a copy.
|
|
1741
|
-
*
|
|
1742
|
-
* The function will dispatch a `drawstart` event.
|
|
1743
|
-
*
|
|
1744
|
-
* @param {!Feature<LineString>} feature Feature to be extended.
|
|
1745
|
-
* @api
|
|
1746
|
-
*/
|
|
1747
|
-
extend(e) {
|
|
1748
|
-
const i = e.getGeometry();
|
|
1749
|
-
this.sketchFeature_ = e, this.sketchCoords_ = i.getCoordinates();
|
|
1750
|
-
const n = this.sketchCoords_[this.sketchCoords_.length - 1];
|
|
1751
|
-
this.finishCoordinate_ = n.slice(), this.sketchCoords_.push(n.slice()), this.sketchPoint_ = new G(new W(n)), this.updateSketchFeatures_(), this.dispatchEvent(
|
|
1752
|
-
new se(ne.DRAWSTART, this.sketchFeature_)
|
|
1753
|
-
);
|
|
1754
|
-
}
|
|
1755
|
-
/**
|
|
1756
|
-
* Redraw the sketch features.
|
|
1757
|
-
* @private
|
|
1758
|
-
*/
|
|
1759
|
-
updateSketchFeatures_() {
|
|
1760
|
-
const e = [];
|
|
1761
|
-
this.sketchFeature_ && e.push(this.sketchFeature_), this.sketchLine_ && e.push(this.sketchLine_), this.sketchPoint_ && e.push(this.sketchPoint_);
|
|
1762
|
-
const t = this.overlay_.getSource();
|
|
1763
|
-
t.clear(!0), t.addFeatures(e);
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* @private
|
|
1767
|
-
*/
|
|
1768
|
-
updateState_() {
|
|
1769
|
-
const e = this.getMap(), t = this.getActive();
|
|
1770
|
-
(!e || !t) && this.abortDrawing(), this.overlay_.setMap(t ? e : null);
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
function _i() {
|
|
1774
|
-
const l = ke();
|
|
1775
|
-
return function(e, t) {
|
|
1776
|
-
return l[e.getGeometry().getType()];
|
|
1777
|
-
};
|
|
1778
|
-
}
|
|
1779
|
-
function mi(l) {
|
|
1780
|
-
switch (l) {
|
|
1781
|
-
case "Point":
|
|
1782
|
-
case "MultiPoint":
|
|
1783
|
-
return "Point";
|
|
1784
|
-
case "LineString":
|
|
1785
|
-
case "MultiLineString":
|
|
1786
|
-
return "LineString";
|
|
1787
|
-
case "Polygon":
|
|
1788
|
-
case "MultiPolygon":
|
|
1789
|
-
return "Polygon";
|
|
1790
|
-
case "Circle":
|
|
1791
|
-
return "Circle";
|
|
1792
|
-
default:
|
|
1793
|
-
throw new Error("Invalid type: " + l);
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
const yi = {
|
|
1797
|
-
/**
|
|
1798
|
-
* Triggered upon snapping to vertex or edge
|
|
1799
|
-
* @event SnapEvent#snap
|
|
1800
|
-
* @api
|
|
1801
|
-
*/
|
|
1802
|
-
SNAP: "snap"
|
|
1803
|
-
};
|
|
1804
|
-
class xi extends J {
|
|
1805
|
-
/**
|
|
1806
|
-
* @param {SnapEventType} type Type.
|
|
1807
|
-
* @param {Object} options Options.
|
|
1808
|
-
* @param {import("../coordinate.js").Coordinate} options.vertex The snapped vertex.
|
|
1809
|
-
* @param {import("../coordinate.js").Coordinate} options.vertexPixel The pixel of the snapped vertex.
|
|
1810
|
-
* @param {import("../Feature.js").default} options.feature The feature being snapped.
|
|
1811
|
-
*/
|
|
1812
|
-
constructor(e, t) {
|
|
1813
|
-
super(e), this.vertex = t.vertex, this.vertexPixel = t.vertexPixel, this.feature = t.feature;
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
function qe(l) {
|
|
1817
|
-
return (
|
|
1818
|
-
/** @type {import("../source/Vector.js").VectorSourceEvent} */
|
|
1819
|
-
l.feature ? (
|
|
1820
|
-
/** @type {import("../source/Vector.js").VectorSourceEvent} */
|
|
1821
|
-
l.feature
|
|
1822
|
-
) : (
|
|
1823
|
-
/** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */
|
|
1824
|
-
l.element ? (
|
|
1825
|
-
/** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */
|
|
1826
|
-
l.element
|
|
1827
|
-
) : null
|
|
1828
|
-
)
|
|
1829
|
-
);
|
|
1830
|
-
}
|
|
1831
|
-
const pe = [];
|
|
1832
|
-
class Ci extends Me {
|
|
1833
|
-
/**
|
|
1834
|
-
* @param {Options} [options] Options.
|
|
1835
|
-
*/
|
|
1836
|
-
constructor(e) {
|
|
1837
|
-
e = e || {};
|
|
1838
|
-
const t = (
|
|
1839
|
-
/** @type {import("./Pointer.js").Options} */
|
|
1840
|
-
e
|
|
1841
|
-
);
|
|
1842
|
-
t.handleDownEvent || (t.handleDownEvent = ce), t.stopDown || (t.stopDown = We), 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 Be(), this.GEOMETRY_SEGMENTERS_ = {
|
|
1843
|
-
Point: this.segmentPointGeometry_.bind(this),
|
|
1844
|
-
LineString: this.segmentLineStringGeometry_.bind(this),
|
|
1845
|
-
LinearRing: this.segmentLineStringGeometry_.bind(this),
|
|
1846
|
-
Polygon: this.segmentPolygonGeometry_.bind(this),
|
|
1847
|
-
MultiPoint: this.segmentMultiPointGeometry_.bind(this),
|
|
1848
|
-
MultiLineString: this.segmentMultiLineStringGeometry_.bind(this),
|
|
1849
|
-
MultiPolygon: this.segmentMultiPolygonGeometry_.bind(this),
|
|
1850
|
-
GeometryCollection: this.segmentGeometryCollectionGeometry_.bind(this),
|
|
1851
|
-
Circle: this.segmentCircleGeometry_.bind(this)
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
/**
|
|
1855
|
-
* Add a feature to the collection of features that we may snap to.
|
|
1856
|
-
* @param {import("../Feature.js").default} feature Feature.
|
|
1857
|
-
* @param {boolean} [register] Whether to listen to the feature change or not
|
|
1858
|
-
* Defaults to `true`.
|
|
1859
|
-
* @api
|
|
1860
|
-
*/
|
|
1861
|
-
addFeature(e, t) {
|
|
1862
|
-
t = t !== void 0 ? t : !0;
|
|
1863
|
-
const i = C(e), n = e.getGeometry();
|
|
1864
|
-
if (n) {
|
|
1865
|
-
const s = this.GEOMETRY_SEGMENTERS_[n.getType()];
|
|
1866
|
-
if (s) {
|
|
1867
|
-
this.indexedFeaturesExtents_[i] = n.getExtent(
|
|
1868
|
-
Bt()
|
|
1869
|
-
);
|
|
1870
|
-
const r = (
|
|
1871
|
-
/** @type {Array<Array<import('../coordinate.js').Coordinate>>} */
|
|
1872
|
-
[]
|
|
1873
|
-
);
|
|
1874
|
-
if (s(r, n), r.length === 1)
|
|
1875
|
-
this.rBush_.insert(P(r[0]), {
|
|
1876
|
-
feature: e,
|
|
1877
|
-
segment: r[0]
|
|
1878
|
-
});
|
|
1879
|
-
else if (r.length > 1) {
|
|
1880
|
-
const o = r.map((h) => P(h)), a = r.map((h) => ({
|
|
1881
|
-
feature: e,
|
|
1882
|
-
segment: h
|
|
1883
|
-
}));
|
|
1884
|
-
this.rBush_.load(o, a);
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
t && (this.featureChangeListenerKeys_[i] = B(
|
|
1889
|
-
e,
|
|
1890
|
-
$.CHANGE,
|
|
1891
|
-
this.handleFeatureChange_,
|
|
1892
|
-
this
|
|
1893
|
-
));
|
|
1894
|
-
}
|
|
1895
|
-
/**
|
|
1896
|
-
* @return {import("../Collection.js").default<import("../Feature.js").default>|Array<import("../Feature.js").default>} Features.
|
|
1897
|
-
* @private
|
|
1898
|
-
*/
|
|
1899
|
-
getFeatures_() {
|
|
1900
|
-
let e;
|
|
1901
|
-
return this.features_ ? e = this.features_ : this.source_ && (e = this.source_.getFeatures()), e;
|
|
1902
|
-
}
|
|
1903
|
-
/**
|
|
1904
|
-
* @param {import("../MapBrowserEvent.js").default} evt Map browser event.
|
|
1905
|
-
* @return {boolean} `false` to stop event propagation.
|
|
1906
|
-
* @api
|
|
1907
|
-
*/
|
|
1908
|
-
handleEvent(e) {
|
|
1909
|
-
const t = this.snapTo(e.pixel, e.coordinate, e.map);
|
|
1910
|
-
return t && (e.coordinate = t.vertex.slice(0, 2), e.pixel = t.vertexPixel, this.dispatchEvent(
|
|
1911
|
-
new xi(yi.SNAP, {
|
|
1912
|
-
vertex: e.coordinate,
|
|
1913
|
-
vertexPixel: e.pixel,
|
|
1914
|
-
feature: t.feature
|
|
1915
|
-
})
|
|
1916
|
-
)), super.handleEvent(e);
|
|
1917
|
-
}
|
|
1918
|
-
/**
|
|
1919
|
-
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
|
|
1920
|
-
* @private
|
|
1921
|
-
*/
|
|
1922
|
-
handleFeatureAdd_(e) {
|
|
1923
|
-
const t = qe(e);
|
|
1924
|
-
t && this.addFeature(t);
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
|
|
1928
|
-
* @private
|
|
1929
|
-
*/
|
|
1930
|
-
handleFeatureRemove_(e) {
|
|
1931
|
-
const t = qe(e);
|
|
1932
|
-
t && this.removeFeature(t);
|
|
1933
|
-
}
|
|
1934
|
-
/**
|
|
1935
|
-
* @param {import("../events/Event.js").default} evt Event.
|
|
1936
|
-
* @private
|
|
1937
|
-
*/
|
|
1938
|
-
handleFeatureChange_(e) {
|
|
1939
|
-
const t = (
|
|
1940
|
-
/** @type {import("../Feature.js").default} */
|
|
1941
|
-
e.target
|
|
1942
|
-
);
|
|
1943
|
-
if (this.handlingDownUpSequence) {
|
|
1944
|
-
const i = C(t);
|
|
1945
|
-
i in this.pendingFeatures_ || (this.pendingFeatures_[i] = t);
|
|
1946
|
-
} else
|
|
1947
|
-
this.updateFeature_(t);
|
|
1948
|
-
}
|
|
1949
|
-
/**
|
|
1950
|
-
* Handle pointer up events.
|
|
1951
|
-
* @param {import("../MapBrowserEvent.js").default} evt Event.
|
|
1952
|
-
* @return {boolean} If the event was consumed.
|
|
1953
|
-
*/
|
|
1954
|
-
handleUpEvent(e) {
|
|
1955
|
-
const t = Object.values(this.pendingFeatures_);
|
|
1956
|
-
return t.length && (t.forEach(this.updateFeature_.bind(this)), this.pendingFeatures_ = {}), !1;
|
|
1957
|
-
}
|
|
1958
|
-
/**
|
|
1959
|
-
* Remove a feature from the collection of features that we may snap to.
|
|
1960
|
-
* @param {import("../Feature.js").default} feature Feature
|
|
1961
|
-
* @param {boolean} [unlisten] Whether to unlisten to the feature change
|
|
1962
|
-
* or not. Defaults to `true`.
|
|
1963
|
-
* @api
|
|
1964
|
-
*/
|
|
1965
|
-
removeFeature(e, t) {
|
|
1966
|
-
const i = t !== void 0 ? t : !0, n = C(e), s = this.indexedFeaturesExtents_[n];
|
|
1967
|
-
if (s) {
|
|
1968
|
-
const r = this.rBush_, o = [];
|
|
1969
|
-
r.forEachInExtent(s, function(a) {
|
|
1970
|
-
e === a.feature && o.push(a);
|
|
1971
|
-
});
|
|
1972
|
-
for (let a = o.length - 1; a >= 0; --a)
|
|
1973
|
-
r.remove(o[a]);
|
|
1974
|
-
}
|
|
1975
|
-
i && (me(this.featureChangeListenerKeys_[n]), delete this.featureChangeListenerKeys_[n]);
|
|
1976
|
-
}
|
|
1977
|
-
/**
|
|
1978
|
-
* Remove the interaction from its current map and attach it to the new map.
|
|
1979
|
-
* Subclasses may set up event handlers to get notified about changes to
|
|
1980
|
-
* the map here.
|
|
1981
|
-
* @param {import("../Map.js").default} map Map.
|
|
1982
|
-
*/
|
|
1983
|
-
setMap(e) {
|
|
1984
|
-
const t = this.getMap(), i = this.featuresListenerKeys_, n = (
|
|
1985
|
-
/** @type {Array<import("../Feature.js").default>} */
|
|
1986
|
-
this.getFeatures_()
|
|
1987
|
-
);
|
|
1988
|
-
t && (i.forEach(me), i.length = 0, this.rBush_.clear(), Object.values(this.featureChangeListenerKeys_).forEach(me), this.featureChangeListenerKeys_ = {}), super.setMap(e), e && (this.features_ ? i.push(
|
|
1989
|
-
B(
|
|
1990
|
-
this.features_,
|
|
1991
|
-
A.ADD,
|
|
1992
|
-
this.handleFeatureAdd_,
|
|
1993
|
-
this
|
|
1994
|
-
),
|
|
1995
|
-
B(
|
|
1996
|
-
this.features_,
|
|
1997
|
-
A.REMOVE,
|
|
1998
|
-
this.handleFeatureRemove_,
|
|
1999
|
-
this
|
|
2000
|
-
)
|
|
2001
|
-
) : this.source_ && i.push(
|
|
2002
|
-
B(
|
|
2003
|
-
this.source_,
|
|
2004
|
-
he.ADDFEATURE,
|
|
2005
|
-
this.handleFeatureAdd_,
|
|
2006
|
-
this
|
|
2007
|
-
),
|
|
2008
|
-
B(
|
|
2009
|
-
this.source_,
|
|
2010
|
-
he.REMOVEFEATURE,
|
|
2011
|
-
this.handleFeatureRemove_,
|
|
2012
|
-
this
|
|
2013
|
-
)
|
|
2014
|
-
), n.forEach((s) => this.addFeature(s)));
|
|
2015
|
-
}
|
|
2016
|
-
/**
|
|
2017
|
-
* @param {import("../pixel.js").Pixel} pixel Pixel
|
|
2018
|
-
* @param {import("../coordinate.js").Coordinate} pixelCoordinate Coordinate
|
|
2019
|
-
* @param {import("../Map.js").default} map Map.
|
|
2020
|
-
* @return {Result|null} Snap result
|
|
2021
|
-
*/
|
|
2022
|
-
snapTo(e, t, i) {
|
|
2023
|
-
i.getView().getProjection();
|
|
2024
|
-
const n = p(t), s = it(
|
|
2025
|
-
nt(
|
|
2026
|
-
P([n]),
|
|
2027
|
-
i.getView().getResolution() * this.pixelTolerance_
|
|
2028
|
-
)
|
|
2029
|
-
), r = this.rBush_.getInExtent(s), o = r.length;
|
|
2030
|
-
if (o === 0)
|
|
2031
|
-
return null;
|
|
2032
|
-
let a, h = 1 / 0, c;
|
|
2033
|
-
const u = this.pixelTolerance_ * this.pixelTolerance_, g = () => {
|
|
2034
|
-
if (a) {
|
|
2035
|
-
const d = i.getPixelFromCoordinate(a);
|
|
2036
|
-
if (O(e, d) <= u)
|
|
2037
|
-
return {
|
|
2038
|
-
vertex: a,
|
|
2039
|
-
vertexPixel: [
|
|
2040
|
-
Math.round(d[0]),
|
|
2041
|
-
Math.round(d[1])
|
|
2042
|
-
],
|
|
2043
|
-
feature: c
|
|
2044
|
-
};
|
|
2045
|
-
}
|
|
2046
|
-
return null;
|
|
2047
|
-
};
|
|
2048
|
-
if (this.vertex_) {
|
|
2049
|
-
for (let f = 0; f < o; ++f) {
|
|
2050
|
-
const _ = r[f];
|
|
2051
|
-
_.feature.getGeometry().getType() !== "Circle" && _.segment.forEach((x) => {
|
|
2052
|
-
const T = p(x), F = O(n, T);
|
|
2053
|
-
F < h && (a = x, h = F, c = _.feature);
|
|
2054
|
-
});
|
|
2055
|
-
}
|
|
2056
|
-
const d = g();
|
|
2057
|
-
if (d)
|
|
2058
|
-
return d;
|
|
2059
|
-
}
|
|
2060
|
-
if (this.edge_) {
|
|
2061
|
-
for (let f = 0; f < o; ++f) {
|
|
2062
|
-
let _ = null;
|
|
2063
|
-
const x = r[f];
|
|
2064
|
-
if (x.feature.getGeometry().getType() === "Circle") {
|
|
2065
|
-
let T = x.feature.getGeometry();
|
|
2066
|
-
_ = Wt(
|
|
2067
|
-
n,
|
|
2068
|
-
/** @type {import("../geom/Circle.js").default} */
|
|
2069
|
-
T
|
|
2070
|
-
);
|
|
2071
|
-
} else {
|
|
2072
|
-
const [T, F] = x.segment;
|
|
2073
|
-
F && (pe[0] = p(T), pe[1] = p(F), _ = st(n, pe));
|
|
2074
|
-
}
|
|
2075
|
-
if (_) {
|
|
2076
|
-
const T = O(n, _);
|
|
2077
|
-
T < h && (a = de(_), h = T);
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
const d = g();
|
|
2081
|
-
if (d)
|
|
2082
|
-
return d;
|
|
2083
|
-
}
|
|
2084
|
-
return null;
|
|
2085
|
-
}
|
|
2086
|
-
/**
|
|
2087
|
-
* @param {import("../Feature.js").default} feature Feature
|
|
2088
|
-
* @private
|
|
2089
|
-
*/
|
|
2090
|
-
updateFeature_(e) {
|
|
2091
|
-
this.removeFeature(e, !1), this.addFeature(e, !1);
|
|
2092
|
-
}
|
|
2093
|
-
/**
|
|
2094
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2095
|
-
* @param {import("../geom/Circle.js").default} geometry Geometry.
|
|
2096
|
-
* @private
|
|
2097
|
-
*/
|
|
2098
|
-
segmentCircleGeometry_(e, t) {
|
|
2099
|
-
this.getMap().getView().getProjection();
|
|
2100
|
-
const s = Ht(t).getCoordinates()[0];
|
|
2101
|
-
for (let r = 0, o = s.length - 1; r < o; ++r)
|
|
2102
|
-
e.push(s.slice(r, r + 2));
|
|
2103
|
-
}
|
|
2104
|
-
/**
|
|
2105
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2106
|
-
* @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
|
|
2107
|
-
* @private
|
|
2108
|
-
*/
|
|
2109
|
-
segmentGeometryCollectionGeometry_(e, t) {
|
|
2110
|
-
const i = t.getGeometriesArray();
|
|
2111
|
-
for (let n = 0; n < i.length; ++n) {
|
|
2112
|
-
const s = this.GEOMETRY_SEGMENTERS_[i[n].getType()];
|
|
2113
|
-
s && s(e, i[n]);
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
/**
|
|
2117
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2118
|
-
* @param {import("../geom/LineString.js").default} geometry Geometry.
|
|
2119
|
-
* @private
|
|
2120
|
-
*/
|
|
2121
|
-
segmentLineStringGeometry_(e, t) {
|
|
2122
|
-
const i = t.getCoordinates();
|
|
2123
|
-
for (let n = 0, s = i.length - 1; n < s; ++n)
|
|
2124
|
-
e.push(i.slice(n, n + 2));
|
|
2125
|
-
}
|
|
2126
|
-
/**
|
|
2127
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2128
|
-
* @param {import("../geom/MultiLineString.js").default} geometry Geometry.
|
|
2129
|
-
* @private
|
|
2130
|
-
*/
|
|
2131
|
-
segmentMultiLineStringGeometry_(e, t) {
|
|
2132
|
-
const i = t.getCoordinates();
|
|
2133
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
2134
|
-
const r = i[n];
|
|
2135
|
-
for (let o = 0, a = r.length - 1; o < a; ++o)
|
|
2136
|
-
e.push(r.slice(o, o + 2));
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
/**
|
|
2140
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2141
|
-
* @param {import("../geom/MultiPoint.js").default} geometry Geometry.
|
|
2142
|
-
* @private
|
|
2143
|
-
*/
|
|
2144
|
-
segmentMultiPointGeometry_(e, t) {
|
|
2145
|
-
t.getCoordinates().forEach((i) => {
|
|
2146
|
-
e.push([i]);
|
|
2147
|
-
});
|
|
2148
|
-
}
|
|
2149
|
-
/**
|
|
2150
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2151
|
-
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
|
|
2152
|
-
* @private
|
|
2153
|
-
*/
|
|
2154
|
-
segmentMultiPolygonGeometry_(e, t) {
|
|
2155
|
-
const i = t.getCoordinates();
|
|
2156
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
2157
|
-
const r = i[n];
|
|
2158
|
-
for (let o = 0, a = r.length; o < a; ++o) {
|
|
2159
|
-
const h = r[o];
|
|
2160
|
-
for (let c = 0, u = h.length - 1; c < u; ++c)
|
|
2161
|
-
e.push(h.slice(c, c + 2));
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
/**
|
|
2166
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2167
|
-
* @param {import("../geom/Point.js").default} geometry Geometry.
|
|
2168
|
-
* @private
|
|
2169
|
-
*/
|
|
2170
|
-
segmentPointGeometry_(e, t) {
|
|
2171
|
-
e.push([t.getCoordinates()]);
|
|
2172
|
-
}
|
|
2173
|
-
/**
|
|
2174
|
-
* @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
|
|
2175
|
-
* @param {import("../geom/Polygon.js").default} geometry Geometry.
|
|
2176
|
-
* @private
|
|
2177
|
-
*/
|
|
2178
|
-
segmentPolygonGeometry_(e, t) {
|
|
2179
|
-
const i = t.getCoordinates();
|
|
2180
|
-
for (let n = 0, s = i.length; n < s; ++n) {
|
|
2181
|
-
const r = i[n];
|
|
2182
|
-
for (let o = 0, a = r.length - 1; o < a; ++o)
|
|
2183
|
-
e.push(r.slice(o, o + 2));
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
class Ti {
|
|
2188
|
-
/**
|
|
2189
|
-
* @param {number} [highWaterMark] High water mark.
|
|
2190
|
-
*/
|
|
2191
|
-
constructor(e) {
|
|
2192
|
-
this.highWaterMark = e !== void 0 ? e : 2048, this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null;
|
|
2193
|
-
}
|
|
2194
|
-
/**
|
|
2195
|
-
* @return {boolean} Can expire cache.
|
|
2196
|
-
*/
|
|
2197
|
-
canExpireCache() {
|
|
2198
|
-
return this.highWaterMark > 0 && this.getCount() > this.highWaterMark;
|
|
2199
|
-
}
|
|
2200
|
-
/**
|
|
2201
|
-
* Expire the cache.
|
|
2202
|
-
* @param {!Object<string, boolean>} [keep] Keys to keep. To be implemented by subclasses.
|
|
2203
|
-
*/
|
|
2204
|
-
expireCache(e) {
|
|
2205
|
-
for (; this.canExpireCache(); )
|
|
2206
|
-
this.pop();
|
|
2207
|
-
}
|
|
2208
|
-
/**
|
|
2209
|
-
* FIXME empty description for jsdoc
|
|
2210
|
-
*/
|
|
2211
|
-
clear() {
|
|
2212
|
-
this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null;
|
|
2213
|
-
}
|
|
2214
|
-
/**
|
|
2215
|
-
* @param {string} key Key.
|
|
2216
|
-
* @return {boolean} Contains key.
|
|
2217
|
-
*/
|
|
2218
|
-
containsKey(e) {
|
|
2219
|
-
return this.entries_.hasOwnProperty(e);
|
|
2220
|
-
}
|
|
2221
|
-
/**
|
|
2222
|
-
* @param {function(T, string, LRUCache<T>): ?} f The function
|
|
2223
|
-
* to call for every entry from the oldest to the newer. This function takes
|
|
2224
|
-
* 3 arguments (the entry value, the entry key and the LRUCache object).
|
|
2225
|
-
* The return value is ignored.
|
|
2226
|
-
*/
|
|
2227
|
-
forEach(e) {
|
|
2228
|
-
let t = this.oldest_;
|
|
2229
|
-
for (; t; )
|
|
2230
|
-
e(t.value_, t.key_, this), t = t.newer;
|
|
2231
|
-
}
|
|
2232
|
-
/**
|
|
2233
|
-
* @param {string} key Key.
|
|
2234
|
-
* @param {*} [options] Options (reserved for subclasses).
|
|
2235
|
-
* @return {T} Value.
|
|
2236
|
-
*/
|
|
2237
|
-
get(e, t) {
|
|
2238
|
-
const i = this.entries_[e];
|
|
2239
|
-
return M(i !== void 0, 15), i === this.newest_ || (i === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
|
|
2240
|
-
this.oldest_.newer, this.oldest_.older = null) : (i.newer.older = i.older, i.older.newer = i.newer), i.newer = null, i.older = this.newest_, this.newest_.newer = i, this.newest_ = i), i.value_;
|
|
2241
|
-
}
|
|
2242
|
-
/**
|
|
2243
|
-
* Remove an entry from the cache.
|
|
2244
|
-
* @param {string} key The entry key.
|
|
2245
|
-
* @return {T} The removed entry.
|
|
2246
|
-
*/
|
|
2247
|
-
remove(e) {
|
|
2248
|
-
const t = this.entries_[e];
|
|
2249
|
-
return M(t !== void 0, 15), t === this.newest_ ? (this.newest_ = /** @type {Entry} */
|
|
2250
|
-
t.older, this.newest_ && (this.newest_.newer = null)) : t === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
|
|
2251
|
-
t.newer, this.oldest_ && (this.oldest_.older = null)) : (t.newer.older = t.older, t.older.newer = t.newer), delete this.entries_[e], --this.count_, t.value_;
|
|
2252
|
-
}
|
|
2253
|
-
/**
|
|
2254
|
-
* @return {number} Count.
|
|
2255
|
-
*/
|
|
2256
|
-
getCount() {
|
|
2257
|
-
return this.count_;
|
|
2258
|
-
}
|
|
2259
|
-
/**
|
|
2260
|
-
* @return {Array<string>} Keys.
|
|
2261
|
-
*/
|
|
2262
|
-
getKeys() {
|
|
2263
|
-
const e = new Array(this.count_);
|
|
2264
|
-
let t = 0, i;
|
|
2265
|
-
for (i = this.newest_; i; i = i.older)
|
|
2266
|
-
e[t++] = i.key_;
|
|
2267
|
-
return e;
|
|
2268
|
-
}
|
|
2269
|
-
/**
|
|
2270
|
-
* @return {Array<T>} Values.
|
|
2271
|
-
*/
|
|
2272
|
-
getValues() {
|
|
2273
|
-
const e = new Array(this.count_);
|
|
2274
|
-
let t = 0, i;
|
|
2275
|
-
for (i = this.newest_; i; i = i.older)
|
|
2276
|
-
e[t++] = i.value_;
|
|
2277
|
-
return e;
|
|
2278
|
-
}
|
|
2279
|
-
/**
|
|
2280
|
-
* @return {T} Last value.
|
|
2281
|
-
*/
|
|
2282
|
-
peekLast() {
|
|
2283
|
-
return this.oldest_.value_;
|
|
2284
|
-
}
|
|
2285
|
-
/**
|
|
2286
|
-
* @return {string} Last key.
|
|
2287
|
-
*/
|
|
2288
|
-
peekLastKey() {
|
|
2289
|
-
return this.oldest_.key_;
|
|
2290
|
-
}
|
|
2291
|
-
/**
|
|
2292
|
-
* Get the key of the newest item in the cache. Throws if the cache is empty.
|
|
2293
|
-
* @return {string} The newest key.
|
|
2294
|
-
*/
|
|
2295
|
-
peekFirstKey() {
|
|
2296
|
-
return this.newest_.key_;
|
|
2297
|
-
}
|
|
2298
|
-
/**
|
|
2299
|
-
* Return an entry without updating least recently used time.
|
|
2300
|
-
* @param {string} key Key.
|
|
2301
|
-
* @return {T} Value.
|
|
2302
|
-
*/
|
|
2303
|
-
peek(e) {
|
|
2304
|
-
if (this.containsKey(e))
|
|
2305
|
-
return this.entries_[e].value_;
|
|
2306
|
-
}
|
|
2307
|
-
/**
|
|
2308
|
-
* @return {T} value Value.
|
|
2309
|
-
*/
|
|
2310
|
-
pop() {
|
|
2311
|
-
const e = this.oldest_;
|
|
2312
|
-
return delete this.entries_[e.key_], e.newer && (e.newer.older = null), this.oldest_ = /** @type {Entry} */
|
|
2313
|
-
e.newer, this.oldest_ || (this.newest_ = null), --this.count_, e.value_;
|
|
2314
|
-
}
|
|
2315
|
-
/**
|
|
2316
|
-
* @param {string} key Key.
|
|
2317
|
-
* @param {T} value Value.
|
|
2318
|
-
*/
|
|
2319
|
-
replace(e, t) {
|
|
2320
|
-
this.get(e), this.entries_[e].value_ = t;
|
|
2321
|
-
}
|
|
2322
|
-
/**
|
|
2323
|
-
* @param {string} key Key.
|
|
2324
|
-
* @param {T} value Value.
|
|
2325
|
-
*/
|
|
2326
|
-
set(e, t) {
|
|
2327
|
-
M(!(e in this.entries_), 16);
|
|
2328
|
-
const i = {
|
|
2329
|
-
key_: e,
|
|
2330
|
-
newer: null,
|
|
2331
|
-
older: this.newest_,
|
|
2332
|
-
value_: t
|
|
2333
|
-
};
|
|
2334
|
-
this.newest_ ? this.newest_.newer = i : this.oldest_ = i, this.newest_ = i, this.entries_[e] = i, ++this.count_;
|
|
2335
|
-
}
|
|
2336
|
-
/**
|
|
2337
|
-
* Set a maximum number of entries for the cache.
|
|
2338
|
-
* @param {number} size Cache size.
|
|
2339
|
-
* @api
|
|
2340
|
-
*/
|
|
2341
|
-
setSize(e) {
|
|
2342
|
-
this.highWaterMark = e;
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
function Ye(l, e, t, i) {
|
|
2346
|
-
return i !== void 0 ? (i[0] = l, i[1] = e, i[2] = t, i) : [l, e, t];
|
|
2347
|
-
}
|
|
2348
|
-
function fe(l, e, t) {
|
|
2349
|
-
return l + "/" + e + "/" + t;
|
|
2350
|
-
}
|
|
2351
|
-
function ut(l) {
|
|
2352
|
-
return fe(l[0], l[1], l[2]);
|
|
2353
|
-
}
|
|
2354
|
-
function Fi(l) {
|
|
2355
|
-
return l.split("/").map(Number);
|
|
2356
|
-
}
|
|
2357
|
-
function pi(l) {
|
|
2358
|
-
return (l[1] << l[0]) + l[2];
|
|
2359
|
-
}
|
|
2360
|
-
function Ei(l, e) {
|
|
2361
|
-
const t = l[0], i = l[1], n = l[2];
|
|
2362
|
-
if (e.getMinZoom() > t || t > e.getMaxZoom())
|
|
2363
|
-
return !1;
|
|
2364
|
-
const s = e.getFullTileRange(t);
|
|
2365
|
-
return s ? s.containsXY(i, n) : !0;
|
|
2366
|
-
}
|
|
2367
|
-
class dt extends Ti {
|
|
2368
|
-
clear() {
|
|
2369
|
-
for (; this.getCount() > 0; )
|
|
2370
|
-
this.pop().release();
|
|
2371
|
-
super.clear();
|
|
2372
|
-
}
|
|
2373
|
-
/**
|
|
2374
|
-
* @param {!Object<string, boolean>} usedTiles Used tiles.
|
|
2375
|
-
*/
|
|
2376
|
-
expireCache(e) {
|
|
2377
|
-
for (; this.canExpireCache() && !(this.peekLast().getKey() in e); )
|
|
2378
|
-
this.pop().release();
|
|
2379
|
-
}
|
|
2380
|
-
/**
|
|
2381
|
-
* Prune all tiles from the cache that don't have the same z as the newest tile.
|
|
2382
|
-
*/
|
|
2383
|
-
pruneExceptNewestZ() {
|
|
2384
|
-
if (this.getCount() === 0)
|
|
2385
|
-
return;
|
|
2386
|
-
const e = this.peekFirstKey(), i = Fi(e)[0];
|
|
2387
|
-
this.forEach((n) => {
|
|
2388
|
-
n.tileCoord[0] !== i && (this.remove(ut(n.tileCoord)), n.release());
|
|
2389
|
-
});
|
|
2390
|
-
}
|
|
2391
|
-
}
|
|
2392
|
-
const Ee = {
|
|
2393
|
-
/**
|
|
2394
|
-
* Triggered when a tile starts loading.
|
|
2395
|
-
* @event module:ol/source/Tile.TileSourceEvent#tileloadstart
|
|
2396
|
-
* @api
|
|
2397
|
-
*/
|
|
2398
|
-
TILELOADSTART: "tileloadstart",
|
|
2399
|
-
/**
|
|
2400
|
-
* Triggered when a tile finishes loading, either when its data is loaded,
|
|
2401
|
-
* or when loading was aborted because the tile is no longer needed.
|
|
2402
|
-
* @event module:ol/source/Tile.TileSourceEvent#tileloadend
|
|
2403
|
-
* @api
|
|
2404
|
-
*/
|
|
2405
|
-
TILELOADEND: "tileloadend",
|
|
2406
|
-
/**
|
|
2407
|
-
* Triggered if tile loading results in an error. Note that this is not the
|
|
2408
|
-
* right place to re-fetch tiles. See {@link module:ol/ImageTile~ImageTile#load}
|
|
2409
|
-
* for details.
|
|
2410
|
-
* @event module:ol/source/Tile.TileSourceEvent#tileloaderror
|
|
2411
|
-
* @api
|
|
2412
|
-
*/
|
|
2413
|
-
TILELOADERROR: "tileloaderror"
|
|
2414
|
-
}, K = [0, 0, 0], R = 5;
|
|
2415
|
-
class gt {
|
|
2416
|
-
/**
|
|
2417
|
-
* @param {Options} options Tile grid options.
|
|
2418
|
-
*/
|
|
2419
|
-
constructor(e) {
|
|
2420
|
-
this.minZoom = e.minZoom !== void 0 ? e.minZoom : 0, this.resolutions_ = e.resolutions, M(
|
|
2421
|
-
St(
|
|
2422
|
-
this.resolutions_,
|
|
2423
|
-
function(n, s) {
|
|
2424
|
-
return s - n;
|
|
2425
|
-
}
|
|
2426
|
-
),
|
|
2427
|
-
17
|
|
2428
|
-
);
|
|
2429
|
-
let t;
|
|
2430
|
-
if (!e.origins) {
|
|
2431
|
-
for (let n = 0, s = this.resolutions_.length - 1; n < s; ++n)
|
|
2432
|
-
if (!t)
|
|
2433
|
-
t = this.resolutions_[n] / this.resolutions_[n + 1];
|
|
2434
|
-
else if (this.resolutions_[n] / this.resolutions_[n + 1] !== t) {
|
|
2435
|
-
t = void 0;
|
|
2436
|
-
break;
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
this.zoomFactor_ = t, this.maxZoom = this.resolutions_.length - 1, this.origin_ = e.origin !== void 0 ? e.origin : null, this.origins_ = null, e.origins !== void 0 && (this.origins_ = e.origins, M(this.origins_.length == this.resolutions_.length, 20));
|
|
2440
|
-
const i = e.extent;
|
|
2441
|
-
i !== void 0 && !this.origin_ && !this.origins_ && (this.origin_ = $t(i)), M(
|
|
2442
|
-
!this.origin_ && this.origins_ || this.origin_ && !this.origins_,
|
|
2443
|
-
18
|
|
2444
|
-
), this.tileSizes_ = null, e.tileSizes !== void 0 && (this.tileSizes_ = e.tileSizes, M(this.tileSizes_.length == this.resolutions_.length, 19)), this.tileSize_ = e.tileSize !== void 0 ? e.tileSize : this.tileSizes_ ? null : ot, M(
|
|
2445
|
-
!this.tileSize_ && this.tileSizes_ || this.tileSize_ && !this.tileSizes_,
|
|
2446
|
-
22
|
|
2447
|
-
), this.extent_ = i !== void 0 ? i : null, this.fullTileRanges_ = null, this.tmpSize_ = [0, 0], this.tmpExtent_ = [0, 0, 0, 0], e.sizes !== void 0 ? this.fullTileRanges_ = e.sizes.map(function(n, s) {
|
|
2448
|
-
const r = new jt(
|
|
2449
|
-
Math.min(0, n[0]),
|
|
2450
|
-
Math.max(n[0] - 1, -1),
|
|
2451
|
-
Math.min(0, n[1]),
|
|
2452
|
-
Math.max(n[1] - 1, -1)
|
|
2453
|
-
);
|
|
2454
|
-
if (i) {
|
|
2455
|
-
const o = this.getTileRangeForExtentAndZ(i, s);
|
|
2456
|
-
r.minX = Math.max(o.minX, r.minX), r.maxX = Math.min(o.maxX, r.maxX), r.minY = Math.max(o.minY, r.minY), r.maxY = Math.min(o.maxY, r.maxY);
|
|
2457
|
-
}
|
|
2458
|
-
return r;
|
|
2459
|
-
}, this) : i && this.calculateTileRanges_(i);
|
|
2460
|
-
}
|
|
2461
|
-
/**
|
|
2462
|
-
* Call a function with each tile coordinate for a given extent and zoom level.
|
|
2463
|
-
*
|
|
2464
|
-
* @param {import("../extent.js").Extent} extent Extent.
|
|
2465
|
-
* @param {number} zoom Integer zoom level.
|
|
2466
|
-
* @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate.
|
|
2467
|
-
* @api
|
|
2468
|
-
*/
|
|
2469
|
-
forEachTileCoord(e, t, i) {
|
|
2470
|
-
const n = this.getTileRangeForExtentAndZ(e, t);
|
|
2471
|
-
for (let s = n.minX, r = n.maxX; s <= r; ++s)
|
|
2472
|
-
for (let o = n.minY, a = n.maxY; o <= a; ++o)
|
|
2473
|
-
i([t, s, o]);
|
|
2474
|
-
}
|
|
2475
|
-
/**
|
|
2476
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
2477
|
-
* @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
|
|
2478
|
-
* @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
|
|
2479
|
-
* @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
|
|
2480
|
-
* @return {boolean} Callback succeeded.
|
|
2481
|
-
*/
|
|
2482
|
-
forEachTileCoordParentTileRange(e, t, i, n) {
|
|
2483
|
-
let s, r, o, a = null, h = e[0] - 1;
|
|
2484
|
-
for (this.zoomFactor_ === 2 ? (r = e[1], o = e[2]) : a = this.getTileCoordExtent(e, n); h >= this.minZoom; ) {
|
|
2485
|
-
if (this.zoomFactor_ === 2 ? (r = Math.floor(r / 2), o = Math.floor(o / 2), s = z(r, r, o, o, i)) : s = this.getTileRangeForExtentAndZ(
|
|
2486
|
-
a,
|
|
2487
|
-
h,
|
|
2488
|
-
i
|
|
2489
|
-
), t(h, s))
|
|
2490
|
-
return !0;
|
|
2491
|
-
--h;
|
|
2492
|
-
}
|
|
2493
|
-
return !1;
|
|
2494
|
-
}
|
|
2495
|
-
/**
|
|
2496
|
-
* Get the extent for this tile grid, if it was configured.
|
|
2497
|
-
* @return {import("../extent.js").Extent} Extent.
|
|
2498
|
-
* @api
|
|
2499
|
-
*/
|
|
2500
|
-
getExtent() {
|
|
2501
|
-
return this.extent_;
|
|
2502
|
-
}
|
|
2503
|
-
/**
|
|
2504
|
-
* Get the maximum zoom level for the grid.
|
|
2505
|
-
* @return {number} Max zoom.
|
|
2506
|
-
* @api
|
|
2507
|
-
*/
|
|
2508
|
-
getMaxZoom() {
|
|
2509
|
-
return this.maxZoom;
|
|
2510
|
-
}
|
|
2511
|
-
/**
|
|
2512
|
-
* Get the minimum zoom level for the grid.
|
|
2513
|
-
* @return {number} Min zoom.
|
|
2514
|
-
* @api
|
|
2515
|
-
*/
|
|
2516
|
-
getMinZoom() {
|
|
2517
|
-
return this.minZoom;
|
|
2518
|
-
}
|
|
2519
|
-
/**
|
|
2520
|
-
* Get the origin for the grid at the given zoom level.
|
|
2521
|
-
* @param {number} z Integer zoom level.
|
|
2522
|
-
* @return {import("../coordinate.js").Coordinate} Origin.
|
|
2523
|
-
* @api
|
|
2524
|
-
*/
|
|
2525
|
-
getOrigin(e) {
|
|
2526
|
-
return this.origin_ ? this.origin_ : this.origins_[e];
|
|
2527
|
-
}
|
|
2528
|
-
/**
|
|
2529
|
-
* Get the resolution for the given zoom level.
|
|
2530
|
-
* @param {number} z Integer zoom level.
|
|
2531
|
-
* @return {number} Resolution.
|
|
2532
|
-
* @api
|
|
2533
|
-
*/
|
|
2534
|
-
getResolution(e) {
|
|
2535
|
-
return this.resolutions_[e];
|
|
2536
|
-
}
|
|
2537
|
-
/**
|
|
2538
|
-
* Get the list of resolutions for the tile grid.
|
|
2539
|
-
* @return {Array<number>} Resolutions.
|
|
2540
|
-
* @api
|
|
2541
|
-
*/
|
|
2542
|
-
getResolutions() {
|
|
2543
|
-
return this.resolutions_;
|
|
2544
|
-
}
|
|
2545
|
-
/**
|
|
2546
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
2547
|
-
* @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
|
|
2548
|
-
* @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
|
|
2549
|
-
* @return {import("../TileRange.js").default|null} Tile range.
|
|
2550
|
-
*/
|
|
2551
|
-
getTileCoordChildTileRange(e, t, i) {
|
|
2552
|
-
if (e[0] < this.maxZoom) {
|
|
2553
|
-
if (this.zoomFactor_ === 2) {
|
|
2554
|
-
const s = e[1] * 2, r = e[2] * 2;
|
|
2555
|
-
return z(
|
|
2556
|
-
s,
|
|
2557
|
-
s + 1,
|
|
2558
|
-
r,
|
|
2559
|
-
r + 1,
|
|
2560
|
-
t
|
|
2561
|
-
);
|
|
2562
|
-
}
|
|
2563
|
-
const n = this.getTileCoordExtent(
|
|
2564
|
-
e,
|
|
2565
|
-
i || this.tmpExtent_
|
|
2566
|
-
);
|
|
2567
|
-
return this.getTileRangeForExtentAndZ(
|
|
2568
|
-
n,
|
|
2569
|
-
e[0] + 1,
|
|
2570
|
-
t
|
|
2571
|
-
);
|
|
2572
|
-
}
|
|
2573
|
-
return null;
|
|
2574
|
-
}
|
|
2575
|
-
/**
|
|
2576
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
2577
|
-
* @param {number} z Integer zoom level.
|
|
2578
|
-
* @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
|
|
2579
|
-
* @return {import("../TileRange.js").default|null} Tile range.
|
|
2580
|
-
*/
|
|
2581
|
-
getTileRangeForTileCoordAndZ(e, t, i) {
|
|
2582
|
-
if (t > this.maxZoom || t < this.minZoom)
|
|
2583
|
-
return null;
|
|
2584
|
-
const n = e[0], s = e[1], r = e[2];
|
|
2585
|
-
if (t === n)
|
|
2586
|
-
return z(
|
|
2587
|
-
s,
|
|
2588
|
-
r,
|
|
2589
|
-
s,
|
|
2590
|
-
r,
|
|
2591
|
-
i
|
|
2592
|
-
);
|
|
2593
|
-
if (this.zoomFactor_) {
|
|
2594
|
-
const a = Math.pow(this.zoomFactor_, t - n), h = Math.floor(s * a), c = Math.floor(r * a);
|
|
2595
|
-
if (t < n)
|
|
2596
|
-
return z(h, h, c, c, i);
|
|
2597
|
-
const u = Math.floor(a * (s + 1)) - 1, g = Math.floor(a * (r + 1)) - 1;
|
|
2598
|
-
return z(h, u, c, g, i);
|
|
2599
|
-
}
|
|
2600
|
-
const o = this.getTileCoordExtent(e, this.tmpExtent_);
|
|
2601
|
-
return this.getTileRangeForExtentAndZ(o, t, i);
|
|
2602
|
-
}
|
|
2603
|
-
/**
|
|
2604
|
-
* Get a tile range for the given extent and integer zoom level.
|
|
2605
|
-
* @param {import("../extent.js").Extent} extent Extent.
|
|
2606
|
-
* @param {number} z Integer zoom level.
|
|
2607
|
-
* @param {import("../TileRange.js").default} [tempTileRange] Temporary tile range object.
|
|
2608
|
-
* @return {import("../TileRange.js").default} Tile range.
|
|
2609
|
-
*/
|
|
2610
|
-
getTileRangeForExtentAndZ(e, t, i) {
|
|
2611
|
-
this.getTileCoordForXYAndZ_(e[0], e[3], t, !1, K);
|
|
2612
|
-
const n = K[1], s = K[2];
|
|
2613
|
-
this.getTileCoordForXYAndZ_(e[2], e[1], t, !0, K);
|
|
2614
|
-
const r = K[1], o = K[2];
|
|
2615
|
-
return z(n, r, s, o, i);
|
|
2616
|
-
}
|
|
2617
|
-
/**
|
|
2618
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
2619
|
-
* @return {import("../coordinate.js").Coordinate} Tile center.
|
|
2620
|
-
*/
|
|
2621
|
-
getTileCoordCenter(e) {
|
|
2622
|
-
const t = this.getOrigin(e[0]), i = this.getResolution(e[0]), n = I(this.getTileSize(e[0]), this.tmpSize_);
|
|
2623
|
-
return [
|
|
2624
|
-
t[0] + (e[1] + 0.5) * n[0] * i,
|
|
2625
|
-
t[1] - (e[2] + 0.5) * n[1] * i
|
|
2626
|
-
];
|
|
2627
|
-
}
|
|
2628
|
-
/**
|
|
2629
|
-
* Get the extent of a tile coordinate.
|
|
2630
|
-
*
|
|
2631
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
2632
|
-
* @param {import("../extent.js").Extent} [tempExtent] Temporary extent object.
|
|
2633
|
-
* @return {import("../extent.js").Extent} Extent.
|
|
2634
|
-
* @api
|
|
2635
|
-
*/
|
|
2636
|
-
getTileCoordExtent(e, t) {
|
|
2637
|
-
const i = this.getOrigin(e[0]), n = this.getResolution(e[0]), s = I(this.getTileSize(e[0]), this.tmpSize_), r = i[0] + e[1] * s[0] * n, o = i[1] - (e[2] + 1) * s[1] * n, a = r + s[0] * n, h = o + s[1] * n;
|
|
2638
|
-
return at(r, o, a, h, t);
|
|
2639
|
-
}
|
|
2640
|
-
/**
|
|
2641
|
-
* Get the tile coordinate for the given map coordinate and resolution. This
|
|
2642
|
-
* method considers that coordinates that intersect tile boundaries should be
|
|
2643
|
-
* assigned the higher tile coordinate.
|
|
2644
|
-
*
|
|
2645
|
-
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
|
|
2646
|
-
* @param {number} resolution Resolution.
|
|
2647
|
-
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
|
|
2648
|
-
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
|
|
2649
|
-
* @api
|
|
2650
|
-
*/
|
|
2651
|
-
getTileCoordForCoordAndResolution(e, t, i) {
|
|
2652
|
-
return this.getTileCoordForXYAndResolution_(
|
|
2653
|
-
e[0],
|
|
2654
|
-
e[1],
|
|
2655
|
-
t,
|
|
2656
|
-
!1,
|
|
2657
|
-
i
|
|
2658
|
-
);
|
|
2659
|
-
}
|
|
2660
|
-
/**
|
|
2661
|
-
* Note that this method should not be called for resolutions that correspond
|
|
2662
|
-
* to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method.
|
|
2663
|
-
* @param {number} x X.
|
|
2664
|
-
* @param {number} y Y.
|
|
2665
|
-
* @param {number} resolution Resolution (for a non-integer zoom level).
|
|
2666
|
-
* @param {boolean} reverseIntersectionPolicy Instead of letting edge
|
|
2667
|
-
* intersections go to the higher tile coordinate, let edge intersections
|
|
2668
|
-
* go to the lower tile coordinate.
|
|
2669
|
-
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
|
|
2670
|
-
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
|
|
2671
|
-
* @private
|
|
2672
|
-
*/
|
|
2673
|
-
getTileCoordForXYAndResolution_(e, t, i, n, s) {
|
|
2674
|
-
const r = this.getZForResolution(i), o = i / this.getResolution(r), a = this.getOrigin(r), h = I(this.getTileSize(r), this.tmpSize_);
|
|
2675
|
-
let c = o * (e - a[0]) / i / h[0], u = o * (a[1] - t) / i / h[1];
|
|
2676
|
-
return n ? (c = ee(c, R) - 1, u = ee(u, R) - 1) : (c = te(c, R), u = te(u, R)), Ye(r, c, u, s);
|
|
2677
|
-
}
|
|
2678
|
-
/**
|
|
2679
|
-
* Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
|
|
2680
|
-
* they should have separate implementations. This method is for integer zoom
|
|
2681
|
-
* levels. The other method should only be called for resolutions corresponding
|
|
2682
|
-
* to non-integer zoom levels.
|
|
2683
|
-
* @param {number} x Map x coordinate.
|
|
2684
|
-
* @param {number} y Map y coordinate.
|
|
2685
|
-
* @param {number} z Integer zoom level.
|
|
2686
|
-
* @param {boolean} reverseIntersectionPolicy Instead of letting edge
|
|
2687
|
-
* intersections go to the higher tile coordinate, let edge intersections
|
|
2688
|
-
* go to the lower tile coordinate.
|
|
2689
|
-
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
|
|
2690
|
-
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
|
|
2691
|
-
* @private
|
|
2692
|
-
*/
|
|
2693
|
-
getTileCoordForXYAndZ_(e, t, i, n, s) {
|
|
2694
|
-
const r = this.getOrigin(i), o = this.getResolution(i), a = I(this.getTileSize(i), this.tmpSize_);
|
|
2695
|
-
let h = (e - r[0]) / o / a[0], c = (r[1] - t) / o / a[1];
|
|
2696
|
-
return n ? (h = ee(h, R) - 1, c = ee(c, R) - 1) : (h = te(h, R), c = te(c, R)), Ye(i, h, c, s);
|
|
2697
|
-
}
|
|
2698
|
-
/**
|
|
2699
|
-
* Get a tile coordinate given a map coordinate and zoom level.
|
|
2700
|
-
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
|
|
2701
|
-
* @param {number} z Zoom level.
|
|
2702
|
-
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
|
|
2703
|
-
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
|
|
2704
|
-
* @api
|
|
2705
|
-
*/
|
|
2706
|
-
getTileCoordForCoordAndZ(e, t, i) {
|
|
2707
|
-
return this.getTileCoordForXYAndZ_(
|
|
2708
|
-
e[0],
|
|
2709
|
-
e[1],
|
|
2710
|
-
t,
|
|
2711
|
-
!1,
|
|
2712
|
-
i
|
|
2713
|
-
);
|
|
2714
|
-
}
|
|
2715
|
-
/**
|
|
2716
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
2717
|
-
* @return {number} Tile resolution.
|
|
2718
|
-
*/
|
|
2719
|
-
getTileCoordResolution(e) {
|
|
2720
|
-
return this.resolutions_[e[0]];
|
|
2721
|
-
}
|
|
2722
|
-
/**
|
|
2723
|
-
* Get the tile size for a zoom level. The type of the return value matches the
|
|
2724
|
-
* `tileSize` or `tileSizes` that the tile grid was configured with. To always
|
|
2725
|
-
* get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}.
|
|
2726
|
-
* @param {number} z Z.
|
|
2727
|
-
* @return {number|import("../size.js").Size} Tile size.
|
|
2728
|
-
* @api
|
|
2729
|
-
*/
|
|
2730
|
-
getTileSize(e) {
|
|
2731
|
-
return this.tileSize_ ? this.tileSize_ : this.tileSizes_[e];
|
|
2732
|
-
}
|
|
2733
|
-
/**
|
|
2734
|
-
* @param {number} z Zoom level.
|
|
2735
|
-
* @return {import("../TileRange.js").default} Extent tile range for the specified zoom level.
|
|
2736
|
-
*/
|
|
2737
|
-
getFullTileRange(e) {
|
|
2738
|
-
return this.fullTileRanges_ ? this.fullTileRanges_[e] : this.extent_ ? this.getTileRangeForExtentAndZ(this.extent_, e) : null;
|
|
2739
|
-
}
|
|
2740
|
-
/**
|
|
2741
|
-
* @param {number} resolution Resolution.
|
|
2742
|
-
* @param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
|
|
2743
|
-
* If 0, the nearest resolution will be used.
|
|
2744
|
-
* If 1, the nearest higher resolution (lower Z) will be used. If -1, the
|
|
2745
|
-
* nearest lower resolution (higher Z) will be used. Default is 0.
|
|
2746
|
-
* Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.
|
|
2747
|
-
*
|
|
2748
|
-
* For example to change tile Z at the midpoint of zoom levels
|
|
2749
|
-
* ```js
|
|
2750
|
-
* function(value, high, low) {
|
|
2751
|
-
* return value - low * Math.sqrt(high / low);
|
|
2752
|
-
* }
|
|
2753
|
-
* ```
|
|
2754
|
-
* @return {number} Z.
|
|
2755
|
-
* @api
|
|
2756
|
-
*/
|
|
2757
|
-
getZForResolution(e, t) {
|
|
2758
|
-
const i = wt(
|
|
2759
|
-
this.resolutions_,
|
|
2760
|
-
e,
|
|
2761
|
-
t || 0
|
|
2762
|
-
);
|
|
2763
|
-
return $e(i, this.minZoom, this.maxZoom);
|
|
2764
|
-
}
|
|
2765
|
-
/**
|
|
2766
|
-
* The tile with the provided tile coordinate intersects the given viewport.
|
|
2767
|
-
* @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
|
|
2768
|
-
* @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
|
|
2769
|
-
* @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
|
|
2770
|
-
*/
|
|
2771
|
-
tileCoordIntersectsViewport(e, t) {
|
|
2772
|
-
return Jt(
|
|
2773
|
-
t,
|
|
2774
|
-
0,
|
|
2775
|
-
t.length,
|
|
2776
|
-
2,
|
|
2777
|
-
this.getTileCoordExtent(e)
|
|
2778
|
-
);
|
|
2779
|
-
}
|
|
2780
|
-
/**
|
|
2781
|
-
* @param {!import("../extent.js").Extent} extent Extent for this tile grid.
|
|
2782
|
-
* @private
|
|
2783
|
-
*/
|
|
2784
|
-
calculateTileRanges_(e) {
|
|
2785
|
-
const t = this.resolutions_.length, i = new Array(t);
|
|
2786
|
-
for (let n = this.minZoom; n < t; ++n)
|
|
2787
|
-
i[n] = this.getTileRangeForExtentAndZ(e, n);
|
|
2788
|
-
this.fullTileRanges_ = i;
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
|
-
function ft(l) {
|
|
2792
|
-
let e = l.getDefaultTileGrid();
|
|
2793
|
-
return e || (e = Li(l), l.setDefaultTileGrid(e)), e;
|
|
2794
|
-
}
|
|
2795
|
-
function Si(l, e, t) {
|
|
2796
|
-
const i = e[0], n = l.getTileCoordCenter(e), s = Re(t);
|
|
2797
|
-
if (!ni(s, n)) {
|
|
2798
|
-
const r = lt(s), o = Math.ceil(
|
|
2799
|
-
(s[0] - n[0]) / r
|
|
2800
|
-
);
|
|
2801
|
-
return n[0] += r * o, l.getTileCoordForCoordAndZ(n, i);
|
|
2802
|
-
}
|
|
2803
|
-
return e;
|
|
2804
|
-
}
|
|
2805
|
-
function wi(l, e, t, i) {
|
|
2806
|
-
i = i !== void 0 ? i : "top-left";
|
|
2807
|
-
const n = _t(l, e, t);
|
|
2808
|
-
return new gt({
|
|
2809
|
-
extent: l,
|
|
2810
|
-
origin: ti(l, i),
|
|
2811
|
-
resolutions: n,
|
|
2812
|
-
tileSize: t
|
|
2813
|
-
});
|
|
2814
|
-
}
|
|
2815
|
-
function Pi(l) {
|
|
2816
|
-
const e = l || {}, t = e.extent || Ge("EPSG:3857").getExtent(), i = {
|
|
2817
|
-
extent: t,
|
|
2818
|
-
minZoom: e.minZoom,
|
|
2819
|
-
tileSize: e.tileSize,
|
|
2820
|
-
resolutions: _t(
|
|
2821
|
-
t,
|
|
2822
|
-
e.maxZoom,
|
|
2823
|
-
e.tileSize,
|
|
2824
|
-
e.maxResolution
|
|
2825
|
-
)
|
|
2826
|
-
};
|
|
2827
|
-
return new gt(i);
|
|
2828
|
-
}
|
|
2829
|
-
function _t(l, e, t, i) {
|
|
2830
|
-
e = e !== void 0 ? e : ii, t = I(t !== void 0 ? t : ot);
|
|
2831
|
-
const n = Qt(l), s = lt(l);
|
|
2832
|
-
i = i > 0 ? i : Math.max(s / t[0], n / t[1]);
|
|
2833
|
-
const r = e + 1, o = new Array(r);
|
|
2834
|
-
for (let a = 0; a < r; ++a)
|
|
2835
|
-
o[a] = i / Math.pow(2, a);
|
|
2836
|
-
return o;
|
|
2837
|
-
}
|
|
2838
|
-
function Li(l, e, t, i) {
|
|
2839
|
-
const n = Re(l);
|
|
2840
|
-
return wi(n, e, t, i);
|
|
2841
|
-
}
|
|
2842
|
-
function Re(l) {
|
|
2843
|
-
l = Ge(l);
|
|
2844
|
-
let e = l.getExtent();
|
|
2845
|
-
if (!e) {
|
|
2846
|
-
const t = 180 * ei.degrees / l.getMetersPerUnit();
|
|
2847
|
-
e = at(-t, -t, t, t);
|
|
2848
|
-
}
|
|
2849
|
-
return e;
|
|
2850
|
-
}
|
|
2851
|
-
class Di extends si {
|
|
2852
|
-
/**
|
|
2853
|
-
* @param {Options} options SourceTile source options.
|
|
2854
|
-
*/
|
|
2855
|
-
constructor(e) {
|
|
2856
|
-
super({
|
|
2857
|
-
attributions: e.attributions,
|
|
2858
|
-
attributionsCollapsible: e.attributionsCollapsible,
|
|
2859
|
-
projection: e.projection,
|
|
2860
|
-
state: e.state,
|
|
2861
|
-
wrapX: e.wrapX,
|
|
2862
|
-
interpolate: e.interpolate
|
|
2863
|
-
}), this.on, this.once, this.un, this.opaque_ = e.opaque !== void 0 ? e.opaque : !1, this.tilePixelRatio_ = e.tilePixelRatio !== void 0 ? e.tilePixelRatio : 1, this.tileGrid = e.tileGrid !== void 0 ? e.tileGrid : null;
|
|
2864
|
-
const t = [256, 256];
|
|
2865
|
-
this.tileGrid && I(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), t), this.tileCache = new dt(e.cacheSize || 0), this.tmpSize = [0, 0], this.key_ = e.key || "", this.tileOptions = {
|
|
2866
|
-
transition: e.transition,
|
|
2867
|
-
interpolate: e.interpolate
|
|
2868
|
-
}, this.zDirection = e.zDirection ? e.zDirection : 0;
|
|
2869
|
-
}
|
|
2870
|
-
/**
|
|
2871
|
-
* @return {boolean} Can expire cache.
|
|
2872
|
-
*/
|
|
2873
|
-
canExpireCache() {
|
|
2874
|
-
return this.tileCache.canExpireCache();
|
|
2875
|
-
}
|
|
2876
|
-
/**
|
|
2877
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2878
|
-
* @param {!Object<string, boolean>} usedTiles Used tiles.
|
|
2879
|
-
*/
|
|
2880
|
-
expireCache(e, t) {
|
|
2881
|
-
const i = this.getTileCacheForProjection(e);
|
|
2882
|
-
i && i.expireCache(t);
|
|
2883
|
-
}
|
|
2884
|
-
/**
|
|
2885
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2886
|
-
* @param {number} z Zoom level.
|
|
2887
|
-
* @param {import("../TileRange.js").default} tileRange Tile range.
|
|
2888
|
-
* @param {function(import("../Tile.js").default):(boolean|void)} callback Called with each
|
|
2889
|
-
* loaded tile. If the callback returns `false`, the tile will not be
|
|
2890
|
-
* considered loaded.
|
|
2891
|
-
* @return {boolean} The tile range is fully covered with loaded tiles.
|
|
2892
|
-
*/
|
|
2893
|
-
forEachLoadedTile(e, t, i, n) {
|
|
2894
|
-
const s = this.getTileCacheForProjection(e);
|
|
2895
|
-
if (!s)
|
|
2896
|
-
return !1;
|
|
2897
|
-
let r = !0, o, a, h;
|
|
2898
|
-
for (let c = i.minX; c <= i.maxX; ++c)
|
|
2899
|
-
for (let u = i.minY; u <= i.maxY; ++u)
|
|
2900
|
-
a = fe(t, c, u), h = !1, s.containsKey(a) && (o = /** @type {!import("../Tile.js").default} */
|
|
2901
|
-
s.get(a), h = o.getState() === j.LOADED, h && (h = n(o) !== !1)), h || (r = !1);
|
|
2902
|
-
return r;
|
|
2903
|
-
}
|
|
2904
|
-
/**
|
|
2905
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2906
|
-
* @return {number} Gutter.
|
|
2907
|
-
*/
|
|
2908
|
-
getGutterForProjection(e) {
|
|
2909
|
-
return 0;
|
|
2910
|
-
}
|
|
2911
|
-
/**
|
|
2912
|
-
* Return the key to be used for all tiles in the source.
|
|
2913
|
-
* @return {string} The key for all tiles.
|
|
2914
|
-
*/
|
|
2915
|
-
getKey() {
|
|
2916
|
-
return this.key_;
|
|
2917
|
-
}
|
|
2918
|
-
/**
|
|
2919
|
-
* Set the value to be used as the key for all tiles in the source.
|
|
2920
|
-
* @param {string} key The key for tiles.
|
|
2921
|
-
* @protected
|
|
2922
|
-
*/
|
|
2923
|
-
setKey(e) {
|
|
2924
|
-
this.key_ !== e && (this.key_ = e, this.changed());
|
|
2925
|
-
}
|
|
2926
|
-
/**
|
|
2927
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2928
|
-
* @return {boolean} Opaque.
|
|
2929
|
-
*/
|
|
2930
|
-
getOpaque(e) {
|
|
2931
|
-
return this.opaque_;
|
|
2932
|
-
}
|
|
2933
|
-
/**
|
|
2934
|
-
* @param {import("../proj/Projection").default} [projection] Projection.
|
|
2935
|
-
* @return {Array<number>|null} Resolutions.
|
|
2936
|
-
*/
|
|
2937
|
-
getResolutions(e) {
|
|
2938
|
-
const t = e ? this.getTileGridForProjection(e) : this.tileGrid;
|
|
2939
|
-
return t ? t.getResolutions() : null;
|
|
2940
|
-
}
|
|
2941
|
-
/**
|
|
2942
|
-
* @abstract
|
|
2943
|
-
* @param {number} z Tile coordinate z.
|
|
2944
|
-
* @param {number} x Tile coordinate x.
|
|
2945
|
-
* @param {number} y Tile coordinate y.
|
|
2946
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
2947
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2948
|
-
* @return {!import("../Tile.js").default} Tile.
|
|
2949
|
-
*/
|
|
2950
|
-
getTile(e, t, i, n, s) {
|
|
2951
|
-
return Pt();
|
|
2952
|
-
}
|
|
2953
|
-
/**
|
|
2954
|
-
* Return the tile grid of the tile source.
|
|
2955
|
-
* @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
|
|
2956
|
-
* @api
|
|
2957
|
-
*/
|
|
2958
|
-
getTileGrid() {
|
|
2959
|
-
return this.tileGrid;
|
|
2960
|
-
}
|
|
2961
|
-
/**
|
|
2962
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2963
|
-
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
|
|
2964
|
-
*/
|
|
2965
|
-
getTileGridForProjection(e) {
|
|
2966
|
-
return this.tileGrid ? this.tileGrid : ft(e);
|
|
2967
|
-
}
|
|
2968
|
-
/**
|
|
2969
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2970
|
-
* @return {import("../TileCache.js").default} Tile cache.
|
|
2971
|
-
* @protected
|
|
2972
|
-
*/
|
|
2973
|
-
getTileCacheForProjection(e) {
|
|
2974
|
-
const t = this.getProjection();
|
|
2975
|
-
return M(
|
|
2976
|
-
t === null || N(t, e),
|
|
2977
|
-
68
|
|
2978
|
-
// A VectorTile source can only be rendered if it has a projection compatible with the view projection.
|
|
2979
|
-
), this.tileCache;
|
|
2980
|
-
}
|
|
2981
|
-
/**
|
|
2982
|
-
* Get the tile pixel ratio for this source. Subclasses may override this
|
|
2983
|
-
* method, which is meant to return a supported pixel ratio that matches the
|
|
2984
|
-
* provided `pixelRatio` as close as possible.
|
|
2985
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
2986
|
-
* @return {number} Tile pixel ratio.
|
|
2987
|
-
*/
|
|
2988
|
-
getTilePixelRatio(e) {
|
|
2989
|
-
return this.tilePixelRatio_;
|
|
2990
|
-
}
|
|
2991
|
-
/**
|
|
2992
|
-
* @param {number} z Z.
|
|
2993
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
2994
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
2995
|
-
* @return {import("../size.js").Size} Tile size.
|
|
2996
|
-
*/
|
|
2997
|
-
getTilePixelSize(e, t, i) {
|
|
2998
|
-
const n = this.getTileGridForProjection(i), s = this.getTilePixelRatio(t), r = I(n.getTileSize(e), this.tmpSize);
|
|
2999
|
-
return s == 1 ? r : Nt(r, s, this.tmpSize);
|
|
3000
|
-
}
|
|
3001
|
-
/**
|
|
3002
|
-
* Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
|
|
3003
|
-
* is outside the resolution and extent range of the tile grid, `null` will be
|
|
3004
|
-
* returned.
|
|
3005
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
3006
|
-
* @param {import("../proj/Projection.js").default} [projection] Projection.
|
|
3007
|
-
* @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
|
|
3008
|
-
* null if no tile URL should be created for the passed `tileCoord`.
|
|
3009
|
-
*/
|
|
3010
|
-
getTileCoordForTileUrlFunction(e, t) {
|
|
3011
|
-
t = t !== void 0 ? t : this.getProjection();
|
|
3012
|
-
const i = this.getTileGridForProjection(t);
|
|
3013
|
-
return this.getWrapX() && t.isGlobal() && (e = Si(i, e, t)), Ei(e, i) ? e : null;
|
|
3014
|
-
}
|
|
3015
|
-
/**
|
|
3016
|
-
* Remove all cached tiles from the source. The next render cycle will fetch new tiles.
|
|
3017
|
-
* @api
|
|
3018
|
-
*/
|
|
3019
|
-
clear() {
|
|
3020
|
-
this.tileCache.clear();
|
|
3021
|
-
}
|
|
3022
|
-
refresh() {
|
|
3023
|
-
this.clear(), super.refresh();
|
|
3024
|
-
}
|
|
3025
|
-
/**
|
|
3026
|
-
* Increases the cache size if needed
|
|
3027
|
-
* @param {number} tileCount Minimum number of tiles needed.
|
|
3028
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3029
|
-
*/
|
|
3030
|
-
updateCacheSize(e, t) {
|
|
3031
|
-
const i = this.getTileCacheForProjection(t);
|
|
3032
|
-
e > i.highWaterMark && (i.highWaterMark = e);
|
|
3033
|
-
}
|
|
3034
|
-
/**
|
|
3035
|
-
* Marks a tile coord as being used, without triggering a load.
|
|
3036
|
-
* @abstract
|
|
3037
|
-
* @param {number} z Tile coordinate z.
|
|
3038
|
-
* @param {number} x Tile coordinate x.
|
|
3039
|
-
* @param {number} y Tile coordinate y.
|
|
3040
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3041
|
-
*/
|
|
3042
|
-
useTile(e, t, i, n) {
|
|
3043
|
-
}
|
|
3044
|
-
}
|
|
3045
|
-
class Mi extends J {
|
|
3046
|
-
/**
|
|
3047
|
-
* @param {string} type Type.
|
|
3048
|
-
* @param {import("../Tile.js").default} tile The tile.
|
|
3049
|
-
*/
|
|
3050
|
-
constructor(e, t) {
|
|
3051
|
-
super(e), this.tile = t;
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
function ki(l, e) {
|
|
3055
|
-
const t = /\{z\}/g, i = /\{x\}/g, n = /\{y\}/g, s = /\{-y\}/g;
|
|
3056
|
-
return (
|
|
3057
|
-
/**
|
|
3058
|
-
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
|
|
3059
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
3060
|
-
* @param {import("./proj/Projection.js").default} projection Projection.
|
|
3061
|
-
* @return {string|undefined} Tile URL.
|
|
3062
|
-
*/
|
|
3063
|
-
function(r, o, a) {
|
|
3064
|
-
if (r)
|
|
3065
|
-
return l.replace(t, r[0].toString()).replace(i, r[1].toString()).replace(n, r[2].toString()).replace(s, function() {
|
|
3066
|
-
const h = r[0], c = e.getFullTileRange(h);
|
|
3067
|
-
return M(c, 55), (c.getHeight() - r[2] - 1).toString();
|
|
3068
|
-
});
|
|
3069
|
-
}
|
|
3070
|
-
);
|
|
3071
|
-
}
|
|
3072
|
-
function Gi(l, e) {
|
|
3073
|
-
const t = l.length, i = new Array(t);
|
|
3074
|
-
for (let n = 0; n < t; ++n)
|
|
3075
|
-
i[n] = ki(l[n], e);
|
|
3076
|
-
return vi(i);
|
|
3077
|
-
}
|
|
3078
|
-
function vi(l) {
|
|
3079
|
-
return l.length === 1 ? l[0] : (
|
|
3080
|
-
/**
|
|
3081
|
-
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
|
|
3082
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
3083
|
-
* @param {import("./proj/Projection.js").default} projection Projection.
|
|
3084
|
-
* @return {string|undefined} Tile URL.
|
|
3085
|
-
*/
|
|
3086
|
-
function(e, t, i) {
|
|
3087
|
-
if (!e)
|
|
3088
|
-
return;
|
|
3089
|
-
const n = pi(e), s = Lt(n, l.length);
|
|
3090
|
-
return l[s](e, t, i);
|
|
3091
|
-
}
|
|
3092
|
-
);
|
|
3093
|
-
}
|
|
3094
|
-
function Ri(l) {
|
|
3095
|
-
const e = [];
|
|
3096
|
-
let t = /\{([a-z])-([a-z])\}/.exec(l);
|
|
3097
|
-
if (t) {
|
|
3098
|
-
const i = t[1].charCodeAt(0), n = t[2].charCodeAt(0);
|
|
3099
|
-
let s;
|
|
3100
|
-
for (s = i; s <= n; ++s)
|
|
3101
|
-
e.push(l.replace(t[0], String.fromCharCode(s)));
|
|
3102
|
-
return e;
|
|
3103
|
-
}
|
|
3104
|
-
if (t = /\{(\d+)-(\d+)\}/.exec(l), t) {
|
|
3105
|
-
const i = parseInt(t[2], 10);
|
|
3106
|
-
for (let n = parseInt(t[1], 10); n <= i; n++)
|
|
3107
|
-
e.push(l.replace(t[0], n.toString()));
|
|
3108
|
-
return e;
|
|
3109
|
-
}
|
|
3110
|
-
return e.push(l), e;
|
|
3111
|
-
}
|
|
3112
|
-
class Ae extends Di {
|
|
3113
|
-
/**
|
|
3114
|
-
* @param {Options} options Image tile options.
|
|
3115
|
-
*/
|
|
3116
|
-
constructor(e) {
|
|
3117
|
-
super({
|
|
3118
|
-
attributions: e.attributions,
|
|
3119
|
-
cacheSize: e.cacheSize,
|
|
3120
|
-
opaque: e.opaque,
|
|
3121
|
-
projection: e.projection,
|
|
3122
|
-
state: e.state,
|
|
3123
|
-
tileGrid: e.tileGrid,
|
|
3124
|
-
tilePixelRatio: e.tilePixelRatio,
|
|
3125
|
-
wrapX: e.wrapX,
|
|
3126
|
-
transition: e.transition,
|
|
3127
|
-
interpolate: e.interpolate,
|
|
3128
|
-
key: e.key,
|
|
3129
|
-
attributionsCollapsible: e.attributionsCollapsible,
|
|
3130
|
-
zDirection: e.zDirection
|
|
3131
|
-
}), this.generateTileUrlFunction_ = this.tileUrlFunction === Ae.prototype.tileUrlFunction, this.tileLoadFunction = e.tileLoadFunction, e.tileUrlFunction && (this.tileUrlFunction = e.tileUrlFunction), this.urls = null, e.urls ? this.setUrls(e.urls) : e.url && this.setUrl(e.url), this.tileLoadingKeys_ = {};
|
|
3132
|
-
}
|
|
3133
|
-
/**
|
|
3134
|
-
* Return the tile load function of the source.
|
|
3135
|
-
* @return {import("../Tile.js").LoadFunction} TileLoadFunction
|
|
3136
|
-
* @api
|
|
3137
|
-
*/
|
|
3138
|
-
getTileLoadFunction() {
|
|
3139
|
-
return this.tileLoadFunction;
|
|
3140
|
-
}
|
|
3141
|
-
/**
|
|
3142
|
-
* Return the tile URL function of the source.
|
|
3143
|
-
* @return {import("../Tile.js").UrlFunction} TileUrlFunction
|
|
3144
|
-
* @api
|
|
3145
|
-
*/
|
|
3146
|
-
getTileUrlFunction() {
|
|
3147
|
-
return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction ? this.tileUrlFunction.bind(this) : this.tileUrlFunction;
|
|
3148
|
-
}
|
|
3149
|
-
/**
|
|
3150
|
-
* Return the URLs used for this source.
|
|
3151
|
-
* When a tileUrlFunction is used instead of url or urls,
|
|
3152
|
-
* null will be returned.
|
|
3153
|
-
* @return {!Array<string>|null} URLs.
|
|
3154
|
-
* @api
|
|
3155
|
-
*/
|
|
3156
|
-
getUrls() {
|
|
3157
|
-
return this.urls;
|
|
3158
|
-
}
|
|
3159
|
-
/**
|
|
3160
|
-
* Handle tile change events.
|
|
3161
|
-
* @param {import("../events/Event.js").default} event Event.
|
|
3162
|
-
* @protected
|
|
3163
|
-
*/
|
|
3164
|
-
handleTileChange(e) {
|
|
3165
|
-
const t = (
|
|
3166
|
-
/** @type {import("../Tile.js").default} */
|
|
3167
|
-
e.target
|
|
3168
|
-
), i = C(t), n = t.getState();
|
|
3169
|
-
let s;
|
|
3170
|
-
n == j.LOADING ? (this.tileLoadingKeys_[i] = !0, s = Ee.TILELOADSTART) : i in this.tileLoadingKeys_ && (delete this.tileLoadingKeys_[i], s = n == j.ERROR ? Ee.TILELOADERROR : n == j.LOADED ? Ee.TILELOADEND : void 0), s != null && this.dispatchEvent(new Mi(s, t));
|
|
3171
|
-
}
|
|
3172
|
-
/**
|
|
3173
|
-
* Set the tile load function of the source.
|
|
3174
|
-
* @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.
|
|
3175
|
-
* @api
|
|
3176
|
-
*/
|
|
3177
|
-
setTileLoadFunction(e) {
|
|
3178
|
-
this.tileCache.clear(), this.tileLoadFunction = e, this.changed();
|
|
3179
|
-
}
|
|
3180
|
-
/**
|
|
3181
|
-
* Set the tile URL function of the source.
|
|
3182
|
-
* @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
|
|
3183
|
-
* @param {string} [key] Optional new tile key for the source.
|
|
3184
|
-
* @api
|
|
3185
|
-
*/
|
|
3186
|
-
setTileUrlFunction(e, t) {
|
|
3187
|
-
this.tileUrlFunction = e, this.tileCache.pruneExceptNewestZ(), typeof t < "u" ? this.setKey(t) : this.changed();
|
|
3188
|
-
}
|
|
3189
|
-
/**
|
|
3190
|
-
* Set the URL to use for requests.
|
|
3191
|
-
* @param {string} url URL.
|
|
3192
|
-
* @api
|
|
3193
|
-
*/
|
|
3194
|
-
setUrl(e) {
|
|
3195
|
-
const t = Ri(e);
|
|
3196
|
-
this.urls = t, this.setUrls(t);
|
|
3197
|
-
}
|
|
3198
|
-
/**
|
|
3199
|
-
* Set the URLs to use for requests.
|
|
3200
|
-
* @param {Array<string>} urls URLs.
|
|
3201
|
-
* @api
|
|
3202
|
-
*/
|
|
3203
|
-
setUrls(e) {
|
|
3204
|
-
this.urls = e;
|
|
3205
|
-
const t = e.join(`
|
|
3206
|
-
`);
|
|
3207
|
-
this.generateTileUrlFunction_ ? this.setTileUrlFunction(Gi(e, this.tileGrid), t) : this.setKey(t);
|
|
3208
|
-
}
|
|
3209
|
-
/**
|
|
3210
|
-
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
3211
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
3212
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3213
|
-
* @return {string|undefined} Tile URL.
|
|
3214
|
-
*/
|
|
3215
|
-
tileUrlFunction(e, t, i) {
|
|
3216
|
-
}
|
|
3217
|
-
/**
|
|
3218
|
-
* Marks a tile coord as being used, without triggering a load.
|
|
3219
|
-
* @param {number} z Tile coordinate z.
|
|
3220
|
-
* @param {number} x Tile coordinate x.
|
|
3221
|
-
* @param {number} y Tile coordinate y.
|
|
3222
|
-
*/
|
|
3223
|
-
useTile(e, t, i) {
|
|
3224
|
-
const n = fe(e, t, i);
|
|
3225
|
-
this.tileCache.containsKey(n) && this.tileCache.get(n);
|
|
3226
|
-
}
|
|
3227
|
-
}
|
|
3228
|
-
class Ai extends Ae {
|
|
3229
|
-
/**
|
|
3230
|
-
* @param {!Options} options Image tile options.
|
|
3231
|
-
*/
|
|
3232
|
-
constructor(e) {
|
|
3233
|
-
super({
|
|
3234
|
-
attributions: e.attributions,
|
|
3235
|
-
cacheSize: e.cacheSize,
|
|
3236
|
-
opaque: e.opaque,
|
|
3237
|
-
projection: e.projection,
|
|
3238
|
-
state: e.state,
|
|
3239
|
-
tileGrid: e.tileGrid,
|
|
3240
|
-
tileLoadFunction: e.tileLoadFunction ? e.tileLoadFunction : bi,
|
|
3241
|
-
tilePixelRatio: e.tilePixelRatio,
|
|
3242
|
-
tileUrlFunction: e.tileUrlFunction,
|
|
3243
|
-
url: e.url,
|
|
3244
|
-
urls: e.urls,
|
|
3245
|
-
wrapX: e.wrapX,
|
|
3246
|
-
transition: e.transition,
|
|
3247
|
-
interpolate: e.interpolate !== void 0 ? e.interpolate : !0,
|
|
3248
|
-
key: e.key,
|
|
3249
|
-
attributionsCollapsible: e.attributionsCollapsible,
|
|
3250
|
-
zDirection: e.zDirection
|
|
3251
|
-
}), this.crossOrigin = e.crossOrigin !== void 0 ? e.crossOrigin : null, this.tileClass = e.tileClass !== void 0 ? e.tileClass : Ot, this.tileCacheForProjection = {}, this.tileGridForProjection = {}, this.reprojectionErrorThreshold_ = e.reprojectionErrorThreshold, this.renderReprojectionEdges_ = !1;
|
|
3252
|
-
}
|
|
3253
|
-
/**
|
|
3254
|
-
* @return {boolean} Can expire cache.
|
|
3255
|
-
*/
|
|
3256
|
-
canExpireCache() {
|
|
3257
|
-
if (this.tileCache.canExpireCache())
|
|
3258
|
-
return !0;
|
|
3259
|
-
for (const e in this.tileCacheForProjection)
|
|
3260
|
-
if (this.tileCacheForProjection[e].canExpireCache())
|
|
3261
|
-
return !0;
|
|
3262
|
-
return !1;
|
|
3263
|
-
}
|
|
3264
|
-
/**
|
|
3265
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3266
|
-
* @param {!Object<string, boolean>} usedTiles Used tiles.
|
|
3267
|
-
*/
|
|
3268
|
-
expireCache(e, t) {
|
|
3269
|
-
const i = this.getTileCacheForProjection(e);
|
|
3270
|
-
this.tileCache.expireCache(
|
|
3271
|
-
this.tileCache == i ? t : {}
|
|
3272
|
-
);
|
|
3273
|
-
for (const n in this.tileCacheForProjection) {
|
|
3274
|
-
const s = this.tileCacheForProjection[n];
|
|
3275
|
-
s.expireCache(s == i ? t : {});
|
|
3276
|
-
}
|
|
3277
|
-
}
|
|
3278
|
-
/**
|
|
3279
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3280
|
-
* @return {number} Gutter.
|
|
3281
|
-
*/
|
|
3282
|
-
getGutterForProjection(e) {
|
|
3283
|
-
return this.getProjection() && e && !N(this.getProjection(), e) ? 0 : this.getGutter();
|
|
3284
|
-
}
|
|
3285
|
-
/**
|
|
3286
|
-
* @return {number} Gutter.
|
|
3287
|
-
*/
|
|
3288
|
-
getGutter() {
|
|
3289
|
-
return 0;
|
|
3290
|
-
}
|
|
3291
|
-
/**
|
|
3292
|
-
* Return the key to be used for all tiles in the source.
|
|
3293
|
-
* @return {string} The key for all tiles.
|
|
3294
|
-
*/
|
|
3295
|
-
getKey() {
|
|
3296
|
-
let e = super.getKey();
|
|
3297
|
-
return this.getInterpolate() || (e += ":disable-interpolation"), e;
|
|
3298
|
-
}
|
|
3299
|
-
/**
|
|
3300
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3301
|
-
* @return {boolean} Opaque.
|
|
3302
|
-
*/
|
|
3303
|
-
getOpaque(e) {
|
|
3304
|
-
return this.getProjection() && e && !N(this.getProjection(), e) ? !1 : super.getOpaque(e);
|
|
3305
|
-
}
|
|
3306
|
-
/**
|
|
3307
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3308
|
-
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
|
|
3309
|
-
*/
|
|
3310
|
-
getTileGridForProjection(e) {
|
|
3311
|
-
const t = this.getProjection();
|
|
3312
|
-
if (this.tileGrid && (!t || N(t, e)))
|
|
3313
|
-
return this.tileGrid;
|
|
3314
|
-
const i = C(e);
|
|
3315
|
-
return i in this.tileGridForProjection || (this.tileGridForProjection[i] = ft(e)), this.tileGridForProjection[i];
|
|
3316
|
-
}
|
|
3317
|
-
/**
|
|
3318
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3319
|
-
* @return {import("../TileCache.js").default} Tile cache.
|
|
3320
|
-
*/
|
|
3321
|
-
getTileCacheForProjection(e) {
|
|
3322
|
-
const t = this.getProjection();
|
|
3323
|
-
if (!t || N(t, e))
|
|
3324
|
-
return this.tileCache;
|
|
3325
|
-
const i = C(e);
|
|
3326
|
-
return i in this.tileCacheForProjection || (this.tileCacheForProjection[i] = new dt(
|
|
3327
|
-
this.tileCache.highWaterMark
|
|
3328
|
-
)), this.tileCacheForProjection[i];
|
|
3329
|
-
}
|
|
3330
|
-
/**
|
|
3331
|
-
* @param {number} z Tile coordinate z.
|
|
3332
|
-
* @param {number} x Tile coordinate x.
|
|
3333
|
-
* @param {number} y Tile coordinate y.
|
|
3334
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
3335
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3336
|
-
* @param {string} key The key set on the tile.
|
|
3337
|
-
* @return {!ImageTile} Tile.
|
|
3338
|
-
* @private
|
|
3339
|
-
*/
|
|
3340
|
-
createTile_(e, t, i, n, s, r) {
|
|
3341
|
-
const o = [e, t, i], a = this.getTileCoordForTileUrlFunction(
|
|
3342
|
-
o,
|
|
3343
|
-
s
|
|
3344
|
-
), h = a ? this.tileUrlFunction(a, n, s) : void 0, c = new this.tileClass(
|
|
3345
|
-
o,
|
|
3346
|
-
h !== void 0 ? j.IDLE : j.EMPTY,
|
|
3347
|
-
h !== void 0 ? h : "",
|
|
3348
|
-
this.crossOrigin,
|
|
3349
|
-
this.tileLoadFunction,
|
|
3350
|
-
this.tileOptions
|
|
3351
|
-
);
|
|
3352
|
-
return c.key = r, c.addEventListener($.CHANGE, this.handleTileChange.bind(this)), c;
|
|
3353
|
-
}
|
|
3354
|
-
/**
|
|
3355
|
-
* @param {number} z Tile coordinate z.
|
|
3356
|
-
* @param {number} x Tile coordinate x.
|
|
3357
|
-
* @param {number} y Tile coordinate y.
|
|
3358
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
3359
|
-
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
3360
|
-
* @return {!(ImageTile|ReprojTile)} Tile.
|
|
3361
|
-
*/
|
|
3362
|
-
getTile(e, t, i, n, s) {
|
|
3363
|
-
const r = this.getProjection();
|
|
3364
|
-
if (!r || !s || N(r, s))
|
|
3365
|
-
return this.getTileInternal(
|
|
3366
|
-
e,
|
|
3367
|
-
t,
|
|
3368
|
-
i,
|
|
3369
|
-
n,
|
|
3370
|
-
r || s
|
|
3371
|
-
);
|
|
3372
|
-
const o = this.getTileCacheForProjection(s), a = [e, t, i];
|
|
3373
|
-
let h;
|
|
3374
|
-
const c = ut(a);
|
|
3375
|
-
o.containsKey(c) && (h = o.get(c));
|
|
3376
|
-
const u = this.getKey();
|
|
3377
|
-
if (h && h.key == u)
|
|
3378
|
-
return h;
|
|
3379
|
-
const g = this.getTileGridForProjection(r), d = this.getTileGridForProjection(s), f = this.getTileCoordForTileUrlFunction(
|
|
3380
|
-
a,
|
|
3381
|
-
s
|
|
3382
|
-
), _ = new Ut(
|
|
3383
|
-
r,
|
|
3384
|
-
g,
|
|
3385
|
-
s,
|
|
3386
|
-
d,
|
|
3387
|
-
a,
|
|
3388
|
-
f,
|
|
3389
|
-
this.getTilePixelRatio(n),
|
|
3390
|
-
this.getGutter(),
|
|
3391
|
-
(x, T, F, E) => this.getTileInternal(x, T, F, E, r),
|
|
3392
|
-
this.reprojectionErrorThreshold_,
|
|
3393
|
-
this.renderReprojectionEdges_,
|
|
3394
|
-
this.getInterpolate()
|
|
3395
|
-
);
|
|
3396
|
-
return _.key = u, h ? (_.interimTile = h, _.refreshInterimChain(), o.replace(c, _)) : o.set(c, _), _;
|
|
3397
|
-
}
|
|
3398
|
-
/**
|
|
3399
|
-
* @param {number} z Tile coordinate z.
|
|
3400
|
-
* @param {number} x Tile coordinate x.
|
|
3401
|
-
* @param {number} y Tile coordinate y.
|
|
3402
|
-
* @param {number} pixelRatio Pixel ratio.
|
|
3403
|
-
* @param {!import("../proj/Projection.js").default} projection Projection.
|
|
3404
|
-
* @return {!ImageTile} Tile.
|
|
3405
|
-
* @protected
|
|
3406
|
-
*/
|
|
3407
|
-
getTileInternal(e, t, i, n, s) {
|
|
3408
|
-
let r = null;
|
|
3409
|
-
const o = fe(e, t, i), a = this.getKey();
|
|
3410
|
-
if (!this.tileCache.containsKey(o))
|
|
3411
|
-
r = this.createTile_(e, t, i, n, s, a), this.tileCache.set(o, r);
|
|
3412
|
-
else if (r = this.tileCache.get(o), r.key != a) {
|
|
3413
|
-
const h = r;
|
|
3414
|
-
r = this.createTile_(e, t, i, n, s, a), h.getState() == j.IDLE ? r.interimTile = h.interimTile : r.interimTile = h, r.refreshInterimChain(), this.tileCache.replace(o, r);
|
|
3415
|
-
}
|
|
3416
|
-
return r;
|
|
3417
|
-
}
|
|
3418
|
-
/**
|
|
3419
|
-
* Sets whether to render reprojection edges or not (usually for debugging).
|
|
3420
|
-
* @param {boolean} render Render the edges.
|
|
3421
|
-
* @api
|
|
3422
|
-
*/
|
|
3423
|
-
setRenderReprojectionEdges(e) {
|
|
3424
|
-
if (this.renderReprojectionEdges_ != e) {
|
|
3425
|
-
this.renderReprojectionEdges_ = e;
|
|
3426
|
-
for (const t in this.tileCacheForProjection)
|
|
3427
|
-
this.tileCacheForProjection[t].clear();
|
|
3428
|
-
this.changed();
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
/**
|
|
3432
|
-
* Sets the tile grid to use when reprojecting the tiles to the given
|
|
3433
|
-
* projection instead of the default tile grid for the projection.
|
|
3434
|
-
*
|
|
3435
|
-
* This can be useful when the default tile grid cannot be created
|
|
3436
|
-
* (e.g. projection has no extent defined) or
|
|
3437
|
-
* for optimization reasons (custom tile size, resolutions, ...).
|
|
3438
|
-
*
|
|
3439
|
-
* @param {import("../proj.js").ProjectionLike} projection Projection.
|
|
3440
|
-
* @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
|
|
3441
|
-
* @api
|
|
3442
|
-
*/
|
|
3443
|
-
setTileGridForProjection(e, t) {
|
|
3444
|
-
const i = Ge(e);
|
|
3445
|
-
if (i) {
|
|
3446
|
-
const n = C(i);
|
|
3447
|
-
n in this.tileGridForProjection || (this.tileGridForProjection[n] = t);
|
|
3448
|
-
}
|
|
3449
|
-
}
|
|
3450
|
-
clear() {
|
|
3451
|
-
super.clear();
|
|
3452
|
-
for (const e in this.tileCacheForProjection)
|
|
3453
|
-
this.tileCacheForProjection[e].clear();
|
|
3454
|
-
}
|
|
3455
|
-
}
|
|
3456
|
-
function bi(l, e) {
|
|
3457
|
-
l.getImage().src = e;
|
|
3458
|
-
}
|
|
3459
|
-
class Ii extends Ai {
|
|
3460
|
-
/**
|
|
3461
|
-
* @param {Options} [options] XYZ options.
|
|
3462
|
-
*/
|
|
3463
|
-
constructor(e) {
|
|
3464
|
-
e = e || {};
|
|
3465
|
-
const t = e.projection !== void 0 ? e.projection : "EPSG:3857", i = e.tileGrid !== void 0 ? e.tileGrid : Pi({
|
|
3466
|
-
extent: Re(t),
|
|
3467
|
-
maxResolution: e.maxResolution,
|
|
3468
|
-
maxZoom: e.maxZoom,
|
|
3469
|
-
minZoom: e.minZoom,
|
|
3470
|
-
tileSize: e.tileSize
|
|
3471
|
-
});
|
|
3472
|
-
super({
|
|
3473
|
-
attributions: e.attributions,
|
|
3474
|
-
cacheSize: e.cacheSize,
|
|
3475
|
-
crossOrigin: e.crossOrigin,
|
|
3476
|
-
interpolate: e.interpolate,
|
|
3477
|
-
opaque: e.opaque,
|
|
3478
|
-
projection: t,
|
|
3479
|
-
reprojectionErrorThreshold: e.reprojectionErrorThreshold,
|
|
3480
|
-
tileGrid: i,
|
|
3481
|
-
tileLoadFunction: e.tileLoadFunction,
|
|
3482
|
-
tilePixelRatio: e.tilePixelRatio,
|
|
3483
|
-
tileUrlFunction: e.tileUrlFunction,
|
|
3484
|
-
url: e.url,
|
|
3485
|
-
urls: e.urls,
|
|
3486
|
-
wrapX: e.wrapX !== void 0 ? e.wrapX : !0,
|
|
3487
|
-
transition: e.transition,
|
|
3488
|
-
attributionsCollapsible: e.attributionsCollapsible,
|
|
3489
|
-
zDirection: e.zDirection
|
|
3490
|
-
}), this.gutter_ = e.gutter !== void 0 ? e.gutter : 0;
|
|
3491
|
-
}
|
|
3492
|
-
/**
|
|
3493
|
-
* @return {number} Gutter.
|
|
3494
|
-
*/
|
|
3495
|
-
getGutter() {
|
|
3496
|
-
return this.gutter_;
|
|
3497
|
-
}
|
|
3498
|
-
}
|
|
3499
|
-
const ji = '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';
|
|
3500
|
-
class Oi extends Ii {
|
|
3501
|
-
/**
|
|
3502
|
-
* @param {Options} [options] Open Street Map options.
|
|
3503
|
-
*/
|
|
3504
|
-
constructor(e) {
|
|
3505
|
-
e = e || {};
|
|
3506
|
-
let t;
|
|
3507
|
-
e.attributions !== void 0 ? t = e.attributions : t = [ji];
|
|
3508
|
-
const i = e.crossOrigin !== void 0 ? e.crossOrigin : "anonymous", n = e.url !== void 0 ? e.url : "https://tile.openstreetmap.org/{z}/{x}/{y}.png";
|
|
3509
|
-
super({
|
|
3510
|
-
attributions: t,
|
|
3511
|
-
attributionsCollapsible: !1,
|
|
3512
|
-
cacheSize: e.cacheSize,
|
|
3513
|
-
crossOrigin: i,
|
|
3514
|
-
interpolate: e.interpolate,
|
|
3515
|
-
maxZoom: e.maxZoom !== void 0 ? e.maxZoom : 19,
|
|
3516
|
-
opaque: e.opaque !== void 0 ? e.opaque : !0,
|
|
3517
|
-
reprojectionErrorThreshold: e.reprojectionErrorThreshold,
|
|
3518
|
-
tileLoadFunction: e.tileLoadFunction,
|
|
3519
|
-
transition: e.transition,
|
|
3520
|
-
url: n,
|
|
3521
|
-
wrapX: e.wrapX,
|
|
3522
|
-
zDirection: e.zDirection
|
|
3523
|
-
});
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3526
|
-
let Se = null;
|
|
3527
|
-
const L = new De(), w = {
|
|
3528
|
-
layer: new ge({
|
|
3529
|
-
source: L,
|
|
3530
|
-
style: Vt
|
|
1
|
+
import i from "react";
|
|
2
|
+
import { createMapboxLayer as _ } from "../../map/helpers/mapbox.js";
|
|
3
|
+
import B from "ol/interaction/Select";
|
|
4
|
+
import j from "ol/source/Vector";
|
|
5
|
+
import { createFeaturesFromKML as K, createFeaturesFromWKT as F } from "../../map/helpers/ol.js";
|
|
6
|
+
import { click as q } from "ol/events/condition";
|
|
7
|
+
import { defaultStyle as z, selectStyleFunction as H, markerStyle as J } from "./style.js";
|
|
8
|
+
import Q from "ol/layer/Vector";
|
|
9
|
+
import U from "ol/interaction/Modify";
|
|
10
|
+
import X from "ol/interaction/Draw";
|
|
11
|
+
import $ from "ol/interaction/Snap";
|
|
12
|
+
import { alert as p } from "../../confirm/index.js";
|
|
13
|
+
import ee from "ol/layer/Tile";
|
|
14
|
+
import te from "ol/source/OSM";
|
|
15
|
+
let T = null;
|
|
16
|
+
const c = new j(), o = {
|
|
17
|
+
layer: new Q({
|
|
18
|
+
source: c,
|
|
19
|
+
style: z
|
|
3531
20
|
}),
|
|
3532
|
-
modify: new
|
|
21
|
+
modify: new U({ source: c }),
|
|
3533
22
|
draw: null,
|
|
3534
23
|
snap: null,
|
|
3535
|
-
select: new
|
|
3536
|
-
condition:
|
|
3537
|
-
style:
|
|
24
|
+
select: new B({
|
|
25
|
+
condition: q,
|
|
26
|
+
style: H
|
|
3538
27
|
})
|
|
3539
28
|
};
|
|
3540
|
-
function
|
|
3541
|
-
const
|
|
29
|
+
function Te(n) {
|
|
30
|
+
const r = i.useRef(null), [u, D] = i.useState("Pointer"), [S, I] = i.useState(!1), [v, f] = i.useState({
|
|
3542
31
|
open: !1,
|
|
3543
32
|
buttons: [],
|
|
3544
33
|
position: void 0
|
|
3545
|
-
}),
|
|
3546
|
-
if (
|
|
3547
|
-
|
|
3548
|
-
const
|
|
3549
|
-
|
|
34
|
+
}), b = () => {
|
|
35
|
+
if (n.defaultExtent && M(n.defaultExtent), C(), W(), O(), w(), n.drawingWKTData && n.drawingWKTData !== "GEOMETRYCOLLECTION()") {
|
|
36
|
+
m(n.drawingWKTData);
|
|
37
|
+
const e = F(n.drawingWKTData);
|
|
38
|
+
e && x(e[0], [100, 100, 100, 100]);
|
|
3550
39
|
}
|
|
3551
40
|
};
|
|
3552
|
-
|
|
3553
|
-
}, []),
|
|
3554
|
-
if (
|
|
3555
|
-
if (
|
|
3556
|
-
|
|
41
|
+
i.useEffect(() => () => {
|
|
42
|
+
}, []), i.useEffect(() => {
|
|
43
|
+
if (u !== "Pointer") {
|
|
44
|
+
if (u === "KML") {
|
|
45
|
+
y();
|
|
3557
46
|
return;
|
|
3558
47
|
}
|
|
3559
|
-
return
|
|
48
|
+
return g(u), () => {
|
|
3560
49
|
};
|
|
3561
50
|
}
|
|
3562
|
-
}, [
|
|
3563
|
-
}), [
|
|
3564
|
-
}), [
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
},
|
|
3568
|
-
|
|
3569
|
-
},
|
|
3570
|
-
|
|
3571
|
-
},
|
|
3572
|
-
var
|
|
3573
|
-
|
|
3574
|
-
id:
|
|
51
|
+
}, [u]), i.useEffect(() => (n.drawingKMLData && L(n.drawingKMLData), () => {
|
|
52
|
+
}), [n.drawingKMLData]), i.useEffect(() => (n.drawingWKTData && (w(), n.drawingWKTData !== "GEOMETRYCOLLECTION()" && m(n.drawingWKTData)), () => {
|
|
53
|
+
}), [n.drawingWKTData]);
|
|
54
|
+
const C = () => {
|
|
55
|
+
k(), A();
|
|
56
|
+
}, W = () => {
|
|
57
|
+
R(), h();
|
|
58
|
+
}, O = () => {
|
|
59
|
+
P();
|
|
60
|
+
}, k = () => {
|
|
61
|
+
var e;
|
|
62
|
+
n.mapboxAccessToken ? T = _({
|
|
63
|
+
id: n.id,
|
|
3575
64
|
center: [0, 0],
|
|
3576
65
|
style: "mapbox://styles/mapbox/streets-v11",
|
|
3577
|
-
accessToken:
|
|
3578
|
-
}).layer :
|
|
3579
|
-
source: new
|
|
3580
|
-
}), (
|
|
3581
|
-
},
|
|
3582
|
-
var
|
|
3583
|
-
(
|
|
3584
|
-
},
|
|
3585
|
-
var
|
|
3586
|
-
(
|
|
3587
|
-
|
|
66
|
+
accessToken: n.mapboxAccessToken
|
|
67
|
+
}).layer : T = new ee({
|
|
68
|
+
source: new te()
|
|
69
|
+
}), (e = r.current) == null || e.addLayer(T);
|
|
70
|
+
}, A = () => {
|
|
71
|
+
var e;
|
|
72
|
+
(e = r.current) == null || e.addLayer(o.layer);
|
|
73
|
+
}, R = () => {
|
|
74
|
+
var e;
|
|
75
|
+
(e = r.current) == null || e.addInteraction(o.select), o.select.on("select", function() {
|
|
76
|
+
n.onSelect && n.onSelect(o.select.getFeatures().getArray());
|
|
3588
77
|
});
|
|
3589
|
-
},
|
|
3590
|
-
var
|
|
3591
|
-
(
|
|
78
|
+
}, h = () => {
|
|
79
|
+
var e;
|
|
80
|
+
(e = r.current) == null || e.addInteraction(o.modify), o.modify.on("modifyend", () => {
|
|
3592
81
|
setTimeout(() => {
|
|
3593
|
-
|
|
3594
|
-
}, 250),
|
|
82
|
+
n.onDrawEnd && n.onDrawEnd(c.getFeatures());
|
|
83
|
+
}, 250), l();
|
|
3595
84
|
});
|
|
3596
|
-
},
|
|
3597
|
-
var
|
|
3598
|
-
(
|
|
85
|
+
}, P = async () => {
|
|
86
|
+
var e;
|
|
87
|
+
(e = r.current) == null || e.on(
|
|
3599
88
|
"contextmenu",
|
|
3600
|
-
async (
|
|
3601
|
-
var
|
|
3602
|
-
|
|
3603
|
-
const
|
|
3604
|
-
if (
|
|
3605
|
-
const
|
|
3606
|
-
if (
|
|
3607
|
-
|
|
89
|
+
async (t) => {
|
|
90
|
+
var d;
|
|
91
|
+
t.preventDefault();
|
|
92
|
+
const a = (d = r.current) == null ? void 0 : d.getEventPixel(t.originalEvent);
|
|
93
|
+
if (a) {
|
|
94
|
+
const s = await o.layer.getFeatures(a);
|
|
95
|
+
if (s && s.length > 0) {
|
|
96
|
+
f({
|
|
3608
97
|
open: !0,
|
|
3609
98
|
buttons: [
|
|
3610
99
|
{
|
|
3611
100
|
label: "Delete",
|
|
3612
101
|
onClick: () => {
|
|
3613
|
-
|
|
3614
|
-
(
|
|
3615
|
-
),
|
|
3616
|
-
|
|
102
|
+
s.forEach(
|
|
103
|
+
(Z) => G(Z)
|
|
104
|
+
), E(), setTimeout(() => {
|
|
105
|
+
n.onDrawEnd && n.onDrawEnd(c.getFeatures());
|
|
3617
106
|
}, 250);
|
|
3618
107
|
}
|
|
3619
108
|
}
|
|
3620
109
|
],
|
|
3621
110
|
position: {
|
|
3622
|
-
top:
|
|
3623
|
-
left:
|
|
111
|
+
top: a[1],
|
|
112
|
+
left: a[0]
|
|
3624
113
|
}
|
|
3625
114
|
});
|
|
3626
115
|
return;
|
|
3627
116
|
}
|
|
3628
117
|
}
|
|
3629
|
-
|
|
118
|
+
E();
|
|
3630
119
|
}
|
|
3631
120
|
);
|
|
3632
|
-
},
|
|
3633
|
-
var
|
|
3634
|
-
|
|
3635
|
-
const
|
|
3636
|
-
source:
|
|
3637
|
-
type:
|
|
3638
|
-
}),
|
|
3639
|
-
|
|
121
|
+
}, g = (e) => {
|
|
122
|
+
var d, s;
|
|
123
|
+
l();
|
|
124
|
+
const t = new X({
|
|
125
|
+
source: c,
|
|
126
|
+
type: e
|
|
127
|
+
}), a = new $({ source: c });
|
|
128
|
+
t.on("drawend", () => {
|
|
3640
129
|
setTimeout(() => {
|
|
3641
|
-
|
|
3642
|
-
}, 250),
|
|
3643
|
-
}),
|
|
3644
|
-
},
|
|
3645
|
-
var
|
|
3646
|
-
|
|
3647
|
-
},
|
|
3648
|
-
const
|
|
3649
|
-
|
|
3650
|
-
},
|
|
3651
|
-
const
|
|
3652
|
-
|
|
3653
|
-
},
|
|
3654
|
-
|
|
3655
|
-
},
|
|
3656
|
-
|
|
3657
|
-
},
|
|
3658
|
-
|
|
130
|
+
n.onDrawEnd && n.onDrawEnd(c.getFeatures());
|
|
131
|
+
}, 250), l(), D("Pointer");
|
|
132
|
+
}), o.draw = t, o.snap = a, (d = r.current) == null || d.addInteraction(t), (s = r.current) == null || s.addInteraction(a);
|
|
133
|
+
}, l = () => {
|
|
134
|
+
var e, t;
|
|
135
|
+
o.draw && ((e = r.current) == null || e.removeInteraction(o.draw)), o.snap && ((t = r.current) == null || t.removeInteraction(o.snap));
|
|
136
|
+
}, L = (e) => {
|
|
137
|
+
const t = K(e);
|
|
138
|
+
t && c.addFeatures(t);
|
|
139
|
+
}, m = (e) => {
|
|
140
|
+
const t = F(e, J);
|
|
141
|
+
t && c.addFeatures(t);
|
|
142
|
+
}, w = () => {
|
|
143
|
+
c.clear();
|
|
144
|
+
}, G = (e) => {
|
|
145
|
+
c.removeFeature(e);
|
|
146
|
+
}, E = () => {
|
|
147
|
+
f({
|
|
3659
148
|
open: !1,
|
|
3660
149
|
buttons: []
|
|
3661
150
|
});
|
|
3662
|
-
},
|
|
3663
|
-
|
|
3664
|
-
},
|
|
3665
|
-
var
|
|
3666
|
-
const
|
|
3667
|
-
|
|
3668
|
-
},
|
|
3669
|
-
var
|
|
3670
|
-
(
|
|
3671
|
-
},
|
|
3672
|
-
var
|
|
3673
|
-
(
|
|
3674
|
-
},
|
|
3675
|
-
var
|
|
3676
|
-
(
|
|
3677
|
-
},
|
|
3678
|
-
var
|
|
3679
|
-
(
|
|
151
|
+
}, y = () => {
|
|
152
|
+
I((e) => !e);
|
|
153
|
+
}, N = (e) => {
|
|
154
|
+
var a;
|
|
155
|
+
const t = K(e);
|
|
156
|
+
t ? (y(), c.addFeatures(t), (a = r.current) == null || a.centerToFeature(t[0]), n.onDrawEnd && n.onDrawEnd(t)) : p("Error!", "Feature(s) could not be loaded! Check your KML data!");
|
|
157
|
+
}, V = (e) => {
|
|
158
|
+
var t;
|
|
159
|
+
(t = r.current) == null || t.setCenter(e);
|
|
160
|
+
}, Y = (e) => {
|
|
161
|
+
var t;
|
|
162
|
+
(t = r.current) == null || t.setZoomLevel(e);
|
|
163
|
+
}, x = (e, t = [0, 0, 0, 0]) => {
|
|
164
|
+
var a;
|
|
165
|
+
(a = r.current) == null || a.centerToFeature(e, t);
|
|
166
|
+
}, M = (e) => {
|
|
167
|
+
var t;
|
|
168
|
+
(t = r.current) == null || t.centerToExtent(e);
|
|
3680
169
|
};
|
|
3681
170
|
return {
|
|
3682
171
|
refs: {
|
|
3683
|
-
mapRef:
|
|
172
|
+
mapRef: r
|
|
3684
173
|
},
|
|
3685
174
|
state: {
|
|
3686
|
-
activeDrawingTool:
|
|
3687
|
-
openAddKMLText:
|
|
3688
|
-
contextMenu:
|
|
175
|
+
activeDrawingTool: u,
|
|
176
|
+
openAddKMLText: S,
|
|
177
|
+
contextMenu: v
|
|
3689
178
|
},
|
|
3690
179
|
action: {
|
|
3691
|
-
setActiveDrawingTool:
|
|
3692
|
-
addInteractions:
|
|
3693
|
-
addDrawingSourceKMLData:
|
|
3694
|
-
addDrawingSourceWKTData:
|
|
3695
|
-
clearDrawingSource:
|
|
3696
|
-
toggleAddKMLText:
|
|
3697
|
-
addKMLText:
|
|
3698
|
-
setContextMenu:
|
|
3699
|
-
setCenter:
|
|
3700
|
-
setZoomLevel:
|
|
3701
|
-
centerToFeature:
|
|
3702
|
-
centerToExtent:
|
|
3703
|
-
onMapInit:
|
|
180
|
+
setActiveDrawingTool: D,
|
|
181
|
+
addInteractions: g,
|
|
182
|
+
addDrawingSourceKMLData: L,
|
|
183
|
+
addDrawingSourceWKTData: m,
|
|
184
|
+
clearDrawingSource: w,
|
|
185
|
+
toggleAddKMLText: y,
|
|
186
|
+
addKMLText: N,
|
|
187
|
+
setContextMenu: f,
|
|
188
|
+
setCenter: V,
|
|
189
|
+
setZoomLevel: Y,
|
|
190
|
+
centerToFeature: x,
|
|
191
|
+
centerToExtent: M,
|
|
192
|
+
onMapInit: b
|
|
3704
193
|
}
|
|
3705
194
|
};
|
|
3706
195
|
}
|
|
3707
196
|
export {
|
|
3708
|
-
|
|
197
|
+
Te as default
|
|
3709
198
|
};
|