@masterportal/masterportalapi 2.59.0 → 2.61.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 +30 -1
- package/README.md +0 -4
- package/example/config/services.json +51 -0
- package/example/index.js +13 -0
- package/jest.config.js +1 -1
- package/package.json +29 -28
- package/publiccode.yml +2 -2
- package/src/layer/vectorTile.js +53 -29
- package/src/maps/olcs/3dUtils/fixedOverlaySynchronizer.js +1 -1
- package/src/maps/olcs/3dUtils/wmsRasterSynchronizer.js +1 -2
- package/src/maps/olcs/olcsMap.js +1 -1
- package/test/layer/vectorTile.test.js +5 -1
- package/babel.config.json +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,36 @@
|
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## 2.61.0 - 2026-04-21
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- VectorTile with `vtStyles`: `setStyle` is not reading from url, if `options.readStyleFromUrl = false`. Is also passed by `options` in `createLayer`.
|
|
10
|
+
- The following packages have been updated:
|
|
11
|
+
- dependencies:
|
|
12
|
+
- ol-mapbox-style: 12.5.0 to 13.3.0
|
|
13
|
+
- olcs: 2.22.1 to 2.23.0
|
|
14
|
+
- ol: 10.8.0 to 10.9.0
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
- The following overwrites have been removed:
|
|
18
|
+
- geotiff in ol
|
|
19
|
+
- The unused babel dev dependencies were removed
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2.60.0 - 2026-04-10
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- Issue #15: At VectorTile layer the `vtStyles` attribute is evaluated, and the style is applied using the `layers` attribute or to the styles attribute `defaultStyle`.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- The following packages have been updated:
|
|
30
|
+
- dependencies:
|
|
31
|
+
- ol-mapbox-style: 12.5.0 to 13.3.0
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 2.59.0 - 2026-03-13
|
|
7
36
|
|
|
8
37
|
### Changed
|
|
9
38
|
- Updated examples to prevent console errors caused by certain layers/services.
|
package/README.md
CHANGED
|
@@ -25,7 +25,3 @@ Both methods may be required for useful user feedback. For example, a WMS may an
|
|
|
25
25
|
|``npm run generate-jsdoc``|Generates the project documentation within the folder ``./docs``.|
|
|
26
26
|
|``npm test``|Runs all tests. Prints code coverage to console.|
|
|
27
27
|
|``npm run test:watch``|Runs all tests in watch mode. Good practive to let this run during development in a separate terminal. |
|
|
28
|
-
|
|
29
|
-
## About Babel
|
|
30
|
-
|
|
31
|
-
The Babel dev dependencies are purely added for development tests and jest tests. Babel is required for testing since Node does not support ES6 in .js files so far.
|
|
@@ -200,6 +200,57 @@
|
|
|
200
200
|
}
|
|
201
201
|
]
|
|
202
202
|
},
|
|
203
|
+
{
|
|
204
|
+
"id": "6002",
|
|
205
|
+
"name": "ArcGIS VectorTile with layers attribute",
|
|
206
|
+
"shortname": "VectorTile",
|
|
207
|
+
"typ": "VectorTile",
|
|
208
|
+
"visibility": false,
|
|
209
|
+
"preview": {
|
|
210
|
+
"src": "./resources/vectorTile.png"
|
|
211
|
+
},
|
|
212
|
+
"layers": "M020_N/DS07_TatsaechlicheNutzung/G020_600_GEB_TNutz_F/P05_CI054_Platz,M020_N/DS07_TatsaechlicheNutzung/G020_600_GEB_TNutz_F/P06_CI060_BaulichGepraegteFlaeche",
|
|
213
|
+
"gfiAttributes": "showAll",
|
|
214
|
+
"url": "https://test.geoportal-hamburg.de/vt/esri/tile/{z}/{y}/{x}.pbf",
|
|
215
|
+
"epsg": "EPSG:25832",
|
|
216
|
+
"extent": [
|
|
217
|
+
441336.2209999999,
|
|
218
|
+
5915995,
|
|
219
|
+
594002,
|
|
220
|
+
5986767.56699999981
|
|
221
|
+
],
|
|
222
|
+
"origin": [
|
|
223
|
+
-9497963.94293634221,
|
|
224
|
+
9997963.94293634221
|
|
225
|
+
],
|
|
226
|
+
"resolutions": [
|
|
227
|
+
39054.5466520950868,
|
|
228
|
+
19527.2733260475434,
|
|
229
|
+
9763.63666302377169,
|
|
230
|
+
4881.81833151188584,
|
|
231
|
+
2440.90916575594292,
|
|
232
|
+
1220.45458287797146,
|
|
233
|
+
610.227291438985731,
|
|
234
|
+
305.113645719492865,
|
|
235
|
+
152.556822859746433,
|
|
236
|
+
76.2784114298732163,
|
|
237
|
+
38.1392057149366082,
|
|
238
|
+
19.0696028574683041,
|
|
239
|
+
9.534801428734152,
|
|
240
|
+
4.767400714367076,
|
|
241
|
+
2.383700357183538,
|
|
242
|
+
1.191850178591769
|
|
243
|
+
],
|
|
244
|
+
"tileSize": 512,
|
|
245
|
+
"vtStyles": [
|
|
246
|
+
{
|
|
247
|
+
"id": "VectorTile_STYLE",
|
|
248
|
+
"name": "Test",
|
|
249
|
+
"url": "https://test.geoportal-hamburg.de/vt/esri/resources/styles/root.json",
|
|
250
|
+
"defaultStyle": true
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
203
254
|
{
|
|
204
255
|
"id": "7001",
|
|
205
256
|
"name": "TopPlusOpen",
|
package/example/index.js
CHANGED
|
@@ -195,6 +195,19 @@ fetch(vtStyleUrl)
|
|
|
195
195
|
});
|
|
196
196
|
*/
|
|
197
197
|
|
|
198
|
+
/* VECTOR TILE EXAMPLE 2, using layers attribute */
|
|
199
|
+
/*
|
|
200
|
+
document.getElementById("enable").style.display = "none";
|
|
201
|
+
window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
|
202
|
+
|
|
203
|
+
window.mpapi.map.getLayers().forEach(layer => {
|
|
204
|
+
window.mpapi.map.removeLayer(layer);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const vtLayer = window.mpapi.map.addLayer("6002");
|
|
208
|
+
|
|
209
|
+
*/
|
|
210
|
+
|
|
198
211
|
/* WMTS example */
|
|
199
212
|
/*
|
|
200
213
|
window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
package/jest.config.js
CHANGED
|
@@ -14,7 +14,7 @@ module.exports = {
|
|
|
14
14
|
/** mapping svg to string representation since jest can't handle svg and mapping olcs paths*/
|
|
15
15
|
"moduleNameMapper": {
|
|
16
16
|
"marker.svg": "<rootDir>/public/stringMarker.js",
|
|
17
|
-
"olcs/lib/olcs/
|
|
17
|
+
"olcs/lib/olcs/util.js": "<rootDir>/node_modules/olcs/lib/olcs/util.js",
|
|
18
18
|
"ol-mapbox-style$": "<rootDir>/node_modules/ol-mapbox-style/src/$1"
|
|
19
19
|
},
|
|
20
20
|
"testEnvironment": "jsdom",
|
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterportal/masterportalapi",
|
|
3
|
-
"
|
|
4
|
-
"version": "2.59.0",
|
|
5
|
-
"license": "MIT",
|
|
3
|
+
"version": "2.61.0",
|
|
6
4
|
"description": "Basic functions of the Masterportal as api",
|
|
5
|
+
"homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/issues"
|
|
8
|
+
},
|
|
7
9
|
"repository": {
|
|
8
10
|
"type": "git",
|
|
9
11
|
"url": "git+https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git"
|
|
10
12
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
|
|
15
|
+
"type": "commonjs",
|
|
13
16
|
"exports": {
|
|
14
17
|
".": "./src/index.js",
|
|
15
18
|
"./src/*": "./src/*"
|
|
16
19
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
"main": false
|
|
20
|
+
"main": "src/index.js",
|
|
21
|
+
"directories": {
|
|
22
|
+
"doc": "docs",
|
|
23
|
+
"example": "example",
|
|
24
|
+
"test": "test"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"test": "jest .test.js --config ./jest.config.js --collectCoverage",
|
|
@@ -34,15 +35,13 @@
|
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"core-js": "^3.33.1",
|
|
36
37
|
"dayjs": "^1.11.10",
|
|
37
|
-
"ol": "10.
|
|
38
|
-
"ol-mapbox-style": "
|
|
39
|
-
"olcs": "^2.
|
|
38
|
+
"ol": "10.9.0",
|
|
39
|
+
"ol-mapbox-style": "13.3.0",
|
|
40
|
+
"olcs": "^2.23.0",
|
|
40
41
|
"proj4": "^2.10.0",
|
|
41
42
|
"xml2js": "^0.6.2"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "7.26.0",
|
|
45
|
-
"@babel/plugin-transform-modules-commonjs": "^7.23.0",
|
|
46
45
|
"@parcel/config-default": "^2.15.4",
|
|
47
46
|
"@parcel/transformer-sass": "^2.15.4",
|
|
48
47
|
"@swc/jest": "^0.2.39",
|
|
@@ -72,21 +71,23 @@
|
|
|
72
71
|
"peerDependencies": {
|
|
73
72
|
"@cesium/engine": "^23.0.0"
|
|
74
73
|
},
|
|
75
|
-
"overrides": {
|
|
76
|
-
"ol": {
|
|
77
|
-
"geotiff": "^2.1.3"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
74
|
"engines": {
|
|
81
75
|
"node": "^22.19.0 || ^24.11.1",
|
|
82
76
|
"npm": "^10.5.0 || ^11.6.2"
|
|
83
77
|
},
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
|
|
78
|
+
"source": "src/index.js",
|
|
79
|
+
"targets": {
|
|
80
|
+
"library": {
|
|
81
|
+
"source": "src/index.js",
|
|
82
|
+
"distDir": "dist",
|
|
83
|
+
"outputFormat": "commonjs"
|
|
84
|
+
},
|
|
85
|
+
"main": false
|
|
88
86
|
},
|
|
89
|
-
"
|
|
90
|
-
"
|
|
87
|
+
"@parcel/resolver-default": {
|
|
88
|
+
"packageExports": true
|
|
89
|
+
},
|
|
90
|
+
"alias": {
|
|
91
|
+
"olcs/lib/olcs/util.js": "./node_modules/olcs/lib/olcs/util.js"
|
|
91
92
|
}
|
|
92
93
|
}
|
package/publiccode.yml
CHANGED
|
@@ -81,8 +81,8 @@ maintenance:
|
|
|
81
81
|
name: Masterportal
|
|
82
82
|
platforms:
|
|
83
83
|
- web
|
|
84
|
-
releaseDate: '2026-
|
|
84
|
+
releaseDate: '2026-04-21'
|
|
85
85
|
roadmap: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/src/master/'
|
|
86
86
|
softwareType: api
|
|
87
|
-
softwareVersion: 2.
|
|
87
|
+
softwareVersion: 2.61.0
|
|
88
88
|
url: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git'
|
package/src/layer/vectorTile.js
CHANGED
|
@@ -4,7 +4,7 @@ import VectorTileSource from "ol/source/VectorTile";
|
|
|
4
4
|
import OpenLayersTileGrid from "ol/tilegrid/TileGrid";
|
|
5
5
|
import {extentFromProjection} from "ol/tilegrid";
|
|
6
6
|
import * as webgl from "../renderer/webgl";
|
|
7
|
-
import {apply, stylefunction} from "ol-mapbox-style";
|
|
7
|
+
import {apply, applyStyle, stylefunction} from "ol-mapbox-style";
|
|
8
8
|
|
|
9
9
|
import defaults from "../defaults";
|
|
10
10
|
|
|
@@ -132,9 +132,56 @@ export function createLayerSource (url, options = {}) {
|
|
|
132
132
|
return new VectorTileSource(sourceParams);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Set a mapbox style
|
|
137
|
+
* @param {ol.layer.VectorTile} layer - layer to style
|
|
138
|
+
* @param {object} glStyle - MapBox style definition
|
|
139
|
+
* @param {options} [styleParams={}] - Additional options for style specification
|
|
140
|
+
* @param {string} url - MapBox style url
|
|
141
|
+
* @returns {void}
|
|
142
|
+
*/
|
|
143
|
+
export function setStyle (layer, glStyle, {options = {}} = {}, url) {
|
|
144
|
+
const readStyleFromUrl = typeof options.readStyleFromUrl === "boolean" ? options.readStyleFromUrl : true;
|
|
145
|
+
|
|
146
|
+
if (url && readStyleFromUrl) {
|
|
147
|
+
fetch(url)
|
|
148
|
+
.then(response => response.json())
|
|
149
|
+
.then(style => {
|
|
150
|
+
const styles = options.layers ? style.layers.filter((styleLayer) => options.layers.includes(styleLayer.id)) : style.layers;
|
|
151
|
+
|
|
152
|
+
style.layers = styles;
|
|
153
|
+
applyStyle(layer, style);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (glStyle && glStyle.sources) {
|
|
157
|
+
|
|
158
|
+
Object.keys(glStyle.sources).forEach((key) => {
|
|
159
|
+
const glStyleSourceId = key;
|
|
160
|
+
|
|
161
|
+
if (glStyle.sources[key].type !== "vector" && glStyle.sources[key].type !== "geojson") {
|
|
162
|
+
const olMap = layer.get("map");
|
|
163
|
+
|
|
164
|
+
apply(olMap, url);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
stylefunction(layer, glStyle,
|
|
168
|
+
options.sourceId ? options.sourceId : glStyleSourceId,
|
|
169
|
+
options.resolutions,
|
|
170
|
+
options.spriteData,
|
|
171
|
+
options.spriteImageUrl,
|
|
172
|
+
options.getFonts);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
135
179
|
/**
|
|
136
180
|
* Creates a Vector Tiles layer.
|
|
137
181
|
*
|
|
182
|
+
* Note: Within the vtStyles of a layer we introduced a boolean flag called defaultStyle.
|
|
183
|
+
* This option allows to mark a vtStyle as default. When not present, the first entry will be taken
|
|
184
|
+
* as style.
|
|
138
185
|
* @param {rawLayer} rawLayer - rawLayer as specified in services.json
|
|
139
186
|
* @param {object} [layerParams={}] - extra params of the layer. Can overwrite or extend all ol layer parameters.
|
|
140
187
|
* @param {object} [options={}] - parameter object. Not used atm.
|
|
@@ -176,34 +223,11 @@ export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {
|
|
|
176
223
|
if (options.style && rawLayer.renderer !== "webgl") {
|
|
177
224
|
layer.setStyle(options.style);
|
|
178
225
|
}
|
|
226
|
+
if (rawLayer.vtStyles) {
|
|
227
|
+
const vtStyle = rawLayer.vtStyles.filter((style) => style.defaultStyle)[0] || rawLayer.vtStyles[0];
|
|
179
228
|
|
|
180
|
-
|
|
181
|
-
}
|
|
229
|
+
setStyle(layer, {}, {options: {layers: rawLayer.layers, readStyleFromUrl: options.readStyleFromUrl}}, vtStyle.url);
|
|
182
230
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
* @param {ol.layer.VectorTile} layer - layer to style
|
|
186
|
-
* @param {object} glStyle - MapBox style definition
|
|
187
|
-
* @param {options} [styleParams={}] - Additional options for style specification
|
|
188
|
-
* @param {string} url - MapBox style url
|
|
189
|
-
* @returns {void}
|
|
190
|
-
*/
|
|
191
|
-
export function setStyle (layer, glStyle, {options = {}} = {}, url) {
|
|
192
|
-
Object.keys(glStyle.sources).forEach((key) => {
|
|
193
|
-
const glStyleSourceId = key;
|
|
194
|
-
|
|
195
|
-
if (glStyle.sources[key].type !== "vector" && glStyle.sources[key].type !== "geojson") {
|
|
196
|
-
const olMap = layer.get("map");
|
|
197
|
-
|
|
198
|
-
apply(olMap, url);
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
stylefunction(layer, glStyle,
|
|
202
|
-
options.sourceId ? options.sourceId : glStyleSourceId,
|
|
203
|
-
options.resolutions,
|
|
204
|
-
options.spriteData,
|
|
205
|
-
options.spriteImageUrl,
|
|
206
|
-
options.getFonts);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
231
|
+
}
|
|
232
|
+
return layer;
|
|
209
233
|
}
|
|
@@ -6,8 +6,7 @@ import {getUid} from "olcs/lib/olcs/util.js";
|
|
|
6
6
|
import TileWMS from "ol/source/TileWMS.js";
|
|
7
7
|
import ImageWMS from "ol/source/ImageWMS.js";
|
|
8
8
|
import WMTS from "ol/source/WMTS.js";
|
|
9
|
-
import AbstractSynchronizer from "olcs
|
|
10
|
-
import {extentToRectangle, tileLayerToImageryLayer, updateCesiumLayerProperties} from "olcs/lib/olcs/core.js";
|
|
9
|
+
import {AbstractSynchronizer, extentToRectangle, tileLayerToImageryLayer, updateCesiumLayerProperties} from "olcs";
|
|
11
10
|
import {Tile, Image as ImageLayer} from "ol/layer.js";
|
|
12
11
|
import {stableSort} from "ol/array.js";
|
|
13
12
|
import {getBottomLeft, getBottomRight, getTopRight, getTopLeft} from "ol/extent.js";
|
package/src/maps/olcs/olcsMap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OLCesium from "olcs";
|
|
2
2
|
import {transform, get} from "ol/proj.js";
|
|
3
|
-
import VectorSynchronizer from "olcs
|
|
3
|
+
import {VectorSynchronizer} from "olcs";
|
|
4
4
|
|
|
5
5
|
import FixedOverlaySynchronizer from "./3dUtils/fixedOverlaySynchronizer.js";
|
|
6
6
|
import WMSRasterSynchronizer from "./3dUtils/wmsRasterSynchronizer.js";
|
|
@@ -29,7 +29,11 @@ jest.mock("../../src/renderer/webgl.js", () => {
|
|
|
29
29
|
|
|
30
30
|
describe("vectorTile.js", function () {
|
|
31
31
|
|
|
32
|
-
beforeAll(() =>
|
|
32
|
+
beforeAll(() => {
|
|
33
|
+
crs.registerProjections();
|
|
34
|
+
global.Request = global.Request || jest.fn();
|
|
35
|
+
global.Response = global.Response || jest.fn();
|
|
36
|
+
});
|
|
33
37
|
|
|
34
38
|
const rawLayer = {
|
|
35
39
|
name: "VT Test",
|