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

iTowns / itowns / 10902507646

17 Sep 2024 11:56AM UTC coverage: 86.931% (-0.03%) from 86.964%
10902507646

push

github

Desplandis
release v2.44.2

2791 of 3694 branches covered (75.55%)

Branch coverage included in aggregate %.

24241 of 27402 relevant lines covered (88.46%)

1027.5 hits per line

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

93.33
/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);
1✔
30

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

1✔
34
        // Necessary because we use the url without the ept.json part as a base
1✔
35
        this.url = this.url.replace('/ept.json', '');
1✔
36

1✔
37
        // https://entwine.io/entwine-point-tile.html#ept-json
1✔
38
        this.whenReady = Fetcher.json(`${this.url}/ept.json`, this.networkOptions).then((metadata) => {
1✔
39
            // Set parser and its configuration from schema
1✔
40
            this.parse = metadata.dataType === 'laszip' ? LASParser.parse : PotreeBinParser.parse;
1!
41
            this.extension = metadata.dataType === 'laszip' ? 'laz' : 'bin';
1!
42

1✔
43
            if (metadata.srs && metadata.srs.authority && metadata.srs.horizontal) {
1✔
44
                this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
1✔
45
                if (!proj4.defs(this.crs)) {
1!
46
                    proj4.defs(this.crs, metadata.srs.wkt);
×
47
                }
×
48

1✔
49
                if (metadata.srs.vertical && metadata.srs.vertical !== metadata.srs.horizontal) {
1✔
50
                    console.warn('EntwinePointTileSource: Vertical coordinates system code is not yet supported.');
1✔
51
                }
1✔
52
            }
1✔
53

1✔
54
            // NOTE: this spacing is kinda arbitrary here, we take the width and
1✔
55
            // length (height can be ignored), and we divide by the specified
1✔
56
            // span in ept.json. This needs improvements.
1✔
57
            this.spacing = (Math.abs(metadata.boundsConforming[3] - metadata.boundsConforming[0])
1✔
58
                + Math.abs(metadata.boundsConforming[4] - metadata.boundsConforming[1])) / (2 * metadata.span);
1✔
59

1✔
60
            this.boundsConforming = metadata.boundsConforming;
1✔
61
            this.span = metadata.span;
1✔
62

1✔
63
            return this;
1✔
64
        });
1✔
65

1✔
66
        this.fetcher = Fetcher.arrayBuffer;
1✔
67
    }
1✔
68
}
1✔
69

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

© 2025 Coveralls, Inc