• 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

89.74
/web/client/utils/ElevationUtils.js
1
/**
2
 * Copyright 2018, 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 axios from '../libs/ajax';
10

11
import LRUCache from 'lrucache';
12
const DEFAULT_SIZE = 100;
1✔
13
let elevationTiles = new LRUCache(DEFAULT_SIZE);
1✔
14

15
export const getElevationKey = (x, y, z, id) => `${z}:${x}:${y}:${id}`;
77✔
16

17
export function getTileRelativePixel(position, extent, tileSize) {
18
    const ratioW = tileSize[0] / (extent[2] - extent[0]);
2✔
19
    const ratioH = tileSize[1] / (extent[3] - extent[1]);
2✔
20
    const x = Math.floor((position[0] - extent[0]) * ratioW);
2✔
21
    const y = Math.floor((extent[3] - position[1]) * ratioH);
2✔
22
    return { x, y };
2✔
23
}
24

25
export const addElevationTile = (data, coords, key) => {
1✔
26
    elevationTiles.set(key, {
3✔
27
        data: data,
28
        dataView: new DataView(data),
29
        coords: coords,
30
        current: true,
31
        status: "success"
32
    });
33
};
34

35
const addErroredElevationTile = (error, coords, key) => {
1✔
36
    elevationTiles.set(key, {
72✔
37
        coords: coords,
38
        current: true,
39
        status: "error: " + error
40
    });
41
};
42

43
const getValueAtXY = (ncols, tile, x, y, nodata = -9999, littleendian = false) => {
1!
44
    const index = (y * ncols) + x;
2✔
45
    try {
2✔
46
        const result = tile.dataView.getInt16(index * 2, littleendian);
2✔
47
        if (result !== nodata && result !== 32767 && result !== -32768) {
2!
48
            return result;
2✔
49
        }
50
    } catch (e) {
51
        //
52
    }
53

UNCOV
54
    return null;
×
55
};
56

57

58
/**
59
 * Loads and stores an elevation tile in application/bil16 format from the given url.
60
 * The original (x, y ,z) coordinates and a tile key are stored together with the tile.
61
 * The key can be used to get back tile information.
62
 *
63
 * @param url tile url
64
 * @param coords coordinates object (x, y , z)
65
 * @param key tile key identifier (e.g. z:x:y)
66
 */
67
export const loadTile = (url, coords, key) => {
1✔
68
    if (!elevationTiles.has(key)) {
75!
69
        return new Promise((resolve, reject) => {
75✔
70
            axios.get(url, {
75✔
71
                responseType: 'arraybuffer'
72
            }).then((response) => {
73
                addElevationTile(response.data, coords, key);
3✔
74
                resolve();
3✔
75
            }).catch(e => {
76
                addErroredElevationTile(e.message, coords, key);
72✔
77
                reject(e);
72✔
78
            });
79
        });
80
    }
UNCOV
81
    return null;
×
82
};
83
/**
84
 * Returns the elevation for:
85
 * @param key a given tile key (e-g. 15:10:20, z:x:y)
86
 * @param tilePixelPosition a pixel position inside the tile (x, y)
87
 * @param tileSize in pixels (e.g. 256)
88
 * @param nodata value to be used for nodata (no elevation available)
89
 * @param littleendian whether or not the BIL data is in little endian or big endian
90
 * @returns an object with the following properties:
91
 *   * available: true / false
92
 *   * value: elevation value if available is true
93
 *   * message: an error message if available is false
94
 */
95
export const getElevation = (key, tilePixelPosition, tileSize, nodata = -9999, littleendian = false) => {
1✔
96
    const tile = elevationTiles.get(key);
8✔
97
    if (tile && tile.status === "success") {
8✔
98
        return {
2✔
99
            available: true,
100
            value: getValueAtXY(tileSize, tile, tilePixelPosition.x, tilePixelPosition.y, nodata, littleendian)
101
        };
102
    } else if (tile && tile.status === "loading") {
6!
UNCOV
103
        return {
×
104
            available: false,
105
            message: "elevationLoading"
106
        };
107
    } else if (tile && tile.status === "error") {
6!
UNCOV
108
        return {
×
109
            available: false,
110
            message: "elevationLoadingError"
111
        };
112
    }
113
    return {
6✔
114
        available: false,
115
        message: "elevationNotAvailable"
116
    };
117
};
118
export const reset = (options = {}) => {
1✔
119
    elevationTiles = new LRUCache(options.max || DEFAULT_SIZE);
4✔
120
};
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