@vaadin/bundles 25.0.0-alpha3 → 25.0.0-alpha5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules_ol_ImageCanvas_js.js +76 -83
- package/node_modules_ol_ImageCanvas_js.js.map +1 -1
- package/node_modules_ol_TileRange_js.js +128 -110
- package/node_modules_ol_TileRange_js.js.map +1 -1
- package/node_modules_ol_Tile_js.js +279 -0
- package/node_modules_ol_Tile_js.js.map +1 -0
- package/node_modules_ol_VectorRenderTile_js.js +428 -143
- package/node_modules_ol_VectorRenderTile_js.js.map +1 -1
- package/node_modules_ol_VectorTile_js.js +405 -119
- package/node_modules_ol_VectorTile_js.js.map +1 -1
- package/node_modules_ol_control_MousePosition_js.js +327 -0
- package/node_modules_ol_control_MousePosition_js.js.map +1 -0
- package/node_modules_ol_control_ZoomToExtent_js.js +118 -0
- package/node_modules_ol_control_ZoomToExtent_js.js.map +1 -0
- package/node_modules_ol_events_SnapEvent_js.js +79 -0
- package/node_modules_ol_events_SnapEvent_js.js.map +1 -0
- package/node_modules_ol_featureloader_js.js +205 -0
- package/node_modules_ol_featureloader_js.js.map +1 -0
- package/node_modules_ol_geom_Circle_js.js +300 -0
- package/node_modules_ol_geom_Circle_js.js.map +1 -0
- package/node_modules_ol_geom_GeometryCollection_js.js +369 -0
- package/node_modules_ol_geom_GeometryCollection_js.js.map +1 -0
- package/node_modules_ol_geom_MultiPoint_js.js +228 -0
- package/node_modules_ol_geom_MultiPoint_js.js.map +1 -0
- package/node_modules_ol_geom_flat_center_js.js +47 -0
- package/node_modules_ol_geom_flat_center_js.js.map +1 -0
- package/node_modules_ol_geom_flat_geodesic_js.js +123 -88
- package/node_modules_ol_geom_flat_geodesic_js.js.map +1 -1
- package/node_modules_ol_geom_flat_interpolate_js.js +230 -0
- package/node_modules_ol_geom_flat_interpolate_js.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a0.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a0.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a1.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a1.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a2.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a2.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a3.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a3.js.map +1 -0
- package/node_modules_ol_geom_flat_length_js-_375a4.js +58 -0
- package/node_modules_ol_geom_flat_length_js-_375a4.js.map +1 -0
- package/node_modules_ol_geom_flat_linechunk_js.js +76 -0
- package/node_modules_ol_geom_flat_linechunk_js.js.map +1 -0
- package/node_modules_ol_geom_flat_straightchunk_js.js +68 -0
- package/node_modules_ol_geom_flat_straightchunk_js.js.map +1 -0
- package/node_modules_ol_geom_flat_textpath_js.js +178 -0
- package/node_modules_ol_geom_flat_textpath_js.js.map +1 -0
- package/node_modules_ol_interaction_DblClickDragZoom_js.js +285 -0
- package/node_modules_ol_interaction_DblClickDragZoom_js.js.map +1 -0
- package/node_modules_ol_interaction_DragAndDrop_js.js +351 -0
- package/node_modules_ol_interaction_DragAndDrop_js.js.map +1 -0
- package/node_modules_ol_interaction_DragRotateAndZoom_js.js +159 -0
- package/node_modules_ol_interaction_DragRotateAndZoom_js.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49290.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49290.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49291.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49291.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49292.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49292.js.map +1 -0
- package/node_modules_ol_layer_Vector_js-_49293.js +110 -0
- package/node_modules_ol_layer_Vector_js-_49293.js.map +1 -0
- package/node_modules_ol_loadingstrategy_js.js +95 -0
- package/node_modules_ol_loadingstrategy_js.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-_3ad60.js +144 -0
- package/node_modules_ol_render_VectorContext_js-_3ad60.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-_3ad61.js +144 -0
- package/node_modules_ol_render_VectorContext_js-_3ad61.js.map +1 -0
- package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js +372 -0
- package/node_modules_ol_render_VectorContext_js-node_modules_ol_render_canvas_hitdetect_js.js.map +1 -0
- package/node_modules_ol_render_canvas_ImageBuilder_js.js +318 -0
- package/node_modules_ol_render_canvas_ImageBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_Instruction_js.js +66 -0
- package/node_modules_ol_render_canvas_Instruction_js.js.map +1 -0
- package/node_modules_ol_render_canvas_LineStringBuilder_js.js +187 -0
- package/node_modules_ol_render_canvas_LineStringBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_PolygonBuilder_js.js +276 -0
- package/node_modules_ol_render_canvas_PolygonBuilder_js.js.map +1 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js +156 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab20.js.map +1 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js +156 -0
- package/node_modules_ol_render_canvas_ZIndexContext_js-_fab21.js.map +1 -0
- package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js +301 -0
- package/node_modules_ol_render_js-node_modules_ol_render_VectorContext_js.js.map +1 -0
- package/node_modules_ol_renderer_Layer_js.js +219 -0
- package/node_modules_ol_renderer_Layer_js.js.map +1 -0
- package/node_modules_ol_source_Source_js.js +256 -0
- package/node_modules_ol_source_Source_js.js.map +1 -0
- package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js +318 -0
- package/node_modules_ol_source_VectorEventType_js-node_modules_ol_structs_RBush_js.js.map +1 -0
- package/node_modules_ol_source_VectorEventType_js.js +80 -0
- package/node_modules_ol_source_VectorEventType_js.js.map +1 -0
- package/node_modules_ol_structs_RBush_js.js +242 -0
- package/node_modules_ol_structs_RBush_js.js.map +1 -0
- package/node_modules_ol_style_js.js +2 -1
- package/node_modules_ol_style_js.js.map +1 -1
- package/node_modules_rbush_rbush_min_js.js +16 -0
- package/node_modules_rbush_rbush_min_js.js.map +1 -0
- package/package.json +142 -146
- package/vaadin-bundle.json +2447 -2352
- package/vaadin.js +52246 -63791
- package/vaadin.js.map +1 -1
- package/vendors-node_modules_dompurify_dist_purify_es_mjs.js +1364 -0
- package/vendors-node_modules_dompurify_dist_purify_es_mjs.js.map +1 -0
- package/vendors-node_modules_dompurify_dist_purify_js.js +26 -21
- package/vendors-node_modules_dompurify_dist_purify_js.js.map +1 -1
- package/vendors-node_modules_marked_lib_marked_esm_js.js +2205 -0
- package/vendors-node_modules_marked_lib_marked_esm_js.js.map +1 -0
- package/vendors-node_modules_marked_lib_marked_umd_js.js +2164 -2556
- package/vendors-node_modules_marked_lib_marked_umd_js.js.map +1 -1
- package/vendors-node_modules_ol_Feature_js.js +360 -0
- package/vendors-node_modules_ol_Feature_js.js.map +1 -0
- package/vendors-node_modules_ol_Geolocation_js.js +352 -293
- package/vendors-node_modules_ol_Geolocation_js.js.map +1 -1
- package/vendors-node_modules_ol_ImageTile_js.js +494 -0
- package/vendors-node_modules_ol_ImageTile_js.js.map +1 -0
- package/vendors-node_modules_ol_Overlay_js.js +606 -0
- package/vendors-node_modules_ol_Overlay_js.js.map +1 -0
- package/vendors-node_modules_ol_control_FullScreen_js.js +417 -0
- package/vendors-node_modules_ol_control_FullScreen_js.js.map +1 -0
- package/vendors-node_modules_ol_control_OverviewMap_js.js +711 -0
- package/vendors-node_modules_ol_control_OverviewMap_js.js.map +1 -0
- package/vendors-node_modules_ol_control_ScaleLine_js.js +509 -0
- package/vendors-node_modules_ol_control_ScaleLine_js.js.map +1 -0
- package/vendors-node_modules_ol_control_ZoomSlider_js.js +418 -0
- package/vendors-node_modules_ol_control_ZoomSlider_js.js.map +1 -0
- package/vendors-node_modules_ol_control_js.js +490 -0
- package/vendors-node_modules_ol_control_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_LineString_js.js +574 -0
- package/vendors-node_modules_ol_geom_LineString_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_MultiLineString_js.js +405 -0
- package/vendors-node_modules_ol_geom_MultiLineString_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_MultiPolygon_js.js +773 -0
- package/vendors-node_modules_ol_geom_MultiPolygon_js.js.map +1 -0
- package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js +769 -0
- package/vendors-node_modules_ol_geom_js-node_modules_ol_geom_flat_length_js.js.map +1 -0
- package/vendors-node_modules_ol_index_js.js +526 -675
- package/vendors-node_modules_ol_index_js.js.map +1 -1
- package/vendors-node_modules_ol_interaction_Draw_js.js +2777 -0
- package/vendors-node_modules_ol_interaction_Draw_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Extent_js.js +586 -0
- package/vendors-node_modules_ol_interaction_Extent_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Link_js.js +489 -0
- package/vendors-node_modules_ol_interaction_Link_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Modify_js.js +1841 -0
- package/vendors-node_modules_ol_interaction_Modify_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Select_js.js +623 -0
- package/vendors-node_modules_ol_interaction_Select_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Snap_js.js +982 -0
- package/vendors-node_modules_ol_interaction_Snap_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_Translate_js.js +466 -0
- package/vendors-node_modules_ol_interaction_Translate_js.js.map +1 -0
- package/vendors-node_modules_ol_interaction_js.js +872 -0
- package/vendors-node_modules_ol_interaction_js.js.map +1 -0
- package/vendors-node_modules_ol_layer_Graticule_js.js +1374 -989
- package/vendors-node_modules_ol_layer_Graticule_js.js.map +1 -1
- package/vendors-node_modules_ol_render_Feature_js.js +546 -0
- package/vendors-node_modules_ol_render_Feature_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js +897 -0
- package/vendors-node_modules_ol_render_canvas_BuilderGroup_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Builder_js.js +907 -0
- package/vendors-node_modules_ol_render_canvas_Builder_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js +539 -0
- package/vendors-node_modules_ol_render_canvas_ExecutorGroup_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Executor_js.js +1715 -0
- package/vendors-node_modules_ol_render_canvas_Executor_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_Immediate_js.js +1208 -0
- package/vendors-node_modules_ol_render_canvas_Immediate_js.js.map +1 -0
- package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js +825 -0
- package/vendors-node_modules_ol_render_canvas_TextBuilder_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_canvas_Layer_js.js +654 -0
- package/vendors-node_modules_ol_renderer_canvas_Layer_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js +1044 -0
- package/vendors-node_modules_ol_renderer_canvas_VectorLayer_js.js.map +1 -0
- package/vendors-node_modules_ol_renderer_vector_js.js +460 -0
- package/vendors-node_modules_ol_renderer_vector_js.js.map +1 -0
- package/vendors-node_modules_ol_source_Vector_js.js +2091 -0
- package/vendors-node_modules_ol_source_Vector_js.js.map +1 -0
- package/node_modules_ol_ImageTile_js.js +0 -177
- package/node_modules_ol_ImageTile_js.js.map +0 -1
- package/node_modules_ol_render_js.js +0 -131
- package/node_modules_ol_render_js.js.map +0 -1
- package/node_modules_ol_structs_LRUCache_js.js +0 -275
- package/node_modules_ol_structs_LRUCache_js.js.map +0 -1
- package/node_modules_ol_tilecoord_js.js +0 -115
- package/node_modules_ol_tilecoord_js.js.map +0 -1
- package/vendors-node_modules_ol_TileCache_js.js +0 -461
- package/vendors-node_modules_ol_TileCache_js.js.map +0 -1
- package/vendors-node_modules_ol_Tile_js.js +0 -330
- package/vendors-node_modules_ol_Tile_js.js.map +0 -1
- package/vendors-node_modules_ol_style_Text_js.js +0 -509
- package/vendors-node_modules_ol_style_Text_js.js.map +0 -1
- package/vendors-node_modules_rbush_index_js.js +0 -531
- package/vendors-node_modules_rbush_index_js.js.map +0 -1
|
@@ -0,0 +1,2091 @@
|
|
|
1
|
+
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_ol_source_Vector_js"],{
|
|
2
|
+
|
|
3
|
+
/***/ "./node_modules/ol/featureloader.js":
|
|
4
|
+
/*!******************************************!*\
|
|
5
|
+
!*** ./node_modules/ol/featureloader.js ***!
|
|
6
|
+
\******************************************/
|
|
7
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
8
|
+
|
|
9
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
/* harmony export */ "loadFeaturesXhr": () => (/* binding */ loadFeaturesXhr),
|
|
12
|
+
/* harmony export */ "setWithCredentials": () => (/* binding */ setWithCredentials),
|
|
13
|
+
/* harmony export */ "xhr": () => (/* binding */ xhr)
|
|
14
|
+
/* harmony export */ });
|
|
15
|
+
/**
|
|
16
|
+
* @module ol/featureloader
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {boolean}
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
let withCredentials = false;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* {@link module:ol/source/Vector~VectorSource} sources use a function of this type to
|
|
28
|
+
* load features.
|
|
29
|
+
*
|
|
30
|
+
* This function takes up to 5 arguments. These are an {@link module:ol/extent~Extent} representing
|
|
31
|
+
* the area to be loaded, a `{number}` representing the resolution (map units per pixel), a
|
|
32
|
+
* {@link module:ol/proj/Projection~Projection} for the projection, an optional success callback that should get
|
|
33
|
+
* the loaded features passed as an argument and an optional failure callback with no arguments. If
|
|
34
|
+
* the callbacks are not used, the corresponding vector source will not fire `'featuresloadend'` and
|
|
35
|
+
* `'featuresloaderror'` events. `this` within the function is bound to the
|
|
36
|
+
* {@link module:ol/source/Vector~VectorSource} it's called from.
|
|
37
|
+
*
|
|
38
|
+
* The function is responsible for loading the features and adding them to the
|
|
39
|
+
* source.
|
|
40
|
+
*
|
|
41
|
+
* @template {import("./Feature.js").FeatureLike} [FeatureType=import("./Feature.js").FeatureLike]
|
|
42
|
+
* @typedef {(
|
|
43
|
+
* extent: import("./extent.js").Extent,
|
|
44
|
+
* resolution: number,
|
|
45
|
+
* projection: import("./proj/Projection.js").default,
|
|
46
|
+
* success?: (features: Array<FeatureType>) => void,
|
|
47
|
+
* failure?: () => void) => void} FeatureLoader
|
|
48
|
+
* @api
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* {@link module:ol/source/Vector~VectorSource} sources use a function of this type to
|
|
53
|
+
* get the url to load features from.
|
|
54
|
+
*
|
|
55
|
+
* This function takes an {@link module:ol/extent~Extent} representing the area
|
|
56
|
+
* to be loaded, a `{number}` representing the resolution (map units per pixel)
|
|
57
|
+
* and an {@link module:ol/proj/Projection~Projection} for the projection as
|
|
58
|
+
* arguments and returns a `{string}` representing the URL.
|
|
59
|
+
* @typedef {function(import("./extent.js").Extent, number, import("./proj/Projection.js").default): string} FeatureUrlFunction
|
|
60
|
+
* @api
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @template {import("./Feature.js").FeatureLike} [FeatureType=import("./Feature.js").default]
|
|
65
|
+
* @param {string|FeatureUrlFunction} url Feature URL service.
|
|
66
|
+
* @param {import("./format/Feature.js").default<FeatureType>} format Feature format.
|
|
67
|
+
* @param {import("./extent.js").Extent} extent Extent.
|
|
68
|
+
* @param {number} resolution Resolution.
|
|
69
|
+
* @param {import("./proj/Projection.js").default} projection Projection.
|
|
70
|
+
* @param {function(Array<FeatureType>, import("./proj/Projection.js").default): void} success Success
|
|
71
|
+
* Function called with the loaded features and optionally with the data projection.
|
|
72
|
+
* @param {function(): void} failure Failure
|
|
73
|
+
* Function called when loading failed.
|
|
74
|
+
*/
|
|
75
|
+
function loadFeaturesXhr(
|
|
76
|
+
url,
|
|
77
|
+
format,
|
|
78
|
+
extent,
|
|
79
|
+
resolution,
|
|
80
|
+
projection,
|
|
81
|
+
success,
|
|
82
|
+
failure,
|
|
83
|
+
) {
|
|
84
|
+
const xhr = new XMLHttpRequest();
|
|
85
|
+
xhr.open(
|
|
86
|
+
'GET',
|
|
87
|
+
typeof url === 'function' ? url(extent, resolution, projection) : url,
|
|
88
|
+
true,
|
|
89
|
+
);
|
|
90
|
+
if (format.getType() == 'arraybuffer') {
|
|
91
|
+
xhr.responseType = 'arraybuffer';
|
|
92
|
+
}
|
|
93
|
+
xhr.withCredentials = withCredentials;
|
|
94
|
+
/**
|
|
95
|
+
* @param {Event} event Event.
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
xhr.onload = function (event) {
|
|
99
|
+
// status will be 0 for file:// urls
|
|
100
|
+
if (!xhr.status || (xhr.status >= 200 && xhr.status < 300)) {
|
|
101
|
+
const type = format.getType();
|
|
102
|
+
try {
|
|
103
|
+
/** @type {Document|Node|Object|string|undefined} */
|
|
104
|
+
let source;
|
|
105
|
+
if (type == 'text' || type == 'json') {
|
|
106
|
+
source = xhr.responseText;
|
|
107
|
+
} else if (type == 'xml') {
|
|
108
|
+
source = xhr.responseXML || xhr.responseText;
|
|
109
|
+
} else if (type == 'arraybuffer') {
|
|
110
|
+
source = /** @type {ArrayBuffer} */ (xhr.response);
|
|
111
|
+
}
|
|
112
|
+
if (source) {
|
|
113
|
+
success(
|
|
114
|
+
/** @type {Array<FeatureType>} */
|
|
115
|
+
(
|
|
116
|
+
format.readFeatures(source, {
|
|
117
|
+
extent: extent,
|
|
118
|
+
featureProjection: projection,
|
|
119
|
+
})
|
|
120
|
+
),
|
|
121
|
+
format.readProjection(source),
|
|
122
|
+
);
|
|
123
|
+
} else {
|
|
124
|
+
failure();
|
|
125
|
+
}
|
|
126
|
+
} catch {
|
|
127
|
+
failure();
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
failure();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* @private
|
|
135
|
+
*/
|
|
136
|
+
xhr.onerror = failure;
|
|
137
|
+
xhr.send();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Create an XHR feature loader for a `url` and `format`. The feature loader
|
|
142
|
+
* loads features (with XHR), parses the features, and adds them to the
|
|
143
|
+
* vector source.
|
|
144
|
+
*
|
|
145
|
+
* @template {import("./Feature.js").FeatureLike} [FeatureType=import("./Feature.js").default]
|
|
146
|
+
* @param {string|FeatureUrlFunction} url Feature URL service.
|
|
147
|
+
* @param {import("./format/Feature.js").default<FeatureType>} format Feature format.
|
|
148
|
+
* @return {FeatureLoader<FeatureType>} The feature loader.
|
|
149
|
+
* @api
|
|
150
|
+
*/
|
|
151
|
+
function xhr(url, format) {
|
|
152
|
+
/**
|
|
153
|
+
* @param {import("./extent.js").Extent} extent Extent.
|
|
154
|
+
* @param {number} resolution Resolution.
|
|
155
|
+
* @param {import("./proj/Projection.js").default} projection Projection.
|
|
156
|
+
* @param {function(Array<FeatureType>): void} [success] Success
|
|
157
|
+
* Function called when loading succeeded.
|
|
158
|
+
* @param {function(): void} [failure] Failure
|
|
159
|
+
* Function called when loading failed.
|
|
160
|
+
* @this {import("./source/Vector.js").default<FeatureType>}
|
|
161
|
+
*/
|
|
162
|
+
return function (extent, resolution, projection, success, failure) {
|
|
163
|
+
loadFeaturesXhr(
|
|
164
|
+
url,
|
|
165
|
+
format,
|
|
166
|
+
extent,
|
|
167
|
+
resolution,
|
|
168
|
+
projection,
|
|
169
|
+
/**
|
|
170
|
+
* @param {Array<FeatureType>} features The loaded features.
|
|
171
|
+
* @param {import("./proj/Projection.js").default} dataProjection Data
|
|
172
|
+
* projection.
|
|
173
|
+
*/
|
|
174
|
+
(features, dataProjection) => {
|
|
175
|
+
this.addFeatures(features);
|
|
176
|
+
if (success !== undefined) {
|
|
177
|
+
success(features);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
() => {
|
|
181
|
+
this.changed();
|
|
182
|
+
if (failure !== undefined) {
|
|
183
|
+
failure();
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Setter for the withCredentials configuration for the XHR.
|
|
192
|
+
*
|
|
193
|
+
* @param {boolean} xhrWithCredentials The value of withCredentials to set.
|
|
194
|
+
* Compare https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/
|
|
195
|
+
* @api
|
|
196
|
+
*/
|
|
197
|
+
function setWithCredentials(xhrWithCredentials) {
|
|
198
|
+
withCredentials = xhrWithCredentials;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
/***/ }),
|
|
203
|
+
|
|
204
|
+
/***/ "./node_modules/ol/loadingstrategy.js":
|
|
205
|
+
/*!********************************************!*\
|
|
206
|
+
!*** ./node_modules/ol/loadingstrategy.js ***!
|
|
207
|
+
\********************************************/
|
|
208
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
209
|
+
|
|
210
|
+
__webpack_require__.r(__webpack_exports__);
|
|
211
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
212
|
+
/* harmony export */ "all": () => (/* binding */ all),
|
|
213
|
+
/* harmony export */ "bbox": () => (/* binding */ bbox),
|
|
214
|
+
/* harmony export */ "tile": () => (/* binding */ tile)
|
|
215
|
+
/* harmony export */ });
|
|
216
|
+
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./proj.js */ "./node_modules/ol/proj.js");
|
|
217
|
+
/**
|
|
218
|
+
* @module ol/loadingstrategy
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Strategy function for loading all features with a single request.
|
|
225
|
+
* @param {import("./extent.js").Extent} extent Extent.
|
|
226
|
+
* @param {number} resolution Resolution.
|
|
227
|
+
* @return {Array<import("./extent.js").Extent>} Extents.
|
|
228
|
+
* @api
|
|
229
|
+
*/
|
|
230
|
+
function all(extent, resolution) {
|
|
231
|
+
return [[-Infinity, -Infinity, Infinity, Infinity]];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Strategy function for loading features based on the view's extent and
|
|
236
|
+
* resolution.
|
|
237
|
+
* @param {import("./extent.js").Extent} extent Extent.
|
|
238
|
+
* @param {number} resolution Resolution.
|
|
239
|
+
* @return {Array<import("./extent.js").Extent>} Extents.
|
|
240
|
+
* @api
|
|
241
|
+
*/
|
|
242
|
+
function bbox(extent, resolution) {
|
|
243
|
+
return [extent];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Creates a strategy function for loading features based on a tile grid.
|
|
248
|
+
* @param {import("./tilegrid/TileGrid.js").default} tileGrid Tile grid.
|
|
249
|
+
* @return {function(import("./extent.js").Extent, number, import("./proj.js").Projection): Array<import("./extent.js").Extent>} Loading strategy.
|
|
250
|
+
* @api
|
|
251
|
+
*/
|
|
252
|
+
function tile(tileGrid) {
|
|
253
|
+
return (
|
|
254
|
+
/**
|
|
255
|
+
* @param {import("./extent.js").Extent} extent Extent.
|
|
256
|
+
* @param {number} resolution Resolution.
|
|
257
|
+
* @param {import("./proj.js").Projection} projection Projection.
|
|
258
|
+
* @return {Array<import("./extent.js").Extent>} Extents.
|
|
259
|
+
*/
|
|
260
|
+
function (extent, resolution, projection) {
|
|
261
|
+
const z = tileGrid.getZForResolution(
|
|
262
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserResolution)(resolution, projection),
|
|
263
|
+
);
|
|
264
|
+
const tileRange = tileGrid.getTileRangeForExtentAndZ(
|
|
265
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.fromUserExtent)(extent, projection),
|
|
266
|
+
z,
|
|
267
|
+
);
|
|
268
|
+
/** @type {Array<import("./extent.js").Extent>} */
|
|
269
|
+
const extents = [];
|
|
270
|
+
/** @type {import("./tilecoord.js").TileCoord} */
|
|
271
|
+
const tileCoord = [z, 0, 0];
|
|
272
|
+
for (
|
|
273
|
+
tileCoord[1] = tileRange.minX;
|
|
274
|
+
tileCoord[1] <= tileRange.maxX;
|
|
275
|
+
++tileCoord[1]
|
|
276
|
+
) {
|
|
277
|
+
for (
|
|
278
|
+
tileCoord[2] = tileRange.minY;
|
|
279
|
+
tileCoord[2] <= tileRange.maxY;
|
|
280
|
+
++tileCoord[2]
|
|
281
|
+
) {
|
|
282
|
+
extents.push(
|
|
283
|
+
(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.toUserExtent)(tileGrid.getTileCoordExtent(tileCoord), projection),
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return extents;
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
/***/ }),
|
|
294
|
+
|
|
295
|
+
/***/ "./node_modules/ol/source/Source.js":
|
|
296
|
+
/*!******************************************!*\
|
|
297
|
+
!*** ./node_modules/ol/source/Source.js ***!
|
|
298
|
+
\******************************************/
|
|
299
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
300
|
+
|
|
301
|
+
__webpack_require__.r(__webpack_exports__);
|
|
302
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
303
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
304
|
+
/* harmony export */ });
|
|
305
|
+
/* harmony import */ var _Object_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Object.js */ "./node_modules/ol/Object.js");
|
|
306
|
+
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../proj.js */ "./node_modules/ol/proj.js");
|
|
307
|
+
/**
|
|
308
|
+
* @module ol/source/Source
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* @typedef {'undefined' | 'loading' | 'ready' | 'error'} State
|
|
315
|
+
* State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* A function that takes a {@link import("../View.js").ViewStateLayerStateExtent} and returns a string or
|
|
320
|
+
* an array of strings representing source attributions.
|
|
321
|
+
*
|
|
322
|
+
* @typedef {function(import("../View.js").ViewStateLayerStateExtent): (string|Array<string>)} Attribution
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* A type that can be used to provide attribution information for data sources.
|
|
327
|
+
*
|
|
328
|
+
* It represents either
|
|
329
|
+
* a simple string (e.g. `'© Acme Inc.'`)
|
|
330
|
+
* an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`)
|
|
331
|
+
* a function that returns a string or array of strings ({@link module:ol/source/Source~Attribution})
|
|
332
|
+
*
|
|
333
|
+
* @typedef {string|Array<string>|Attribution} AttributionLike
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @typedef {Object} Options
|
|
338
|
+
* @property {AttributionLike} [attributions] Attributions.
|
|
339
|
+
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
|
|
340
|
+
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
|
341
|
+
* @property {import("./Source.js").State} [state='ready'] State.
|
|
342
|
+
* @property {boolean} [wrapX=false] WrapX.
|
|
343
|
+
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
|
|
344
|
+
* the nearest neighbor is used when resampling.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @classdesc
|
|
349
|
+
* Abstract base class; normally only used for creating subclasses and not
|
|
350
|
+
* instantiated in apps.
|
|
351
|
+
* Base class for {@link module:ol/layer/Layer~Layer} sources.
|
|
352
|
+
*
|
|
353
|
+
* A generic `change` event is triggered when the state of the source changes.
|
|
354
|
+
* @abstract
|
|
355
|
+
* @api
|
|
356
|
+
*/
|
|
357
|
+
class Source extends _Object_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
358
|
+
/**
|
|
359
|
+
* @param {Options} options Source options.
|
|
360
|
+
*/
|
|
361
|
+
constructor(options) {
|
|
362
|
+
super();
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* @protected
|
|
366
|
+
* @type {import("../proj/Projection.js").default|null}
|
|
367
|
+
*/
|
|
368
|
+
this.projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)(options.projection);
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* @private
|
|
372
|
+
* @type {?Attribution}
|
|
373
|
+
*/
|
|
374
|
+
this.attributions_ = adaptAttributions(options.attributions);
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* @private
|
|
378
|
+
* @type {boolean}
|
|
379
|
+
*/
|
|
380
|
+
this.attributionsCollapsible_ = options.attributionsCollapsible ?? true;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* This source is currently loading data. Sources that defer loading to the
|
|
384
|
+
* map's tile queue never set this to `true`.
|
|
385
|
+
* @type {boolean}
|
|
386
|
+
*/
|
|
387
|
+
this.loading = false;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* @private
|
|
391
|
+
* @type {import("./Source.js").State}
|
|
392
|
+
*/
|
|
393
|
+
this.state_ = options.state !== undefined ? options.state : 'ready';
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* @private
|
|
397
|
+
* @type {boolean}
|
|
398
|
+
*/
|
|
399
|
+
this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* @private
|
|
403
|
+
* @type {boolean}
|
|
404
|
+
*/
|
|
405
|
+
this.interpolate_ = !!options.interpolate;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @protected
|
|
409
|
+
* @type {function(import("../View.js").ViewOptions):void}
|
|
410
|
+
*/
|
|
411
|
+
this.viewResolver = null;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* @protected
|
|
415
|
+
* @type {function(Error):void}
|
|
416
|
+
*/
|
|
417
|
+
this.viewRejector = null;
|
|
418
|
+
|
|
419
|
+
const self = this;
|
|
420
|
+
/**
|
|
421
|
+
* @private
|
|
422
|
+
* @type {Promise<import("../View.js").ViewOptions>}
|
|
423
|
+
*/
|
|
424
|
+
this.viewPromise_ = new Promise(function (resolve, reject) {
|
|
425
|
+
self.viewResolver = resolve;
|
|
426
|
+
self.viewRejector = reject;
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Get the attribution function for the source.
|
|
432
|
+
* @return {?Attribution} Attribution function.
|
|
433
|
+
* @api
|
|
434
|
+
*/
|
|
435
|
+
getAttributions() {
|
|
436
|
+
return this.attributions_;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* @return {boolean} Attributions are collapsible.
|
|
441
|
+
* @api
|
|
442
|
+
*/
|
|
443
|
+
getAttributionsCollapsible() {
|
|
444
|
+
return this.attributionsCollapsible_;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Get the projection of the source.
|
|
449
|
+
* @return {import("../proj/Projection.js").default|null} Projection.
|
|
450
|
+
* @api
|
|
451
|
+
*/
|
|
452
|
+
getProjection() {
|
|
453
|
+
return this.projection;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @param {import("../proj/Projection").default} [projection] Projection.
|
|
458
|
+
* @return {Array<number>|null} Resolutions.
|
|
459
|
+
*/
|
|
460
|
+
getResolutions(projection) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties.
|
|
466
|
+
*/
|
|
467
|
+
getView() {
|
|
468
|
+
return this.viewPromise_;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Get the state of the source, see {@link import("./Source.js").State} for possible states.
|
|
473
|
+
* @return {import("./Source.js").State} State.
|
|
474
|
+
* @api
|
|
475
|
+
*/
|
|
476
|
+
getState() {
|
|
477
|
+
return this.state_;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* @return {boolean|undefined} Wrap X.
|
|
482
|
+
*/
|
|
483
|
+
getWrapX() {
|
|
484
|
+
return this.wrapX_;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* @return {boolean} Use linear interpolation when resampling.
|
|
489
|
+
*/
|
|
490
|
+
getInterpolate() {
|
|
491
|
+
return this.interpolate_;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Refreshes the source. The source will be cleared, and data from the server will be reloaded.
|
|
496
|
+
* @api
|
|
497
|
+
*/
|
|
498
|
+
refresh() {
|
|
499
|
+
this.changed();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Set the attributions of the source.
|
|
504
|
+
* @param {AttributionLike|undefined} attributions Attributions.
|
|
505
|
+
* Can be passed as `string`, `Array<string>`, {@link module:ol/source/Source~Attribution},
|
|
506
|
+
* or `undefined`.
|
|
507
|
+
* @api
|
|
508
|
+
*/
|
|
509
|
+
setAttributions(attributions) {
|
|
510
|
+
this.attributions_ = adaptAttributions(attributions);
|
|
511
|
+
this.changed();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Set the state of the source.
|
|
516
|
+
* @param {import("./Source.js").State} state State.
|
|
517
|
+
*/
|
|
518
|
+
setState(state) {
|
|
519
|
+
this.state_ = state;
|
|
520
|
+
this.changed();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Turns the attributions option into an attributions function.
|
|
526
|
+
* @param {AttributionLike|undefined} attributionLike The attribution option.
|
|
527
|
+
* @return {Attribution|null} An attribution function (or null).
|
|
528
|
+
*/
|
|
529
|
+
function adaptAttributions(attributionLike) {
|
|
530
|
+
if (!attributionLike) {
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
if (typeof attributionLike === 'function') {
|
|
534
|
+
return attributionLike;
|
|
535
|
+
}
|
|
536
|
+
if (!Array.isArray(attributionLike)) {
|
|
537
|
+
attributionLike = [attributionLike];
|
|
538
|
+
}
|
|
539
|
+
return (frameState) => attributionLike;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Source);
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
/***/ }),
|
|
546
|
+
|
|
547
|
+
/***/ "./node_modules/ol/source/Vector.js":
|
|
548
|
+
/*!******************************************!*\
|
|
549
|
+
!*** ./node_modules/ol/source/Vector.js ***!
|
|
550
|
+
\******************************************/
|
|
551
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
552
|
+
|
|
553
|
+
__webpack_require__.r(__webpack_exports__);
|
|
554
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
555
|
+
/* harmony export */ "VectorSourceEvent": () => (/* binding */ VectorSourceEvent),
|
|
556
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
557
|
+
/* harmony export */ });
|
|
558
|
+
/* harmony import */ var _Collection_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Collection.js */ "./node_modules/ol/Collection.js");
|
|
559
|
+
/* harmony import */ var _CollectionEventType_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../CollectionEventType.js */ "./node_modules/ol/CollectionEventType.js");
|
|
560
|
+
/* harmony import */ var _ObjectEventType_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../ObjectEventType.js */ "./node_modules/ol/ObjectEventType.js");
|
|
561
|
+
/* harmony import */ var _array_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../array.js */ "./node_modules/ol/array.js");
|
|
562
|
+
/* harmony import */ var _asserts_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../asserts.js */ "./node_modules/ol/asserts.js");
|
|
563
|
+
/* harmony import */ var _events_Event_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../events/Event.js */ "./node_modules/ol/events/Event.js");
|
|
564
|
+
/* harmony import */ var _events_EventType_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../events/EventType.js */ "./node_modules/ol/events/EventType.js");
|
|
565
|
+
/* harmony import */ var _events_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../events.js */ "./node_modules/ol/events.js");
|
|
566
|
+
/* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../extent.js */ "./node_modules/ol/extent.js");
|
|
567
|
+
/* harmony import */ var _featureloader_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../featureloader.js */ "./node_modules/ol/featureloader.js");
|
|
568
|
+
/* harmony import */ var _functions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../functions.js */ "./node_modules/ol/functions.js");
|
|
569
|
+
/* harmony import */ var _loadingstrategy_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../loadingstrategy.js */ "./node_modules/ol/loadingstrategy.js");
|
|
570
|
+
/* harmony import */ var _obj_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../obj.js */ "./node_modules/ol/obj.js");
|
|
571
|
+
/* harmony import */ var _render_Feature_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../render/Feature.js */ "./node_modules/ol/render/Feature.js");
|
|
572
|
+
/* harmony import */ var _structs_RBush_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../structs/RBush.js */ "./node_modules/ol/structs/RBush.js");
|
|
573
|
+
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../util.js */ "./node_modules/ol/util.js");
|
|
574
|
+
/* harmony import */ var _Source_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Source.js */ "./node_modules/ol/source/Source.js");
|
|
575
|
+
/* harmony import */ var _VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./VectorEventType.js */ "./node_modules/ol/source/VectorEventType.js");
|
|
576
|
+
/**
|
|
577
|
+
* @module ol/source/Vector
|
|
578
|
+
*/
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* A function that takes an {@link module:ol/extent~Extent} and a resolution as arguments, and
|
|
601
|
+
* returns an array of {@link module:ol/extent~Extent} with the extents to load. Usually this
|
|
602
|
+
* is one of the standard {@link module:ol/loadingstrategy} strategies.
|
|
603
|
+
*
|
|
604
|
+
* @typedef {function(import("../extent.js").Extent, number, import("../proj/Projection.js").default): Array<import("../extent.js").Extent>} LoadingStrategy
|
|
605
|
+
* @api
|
|
606
|
+
*/
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* @classdesc
|
|
610
|
+
* Events emitted by {@link module:ol/source/Vector~VectorSource} instances are instances of this
|
|
611
|
+
* type.
|
|
612
|
+
* @template {import("../Feature.js").FeatureLike} [FeatureType=import("../Feature.js").default]
|
|
613
|
+
*/
|
|
614
|
+
class VectorSourceEvent extends _events_Event_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
615
|
+
/**
|
|
616
|
+
* @param {string} type Type.
|
|
617
|
+
* @param {FeatureType} [feature] Feature.
|
|
618
|
+
* @param {Array<FeatureType>} [features] Features.
|
|
619
|
+
*/
|
|
620
|
+
constructor(type, feature, features) {
|
|
621
|
+
super(type);
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* The added or removed feature for the `ADDFEATURE` and `REMOVEFEATURE` events, `undefined` otherwise.
|
|
625
|
+
* @type {FeatureType|undefined}
|
|
626
|
+
* @api
|
|
627
|
+
*/
|
|
628
|
+
this.feature = feature;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* The loaded features for the `FEATURESLOADED` event, `undefined` otherwise.
|
|
632
|
+
* @type {Array<FeatureType>|undefined}
|
|
633
|
+
* @api
|
|
634
|
+
*/
|
|
635
|
+
this.features = features;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/***
|
|
640
|
+
* @template {import("../Feature.js").FeatureLike} [T=import("../Feature.js").default]
|
|
641
|
+
* @typedef {T extends RenderFeature ? T|Array<T> : T} FeatureClassOrArrayOfRenderFeatures
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
/***
|
|
645
|
+
* @template Return
|
|
646
|
+
* @template {import("../Feature.js").FeatureLike} [FeatureType=import("../Feature.js").default]
|
|
647
|
+
* @typedef {import("../Observable").OnSignature<import("../Observable").EventTypes, import("../events/Event.js").default, Return> &
|
|
648
|
+
* import("../Observable").OnSignature<import("../ObjectEventType").Types, import("../Object").ObjectEvent, Return> &
|
|
649
|
+
* import("../Observable").OnSignature<import("./VectorEventType").VectorSourceEventTypes, VectorSourceEvent<FeatureType>, Return> &
|
|
650
|
+
* import("../Observable").CombinedOnSignature<import("../Observable").EventTypes|import("../ObjectEventType").Types|
|
|
651
|
+
* import("./VectorEventType").VectorSourceEventTypes, Return>} VectorSourceOnSignature
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* @template {import("../Feature.js").FeatureLike} [FeatureType=import("../Feature.js").default]
|
|
656
|
+
* @typedef {Object} Options
|
|
657
|
+
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
|
|
658
|
+
* @property {Array<FeatureType>|Collection<FeatureType>} [features]
|
|
659
|
+
* Features. If provided as {@link module:ol/Collection~Collection}, the features in the source
|
|
660
|
+
* and the collection will stay in sync.
|
|
661
|
+
* @property {import("../format/Feature.js").default<FeatureType>} [format] The feature format used by the XHR
|
|
662
|
+
* feature loader when `url` is set. Required if `url` is set, otherwise ignored.
|
|
663
|
+
* @property {import("../featureloader.js").FeatureLoader<FeatureType>} [loader]
|
|
664
|
+
* The loader function used to load features, from a remote source for example.
|
|
665
|
+
* If this is not set and `url` is set, the source will create and use an XHR
|
|
666
|
+
* feature loader. The `'featuresloadend'` and `'featuresloaderror'` events
|
|
667
|
+
* will only fire if the `success` and `failure` callbacks are used.
|
|
668
|
+
*
|
|
669
|
+
* Example:
|
|
670
|
+
*
|
|
671
|
+
* ```js
|
|
672
|
+
* import Vector from 'ol/source/Vector.js';
|
|
673
|
+
* import GeoJSON from 'ol/format/GeoJSON.js';
|
|
674
|
+
* import {bbox} from 'ol/loadingstrategy.js';
|
|
675
|
+
*
|
|
676
|
+
* const vectorSource = new Vector({
|
|
677
|
+
* format: new GeoJSON(),
|
|
678
|
+
* loader: function(extent, resolution, projection, success, failure) {
|
|
679
|
+
* const proj = projection.getCode();
|
|
680
|
+
* const url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
|
|
681
|
+
* 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
|
|
682
|
+
* 'outputFormat=application/json&srsname=' + proj + '&' +
|
|
683
|
+
* 'bbox=' + extent.join(',') + ',' + proj;
|
|
684
|
+
* const xhr = new XMLHttpRequest();
|
|
685
|
+
* xhr.open('GET', url);
|
|
686
|
+
* const onError = function() {
|
|
687
|
+
* vectorSource.removeLoadedExtent(extent);
|
|
688
|
+
* failure();
|
|
689
|
+
* }
|
|
690
|
+
* xhr.onerror = onError;
|
|
691
|
+
* xhr.onload = function() {
|
|
692
|
+
* if (xhr.status == 200) {
|
|
693
|
+
* const features = vectorSource.getFormat().readFeatures(xhr.responseText);
|
|
694
|
+
* vectorSource.addFeatures(features);
|
|
695
|
+
* success(features);
|
|
696
|
+
* } else {
|
|
697
|
+
* onError();
|
|
698
|
+
* }
|
|
699
|
+
* }
|
|
700
|
+
* xhr.send();
|
|
701
|
+
* },
|
|
702
|
+
* strategy: bbox,
|
|
703
|
+
* });
|
|
704
|
+
* ```
|
|
705
|
+
* @property {boolean} [overlaps=true] This source may have overlapping geometries.
|
|
706
|
+
* Setting this to `false` (e.g. for sources with polygons that represent administrative
|
|
707
|
+
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
|
|
708
|
+
* stroke operations.
|
|
709
|
+
* @property {LoadingStrategy} [strategy] The loading strategy to use.
|
|
710
|
+
* By default an {@link module:ol/loadingstrategy.all}
|
|
711
|
+
* strategy is used, a one-off strategy which loads all features at once.
|
|
712
|
+
* @property {string|import("../featureloader.js").FeatureUrlFunction} [url]
|
|
713
|
+
* Setting this option instructs the source to load features using an XHR loader
|
|
714
|
+
* (see {@link module:ol/featureloader.xhr}). Use a `string` and an
|
|
715
|
+
* {@link module:ol/loadingstrategy.all} for a one-off download of all features from
|
|
716
|
+
* the given URL. Use a {@link module:ol/featureloader~FeatureUrlFunction} to generate the url with
|
|
717
|
+
* other loading strategies.
|
|
718
|
+
* Requires `format` to be set as well.
|
|
719
|
+
* When default XHR feature loader is provided, the features will
|
|
720
|
+
* be transformed from the data projection to the view projection
|
|
721
|
+
* during parsing. If your remote data source does not advertise its projection
|
|
722
|
+
* properly, this transformation will be incorrect. For some formats, the
|
|
723
|
+
* default projection (usually EPSG:4326) can be overridden by setting the
|
|
724
|
+
* dataProjection constructor option on the format.
|
|
725
|
+
* Note that if a source contains non-feature data, such as a GeoJSON geometry
|
|
726
|
+
* or a KML NetworkLink, these will be ignored. Use a custom loader to load these.
|
|
727
|
+
* @property {boolean} [useSpatialIndex=true]
|
|
728
|
+
* By default, an RTree is used as spatial index. When features are removed and
|
|
729
|
+
* added frequently, and the total number of features is low, setting this to
|
|
730
|
+
* `false` may improve performance.
|
|
731
|
+
*
|
|
732
|
+
* Note that
|
|
733
|
+
* {@link module:ol/source/Vector~VectorSource#getFeaturesInExtent},
|
|
734
|
+
* {@link module:ol/source/Vector~VectorSource#getClosestFeatureToCoordinate} and
|
|
735
|
+
* {@link module:ol/source/Vector~VectorSource#getExtent} cannot be used when `useSpatialIndex` is
|
|
736
|
+
* set to `false`, and {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent} will loop
|
|
737
|
+
* through all features.
|
|
738
|
+
*
|
|
739
|
+
* When set to `false`, the features will be maintained in an
|
|
740
|
+
* {@link module:ol/Collection~Collection}, which can be retrieved through
|
|
741
|
+
* {@link module:ol/source/Vector~VectorSource#getFeaturesCollection}.
|
|
742
|
+
* @property {boolean} [wrapX=true] Wrap the world horizontally. For vector editing across the
|
|
743
|
+
* -180° and 180° meridians to work properly, this should be set to `false`. The
|
|
744
|
+
* resulting geometry coordinates will then exceed the world bounds.
|
|
745
|
+
*/
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* @classdesc
|
|
749
|
+
* Provides a source of features for vector layers. Vector features provided
|
|
750
|
+
* by this source are suitable for editing. See {@link module:ol/source/VectorTile~VectorTile} for
|
|
751
|
+
* vector data that is optimized for rendering.
|
|
752
|
+
*
|
|
753
|
+
* @fires VectorSourceEvent
|
|
754
|
+
* @api
|
|
755
|
+
* @template {import("../Feature.js").FeatureLike} [FeatureType=import("../Feature.js").default]
|
|
756
|
+
*/
|
|
757
|
+
class VectorSource extends _Source_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
758
|
+
/**
|
|
759
|
+
* @param {Options<FeatureType>} [options] Vector source options.
|
|
760
|
+
*/
|
|
761
|
+
constructor(options) {
|
|
762
|
+
options = options || {};
|
|
763
|
+
|
|
764
|
+
super({
|
|
765
|
+
attributions: options.attributions,
|
|
766
|
+
interpolate: true,
|
|
767
|
+
projection: undefined,
|
|
768
|
+
state: 'ready',
|
|
769
|
+
wrapX: options.wrapX !== undefined ? options.wrapX : true,
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
/***
|
|
773
|
+
* @type {VectorSourceOnSignature<import("../events").EventsKey, FeatureType>}
|
|
774
|
+
*/
|
|
775
|
+
this.on;
|
|
776
|
+
|
|
777
|
+
/***
|
|
778
|
+
* @type {VectorSourceOnSignature<import("../events").EventsKey, FeatureType>}
|
|
779
|
+
*/
|
|
780
|
+
this.once;
|
|
781
|
+
|
|
782
|
+
/***
|
|
783
|
+
* @type {VectorSourceOnSignature<void>}
|
|
784
|
+
*/
|
|
785
|
+
this.un;
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* @private
|
|
789
|
+
* @type {import("../featureloader.js").FeatureLoader<import("../Feature.js").FeatureLike>}
|
|
790
|
+
*/
|
|
791
|
+
this.loader_ = _functions_js__WEBPACK_IMPORTED_MODULE_2__.VOID;
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* @private
|
|
795
|
+
* @type {import("../format/Feature.js").default<FeatureType>|null}
|
|
796
|
+
*/
|
|
797
|
+
this.format_ = options.format || null;
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* @private
|
|
801
|
+
* @type {boolean}
|
|
802
|
+
*/
|
|
803
|
+
this.overlaps_ = options.overlaps === undefined ? true : options.overlaps;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* @private
|
|
807
|
+
* @type {string|import("../featureloader.js").FeatureUrlFunction|undefined}
|
|
808
|
+
*/
|
|
809
|
+
this.url_ = options.url;
|
|
810
|
+
|
|
811
|
+
if (options.loader !== undefined) {
|
|
812
|
+
this.loader_ = options.loader;
|
|
813
|
+
} else if (this.url_ !== undefined) {
|
|
814
|
+
(0,_asserts_js__WEBPACK_IMPORTED_MODULE_3__.assert)(this.format_, '`format` must be set when `url` is set');
|
|
815
|
+
// create a XHR feature loader for "url" and "format"
|
|
816
|
+
this.loader_ = (0,_featureloader_js__WEBPACK_IMPORTED_MODULE_4__.xhr)(this.url_, this.format_);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* @private
|
|
821
|
+
* @type {LoadingStrategy}
|
|
822
|
+
*/
|
|
823
|
+
this.strategy_ =
|
|
824
|
+
options.strategy !== undefined ? options.strategy : _loadingstrategy_js__WEBPACK_IMPORTED_MODULE_5__.all;
|
|
825
|
+
|
|
826
|
+
const useSpatialIndex =
|
|
827
|
+
options.useSpatialIndex !== undefined ? options.useSpatialIndex : true;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* @private
|
|
831
|
+
* @type {RBush<FeatureType>}
|
|
832
|
+
*/
|
|
833
|
+
this.featuresRtree_ = useSpatialIndex ? new _structs_RBush_js__WEBPACK_IMPORTED_MODULE_6__["default"]() : null;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* @private
|
|
837
|
+
* @type {RBush<{extent: import("../extent.js").Extent}>}
|
|
838
|
+
*/
|
|
839
|
+
this.loadedExtentsRtree_ = new _structs_RBush_js__WEBPACK_IMPORTED_MODULE_6__["default"]();
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* @type {number}
|
|
843
|
+
* @private
|
|
844
|
+
*/
|
|
845
|
+
this.loadingExtentsCount_ = 0;
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* @private
|
|
849
|
+
* @type {!Object<string, FeatureType>}
|
|
850
|
+
*/
|
|
851
|
+
this.nullGeometryFeatures_ = {};
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* A lookup of features by id (the return from feature.getId()).
|
|
855
|
+
* @private
|
|
856
|
+
* @type {!Object<string, import('../Feature.js').FeatureLike|Array<import('../Feature.js').FeatureLike>>}
|
|
857
|
+
*/
|
|
858
|
+
this.idIndex_ = {};
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* A lookup of features by uid (using getUid(feature)).
|
|
862
|
+
* @private
|
|
863
|
+
* @type {!Object<string, FeatureType>}
|
|
864
|
+
*/
|
|
865
|
+
this.uidIndex_ = {};
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* @private
|
|
869
|
+
* @type {Object<string, Array<import("../events.js").EventsKey>>}
|
|
870
|
+
*/
|
|
871
|
+
this.featureChangeKeys_ = {};
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* @private
|
|
875
|
+
* @type {Collection<FeatureType>|null}
|
|
876
|
+
*/
|
|
877
|
+
this.featuresCollection_ = null;
|
|
878
|
+
|
|
879
|
+
/** @type {Collection<FeatureType>} */
|
|
880
|
+
let collection;
|
|
881
|
+
/** @type {Array<FeatureType>} */
|
|
882
|
+
let features;
|
|
883
|
+
if (Array.isArray(options.features)) {
|
|
884
|
+
features = options.features;
|
|
885
|
+
} else if (options.features) {
|
|
886
|
+
collection = options.features;
|
|
887
|
+
features = collection.getArray();
|
|
888
|
+
}
|
|
889
|
+
if (!useSpatialIndex && collection === undefined) {
|
|
890
|
+
collection = new _Collection_js__WEBPACK_IMPORTED_MODULE_7__["default"](features);
|
|
891
|
+
}
|
|
892
|
+
if (features !== undefined) {
|
|
893
|
+
this.addFeaturesInternal(features);
|
|
894
|
+
}
|
|
895
|
+
if (collection !== undefined) {
|
|
896
|
+
this.bindFeaturesCollection_(collection);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Add a single feature to the source. If you want to add a batch of features
|
|
902
|
+
* at once, call {@link module:ol/source/Vector~VectorSource#addFeatures #addFeatures()}
|
|
903
|
+
* instead. A feature will not be added to the source if feature with
|
|
904
|
+
* the same id is already there. The reason for this behavior is to avoid
|
|
905
|
+
* feature duplication when using bbox or tile loading strategies.
|
|
906
|
+
* Note: this also applies if a {@link module:ol/Collection~Collection} is used for features,
|
|
907
|
+
* meaning that if a feature with a duplicate id is added in the collection, it will
|
|
908
|
+
* be removed from it right away.
|
|
909
|
+
* @param {FeatureType} feature Feature to add.
|
|
910
|
+
* @api
|
|
911
|
+
*/
|
|
912
|
+
addFeature(feature) {
|
|
913
|
+
this.addFeatureInternal(feature);
|
|
914
|
+
this.changed();
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Add a feature without firing a `change` event.
|
|
919
|
+
* @param {FeatureType} feature Feature.
|
|
920
|
+
* @protected
|
|
921
|
+
*/
|
|
922
|
+
addFeatureInternal(feature) {
|
|
923
|
+
const featureKey = (0,_util_js__WEBPACK_IMPORTED_MODULE_8__.getUid)(feature);
|
|
924
|
+
|
|
925
|
+
if (!this.addToIndex_(featureKey, feature)) {
|
|
926
|
+
if (this.featuresCollection_) {
|
|
927
|
+
this.featuresCollection_.remove(feature);
|
|
928
|
+
}
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
this.setupChangeEvents_(featureKey, feature);
|
|
933
|
+
|
|
934
|
+
const geometry = feature.getGeometry();
|
|
935
|
+
if (geometry) {
|
|
936
|
+
const extent = geometry.getExtent();
|
|
937
|
+
if (this.featuresRtree_) {
|
|
938
|
+
this.featuresRtree_.insert(extent, feature);
|
|
939
|
+
}
|
|
940
|
+
} else {
|
|
941
|
+
this.nullGeometryFeatures_[featureKey] = feature;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
this.dispatchEvent(
|
|
945
|
+
new VectorSourceEvent(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].ADDFEATURE, feature),
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* @param {string} featureKey Unique identifier for the feature.
|
|
951
|
+
* @param {FeatureType} feature The feature.
|
|
952
|
+
* @private
|
|
953
|
+
*/
|
|
954
|
+
setupChangeEvents_(featureKey, feature) {
|
|
955
|
+
if (feature instanceof _render_Feature_js__WEBPACK_IMPORTED_MODULE_10__["default"]) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
this.featureChangeKeys_[featureKey] = [
|
|
959
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_11__.listen)(feature, _events_EventType_js__WEBPACK_IMPORTED_MODULE_12__["default"].CHANGE, this.handleFeatureChange_, this),
|
|
960
|
+
(0,_events_js__WEBPACK_IMPORTED_MODULE_11__.listen)(
|
|
961
|
+
feature,
|
|
962
|
+
_ObjectEventType_js__WEBPACK_IMPORTED_MODULE_13__["default"].PROPERTYCHANGE,
|
|
963
|
+
this.handleFeatureChange_,
|
|
964
|
+
this,
|
|
965
|
+
),
|
|
966
|
+
];
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* @param {string} featureKey Unique identifier for the feature.
|
|
971
|
+
* @param {FeatureType} feature The feature.
|
|
972
|
+
* @return {boolean} The feature is "valid", in the sense that it is also a
|
|
973
|
+
* candidate for insertion into the Rtree.
|
|
974
|
+
* @private
|
|
975
|
+
*/
|
|
976
|
+
addToIndex_(featureKey, feature) {
|
|
977
|
+
let valid = true;
|
|
978
|
+
if (feature.getId() !== undefined) {
|
|
979
|
+
const id = String(feature.getId());
|
|
980
|
+
if (!(id in this.idIndex_)) {
|
|
981
|
+
this.idIndex_[id] = feature;
|
|
982
|
+
} else if (feature instanceof _render_Feature_js__WEBPACK_IMPORTED_MODULE_10__["default"]) {
|
|
983
|
+
const indexedFeature = this.idIndex_[id];
|
|
984
|
+
if (!(indexedFeature instanceof _render_Feature_js__WEBPACK_IMPORTED_MODULE_10__["default"])) {
|
|
985
|
+
valid = false;
|
|
986
|
+
} else if (!Array.isArray(indexedFeature)) {
|
|
987
|
+
this.idIndex_[id] = [indexedFeature, feature];
|
|
988
|
+
} else {
|
|
989
|
+
indexedFeature.push(feature);
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
valid = false;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if (valid) {
|
|
996
|
+
(0,_asserts_js__WEBPACK_IMPORTED_MODULE_3__.assert)(
|
|
997
|
+
!(featureKey in this.uidIndex_),
|
|
998
|
+
'The passed `feature` was already added to the source',
|
|
999
|
+
);
|
|
1000
|
+
this.uidIndex_[featureKey] = feature;
|
|
1001
|
+
}
|
|
1002
|
+
return valid;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* Add a batch of features to the source.
|
|
1007
|
+
* @param {Array<FeatureType>} features Features to add.
|
|
1008
|
+
* @api
|
|
1009
|
+
*/
|
|
1010
|
+
addFeatures(features) {
|
|
1011
|
+
this.addFeaturesInternal(features);
|
|
1012
|
+
this.changed();
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Add features without firing a `change` event.
|
|
1017
|
+
* @param {Array<FeatureType>} features Features.
|
|
1018
|
+
* @protected
|
|
1019
|
+
*/
|
|
1020
|
+
addFeaturesInternal(features) {
|
|
1021
|
+
const extents = [];
|
|
1022
|
+
/** @type {Array<FeatureType>} */
|
|
1023
|
+
const newFeatures = [];
|
|
1024
|
+
/** @type {Array<FeatureType>} */
|
|
1025
|
+
const geometryFeatures = [];
|
|
1026
|
+
|
|
1027
|
+
for (let i = 0, length = features.length; i < length; i++) {
|
|
1028
|
+
const feature = features[i];
|
|
1029
|
+
const featureKey = (0,_util_js__WEBPACK_IMPORTED_MODULE_8__.getUid)(feature);
|
|
1030
|
+
if (this.addToIndex_(featureKey, feature)) {
|
|
1031
|
+
newFeatures.push(feature);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
for (let i = 0, length = newFeatures.length; i < length; i++) {
|
|
1036
|
+
const feature = newFeatures[i];
|
|
1037
|
+
const featureKey = (0,_util_js__WEBPACK_IMPORTED_MODULE_8__.getUid)(feature);
|
|
1038
|
+
this.setupChangeEvents_(featureKey, feature);
|
|
1039
|
+
|
|
1040
|
+
const geometry = feature.getGeometry();
|
|
1041
|
+
if (geometry) {
|
|
1042
|
+
const extent = geometry.getExtent();
|
|
1043
|
+
extents.push(extent);
|
|
1044
|
+
geometryFeatures.push(feature);
|
|
1045
|
+
} else {
|
|
1046
|
+
this.nullGeometryFeatures_[featureKey] = feature;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
if (this.featuresRtree_) {
|
|
1050
|
+
this.featuresRtree_.load(extents, geometryFeatures);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
if (this.hasListener(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].ADDFEATURE)) {
|
|
1054
|
+
for (let i = 0, length = newFeatures.length; i < length; i++) {
|
|
1055
|
+
this.dispatchEvent(
|
|
1056
|
+
new VectorSourceEvent(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].ADDFEATURE, newFeatures[i]),
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* @param {!Collection<FeatureType>} collection Collection.
|
|
1064
|
+
* @private
|
|
1065
|
+
*/
|
|
1066
|
+
bindFeaturesCollection_(collection) {
|
|
1067
|
+
let modifyingCollection = false;
|
|
1068
|
+
this.addEventListener(
|
|
1069
|
+
_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].ADDFEATURE,
|
|
1070
|
+
/**
|
|
1071
|
+
* @param {VectorSourceEvent<FeatureType>} evt The vector source event
|
|
1072
|
+
*/
|
|
1073
|
+
function (evt) {
|
|
1074
|
+
if (!modifyingCollection) {
|
|
1075
|
+
modifyingCollection = true;
|
|
1076
|
+
collection.push(evt.feature);
|
|
1077
|
+
modifyingCollection = false;
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
);
|
|
1081
|
+
this.addEventListener(
|
|
1082
|
+
_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].REMOVEFEATURE,
|
|
1083
|
+
/**
|
|
1084
|
+
* @param {VectorSourceEvent<FeatureType>} evt The vector source event
|
|
1085
|
+
*/
|
|
1086
|
+
function (evt) {
|
|
1087
|
+
if (!modifyingCollection) {
|
|
1088
|
+
modifyingCollection = true;
|
|
1089
|
+
collection.remove(evt.feature);
|
|
1090
|
+
modifyingCollection = false;
|
|
1091
|
+
}
|
|
1092
|
+
},
|
|
1093
|
+
);
|
|
1094
|
+
collection.addEventListener(
|
|
1095
|
+
_CollectionEventType_js__WEBPACK_IMPORTED_MODULE_14__["default"].ADD,
|
|
1096
|
+
/**
|
|
1097
|
+
* @param {import("../Collection.js").CollectionEvent<FeatureType>} evt The collection event
|
|
1098
|
+
*/
|
|
1099
|
+
(evt) => {
|
|
1100
|
+
if (!modifyingCollection) {
|
|
1101
|
+
modifyingCollection = true;
|
|
1102
|
+
this.addFeature(evt.element);
|
|
1103
|
+
modifyingCollection = false;
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
);
|
|
1107
|
+
collection.addEventListener(
|
|
1108
|
+
_CollectionEventType_js__WEBPACK_IMPORTED_MODULE_14__["default"].REMOVE,
|
|
1109
|
+
/**
|
|
1110
|
+
* @param {import("../Collection.js").CollectionEvent<FeatureType>} evt The collection event
|
|
1111
|
+
*/
|
|
1112
|
+
(evt) => {
|
|
1113
|
+
if (!modifyingCollection) {
|
|
1114
|
+
modifyingCollection = true;
|
|
1115
|
+
this.removeFeature(evt.element);
|
|
1116
|
+
modifyingCollection = false;
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
);
|
|
1120
|
+
this.featuresCollection_ = collection;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Remove all features from the source.
|
|
1125
|
+
* @param {boolean} [fast] Skip dispatching of {@link module:ol/source/Vector.VectorSourceEvent#event:removefeature} events.
|
|
1126
|
+
* @api
|
|
1127
|
+
*/
|
|
1128
|
+
clear(fast) {
|
|
1129
|
+
if (fast) {
|
|
1130
|
+
for (const featureId in this.featureChangeKeys_) {
|
|
1131
|
+
const keys = this.featureChangeKeys_[featureId];
|
|
1132
|
+
keys.forEach(_events_js__WEBPACK_IMPORTED_MODULE_11__.unlistenByKey);
|
|
1133
|
+
}
|
|
1134
|
+
if (!this.featuresCollection_) {
|
|
1135
|
+
this.featureChangeKeys_ = {};
|
|
1136
|
+
this.idIndex_ = {};
|
|
1137
|
+
this.uidIndex_ = {};
|
|
1138
|
+
}
|
|
1139
|
+
} else {
|
|
1140
|
+
if (this.featuresRtree_) {
|
|
1141
|
+
this.featuresRtree_.forEach((feature) => {
|
|
1142
|
+
this.removeFeatureInternal(feature);
|
|
1143
|
+
});
|
|
1144
|
+
for (const id in this.nullGeometryFeatures_) {
|
|
1145
|
+
this.removeFeatureInternal(this.nullGeometryFeatures_[id]);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
if (this.featuresCollection_) {
|
|
1150
|
+
this.featuresCollection_.clear();
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
if (this.featuresRtree_) {
|
|
1154
|
+
this.featuresRtree_.clear();
|
|
1155
|
+
}
|
|
1156
|
+
this.nullGeometryFeatures_ = {};
|
|
1157
|
+
|
|
1158
|
+
const clearEvent = new VectorSourceEvent(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].CLEAR);
|
|
1159
|
+
this.dispatchEvent(clearEvent);
|
|
1160
|
+
this.changed();
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Iterate through all features on the source, calling the provided callback
|
|
1165
|
+
* with each one. If the callback returns any "truthy" value, iteration will
|
|
1166
|
+
* stop and the function will return the same value.
|
|
1167
|
+
* Note: this function only iterate through the feature that have a defined geometry.
|
|
1168
|
+
*
|
|
1169
|
+
* @param {function(FeatureType): T} callback Called with each feature
|
|
1170
|
+
* on the source. Return a truthy value to stop iteration.
|
|
1171
|
+
* @return {T|undefined} The return value from the last call to the callback.
|
|
1172
|
+
* @template T
|
|
1173
|
+
* @api
|
|
1174
|
+
*/
|
|
1175
|
+
forEachFeature(callback) {
|
|
1176
|
+
if (this.featuresRtree_) {
|
|
1177
|
+
return this.featuresRtree_.forEach(callback);
|
|
1178
|
+
}
|
|
1179
|
+
if (this.featuresCollection_) {
|
|
1180
|
+
this.featuresCollection_.forEach(callback);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Iterate through all features whose geometries contain the provided
|
|
1186
|
+
* coordinate, calling the callback with each feature. If the callback returns
|
|
1187
|
+
* a "truthy" value, iteration will stop and the function will return the same
|
|
1188
|
+
* value.
|
|
1189
|
+
*
|
|
1190
|
+
* For {@link module:ol/render/Feature~RenderFeature} features, the callback will be
|
|
1191
|
+
* called for all features.
|
|
1192
|
+
*
|
|
1193
|
+
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
|
|
1194
|
+
* @param {function(FeatureType): T} callback Called with each feature
|
|
1195
|
+
* whose goemetry contains the provided coordinate.
|
|
1196
|
+
* @return {T|undefined} The return value from the last call to the callback.
|
|
1197
|
+
* @template T
|
|
1198
|
+
*/
|
|
1199
|
+
forEachFeatureAtCoordinateDirect(coordinate, callback) {
|
|
1200
|
+
const extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
|
|
1201
|
+
return this.forEachFeatureInExtent(extent, function (feature) {
|
|
1202
|
+
const geometry = feature.getGeometry();
|
|
1203
|
+
if (
|
|
1204
|
+
geometry instanceof _render_Feature_js__WEBPACK_IMPORTED_MODULE_10__["default"] ||
|
|
1205
|
+
geometry.intersectsCoordinate(coordinate)
|
|
1206
|
+
) {
|
|
1207
|
+
return callback(feature);
|
|
1208
|
+
}
|
|
1209
|
+
return undefined;
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Iterate through all features whose bounding box intersects the provided
|
|
1215
|
+
* extent (note that the feature's geometry may not intersect the extent),
|
|
1216
|
+
* calling the callback with each feature. If the callback returns a "truthy"
|
|
1217
|
+
* value, iteration will stop and the function will return the same value.
|
|
1218
|
+
*
|
|
1219
|
+
* If you are interested in features whose geometry intersects an extent, call
|
|
1220
|
+
* the {@link module:ol/source/Vector~VectorSource#forEachFeatureIntersectingExtent #forEachFeatureIntersectingExtent()} method instead.
|
|
1221
|
+
*
|
|
1222
|
+
* When `useSpatialIndex` is set to false, this method will loop through all
|
|
1223
|
+
* features, equivalent to {@link module:ol/source/Vector~VectorSource#forEachFeature #forEachFeature()}.
|
|
1224
|
+
*
|
|
1225
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1226
|
+
* @param {function(FeatureType): T} callback Called with each feature
|
|
1227
|
+
* whose bounding box intersects the provided extent.
|
|
1228
|
+
* @return {T|undefined} The return value from the last call to the callback.
|
|
1229
|
+
* @template T
|
|
1230
|
+
* @api
|
|
1231
|
+
*/
|
|
1232
|
+
forEachFeatureInExtent(extent, callback) {
|
|
1233
|
+
if (this.featuresRtree_) {
|
|
1234
|
+
return this.featuresRtree_.forEachInExtent(extent, callback);
|
|
1235
|
+
}
|
|
1236
|
+
if (this.featuresCollection_) {
|
|
1237
|
+
this.featuresCollection_.forEach(callback);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* Iterate through all features whose geometry intersects the provided extent,
|
|
1243
|
+
* calling the callback with each feature. If the callback returns a "truthy"
|
|
1244
|
+
* value, iteration will stop and the function will return the same value.
|
|
1245
|
+
*
|
|
1246
|
+
* If you only want to test for bounding box intersection, call the
|
|
1247
|
+
* {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent #forEachFeatureInExtent()} method instead.
|
|
1248
|
+
*
|
|
1249
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1250
|
+
* @param {function(FeatureType): T} callback Called with each feature
|
|
1251
|
+
* whose geometry intersects the provided extent.
|
|
1252
|
+
* @return {T|undefined} The return value from the last call to the callback.
|
|
1253
|
+
* @template T
|
|
1254
|
+
* @api
|
|
1255
|
+
*/
|
|
1256
|
+
forEachFeatureIntersectingExtent(extent, callback) {
|
|
1257
|
+
return this.forEachFeatureInExtent(
|
|
1258
|
+
extent,
|
|
1259
|
+
/**
|
|
1260
|
+
* @param {FeatureType} feature Feature.
|
|
1261
|
+
* @return {T|undefined} The return value from the last call to the callback.
|
|
1262
|
+
*/
|
|
1263
|
+
function (feature) {
|
|
1264
|
+
const geometry = feature.getGeometry();
|
|
1265
|
+
if (
|
|
1266
|
+
geometry instanceof _render_Feature_js__WEBPACK_IMPORTED_MODULE_10__["default"] ||
|
|
1267
|
+
geometry.intersectsExtent(extent)
|
|
1268
|
+
) {
|
|
1269
|
+
const result = callback(feature);
|
|
1270
|
+
if (result) {
|
|
1271
|
+
return result;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Get the features collection associated with this source. Will be `null`
|
|
1280
|
+
* unless the source was configured with `useSpatialIndex` set to `false`, or
|
|
1281
|
+
* with a {@link module:ol/Collection~Collection} as `features`.
|
|
1282
|
+
* @return {Collection<FeatureType>|null} The collection of features.
|
|
1283
|
+
* @api
|
|
1284
|
+
*/
|
|
1285
|
+
getFeaturesCollection() {
|
|
1286
|
+
return this.featuresCollection_;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Get a snapshot of the features currently on the source in random order. The returned array
|
|
1291
|
+
* is a copy, the features are references to the features in the source.
|
|
1292
|
+
* @return {Array<FeatureType>} Features.
|
|
1293
|
+
* @api
|
|
1294
|
+
*/
|
|
1295
|
+
getFeatures() {
|
|
1296
|
+
let features;
|
|
1297
|
+
if (this.featuresCollection_) {
|
|
1298
|
+
features = this.featuresCollection_.getArray().slice(0);
|
|
1299
|
+
} else if (this.featuresRtree_) {
|
|
1300
|
+
features = this.featuresRtree_.getAll();
|
|
1301
|
+
if (!(0,_obj_js__WEBPACK_IMPORTED_MODULE_15__.isEmpty)(this.nullGeometryFeatures_)) {
|
|
1302
|
+
(0,_array_js__WEBPACK_IMPORTED_MODULE_16__.extend)(features, Object.values(this.nullGeometryFeatures_));
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
return features;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Get all features whose geometry intersects the provided coordinate.
|
|
1310
|
+
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
|
|
1311
|
+
* @return {Array<FeatureType>} Features.
|
|
1312
|
+
* @api
|
|
1313
|
+
*/
|
|
1314
|
+
getFeaturesAtCoordinate(coordinate) {
|
|
1315
|
+
/** @type {Array<FeatureType>} */
|
|
1316
|
+
const features = [];
|
|
1317
|
+
this.forEachFeatureAtCoordinateDirect(coordinate, function (feature) {
|
|
1318
|
+
features.push(feature);
|
|
1319
|
+
});
|
|
1320
|
+
return features;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Get all features whose bounding box intersects the provided extent. Note that this returns an array of
|
|
1325
|
+
* all features intersecting the given extent in random order (so it may include
|
|
1326
|
+
* features whose geometries do not intersect the extent).
|
|
1327
|
+
*
|
|
1328
|
+
* When `useSpatialIndex` is set to false, this method will return all
|
|
1329
|
+
* features.
|
|
1330
|
+
*
|
|
1331
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1332
|
+
* @param {import("../proj/Projection.js").default} [projection] Include features
|
|
1333
|
+
* where `extent` exceeds the x-axis bounds of `projection` and wraps around the world.
|
|
1334
|
+
* @return {Array<FeatureType>} Features.
|
|
1335
|
+
* @api
|
|
1336
|
+
*/
|
|
1337
|
+
getFeaturesInExtent(extent, projection) {
|
|
1338
|
+
if (this.featuresRtree_) {
|
|
1339
|
+
const multiWorld = projection && projection.canWrapX() && this.getWrapX();
|
|
1340
|
+
|
|
1341
|
+
if (!multiWorld) {
|
|
1342
|
+
return this.featuresRtree_.getInExtent(extent);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
const extents = (0,_extent_js__WEBPACK_IMPORTED_MODULE_17__.wrapAndSliceX)(extent, projection);
|
|
1346
|
+
|
|
1347
|
+
return [].concat(
|
|
1348
|
+
...extents.map((anExtent) => this.featuresRtree_.getInExtent(anExtent)),
|
|
1349
|
+
);
|
|
1350
|
+
}
|
|
1351
|
+
if (this.featuresCollection_) {
|
|
1352
|
+
return this.featuresCollection_.getArray().slice(0);
|
|
1353
|
+
}
|
|
1354
|
+
return [];
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* Get the closest feature to the provided coordinate.
|
|
1359
|
+
*
|
|
1360
|
+
* This method is not available when the source is configured with
|
|
1361
|
+
* `useSpatialIndex` set to `false` and the features in this source are of type
|
|
1362
|
+
* {@link module:ol/Feature~Feature}.
|
|
1363
|
+
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
|
|
1364
|
+
* @param {function(FeatureType):boolean} [filter] Feature filter function.
|
|
1365
|
+
* The filter function will receive one argument, the {@link module:ol/Feature~Feature feature}
|
|
1366
|
+
* and it should return a boolean value. By default, no filtering is made.
|
|
1367
|
+
* @return {FeatureType} Closest feature.
|
|
1368
|
+
* @api
|
|
1369
|
+
*/
|
|
1370
|
+
getClosestFeatureToCoordinate(coordinate, filter) {
|
|
1371
|
+
// Find the closest feature using branch and bound. We start searching an
|
|
1372
|
+
// infinite extent, and find the distance from the first feature found. This
|
|
1373
|
+
// becomes the closest feature. We then compute a smaller extent which any
|
|
1374
|
+
// closer feature must intersect. We continue searching with this smaller
|
|
1375
|
+
// extent, trying to find a closer feature. Every time we find a closer
|
|
1376
|
+
// feature, we update the extent being searched so that any even closer
|
|
1377
|
+
// feature must intersect it. We continue until we run out of features.
|
|
1378
|
+
const x = coordinate[0];
|
|
1379
|
+
const y = coordinate[1];
|
|
1380
|
+
let closestFeature = null;
|
|
1381
|
+
const closestPoint = [NaN, NaN];
|
|
1382
|
+
let minSquaredDistance = Infinity;
|
|
1383
|
+
const extent = [-Infinity, -Infinity, Infinity, Infinity];
|
|
1384
|
+
filter = filter ? filter : _functions_js__WEBPACK_IMPORTED_MODULE_2__.TRUE;
|
|
1385
|
+
this.featuresRtree_.forEachInExtent(
|
|
1386
|
+
extent,
|
|
1387
|
+
/**
|
|
1388
|
+
* @param {FeatureType} feature Feature.
|
|
1389
|
+
*/
|
|
1390
|
+
function (feature) {
|
|
1391
|
+
if (filter(feature)) {
|
|
1392
|
+
const geometry = feature.getGeometry();
|
|
1393
|
+
const previousMinSquaredDistance = minSquaredDistance;
|
|
1394
|
+
minSquaredDistance =
|
|
1395
|
+
geometry instanceof _render_Feature_js__WEBPACK_IMPORTED_MODULE_10__["default"]
|
|
1396
|
+
? 0
|
|
1397
|
+
: geometry.closestPointXY(x, y, closestPoint, minSquaredDistance);
|
|
1398
|
+
if (minSquaredDistance < previousMinSquaredDistance) {
|
|
1399
|
+
closestFeature = feature;
|
|
1400
|
+
// This is sneaky. Reduce the extent that it is currently being
|
|
1401
|
+
// searched while the R-Tree traversal using this same extent object
|
|
1402
|
+
// is still in progress. This is safe because the new extent is
|
|
1403
|
+
// strictly contained by the old extent.
|
|
1404
|
+
const minDistance = Math.sqrt(minSquaredDistance);
|
|
1405
|
+
extent[0] = x - minDistance;
|
|
1406
|
+
extent[1] = y - minDistance;
|
|
1407
|
+
extent[2] = x + minDistance;
|
|
1408
|
+
extent[3] = y + minDistance;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
);
|
|
1413
|
+
return closestFeature;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* Get the extent of the features currently in the source.
|
|
1418
|
+
*
|
|
1419
|
+
* This method is not available when the source is configured with
|
|
1420
|
+
* `useSpatialIndex` set to `false`.
|
|
1421
|
+
* @param {import("../extent.js").Extent} [extent] Destination extent. If provided, no new extent
|
|
1422
|
+
* will be created. Instead, that extent's coordinates will be overwritten.
|
|
1423
|
+
* @return {import("../extent.js").Extent} Extent.
|
|
1424
|
+
* @api
|
|
1425
|
+
*/
|
|
1426
|
+
getExtent(extent) {
|
|
1427
|
+
return this.featuresRtree_.getExtent(extent);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* Get a feature by its identifier (the value returned by feature.getId()). When `RenderFeature`s
|
|
1432
|
+
* are used, `getFeatureById()` can return an array of `RenderFeature`s. This allows for handling
|
|
1433
|
+
* of `GeometryCollection` geometries, where format readers create one `RenderFeature` per
|
|
1434
|
+
* `GeometryCollection` member.
|
|
1435
|
+
* Note that the index treats string and numeric identifiers as the same. So
|
|
1436
|
+
* `source.getFeatureById(2)` will return a feature with id `'2'` or `2`.
|
|
1437
|
+
*
|
|
1438
|
+
* @param {string|number} id Feature identifier.
|
|
1439
|
+
* @return {FeatureClassOrArrayOfRenderFeatures<FeatureType>|null} The feature (or `null` if not found).
|
|
1440
|
+
* @api
|
|
1441
|
+
*/
|
|
1442
|
+
getFeatureById(id) {
|
|
1443
|
+
const feature = this.idIndex_[id.toString()];
|
|
1444
|
+
return feature !== undefined
|
|
1445
|
+
? /** @type {FeatureClassOrArrayOfRenderFeatures<FeatureType>} */ (
|
|
1446
|
+
feature
|
|
1447
|
+
)
|
|
1448
|
+
: null;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* Get a feature by its internal unique identifier (using `getUid`).
|
|
1453
|
+
*
|
|
1454
|
+
* @param {string} uid Feature identifier.
|
|
1455
|
+
* @return {FeatureType|null} The feature (or `null` if not found).
|
|
1456
|
+
*/
|
|
1457
|
+
getFeatureByUid(uid) {
|
|
1458
|
+
const feature = this.uidIndex_[uid];
|
|
1459
|
+
return feature !== undefined ? feature : null;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Get the format associated with this source.
|
|
1464
|
+
*
|
|
1465
|
+
* @return {import("../format/Feature.js").default<FeatureType>|null}} The feature format.
|
|
1466
|
+
* @api
|
|
1467
|
+
*/
|
|
1468
|
+
getFormat() {
|
|
1469
|
+
return this.format_;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/**
|
|
1473
|
+
* @return {boolean} The source can have overlapping geometries.
|
|
1474
|
+
*/
|
|
1475
|
+
getOverlaps() {
|
|
1476
|
+
return this.overlaps_;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Get the url associated with this source.
|
|
1481
|
+
*
|
|
1482
|
+
* @return {string|import("../featureloader.js").FeatureUrlFunction|undefined} The url.
|
|
1483
|
+
* @api
|
|
1484
|
+
*/
|
|
1485
|
+
getUrl() {
|
|
1486
|
+
return this.url_;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* @param {Event} event Event.
|
|
1491
|
+
* @private
|
|
1492
|
+
*/
|
|
1493
|
+
handleFeatureChange_(event) {
|
|
1494
|
+
const feature = /** @type {FeatureType} */ (event.target);
|
|
1495
|
+
const featureKey = (0,_util_js__WEBPACK_IMPORTED_MODULE_8__.getUid)(feature);
|
|
1496
|
+
const geometry = feature.getGeometry();
|
|
1497
|
+
if (!geometry) {
|
|
1498
|
+
if (!(featureKey in this.nullGeometryFeatures_)) {
|
|
1499
|
+
if (this.featuresRtree_) {
|
|
1500
|
+
this.featuresRtree_.remove(feature);
|
|
1501
|
+
}
|
|
1502
|
+
this.nullGeometryFeatures_[featureKey] = feature;
|
|
1503
|
+
}
|
|
1504
|
+
} else {
|
|
1505
|
+
const extent = geometry.getExtent();
|
|
1506
|
+
if (featureKey in this.nullGeometryFeatures_) {
|
|
1507
|
+
delete this.nullGeometryFeatures_[featureKey];
|
|
1508
|
+
if (this.featuresRtree_) {
|
|
1509
|
+
this.featuresRtree_.insert(extent, feature);
|
|
1510
|
+
}
|
|
1511
|
+
} else {
|
|
1512
|
+
if (this.featuresRtree_) {
|
|
1513
|
+
this.featuresRtree_.update(extent, feature);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
const id = feature.getId();
|
|
1518
|
+
if (id !== undefined) {
|
|
1519
|
+
const sid = id.toString();
|
|
1520
|
+
if (this.idIndex_[sid] !== feature) {
|
|
1521
|
+
this.removeFromIdIndex_(feature);
|
|
1522
|
+
this.idIndex_[sid] = feature;
|
|
1523
|
+
}
|
|
1524
|
+
} else {
|
|
1525
|
+
this.removeFromIdIndex_(feature);
|
|
1526
|
+
this.uidIndex_[featureKey] = feature;
|
|
1527
|
+
}
|
|
1528
|
+
this.changed();
|
|
1529
|
+
this.dispatchEvent(
|
|
1530
|
+
new VectorSourceEvent(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].CHANGEFEATURE, feature),
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
/**
|
|
1535
|
+
* Returns true if the feature is contained within the source.
|
|
1536
|
+
* @param {FeatureType} feature Feature.
|
|
1537
|
+
* @return {boolean} Has feature.
|
|
1538
|
+
* @api
|
|
1539
|
+
*/
|
|
1540
|
+
hasFeature(feature) {
|
|
1541
|
+
const id = feature.getId();
|
|
1542
|
+
if (id !== undefined) {
|
|
1543
|
+
return id in this.idIndex_;
|
|
1544
|
+
}
|
|
1545
|
+
return (0,_util_js__WEBPACK_IMPORTED_MODULE_8__.getUid)(feature) in this.uidIndex_;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/**
|
|
1549
|
+
* @return {boolean} Is empty.
|
|
1550
|
+
*/
|
|
1551
|
+
isEmpty() {
|
|
1552
|
+
if (this.featuresRtree_) {
|
|
1553
|
+
return (
|
|
1554
|
+
this.featuresRtree_.isEmpty() && (0,_obj_js__WEBPACK_IMPORTED_MODULE_15__.isEmpty)(this.nullGeometryFeatures_)
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
if (this.featuresCollection_) {
|
|
1558
|
+
return this.featuresCollection_.getLength() === 0;
|
|
1559
|
+
}
|
|
1560
|
+
return true;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1565
|
+
* @param {number} resolution Resolution.
|
|
1566
|
+
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
1567
|
+
*/
|
|
1568
|
+
loadFeatures(extent, resolution, projection) {
|
|
1569
|
+
const loadedExtentsRtree = this.loadedExtentsRtree_;
|
|
1570
|
+
const extentsToLoad = this.strategy_(extent, resolution, projection);
|
|
1571
|
+
for (let i = 0, ii = extentsToLoad.length; i < ii; ++i) {
|
|
1572
|
+
const extentToLoad = extentsToLoad[i];
|
|
1573
|
+
const alreadyLoaded = loadedExtentsRtree.forEachInExtent(
|
|
1574
|
+
extentToLoad,
|
|
1575
|
+
/**
|
|
1576
|
+
* @param {{extent: import("../extent.js").Extent}} object Object.
|
|
1577
|
+
* @return {boolean} Contains.
|
|
1578
|
+
*/
|
|
1579
|
+
function (object) {
|
|
1580
|
+
return (0,_extent_js__WEBPACK_IMPORTED_MODULE_17__.containsExtent)(object.extent, extentToLoad);
|
|
1581
|
+
},
|
|
1582
|
+
);
|
|
1583
|
+
if (!alreadyLoaded) {
|
|
1584
|
+
++this.loadingExtentsCount_;
|
|
1585
|
+
this.dispatchEvent(
|
|
1586
|
+
new VectorSourceEvent(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].FEATURESLOADSTART),
|
|
1587
|
+
);
|
|
1588
|
+
this.loader_.call(
|
|
1589
|
+
this,
|
|
1590
|
+
extentToLoad,
|
|
1591
|
+
resolution,
|
|
1592
|
+
projection,
|
|
1593
|
+
/**
|
|
1594
|
+
* @param {Array<FeatureType>} features Loaded features
|
|
1595
|
+
*/
|
|
1596
|
+
(features) => {
|
|
1597
|
+
--this.loadingExtentsCount_;
|
|
1598
|
+
this.dispatchEvent(
|
|
1599
|
+
new VectorSourceEvent(
|
|
1600
|
+
_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].FEATURESLOADEND,
|
|
1601
|
+
undefined,
|
|
1602
|
+
features,
|
|
1603
|
+
),
|
|
1604
|
+
);
|
|
1605
|
+
},
|
|
1606
|
+
() => {
|
|
1607
|
+
--this.loadingExtentsCount_;
|
|
1608
|
+
this.dispatchEvent(
|
|
1609
|
+
new VectorSourceEvent(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].FEATURESLOADERROR),
|
|
1610
|
+
);
|
|
1611
|
+
},
|
|
1612
|
+
);
|
|
1613
|
+
loadedExtentsRtree.insert(extentToLoad, {extent: extentToLoad.slice()});
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
this.loading =
|
|
1617
|
+
this.loader_.length < 4 ? false : this.loadingExtentsCount_ > 0;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/**
|
|
1621
|
+
* @override
|
|
1622
|
+
*/
|
|
1623
|
+
refresh() {
|
|
1624
|
+
this.clear(true);
|
|
1625
|
+
this.loadedExtentsRtree_.clear();
|
|
1626
|
+
super.refresh();
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
/**
|
|
1630
|
+
* Remove an extent from the list of loaded extents.
|
|
1631
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1632
|
+
* @api
|
|
1633
|
+
*/
|
|
1634
|
+
removeLoadedExtent(extent) {
|
|
1635
|
+
const loadedExtentsRtree = this.loadedExtentsRtree_;
|
|
1636
|
+
const obj = loadedExtentsRtree.forEachInExtent(extent, function (object) {
|
|
1637
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_17__.equals)(object.extent, extent)) {
|
|
1638
|
+
return object;
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
if (obj) {
|
|
1642
|
+
loadedExtentsRtree.remove(obj);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* Batch remove features from the source. If you want to remove all features
|
|
1648
|
+
* at once, use the {@link module:ol/source/Vector~VectorSource#clear #clear()} method
|
|
1649
|
+
* instead.
|
|
1650
|
+
* @param {Array<FeatureType>} features Features to remove.
|
|
1651
|
+
* @api
|
|
1652
|
+
*/
|
|
1653
|
+
removeFeatures(features) {
|
|
1654
|
+
let removed = false;
|
|
1655
|
+
for (let i = 0, ii = features.length; i < ii; ++i) {
|
|
1656
|
+
removed = this.removeFeatureInternal(features[i]) || removed;
|
|
1657
|
+
}
|
|
1658
|
+
if (removed) {
|
|
1659
|
+
this.changed();
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* Remove a single feature from the source. If you want to batch remove
|
|
1665
|
+
* features, use the {@link module:ol/source/Vector~VectorSource#removeFeatures #removeFeatures()} method
|
|
1666
|
+
* instead.
|
|
1667
|
+
* @param {FeatureType} feature Feature to remove.
|
|
1668
|
+
* @api
|
|
1669
|
+
*/
|
|
1670
|
+
removeFeature(feature) {
|
|
1671
|
+
if (!feature) {
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
const removed = this.removeFeatureInternal(feature);
|
|
1675
|
+
if (removed) {
|
|
1676
|
+
this.changed();
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Remove feature without firing a `change` event.
|
|
1682
|
+
* @param {FeatureType} feature Feature.
|
|
1683
|
+
* @return {boolean} True if the feature was removed, false if it was not found.
|
|
1684
|
+
* @protected
|
|
1685
|
+
*/
|
|
1686
|
+
removeFeatureInternal(feature) {
|
|
1687
|
+
const featureKey = (0,_util_js__WEBPACK_IMPORTED_MODULE_8__.getUid)(feature);
|
|
1688
|
+
if (!(featureKey in this.uidIndex_)) {
|
|
1689
|
+
return false;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
if (featureKey in this.nullGeometryFeatures_) {
|
|
1693
|
+
delete this.nullGeometryFeatures_[featureKey];
|
|
1694
|
+
} else {
|
|
1695
|
+
if (this.featuresRtree_) {
|
|
1696
|
+
this.featuresRtree_.remove(feature);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
const featureChangeKeys = this.featureChangeKeys_[featureKey];
|
|
1701
|
+
featureChangeKeys?.forEach(_events_js__WEBPACK_IMPORTED_MODULE_11__.unlistenByKey);
|
|
1702
|
+
delete this.featureChangeKeys_[featureKey];
|
|
1703
|
+
|
|
1704
|
+
const id = feature.getId();
|
|
1705
|
+
if (id !== undefined) {
|
|
1706
|
+
const idString = id.toString();
|
|
1707
|
+
const indexedFeature = this.idIndex_[idString];
|
|
1708
|
+
if (indexedFeature === feature) {
|
|
1709
|
+
delete this.idIndex_[idString];
|
|
1710
|
+
} else if (Array.isArray(indexedFeature)) {
|
|
1711
|
+
indexedFeature.splice(indexedFeature.indexOf(feature), 1);
|
|
1712
|
+
if (indexedFeature.length === 1) {
|
|
1713
|
+
this.idIndex_[idString] = indexedFeature[0];
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
delete this.uidIndex_[featureKey];
|
|
1718
|
+
if (this.hasListener(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].REMOVEFEATURE)) {
|
|
1719
|
+
this.dispatchEvent(
|
|
1720
|
+
new VectorSourceEvent(_VectorEventType_js__WEBPACK_IMPORTED_MODULE_9__["default"].REMOVEFEATURE, feature),
|
|
1721
|
+
);
|
|
1722
|
+
}
|
|
1723
|
+
return true;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/**
|
|
1727
|
+
* Remove a feature from the id index. Called internally when the feature id
|
|
1728
|
+
* may have changed.
|
|
1729
|
+
* @param {FeatureType} feature The feature.
|
|
1730
|
+
* @private
|
|
1731
|
+
*/
|
|
1732
|
+
removeFromIdIndex_(feature) {
|
|
1733
|
+
for (const id in this.idIndex_) {
|
|
1734
|
+
if (this.idIndex_[id] === feature) {
|
|
1735
|
+
delete this.idIndex_[id];
|
|
1736
|
+
break;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* Set the new loader of the source. The next render cycle will use the
|
|
1743
|
+
* new loader.
|
|
1744
|
+
* @param {import("../featureloader.js").FeatureLoader} loader The loader to set.
|
|
1745
|
+
* @api
|
|
1746
|
+
*/
|
|
1747
|
+
setLoader(loader) {
|
|
1748
|
+
this.loader_ = loader;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
/**
|
|
1752
|
+
* Points the source to a new url. The next render cycle will use the new url.
|
|
1753
|
+
* @param {string|import("../featureloader.js").FeatureUrlFunction} url Url.
|
|
1754
|
+
* @api
|
|
1755
|
+
*/
|
|
1756
|
+
setUrl(url) {
|
|
1757
|
+
(0,_asserts_js__WEBPACK_IMPORTED_MODULE_3__.assert)(this.format_, '`format` must be set when `url` is set');
|
|
1758
|
+
this.url_ = url;
|
|
1759
|
+
this.setLoader((0,_featureloader_js__WEBPACK_IMPORTED_MODULE_4__.xhr)(url, this.format_));
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* @param {boolean} overlaps The source can have overlapping geometries.
|
|
1764
|
+
*/
|
|
1765
|
+
setOverlaps(overlaps) {
|
|
1766
|
+
this.overlaps_ = overlaps;
|
|
1767
|
+
this.changed();
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (VectorSource);
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
/***/ }),
|
|
1775
|
+
|
|
1776
|
+
/***/ "./node_modules/ol/source/VectorEventType.js":
|
|
1777
|
+
/*!***************************************************!*\
|
|
1778
|
+
!*** ./node_modules/ol/source/VectorEventType.js ***!
|
|
1779
|
+
\***************************************************/
|
|
1780
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
1781
|
+
|
|
1782
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1783
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1784
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
1785
|
+
/* harmony export */ });
|
|
1786
|
+
/**
|
|
1787
|
+
* @module ol/source/VectorEventType
|
|
1788
|
+
*/
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* @enum {string}
|
|
1792
|
+
*/
|
|
1793
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
|
1794
|
+
/**
|
|
1795
|
+
* Triggered when a feature is added to the source.
|
|
1796
|
+
* @event module:ol/source/Vector.VectorSourceEvent#addfeature
|
|
1797
|
+
* @api
|
|
1798
|
+
*/
|
|
1799
|
+
ADDFEATURE: 'addfeature',
|
|
1800
|
+
|
|
1801
|
+
/**
|
|
1802
|
+
* Triggered when a feature is updated.
|
|
1803
|
+
* @event module:ol/source/Vector.VectorSourceEvent#changefeature
|
|
1804
|
+
* @api
|
|
1805
|
+
*/
|
|
1806
|
+
CHANGEFEATURE: 'changefeature',
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Triggered when the clear method is called on the source.
|
|
1810
|
+
* @event module:ol/source/Vector.VectorSourceEvent#clear
|
|
1811
|
+
* @api
|
|
1812
|
+
*/
|
|
1813
|
+
CLEAR: 'clear',
|
|
1814
|
+
|
|
1815
|
+
/**
|
|
1816
|
+
* Triggered when a feature is removed from the source.
|
|
1817
|
+
* See {@link module:ol/source/Vector~VectorSource#clear source.clear()} for exceptions.
|
|
1818
|
+
* @event module:ol/source/Vector.VectorSourceEvent#removefeature
|
|
1819
|
+
* @api
|
|
1820
|
+
*/
|
|
1821
|
+
REMOVEFEATURE: 'removefeature',
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* Triggered when features starts loading.
|
|
1825
|
+
* @event module:ol/source/Vector.VectorSourceEvent#featuresloadstart
|
|
1826
|
+
* @api
|
|
1827
|
+
*/
|
|
1828
|
+
FEATURESLOADSTART: 'featuresloadstart',
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* Triggered when features finishes loading.
|
|
1832
|
+
* @event module:ol/source/Vector.VectorSourceEvent#featuresloadend
|
|
1833
|
+
* @api
|
|
1834
|
+
*/
|
|
1835
|
+
FEATURESLOADEND: 'featuresloadend',
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* Triggered if feature loading results in an error.
|
|
1839
|
+
* @event module:ol/source/Vector.VectorSourceEvent#featuresloaderror
|
|
1840
|
+
* @api
|
|
1841
|
+
*/
|
|
1842
|
+
FEATURESLOADERROR: 'featuresloaderror',
|
|
1843
|
+
});
|
|
1844
|
+
|
|
1845
|
+
/**
|
|
1846
|
+
* @typedef {'addfeature'|'changefeature'|'clear'|'removefeature'|'featuresloadstart'|'featuresloadend'|'featuresloaderror'} VectorSourceEventTypes
|
|
1847
|
+
*/
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
/***/ }),
|
|
1851
|
+
|
|
1852
|
+
/***/ "./node_modules/ol/structs/RBush.js":
|
|
1853
|
+
/*!******************************************!*\
|
|
1854
|
+
!*** ./node_modules/ol/structs/RBush.js ***!
|
|
1855
|
+
\******************************************/
|
|
1856
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
1857
|
+
|
|
1858
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1859
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1860
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
1861
|
+
/* harmony export */ });
|
|
1862
|
+
/* harmony import */ var rbush__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rbush */ "./node_modules/rbush/index.js");
|
|
1863
|
+
/* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../extent.js */ "./node_modules/ol/extent.js");
|
|
1864
|
+
/* harmony import */ var _obj_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../obj.js */ "./node_modules/ol/obj.js");
|
|
1865
|
+
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util.js */ "./node_modules/ol/util.js");
|
|
1866
|
+
/**
|
|
1867
|
+
* @module ol/structs/RBush
|
|
1868
|
+
*/
|
|
1869
|
+
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
/**
|
|
1875
|
+
* @typedef {import("rbush").BBox & {value: T}} Entry
|
|
1876
|
+
* @template T
|
|
1877
|
+
*/
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* @classdesc
|
|
1881
|
+
* Wrapper around the RBush by Vladimir Agafonkin.
|
|
1882
|
+
* See https://github.com/mourner/rbush.
|
|
1883
|
+
*
|
|
1884
|
+
* @template {Object} T
|
|
1885
|
+
*/
|
|
1886
|
+
class RBush {
|
|
1887
|
+
/**
|
|
1888
|
+
* @param {number} [maxEntries] Max entries.
|
|
1889
|
+
*/
|
|
1890
|
+
constructor(maxEntries) {
|
|
1891
|
+
/**
|
|
1892
|
+
* @private
|
|
1893
|
+
* @type {RBush_<Entry<T>>}
|
|
1894
|
+
*/
|
|
1895
|
+
this.rbush_ = new rbush__WEBPACK_IMPORTED_MODULE_0__["default"](maxEntries);
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* A mapping between the objects added to this rbush wrapper
|
|
1899
|
+
* and the objects that are actually added to the internal rbush.
|
|
1900
|
+
* @private
|
|
1901
|
+
* @type {Object<string, Entry<T>>}
|
|
1902
|
+
*/
|
|
1903
|
+
this.items_ = {};
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
/**
|
|
1907
|
+
* Insert a value into the RBush.
|
|
1908
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1909
|
+
* @param {T} value Value.
|
|
1910
|
+
*/
|
|
1911
|
+
insert(extent, value) {
|
|
1912
|
+
/** @type {Entry<T>} */
|
|
1913
|
+
const item = {
|
|
1914
|
+
minX: extent[0],
|
|
1915
|
+
minY: extent[1],
|
|
1916
|
+
maxX: extent[2],
|
|
1917
|
+
maxY: extent[3],
|
|
1918
|
+
value: value,
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
this.rbush_.insert(item);
|
|
1922
|
+
this.items_[(0,_util_js__WEBPACK_IMPORTED_MODULE_1__.getUid)(value)] = item;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
/**
|
|
1926
|
+
* Bulk-insert values into the RBush.
|
|
1927
|
+
* @param {Array<import("../extent.js").Extent>} extents Extents.
|
|
1928
|
+
* @param {Array<T>} values Values.
|
|
1929
|
+
*/
|
|
1930
|
+
load(extents, values) {
|
|
1931
|
+
const items = new Array(values.length);
|
|
1932
|
+
for (let i = 0, l = values.length; i < l; i++) {
|
|
1933
|
+
const extent = extents[i];
|
|
1934
|
+
const value = values[i];
|
|
1935
|
+
|
|
1936
|
+
/** @type {Entry<T>} */
|
|
1937
|
+
const item = {
|
|
1938
|
+
minX: extent[0],
|
|
1939
|
+
minY: extent[1],
|
|
1940
|
+
maxX: extent[2],
|
|
1941
|
+
maxY: extent[3],
|
|
1942
|
+
value: value,
|
|
1943
|
+
};
|
|
1944
|
+
items[i] = item;
|
|
1945
|
+
this.items_[(0,_util_js__WEBPACK_IMPORTED_MODULE_1__.getUid)(value)] = item;
|
|
1946
|
+
}
|
|
1947
|
+
this.rbush_.load(items);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
/**
|
|
1951
|
+
* Remove a value from the RBush.
|
|
1952
|
+
* @param {T} value Value.
|
|
1953
|
+
* @return {boolean} Removed.
|
|
1954
|
+
*/
|
|
1955
|
+
remove(value) {
|
|
1956
|
+
const uid = (0,_util_js__WEBPACK_IMPORTED_MODULE_1__.getUid)(value);
|
|
1957
|
+
|
|
1958
|
+
// get the object in which the value was wrapped when adding to the
|
|
1959
|
+
// internal rbush. then use that object to do the removal.
|
|
1960
|
+
const item = this.items_[uid];
|
|
1961
|
+
delete this.items_[uid];
|
|
1962
|
+
return this.rbush_.remove(item) !== null;
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
/**
|
|
1966
|
+
* Update the extent of a value in the RBush.
|
|
1967
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1968
|
+
* @param {T} value Value.
|
|
1969
|
+
*/
|
|
1970
|
+
update(extent, value) {
|
|
1971
|
+
const item = this.items_[(0,_util_js__WEBPACK_IMPORTED_MODULE_1__.getUid)(value)];
|
|
1972
|
+
const bbox = [item.minX, item.minY, item.maxX, item.maxY];
|
|
1973
|
+
if (!(0,_extent_js__WEBPACK_IMPORTED_MODULE_2__.equals)(bbox, extent)) {
|
|
1974
|
+
this.remove(value);
|
|
1975
|
+
this.insert(extent, value);
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* Return all values in the RBush.
|
|
1981
|
+
* @return {Array<T>} All.
|
|
1982
|
+
*/
|
|
1983
|
+
getAll() {
|
|
1984
|
+
const items = this.rbush_.all();
|
|
1985
|
+
return items.map(function (item) {
|
|
1986
|
+
return item.value;
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* Return all values in the given extent.
|
|
1992
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1993
|
+
* @return {Array<T>} All in extent.
|
|
1994
|
+
*/
|
|
1995
|
+
getInExtent(extent) {
|
|
1996
|
+
/** @type {import("rbush").BBox} */
|
|
1997
|
+
const bbox = {
|
|
1998
|
+
minX: extent[0],
|
|
1999
|
+
minY: extent[1],
|
|
2000
|
+
maxX: extent[2],
|
|
2001
|
+
maxY: extent[3],
|
|
2002
|
+
};
|
|
2003
|
+
const items = this.rbush_.search(bbox);
|
|
2004
|
+
return items.map(function (item) {
|
|
2005
|
+
return item.value;
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* Calls a callback function with each value in the tree.
|
|
2011
|
+
* If the callback returns a truthy value, this value is returned without
|
|
2012
|
+
* checking the rest of the tree.
|
|
2013
|
+
* @param {function(T): R} callback Callback.
|
|
2014
|
+
* @return {R|undefined} Callback return value.
|
|
2015
|
+
* @template R
|
|
2016
|
+
*/
|
|
2017
|
+
forEach(callback) {
|
|
2018
|
+
return this.forEach_(this.getAll(), callback);
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
/**
|
|
2022
|
+
* Calls a callback function with each value in the provided extent.
|
|
2023
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
2024
|
+
* @param {function(T): R} callback Callback.
|
|
2025
|
+
* @return {R|undefined} Callback return value.
|
|
2026
|
+
* @template R
|
|
2027
|
+
*/
|
|
2028
|
+
forEachInExtent(extent, callback) {
|
|
2029
|
+
return this.forEach_(this.getInExtent(extent), callback);
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* @param {Array<T>} values Values.
|
|
2034
|
+
* @param {function(T): R} callback Callback.
|
|
2035
|
+
* @return {R|undefined} Callback return value.
|
|
2036
|
+
* @template R
|
|
2037
|
+
* @private
|
|
2038
|
+
*/
|
|
2039
|
+
forEach_(values, callback) {
|
|
2040
|
+
let result;
|
|
2041
|
+
for (let i = 0, l = values.length; i < l; i++) {
|
|
2042
|
+
result = callback(values[i]);
|
|
2043
|
+
if (result) {
|
|
2044
|
+
return result;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
return result;
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* @return {boolean} Is empty.
|
|
2052
|
+
*/
|
|
2053
|
+
isEmpty() {
|
|
2054
|
+
return (0,_obj_js__WEBPACK_IMPORTED_MODULE_3__.isEmpty)(this.items_);
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
/**
|
|
2058
|
+
* Remove all values from the RBush.
|
|
2059
|
+
*/
|
|
2060
|
+
clear() {
|
|
2061
|
+
this.rbush_.clear();
|
|
2062
|
+
this.items_ = {};
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
/**
|
|
2066
|
+
* @param {import("../extent.js").Extent} [extent] Extent.
|
|
2067
|
+
* @return {import("../extent.js").Extent} Extent.
|
|
2068
|
+
*/
|
|
2069
|
+
getExtent(extent) {
|
|
2070
|
+
const data = this.rbush_.toJSON();
|
|
2071
|
+
return (0,_extent_js__WEBPACK_IMPORTED_MODULE_2__.createOrUpdate)(data.minX, data.minY, data.maxX, data.maxY, extent);
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* @param {RBush<T>} rbush R-Tree.
|
|
2076
|
+
*/
|
|
2077
|
+
concat(rbush) {
|
|
2078
|
+
this.rbush_.load(rbush.rbush_.all());
|
|
2079
|
+
for (const i in rbush.items_) {
|
|
2080
|
+
this.items_[i] = rbush.items_[i];
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RBush);
|
|
2086
|
+
|
|
2087
|
+
|
|
2088
|
+
/***/ })
|
|
2089
|
+
|
|
2090
|
+
}])
|
|
2091
|
+
//# sourceMappingURL=vendors-node_modules_ol_source_Vector_js.js.map
|