• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 19710972030

26 Nov 2025 03:38PM UTC coverage: 76.665% (-0.3%) from 76.929%
19710972030

Pull #11119

github

web-flow
Fix maven publish (#11739)
Pull Request #11119: Layer Selection Plugin on ArcGIS, WFS & WMS layers

32272 of 50209 branches covered (64.28%)

3 of 3 new or added lines in 2 files covered. (100.0%)

3018 existing lines in 249 files now uncovered.

40157 of 52380 relevant lines covered (76.66%)

37.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.7
/web/client/components/map/leaflet/plugins/WMSLayer.js
1
/*
2
 * Copyright 2017, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
import Layers from '../../../../utils/leaflet/Layers';
10

11
import { filterWMSParamOptions, getWMSURLs, wmsToLeafletOptions, removeNulls } from '../../../../utils/leaflet/WMSUtils';
12
import L from 'leaflet';
13
import { isArray } from 'lodash';
14
import {addAuthenticationToSLD, addAuthenticationParameter} from '../../../../utils/SecurityUtils';
15

16
import 'leaflet.nontiledlayer';
17

18
L.NonTiledLayer.WMSCustom = L.NonTiledLayer.WMS.extend({
1✔
19
    initialize: function(url, options) { // (String, Object)
20
        this._wmsUrl = url;
2✔
21

22
        let wmsParams = L.extend({}, this.defaultWmsParams);
2✔
23

24
        // all keys that are not NonTiledLayer options go to WMS params
25
        for (let i in options) {
2✔
26
            if (!this.options.hasOwnProperty(i) && i.toUpperCase() !== 'CRS' && i !== "maxNativeZoom") {
24✔
27
                wmsParams[i] = options[i];
22✔
28
            }
29
        }
30

31
        this.wmsParams = wmsParams;
2✔
32

33
        L.setOptions(this, options);
2✔
34
    },
35
    removeParams: function(params = [], noRedraw) {
×
UNCOV
36
        params.forEach( key => delete this.wmsParams[key]);
×
37
        if (!noRedraw) {
×
38
            this.redraw();
×
39
        }
UNCOV
40
        return this;
×
41
    }
42
});
43
L.nonTiledLayer.wmsCustom = function(url, options) {
1✔
44
    return new L.NonTiledLayer.WMSCustom(url, options);
2✔
45
};
46

47
Layers.registerType('wms', {
1✔
48
    create: (options, map, mapId) => {
49
        // the useForElevation in wms types will be deprecated
50
        // as support for existing configuration
51
        // we can use this fallback
52
        if (options.useForElevation) {
20✔
53
            return Layers.createLayer('elevation', {
4✔
54
                ...options,
55
                provider: 'wms'
56
            }, map, mapId);
57
        }
58
        const urls = getWMSURLs(isArray(options.url) ? options.url : [options.url]);
16✔
59
        const queryParameters = removeNulls(wmsToLeafletOptions(options) || {});
16!
60
        urls.forEach(url => addAuthenticationParameter(url, queryParameters, options.securityToken));
17✔
61
        if (options.singleTile) {
16✔
62
            return L.nonTiledLayer.wmsCustom(urls[0], queryParameters);
1✔
63
        }
64
        return L.tileLayer.multipleUrlWMS(urls, queryParameters);
15✔
65
    },
66
    update: function(layer, newOptions, oldOptions) {
67
        if (oldOptions.singleTile !== newOptions.singleTile || oldOptions.tileSize !== newOptions.tileSize || oldOptions.securityToken !== newOptions.securityToken && newOptions.visibility) {
8✔
68
            let newLayer;
69
            const urls = getWMSURLs(isArray(newOptions.url) ? newOptions.url : [newOptions.url]);
3!
70
            const queryParameters = wmsToLeafletOptions(newOptions) || {};
3!
71
            urls.forEach(url => addAuthenticationParameter(url, queryParameters, newOptions.securityToken));
3✔
72
            if (newOptions.singleTile) {
3✔
73
                // return the nonTiledLayer
74
                newLayer = L.nonTiledLayer.wmsCustom(urls[0], queryParameters);
1✔
75
            } else {
76
                newLayer = L.tileLayer.multipleUrlWMS(urls, queryParameters);
2✔
77
            }
78
            return newLayer;
3✔
79
        }
80
        // find the options that make a parameter change
81
        let oldqueryParameters = Object.assign({}, filterWMSParamOptions(wmsToLeafletOptions(oldOptions)),
5✔
82
            addAuthenticationToSLD(oldOptions.params || {}, oldOptions));
10✔
83
        let newQueryParameters = Object.assign({}, filterWMSParamOptions(wmsToLeafletOptions(newOptions)),
5✔
84
            addAuthenticationToSLD(newOptions.params || {}, newOptions));
10✔
85
        let newParameters = Object.keys(newQueryParameters).filter((key) => {return newQueryParameters[key] !== oldqueryParameters[key]; });
35✔
86
        let removeParams = Object.keys(oldqueryParameters).filter((key) => { return oldqueryParameters[key] !== newQueryParameters[key]; });
35✔
87
        let newParams = {};
5✔
88
        if (removeParams.length > 0) {
5✔
89
            layer.removeParams(removeParams, newParameters.length > 0);
2✔
90
        }
91
        if ( newParameters.length > 0 ) {
5✔
92
            newParams = newParameters.reduce( (accumulator, currentValue) => {
2✔
93
                return Object.assign({}, accumulator, {[currentValue]: newQueryParameters[currentValue] });
2✔
94
            }, newParams);
95
            // set new options as parameters, merged with params
96
            layer.setParams(removeNulls(Object.assign(newParams, newParams.params, addAuthenticationToSLD(newOptions.params || {}, newOptions))));
2✔
97
        }/* else if (!isEqual(newOptions.params, oldOptions.params)) {
98
            layer.setParams(newOptions.params);
99
        }*/
100
        return null;
5✔
101
    }
102
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc