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

iTowns / itowns / 20925540062

12 Jan 2026 03:46PM UTC coverage: 88.09%. First build
20925540062

Pull #2659

github

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

2767 of 3568 branches covered (77.55%)

Branch coverage included in aggregate %.

83 of 104 new or added lines in 9 files covered. (79.81%)

28245 of 31637 relevant lines covered (89.28%)

1199.07 hits per line

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

92.86
/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);
3✔
33

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

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

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

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

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

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

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

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

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

12✔
90
                    const mockSource = {
12✔
91
                        boundsConforming: boundsConformings[i],
12✔
92
                        whenReady,
12✔
93
                        crs: CRS.defsFromWkt(projsWkt2[i]),
12✔
94
                        instantiate: () => {
12✔
95
                            let newSource;
2✔
96

2✔
97
                            if (url.includes('.copc')) {
2✔
98
                                newSource = new CopcSource({ url });
1✔
99
                            } else if (url.includes('.json')) {
1✔
100
                                newSource = new EntwinePointTileSource({ url });
1✔
101
                            } else {
1!
NEW
102
                                const msg = '[VPCLayer]: stack point cloud format not supporter';
×
NEW
103
                                console.warn(msg);
×
NEW
104
                                this.handlingError(msg);
×
NEW
105
                            }
×
106

2✔
107
                            resolve(newSource.whenReady);
2✔
108

2✔
109
                            this.sources[i] = newSource;
2✔
110

2✔
111
                            return newSource;
2✔
112
                        },
12✔
113
                        instantiation: false,
12✔
114
                    };
12✔
115
                    this.sources.push(mockSource);
12✔
116
                });
3✔
117
                return this;
3✔
118
            });
3✔
119
    }
3✔
120
}
1✔
121

1✔
122
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