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

geosolutions-it / MapStore2 / 15022192473

14 May 2025 01:37PM UTC coverage: 76.899% (-0.09%) from 76.993%
15022192473

Pull #10515

github

web-flow
Merge 76310647b into d76ffd67a
Pull Request #10515: #10514 - FeatureEditor filter by geometric area

30971 of 48268 branches covered (64.16%)

27 of 42 new or added lines in 6 files covered. (64.29%)

532 existing lines in 55 files now uncovered.

38582 of 50172 relevant lines covered (76.9%)

35.92 hits per line

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

95.83
/web/client/api/ThreeDTiles.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 axios from '../libs/ajax';
10
import { convertRadianToDegrees } from '../utils/CoordinatesUtils';
11
import { METERS_PER_UNIT } from '../utils/MapUtils';
12
import { logError } from '../utils/DebugUtils';
13
import { getAuthorizationBasic } from '../utils/SecurityUtils';
14

15
// converts the boundingVolume of the root tileset to a valid layer bbox
16
function tilesetToBoundingBox(Cesium, tileset) {
17
    if (tileset?.root?.boundingVolume?.region) {
18✔
18
        // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians
19
        // region [west, south, east, north, minimum height, maximum height]
20
        const [west, south, east, north] = tileset.root.boundingVolume.region;
8✔
21

22
        return {
8✔
23
            bounds: {
24
                minx: convertRadianToDegrees(west),
25
                miny: convertRadianToDegrees(south),
26
                maxx: convertRadianToDegrees(east),
27
                maxy: convertRadianToDegrees(north)
28
            },
29
            crs: 'EPSG:4326'
30
        };
31
    }
32

33
    const transform = Cesium.Matrix4.fromArray(tileset.root.transform || [
10✔
34
        1.0, 0.0, 0.0, 0.0,
35
        0.0, 1.0, 0.0, 0.0,
36
        0.0, 0.0, 1.0, 0.0,
37
        0.0, 0.0, 0.0, 1.0
38
    ]);
39

40
    // computation from https://github.com/CesiumGS/cesium/blob/1.90/Source/Scene/Cesium3DTile.js
41
    // createBox function
42
    if (tileset?.root?.boundingVolume?.box) {
10✔
43
        const [x, y, z] = tileset.root.boundingVolume.box;
6✔
44
        const center = Cesium.Matrix4.multiplyByPoint(
6✔
45
            transform,
46
            new Cesium.Cartesian3(x, y, z),
47
            new Cesium.Cartesian3()
48
        );
49
        const rotationScale = Cesium.Matrix4.getMatrix3(transform, new Cesium.Matrix4());
6✔
50
        const halfAxes = Cesium.Matrix3.multiply(
6✔
51
            rotationScale,
52
            Cesium.Matrix3.fromArray(tileset.root.boundingVolume.box, 3, new Cesium.Matrix3()),
53
            new Cesium.Matrix3()
54
        );
55
        // from https://github.com/CesiumGS/cesium/blob/a11b14cab7229036b3348763d861a28b905d367d/Source/Scene/TileOrientedBoundingBox.js#L95
56
        const sphere = Cesium.BoundingSphere.fromOrientedBoundingBox(new Cesium.OrientedBoundingBox(center, halfAxes));
6✔
57
        const cartographic = Cesium.Cartographic.fromCartesian(sphere.center);
6✔
58
        if (!cartographic) {
6✔
59
            return null;
1✔
60
        }
61
        const lng = convertRadianToDegrees(cartographic.longitude);
5✔
62
        const lat = convertRadianToDegrees(cartographic.latitude);
5✔
63

64
        const radiusDegrees = sphere.radius / METERS_PER_UNIT.degrees;
5✔
65
        return {
5✔
66
            bounds: {
67
                minx: lng - radiusDegrees,
68
                miny: lat - radiusDegrees,
69
                maxx: lng + radiusDegrees,
70
                maxy: lat + radiusDegrees
71
            },
72
            crs: 'EPSG:4326'
73
        };
74
    }
75
    // computation from https://github.com/CesiumGS/cesium/blob/1.90/Source/Scene/Cesium3DTile.js
76
    // createSphere function
77
    if (tileset?.root?.boundingVolume?.sphere) {
4✔
78
        const [x, y, z, radius] = tileset.root.boundingVolume.sphere;
3✔
79
        const center = Cesium.Matrix4.multiplyByPoint(
3✔
80
            transform,
81
            new Cesium.Cartesian3(x, y, z),
82
            new Cesium.Cartesian3()
83
        );
84
        const scale = Cesium.Matrix4.getScale(transform, new Cesium.Matrix4());
3✔
85
        const uniformScale = Cesium.Cartesian3.maximumComponent(scale);
3✔
86
        const radiusDegrees = (radius * uniformScale) / METERS_PER_UNIT.degrees;
3✔
87
        const cartographic = Cesium.Cartographic.fromCartesian(center);
3✔
88
        if (!cartographic) {
3✔
89
            return null;
1✔
90
        }
91
        const lng = convertRadianToDegrees(cartographic.longitude);
2✔
92
        const lat = convertRadianToDegrees(cartographic.latitude);
2✔
93
        return {
2✔
94
            bounds: {
95
                minx: lng - radiusDegrees,
96
                miny: lat - radiusDegrees,
97
                maxx: lng + radiusDegrees,
98
                maxy: lat + radiusDegrees
99
            },
100
            crs: 'EPSG:4326'
101
        };
102
    }
103
    return null;
1✔
104
}
105

106
// extract the tile format from the uri
107
function getFormat(uri) {
108
    const parts = uri.split(/\./g);
18✔
109
    const format = parts[parts.length - 1];
18✔
110
    return format;
18✔
111
}
112

113
// extract version, bbox, format and properties from the tileset metadata
114
function extractCapabilities(tileset) {
115
    return import('cesium')
18✔
116
        .then((mod) => {
117
            const Cesium = mod;
18✔
118
            const version = tileset?.asset?.version !== undefined ? tileset.asset.version : '1.0';
18✔
119
            const bbox = tilesetToBoundingBox(Cesium, tileset);
18✔
120
            const format = getFormat(tileset?.root?.content?.uri || '');
18✔
121
            const properties =  tileset?.properties;
18✔
122
            return {
18✔
123
                version,
124
                ...(bbox && { bbox }),
33✔
125
                format,
126
                properties
127
            };
128
        });
129
}
130

131
/**
132
 * Common requests to 3D tiles tileset
133
 * @module api.ThreeDTiles
134
 */
135

136
/**
137
 * get the tileset json response and additional parsed information such as: version, bbox, format and properties
138
 * @param {string} url URL of the 3d tiles tileset.json file
139
 * @
140
 */
141
export const getCapabilities = (url, info) => {
1✔
142
    const protectedId = info?.options?.service?.protectedId;
18✔
143
    let headers = getAuthorizationBasic(protectedId);
18✔
144
    return axios.get(url, {headers})
18✔
145
        .then(({ data }) => {
146
            return extractCapabilities(data).then((properties) => ({ tileset: data, ...properties }));
18✔
147
        }).catch((e) => {
UNCOV
148
            logError(e);
×
UNCOV
149
            return { tileset: {}};
×
150
        });
151
};
152

153
/**
154
 *  constant of 3D tiles 'format'
155
 */
156
export const THREE_D_TILES = "3D Tiles";
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

© 2026 Coveralls, Inc