From 5f6ee3d02525d51260a3095e702da12922beb218 Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Fri, 21 Jul 2023 15:04:37 +0200 Subject: [PATCH 1/4] chore: update dependencies; add ol-mapbox-style and @types/mapbox-gl --- package-lock.json | 123 +++++++++++++++++++++++++--------------------- package.json | 12 +++-- 2 files changed, 74 insertions(+), 61 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2da49eefc..3c51f29be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,18 +10,19 @@ "license": "BSD-2-Clause", "dependencies": { "@terrestris/base-util": "^1.0.1", - "@terrestris/ol-util": "^11.0.0", + "@terrestris/ol-util": "^11.1.0", "geojson": "^0.5.0", - "keycloak-js": "^22.0.0", + "keycloak-js": "^22.0.1", "lodash": "^4.17.21", - "ol": "^7.4.0" + "ol": "^7.4.0", + "ol-mapbox-style": "^10.6.0" }, "devDependencies": { "@babel/core": "^7.22.9", "@babel/preset-env": "^7.22.9", "@babel/preset-typescript": "^7.22.5", - "@commitlint/cli": "^17.6.5", - "@commitlint/config-conventional": "^17.6.5", + "@commitlint/cli": "^17.6.7", + "@commitlint/config-conventional": "^17.6.7", "@semantic-release/changelog": "^6.0.3", "@semantic-release/commit-analyzer": "^10.0.1", "@semantic-release/git": "^10.0.1", @@ -32,6 +33,7 @@ "@types/geojson": "^7946.0.10", "@types/jest": "^29.5.3", "@types/lodash": "^4.14.195", + "@types/mapbox-gl": "^2.7.12", "eslint": "^8.45.0", "eslint-plugin-simple-import-sort": "^10.0.0", "husky": "^8.0.3", @@ -1827,14 +1829,14 @@ } }, "node_modules/@commitlint/cli": { - "version": "17.6.6", - "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.6.6.tgz", - "integrity": "sha512-sTKpr2i/Fjs9OmhU+beBxjPavpnLSqZaO6CzwKVq2Tc4UYVTMFgpKOslDhUBVlfAUBfjVO8ParxC/MXkIOevEA==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.6.7.tgz", + "integrity": "sha512-nzZmfO5KIOupYppn1MsnYX/80I+KDlxiwkks3CJT0XT+t34UgqGi3eSyEuzgcIjPlORk5/GMaAEiys78iLfGMg==", "dev": true, "dependencies": { "@commitlint/format": "^17.4.4", - "@commitlint/lint": "^17.6.6", - "@commitlint/load": "^17.5.0", + "@commitlint/lint": "^17.6.7", + "@commitlint/load": "^17.6.7", "@commitlint/read": "^17.5.1", "@commitlint/types": "^17.4.4", "execa": "^5.0.0", @@ -1851,9 +1853,9 @@ } }, "node_modules/@commitlint/config-conventional": { - "version": "17.6.6", - "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.6.6.tgz", - "integrity": "sha512-phqPz3BDhfj49FUYuuZIuDiw+7T6gNAEy7Yew1IBHqSohVUCWOK2FXMSAExzS2/9X+ET93g0Uz83KjiHDOOFag==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.6.7.tgz", + "integrity": "sha512-4oTpEUC0HRM54QRHBPMOJW1pETp7usxXn9RuNYNWHcmu8wi1mpws95hvS20u2n6HtIkTn0jfn7vHioCm4AGUTw==", "dev": true, "dependencies": { "conventional-changelog-conventionalcommits": "^5.0.0" @@ -1863,9 +1865,9 @@ } }, "node_modules/@commitlint/config-validator": { - "version": "17.4.4", - "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-17.4.4.tgz", - "integrity": "sha512-bi0+TstqMiqoBAQDvdEP4AFh0GaKyLFlPPEObgI29utoKEYoPQTvF0EYqIwYYLEoJYhj5GfMIhPHJkTJhagfeg==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-17.6.7.tgz", + "integrity": "sha512-vJSncmnzwMvpr3lIcm0I8YVVDJTzyjy7NZAeXbTXy+MPUdAr9pKyyg7Tx/ebOQ9kqzE6O9WT6jg2164br5UdsQ==", "dev": true, "dependencies": { "@commitlint/types": "^17.4.4", @@ -1876,9 +1878,9 @@ } }, "node_modules/@commitlint/ensure": { - "version": "17.4.4", - "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-17.4.4.tgz", - "integrity": "sha512-AHsFCNh8hbhJiuZ2qHv/m59W/GRE9UeOXbkOqxYMNNg9pJ7qELnFcwj5oYpa6vzTSHtPGKf3C2yUFNy1GGHq6g==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-17.6.7.tgz", + "integrity": "sha512-mfDJOd1/O/eIb/h4qwXzUxkmskXDL9vNPnZ4AKYKiZALz4vHzwMxBSYtyL2mUIDeU9DRSpEUins8SeKtFkYHSw==", "dev": true, "dependencies": { "@commitlint/types": "^17.4.4", @@ -1985,9 +1987,9 @@ } }, "node_modules/@commitlint/is-ignored": { - "version": "17.6.6", - "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.6.6.tgz", - "integrity": "sha512-4Fw875faAKO+2nILC04yW/2Vy/wlV3BOYCSQ4CEFzriPEprc1Td2LILmqmft6PDEK5Sr14dT9tEzeaZj0V56Gg==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.6.7.tgz", + "integrity": "sha512-vqyNRqtbq72P2JadaoWiuoLtXIs9SaAWDqdtef6G2zsoXqKFc7vqj1f+thzVgosXG3X/5K9jNp+iYijmvOfc/g==", "dev": true, "dependencies": { "@commitlint/types": "^17.4.4", @@ -2031,14 +2033,14 @@ "dev": true }, "node_modules/@commitlint/lint": { - "version": "17.6.6", - "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.6.6.tgz", - "integrity": "sha512-5bN+dnHcRLkTvwCHYMS7Xpbr+9uNi0Kq5NR3v4+oPNx6pYXt8ACuw9luhM/yMgHYwW0ajIR20wkPAFkZLEMGmg==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.6.7.tgz", + "integrity": "sha512-TW+AozfuOFMrHn+jdwtz0IWu8REKFp0eryOvoBp2r8IXNc4KihKB1spAiUB6SFyHD6hVVeolz12aHnJ3Mb+xVQ==", "dev": true, "dependencies": { - "@commitlint/is-ignored": "^17.6.6", - "@commitlint/parse": "^17.6.5", - "@commitlint/rules": "^17.6.5", + "@commitlint/is-ignored": "^17.6.7", + "@commitlint/parse": "^17.6.7", + "@commitlint/rules": "^17.6.7", "@commitlint/types": "^17.4.4" }, "engines": { @@ -2046,14 +2048,14 @@ } }, "node_modules/@commitlint/load": { - "version": "17.5.0", - "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-17.5.0.tgz", - "integrity": "sha512-l+4W8Sx4CD5rYFsrhHH8HP01/8jEP7kKf33Xlx2Uk2out/UKoKPYMOIRcDH5ppT8UXLMV+x6Wm5osdRKKgaD1Q==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-17.6.7.tgz", + "integrity": "sha512-QZ2rJTbX55BQdYrCm/p6+hh/pFBgC9nTJxfsrK6xRPe2thiQzHN0AQDBqBwAirn6gIkHrjIbCbtAE6kiDYLjrw==", "dev": true, "dependencies": { - "@commitlint/config-validator": "^17.4.4", + "@commitlint/config-validator": "^17.6.7", "@commitlint/execute-rule": "^17.4.0", - "@commitlint/resolve-extends": "^17.4.4", + "@commitlint/resolve-extends": "^17.6.7", "@commitlint/types": "^17.4.4", "@types/node": "*", "chalk": "^4.1.0", @@ -2150,9 +2152,9 @@ } }, "node_modules/@commitlint/parse": { - "version": "17.6.5", - "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.6.5.tgz", - "integrity": "sha512-0zle3bcn1Hevw5Jqpz/FzEWNo2KIzUbc1XyGg6WrWEoa6GH3A1pbqNF6MvE6rjuy6OY23c8stWnb4ETRZyN+Yw==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.6.7.tgz", + "integrity": "sha512-ibO03BgEns+JJpohpBZYD49mCdSNMg6fTv7vA5yqzEFWkBQk5NWhEBw2yG+Z1UClStIRkMkAYyI2HzoQG9tCQQ==", "dev": true, "dependencies": { "@commitlint/types": "^17.4.4", @@ -2180,12 +2182,12 @@ } }, "node_modules/@commitlint/resolve-extends": { - "version": "17.4.4", - "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-17.4.4.tgz", - "integrity": "sha512-znXr1S0Rr8adInptHw0JeLgumS11lWbk5xAWFVno+HUFVN45875kUtqjrI6AppmD3JI+4s0uZlqqlkepjJd99A==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-17.6.7.tgz", + "integrity": "sha512-PfeoAwLHtbOaC9bGn/FADN156CqkFz6ZKiVDMjuC2N5N0740Ke56rKU7Wxdwya8R8xzLK9vZzHgNbuGhaOVKIg==", "dev": true, "dependencies": { - "@commitlint/config-validator": "^17.4.4", + "@commitlint/config-validator": "^17.6.7", "@commitlint/types": "^17.4.4", "import-fresh": "^3.0.0", "lodash.mergewith": "^4.6.2", @@ -2197,12 +2199,12 @@ } }, "node_modules/@commitlint/rules": { - "version": "17.6.5", - "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.6.5.tgz", - "integrity": "sha512-uTB3zSmnPyW2qQQH+Dbq2rekjlWRtyrjDo4aLFe63uteandgkI+cc0NhhbBAzcXShzVk0qqp8SlkQMu0mgHg/A==", + "version": "17.6.7", + "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.6.7.tgz", + "integrity": "sha512-x/SDwDTN3w3Gr5xkhrIORu96rlKCc8ZLYEMXRqi9+MB33st2mKcGvKa5uJuigHlbl3xm75bAAubATrodVrjguQ==", "dev": true, "dependencies": { - "@commitlint/ensure": "^17.4.4", + "@commitlint/ensure": "^17.6.7", "@commitlint/message": "^17.4.2", "@commitlint/to-lines": "^17.4.0", "@commitlint/types": "^17.4.4", @@ -4140,9 +4142,9 @@ } }, "node_modules/@terrestris/ol-util": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@terrestris/ol-util/-/ol-util-11.0.0.tgz", - "integrity": "sha512-ANVQjHQ/eHDruY9mRfREFS9LtGKwiFTFBjfJ4YpnJ7oYTiJwTXZQwxM/sUI7BiYCwgtyNnqYnKUfjh7zrRFZ7A==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@terrestris/ol-util/-/ol-util-11.1.0.tgz", + "integrity": "sha512-Ah05KNb9NyTn/yE+Z/Z8qorSi96loriFROtygf5f3vODs6mXXwpO2j490gQoxVyJMw8cJd+K1+GiMv2JeDpaVA==", "dependencies": { "@terrestris/base-util": "^1.0.1", "@turf/turf": "^6.5.0", @@ -5881,6 +5883,15 @@ "loglevel": "*" } }, + "node_modules/@types/mapbox-gl": { + "version": "2.7.12", + "resolved": "https://registry.npmjs.org/@types/mapbox-gl/-/mapbox-gl-2.7.12.tgz", + "integrity": "sha512-aEMMOWlSTn2lp0liLqHsI/vAkV8858mkhn4fFYZELdLO1o6PEKCkkUfQ/GBp603Xfc3xmasLZsoELJBbje+atw==", + "dev": true, + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/minimist": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", @@ -11361,9 +11372,9 @@ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" }, "node_modules/keycloak-js": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-22.0.0.tgz", - "integrity": "sha512-4/xJm6aswS/RLD3h3OhfZTrHAH6Ku/oDvBbK8/tgTxg0rywbxKUjCRUG2Zkw7UGwJPsrqhVT/nmsGTQqj3sQAw==", + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-22.0.1.tgz", + "integrity": "sha512-5cwOzMTMW2HuKGaIHv50BJHz2o8ID+YgzaaXKNwOk0XqD6ZOPD/jQXvqTz+Z8ID5cP46zVWnNiTouFK41NbPOQ==", "dependencies": { "base64-js": "^1.5.1", "js-sha256": "^0.9.0" @@ -11878,9 +11889,9 @@ } }, "node_modules/meow/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" @@ -18188,9 +18199,9 @@ "integrity": "sha512-ZnV3yH8/k58ZPACOXeiHaMuXIiaTk1t0hSUVisbO0t4RjA5wPpUytcxeyiN2h+LZRrmuHIh/1UlrR9e7DHDvTw==" }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true, "engines": { "node": ">=0.10.0" diff --git a/package.json b/package.json index 469b970c2..c436d3bf9 100644 --- a/package.json +++ b/package.json @@ -34,18 +34,19 @@ }, "dependencies": { "@terrestris/base-util": "^1.0.1", - "@terrestris/ol-util": "^11.0.0", + "@terrestris/ol-util": "^11.1.0", "geojson": "^0.5.0", - "keycloak-js": "^22.0.0", + "keycloak-js": "^22.0.1", "lodash": "^4.17.21", - "ol": "^7.4.0" + "ol": "^7.4.0", + "ol-mapbox-style": "^10.6.0" }, "devDependencies": { "@babel/core": "^7.22.9", "@babel/preset-env": "^7.22.9", "@babel/preset-typescript": "^7.22.5", - "@commitlint/cli": "^17.6.5", - "@commitlint/config-conventional": "^17.6.5", + "@commitlint/cli": "^17.6.7", + "@commitlint/config-conventional": "^17.6.7", "@semantic-release/changelog": "^6.0.3", "@semantic-release/commit-analyzer": "^10.0.1", "@semantic-release/git": "^10.0.1", @@ -56,6 +57,7 @@ "@types/geojson": "^7946.0.10", "@types/jest": "^29.5.3", "@types/lodash": "^4.14.195", + "@types/mapbox-gl": "^2.7.12", "eslint": "^8.45.0", "eslint-plugin-simple-import-sort": "^10.0.0", "husky": "^8.0.3", From 44d1fef6c5b7d8d9276c6f523ddc559dabeb5652 Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Fri, 21 Jul 2023 15:05:23 +0200 Subject: [PATCH 2/4] build: output ES2020 --- tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 069b31236..996a07662 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ "lib": ["es5", "es6", "dom"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ @@ -24,7 +24,7 @@ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ + "module": "ES2020", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ From f13e1daca46fa0d49818b351dca05968888ea5c5 Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Fri, 21 Jul 2023 15:06:15 +0200 Subject: [PATCH 3/4] feat: basic support for vectortile/mapboxstyle layers --- src/parser/SHOGunApplicationUtil.ts | 136 +++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/src/parser/SHOGunApplicationUtil.ts b/src/parser/SHOGunApplicationUtil.ts index f5fb7f8dd..fb2b17a77 100644 --- a/src/parser/SHOGunApplicationUtil.ts +++ b/src/parser/SHOGunApplicationUtil.ts @@ -4,6 +4,21 @@ import CapabilitiesUtil from '@terrestris/ol-util/dist/CapabilitiesUtil/Capabili import { MapUtil } from '@terrestris/ol-util/dist/MapUtil/MapUtil'; import ProjectionUtil, { defaultProj4CrsDefinitions } from '@terrestris/ol-util/dist/ProjectionUtil/ProjectionUtil'; import _uniqueBy from 'lodash/uniqBy'; +import type { + BackgroundLayer as MapboxBackgroundLayer, + CircleLayer as MapboxCircleLayer, + CustomLayerInterface as MapboxCustomLayerInterface, + FillExtrusionLayer as MapboxFillExtrusionLayer, + FillLayer as MapboxFillLayer, + HeatmapLayer as MapboxHeatmapLayer, + HillshadeLayer as MapboxHillshadeLayer, + Layer as MapboxLayer, + LineLayer as MapboxLineLayer, + RasterLayer as MapboxRasterLayer, + SkyLayer as MapboxSkyLayer, + Style as MapboxStyle, + SymbolLayer as MapboxSymbolLayer +} from 'mapbox-gl'; import { Extent as OlExtent } from 'ol/extent'; import OlFeature from 'ol/Feature'; import OlFormatGeoJSON from 'ol/format/GeoJSON'; @@ -14,6 +29,7 @@ import OlImageTile from 'ol/ImageTile'; import OlLayerBase from 'ol/layer/Base'; import OlLayerGroup from 'ol/layer/Group'; import OlImageLayer from 'ol/layer/Image'; +import OlLayer from 'ol/layer/Layer'; import OlTileLayer from 'ol/layer/Tile'; import OlLayerVector from 'ol/layer/Vector'; import { bbox as olStrategyBbox } from 'ol/loadingstrategy'; @@ -34,6 +50,7 @@ import OlTile from 'ol/Tile'; import OlTileGrid from 'ol/tilegrid/TileGrid'; import OlTileGridWMTS from 'ol/tilegrid/WMTS'; import OlView, { ViewOptions as OlViewOptions } from 'ol/View'; +import { apply as applyMapboxStyle } from 'ol-mapbox-style'; import { allLayersByIds @@ -230,8 +247,12 @@ class SHOGunApplicationUtil { return this.parseXYZLayer(layer); } - // TODO Add support for VECTORTILE - throw new Error('Currently only WMTS, WMS, TILEWMS, WFS, WMSTIME and XYZ layers are supported.'); + if (layer.type === 'VECTORTILE' || layer.type === 'MAPBOXSTYLE') { + return await this.parseMapboxStyleLayer(layer); + } + + Logger.error(`Unsupported layer type ${layer.type} given. Currently only WMS, TILEWMS, WMTS, ` + + 'WFS, WMSTIME, XYZ and VECTORTILE/MAPBOXSTYLE are supported.'); } parseImageLayer(layer: S) { @@ -614,6 +635,49 @@ class SHOGunApplicationUtil { return xyzLayer; } + async parseMapboxStyleLayer(layer: S) { + const { + url, + useBearerToken, + resolutions + } = layer.sourceConfig || {}; + + const { + minResolution, + maxResolution, + opacity, + } = layer.clientConfig || {}; + + const mapBoxLayerGroup = new OlLayerGroup({ + minResolution, + maxResolution, + opacity + }); + + await applyMapboxStyle( + mapBoxLayerGroup, + url, + { + resolutions: resolutions, + transformRequest: (resourceUrl, resourceType) => { + const request = new Request(resourceUrl, { + headers: useBearerToken ? { + ...getBearerTokenHeader(this.client?.getKeycloak()) + } : {} + }); + + return request; + } + } + ); + + this.setLayerTitles(mapBoxLayerGroup); + + this.setLayerProperties(mapBoxLayerGroup, layer); + + return mapBoxLayerGroup; + } + getMapScales(resolutions: number[], projUnit: Units = 'm'): number[] { return resolutions .map((res: number) => @@ -622,6 +686,74 @@ class SHOGunApplicationUtil { .reverse(); } + private setLayerTitles(mapBoxLayerGroup: OlLayerGroup) { + const getLayerTitle = (mapboxLayer: MapboxLayer) => { + return mapboxLayer['source-layer'] || mapboxLayer.source || mapboxLayer.id; + }; + + this.forEachLayer(mapBoxLayerGroup, childLayer => { + const mapBoxStyle: MapboxStyle = mapBoxLayerGroup.get('mapbox-style'); + const mapBoxLayers: string[] = childLayer.get('mapbox-layers'); + + const p = mapBoxLayers + ?.map(l => mapBoxStyle.layers.find(lay => lay.id === l)) + ?.map(l => { + if (!l) { + return; + } + + if (l.type === 'background') { + return getLayerTitle(l as MapboxBackgroundLayer); + } + if (l.type === 'circle') { + return getLayerTitle(l as MapboxCircleLayer); + } + if (l.type === 'fill-extrusion') { + return getLayerTitle(l as MapboxFillExtrusionLayer); + } + if (l.type === 'fill') { + return getLayerTitle(l as MapboxFillLayer); + } + if (l.type === 'heatmap') { + return getLayerTitle(l as MapboxHeatmapLayer); + } + if (l.type === 'hillshade') { + return getLayerTitle(l as MapboxHillshadeLayer); + } + if (l.type === 'line') { + return getLayerTitle(l as MapboxLineLayer); + } + if (l.type === 'raster') { + return getLayerTitle(l as MapboxRasterLayer); + } + if (l.type === 'symbol') { + return getLayerTitle(l as MapboxSymbolLayer); + } + if (l.type === 'sky') { + return getLayerTitle(l as MapboxSkyLayer); + } + if (l.type === 'custom') { + Logger.warn('Getting the name of a custom layer is not supported right now'); + } + }) + .filter(l => l); + + childLayer.set('name', [...new Set(p)].join('\n')); + }); + } + + private forEachLayer(groupLayer: OlLayerGroup, callback: (layer: OlLayer) => void) { + groupLayer.getLayers().forEach(childLayer => { + if (childLayer instanceof OlLayerGroup) { + this.forEachLayer(childLayer, callback); + } + + if (childLayer instanceof OlLayer) { + callback(childLayer); + } + }); + } + private mergeApplicationLayerConfigs(layers: S[], application: T): void { application.layerConfig?.forEach(layerConfig => { const layerCandidate = layers.find(layer => layer.id === layerConfig.layerId); From a12d64c8edd35a0f5f52520cc7465160c6b37508 Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Thu, 14 Sep 2023 11:32:59 +0200 Subject: [PATCH 4/4] fix: wip --- src/parser/SHOGunApplicationUtil.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/parser/SHOGunApplicationUtil.ts b/src/parser/SHOGunApplicationUtil.ts index fb2b17a77..bb36e08a8 100644 --- a/src/parser/SHOGunApplicationUtil.ts +++ b/src/parser/SHOGunApplicationUtil.ts @@ -673,6 +673,7 @@ class SHOGunApplicationUtil { this.setLayerTitles(mapBoxLayerGroup); + this.setLayerProps(mapBoxLayerGroup, layer); this.setLayerProperties(mapBoxLayerGroup, layer); return mapBoxLayerGroup; @@ -686,6 +687,24 @@ class SHOGunApplicationUtil { .reverse(); } + private setLayerProps(mapBoxLayerGroup: OlLayerGroup, layer: Layer) { + this.forEachLayer(mapBoxLayerGroup, childLayer => { + // childLayer.set('shogunId', layer.id); + // childLayer.set('name', layer.name); + // childLayer.set('type', layer.type); + // childLayer.set('searchable', layer.clientConfig?.searchable); + childLayer.set('propertyConfig', layer.clientConfig?.propertyConfig); + // childLayer.set('downloadConfig', layer.clientConfig?.downloadConfig); + // childLayer.set('searchConfig', layer.clientConfig?.searchConfig); + // childLayer.set('legendUrl', layer.sourceConfig?.legendUrl); + childLayer.set('hoverable', layer.clientConfig?.hoverable); + childLayer.set('useBearerToken', layer.sourceConfig?.useBearerToken); + // childLayer.set('editable', layer.clientConfig?.editable); + // childLayer.set('editFormConfig', layer.clientConfig?.editFormConfig); + childLayer.set('featureInfoFormConfig', layer.clientConfig?.featureInfoFormConfig); + }); + } + private setLayerTitles(mapBoxLayerGroup: OlLayerGroup) { const getLayerTitle = (mapboxLayer: MapboxLayer) => { return mapboxLayer['source-layer'] || mapboxLayer.source || mapboxLayer.id;