@masterportal/masterportalapi 2.1.1 → 2.2.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
@@ -16,8 +16,13 @@
16
16
 
17
17
  ---
18
18
 
19
- ## 2.1.1 - 2022-04-20
19
+ ## 2.2.0 - 2022-04-25
20
+ ### Added
21
+ - Add a new layer type Vector tile layer.
20
22
 
23
+ ---
24
+
25
+ ## 2.1.1 - 2022-04-20
21
26
  ### Fixed
22
27
  - Allow searchAddress to find street names with a prefix.
23
28
 
@@ -15,65 +15,94 @@
15
15
  "maxScale": 200
16
16
  },
17
17
  {
18
- "id" : "1002",
19
- "name" : "Krankenhäuser",
20
- "url" : "https://geodienste.hamburg.de/HH_WMS_Krankenhaeuser",
21
- "typ" : "WMS",
22
- "layers" : "krankenhaeuser",
23
- "format" : "image/png",
24
- "version" : "1.3.0",
25
- "singleTile" : false,
26
- "transparent" : true,
27
- "transparency" : 0,
28
- "urlIsVisible" : true,
29
- "tilesize" : 512
18
+ "id": "1002",
19
+ "name": "Krankenhäuser",
20
+ "url": "https://geodienste.hamburg.de/HH_WMS_Krankenhaeuser",
21
+ "typ": "WMS",
22
+ "layers": "krankenhaeuser",
23
+ "format": "image/png",
24
+ "version": "1.3.0",
25
+ "singleTile": false,
26
+ "transparent": true,
27
+ "transparency": 0,
28
+ "urlIsVisible": true,
29
+ "tilesize": 512
30
+ },
31
+ {
32
+ "id": "2001",
33
+ "typ": "GeoJSON",
34
+ "name": "Landesgrenze Hamburg",
35
+ "url": "https://geoportal-hamburg.de/lgv-config/landesgrenze_hh.json"
30
36
  },
31
37
  {
32
- "id" : "2001",
33
- "typ" : "GeoJSON",
34
- "name" : "Landesgrenze Hamburg",
35
- "url" : "https://geoportal-hamburg.de/lgv-config/landesgrenze_hh.json"
38
+ "id": "3001",
39
+ "name": "Bauwerke",
40
+ "url": "https://geodienste.hamburg.de/HH_WFS_Geotourismus",
41
+ "typ": "WFS",
42
+ "featureType": "bauwerke",
43
+ "outputFormat": "XML",
44
+ "version": "1.1.0",
45
+ "featureNS": "http://www.deegree.org/app"
36
46
  },
