• 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

66.67
/web/client/components/map/cesium/plugins/TerrainLayer.js
1
/*
2
 * Copyright 2022, 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 GeoServerBILTerrainProvider from '../../../../utils/cesium/GeoServerBILTerrainProvider';
12
import WMSUtils from '../../../../utils/cesium/WMSUtils';
13
import { getProxyUrl } from "../../../../utils/ProxyUtils";
14

15
function cesiumOptionsMapping(config) {
16
    return {
2✔
17
        url: new Cesium.Resource({
18
            url: config.url,
19
            proxy: config.forceProxy ? new Cesium.DefaultProxy(getProxyUrl()) : undefined
2!
20
        }),
21
        options: {
22
            credit: config?.options?.credit,
23
            ellipsoid: config?.options?.ellipsoid,
24
            requestMetadata: config?.options?.requestMetadata,
25
            requestWaterMask: config?.options?.requestWaterMask,
26
            requestVertexNormals: config?.options?.requestVertexNormals
27
        }
28

29
    };
30
}
31

32
function cesiumIonOptionsMapping(config) {
UNCOV
33
    const options = config?.options ?? {};
×
UNCOV
34
    return {
×
35
        url: options.assetId
×
36
            ? Cesium.IonResource.fromAssetId(options.assetId, {
37
                accessToken: options.accessToken,
38
                server: options.server
39
            })
40
            : undefined,
41
        options: {
42
            credit: options.credit,
43
            requestMetadata: options.requestMetadata
44
        }
45
    };
46
}
47

48
const createLayer = (config, map) => {
1✔
49
    map.terrainProvider = undefined;
6✔
50
    let terrainProvider;
51
    let terrain;
52
    let url;
53
    let options;
54
    switch (config.provider) {
6!
55
    case 'wms': {
56
        const cesiumOptionsBIL = WMSUtils.wmsToCesiumOptionsBIL(config);
4✔
57
        url = cesiumOptionsBIL.url;
4✔
58
        options = cesiumOptionsBIL || {};
4!
59
        if (url) {
4!
60
            terrainProvider = GeoServerBILTerrainProvider.fromUrl(url, options);
4✔
61
        }
62
        break;
4✔
63
    }
64
    case 'cesium': {
65
        const cesiumOptions = cesiumOptionsMapping(config);
2✔
66
        url = cesiumOptions.url;
2✔
67
        options = cesiumOptions.options || {};
2!
68
        if (url) {
2!
69
            terrainProvider = Cesium.CesiumTerrainProvider.fromUrl(url, options);
2✔
70
        }
71
        break;
2✔
72
    }
73
    case 'ellipsoid': {
UNCOV
74
        terrainProvider = new Cesium.EllipsoidTerrainProvider();
×
UNCOV
75
        break;
×
76
    }
77
    case 'cesium-ion': {
UNCOV
78
        const ionOptions = cesiumIonOptionsMapping(config);
×
UNCOV
79
        url = ionOptions.url;
×
UNCOV
80
        options = ionOptions.options || {};
×
UNCOV
81
        if (url) {
×
UNCOV
82
            terrainProvider = Cesium.CesiumTerrainProvider.fromUrl(url, options);
×
83
        }
UNCOV
84
        break;
×
85
    }
86
    default:
UNCOV
87
        terrainProvider = new Cesium.EllipsoidTerrainProvider();
×
UNCOV
88
        break;
×
89
    }
90
    return {
6✔
91
        detached: true,
92
        terrainProvider,
93
        terrain,
94
        add: () => {
95
            if (terrainProvider) {
3!
96
                terrain = new Cesium.Terrain(terrainProvider);
3✔
97
                map.scene.setTerrain(terrain);
3✔
98
            }
99
        },
100
        remove: () => {
101
            terrain = new Cesium.Terrain(new Cesium.EllipsoidTerrainProvider());
6✔
102
            map.scene.setTerrain(terrain);
6✔
103
        }
104
    };
105
};
106

107
const updateLayer = (layer, newOptions, oldOptions, map) => {
1✔
108
    if (newOptions.securityToken !== oldOptions.securityToken
3!
109
    || oldOptions.credits !== newOptions.credits
110
    || oldOptions.provider !== newOptions.provider
111
    || newOptions.url !== oldOptions.url
112
    || newOptions?.options?.assetId !== oldOptions?.options?.assetId
113
    || newOptions?.options?.accessToken !== oldOptions?.options?.accessToken
114
    || newOptions?.options?.server !== oldOptions?.options?.server
115
    || newOptions?.options?.crs !== oldOptions?.options?.crs
116
    || newOptions?.version !== oldOptions?.version
117
    || newOptions?.name !== oldOptions?.name
118
    || oldOptions.forceProxy !== newOptions.forceProxy) {
119
        return createLayer(newOptions, map);
3✔
120
    }
UNCOV
121
    return null;
×
122
};
123

124
Layers.registerType('terrain', {
1✔
125
    create: createLayer,
126
    update: updateLayer
127
});
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