@masterportal/masterportalapi 2.39.0 → 2.40.0
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/CHANGELOG.md +18 -2
- package/example/config/services.json +2 -1
- package/package.json +1 -1
- package/src/layer/oaf.js +60 -38
- package/src/rawLayerList.js +19 -22
- package/src/vectorStyle/styleList.js +21 -0
- package/src/vectorStyle/styles/defaultStyles.js +11 -0
- package/test/layer/oaf.test.js +90 -10
- package/test/layer/wfs.test.js +8 -8
- package/test/searchAddress/search.test.js +1 -1
- package/src/lib/oafUtil.js +0 -22
- package/tall +0 -59
- package/test/lib/oafUtil.test.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -17,13 +17,29 @@
|
|
|
17
17
|
### Fixed
|
|
18
18
|
|
|
19
19
|
---
|
|
20
|
+
|
|
21
|
+
## 2.40.0 - 2024-07-17
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- vectorStyle: enables support for additional polygon highlighting, including default styles.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- Replace `XMLHttpRequest` with `fetch` in `initializeLayerList`
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- OAF-Layer: bbox and bboxCrs are respected when building url.
|
|
31
|
+
- OAF-Layer: prevent url to not use more than one questionmark.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
20
35
|
## 2.39.0 - 2024-06-18
|
|
21
36
|
|
|
22
37
|
### Changed
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
- peerDependencies:
|
|
39
|
+
- @cesium/engine: 6.2.0 to 9.2.0
|
|
25
40
|
|
|
26
41
|
---
|
|
42
|
+
|
|
27
43
|
## 2.38.0 - 2024-06-04
|
|
28
44
|
|
|
29
45
|
### Added
|
|
@@ -105,7 +105,8 @@
|
|
|
105
105
|
"url": "https://api.hamburg.de/datasets/v1/schulen",
|
|
106
106
|
"collection": "staatliche_schulen",
|
|
107
107
|
"typ": "OAF",
|
|
108
|
-
"crs": "http://www.opengis.net/def/crs/EPSG/0/25832"
|
|
108
|
+
"crs": "http://www.opengis.net/def/crs/EPSG/0/25832",
|
|
109
|
+
"bboxCrs": "http://www.opengis.net/def/crs/EPSG/0/25832"
|
|
109
110
|
},
|
|
110
111
|
{
|
|
111
112
|
"id": "8712",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterportal/masterportalapi",
|
|
3
3
|
"author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.40.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Basic functions of the Masterportal as api",
|
|
7
7
|
"repository": {
|
package/src/layer/oaf.js
CHANGED
|
@@ -3,7 +3,6 @@ import {bbox} from "ol/loadingstrategy.js";
|
|
|
3
3
|
import GeoJSON from "ol/format/GeoJSON.js";
|
|
4
4
|
import {createVectorSource, createClusterVectorSource} from "./vector";
|
|
5
5
|
import {onError, onLoad} from "../lib/wfsUtil";
|
|
6
|
-
import {getParamsUrl} from "../lib/oafUtil";
|
|
7
6
|
import * as webgl from "../renderer/webgl";
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -110,20 +109,75 @@ function loadSource (url, source, {onErrorFn, success, failure}, options, collec
|
|
|
110
109
|
});
|
|
111
110
|
}
|
|
112
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Creates the url for OAF request.
|
|
114
|
+
* @param {rawLayer} rawLayer layer specification as in services.json
|
|
115
|
+
* @param {object} loadingParams added as params to url
|
|
116
|
+
* @param {number[]} [extent] the current viewport extent
|
|
117
|
+
* @returns {string} the url
|
|
118
|
+
*/
|
|
119
|
+
export function createUrl (rawLayer, loadingParams) {
|
|
120
|
+
const bboxParam = loadingParams?.bbox || rawLayer.bbox,
|
|
121
|
+
rawUrl = rawLayer.url;
|
|
122
|
+
let bboxValue = typeof bboxParam === "string" && bboxParam.length ? bboxParam : null,
|
|
123
|
+
url = null;
|
|
124
|
+
|
|
125
|
+
url = new URL(rawUrl);
|
|
126
|
+
if (typeof rawLayer.collection === "string") {
|
|
127
|
+
if (!url.pathname.endsWith("/")) {
|
|
128
|
+
url.pathname += "/collections/" + rawLayer.collection + "/items";
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
url.pathname = "collections/" + rawLayer.collection + "/items";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
if (typeof rawLayer.limit === "number") {
|
|
136
|
+
url.searchParams.set("limit", rawLayer.limit);
|
|
137
|
+
}
|
|
138
|
+
if (Array.isArray(bboxParam) && bboxParam.length === 4) {
|
|
139
|
+
bboxValue = bboxParam.join(",");
|
|
140
|
+
}
|
|
141
|
+
if (bboxValue) {
|
|
142
|
+
url.searchParams.set("bbox", bboxParam);
|
|
143
|
+
if (typeof rawLayer.bboxCrs === "string" && rawLayer.bboxCrs !== "") {
|
|
144
|
+
url.searchParams.set("bbox-crs", rawLayer.bboxCrs);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (typeof rawLayer.crs === "string") {
|
|
148
|
+
url.searchParams.set("crs", rawLayer.crs);
|
|
149
|
+
}
|
|
150
|
+
if (typeof rawLayer.datetime === "string" && rawLayer.datetime !== "") {
|
|
151
|
+
url.searchParams.set("datetime", rawLayer.datetime);
|
|
152
|
+
}
|
|
153
|
+
if (typeof rawLayer.params === "object" && Object.keys(rawLayer.params).length) {
|
|
154
|
+
Object.entries(rawLayer.params).forEach(([key, value]) => {
|
|
155
|
+
url.searchParams.set(key, value);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return url;
|
|
160
|
+
}
|
|
161
|
+
|
|
113
162
|
/**
|
|
114
163
|
* Creates an ol/source element for the rawLayer by using a loader.
|
|
115
164
|
* The 'featuresloadend' and 'featuresloaderror' events will be fired by using success and failure callbacks of the loader.
|
|
116
165
|
* @param {rawLayer} rawLayer layer specification as in services.json
|
|
117
166
|
* @param {options} [options] additional options
|
|
118
|
-
* @param {String} url the parsed url
|
|
119
167
|
* {@link https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html failure/success see}
|
|
120
168
|
* @returns {(ol.source.VectorSource|ol.source.Cluster)} VectorSource or Cluster, depending on whether clusterDistance is set.
|
|
121
169
|
*/
|
|
122
|
-
function getLayerSource (rawLayer, options
|
|
170
|
+
function getLayerSource (rawLayer, options) {
|
|
123
171
|
const format = new GeoJSON();
|
|
124
172
|
let source = null;
|
|
125
173
|
|
|
126
|
-
function loader (extent,
|
|
174
|
+
function loader (extent, _, __, success, failure) {
|
|
175
|
+
const bboxParam = options.loadingStrategy === bbox ? extent : options.loadingParams.bbox,
|
|
176
|
+
url = createUrl(rawLayer, {
|
|
177
|
+
...options.loadingParams,
|
|
178
|
+
bbox: bboxParam
|
|
179
|
+
});
|
|
180
|
+
|
|
127
181
|
loadSource(url, source, {onErrorFn: onError, success, failure}, options);
|
|
128
182
|
}
|
|
129
183
|
source = createVectorSource(loader, options.loadingStrategy, format);
|
|
@@ -138,36 +192,6 @@ function getLayerSource (rawLayer, options, url) {
|
|
|
138
192
|
return source;
|
|
139
193
|
}
|
|
140
194
|
|
|
141
|
-
/**
|
|
142
|
-
* Creates the url for OAF request.
|
|
143
|
-
* @param {rawLayer} rawLayer layer specification as in services.json
|
|
144
|
-
* @returns {string} the url
|
|
145
|
-
*/
|
|
146
|
-
function createUrl (rawLayer) {
|
|
147
|
-
let url = rawLayer.url,
|
|
148
|
-
appendingString;
|
|
149
|
-
const crsDefault = "";
|
|
150
|
-
|
|
151
|
-
url += typeof rawLayer.collection === "string" ? "/collections/" + rawLayer.collection + "/items?" : "";
|
|
152
|
-
url += typeof rawLayer.limit === "number" ? "limit=" + rawLayer.limit + "&" : "";
|
|
153
|
-
if (Array.isArray(rawLayer.bbox) && rawLayer.bbox.length === 4) {
|
|
154
|
-
appendingString = "";
|
|
155
|
-
|
|
156
|
-
rawLayer.bbox.forEach((bboxEntry, i) => {
|
|
157
|
-
appendingString += i !== rawLayer.bbox.length - 1 ? bboxEntry + "," : bboxEntry;
|
|
158
|
-
});
|
|
159
|
-
url += "bbox=" + appendingString + "&";
|
|
160
|
-
}
|
|
161
|
-
url += typeof rawLayer.bboxCrs === "string" && rawLayer.bboxCrs !== "" ? "bbox-crs=" + encodeURIComponent(rawLayer.bboxCrs) + "&" : "";
|
|
162
|
-
if (rawLayer.crs !== false) {
|
|
163
|
-
url += "crs=" + encodeURIComponent(typeof rawLayer.crs === "string" && rawLayer.crs !== "" ? rawLayer.crs : crsDefault) + "&";
|
|
164
|
-
}
|
|
165
|
-
url += typeof rawLayer.datetime === "string" && rawLayer.datetime !== "" ? "datetime=" + rawLayer.datetime + "&" : "";
|
|
166
|
-
url += getParamsUrl(rawLayer.params);
|
|
167
|
-
|
|
168
|
-
return url;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
195
|
/**
|
|
172
196
|
* Creates an ol/source element for the rawLayer by OAF (XML or Geojson)
|
|
173
197
|
* @param {rawLayer} rawLayer layer specification as in services.json
|
|
@@ -182,9 +206,7 @@ function createLayerSource (rawLayer, options = {}) {
|
|
|
182
206
|
if (!options.loadingStrategy) {
|
|
183
207
|
options.loadingStrategy = bbox;
|
|
184
208
|
}
|
|
185
|
-
|
|
186
|
-
const url = createUrl(rawLayer),
|
|
187
|
-
source = getLayerSource(rawLayer, options, url);
|
|
209
|
+
const source = getLayerSource(rawLayer, options);
|
|
188
210
|
|
|
189
211
|
if (rawLayer.renderer === "webgl") {
|
|
190
212
|
source.once("featuresloadend", event => {
|
|
@@ -261,4 +283,4 @@ function loadFeaturesManually (layerAttributes, layerSource) {
|
|
|
261
283
|
});
|
|
262
284
|
}
|
|
263
285
|
|
|
264
|
-
export default {createLayer, createLayerSource, loadFeaturesManually};
|
|
286
|
+
export default {createLayer, createLayerSource, createUrl, loadFeaturesManually};
|
package/src/rawLayerList.js
CHANGED
|
@@ -26,28 +26,25 @@ function initializeLayerList (layerConf = defaults.layerConf, callback) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// case: parameter is URL
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.error("An error occured when trying to fetch services from '" + layerConf + "':", e);
|
|
49
|
-
callback(false, e);
|
|
50
|
-
};
|
|
29
|
+
fetch(layerConf, {method: "GET", timeout: 10000})
|
|
30
|
+
.then((response) => {
|
|
31
|
+
response.json()
|
|
32
|
+
.then((json) => {
|
|
33
|
+
layerList = json;
|
|
34
|
+
if (typeof callback === "function") {
|
|
35
|
+
return callback(layerList);
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
})
|
|
39
|
+
.catch((error) => {
|
|
40
|
+
console.error("An error occured when parsing the response after loading '" + layerConf + "':", error);
|
|
41
|
+
return callback(false, error);
|
|
42
|
+
});
|
|
43
|
+
})
|
|
44
|
+
.catch((error) => {
|
|
45
|
+
console.error("An error occured when trying to fetch services from '" + layerConf + "':", error);
|
|
46
|
+
callback(false, error);
|
|
47
|
+
});
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
/**
|
|
@@ -14,6 +14,7 @@ let styleList,
|
|
|
14
14
|
configuredTools,
|
|
15
15
|
mapMarkerPointStyleId,
|
|
16
16
|
mapMarkerPolygonStyleId,
|
|
17
|
+
additionalPolygonStyleId,
|
|
17
18
|
highlightFeaturesPointStyleId,
|
|
18
19
|
highlightFeaturesPolygonStyleId,
|
|
19
20
|
highlightFeaturesLineStyleId,
|
|
@@ -140,6 +141,23 @@ function getStyleIdForMapMarkerPolygon () {
|
|
|
140
141
|
return styleId;
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Gets the style id for an additional MapMarker.
|
|
146
|
+
* If the additionalPolygonStyleId exists, return it; otherwise, returns the default styleId.
|
|
147
|
+
* @returns {String} - The styleId of the additional MapMarker
|
|
148
|
+
*/
|
|
149
|
+
function getStyleIdForAdditionalMapMarkerPolygon () {
|
|
150
|
+
let styleId;
|
|
151
|
+
|
|
152
|
+
if (additionalPolygonStyleId) {
|
|
153
|
+
styleId = additionalPolygonStyleId;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
styleId = "defaultAdditionalMapMarkerPolygon";
|
|
157
|
+
}
|
|
158
|
+
return styleId;
|
|
159
|
+
}
|
|
160
|
+
|
|
143
161
|
/**
|
|
144
162
|
* gets style id from HighlightFeatures
|
|
145
163
|
* @returns {String} - Style id of highlightFeatures.
|
|
@@ -186,6 +204,7 @@ function parseStyles (data) {
|
|
|
186
204
|
dataWithDefaultValue.push({styleId: "default", rules: [{style: {}}]},
|
|
187
205
|
defaultStyle.defaultMapMarkerPoint,
|
|
188
206
|
defaultStyle.defaultMapMarkerPolygon,
|
|
207
|
+
defaultStyle.defaultAdditionalMapMarkerPolygon,
|
|
189
208
|
defaultStyle.defaultHighlightFeaturesPoint,
|
|
190
209
|
defaultStyle.defaultHighlightFeaturesPolygon,
|
|
191
210
|
defaultStyle.defaultHighlightFeaturesLine);
|
|
@@ -193,6 +212,7 @@ function parseStyles (data) {
|
|
|
193
212
|
styleIds.push(getStyleIdsFromLayers(),
|
|
194
213
|
getStyleIdForMapMarkerPoint(),
|
|
195
214
|
getStyleIdForMapMarkerPolygon(),
|
|
215
|
+
getStyleIdForAdditionalMapMarkerPolygon(),
|
|
196
216
|
getStyleIdForHighlightFeaturesPoint(),
|
|
197
217
|
getStyleIdForHighlightFeaturesPolygon(),
|
|
198
218
|
getStyleIdForHighlightFeaturesLine(),
|
|
@@ -222,6 +242,7 @@ async function initializeStyleList (styleGetters, Config, layers, tools, callbac
|
|
|
222
242
|
|
|
223
243
|
mapMarkerPointStyleId = styleGetters.mapMarkerPointStyleId;
|
|
224
244
|
mapMarkerPolygonStyleId = styleGetters.mapMarkerPolygonStyleId;
|
|
245
|
+
additionalPolygonStyleId = styleGetters.additionalPolygonStyleId;
|
|
225
246
|
highlightFeaturesPointStyleId = styleGetters.highlightFeaturesPointStyleId;
|
|
226
247
|
highlightFeaturesPolygonStyleId = styleGetters.highlightFeaturesPolygonStyleId;
|
|
227
248
|
highlightFeaturesLineStyleId = styleGetters.highlightFeaturesLineStyleId;
|
|
@@ -137,6 +137,17 @@ const defaultColors = {
|
|
|
137
137
|
}
|
|
138
138
|
}]
|
|
139
139
|
},
|
|
140
|
+
defaultAdditionalMapMarkerPolygon: {
|
|
141
|
+
styleId: "defaultAdditionalMapMarkerPolygon",
|
|
142
|
+
rules: [{
|
|
143
|
+
style: {
|
|
144
|
+
polygonStrokeColor: [255, 255, 0, 1],
|
|
145
|
+
polygonStrokeWidth: 4,
|
|
146
|
+
polygonFillColor: [255, 255, 0, 0.3],
|
|
147
|
+
polygonStrokeDash: [8]
|
|
148
|
+
}
|
|
149
|
+
}]
|
|
150
|
+
},
|
|
140
151
|
defaultHighlightFeaturesPoint: {
|
|
141
152
|
styleId: "defaultHighlightFeaturesPoint",
|
|
142
153
|
rules: [{
|
package/test/layer/oaf.test.js
CHANGED
|
@@ -38,7 +38,7 @@ describe("oaf.js", function () {
|
|
|
38
38
|
const attr = {
|
|
39
39
|
"id": "id",
|
|
40
40
|
"name": "Schulen",
|
|
41
|
-
"url": "https://url
|
|
41
|
+
"url": "https://url",
|
|
42
42
|
"collection": "staatliche_schulen",
|
|
43
43
|
"typ": "OAF",
|
|
44
44
|
"bbox": "",
|
|
@@ -137,7 +137,7 @@ describe("oaf.js", function () {
|
|
|
137
137
|
console.error = consoleError;
|
|
138
138
|
});
|
|
139
139
|
it("creates a GeoJSON VectorSource", function () {
|
|
140
|
-
global.fetch = jest.fn().
|
|
140
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
141
141
|
return new Promise((resolve) => {
|
|
142
142
|
resolve({
|
|
143
143
|
ok: true,
|
|
@@ -153,7 +153,7 @@ describe("oaf.js", function () {
|
|
|
153
153
|
const rawLayer = {
|
|
154
154
|
id: "id",
|
|
155
155
|
name: "Schulen",
|
|
156
|
-
url: "https://url
|
|
156
|
+
url: "https://url",
|
|
157
157
|
collection: "staatliche_schulen",
|
|
158
158
|
typ: "OAF",
|
|
159
159
|
limit: 10,
|
|
@@ -167,7 +167,7 @@ describe("oaf.js", function () {
|
|
|
167
167
|
expect(layer.getSource().getFormat()).toBeInstanceOf(GeoJSON);
|
|
168
168
|
});
|
|
169
169
|
it("creates a VectorSource and onLoadingError is called", function () {
|
|
170
|
-
global.fetch = jest.fn().
|
|
170
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
171
171
|
return new Promise((resolve) => {
|
|
172
172
|
resolve({
|
|
173
173
|
ok: false,
|
|
@@ -184,7 +184,7 @@ describe("oaf.js", function () {
|
|
|
184
184
|
const rawLayer = {
|
|
185
185
|
id: "id",
|
|
186
186
|
name: "Schulen",
|
|
187
|
-
url: "https://url
|
|
187
|
+
url: "https://url",
|
|
188
188
|
collection: "staatliche_schulen",
|
|
189
189
|
typ: "OAF",
|
|
190
190
|
limit: 10,
|
|
@@ -206,7 +206,7 @@ describe("oaf.js", function () {
|
|
|
206
206
|
});
|
|
207
207
|
});
|
|
208
208
|
it("creates a clustered VectorSource and beforeLoading, afterLoading and featuresFilter are called", function () {
|
|
209
|
-
global.fetch = jest.fn().
|
|
209
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
210
210
|
return new Promise((resolve) => {
|
|
211
211
|
resolve({
|
|
212
212
|
ok: true,
|
|
@@ -223,7 +223,7 @@ describe("oaf.js", function () {
|
|
|
223
223
|
rawLayer = {
|
|
224
224
|
id: "id",
|
|
225
225
|
name: "Schulen",
|
|
226
|
-
url: "https://url
|
|
226
|
+
url: "https://url",
|
|
227
227
|
collection: "staatliche_schulen",
|
|
228
228
|
typ: "OAF",
|
|
229
229
|
limit: 10,
|
|
@@ -259,7 +259,7 @@ describe("oaf.js", function () {
|
|
|
259
259
|
});
|
|
260
260
|
it("creates a vectorSource with an additional listener, when renderer is \"webgl\"", () => {
|
|
261
261
|
const
|
|
262
|
-
url = "https://url
|
|
262
|
+
url = "https://url",
|
|
263
263
|
rawLayer = {
|
|
264
264
|
id: "id",
|
|
265
265
|
url: url,
|
|
@@ -290,7 +290,7 @@ describe("oaf.js", function () {
|
|
|
290
290
|
describe("loadFeaturesManually", function () {
|
|
291
291
|
it("loadFeaturesManually shall call fetch", function () {
|
|
292
292
|
console.error = jest.fn();
|
|
293
|
-
global.fetch = jest.fn().
|
|
293
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
294
294
|
return new Promise((resolve) => {
|
|
295
295
|
resolve({
|
|
296
296
|
ok: true,
|
|
@@ -304,7 +304,7 @@ describe("oaf.js", function () {
|
|
|
304
304
|
|
|
305
305
|
const rawLayer = {
|
|
306
306
|
id: "id",
|
|
307
|
-
url: "url",
|
|
307
|
+
url: "https://url",
|
|
308
308
|
featureNS: "http://www.deegree.org/app",
|
|
309
309
|
featureType: "krankenhaeuser_hh",
|
|
310
310
|
version: "1.0.0"
|
|
@@ -317,4 +317,84 @@ describe("oaf.js", function () {
|
|
|
317
317
|
expect(global.fetch.mock.calls.length).toBe(1);
|
|
318
318
|
});
|
|
319
319
|
});
|
|
320
|
+
describe("createUrl", () => {
|
|
321
|
+
it("should append bbox, collection, limit, datetime, bboxCrs, and crs, as provided in rawLayer", () => {
|
|
322
|
+
const rawLayer = {
|
|
323
|
+
id: "id",
|
|
324
|
+
name: "Schulen",
|
|
325
|
+
url: "https://url.de",
|
|
326
|
+
collection: "staatliche_schulen",
|
|
327
|
+
typ: "OAF",
|
|
328
|
+
limit: 10,
|
|
329
|
+
bbox: [0, 0, 10, 10],
|
|
330
|
+
bboxCrs: "EPSG:4326",
|
|
331
|
+
datetime: "123",
|
|
332
|
+
crs: "EPSG:25832"
|
|
333
|
+
},
|
|
334
|
+
loadingParams = undefined,
|
|
335
|
+
createdUrl = oaf.createUrl(rawLayer, loadingParams);
|
|
336
|
+
|
|
337
|
+
expect(createdUrl.origin).toEqual(rawLayer.url);
|
|
338
|
+
expect(createdUrl.pathname).toEqual("/collections/" + rawLayer.collection + "/items");
|
|
339
|
+
expect(createdUrl.searchParams.get("limit")).toEqual("10");
|
|
340
|
+
expect(createdUrl.searchParams.get("bbox")).toEqual("0,0,10,10");
|
|
341
|
+
expect(createdUrl.searchParams.get("bbox-crs")).toEqual(rawLayer.bboxCrs);
|
|
342
|
+
expect(createdUrl.searchParams.get("crs")).toEqual(rawLayer.crs);
|
|
343
|
+
expect(createdUrl.searchParams.get("datetime")).toEqual(rawLayer.datetime);
|
|
344
|
+
});
|
|
345
|
+
it("should append the bbox, if provided as string in rawLayer", () => {
|
|
346
|
+
const rawLayer = {
|
|
347
|
+
id: "id",
|
|
348
|
+
name: "Schulen",
|
|
349
|
+
url: "https://url.de",
|
|
350
|
+
collection: "staatliche_schulen",
|
|
351
|
+
typ: "OAF",
|
|
352
|
+
bbox: "0,0,10,10",
|
|
353
|
+
bboxCrs: "EPSG:4326"
|
|
354
|
+
},
|
|
355
|
+
loadingParams = undefined,
|
|
356
|
+
createdUrl = oaf.createUrl(rawLayer, loadingParams);
|
|
357
|
+
|
|
358
|
+
expect(createdUrl.origin).toEqual(rawLayer.url);
|
|
359
|
+
expect(createdUrl.pathname).toEqual("/collections/" + rawLayer.collection + "/items");
|
|
360
|
+
expect(createdUrl.searchParams.get("bbox")).toEqual("0,0,10,10");
|
|
361
|
+
expect(createdUrl.searchParams.get("bbox-crs")).toEqual(rawLayer.bboxCrs);
|
|
362
|
+
});
|
|
363
|
+
it("should append the bbox, if provided as string in loadingParams", () => {
|
|
364
|
+
const rawLayer = {
|
|
365
|
+
id: "id",
|
|
366
|
+
name: "Schulen",
|
|
367
|
+
url: "https://mapservice.regensburg.de/cgi-bin/mapserv?map=wfs.map",
|
|
368
|
+
collection: "staatliche_schulen",
|
|
369
|
+
typ: "OAF"
|
|
370
|
+
},
|
|
371
|
+
loadingParams = {bbox: "0,0,10,10"},
|
|
372
|
+
createdUrl = oaf.createUrl(rawLayer, loadingParams);
|
|
373
|
+
|
|
374
|
+
expect(createdUrl.origin).toEqual("https://mapservice.regensburg.de");
|
|
375
|
+
expect(createdUrl.pathname).toEqual("/cgi-bin/mapserv/collections/" + rawLayer.collection + "/items");
|
|
376
|
+
expect(createdUrl.searchParams.get("map")).toEqual("wfs.map");
|
|
377
|
+
expect(createdUrl.searchParams.get("bbox")).toEqual("0,0,10,10");
|
|
378
|
+
});
|
|
379
|
+
it("should append additional key:value filters, if provided as in rawLayer.params", () => {
|
|
380
|
+
const rawLayer = {
|
|
381
|
+
id: "id",
|
|
382
|
+
name: "Schulen",
|
|
383
|
+
url: "https://url/",
|
|
384
|
+
collection: "staatliche_schulen",
|
|
385
|
+
typ: "OAF",
|
|
386
|
+
params: {
|
|
387
|
+
kapitelbezeichnung: "Gymnasien",
|
|
388
|
+
anzahl_schueler: ">1000"
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
loadingParams = undefined,
|
|
392
|
+
createdUrl = oaf.createUrl(rawLayer, loadingParams);
|
|
393
|
+
|
|
394
|
+
expect(createdUrl.origin).toEqual("https://url");
|
|
395
|
+
expect(createdUrl.pathname).toEqual("/collections/" + rawLayer.collection + "/items");
|
|
396
|
+
expect(createdUrl.searchParams.get("kapitelbezeichnung")).toEqual("Gymnasien");
|
|
397
|
+
expect(createdUrl.searchParams.get("anzahl_schueler")).toEqual(">1000");
|
|
398
|
+
});
|
|
399
|
+
});
|
|
320
400
|
});
|
package/test/layer/wfs.test.js
CHANGED
|
@@ -152,7 +152,7 @@ describe("wfs.js", function () {
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
it("creates a VectorSource and beforeLoading, afterLoading and featuresFilter are called", function () {
|
|
155
|
-
global.fetch = jest.fn().
|
|
155
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
156
156
|
return new Promise((resolve) => {
|
|
157
157
|
resolve({
|
|
158
158
|
ok: true,
|
|
@@ -202,7 +202,7 @@ describe("wfs.js", function () {
|
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
it("creates a VectorSource with doNotLoadInitially", function () {
|
|
205
|
-
global.fetch = jest.fn().
|
|
205
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
206
206
|
return new Promise((resolve) => {
|
|
207
207
|
resolve({
|
|
208
208
|
ok: true,
|
|
@@ -255,7 +255,7 @@ describe("wfs.js", function () {
|
|
|
255
255
|
it("creates a VectorSource with wfsFilter", function () {
|
|
256
256
|
let secondFetchCalled = false;
|
|
257
257
|
|
|
258
|
-
global.fetch = jest.fn().
|
|
258
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
259
259
|
return new Promise((resolve) => {
|
|
260
260
|
resolve({
|
|
261
261
|
ok: true,
|
|
@@ -265,7 +265,7 @@ describe("wfs.js", function () {
|
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
});
|
|
268
|
-
}).
|
|
268
|
+
}).mockImplementation(() => {
|
|
269
269
|
return new Promise((resolve) => {
|
|
270
270
|
resolve({
|
|
271
271
|
ok: true,
|
|
@@ -317,7 +317,7 @@ describe("wfs.js", function () {
|
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
319
|
it("creates a VectorSource and onLoadingError is called", function () {
|
|
320
|
-
global.fetch = jest.fn().
|
|
320
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
321
321
|
// NOTE: fetch only rejects if a network error occurs, which do not apply to 4xx or 5xx http codes.
|
|
322
322
|
return new Promise((resolve) => {
|
|
323
323
|
resolve({
|
|
@@ -360,7 +360,7 @@ describe("wfs.js", function () {
|
|
|
360
360
|
});
|
|
361
361
|
});
|
|
362
362
|
it("creates a clustered VectorSource and beforeLoading, afterLoading and featuresFilter are called", function () {
|
|
363
|
-
global.fetch = jest.fn().
|
|
363
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
364
364
|
return new Promise((resolve) => {
|
|
365
365
|
resolve({
|
|
366
366
|
ok: true,
|
|
@@ -442,7 +442,7 @@ describe("wfs.js", function () {
|
|
|
442
442
|
expect(webgl.afterLoading).toHaveBeenCalledWith(features, layerParams.styleId, layerParams.excludeTypesFromParsing, layerParams.isPointLayer);
|
|
443
443
|
});
|
|
444
444
|
it("creates a vectorSource with credentials: include as params", () => {
|
|
445
|
-
global.fetch = jest.fn().
|
|
445
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
446
446
|
// NOTE: fetch only rejects if a network error occurs, which do not apply to 4xx or 5xx http codes.
|
|
447
447
|
return new Promise((resolve) => {
|
|
448
448
|
resolve({
|
|
@@ -1068,7 +1068,7 @@ describe("wfs.js", function () {
|
|
|
1068
1068
|
});
|
|
1069
1069
|
|
|
1070
1070
|
it("load features manually", async function () {
|
|
1071
|
-
global.fetch = jest.fn().
|
|
1071
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
1072
1072
|
return new Promise((resolve) => {
|
|
1073
1073
|
resolve({
|
|
1074
1074
|
ok: true,
|
|
@@ -33,7 +33,7 @@ jest.mock("../../src/searchAddress/searchGazetteer", () => {
|
|
|
33
33
|
|
|
34
34
|
import {searchGazetteer as mockedSearchGazetteer} from "../../src/searchAddress/searchGazetteer";
|
|
35
35
|
|
|
36
|
-
describe
|
|
36
|
+
describe("searchAddress", function () {
|
|
37
37
|
describe("search", function () {
|
|
38
38
|
it("rejects if missing configuration of what to search for", function (done) {
|
|
39
39
|
search("Pflugacker", {}).catch(e => {
|
package/src/lib/oafUtil.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parsing the params object in to string for url
|
|
3
|
-
* @param {Object} params the paramters in object
|
|
4
|
-
* @returns {String} The url parameters in string format
|
|
5
|
-
*/
|
|
6
|
-
function getParamsUrl (params) {
|
|
7
|
-
if (!params || typeof params !== "object" || params.constructor !== Object || !Object.keys(params).length) {
|
|
8
|
-
return "";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let paramsUrl = "";
|
|
12
|
-
|
|
13
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
14
|
-
paramsUrl += "&" + key + "=" + value;
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return paramsUrl;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
getParamsUrl
|
|
22
|
-
};
|
package/tall
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
v1.0.0
|
|
2
|
-
v1.1.0
|
|
3
|
-
v1.10.0
|
|
4
|
-
v1.2.0
|
|
5
|
-
v1.3.0
|
|
6
|
-
v1.4.0
|
|
7
|
-
v1.5.0
|
|
8
|
-
v1.6.0
|
|
9
|
-
v1.6.1
|
|
10
|
-
v1.7.0
|
|
11
|
-
v1.7.1
|
|
12
|
-
v1.8.0
|
|
13
|
-
v1.9.0
|
|
14
|
-
v2.0.0
|
|
15
|
-
v2.1.0
|
|
16
|
-
v2.1.1
|
|
17
|
-
v2.10.0
|
|
18
|
-
v2.11.0
|
|
19
|
-
v2.12.0
|
|
20
|
-
v2.13.0
|
|
21
|
-
v2.14.0
|
|
22
|
-
v2.15.0
|
|
23
|
-
v2.15.1
|
|
24
|
-
v2.15.2
|
|
25
|
-
v2.16.0
|
|
26
|
-
v2.17.0
|
|
27
|
-
v2.18.0
|
|
28
|
-
v2.19.0
|
|
29
|
-
v2.19.1
|
|
30
|
-
v2.19.2
|
|
31
|
-
v2.2.0
|
|
32
|
-
v2.20.0
|
|
33
|
-
v2.21.0
|
|
34
|
-
v2.22.0
|
|
35
|
-
v2.23.0
|
|
36
|
-
v2.24.0
|
|
37
|
-
v2.25.0
|
|
38
|
-
v2.26.0
|
|
39
|
-
v2.27.0
|
|
40
|
-
v2.28.0
|
|
41
|
-
v2.29.0
|
|
42
|
-
v2.3.0
|
|
43
|
-
v2.30.0
|
|
44
|
-
v2.31.0
|
|
45
|
-
v2.32.0
|
|
46
|
-
v2.33.0
|
|
47
|
-
v2.34.0
|
|
48
|
-
v2.35.0
|
|
49
|
-
v2.36.0
|
|
50
|
-
v2.37.0
|
|
51
|
-
v2.38.0
|
|
52
|
-
v2.39.0
|
|
53
|
-
v2.4.0
|
|
54
|
-
v2.5.0
|
|
55
|
-
v2.5.1
|
|
56
|
-
v2.6.0
|
|
57
|
-
v2.7.0
|
|
58
|
-
v2.8.0
|
|
59
|
-
v2.9.0
|
package/test/lib/oafUtil.test.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {getParamsUrl} from "../../src/lib/oafUtil";
|
|
2
|
-
|
|
3
|
-
describe("oafUtil.js", function () {
|
|
4
|
-
describe("getParamsUrl", function () {
|
|
5
|
-
const params = {
|
|
6
|
-
"anzahl_schueler": ">1000",
|
|
7
|
-
"bezirk": "Bergedorf"
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
it("should return the parsed paramsUrl", function () {
|
|
11
|
-
expect(getParamsUrl(params)).toEqual("&anzahl_schueler=>1000&bezirk=Bergedorf");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should return an empty string", function () {
|
|
15
|
-
expect(getParamsUrl("string")).toEqual("");
|
|
16
|
-
expect(getParamsUrl(0)).toEqual("");
|
|
17
|
-
expect(getParamsUrl(null)).toEqual("");
|
|
18
|
-
expect(getParamsUrl(undefined)).toEqual("");
|
|
19
|
-
expect(getParamsUrl(true)).toEqual("");
|
|
20
|
-
expect(getParamsUrl([])).toEqual("");
|
|
21
|
-
expect(getParamsUrl({})).toEqual("");
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|