@masterportal/masterportalapi 2.10.0 → 2.11.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 CHANGED
@@ -3,45 +3,28 @@
3
3
 
4
4
  The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
5
5
 
6
- ## Unreleased - in development
6
+ ## 2.11.0 - 2022-11-24
7
7
  ### Added
8
-
9
- ### Changed
10
-
11
- ### Deprecated
12
-
13
- ### Removed
8
+ - crossOrigin settings can now be passed to WMSSources (TileWMS, ImageWMS) via config.json or services.json
14
9
 
15
10
  ### Fixed
11
+ - Issue #847(Masterportal): searchAddress now keeps searching for house numbers if a digit was entered at the end of the search string
16
12
 
17
13
  ---
18
- ## 2.10.0 - 2022-03-11
14
+
15
+ ## 2.10.0 - 2022-11-03
19
16
  ### Added
20
17
  - DPS-1313: Added custom DragPan interaction to add ability to use 2-Finger-Pan instead of 1-Finger-Pan on mobile devices
21
18
 
22
19
  ### Changed
23
20
  - Exports in src/rawLayerList, src/crs.js and src/lib/load3DScript.js changed to export default {} to provide ES-Syntax.
24
21
 
25
- ### Deprecated
26
-
27
- ### Removed
28
-
29
- ### Fixed
30
-
31
22
  ---
32
23
 
33
24
  ## 2.9.0 - 2022-10-25
34
- ### Added
35
-
36
25
  ### Changed
37
26
  - Exports in src/rawLayerList and src/crs.js changed to module.exports to provide the possibility to stub the functions with sinon in masterportal.
38
27
 
39
- ### Deprecated
40
-
41
- ### Removed
42
-
43
- ### Fixed
44
-
45
28
  ---
46
29
 
47
30
  ## 2.8.0 - 2022-10-04
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.10.0",
4
+ "version": "2.11.0",
5
5
  "license": "MIT",
6
6
  "description": "Basic functions of the Masterportal as api",
7
7
  "repository": {
@@ -53,6 +53,7 @@
53
53
  },
54
54
  "homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
55
55
  "directories": {
56
+ "doc": "docs",
56
57
  "example": "example",
57
58
  "test": "test"
58
59
  },
package/src/layer/wms.js CHANGED
@@ -82,6 +82,7 @@ export function makeParams (rawLayer) {
82
82
  * @param {string} [rawLayer.gutter] - optional the size in pixels of the gutter around image tiles to ignore
83
83
  * @param {function} [rawLayer.olAttribution] - optional function that takes a module:ol/Map~FrameState and returns a string or an array of strings representing source attributions
84
84
  * @param {string|number} [rawLayer.tilesize] - optional needed to create the tileGrid
85
+ * @param {string|"anonymous"} [rawLayer.crossOrigin] - optional needed for CORS requests of image data, to enable canvas export
85
86
  * @param {object} options - optional resolutions and origin to create the TileGrid
86
87
  * @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
87
88
  * @param {Array} [options.origin] - optional origin to create the TileGrid
@@ -99,7 +100,8 @@ export function createLayerSource (rawLayer, options) {
99
100
  params,
100
101
  serverType: rawLayer.serverType,
101
102
  projection: projection,
102
- attributions: rawLayer.olAttribution
103
+ attributions: rawLayer.olAttribution,
104
+ crossOrigin: rawLayer.crossOrigin
103
105
  });
104
106
  }
105
107
  if (options && options.resolutions) {
@@ -115,7 +117,8 @@ export function createLayerSource (rawLayer, options) {
115
117
  gutter: rawLayer.gutter || 0,
116
118
  tileGrid: tileGrid,
117
119
  projection: projection,
118
- attributions: rawLayer.olAttribution
120
+ attributions: rawLayer.olAttribution,
121
+ crossOrigin: rawLayer.crossOrigin
119
122
  });
120
123
  }
121
124
 
