• 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

94.74
/web/client/components/map/leaflet/plugins/ElevationLayer.js
1
/*
2
 * Copyright 2023, 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 L from 'leaflet';
11
import { isArray } from 'lodash';
12
import { addAuthenticationParameter } from '../../../../utils/SecurityUtils';
13
import { loadTile, getElevation, getElevationKey } from '../../../../utils/ElevationUtils';
14
import { getWMSURLs, wmsToLeafletOptions, removeNulls } from '../../../../utils/leaflet/WMSUtils';
15

16
L.TileLayer.ElevationWMS = L.TileLayer.MultipleUrlWMS.extend({
1✔
17
    initialize: function(urls, options, nodata, littleEndian, id) {
18
        this._msId = id;
6✔
19
        this._tiles = {};
6✔
20
        this._nodata = nodata;
6✔
21
        this._littleEndian = littleEndian;
6✔
22
        L.TileLayer.MultipleUrlWMS.prototype.initialize.apply(this, arguments);
6✔
23
    },
24
    _addTile: function(coords) {
25
        const tileUrl = this.getTileUrl(coords);
72✔
26
        loadTile(tileUrl, coords, getElevationKey(coords.x, coords.y, coords.z, this._msId));
72✔
27
    },
28

29
    getElevation: function(latLng, containerPoint) {
30
        try {
5✔
31
            const tilePoint = this._getTileFromCoords(latLng);
5✔
32
            const elevation = getElevation(
3✔
33
                getElevationKey(tilePoint.x, tilePoint.y, tilePoint.z, this._msId),
34
                this._getTileRelativePixel(tilePoint, containerPoint),
35
                this.getTileSize().x,
36
                this._nodata, this._littleEndian
37
            );
38
            if (elevation.available) {
3!
UNCOV
39
                return elevation.value;
×
40
            }
41
            return '';
3✔
42
        } catch (e) {
43
            return '';
2✔
44
        }
45
    },
46
    _getTileFromCoords: function(latLng) {
47
        const layerPoint = this._map.project(latLng).divideBy(256).floor();
5✔
48
        return Object.assign(layerPoint, {z: this._tileZoom});
3✔
49
    },
50
    _getTileRelativePixel: function(tilePoint, containerPoint) {
51
        const x = Math.floor(containerPoint.x - this._getTilePos(tilePoint).x - this._map._getMapPanePos().x);
3✔
52
        const y = Math.min(this.getTileSize().x - 1, Math.floor(containerPoint.y - this._getTilePos(tilePoint).y - this._map._getMapPanePos().y));
3✔
53
        return new L.Point(x, y);
3✔
54
    },
55
    _removeTile: function() {},
56
    _abortLoading: function() {},
57
    onAdd(map) {
58
        if (!map.msElevationLayers) {
4!
59
            map.msElevationLayers = [];
4✔
60
        }
61
        map.msElevationLayers.push(this);
4✔
62
        return L.TileLayer.MultipleUrlWMS.prototype.onAdd.call(this, map);
4✔
63
    },
64
    onRemove(map) {
65
        map.msElevationLayers = map.msElevationLayers.filter(elevationLayer => elevationLayer._msId !== this._msId);
4✔
66
        return L.TileLayer.MultipleUrlWMS.prototype.onRemove.call(this, map);
4✔
67
    }
68
});
69

70
L.tileLayer.elevationWMS = function(urls, options, nodata, littleEndian, id) {
1✔
71
    return new L.TileLayer.ElevationWMS(urls, options, nodata, littleEndian, id);
6✔
72
};
73

74
const createWMSElevationLayer = (options) => {
1✔
75
    const urls = getWMSURLs(isArray(options.url) ? options.url : [options.url]);
6!
76
    const queryParameters = removeNulls(wmsToLeafletOptions(options) || {});
6!
77
    urls.forEach(url => addAuthenticationParameter(url, queryParameters, options.securityToken));
6✔
78
    const layer = L.tileLayer.elevationWMS(
6✔
79
        urls,
80
        {
81
            ...queryParameters,
82
            format: options?.format || 'application/bil16'
11✔
83
        },
84
        options.nodata || -9999,
12✔
85
        options?.littleEndian ?? options?.littleendian ?? false,
18✔
86
        options.id
87
    );
88
    return layer;
6✔
89
};
90

91
Layers.registerType('elevation', {
1✔
92
    create: (options) => {
93
        if (options.provider === 'wms') {
6!
94
            return createWMSElevationLayer(options);
6✔
95
        }
UNCOV
96
        return null;
×
97
    }
98
});
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