@masterportal/masterportalapi 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.editorconfig +15 -0
  2. package/.eslintignore +6 -0
  3. package/.eslintrc +184 -0
  4. package/.husky/pre-push +4 -0
  5. package/CHANGELOG.md +217 -0
  6. package/License.txt +21 -0
  7. package/README.md +24 -0
  8. package/babel.config.json +6 -0
  9. package/example/README.md +7 -0
  10. package/example/config/localGeoJSON.js +956 -0
  11. package/example/config/portal.json +35 -0
  12. package/example/config/services.json +79 -0
  13. package/example/index.html +27 -0
  14. package/example/index.js +210 -0
  15. package/example/style.scss +59 -0
  16. package/jest.config.js +18 -0
  17. package/jest.setup.js +5 -0
  18. package/jsdoc.json +15 -0
  19. package/package.json +62 -0
  20. package/public/marker.svg +1 -0
  21. package/public/stringMarker.js +5 -0
  22. package/src/crs.js +122 -0
  23. package/src/defaults.js +38 -0
  24. package/src/index.js +30 -0
  25. package/src/layer/geojson/index.js +109 -0
  26. package/src/layer/geojson/style.js +61 -0
  27. package/src/layer/lib.js +32 -0
  28. package/src/layer/oaf.js +207 -0
  29. package/src/layer/terrain.js +72 -0
  30. package/src/layer/tileset.js +71 -0
  31. package/src/layer/vector.js +48 -0
  32. package/src/layer/vectorBase.js +39 -0
  33. package/src/layer/wfs.js +218 -0
  34. package/src/layer/wms.js +185 -0
  35. package/src/lib/coordsToPairs.js +15 -0
  36. package/src/lib/getInitialLayers.js +22 -0
  37. package/src/lib/load3DScript.js +22 -0
  38. package/src/lib/oafUtil.js +22 -0
  39. package/src/lib/setBackgroundImage.js +23 -0
  40. package/src/lib/wfsUtil.js +75 -0
  41. package/src/lib/zoomTo.js +40 -0
  42. package/src/maps/api.js +5 -0
  43. package/src/maps/map.js +35 -0
  44. package/src/maps/mapView.js +54 -0
  45. package/src/maps/ol/olMap.js +124 -0
  46. package/src/maps/olcs/3dUtils/fixedOverlaySynchronizer.js +39 -0
  47. package/src/maps/olcs/3dUtils/wmsRasterSynchronizer.js +348 -0
  48. package/src/maps/olcs/olcsMap.js +212 -0
  49. package/src/rawLayerList.js +88 -0
  50. package/src/searchAddress/gazetteerUrl.js +22 -0
  51. package/src/searchAddress/index.js +13 -0
  52. package/src/searchAddress/parse.js +196 -0
  53. package/src/searchAddress/search.js +184 -0
  54. package/src/searchAddress/searchGazetteer.js +52 -0
  55. package/src/searchAddress/showGeographicIdentifier.js +20 -0
  56. package/src/searchAddress/types.js +17 -0
  57. package/test/.eslintrc +7 -0
  58. package/test/crs.test.js +109 -0
  59. package/test/layer/geojson/index.test.js +133 -0
  60. package/test/layer/geojson/style.test.js +46 -0
  61. package/test/layer/lib.test.js +83 -0
  62. package/test/layer/oaf.test.js +245 -0
  63. package/test/layer/resources/oafFeatures.js +105 -0
  64. package/test/layer/resources/wfsFeatures.js +26 -0
  65. package/test/layer/resources/wfsFilter.js +17 -0
  66. package/test/layer/terrain.test.js +106 -0
  67. package/test/layer/tileset.test.js +116 -0
  68. package/test/layer/vector.test.js +76 -0
  69. package/test/layer/vectorBase.test.js +48 -0
  70. package/test/layer/wfs.test.js +388 -0
  71. package/test/layer/wms.test.js +256 -0
  72. package/test/lib/coordsToPairs.test.js +9 -0
  73. package/test/lib/getInitialLayers.test.js +28 -0
  74. package/test/lib/oafUtil.test.js +24 -0
  75. package/test/lib/setBackgroundImage.test.js +49 -0
  76. package/test/lib/wfsUtil.test.js +28 -0
  77. package/test/lib/zoomTo.test.js +74 -0
  78. package/test/map.test.js +258 -0
  79. package/test/mapView.test.js +59 -0
  80. package/test/rawLayerList.test.js +48 -0
  81. package/test/searchAddress/gazetteerSearchResults/address.js +175 -0
  82. package/test/searchAddress/gazetteerSearchResults/district.js +71 -0
  83. package/test/searchAddress/gazetteerSearchResults/houseNumber.js +32 -0
  84. package/test/searchAddress/gazetteerSearchResults/index.js +19 -0
  85. package/test/searchAddress/gazetteerSearchResults/parcel.js +44 -0
  86. package/test/searchAddress/gazetteerSearchResults/street.js +46 -0
  87. package/test/searchAddress/gazetteerSearchResults/streetKey.js +51 -0
  88. package/test/searchAddress/gazetteerUrl.test.js +22 -0
  89. package/test/searchAddress/parse.test.js +110 -0
  90. package/test/searchAddress/search.test.js +150 -0
  91. package/test/searchAddress/searchGazetteer.test.js +58 -0
  92. package/test/searchAddress/showGeographicIdentifier.test.js +22 -0
