• 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

8.0
/web/client/components/map/openlayers/plugins/TileProviderLayer.js
1
/**
2
 * Copyright 2015, 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
import Layers from '../../../../utils/openlayers/Layers';
9
import TileProvider from '../../../../utils/TileConfigProvider';
10
import CoordinatesUtils from '../../../../utils/CoordinatesUtils';
11
import { getUrls, template } from '../../../../utils/TileProviderUtils';
12
import XYZ from 'ol/source/XYZ';
13
import TileLayer from 'ol/layer/Tile';
14
import axios from 'axios';
15
import { getCredentials } from '../../../../utils/SecurityUtils';
16
import { isEqual } from 'lodash';
17
function lBoundsToOlExtent(bounds, destPrj) {
UNCOV
18
    var [ [ miny, minx], [ maxy, maxx ] ] = bounds;
×
19
    return CoordinatesUtils.reprojectBbox([minx, miny, maxx, maxy], 'EPSG:4326', CoordinatesUtils.normalizeSRS(destPrj));
×
20
}
21

22
const tileLoadFunction = options => (image, src) => {
1✔
UNCOV
23
    const storedProtectedService = getCredentials(options.security?.sourceId) || {};
×
24
    axios.get(src, {
×
25
        headers: {
26
            "Authorization": `Basic ${btoa(storedProtectedService.username + ":" + storedProtectedService.password)}`
27
        },
28
        responseType: 'blob'
29
    }).then(response => {
UNCOV
30
        image.getImage().src = URL.createObjectURL(response.data);
×
31
    }).catch(e => {
UNCOV
32
        image.getImage().src = null;
×
33
        console.error(e);
×
34
    });
35
};
36
function tileXYZToOpenlayersOptions(options) {
UNCOV
37
    let urls = options.url.match(/(\{s\})/) ? getUrls(options) : [template(options.url, options)];
×
38
    let sourceOpt = Object.assign({}, {
×
39
        urls: urls,
40
        attributions: options.attribution ? [options.attribution] : [],
×
41
        maxZoom: options.maxZoom ? options.maxZoom : 18,
×
42
        minZoom: options.minZoom ? options.minZoom : 0 // dosen't affect ol layer rendering UNSUPPORTED
×
43
    });
UNCOV
44
    if (options.security) {
×
45
        sourceOpt.tileLoadFunction = tileLoadFunction(options);
×
46
    }
UNCOV
47
    let source = new XYZ(sourceOpt);
×
48
    let olOpt = Object.assign({}, {
×
49
        msId: options.id,
50
        opacity: options.opacity !== undefined ? options.opacity : 1,
×
51
        visible: options.visibility !== false,
52
        zIndex: options.zIndex,
53
        source: source,
54
        minResolution: options.minResolution,
55
        maxResolution: options.maxResolution
56
    }, options.bounds ? {extent: lBoundsToOlExtent(options.bounds, options.srs ? options.srs : 'EPSG:3857')} : {} );
×
UNCOV
57
    return olOpt;
×
58
}
59

60
Layers.registerType('tileprovider', {
1✔
61
    create: (options) => {
UNCOV
62
        let [url, opt] = TileProvider.getLayerConfig(options.provider, options);
×
63
        opt.url = url;
×
64
        return new TileLayer(tileXYZToOpenlayersOptions(opt));
×
65
    },
66
    update: (layer, newOptions, oldOptions) => {
UNCOV
67
        if (oldOptions.minResolution !== newOptions.minResolution) {
×
68
            layer.setMinResolution(newOptions.minResolution === undefined ? 0 : newOptions.minResolution);
×
69
        }
UNCOV
70
        if (oldOptions.maxResolution !== newOptions.maxResolution) {
×
71
            layer.setMaxResolution(newOptions.maxResolution === undefined ? Infinity : newOptions.maxResolution);
×
72
        }
UNCOV
73
        if (!isEqual(oldOptions.security, newOptions.security)) {
×
74
            layer.getSource().setTileLoadFunction(tileLoadFunction(newOptions));
×
75
        }
76
    }
77
});
78

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