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

iTowns / itowns / 21714509524

05 Feb 2026 02:03PM UTC coverage: 88.096% (+0.05%) from 88.045%
21714509524

push

github

Desplandis
example: add default datasets for point clouds examples

2777 of 3588 branches covered (77.4%)

Branch coverage included in aggregate %.

28335 of 31728 relevant lines covered (89.31%)

930.99 hits per line

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

95.87
/packages/Main/src/Source/EntwinePointTileSource.ts
1
import { CRS } from '@itowns/geographic';
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
 * @param colorDepth - Color depth (in bits).
1✔
9
 * Either 8 or 16 bits. By defaults it will be set to 8 bits for LAS 1.2 and
1✔
10
 * 16 bits for later versions (as mandatory by the specification).
1✔
11
 */
1✔
12
interface EntwinePointTileSourceParameters {
1✔
13
    /** he URL of the directory containing the whole
1✔
14
     * Entwine Point Tile structure. */
1✔
15
    url: string;
1✔
16
    crs: string;
1✔
17
    colorDepth: number;
1✔
18
    networkOptions?: RequestInit;
1✔
19
}
1✔
20

1✔
21
interface EntwinePointTileMetadata {
1✔
22
    bounds: [number, number, number, number, number, number];
1✔
23
    boundsConforming: [number, number, number, number, number, number];
1✔
24
    span: number;
1✔
25
    dataType: 'laszip' | 'bin';
1✔
26
    srs: {
1✔
27
        authority?: string;
1✔
28
        horizontal?: string;
1✔
29
        vertical?: string;
1✔
30
        wkt: string;
1✔
31
    };
1✔
32
}
1✔
33

1✔
34
/**
1✔
35
 * An object defining the source of Entwine Point Tile data. It fetches and
1✔
36
 * parses the main configuration file of Entwine Point Tile format,
1✔
37
 * [`ept.json`](https://entwine.io/entwine-point-tile.html#ept-json).
1✔
38
 */
1✔
39
class EntwinePointTileSource extends Source {
1✔
40
    /** Used to checkout whether this source is a EntwinePointTileSource.
1✔
41
     * Default is true. You should not change this,
1✔
42
     * as it is used internally for optimisation. */
1✔
43
    readonly isEntwinePointTileSource: true;
1✔
44
    colorDepth: number;
1✔
45

1✔
46
    // Properties initialized after fetching ept.json file
1✔
47
    boundsConforming!: [number, number, number, number, number, number];
1✔
48
    bounds!: [number, number, number, number, number, number];
1✔
49
    span!: number;
1✔
50
    zmin!: number;
1✔
51
    zmax!: number;
1✔
52
    spacing!: number;
1✔
53
    extension!: 'laz' | 'bin';
1✔
54

1✔
55
    /**
1✔
56
     * @param config - The configuration, see {@link Source} for
1✔
57
     * available values.
1✔
58
     */
1✔
59
    constructor(config: EntwinePointTileSourceParameters) {
1✔
60
        super(config);
4✔
61

4✔
62
        this.isEntwinePointTileSource = true;
4✔
63
        this.colorDepth = config.colorDepth;
4✔
64

4✔
65
        this.fetcher = Fetcher.arrayBuffer;
4✔
66

4✔
67
        // Necessary because we use the url without the ept.json part as a base
4✔
68
        this.url = this.url.replace('/ept.json', '');
4✔
69

4✔
70
        const jsonPromise = Fetcher
4✔
71
            .json(`${this.url}/ept.json`, this.networkOptions) as Promise<EntwinePointTileMetadata>;
4✔
72
        // https://entwine.io/entwine-point-tile.html#ept-json
4✔
73
        this.whenReady = jsonPromise.then((metadata) => {
4✔
74
            this.boundsConforming = metadata.boundsConforming;
4✔
75
            this.bounds = metadata.bounds;// xMin, yMin, zMin, xMax, yMax, zMax
4✔
76
            this.span = metadata.span;
4✔
77

4✔
78
            this.zmin = this.boundsConforming[2];
4✔
79
            this.zmax = this.boundsConforming[5];
4✔
80

4✔
81
            // NOTE: this spacing is kinda arbitrary here, we take the width and
4✔
82
            // length (height can be ignored), and we divide by the specified
4✔
83
            // span in ept.json. This needs improvements.
4✔
84
            this.spacing = (Math.abs(this.bounds[3] - this.bounds[0])
4✔
85
                + Math.abs(this.bounds[4] - this.bounds[1])) / (2 * this.span);
4✔
86

4✔
87
            // Set parser and its configuration from schema
4✔
88
            this.parser = metadata.dataType === 'laszip' ? LASParser.parse : PotreeBinParser.parse;
4!
89
            this.extension = metadata.dataType === 'laszip' ? 'laz' : 'bin';
4!
90

4✔
91
            if (metadata.srs) {
4✔
92
                if (metadata.srs.authority && metadata.srs.horizontal) {
4✔
93
                    this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
3✔
94
                    if (!CRS.defs(this.crs)) {
3!
95
                        CRS.defs(this.crs, metadata.srs.wkt);
×
96
                    }
×
97
                } else if (metadata.srs.wkt) {
4✔
98
                    this.crs = CRS.defsFromWkt(metadata.srs.wkt);
1✔
99
                }
1✔
100
                if (metadata.srs.vertical && metadata.srs.vertical !== metadata.srs.horizontal) {
4✔
101
                    console.warn('EntwinePointTileSource:' +
3✔
102
                        'Vertical coordinates system code is not yet supported.');
3✔
103
                }
3✔
104
            }
4✔
105

4✔
106
            return this;
4✔
107
        });
4✔
108
    }
4✔
109
}
1✔
110

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