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

iTowns / itowns / 11342622151

15 Oct 2024 08:52AM UTC coverage: 87.082% (+0.1%) from 86.936%
11342622151

Pull #2422

github

web-flow
Merge 1f594815d into cfb9d0f51
Pull Request #2422: Preparation for PR reprojection 'a la volee'

2818 of 3739 branches covered (75.37%)

Branch coverage included in aggregate %.

37 of 42 new or added lines in 5 files covered. (88.1%)

5 existing lines in 2 files now uncovered.

24550 of 27689 relevant lines covered (88.66%)

1183.5 hits per line

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

94.32
/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
        // Necessary because we use the url without the ept.json part as a base
2✔
35
        this.url = this.url.replace('/ept.json', '');
2✔
36

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

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

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

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

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

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

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