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

iTowns / itowns / 10635241580

30 Aug 2024 03:26PM UTC coverage: 86.966% (-2.8%) from 89.766%
10635241580

push

github

jailln
feat(3dtiles): add new OGC3DTilesLayer using 3d-tiles-renderer-js

Deprecate C3DTilesLayer (replaced by OGC3DTilesLayer).
Add new iGLTFLoader that loads gltf 1.0 and 2.0 files.

2791 of 3694 branches covered (75.55%)

Branch coverage included in aggregate %.

480 of 644 new or added lines in 8 files covered. (74.53%)

2144 existing lines in 111 files now uncovered.

24319 of 27479 relevant lines covered (88.5%)

1024.72 hits per line

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

70.37
/src/Parser/XbilParser.js
1
import { readTextureValueWithBilinearFiltering } from 'Utils/DEMUtils';
1✔
2

1✔
3
function minMax4Corners(texture, pitch, options) {
2✔
4
    const u = pitch.x;
2✔
5
    const v = pitch.y;
2✔
6
    const w = pitch.z;
2✔
7
    const z = [
2✔
8
        readTextureValueWithBilinearFiltering(options, texture, u, v),
2✔
9
        readTextureValueWithBilinearFiltering(options, texture, u + w, v),
2✔
10
        readTextureValueWithBilinearFiltering(options, texture, u + w, v + w),
2✔
11
        readTextureValueWithBilinearFiltering(options, texture, u, v + w),
2✔
12
    ].filter(val => val != undefined);
2✔
13

2✔
14
    if (z.length) {
2✔
15
        return { min: Math.min(...z), max: Math.max(...z) };
2✔
16
    } else {
2!
17
        return {
×
UNCOV
18
            min: Infinity,
×
UNCOV
19
            max: -Infinity,
×
UNCOV
20
        };
×
UNCOV
21
    }
×
22
}
2✔
23

1✔
24
/**
1✔
25
 * Calculates the minimum maximum texture elevation with xbil data
1✔
26
 *
1✔
27
 * @param      {THREE.Texture}   texture                     The texture to parse
1✔
28
 * @param      {THREE.Vector4}   pitch                       The pitch,  restrict zone to parse
1✔
29
 * @param      {Object}          options                     No data value and clamp values
1✔
30
 * @param      {number}          options.noDataValue         No data value
1✔
31
 * @param      {number}          [options.zmin]   The minimum elevation value after which it will be clamped
1✔
32
 * @param      {number}          [options.zmax]   The maximum elevation value after which it will be clamped
1✔
33
 * @return     {Object}  The minimum and maximum elevation.
1✔
34
 */
1✔
35
export function computeMinMaxElevation(texture, pitch, options) {
1✔
36
    const { width, height, data } = texture.image;
2✔
37
    if (!data) {
2!
38
        // Return null values means there's no elevation values.
×
39
        // They can't be determined.
×
UNCOV
40
        // Don't return 0 because the result will be wrong
×
UNCOV
41
        return { min: null, max: null };
×
UNCOV
42
    }
×
43

2✔
44
    // compute the minimum and maximum elevation on the 4 corners texture.
2✔
45
    let { min, max } = minMax4Corners(texture, pitch, options);
2✔
46

2✔
47
    const sizeX = Math.floor(pitch.z * width);
2✔
48

2✔
49
    if (sizeX > 2) {
2✔
50
        const sizeY = Math.floor(pitch.z * height);
2✔
51
        const xs = Math.floor(pitch.x * width);
2✔
52
        const ys = Math.floor(pitch.y * height);
2✔
53
        const inc = Math.max(Math.floor(sizeX / 32), 2);
2✔
54
        const limX = ys + sizeY;
2✔
55
        for (let y = ys; y < limX; y += inc) {
2✔
56
            const pit = y * (width || 0);
34!
57
            let x = pit + xs;
34✔
58
            const limX = x + sizeX;
34✔
59
            for (x; x < limX; x += inc) {
34✔
60
                const val = data[x];
1,028✔
61
                if (val !== options.noDataValue) {
1,028✔
62
                    max = Math.max(max, val);
1,028✔
63
                    min = Math.min(min, val);
1,028✔
64
                }
1,028✔
65
            }
1,028✔
66
        }
34✔
67
        if (options.zmin > min) { min = options.zmin; }
2!
68
        if (options.zmax < max) { max = options.zmax; }
2!
69
    }
2✔
70

2✔
71
    if (max === -Infinity || min === Infinity) {
2!
UNCOV
72
        // Return null values means the elevation values are incoherent
×
UNCOV
73
        // They can't be determined.
×
UNCOV
74
        // Don't return 0, -Infinity or Infinity because the result will be wrong
×
UNCOV
75
        return { min: null, max: null };
×
76
    } else {
2✔
77
        return { min, max };
2✔
78
    }
2✔
79
}
2✔
80

1✔
81
// We check if the elevation texture has some significant values through corners
1✔
82
export function checkNodeElevationTextureValidity(data, noDataValue) {
1✔
UNCOV
83
    const l = data.length;
×
UNCOV
84
    return data[0] > noDataValue &&
×
UNCOV
85
           data[l - 1] > noDataValue &&
×
86
           data[Math.sqrt(l) - 1] > noDataValue &&
×
87
           data[l - Math.sqrt(l)] > noDataValue;
×
88
}
×
89

1✔
90
// This function replaces noDataValue by significant values from parent texture (or 0)
1✔
91
export function insertSignificantValuesFromParent(data, dataParent = () => 0, noDataValue) {
1✔
92
    for (let i = 0, l = data.length; i < l; ++i) {
×
UNCOV
93
        if (data[i] === noDataValue) {
×
UNCOV
94
            data[i] = dataParent(i);
×
UNCOV
95
        }
×
UNCOV
96
    }
×
UNCOV
97
}
×
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