Skip to content

Commit

Permalink
Merge pull request #4516 from rldhont/fix-startup-project-background-…
Browse files Browse the repository at this point in the history
…color

Fix: project-background-color group as startup base layer
  • Loading branch information
rldhont authored Jun 14, 2024
2 parents ec65a60 + b82d548 commit 3a99d4c
Show file tree
Hide file tree
Showing 9 changed files with 1,669 additions and 56 deletions.
32 changes: 16 additions & 16 deletions assets/src/modules/config/BaseLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,19 +911,6 @@ export class BaseLayersConfig {
extendedCfg[layerCfg.name].layerConfig = layerCfg;
}

// Define startup base layer based on names from tree
this._startupBaselayer = null;
if (names.length != 0) {
this._startupBaselayer = names[0];
}

// Add names from keys
for (const key in extendedCfg) {
if (names.indexOf(key) == -1) {
names.push(key);
}
}

// Add base layer as project default background color
// Get provided default background color index from options
const default_background_color_index = options.hasOwnProperty('default_background_color_index') ? options.default_background_color_index : -1;
Expand All @@ -949,12 +936,12 @@ export class BaseLayersConfig {
if (i <= baselayersGroupIndex) {
continue;
}
if (baselayerCfg.type != 'group') {
background_color_index += 1
}
if (i > global_background_color_index) {
break;
}
if (baselayerCfg.type != 'group') {
background_color_index += 1
}
if (baselayerCfg.name == 'project-background-color') {
background_color_index += 1
}
Expand All @@ -970,6 +957,19 @@ export class BaseLayersConfig {
}
}

// Define startup base layer based on names from tree
this._startupBaselayer = null;
if (names.length != 0) {
this._startupBaselayer = names[0];
}

// Add names from keys
for (const key in extendedCfg) {
if (names.indexOf(key) == -1) {
names.push(key);
}
}

this._names = [];
this._configs = [];
for (const key of names) {
Expand Down
8 changes: 4 additions & 4 deletions tests/js-units/data/backgrounds-capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,8 @@
"noSubsets": false
},
{
"Name": "WM_T_S_are_on_demo_lizmap_com",
"Title": "=== WM[T]S are on demo.lizmap.com ===",
"Name": "WM_T_S_are_on_liz_lizmap_com",
"Title": "=== WM[T]S are on liz.lizmap.com ===",
"CRS": [
"CRS:84",
"EPSG:3857",
Expand Down Expand Up @@ -1318,7 +1318,7 @@
"noSubsets": false
},
{
"Name": "WMTS_demo_lizmap_com_communes",
"Name": "WMTS_liz_lizmap_com_communes",
"Title": "WMTS single external",
"CRS": [
"CRS:84",
Expand Down Expand Up @@ -1369,7 +1369,7 @@
"LegendURL": [
{
"Format": "image/png",
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=base_layers_user_defined&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=WMTS_demo_lizmap_com_communes&FORMAT=image/png&STYLE=default&SLD_VERSION=1.1.0",
"OnlineResource": "http://localhost:8130/index.php/lizmap/service?repository=testsrepository&project=base_layers_user_defined&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&LAYER=WMTS_liz_lizmap_com_communes&FORMAT=image/png&STYLE=default&SLD_VERSION=1.1.0",
"size": [
null,
null
Expand Down
18 changes: 9 additions & 9 deletions tests/js-units/data/backgrounds-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@
"shortname": "local_raster",
"layerType": "raster"
},
"=== WM[T]S are on demo.lizmap.com ===": {
"id": "=== WM[T]S are on demo.lizmap.com ===",
"name": "=== WM[T]S are on demo.lizmap.com ===",
"=== WM[T]S are on liz.lizmap.com ===": {
"id": "=== WM[T]S are on liz.lizmap.com ===",
"name": "=== WM[T]S are on liz.lizmap.com ===",
"type": "group",
"title": "=== WM[T]S are on demo.lizmap.com ===",
"title": "=== WM[T]S are on liz.lizmap.com ===",
"abstract": "",
"link": "",
"minScale": 1,
Expand All @@ -668,7 +668,7 @@
"imageFormat": "image/png",
"cached": "False",
"clientCacheExpiration": 300,
"shortname": "WM_T_S_are_on_demo_lizmap_com"
"shortname": "WM_T_S_are_on_liz_lizmap_com"
},
"WMTS single external": {
"id": "Communes_37a6346a_94e4_4071_8fa5_94f406319b05",
Expand Down Expand Up @@ -701,7 +701,7 @@
"imageFormat": "image/png",
"cached": "False",
"clientCacheExpiration": 300,
"shortname": "WMTS_demo_lizmap_com_communes",
"shortname": "WMTS_liz_lizmap_com_communes",
"layerType": "raster",
"externalWmsToggle": "True",
"externalAccess": {
Expand All @@ -711,7 +711,7 @@
"layers": "Communes",
"styles": "default",
"tileMatrixSet": "EPSG:3857",
"url": "https://demo.lizmap.com/lizmap/index.php/lizmap/service?repository=cypress&project=wmts&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities",
"url": "https://liz.lizmap.com/tests/index.php/lizmap/service?repository=testse2elwc&project=wmts&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities",
"type": "wmts"
}
},
Expand Down Expand Up @@ -750,7 +750,7 @@
"layerType": "raster"
},
"WMS grouped external": {
"id": "WMS_demo_lizmap_com_communes_1d5559c6_3210_42c0_b4ee_227d19588dc2",
"id": "WMS_liz_lizmap_com_communes_1d5559c6_3210_42c0_b4ee_227d19588dc2",
"name": "WMS grouped external",
"type": "layer",
"extent": [
Expand Down Expand Up @@ -789,7 +789,7 @@
"format": "image/png;%20mode%3D8bit",
"layers": "commune",
"styles": "d%C3%A9faut",
"url": "https://demo.lizmap.com/lizmap/index.php/lizmap/service?repository=miscellaneous&project=flatgeobuf&VERSION=1.3.0"
"url": "https://liz.lizmap.com/tests/index.php/lizmap/service?repository=miscellaneous&project=flatgeobuf&VERSION=1.3.0"
},
"shortname": "WMST_lizmap_com_MTP",
"layerType": "raster"
Expand Down
Loading

0 comments on commit 3a99d4c

Please sign in to comment.