• 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

93.88
/web/client/utils/leaflet/WMSUtils.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 L from 'leaflet';
10
import { isNil } from 'lodash';
11
import { creditsToAttribution, getWMSVendorParams } from '../LayersUtils';
12
import { isVectorFormat } from '../VectorTileUtils';
13
import { optionsToVendorParams } from '../VendorParamsUtils';
14
import { addAuthenticationToSLD } from '../SecurityUtils';
15

16
// implementation used by wms and elevation types
17
L.TileLayer.MultipleUrlWMS = L.TileLayer.WMS.extend({
1✔
18
    initialize: function(urls, options) {
19
        this._url = urls[0];
23✔
20
        this._urls = urls;
23✔
21

22
        this._urlsIndex = 0;
23✔
23

24
        let wmsParams = L.extend({}, this.defaultWmsParams);
23✔
25
        let tileSize = options.tileSize || this.options.tileSize;
23!
26

27
        if (options.detectRetina && L.Browser.retina) {
23!
UNCOV
28
            wmsParams.width = wmsParams.height = tileSize * 2;
×
29
        } else {
30
            wmsParams.width = wmsParams.height = tileSize;
23✔
31
        }
32
        for (let i in options) {
23✔
33
            // all keys that are not TileLayer options go to WMS params
34
            if (!this.options.hasOwnProperty(i) && i.toUpperCase() !== 'CRS' && i !== "maxNativeZoom") {
262✔
35
                wmsParams[i] = options[i];
239✔
36
            }
37
        }
38
        this.wmsParams = wmsParams;
23✔
39

40
        L.setOptions(this, options);
23✔
41
    },
42
    getTileUrl: function(tilePoint) { // (Point, Number) -> String
43
        let map = this._map;
76✔
44
        let tileSize = this.options.tileSize;
76✔
45

46
        let nwPoint = tilePoint.multiplyBy(tileSize);
76✔
47
        let sePoint = nwPoint.add([tileSize, tileSize]);
76✔
48

49
        let nw = this._crs.project(map.unproject(nwPoint, tilePoint.z));
76✔
50
        let se = this._crs.project(map.unproject(sePoint, tilePoint.z));
76✔
51
        let bbox = this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ?
76!
52
            [se.y, nw.x, nw.y, se.x].join(',') :
53
            [nw.x, se.y, se.x, nw.y].join(',');
54
        this._urlsIndex++;
76✔
55
        if (this._urlsIndex === this._urls.length) {
76!
56
            this._urlsIndex = 0;
76✔
57
        }
58
        const url = L.Util.template(this._urls[this._urlsIndex], {s: this._getSubdomain(tilePoint)});
76✔
59

60
        return url + L.Util.getParamString(this.wmsParams, url, true) + '&BBOX=' + bbox;
76✔
61
    },
62
    removeParams: function(params = [], noRedraw) {
×
63
        params.forEach( key => delete this.wmsParams[key]);
2✔
64
        if (!noRedraw) {
2!
UNCOV
65
            this.redraw();
×
66
        }
67
        return this;
2✔
68
    }
69
});
70

71
L.tileLayer.multipleUrlWMS = function(urls, options) {
1✔
72
    return new L.TileLayer.MultipleUrlWMS(urls, options);
17✔
73
};
74

75
export const PARAM_OPTIONS = ["layers", "styles", "format", "transparent", "version", "tiled", "zindex", "_v_", "cql_filter", "sld"];
1✔
76

77
export const filterWMSParamOptions = (options) => {
1✔
78
    let paramOptions = {};
11✔
79
    Object.keys(options).forEach((key) => {
11✔
80
        if (!key || !key.toLowerCase) {
123!
UNCOV
81
            return;
×
82
        }
83
        if (PARAM_OPTIONS.indexOf(key.toLowerCase()) >= 0) {
123✔
84
            paramOptions[key] = options[key];
72✔
85
        }
86
    });
87
    return paramOptions;
11✔
88
};
89

90
export function wmsToLeafletOptions(options) {
91
    var opacity = options.opacity !== undefined ? options.opacity : 1;
36✔
92
    const params = optionsToVendorParams(options);
36✔
93
    // NOTE: can we use opacity to manage visibility?
94
    const result = {
36✔
95
        ...options.baseParams,
96
        attribution: options.credits && creditsToAttribution(options.credits),
37✔
97
        layers: options.name,
98
        styles: options.style || "",
72✔
99
        format: isVectorFormat(options.format) && 'image/png' || options.format || 'image/png',
80✔
100
        transparent: options.transparent !== undefined ? options.transparent : true,
36!
101
        ...getWMSVendorParams(options),
102
        opacity: opacity,
103
        zIndex: options.zIndex,
104
        version: options.version || "1.3.0",
72✔
105
        tileSize: options.tileSize || 256,
71✔
106
        maxZoom: options.maxZoom || 23,
70✔
107
        maxNativeZoom: options.maxNativeZoom || 18,
72✔
108
        ...(options._v_ ? {_v_: options._v_} : {}),
36!
109
        ...(params || {})
66✔
110
    };
111
    return addAuthenticationToSLD(result, options);
36✔
112
}
113

114
export function getWMSURLs( urls ) {
115
    return urls.map((url) => url.split("\?")[0]);
28✔
116
}
117

118
export const removeNulls = (obj = {}) => {
1!
119
    return Object.keys(obj).reduce((previous, key) => {
25✔
120
        return isNil(obj[key]) ? previous : Object.assign(previous, {
287✔
121
            [key]: obj[key]
122
        });
123
    }, {});
124
};
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