• 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

95.0
/web/client/components/map/leaflet/plugins/WMTSLayer.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
import {normalizeSRS} from '../../../../utils/CoordinatesUtils';
11
import L from 'leaflet';
12
import {addAuthenticationParameter} from '../../../../utils/SecurityUtils';
13
import { creditsToAttribution } from '../../../../utils/LayersUtils';
14
import * as WMTSUtils from '../../../../utils/WMTSUtils';
15
import WMTS from '../../../../utils/leaflet/WMTS';
16
import { isArray } from 'lodash';
17
import { isVectorFormat } from '../../../../utils/VectorTileUtils';
18

19
L.tileLayer.wmts = function(urls, options, matrixOptions) {
1✔
20
    return new WMTS(urls, options, matrixOptions);
13✔
21
};
22

23
function wmtsToLeafletOptions(options) {
24
    const srs = normalizeSRS(options.srs || 'EPSG:3857', options.allowedSRS);
13✔
25
    const attribution = options.credits && creditsToAttribution(options.credits) || '';
13✔
26
    const tileMatrixSet = WMTSUtils.getTileMatrixSet(options.tileMatrixSet, srs, options.allowedSRS, options.matrixIds);
13✔
27
    return Object.assign({
13✔
28
        requestEncoding: options.requestEncoding,
29
        layer: options.name,
30
        style: options.style || "",
26✔
31
        attribution,
32
        // set image format to png if vector to avoid errors while switching between map type
33
        format: isVectorFormat(options.format) && 'image/png' || options.format || 'image/png',
26!
34
        tileMatrixSet: tileMatrixSet,
35
        version: options.version || "1.0.0",
26✔
36
        tileSize: options.tileSize || 256,
26✔
37
        CRS: normalizeSRS(options.srs || 'EPSG:3857', options.allowedSRS),
26✔
38
        maxZoom: options.maxZoom || 23,
26✔
39
        maxNativeZoom: options.maxNativeZoom || 18
26✔
40
    }, options.params || {});
26✔
41
}
42

43
function getWMSURLs(urls) {
44
    return urls.map((url) => url.split("\?")[0]);
14✔
45
}
46

47
const createLayer = _options => {
1✔
48
    const options = WMTSUtils.parseTileMatrixSetOption(_options);
13✔
49
    const urls = getWMSURLs(isArray(options.url) ? options.url : [options.url]);
13✔
50
    const queryParameters = wmtsToLeafletOptions(options) || {};
13!
51
    urls.forEach(url => addAuthenticationParameter(url, queryParameters, options.securityToken));
14✔
52
    const srs = normalizeSRS(options.srs || 'EPSG:3857', options.allowedSRS);
13✔
53
    const { tileMatrixSet, matrixIds } = WMTSUtils.getTileMatrix(options, srs);
13✔
54
    return L.tileLayer.wmts(urls, queryParameters, {
13✔
55
        tileMatrixPrefix: options.tileMatrixPrefix || queryParameters.tileMatrixSet + ':' || srs + ':',
26!
56
        originY: options.originY || 20037508.3428,
26✔
57
        originX: options.originX || -20037508.3428,
26✔
58
        ignoreErrors: options.ignoreErrors || false,
26✔
59
        // TODO: use matrix IDs sorted from getTileMatrix
60
        matrixIds: matrixIds,
61
        matrixSet: tileMatrixSet
62
    });
63
};
64

65
const updateLayer = (layer, newOptions, oldOptions) => {
1✔
66
    if (oldOptions.securityToken !== newOptions.securityToken
5!
67
    || oldOptions.format !== newOptions.format
68
    || oldOptions.credits !== newOptions.credits) {
69
        return createLayer(newOptions);
5✔
70
    }
UNCOV
71
    return null;
×
72
};
73

74
Layers.registerType('wmts', {create: createLayer, update: updateLayer});
1✔
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