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

iTowns / itowns / 20968089171

13 Jan 2026 06:31PM UTC coverage: 88.124%. First build
20968089171

Pull #2659

github

web-flow
Merge 315e5a4ca into bbd11b5f3
Pull Request #2659: [fix]: Vpc Layer and multisources -> too many request at once

2776 of 3578 branches covered (77.59%)

Branch coverage included in aggregate %.

93 of 102 new or added lines in 8 files covered. (91.18%)

28257 of 31637 relevant lines covered (89.32%)

1199.4 hits per line

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

93.62
/packages/Main/src/Source/VpcSource.js
1
import { CRS } from '@itowns/geographic';
1✔
2
import Fetcher from 'Provider/Fetcher';
1✔
3
import Source from 'Source/Source';
1✔
4
import EntwinePointTileSource from 'Source/EntwinePointTileSource';
1✔
5
import CopcSource from 'Source/CopcSource';
1✔
6

1✔
7
/**
1✔
8
 * An object defining the source of Entwine Point Tile data. It fetches and
1✔
9
 * parses the main configuration file of Entwine Point Tile format,
1✔
10
 * [`ept.json`](https://entwine.io/entwine-point-tile.html#ept-json).
1✔
11
 *
1✔
12
 * @extends Source
1✔
13
 *
1✔
14
 * @property {boolean} isEntwinePointTileSource - Used to checkout whether this
1✔
15
 * source is a EntwinePointTileSource. Default is true. You should not change
1✔
16
 * this, as it is used internally for optimisation.
1✔
17
 * @property {string} url - The URL of the directory containing the whole
1✔
18
 * Entwine Point Tile structure.
1✔
19
 * @property {Object[]|PointCloudSource[]} sources - Array of all the source described in the VPC.
1✔
20
 * initialized with mockSource that will be replace by COPC or EPT Source as soon as any data need
1✔
21
 * to be loaded.
1✔
22
 */
1✔
23
class VpcSource extends Source {
1✔
24
    /**
1✔
25
     * @param {Object} config - The configuration, see {@link Source} for
1✔
26
     * available values.
1✔
27
     * @param {number} [config.colorDepth] - Color depth (in bits).
1✔
28
     * Either 8 or 16 bits. By defaults it will be set to 8 bits for LAS 1.2 and
1✔
29
     * 16 bits for later versions (as mandatory by the specification).
1✔
30
     */
1✔
31
    constructor(config) {
1✔
32
        super(config);
4✔
33

4✔
34
        this.isVpcSource = true;
4✔
35
        this.sources = [];
4✔
36

4✔
37
        this.colorDepth = config.colorDepth;
4✔
38

4✔
39
        this.spacing = Infinity;
4✔
40

4✔
41
        this.whenReady = Fetcher.json(this.url, this.networkOptions)
4✔
42
            .then((metadata) => {
4✔
43
                this.metadata = metadata;
4✔
44

4✔
45
                // Set the Crs of the VPC Layer.
4✔
46
                const projsWkt2 = metadata.features.map(f => f.properties['proj:wkt2']);
4✔
47
                const crs = [...new Set(projsWkt2)];
4✔
48
                if (crs.length !== 1) {
4!
49
                    console.warn('Only 1 crs is supported for 1 vpc.');
×
50
                }
×
51
                this.crs = CRS.defsFromWkt(projsWkt2[0]);
4✔
52

4✔
53
                // Set boundsConformings (the bbox) of the VPC Layer
4✔
54
                const boundsConformings = metadata.features
4✔
55
                    .filter(f => f.properties['proj:wkt2'] === projsWkt2[0])
4✔
56
                    .map(f => f.properties['proj:bbox']);
4✔
57

4✔
58
                this.boundsConforming = [
4✔
59
                    Math.min(...boundsConformings.map(b => b[0])),
4✔
60
                    Math.min(...boundsConformings.map(b => b[1])),
4✔
61
                    Math.min(...boundsConformings.map(b => b[2])),
4✔
62
                    Math.max(...boundsConformings.map(b => b[3])),
4✔
63
                    Math.max(...boundsConformings.map(b => b[4])),
4✔
64
                    Math.max(...boundsConformings.map(b => b[5])),
4✔
65
                ];
4✔
66

4✔
67
                // Set the zmin and zmax from the source
4✔
68
                this.zmin = this.boundsConforming[2];
4✔
69
                this.zmax = this.boundsConforming[5];
4✔
70

4✔
71
                /* Set  several object (MockSource) to mock the source that will need to be instantiated.
4✔
72
                 We don't want all child source to be instantiated at once as it will send the fetch request
4✔
73
                 (current architectural choice) thus we want to delay the instanciation of the child source
4✔
74
                 when the data need to be load on a particular node.
4✔
75
                 Creation of 1 mockSource for each item in the stack (that will be replace by a real source
4✔
76
                 when needed, when we will call the load on a node depending of that source).
4✔
77
                */
4✔
78
                this._promises = [];
4✔
79
                this.urls = metadata.features.map(f => f.assets.data.href);
4✔
80
                this.urls.forEach((url, i) => {
4✔
81
                    let resolve;
16✔
82
                    let reject;
16✔
83
                    const whenReady = new Promise((re, rj) => {
16✔
84
                        // waiting for source to be instantiate;
16✔
85
                        resolve = re;
16✔
86
                        reject = rj;
16✔
87
                    }).catch((err) => {
16✔
88
                        console.warn(err);
×
89
                        this.handlingError(err);
×
90
                    });
16✔
91

16✔
92
                    const mockSource = {
16✔
93
                        boundsConforming: boundsConformings[i],
16✔
94
                        whenReady,
16✔
95
                        crs: CRS.defsFromWkt(projsWkt2[i]),
16✔
96
                        instantiate: () => {
16✔
97
                            let newSource;
4✔
98

4✔
99
                            if (url.includes('.copc')) {
4✔
100
                                newSource = new CopcSource({ url });
2✔
101
                            } else if (url.includes('.json')) {
2✔
102
                                newSource = new EntwinePointTileSource({ url });
2✔
103
                            } else {
2!
NEW
104
                                const err = new Error('[VPCLayer]: stack point cloud format not supporter');
×
NEW
105
                                reject(err);
×
NEW
106
                            }
×
107

4✔
108
                            resolve(newSource.whenReady);
4✔
109

4✔
110
                            this.sources[i] = newSource;
4✔
111

4✔
112
                            return newSource;
4✔
113
                        },
16✔
114
                        instantiation: false,
16✔
115
                    };
16✔
116
                    this.sources.push(mockSource);
16✔
117
                });
4✔
118
                return this;
4✔
119
            });
4✔
120
    }
4✔
121
}
1✔
122

1✔
123
export default VpcSource;
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