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

iTowns / itowns / 17292947856

28 Aug 2025 10:21AM UTC coverage: 86.774% (-0.2%) from 86.927%
17292947856

Pull #2593

github

web-flow
Merge 3396d4fd1 into 737a8f3de
Pull Request #2593: Refactoring sources

2792 of 3749 branches covered (74.47%)

Branch coverage included in aggregate %.

459 of 531 new or added lines in 18 files covered. (86.44%)

10 existing lines in 5 files now uncovered.

26155 of 29610 relevant lines covered (88.33%)

1094.86 hits per line

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

86.96
/packages/Main/src/Source/EntwinePointTileSource.js
1
import proj4 from 'proj4';
1✔
2
import LASParser from 'Parser/LASParser';
1✔
3
import PotreeBinParser from 'Parser/PotreeBinParser';
1✔
4
import Fetcher from 'Provider/Fetcher';
1✔
5
import Source from 'Source/Source';
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
 */
1✔
20
class EntwinePointTileSource extends Source {
1✔
21
    /**
1✔
22
     * @param {Object} config - The configuration, see {@link Source} for
1✔
23
     * available values.
1✔
24
     * @param {number|string} [config.colorDepth='auto'] - Does the color
1✔
25
     * encoding is known ? Is it `8` or `16` bits ? By default it is to
1✔
26
     * `'auto'`, but it will be more performant if a specific value is set.
1✔
27
     */
1✔
28
    constructor(config) {
1✔
29
        super(config);
2✔
30

2✔
31
        this.isEntwinePointTileSource = true;
2✔
32
        this.colorDepth = config.colorDepth;
2✔
33

2✔
34
        if (!config.url) {
2!
NEW
35
            throw new Error(`[${this.constructor.name}]: url is required`);
×
NEW
36
        }
×
37

2✔
38
        this.url = config.url;
2✔
39
        this.networkOptions = config.networkOptions ?? {};
2✔
40

2✔
41
        // Necessary because we use the url without the ept.json part as a base
2✔
42
        this.url = this.url.replace('/ept.json', '');
2✔
43

2✔
44
        // https://entwine.io/entwine-point-tile.html#ept-json
2✔
45
        this.whenReady = Fetcher.json(`${this.url}/ept.json`, this.networkOptions).then((metadata) => {
2✔
46
            // Set parser and its configuration from schema
2✔
47
            this.parse = metadata.dataType === 'laszip' ? LASParser.parse : PotreeBinParser.parse;
2!
48
            this.extension = metadata.dataType === 'laszip' ? 'laz' : 'bin';
2!
49

2✔
50
            if (metadata.srs) {
2✔
51
                if (metadata.srs.authority && metadata.srs.horizontal) {
2✔
52
                    this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
1✔
53
                    if (!proj4.defs(this.crs)) {
1!
54
                        proj4.defs(this.crs, metadata.srs.wkt);
×
55
                    }
×
56
                } else if (metadata.srs.wkt) {
1✔
57
                    proj4.defs('unknown', metadata.srs.wkt);
1✔
58
                    const projCS = proj4.defs('unknown');
1✔
59
                    this.crs = projCS.title || projCS.name;
1!
60
                    if (!(this.crs in proj4.defs)) {
1!
61
                        proj4.defs(this.crs, projCS);
×
62
                    }
×
63
                }
1✔
64
                if (metadata.srs.vertical && metadata.srs.vertical !== metadata.srs.horizontal) {
2✔
65
                    console.warn('EntwinePointTileSource: Vertical coordinates system code is not yet supported.');
1✔
66
                }
1✔
67
            }
2✔
68

2✔
69
            this.boundsConforming = metadata.boundsConforming;
2✔
70
            this.bounds = metadata.bounds;
2✔
71
            this.span = metadata.span;
2✔
72

2✔
73
            return this;
2✔
74
        });
2✔
75

2✔
76
        this.fetcher = Fetcher.arrayBuffer;
2✔
77
    }
2✔
78
}
1✔
79

1✔
80
export default EntwinePointTileSource;
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