@masterportal/masterportalapi 2.5.1 → 2.7.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,6 +3,33 @@
3
3
 
4
4
  The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
5
5
 
6
+ ## Unreleased - in development
7
+ ### Added
8
+ ### Changed
9
+
10
+ ### Deprecated
11
+
12
+ ### Removed
13
+ ### Fixed
14
+
15
+ ## 2.7.0 - 2022-09-14
16
+ ### Changed
17
+ - The following packages have been updated:
18
+ - dependencies:
19
+ - ol: 6.15.1 to 7.1.0
20
+ - olcs: 2.13.0 to 2.13.1
21
+
22
+ ---
23
+
24
+ ## 2.6.0 - 2022-09-06
25
+ ### Added
26
+ - Added possibility to set initial features for layer vectorBase.
27
+
28
+ ### Changed
29
+ - OAF: Fixed oaf recursion and a possibility to disable the CRS parameter is added.
30
+
31
+ ---
32
+
6
33
  ## 2.5.1 - 2022-08-05
7
34
  ### Fixed
8
35
  - Remove import of `defaultResolutions` for the vectorStyle layer
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.5.1",
4
+ "version": "2.7.0",
5
5
  "license": "MIT",
6
6
  "description": "Basic functions of the Masterportal as api",
7
7
  "repository": {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "core-js": "^3.24.0",
23
- "ol": "6.15.1",
24
- "olcs": "^2.13.0",
23
+ "ol": "7.1.0",
24
+ "olcs": "^2.13.1",
25
25
  "proj4": "^2.8.0",
26
26
  "xml2js": "^0.4.23"
27
27
  },
@@ -53,7 +53,6 @@
53
53
  },
54
54
  "homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
55
55
  "directories": {
56
- "doc": "docs",
57
56
  "example": "example",
58
57
  "test": "test"
59
58
  },
package/src/layer/oaf.js CHANGED
@@ -57,7 +57,8 @@ function getNextLinkFromFeatureCollection (featureCollection) {
57
57
  if (
58
58
  typeof featureCollection.links[i] === "object" && featureCollection.links[i] !== null
59
59
  && typeof featureCollection.links[i].href === "string"
60
- && featureCollection.links[i].title === "next page"
60
+ && featureCollection.links[i].rel === "next"
61
+ && featureCollection.links[i].type === "application/geo+json"
61
62
  ) {
62
63
  return featureCollection.links[i].href;
63
64
  }
@@ -157,7 +158,9 @@ function createUrl (rawLayer) {
157
158
  url += "bbox=" + appendingString + "&";
158
159
  }
159
160
  url += typeof rawLayer.bboxCrs === "string" && rawLayer.bboxCrs !== "" ? "bbox-crs=" + encodeURIComponent(rawLayer.bboxCrs) + "&" : "";
160
- url += "crs=" + encodeURIComponent(typeof rawLayer.crs === "string" && rawLayer.crs !== "" ? rawLayer.crs : crsDefault) + "&";
161
+ if (rawLayer.crs !== false) {
162
+ url += "crs=" + encodeURIComponent(typeof rawLayer.crs === "string" && rawLayer.crs !== "" ? rawLayer.crs : crsDefault) + "&";
163
+ }
161
164
  url += typeof rawLayer.datetime === "string" && rawLayer.datetime !== "" ? "datetime=" + rawLayer.datetime + "&" : "";
162
165
  url += getParamsUrl(rawLayer.params);
163
166
 
@@ -29,8 +29,10 @@ export default function Tileset (rawLayer) {
29
29
  id: rawLayer.id,
30
30
  typ: rawLayer.typ
31
31
  };
32
- this.tileset = createTileSet(rawLayer);
33
- this.tileset.layerReferenceId = rawLayer.id;
32
+ if (Cesium) {
33
+ this.tileset = createTileSet(rawLayer);
34
+ this.tileset.layerReferenceId = rawLayer.id;
35
+ }
34
36
  }
35
37
  /**
36
38
  *
@@ -4,10 +4,13 @@ import VectorSource from "ol/source/Vector.js";
4
4
 
5
5
  /**
6
6
  * Triggered by Layer to create a layerSource
7
+ * @param {Object} attrs attributes of the layer
7
8
  * @returns {void}
8
9
  */
