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

geosolutions-it / MapStore2 / 14797665772

02 May 2025 02:55PM UTC coverage: 76.933% (-0.06%) from 76.991%
14797665772

Pull #11067

github

web-flow
Merge 99dcd7f92 into d28bf7035
Pull Request #11067: Fix #10966 basic auth for services

30858 of 48053 branches covered (64.22%)

104 of 172 new or added lines in 24 files covered. (60.47%)

3 existing lines in 3 files now uncovered.

38384 of 49893 relevant lines covered (76.93%)

35.93 hits per line

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

48.72
/web/client/components/map/cesium/plugins/TileProviderLayer.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/cesium/Layers';
10
import * as Cesium from 'cesium';
11
import TileProvider from '../../../../utils/TileConfigProvider';
12
import ConfigUtils from '../../../../utils/ConfigUtils';
13
import {creditsToAttribution} from '../../../../utils/LayersUtils';
14
import {getProxyUrl} from '../../../../utils/ProxyUtils';
15
import isEqual from 'lodash/isEqual';
16

17
function splitUrl(originalUrl) {
18
    let url = originalUrl;
×
19
    let queryString = "";
×
20
    if (originalUrl.indexOf('?') !== -1) {
×
21
        url = originalUrl.substring(0, originalUrl.indexOf('?') + 1);
×
22
        if (originalUrl.indexOf('%') !== -1) {
×
23
            url = decodeURIComponent(url);
×
24
        }
25
        queryString = originalUrl.substring(originalUrl.indexOf('?') + 1);
×
26
    }
27
    return {url, queryString};
×
28
}
29

30
function TileProviderProxy(proxy) {
31
    this.proxy = proxy;
×
32
}
33

34
TileProviderProxy.prototype.getURL = function(resource) {
1✔
35
    let {url, queryString} = splitUrl(resource);
×
36
    if (url.indexOf("//") === 0) {
×
37
        url = location.protocol + url;
×
38
    }
39
    return getProxyUrl() + encodeURIComponent(url + queryString);
×
40
};
41

42
function NoProxy() {
43
}
44

45
NoProxy.prototype.getURL = (r) => r;
1✔
46

47
/**
48
 * Returns the URL passed as parameter, replacing all the variables with the values in the data object, except for the variables x, y, z and s, that are reserved for the tile coordinates and server.
49
 * @param {string} URL the string to replace
50
 * @param {object} data data to use for replacement
51
 * @returns {string}
52
 */
53
export function template(str, data) {
54

55
    return str.replace(/{([^{}]+)}/g, function(textMatched, key) {
6✔
56
        if (['x', 'y', 'z', 's'].includes(key)) {
29✔
57
            return textMatched;
21✔
58
        }
59
        if (key === '-x') {
8!
60
            return "{reverseX}";
×
61
        }
62
        if (key === '-y') {
8!
63
            return "{reverseY}";
×
64
        }
65

66
        let value = data[key];
8✔
67

68
        if (value === undefined) {
8!
69
            throw new Error('No value provided for variable ' + key);
×
70

71
        } else if (typeof value === 'function') {
8!
72
            value = value(data);
×
73
        }
74
        return value;
8✔
75
    });
76
}
77

78
const create = (options) => {
1✔
79
    let [url, opt] = TileProvider.getLayerConfig(options.provider, options);
1✔
80
    let proxyUrl = ConfigUtils.getProxyUrl({});
1✔
81
    const cr = opt.credits;
1✔
82

83
    const credit = cr ? new Cesium.Credit(creditsToAttribution(cr)) : opt.attribution;
1!
84
    return new Cesium.UrlTemplateImageryProvider({
1✔
85
        url: template(url, opt),
86
        enablePickFeatures: false,
87
        subdomains: opt.subdomains,
88
        maximumLevel: opt.maxZoom,
89
        minimumLevel: opt.minZoom,
90
        credit,
91
        proxy: options?.forceProxy ? new TileProviderProxy(proxyUrl) : new NoProxy()
1!
92
    });
93
};
94

95
const update = (layer, newOptions, oldOptions) => {
1✔
NEW
96
    if (
×
97
        newOptions.forceProxy !== oldOptions.forceProxy ||
×
98
        !isEqual(oldOptions.security, newOptions.security)
99
    ) {
UNCOV
100
        return create(newOptions);
×
101
    }
102
    return null;
×
103
};
104

105
Layers.registerType('tileprovider', {
1✔
106
    create,
107
    update: update
108
});
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