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

geosolutions-it / MapStore2 / 19933858499

04 Dec 2025 01:54PM UTC coverage: 76.636% (-0.03%) from 76.661%
19933858499

Pull #11648

github

web-flow
Update User Guide - Itinerary plugin (#11768)

* add_11664

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

* Update docs/user-guide/itinerary.md

Co-authored-by: Suren <dsuren1@gmail.com>

---------

Co-authored-by: Suren <dsuren1@gmail.com>
Pull Request #11648: #11644: Implement dynamic request configurations

32316 of 50296 branches covered (64.25%)

132 of 155 new or added lines in 40 files covered. (85.16%)

283 existing lines in 32 files now uncovered.

40207 of 52465 relevant lines covered (76.64%)

37.89 hits per line

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

29.03
/web/client/components/map/cesium/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/cesium/Layers';
10
import * as Cesium from 'cesium';
11

12
import { wmsToCesiumOptions } from '../../../../utils/cesium/WMSUtils';
13
import { addElevationTile, getElevation, getElevationKey, getTileRelativePixel } from '../../../../utils/ElevationUtils';
14

15
let canvas;
16

17
const createEmptyCanvas = () => {
1✔
18
    if (!canvas) {
×
19
        canvas = document.createElement('canvas');
×
20
        canvas.width = 1;
×
21
        canvas.height = 1;
×
22
    }
23
    return canvas;
×
24
};
25

26
const templateRegex = /{[^}]+}/g;
1✔
27

28
function buildTileResource(imageryProvider, x, y, level, request) {
29
    const resource = imageryProvider._resource;
×
30
    const url = resource.getUrlComponent(true);
×
31
    const allTags = imageryProvider._tags;
×
32
    const templateValues = {};
×
33
    const match = url.match(templateRegex);
×
34
    if (Cesium.defined(match)) {
×
35
        match.forEach(function(tag) {
×
36
            const key = tag.substring(1, tag.length - 1); // strip {}
×
37
            if (!['westProjected', 'southProjected', 'eastProjected', 'northProjected'].includes(key) && Cesium.defined(allTags[key])) {
×
38
                templateValues[key] = allTags[key](imageryProvider, x, y, level);
×
39
            }
40
        });
41
    }
42
    const nativeRectangle = imageryProvider.tilingScheme.tileXYToNativeRectangle(x, y, level);
×
43
    return resource.getDerivedResource({
×
44
        request: request,
45
        templateValues: {
46
            ...templateValues,
47
            // the bbox value must be computed here
48
            // because the internal Cesium tags are using the same object to store the cartesian value with a private boolean
49
            // causing wrong output related on previous tile bounding boxes
50
            westProjected: nativeRectangle.west,
51
            southProjected: nativeRectangle.south,
52
            eastProjected: nativeRectangle.east,
53
            northProjected: nativeRectangle.north
54
        }
55
    });
56
}
57

58
class ElevationWMS extends Cesium.WebMapServiceImageryProvider {
59
    constructor({
60
        nodata,
61
        littleEndian,
62
        map,
63
        ...options
64
    }) {
65
        super(options);
2✔
66
        this._msId = options.id;
2✔
67
        this._nodata = nodata ?? -9999;
2✔
68
        this._littleEndian = littleEndian ?? false;
2!
69
        this._map = map;
2✔
70
        if (!this._map.msElevationLayers) {
2!
71
            this._map.msElevationLayers = [];
2✔
72
        }
73
        this._map.msElevationLayers.push(this);
2✔
74
    }
75
    requestImage(x, y, z, request) {
76
        const tileRequest = buildTileResource(this._tileProvider, x, y, z, request.clone());
×
77
        const resource = Cesium.Resource.createIfNeeded(tileRequest);
×
78
        const promise = resource.fetchArrayBuffer();
×
79
        if (promise) {
×
80
            return promise.then((data) => {
×
81
                if (!this._zoomLevelRequested) {
×
82
                    this._zoomLevelRequested = [];
×
83
                }
84
                if (!this._zoomLevelRequested.includes(z)) {
×
85
                    this._zoomLevelRequested.push(z);
×
86
                    this._zoomLevelRequested.sort((a, b) => b - a);
×
87
                }
88
                addElevationTile(data, { x, y, z }, getElevationKey(x, y, z, this._msId), tileRequest.url);
×
89
                return createEmptyCanvas();
×
90
            });
91
        }
92
        return promise;
×
93
    }
94
    getElevation({
95
        longitude,
96
        latitude
97
    }) {
98
        let elevation;
99
        const zoomLevelRequested = this._zoomLevelRequested || [];
×
100
        for (let i = 0; i < zoomLevelRequested.length; i++) {
×
101
            const z = zoomLevelRequested[i];
×
102
            const tile = this._tileProvider.tilingScheme.positionToTileXY(new Cesium.Cartographic(longitude, latitude), z);
×
103
            if (tile) {
×
104
                const x = tile.x;
×
105
                const y = tile.y;
×
106
                const rectangle = this._tileProvider.tilingScheme.tileXYToRectangle(x, y, z);
×
107
                const currentElevation = getElevation(
×
108
                    getElevationKey(x, y, z, this._msId),
109
                    getTileRelativePixel(
110
                        [longitude, latitude],
111
                        [rectangle.west, rectangle.south, rectangle.east, rectangle.north],
112
                        [this._tileProvider.tileWidth, this._tileProvider.tileHeight]
113
                    ),
114
                    this._tileProvider.tileWidth,
115
                    this._nodata,
116
                    this._littleEndian
117
                );
118
                if (currentElevation.available) {
×
119
                    elevation = currentElevation;
×
120
                    break;
×
121
                }
122
            }
123
        }
124
        return elevation?.available ? elevation.value : '';
×
125
    }
126
    destroy() {
127
        this._map.msElevationLayers = this._map.msElevationLayers.filter(elevationLayer => elevationLayer._msId !== this._msId);
1✔
128
    }
129
}
130

131
const createWMSElevationLayer = (options, map) => {
1✔
132
    const { parameters, ...wmsOptions } = wmsToCesiumOptions(options);
2✔
133
    const layer = new ElevationWMS({
2✔
134
        ...wmsOptions,
135
        parameters: {
136
            ...parameters,
137
            format: options?.format || 'application/bil16'
4✔
138
        },
139
        id: options.id,
140
        map,
141
        nodata: options.nodata,
142
        littleEndian: options?.littleEndian ?? options?.littleendian ?? false
6✔
143
    });
144
    return layer;
2✔
145
};
146

147
Layers.registerType('elevation', {
1✔
148
    create: (options, map) => {
149
        if (options.provider === 'wms') {
2!
150
            return createWMSElevationLayer(options, map);
2✔
151
        }
NEW
152
        return null;
×
153
    }
154
});
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