9
- export function createLayerSource () {
10
- return new VectorSource();
10
+ export function createLayerSource (attrs) {
11
+ return new VectorSource({
12
+ features: attrs.features
13
+ });
11
14
  }
12
15
 
13
16
  /**
@@ -27,7 +30,7 @@ export function updateSource (layer, features) {
27
30
  * @returns {Object} layer
28
31
  */
29
32
  export function createLayer (attrs) {
30
- const source = this.createLayerSource();
33
+ const source = this.createLayerSource(attrs);
31
34
 
32
35
  return new VectorLayer({
33
36
  source: source,
@@ -21,7 +21,7 @@ const OL_DEFAULT_VECTOR_TILE_GRID_CRS = "EPSG:3857";
21
21
  * @property {number[]} [extent] - extent
22
22
  * @property {number} [maxZoom=22] - min zoom level
23
23
  * @property {number} [minZoom] - max zoom level
24
- * @property {function} [olAttribution] - optional function that takes a module:ol/PluggableMap~FrameState and returns a string or an array of strings representing source attributions
24
+ * @property {function} [olAttribution] - optional function that takes a module:ol/Map~FrameState and returns a string or an array of strings representing source attributions
25
25
  * @property {number[]} [origin] - The tile grid origin, i.e. where the x and y axes meet ([z, 0, 0]). Tile coordinates increase left to right and downwards
26
26
  * @property {number[][]} [origins] - Tile grid origins, i.e. where the x and y axes meet ([z, 0, 0]), for each zoom level. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different origin. Tile coordinates increase left to right and downwards. If not specified, extent or origin must be provided.
27
27
  * @property {number[]} [resolutions] - Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1.
package/src/layer/wms.js CHANGED
@@ -80,7 +80,7 @@ export function makeParams (rawLayer) {
80
80
  * @param {string} [rawLayer.url] - WMS service URL
81
81
  * @param {string} [rawLayer.serverType] - optional servertype definition: "geoserver" or "mapserver" or "qgis"
82
82
  * @param {string} [rawLayer.gutter] - optional the size in pixels of the gutter around image tiles to ignore
83
- * @param {function} [rawLayer.olAttribution] - optional function that takes a module:ol/PluggableMap~FrameState and returns a string or an array of strings representing source attributions
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
85
  * @param {object} options - optional resolutions and origin to create the TileGrid
86
86
  * @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
@@ -128,7 +128,7 @@ export function createLayerSource (rawLayer, options) {
128
128
  * @param {string} [rawLayer.maxScale] - optional the maximal resolution
129
129
  * @param {string} [rawLayer.serverType] - optional servertype definition: "geoserver" or "mapserver" or "qgis"
130
130
  * @param {string} [rawLayer.gutter] - optional the size in pixels of the gutter around image tiles to ignore
131
- * @param {function} [rawLayer.olAttribution] - optional function that takes a module:ol/PluggableMap~FrameState and returns a string or an array of strings representing source attributions
131
+ * @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
132
  * @param {string|number} [rawLayer.tilesize] - optional needed to create the tileGrid
133
133
  * @param {object} layerParams - additional layer params
134
134
  * @param {object} options - optional resolutions and origin to create the TileGrid
package/src/maps/map.js CHANGED
@@ -20,7 +20,7 @@ export default {
20
20
  * @param {object} [settings={}] - settings object
21
21
  * @param {object} [settings.mapParams] - additional parameter object that is spread into the ol.Map constructor object
22
22
  * @param {function} [settings.callback] - optional callback for layer list loading
23
- * @returns {module:ol/PluggableMap~PluggableMap} The map.
23
+ * @returns {module:ol/Map~Map} The map.
24
24
  */
25
25
  createMap: function (config, mapMode = "2D", settings = {}) {
26
26
  const createMapFunctions = {
@@ -1,4 +1,4 @@
1
- import {Map, PluggableMap} from "ol";
1
+ import {Map} from "ol";
2
2
  import {defaults as olDefaultInteractions} from "ol/interaction.js";
3
3
  import setBackgroundImage from "../../lib/setBackgroundImage";
4
4
  import getInitialLayers from "../../lib/getInitialLayers";
@@ -30,7 +30,7 @@ const layerBuilderMap = {
30
30
  vectortile,
31
31
  oaf
32
32
  },
33
- originalAddLayer = PluggableMap.prototype.addLayer;
33
+ originalAddLayer = Map.prototype.addLayer;
34
34
 
35
35
  /**
36
36
  * Adds a layer to the map, or adds a layer to the map by id.
@@ -73,7 +73,7 @@ function addLayer (layerOrId, params = {visibility: true, transparency: 0}) {
73
73
  return originalAddLayer.call(this, layerOrId);
74
74
  }
75
75
 
76
- PluggableMap.prototype.addLayer = addLayer;
76
+ Map.prototype.addLayer = addLayer;
77
77
 
78
78
  /**
79
79
  * Creates an openlayers map according to configuration. Does not set many default values itself, but uses function that do.
@@ -99,7 +99,7 @@ export function setCameraParameter (params, map3D, cesium) {
99
99
  /**
100
100
  * Creates a 3D-map.
101
101
  * @param {object} [settings] The settings for the 3D-map.
102
- * @param {module:ol/PluggableMap~PluggableMap} [settings.map2D] The 2D-Map
102
+ * @param {module:ol/Map~Map} [settings.map2D] The 2D-Map
103
103
  * @param {Cesium.JulianDate} [settings.shadowTime] The shadow time in julian date format if undefined olcs default is Cesium.JulianDate.now().
104
104
  * @returns {module:OLCesium} the 3d-map
105
105
  */
@@ -1,3 +1,6 @@
1
+ import Feature from "ol/Feature";
2
+ import Point from "ol/geom/Point";
3
+ import Polygon from "ol/geom/Polygon";
1
4
  import VectorLayer from "ol/layer/Vector";
2
5
  import VectorSource from "ol/source/Vector.js";
3
6
  import * as vectorBase from "../../src/layer/vectorBase";
@@ -5,8 +8,20 @@ import * as vectorBase from "../../src/layer/vectorBase";
5
8
  describe("vectorBase.js", function () {
6
9
 
7
10
  describe("createLayerSource", function () {
8
- it("creates a layerSource", function () {
9
- const source = vectorBase.createLayerSource();
11
+ it("creates a layerSource with features", function () {
12
+ const attr = {
13
+ features: [
14
+ new Feature({geometry: new Polygon([[[565086.1948534324, 5934664.461947621], [565657.6945448224, 5934738.54524095], [565625.9445619675, 5934357.545446689], [565234.3614400891, 5934346.962119071], [565086.1948534324, 5934664.461947621]]])}),
15
+ new Feature({geometry: new Point([565826.38, 5934174.40])})
16
+ ]
17
+ },
18
+ source = vectorBase.createLayerSource(attr);
19
+
20
+ expect(source).toBeInstanceOf(VectorSource);
21
+ });
22
+
23
+ it("creates a layerSource without features", function () {
24
+ const source = vectorBase.createLayerSource({});
10
25
 
11
26
  expect(source).toBeInstanceOf(VectorSource);
12
27
  });
package/test/map.test.js CHANGED
@@ -1,4 +1,4 @@
1
- import {PluggableMap, Map} from "ol";
1
+ import {Map} from "ol";
2
2
  import TileLayer from "ol/layer/Tile";
3
3
  import map from "../src/maps/map.js";
4
4
  import {createMap as create3DMap} from "../src/maps/olcs/olcsMap.js";
@@ -86,12 +86,12 @@ describe("map.js", function () {
86
86
  });
87
87
  });
88
88
 
89
- // NOTE: loading map.js monkey patches PluggableMap.prototype.addLayer - testing result here
89
+ // NOTE: loading map.js monkey patches Map.prototype.addLayer - testing result here
90
90
  describe("addLayer", function () {
91
91
  it("logs an error for unknown ids", function () {
92
92
  console.error = jest.fn();
93
93
  const consoleError = console.error,
94
- result = PluggableMap.prototype.addLayer("999999999999999");
94
+ result = Map.prototype.addLayer("999999999999999");
95
95
 
96
96
  expect(console.error).toHaveBeenCalled();
97
97
  expect(result).toBeNull();
@@ -101,7 +101,7 @@ describe("map.js", function () {
101
101
  it("logs an error for unknown types", function () {
102
102
  console.error = jest.fn();
103
103
  const consoleError = console.error,
104
- result = PluggableMap.prototype.addLayer("exists");
104
+ result = Map.prototype.addLayer("exists");
105
105
 
106
106
  expect(result).toBeNull();
107
107
  expect(console.error).toHaveBeenCalledWith("Layer with id 'exists' has unknown type 'doesntExist'. No layer added to map.");
@@ -109,17 +109,17 @@ describe("map.js", function () {
109
109
  });
110
110
 
111
111
  it("creates existing layers that have a known builder", function () {
112
- const result = PluggableMap.prototype.addLayer("works");
112
+ const result = Map.prototype.addLayer("works");
113
113
 
114
114
  expect(result).toBeInstanceOf(TileLayer);
115
115
  });
116
116
 
117
117
  it("sets visibility and transparency", function () {
118
- const result1 = PluggableMap.prototype.addLayer("works"),
119
- result2 = PluggableMap.prototype.addLayer("works", {}),
120
- result3 = PluggableMap.prototype.addLayer("works", {visibility: false}),
121
- result4 = PluggableMap.prototype.addLayer("works", {transparency: 50}),
122
- result5 = PluggableMap.prototype.addLayer("works", {visibility: false, transparency: 20});
118
+ const result1 = Map.prototype.addLayer("works"),
119
+ result2 = Map.prototype.addLayer("works", {}),
120
+ result3 = Map.prototype.addLayer("works", {visibility: false}),
121
+ result4 = Map.prototype.addLayer("works", {transparency: 50}),
122
+ result5 = Map.prototype.addLayer("works", {visibility: false, transparency: 20});
123
123
 
124
124
  expect(result1.getOpacity()).toBe(1);
125
125
  expect(result1.getVisible()).toBe(true);