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

geosolutions-it / MapStore2 / 19935919825

04 Dec 2025 04:19PM UTC coverage: 76.703% (+0.04%) from 76.661%
19935919825

Pull #11648

github

web-flow
Merge f9ef0e5ca into a0da62e93
Pull Request #11648: #11644: Implement dynamic request configurations

32405 of 50408 branches covered (64.29%)

220 of 244 new or added lines in 42 files covered. (90.16%)

3 existing lines in 3 files now uncovered.

40299 of 52539 relevant lines covered (76.7%)

40.18 hits per line

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

8.33
/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 { isEqual } from 'lodash';
16
import { hasRequestConfigurationByUrl } from '../../../../utils/SecurityUtils';
17
function lBoundsToOlExtent(bounds, destPrj) {
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✔
23
    axios.get(src, {
×
24
        _msAuthSourceId: options.security?.sourceId,
25
        responseType: 'blob'
26
    }).then(response => {
27
        image.getImage().src = URL.createObjectURL(response.data);
×
28
    }).catch(e => {
29
        image.getImage().src = null;
×
30
        console.error(e);
×
31
    });
32
};
33
function tileXYZToOpenlayersOptions(options) {
34
    let urls = options.url.match(/(\{s\})/) ? getUrls(options) : [template(options.url, options)];
×
35
    let sourceOpt = Object.assign({}, {
×
36
        urls: urls,
37
        attributions: options.attribution ? [options.attribution] : [],
×
38
        maxZoom: options.maxZoom ? options.maxZoom : 18,
×
39
        minZoom: options.minZoom ? options.minZoom : 0 // dosen't affect ol layer rendering UNSUPPORTED
×
40
    });
NEW
41
    if (hasRequestConfigurationByUrl(options.url, null, options.security?.sourceId)) {
×
42
        sourceOpt.tileLoadFunction = tileLoadFunction(options);
×
43
    }
44
    let source = new XYZ(sourceOpt);
×
45
    let olOpt = Object.assign({}, {
×
46
        msId: options.id,
47
        opacity: options.opacity !== undefined ? options.opacity : 1,
×
48
        visible: options.visibility !== false,
49
        zIndex: options.zIndex,
50
        source: source,
51
        minResolution: options.minResolution,
52
        maxResolution: options.maxResolution
53
    }, options.bounds ? {extent: lBoundsToOlExtent(options.bounds, options.srs ? options.srs : 'EPSG:3857')} : {} );
×
54
    return olOpt;
×
55
}
56

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

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

© 2026 Coveralls, Inc