@@ -130,6 +133,7 @@ export function createLayerSource (rawLayer, options) {
130
133
  * @param {string} [rawLayer.gutter] - optional the size in pixels of the gutter around image tiles to ignore
131
134
  * @param {function} [rawLayer.olAttribution] - optional function that takes a module:ol/Map~FrameState and returns a string or an array of strings representing source attributions
132
135
  * @param {string|number} [rawLayer.tilesize] - optional needed to create the tileGrid
136
+ * @param {string|"anonymous"} [rawLayer.crossOrigin] - optional needed for CORS requests of image data, to enable canvas export
133
137
  * @param {object} layerParams - additional layer params
134
138
  * @param {object} options - optional resolutions and origin to create the TileGrid
135
139
  * @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
@@ -10,16 +10,19 @@ let abortController = null;
10
10
  * Chains gazetteer request and response parser.
11
11
  * @param {string} type from searchTypes
12
12
  * @param {(string|string[])} values one or multiple strings, depending on type
13
+ * @param {function} sortFunction a function with two parameters which can be used to sort all results
14
+ * @param {function} filterFunction a function which will be executed to filter results
13
15
  * @returns {Promise<SearchResult[]>} parsed response
14
16
  * @ignore
15
17
  */
16
- function searchAndParse (type, values) {
18
+ function searchAndParse (type, values, sortFunction = (a, b) => a.name.localeCompare(b.name), filterFunction = () => true) {
17
19
  return new Promise((resolve, reject) => {
18
20
  searchGazetteer(type, values, abortController)
19
21
  .then(results => {
20
- const parsed = parse(type, results);
21
-
22
- resolve(parsed);
22
+ parse(type, results).then(parsed => {
23
+ resolve(parsed.filter(filterFunction)
24
+ .sort(sortFunction));
25
+ });
23
26
  })
24
27
  .catch(e => reject(e));
25
28
  });
@@ -38,7 +41,8 @@ function searchAndParseStreetAndHouseNumber (searchstring, searchHouseNumbers) {
38
41
  searchGazetteer(searchTypes.STREET, searchstring, abortController)
39
42
  .then(streetResults => parse(searchTypes.STREET, streetResults))
40
43
  .then(parsedStreetResults => {
41
- const allSearches = [];
44
+ const allSearches = [],
45
+ matches = searchstring.match(new RegExp("^(.+)[\\s,](\\d+|\\d.*)$"));
42
46
 
43
47
  for (let i = 0; i < parsedStreetResults.length; i++) {
44
48
  // put street in front of street's street+hnr as ordering
@@ -48,6 +52,13 @@ function searchAndParseStreetAndHouseNumber (searchstring, searchHouseNumbers) {
48
52
  }
49
53
  }
50
54
 
55
+ if (!parsedStreetResults.length && matches?.length && searchHouseNumbers) {
56
+ allSearches.push(searchAndParse(searchTypes.HOUSE_NUMBERS_FOR_STREET,
57
+ matches[1],
58
+ (a, b) => parseInt(a.properties?.hausnummer, 10) - parseInt(b.properties?.hausnummer, 10),
59
+ item => item.properties?.hausnummerkomplett?.indexOf(matches[2]) === 0)); // check longer housenumbers and suffixes!
60
+ }
61
+
51
62
  return Promise.all(allSearches);
52
63
  })
53
64
  .then(allResults => resolve([].concat(...allResults)))
@@ -111,6 +111,16 @@ describe("wms.js", function () {
111
111
 
112
112
  expect(source).toBeInstanceOf(ImageWMS);
113
113
  });
114
+ it("creates a LayerSource with crossOrigin set to 'anonymous'", function () {
115
+ // only relevant for TileWMS and ImageWMS instances
116
+ const
117
+ tileWMS = wms.createLayerSource({singleTile: false, crossOrigin: "anonymous"}),
118
+ imageWMS = wms.createLayerSource({singleTile: true, crossOrigin: "anonymous"});
119
+
120
+ // eslint-disable-next-line no-underscore-dangle
121
+ expect(imageWMS.crossOrigin_).toEqual("anonymous");
122
+ expect(tileWMS.crossOrigin).toEqual("anonymous");
123
+ });
114
124
  });
115
125
  describe("createLayerSource with a tileGrid", function () {
116
126
  function attrFunction () {