Skip to content

Commit

Permalink
[Bugfix] Action Symbology module: perform request only if layers are …
Browse files Browse the repository at this point in the history
…displayed in the tree
  • Loading branch information
rldhont committed Jul 19, 2023
1 parent 8b82ec2 commit cdf57ca
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions assets/src/modules/action/Symbology.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import WMS from './../WMS.js';
import {LayerTreeLayerState, LayerTreeGroupState} from './../state/LayerTree.js'

/**
* @param {LayerTreeLayerState[]} treeLayers - The tree layer group in which tree layers will be updated
*
* @returns {Promise} Promise object represents the tree layers updated
*/
export async function updateLayerTreeLayersSymbology(treeLayers) {
if (!Array.isArray(treeLayers)) {
throw new TypeError('`updateLayerTreeLayersSymbology` method required an array as parameter!');
}

// If the tree layers is empty
// nothing to do
if (treeLayers.length == 0) {
return treeLayers;
}

const wmsNames = treeLayers.map(layer => layer.wmsName);
const wmsStyles = treeLayers.map(layer => layer.wmsSelectedStyleName);
let treeLayersByName = {};
Expand All @@ -30,6 +41,9 @@ export async function updateLayerTreeLayersSymbology(treeLayers) {
* @returns {Promise} Promise object represents the tree layer updated
*/
export async function updateLayerTreeLayerSymbology(treeLayer) {
if (!(treeLayer instanceof LayerTreeLayerState)) {
throw new TypeError('`updateLayerTreeLayerSymbology` method required a LayerTreeLayerState as parameter!');
}
return updateLayerTreeLayersSymbology([treeLayer])[0];
}

Expand All @@ -39,5 +53,8 @@ export async function updateLayerTreeLayerSymbology(treeLayer) {
* @returns {Promise} Promise object represents the tree layers updated
*/
export async function updateLayerTreeGroupLayersSymbology(treeGroup) {
if (!(treeGroup instanceof LayerTreeGroupState)) {
throw new TypeError('`updateLayerTreeGroupLayersSymbology` method required a LayerTreeGroupState as parameter!');
}
return updateLayerTreeLayersSymbology(treeGroup.findTreeLayers());
}

0 comments on commit cdf57ca

Please sign in to comment.