37
47
  {
38
- "id" : "3001",
39
- "name" : "Bauwerke",
40
- "url" : "https://geodienste.hamburg.de/HH_WFS_Geotourismus",
41
- "typ" : "WFS",
42
- "featureType" : "bauwerke",
43
- "outputFormat" : "XML",
44
- "version" : "1.1.0",
45
- "featureNS" : "http://www.deegree.org/app"
46
- },
47
- {
48
- "id" : "4001",
49
- "name" : "Gelaende",
50
- "url" : "https://daten-hamburg.de/gdi3d/datasource-data/Gelaende ",
51
- "typ" : "Terrain3D",
52
- "cesiumTerrainProviderOptions" : {
53
- "requestVertexNormals" : true
54
- }
55
- },
48
+ "id": "4001",
49
+ "name": "Gelaende",
50
+ "url": "https://daten-hamburg.de/gdi3d/datasource-data/Gelaende ",
51
+ "typ": "Terrain3D",
52
+ "cesiumTerrainProviderOptions": {
53
+ "requestVertexNormals": true
54
+ }
55
+ },
56
56
  {
57
- "id" : "4002",
58
- "name" : "Gebäude LoD2",
59
- "url" : "https://daten-hamburg.de/gdi3d/datasource-data/LoD2",
60
- "typ" : "TileSet3D",
61
- "cesium3DTilesetOptions" : {
62
- "maximumScreenSpaceError" : 6
57
+ "id": "4002",
58
+ "name": "Gebäude LoD2",
59
+ "url": "https://daten-hamburg.de/gdi3d/datasource-data/LoD2",
60
+ "typ": "TileSet3D",
61
+ "cesium3DTilesetOptions": {
62
+ "maximumScreenSpaceError": 6
63
63
  }
64
64
  },
65
- {
66
- "id": "5001",
67
- "name": "Schulen",
68
- "url": "https://api.hamburg.de/datasets/v1/schulen",
69
- "collection" : "staatliche_schulen",
70
- "typ": "OAF",
71
- "bbox": "",
72
- "bboxCrs": "",
73
- "datetime": "",
74
- "crs": "EPSG:25832",
75
- "params": {
76
- "anzahl_schueler": ">1000"
77
- }
65
+ {
66
+ "id": "5001",
67
+ "name": "Schulen",
68
+ "url": "https://api.hamburg.de/datasets/v1/schulen",
69
+ "collection": "staatliche_schulen",
70
+ "typ": "OAF",
71
+ "bbox": "",
72
+ "bboxCrs": "",
73
+ "datetime": "",
74
+ "crs": "EPSG:25832",
75
+ "params": {
76
+ "anzahl_schueler": ">1000"
78
77
  }
78
+ },
79
+ {
80
+ "id": "6001",
81
+ "name": "ADV (EPSG:25832)",
82
+ "url": "https://dev.adv-smart.de/tiles/smarttiles_de_UTM32_dev/{z}/{x}/{y}.pbf",
83
+ "epsg": "EPSG:25832",
84
+ "typ": "VectorTile",
85
+ "extent": [
86
+ -46133.17,
87
+ 5048875.26857567,
88
+ 1206211.10142433,
89
+ 6301219.54000000
90
+ ],
91
+ "resolutions": [
92
+ 4891.96981025128,
93
+ 2445.98490512564,
94
+ 1222.99245256282,
95
+ 611.496226281410,
96
+ 305.748113140705,
97
+ 152.874056570353,
98
+ 76.4370282851763,
99
+ 38.2185141425881,
100
+ 19.1092570712941,
101
+ 9.55462853564703,
102
+ 4.77731426782352,
103
+ 2.38865713391176
104
+ ],
105
+ "tileSize": 256,
106
+ "zDirection": -1
107
+ }
79
108
  ]
package/example/index.js CHANGED
@@ -208,3 +208,20 @@ window.mpapi.search("Mümmelmannsberg 72", {
208
208
  }).then(x => console.log(x)).catch(e => console.error(e))
209
209
 
210
210
  //*/
211
+
212
+ /* VECTOR TILE EXAMPLE */
213
+ /*
214
+ document.getElementById("enable").style.display = "none";
215
+ map2D.getLayers().forEach(layer => {
216
+ map2D.removeLayer(layer);
217
+ });
218
+
219
+ let vtStyleUrl = 'https://dev.adv-smart.de/styles/playground/masterportal_test1.json';
220
+
221
+ fetch(vtStyleUrl)
222
+ .then(response => response.json())
223
+ .then(style => {
224
+ let vtLayer = window.mpapi.map.addLayer("6001");
225
+ mpapi.vectorTile.setStyle(vtLayer, style);
226
+ });
227
+ */
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.1.1",
4
+ "version": "2.2.0",
5
5
  "license": "MIT",
6
6
  "description": "Basic functions of the Masterportal as api",
7
7
  "repository": {
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ import * as wms from "./layer/wms";
5
5
  import * as wfs from "./layer/wfs";
6
6
  import * as geojson from "./layer/geojson";
7
7
  import * as vectorBase from "./layer/vectorBase";
8
+ import * as vectorTile from "./layer/vectorTile";
8
9
  import * as oaf from "./layer/oaf";
9
10
  import * as terrain from "./layer/terrain";
10
11
  import Tileset from "./layer/tileset";
@@ -19,6 +20,7 @@ export {
19
20
  geojson,
20
21
  layerLib,
21
22
  vectorBase,
23
+ vectorTile,
22
24
  oaf,
23
25
  terrain,
24
26
  Tileset,
@@ -0,0 +1,174 @@
1
+ import MVT from "ol/format/MVT";
2
+ import VectorTileLayer from "ol/layer/VectorTile";
3
+ import VectorTileSource from "ol/source/VectorTile";
4
+ import OpenLayersTileGrid from "ol/tilegrid/TileGrid";
5
+ import {extentFromProjection} from "ol/tilegrid";
6
+
7
+ import stylefunction from "ol-mapbox-style/dist/stylefunction";
8
+ import {defaultResolutions} from "ol-mapbox-style/dist/util";
9
+
10
+ import defaults from "../defaults";
11
+
12
+ const OL_DEFAULT_VECTOR_TILE_GRID_CRS = "EPSG:3857";
13
+
14
+ /**
15
+ * Used properites of layer specification as in services.json.
16
+ *
17
+ * @typedef {Object} rawLayer
18
+ * @property {string} id - Layer id
19
+ * @property {string} name - Layer name
20
+ * @property {string} url - source url
21
+ * @property {string} [epsg=defaults.epsg] - vector tiles crs
22
+ * @property {number[]} [extent] - extent
23
+ * @property {number} [maxZoom=22] - min zoom level
24
+ * @property {number} [minZoom] - max zoom level
25
+ * @property {function} [olAttribution] - optional function that takes a module:ol/PluggableMap~FrameState and returns a string or an array of strings representing source attributions
26
+ * @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
27
+ * @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.
28
+ * @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.
29
+ * @property {number} [tileSize=512] - size of a tile in px
30
+ * @property {number} [zDirection=1] - zoom level offset for requested tiles
31
+ */
32
+
33
+ /**
34
+ * Used properites of layer specification as in services.json.
35
+ *
36
+ * @typedef {Object} tileGridProperties
37
+ * @property {string} [epsg] - vector tiles crs
38
+ * @property {number} [tileSize=512] - size of a tile in px
39
+ * @property {number} [zDirection=1] - zoom level offset for requested tiles
40
+ * @property {number} [minZoom] - min zoom level
41
+ * @property {number} [maxZoom=22] - may zoom level
42
+ * @property {number[]} [extent] - extent
43
+ * @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.
44
+ * @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
45
+ * @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.
46
+ */
47
+
48
+ /**
49
+ * Additional properties for style specification
50
+ * @typedef {Object} styleParams
51
+ * @property {string} [sourceId] - key from the Mapbox Style object. When a source key is provided, all layers for the specified source will be included in the style function.
52
+ * @property {number[]} [resolutions] - Resolutions for mapping resolution to zoom level.
53
+ * @property {object} [spriteData] - Sprite data from the url specified in the Mapbox Style object's sprite property. Only required if a sprite property is specified in the Mapbox Style object.
54
+ * @property {string} [spriteImageUrl] - Url to sprite image
55
+ * @property {function} [getFonts] - Function that receives a font stack as arguments, and returns a (modified) font stack that is available. Font names are the names used in the Mapbox Style object. If not provided, the font stack will be used as-is. This function can also be used for loading web fonts.
56
+ */
57
+
58
+ /**
59
+ * Create a TileGrid.
60
+ *
61
+ * @param {tileGridProperties} [options] - options
62
+ * @returns {ol.tilegrid.TileGrid} TileGrid
63
+ */
64
+ export function createTileGrid (options = {}) {
65
+
66
+ const epsg = options.epsg ? options.epsg : defaults.epsg,
67
+ extent = options.extent ? options.extent : extentFromProjection(epsg),
68
+ tileSize = options.tileSize ? options.tileSize : 512,
69
+ resolutions = options.resolutions ? options.resolutions : defaults.options.map(x => x.resolution),
70
+ tileGridParams = {
71
+ extent: extent,
72
+ resolutions: resolutions,
73
+ minZoom: options.minZoom,
74
+ tileSize: new Array(2).fill(tileSize)
75
+ };
76
+
77
+ if (options.origins) {
78
+ tileGridParams.origins = options.origins;
79
+ }
80
+ else {
81
+ tileGridParams.origin = options.origin ? options.origin : [tileGridParams.extent[0], tileGridParams.extent[3]];
82
+ }
83
+
84
+ return new OpenLayersTileGrid(tileGridParams);
85
+ }
86
+
87
+ /**
88
+ * Check if TileGrid must be created.
89
+ *
90
+ * @param {tileGridProperties} options - tile grid parameters
91
+ * @returns {boolean} must create tileGrid
92
+ */
93
+ function mustCreateTileGrid (options = {}) {
94
+ const createOptions = [options.extent, options.tileSize, options.resolutions, options.origin, options.origins, options.minZoom],
95
+ epsgTest = options.epsg ? options.epsg.toUpperCase() : options.epsg;
96
+
97
+ if (!createOptions.every((x) => typeof x === "undefined")) {
98
+ return true;
99
+ }
100
+
101
+ if (epsgTest !== OL_DEFAULT_VECTOR_TILE_GRID_CRS) {
102
+ return true;
103
+ }
104
+ return false;
105
+ }
106
+
107
+ /**
108
+ * Creates a Vector Tiles source.
109
+ *
110
+ * @param {string} url - url to vector tile service
111
+ * @param {tileGridProperties} [options] - properties for tileGrid
112
+ * @returns {ol.source.VectorTile} Source
113
+ */
114
+ export function createLayerSource (url, options = {}) {
115
+ options.epsg = options.epsg ? options.epsg : defaults.epsg;
116
+
117
+ const sourceParams = {
118
+ projection: options.epsg,
119
+ format: new MVT(),
120
+ url: url,
121
+ tileSize: options.tileSize,
122
+ zDirection: options.zDirection,
123
+ minZoom: options.minZoom,
124
+ maxZoom: options.maxZoom
125
+ };
126
+
127
+ if (mustCreateTileGrid(options)) {
128
+ sourceParams.tileGrid = createTileGrid(options);
129
+ }
130
+
131
+ return new VectorTileSource(sourceParams);
132
+ }
133
+
134
+ /**
135
+ * Creates a Vector Tiles layer.
136
+ *
137
+ * @param {rawLayer} rawLayer - rawLayer as specified in services.json
138
+ * @param {object} [layerParams={}] - extra params of the layer. Can overwrite or extend all ol layer parameters.
139
+ * @param {object} [options={}] - parameter object. Not used atm.
140
+ * @returns {ol.layer.VectorTile} Layer with id and source specified in rawLayer
141
+ */
142
+ export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {}) {
143
+ if ([rawLayer.id, rawLayer.name, rawLayer.url].some((x) => typeof x === "undefined")) {
144
+ console.error(`Cancelled creation of layer "${rawLayer.id}"(${rawLayer.name}) because of missing required parameters`);
145
+ return undefined;
146
+ }
147
+ const source = createLayerSource(rawLayer.url, rawLayer),
148
+ layer = new VectorTileLayer(Object.assign({
149
+ id: rawLayer.id, name: rawLayer.name, attribution: rawLayer.olAttribution, extent: source.getTileGrid().getExtent(),
150
+ minZoom: rawLayer.minZoom, maxZoom: rawLayer.maxZoom, source: source,
151
+ declutter: true}, layerParams));
152
+
153
+ if (options.style) {
154
+ layer.setStyle(options.style);
155
+ }
156
+
157
+ return layer;
158
+ }
159
+
160
+ /**
161
+ * Set a mapbox style
162
+ * @param {ol.layer.VectorTile} layer - layer to style
163
+ * @param {object} glStyle - MapBox style definition
164
+ * @param {options} [styleParams={}] - Additional options for style specification
165
+ * @returns {void}
166
+ */
167
+ export function setStyle (layer, glStyle, {options = {}} = {}) {
168
+ stylefunction(layer, glStyle,
169
+ options.sourceId ? options.sourceId : Object.keys(glStyle.sources)[0],
170
+ options.resolutions ? options.resolutions : defaultResolutions,
171
+ options.spriteData,
172
+ options.spriteImageUrl,
173
+ options.getFonts);
174
+ }
@@ -7,6 +7,7 @@ import * as wms from "../../layer/wms";
7
7
  import * as geojson from "../../layer/geojson";
8
8
  import * as wfs from "../../layer/wfs";
9
9
  import * as vectorBase from "../../layer/vectorBase";
10
+ import * as vectortile from "../../layer/vectorTile";
10
11
  import * as oaf from "../../layer/oaf";
11
12
  import {createMapView} from "../../maps/mapView";
12
13
  import {initializeLayerList, getLayerWhere} from "../../rawLayerList";
@@ -24,6 +25,7 @@ const layerBuilderMap = {
24
25
  wfs,
25
26
  geojson,
26
27
  vectorBase,
28
+ vectortile,
27
29
  oaf
28
30
  },
29
31
  originalAddLayer = PluggableMap.prototype.addLayer;
@@ -0,0 +1,172 @@
1
+ import OpenLayersVectorTileLayer from "ol/layer/VectorTile";
2
+ import OpenLayersVectorTileSource from "ol/source/VectorTile";
3
+ import OpenLayersTileGrid from "ol/tilegrid/TileGrid";
4
+
5
+ import {Feature} from "ol";
6
+ import Polygon from "ol/geom/Polygon";
7
+
8
+ import * as vectorTile from "../../src/layer/vectorTile";
9
+ import {registerProjections} from "../../src/crs";
10
+ import defaults from "../../src/defaults";
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
+ describe("vectorTile.js", function () {
20
+
21
+ beforeAll(() => registerProjections());
22
+
23
+ const layerParams = {
24
+ name: "VT Test",
25
+ id: "VT_01",
26
+ url: "https://example.org"
27
+ },
28
+ tileGridParams = {
29
+ extent: [0, 0, 1, 1],
30
+ tileSize: 512,
31
+ minZoom: 0
32
+ },
33
+
34
+ vtStyle = {
35
+ "version": 8,
36
+ "sources": {
37
+ "test": {
38
+ "type": "vector"
39
+ }
40
+ },
41
+ "layers": [
42
+ {
43
+ "type": "fill",
44
+ "source": "test",
45
+ "source-layer": "Background",
46
+ "paint": {"fill-color": "rgb(255,253,238)", "fill-opacity": 1}
47
+ }
48
+ ]
49
+ },
50
+
51
+ feature = new Feature({
52
+ geometry: new Polygon([[0, 0], [0, 1], [1, 1], [0, 0]]),
53
+ layer: "Background"
54
+ });
55
+
56
+ describe("createTileGrid", function () {
57
+ it("creates a ol/tilegrid/TileGrid with default values for not required parameters", function () {
58
+ const tileGrid = vectorTile.createTileGrid(tileGridParams);
59
+
60
+ expect(tileGrid).toBeInstanceOf(OpenLayersTileGrid);
61
+ expect(tileGrid.getExtent()).toEqual(tileGridParams.extent);
62
+ expect(tileGrid.getResolutions()).toEqual(defaults.options.map(x => x.resolution));
63
+ expect(tileGrid.getTileSize()).toEqual(new Array(2).fill(tileGridParams.tileSize));
64
+ expect(tileGrid.getMinZoom()).toBe(tileGrid.minZoom);
65
+ expect(tileGrid.getOrigin()).toEqual([tileGridParams.extent[0], tileGridParams.extent[3]]);
66
+ });
67
+ });
68
+
69
+ describe("createLayerSource", function () {
70
+ it("creates a layerSource", function () {
71
+ const tileGrid = vectorTile.createTileGrid(tileGridParams),
72
+ sourceParams = {
73
+ tileGrid: tileGrid,
74
+ tileSize: tileGrid.getTileSize(),
75
+ zDirection: 1,
76
+ minZoom: 0,
77
+ maxZoom: 22
78
+ },
79
+ source = vectorTile.createLayerSource("https://foo.example.org", sourceParams);
80
+
81
+ expect(source).toBeInstanceOf(OpenLayersVectorTileSource);
82
+ });
83
+ });
84
+
85
+ describe("createLayer", function () {
86
+ it("creates a vector Tile Layer", function () {
87
+ const layer = vectorTile.createLayer(layerParams);
88
+
89
+ expect(layer).toBeInstanceOf(OpenLayersVectorTileLayer);
90
+ expect(layer.getSource()).toBeInstanceOf(OpenLayersVectorTileSource);
91
+ expect(layer.get("name")).toEqual("VT Test");
92
+ expect(layer.get("id")).toEqual("VT_01");
93
+ });
94
+
95
+ it("should log an error when required param is missing", function () {
96
+ const spyConsole = jest.spyOn(console, "error").mockImplementation(() => ""),
97
+ layer = vectorTile.createLayer({
98
+ name: "VT Test",
99
+ id: "VT_01"
100
+ });
101
+
102
+ expect(layer).toBeUndefined();
103
+ expect(console.error).toHaveBeenCalled();
104
+ expect(spyConsole.mock.calls[0][0]).toContain("Cancelled creation of layer \"VT_01\"(VT Test) because of missing required parameters");
105
+ spyConsole.mockRestore();
106
+ });
107
+
108
+ it("should apply default values for all not required ones", function () {
109
+ const defaultValues = { // defaults defined in services.json.md
110
+ zDirection: 1,
111
+ epsg: "EPSG:25832", // default value from config.json.md/MapView. Should be the default CRS
112
+ extent: [ // If not set, the portal's coordinate reference system's extent is used
113
+ // Note: this should be the extent of the projection but is the extent of EPSG:3857
114
+ // this is because in masterportalAPI is no definition of the extent of the
115
+ // default projection which is EPSG:25832
116
+ -20015077.371242613,
117
+ -20015077.371242613,
118
+ 20015077.371242613,
119
+ 20015077.371242613
120
+ ],
121
+ origin: [ // if not set, the portal's coordinate reference system's top-left corner is used.
122
+ // Note: this should be the top left corner of the projection extent but is top left
123
+ // corner of extent of EPSG:3857 this is because in masterportalAPI is no
124
+ // definition of the extent of the default projection which is EPSG:25832
125
+ -20015077.371242613,
126
+ 20015077.371242613
127
+ ],
128
+ resolutions: [ // If not used, the portal's resolutions are used. (Missing default resolution definition? used default resolutions from masterportal-api)
129
+ 66.14579761460263,
130
+ 26.458319045841044,
131
+ 15.874991427504629,
132
+ 10.583327618336419,
133
+ 5.2916638091682096,
134
+ 2.6458319045841048,
135
+ 1.3229159522920524,
136
+ 0.6614579761460262,
137
+ 0.2645831904584105,
138
+ 0.13229159522920522
139
+ ],
140
+ tileSize: 512
141
+ },
142
+ layer = vectorTile.createLayer(layerParams),
143
+ source = layer.getSource(),
144
+ tileGrid = source.getTileGrid();
145
+
146
+ expect(layer.getExtent()).toEqual(defaultValues.extent);
147
+
148
+ expect(source.getProjection().getCode()).toEqual(defaultValues.epsg);
149
+
150
+ expect(tileGrid.getExtent()).toEqual(defaultValues.extent);
151
+ expect(tileGrid.getOrigin()).toEqual(defaultValues.origin);
152
+ expect(tileGrid.getResolutions()).toEqual(defaultValues.resolutions);
153
+ expect(tileGrid.getTileSize()).toEqual(new Array(2).fill(defaultValues.tileSize));
154
+ });
155
+ });
156
+
157
+ describe("setStyle", function () {
158
+ it("should apply a given style", function () {
159
+ const layer = vectorTile.createLayer(layerParams);
160
+
161
+ let featureStyle = null;
162
+
163
+ vectorTile.setStyle(layer, vtStyle);
164
+
165
+ expect(typeof layer.getStyle()).toBe("function");
166
+
167
+ featureStyle = layer.getStyle()(feature, 1.3229159522920524);
168
+
169
+ expect(featureStyle[0].getFill().getColor()).toBe("rgba(255,253,238,1)");
170
+ });
171
+ });
172
+ });