@@ -0,0 +1,76 @@
1
+ import VectorSource from "ol/source/Vector.js";
2
+ import Cluster from "ol/source/Cluster.js";
3
+ import {bbox} from "ol/loadingstrategy.js";
4
+ import {WFS} from "ol/format.js";
5
+ import * as vector from "../../src/layer/vector";
6
+
7
+ /* eslint-disable no-underscore-dangle */
8
+ describe("vector.js", function () {
9
+ describe("createVectorSource", function () {
10
+ it("creates a VectorSource with all params", function () {
11
+ const loader = jest.fn(),
12
+ loadingStrategy = bbox,
13
+ format = new WFS(),
14
+ source = vector.createVectorSource(loader, loadingStrategy, format);
15
+
16
+ expect(source).toBeInstanceOf(VectorSource);
17
+ expect(source.getFormat()).toBeInstanceOf(WFS);
18
+ expect(source.loader_).toEqual(loader);
19
+ expect(source.strategy_).toEqual(loadingStrategy);
20
+ });
21
+ it("creates a VectorSource with an url", function () {
22
+ const url = "https://url.de",
23
+ loadingStrategy = bbox,
24
+ format = new WFS(),
25
+ source = vector.createVectorSource(url, loadingStrategy, format);
26
+
27
+ expect(source).toBeInstanceOf(VectorSource);
28
+ expect(source.getFormat()).toBeInstanceOf(WFS);
29
+ expect(source.getUrl()).toEqual(url);
30
+ expect(source.strategy_).toEqual(loadingStrategy);
31
+ });
32
+ it("creates a VectorSource without an url", function () {
33
+ const loader = jest.fn(),
34
+ loadingStrategy = bbox,
35
+ format = new WFS(),
36
+ source = vector.createVectorSource(loader, loadingStrategy, format);
37
+
38
+ expect(source).toBeInstanceOf(VectorSource);
39
+ expect(source.getFormat()).toBeInstanceOf(WFS);
40
+ expect(source.getUrl()).toEqual(undefined);
41
+ expect(source.loader_).toEqual(loader);
42
+ expect(source.strategy_).toEqual(loadingStrategy);
43
+ });
44
+
45
+ });
46
+ describe("createClusterVectorSource", function () {
47
+ it("creates a Cluster with without params", function () {
48
+ const source = vector.createClusterVectorSource(new VectorSource());
49
+
50
+ expect(source).toBeInstanceOf(Cluster);
51
+ });
52
+ it("creates a Cluster with all params", function () {
53
+ const layerSource = new VectorSource(),
54
+ clusterDistance = 60,
55
+ clusterGeometryFunction = jest.fn(() => "testGeometryFn"),
56
+ cluster = vector.createClusterVectorSource(layerSource, clusterDistance, clusterGeometryFunction);
57
+
58
+ expect(cluster).toBeInstanceOf(Cluster);
59
+ expect(cluster.getDistance()).toEqual(60);
60
+ expect(cluster.getSource()).toEqual(layerSource);
61
+ expect(typeof cluster.geometryFunction).toEqual("function");
62
+ expect(cluster.geometryFunction()).toEqual("testGeometryFn");
63
+ });
64
+ it("creates a Cluster without geometryFunction", function () {
65
+ const layerSource = new VectorSource(),
66
+ clusterDistance = 60,
67
+ cluster = vector.createClusterVectorSource(layerSource, clusterDistance, null);
68
+
69
+ expect(cluster).toBeInstanceOf(Cluster);
70
+ expect(cluster.getDistance()).toEqual(60);
71
+ expect(cluster.getSource()).toEqual(layerSource);
72
+ expect(typeof cluster.geometryFunction).toEqual("function");
73
+ });
74
+ });
75
+
76
+ });
@@ -0,0 +1,48 @@
1
+ import VectorLayer from "ol/layer/Vector";
2
+ import VectorSource from "ol/source/Vector.js";
3
+ import * as vectorBase from "../../src/layer/vectorBase";
4
+
5
+ describe("vectorBase.js", function () {
6
+
7
+ describe("createLayerSource", function () {
8
+ it("creates a layerSource", function () {
9
+ const source = vectorBase.createLayerSource();
10
+
11
+ expect(source).toBeInstanceOf(VectorSource);
12
+ });
13
+ });
14
+
15
+ describe("createLayer", function () {
16
+ it("creates a vector Base Layer", function () {
17
+ const attr = {
18
+ name: "Albus Percival Wulfric Brian Dumbledore",
19
+ typ: "VectorBase",
20
+ gfiAttributes: "ignore",
21
+ id: "Rawenclaw_01"
22
+ },
23
+ layer = vectorBase.createLayer(attr);
24
+
25
+ expect(layer).toBeInstanceOf(VectorLayer);
26
+ expect(layer.get("name")).toEqual("Albus Percival Wulfric Brian Dumbledore");
27
+ expect(layer.get("typ")).toEqual("VectorBase");
28
+ expect(layer.get("id")).toEqual("Rawenclaw_01");
29
+ });
30
+ });
31
+
32
+ describe("updateSource", function () {
33
+ it("updateSource will fetch layer again", function () {
34
+ const layer = vectorBase.createLayer({id: "id"}),
35
+ layerGetSourceMock = jest.fn(() => {
36
+ return {
37
+ clear: () => this,
38
+ addFeatures: () => this
39
+ };
40
+ });
41
+
42
+ layer.getSource = layerGetSourceMock;
43
+ vectorBase.updateSource(layer);
44
+ expect(layerGetSourceMock.mock.calls.length).toBe(2);
45
+ });
46
+ });
47
+
48
+ });
@@ -0,0 +1,388 @@
1
+ import VectorLayer from "ol/layer/Vector.js";
2
+ import VectorSource from "ol/source/Vector.js";
3
+ import Cluster from "ol/source/Cluster.js";
4
+ import {Style, Icon} from "ol/style.js";
5
+ import map from "../../src/maps/map.js";
6
+ import defaults from "../../src/defaults";
7
+ import {WFS} from "ol/format.js";
8
+ import * as wfs from "../../src/layer/wfs";
9
+ import {featureCollection} from "./resources/wfsFeatures";
10
+ import {wfsFilterQuery} from "./resources/wfsFilter";
11
+
12
+ jest.mock("../../src/rawLayerList.js", () => {
13
+ const original = jest.requireActual("../../src/rawLayerList.js");
14
+
15
+ original.initializeLayerList = jest.fn();
16
+ return original;
17
+ });
18
+
19
+
20
+ describe("wfs.js", function () {
21
+ describe("createLayer", function () {
22
+ it("creates a VectorLayer without id", function () {
23
+ const layer = wfs.createLayer({version: "1.1.0"});
24
+
25
+ expect(layer).toBeInstanceOf(VectorLayer);
26
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
27
+ });
28
+ it("creates a VectorLayer without id and version", function () {
29
+ const warn = jest.spyOn(console, "warn").mockImplementation(() => ""),
30
+ layer = wfs.createLayer();
31
+
32
+ expect(layer).toBeInstanceOf(VectorLayer);
33
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
34
+ expect(warn).toHaveBeenCalled();
35
+
36
+ warn.mockReset();
37
+ });
38
+ it("creates a VectorLayer with source", function () {
39
+ const layer = wfs.createLayer({id: "id", version: "1.1.0"});
40
+
41
+ expect(layer).toBeInstanceOf(VectorLayer);
42
+ expect(layer.get("id")).toEqual("id");
43
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
44
+ });
45
+ it("creates a VectorLayer with style in rawLayer", function () {
46
+ function styleFunction () {
47
+ const icon = new Style({
48
+ image: new Icon({
49
+ src: "https://building.png",
50
+ scale: 0.5,
51
+ opacity: 1
52
+ })
53
+ });
54
+
55
+ return [icon];
56
+ }
57
+ const layer = wfs.createLayer({id: "id", style: styleFunction, version: "1.1.0"});
58
+
59
+ expect(layer).toBeInstanceOf(VectorLayer);
60
+ expect(layer.get("id")).toEqual("id");
61
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
62
+ expect(layer.getStyleFunction()).toBeDefined();
63
+ expect(layer.getStyleFunction()).toEqual(styleFunction);
64
+
65
+ });
66
+ });
67
+ describe("createLayer with additional params and options", function () {
68
+ it("creates a VectorLayer with layerParams", function () {
69
+ const layerParams = {
70
+ name: "name",
71
+ layers: "layer1, layer2"
72
+ },
73
+ layer = wfs.createLayer({id: "id", version: "1.1.0"}, {layerParams});
74
+
75
+ expect(layer).toBeInstanceOf(VectorLayer);
76
+ expect(layer.get("id")).toEqual("id");
77
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
78
+ expect(layer.get("name")).toEqual("name");
79
+ expect(layer.get("layers")).toEqual("layer1, layer2");
80
+ });
81
+ it("creates a VectorLayer with style in options", function () {
82
+ function styleFunction () {
83
+ const icon = new Style({
84
+ image: new Icon({
85
+ src: "https://building.png",
86
+ scale: 0.5,
87
+ opacity: 1
88
+ })
89
+ });
90
+
91
+ return [icon];
92
+ }
93
+ const options = {
94
+ style: styleFunction
95
+ },
96
+ layerParams = {
97
+ name: "name",
98
+ layers: "layer1, layer2"
99
+ },
100
+ layer = wfs.createLayer({id: "id", version: "2.0.0"}, {layerParams, options});
101
+
102
+ expect(layer).toBeInstanceOf(VectorLayer);
103
+ expect(layer.get("id")).toEqual("id");
104
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
105
+ expect(layer.getStyleFunction()).toBeDefined();
106
+ expect(layer.getStyleFunction()).toEqual(styleFunction);
107
+ expect(layer.get("name")).toEqual("name");
108
+ expect(layer.get("layers")).toEqual("layer1, layer2");
109
+ });
110
+ });
111
+ describe("createLayerSource", function () {
112
+ const consoleError = console.error;
113
+
114
+ beforeEach(() => {
115
+ if (global.fetch) {
116
+ global.fetch.mockClear();
117
+ }
118
+ });
119
+ // to reset show error on load in console
120
+ afterEach(() => {
121
+ console.error = consoleError;
122
+ });
123
+ it("creates a VectorSource and beforeLoading, afterLoading and featuresFilter are called", function () {
124
+ global.fetch = jest.fn().mockImplementationOnce(() => {
125
+ return new Promise((resolve) => {
126
+ resolve({
127
+ ok: true,
128
+ status: 200,
129
+ text: () => {
130
+ return featureCollection;
131
+ }
132
+ });
133
+ });
134
+ });
135
+
136
+ const map2D = map.createMap(defaults),
137
+ url = "https://url.de",
138
+ rawLayer = {
139
+ id: "id",
140
+ url: url,
141
+ featureNS: "http://www.deegree.org/app",
142
+ featureType: "krankenhaeuser_hh",
143
+ version: "2.0.0"
144
+ },
145
+ beforeLoadingMock = jest.fn(),
146
+ afterLoadingMock = jest.fn(),
147
+ featuresFilterMock = jest.fn((features) => features),
148
+ // jest.fn().mockReturnValueOnce(10),
149
+ options = {
150
+ beforeLoading: beforeLoadingMock,
151
+ afterLoading: afterLoadingMock,
152
+ featuresFilter: featuresFilterMock
153
+ },
154
+ layer = wfs.createLayer(rawLayer, {options});
155
+
156
+ layer.getSource().loadFeatures([-10000, -10000, 10000, 10000],
157
+ 1,
158
+ map2D.getView().getProjection());
159
+
160
+ expect(layer).toBeInstanceOf(VectorLayer);
161
+ expect(layer.get("id")).toEqual("id");
162
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
163
+ expect(layer.getSource().getFormat()).toBeInstanceOf(WFS);
164
+ // eslint-disable-next-line no-underscore-dangle
165
+ expect(typeof layer.getSource().loader_).toEqual("function");
166
+ expect(beforeLoadingMock.mock.calls.length).toBe(1);
167
+
168
+ layer.getSource().on("featuresloadend", function () {
169
+ expect(featuresFilterMock.mock.calls.length).toBe(1);
170
+ expect(afterLoadingMock.mock.calls.length).toBe(1);
171
+ });
172
+ });
173
+ it("creates a VectorSource with doNotLoadInitially", function () {
174
+ global.fetch = jest.fn().mockImplementationOnce(() => {
175
+ return new Promise((resolve) => {
176
+ resolve({
177
+ ok: true,
178
+ status: 200,
179
+ text: () => {
180
+ return featureCollection;
181
+ }
182
+ });
183
+ });
184
+ });
185
+
186
+ const map2D = map.createMap(defaults),
187
+ url = "https://url.de",
188
+ rawLayer = {
189
+ id: "id",
190
+ url: url,
191
+ featureNS: "http://www.deegree.org/app",
192
+ featureType: "krankenhaeuser_hh",
193
+ version: "2.0.0"
194
+ },
195
+ beforeLoadingMock = jest.fn(),
196
+ afterLoadingMock = jest.fn(),
197
+ featuresFilterMock = jest.fn((features) => features),
198
+ // jest.fn().mockReturnValueOnce(10),
199
+ options = {
200
+ doNotLoadInitially: true,
201
+ beforeLoading: beforeLoadingMock,
202
+ afterLoading: afterLoadingMock,
203
+ featuresFilter: featuresFilterMock
204
+ },
205
+ layer = wfs.createLayer(rawLayer, {options});
206
+
207
+ layer.getSource().loadFeatures([-10000, -10000, 10000, 10000],
208
+ 1,
209
+ map2D.getView().getProjection());
210
+
211
+ expect(layer).toBeInstanceOf(VectorLayer);
212
+ expect(layer.get("id")).toEqual("id");
213
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
214
+ expect(layer.getSource().getFormat()).toBeInstanceOf(WFS);
215
+ // eslint-disable-next-line no-underscore-dangle
216
+ expect(typeof layer.getSource().loader_).toEqual("function");
217
+ expect(beforeLoadingMock.mock.calls.length).toBe(1);
218
+
219
+ layer.getSource().on("featuresloadend", function () {
220
+ expect(featuresFilterMock.mock.calls.length).toBe(1);
221
+ expect(afterLoadingMock.mock.calls.length).toBe(1);
222
+ });
223
+ });
224
+ it("creates a VectorSource with wfsFilter", function () {
225
+ let secondFetchCalled = false;
226
+
227
+ global.fetch = jest.fn().mockImplementationOnce(() => {
228
+ return new Promise((resolve) => {
229
+ resolve({
230
+ ok: true,
231
+ status: 200,
232
+ text: () => {
233
+ return wfsFilterQuery;
234
+ }
235
+ });
236
+ });
237
+ }).mockImplementationOnce(() => {
238
+ return new Promise((resolve) => {
239
+ resolve({
240
+ ok: true,
241
+ status: 200,
242
+ text: () => {
243
+ secondFetchCalled = true;
244
+ return featureCollection;
245
+ }
246
+ });
247
+ });
248
+ });
249
+
250
+ const map2D = map.createMap(defaults),
251
+ url = "https://url.de",
252
+ rawLayer = {
253
+ id: "id",
254
+ url: url,
255
+ featureNS: "http://www.deegree.org/app",
256
+ featureType: "krankenhaeuser_hh",
257
+ version: "1.0.0"
258
+ },
259
+ beforeLoadingMock = jest.fn(),
260
+ afterLoadingMock = jest.fn(),
261
+ featuresFilterMock = jest.fn((features) => features),
262
+ options = {
263
+ wfsFilter: "resources/xml/schulstandort.staatlich.1-4.grundschulen.xml",
264
+ beforeLoading: beforeLoadingMock,
265
+ afterLoading: afterLoadingMock,
266
+ featuresFilter: featuresFilterMock
267
+ },
268
+ layer = wfs.createLayer(rawLayer, {options});
269
+
270
+ layer.getSource().loadFeatures([-10000, -10000, 10000, 10000],
271
+ 1,
272
+ map2D.getView().getProjection());
273
+
274
+ expect(layer).toBeInstanceOf(VectorLayer);
275
+ expect(layer.get("id")).toEqual("id");
276
+
277
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
278
+ expect(layer.getSource().getFormat()).toBeInstanceOf(WFS);
279
+ // eslint-disable-next-line no-underscore-dangle
280
+ expect(typeof layer.getSource().loader_).toEqual("function");
281
+ expect(beforeLoadingMock.mock.calls.length).toBe(1);
282
+ layer.getSource().on("featuresloadend", function () {
283
+ expect(secondFetchCalled).toEqual(true);
284
+ expect(featuresFilterMock.mock.calls.length).toBe(1);
285
+ expect(afterLoadingMock.mock.calls.length).toBe(1);
286
+ });
287
+ });
288
+ it("creates a VectorSource and onLoadingError is called", function () {
289
+ global.fetch = jest.fn().mockImplementationOnce(() => {
290
+ // NOTE: fetch only rejects if a network error occurs, which do not apply to 4xx or 5xx http codes.
291
+ return new Promise((resolve) => {
292
+ resolve({
293
+ ok: false,
294
+ status: 404,
295
+ text: () => {
296
+ return null;
297
+ }
298
+ });
299
+ });
300
+ });
301
+ // to reset show error on load in console when testing 'onLoadingError'
302
+ console.error = jest.fn();
303
+
304
+ const map2D = map.createMap(defaults),
305
+ url = "https://url.de",
306
+ rawLayer = {
307
+ id: "id",
308
+ url: url,
309
+ featureNS: "http://www.deegree.org/app",
310
+ featureType: "krankenhaeuser_hh",
311
+ version: "2.0.0"
312
+ },
313
+ onLoadingErrorMock = jest.fn(),
314
+ options = {
315
+ onLoadingError: onLoadingErrorMock
316
+ },
317
+ layer = wfs.createLayer(rawLayer, {options});
318
+
319
+ layer.getSource().loadFeatures([-10000, -10000, 10000, 10000],
320
+ 1,
321
+ map2D.getView().getProjection());
322
+
323
+ expect(layer).toBeInstanceOf(VectorLayer);
324
+ expect(layer.get("id")).toEqual("id");
325
+ expect(layer.getSource()).toBeInstanceOf(VectorSource);
326
+ expect(layer.getSource().getFormat()).toBeInstanceOf(WFS);
327
+ // eslint-disable-next-line no-underscore-dangle
328
+ expect(typeof layer.getSource().loader_).toEqual("function");
329
+ layer.getSource().on("featuresloaderror", function () {
330
+ expect(onLoadingErrorMock.mock.calls.length).toBe(2);
331
+ });
332
+ });
333
+ it("creates a clustered VectorSource and beforeLoading, afterLoading and featuresFilter are called", function () {
334
+ global.fetch = jest.fn().mockImplementationOnce(() => {
335
+ return new Promise((resolve) => {
336
+ resolve({
337
+ ok: true,
338
+ status: 200,
339
+ text: () => {
340
+ return featureCollection;
341
+ }
342
+ });
343
+ });
344
+ });
345
+
346
+ const map2D = map.createMap(defaults),
347
+ url = "https://url.de",
348
+ rawLayer = {
349
+ id: "id",
350
+ url: url,
351
+ featureNS: "http://www.deegree.org/app",
352
+ featureType: "krankenhaeuser_hh",
353
+ clusterDistance: 60,
354
+ version: "1.1.0"
355
+ },
356
+ beforeLoadingMock = jest.fn(),
357
+ afterLoadingMock = jest.fn(),
358
+ featuresFilterMock = jest.fn((features) => features),
359
+ clusterGeometryFunctionMock = jest.fn(),
360
+ options = {
361
+ beforeLoading: beforeLoadingMock,
362
+ afterLoading: afterLoadingMock,
363
+ featuresFilter: featuresFilterMock,
364
+ clusterGeometryFunction: clusterGeometryFunctionMock
365
+ },
366
+ layer = wfs.createLayer(rawLayer, {options});
367
+
368
+ layer.getSource().loadFeatures([-10000, -10000, 10000, 10000],
369
+ 1,
370
+ map2D.getView().getProjection());
371
+
372
+ expect(layer).toBeInstanceOf(VectorLayer);
373
+ expect(layer.get("id")).toEqual("id");
374
+ expect(layer.getSource()).toBeInstanceOf(Cluster);
375
+ expect(layer.getSource().getDistance()).toEqual(60);
376
+ expect(layer.getSource().getSource().getFormat()).toBeInstanceOf(WFS);
377
+ // eslint-disable-next-line no-underscore-dangle
378
+ expect(typeof layer.getSource().loader_).toEqual("function");
379
+ expect(beforeLoadingMock.mock.calls.length).toBe(1);
380
+ layer.getSource().on("featuresloadend", function () {
381
+ expect(clusterGeometryFunctionMock.mock.calls.length).toBe(1);
382
+ expect(featuresFilterMock.mock.calls.length).toBe(1);
383
+ expect(afterLoadingMock.mock.calls.length).toBe(1);
384
+ });
385
+ });
386
+ });
387
+ });
388
+