• 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

98.31
/src/Source/Potree2Source.js
1
import Source from 'Source/Source';
1✔
2
import Fetcher from 'Provider/Fetcher';
1✔
3
import Potree2BinParser from 'Parser/Potree2BinParser';
1✔
4

1✔
5
/**
1✔
6
 * Potree2Source are object containing informations on how to fetch potree 2.0 points cloud resources.
1✔
7
 */
1✔
8

1✔
9
class Potree2Source extends Source {
1✔
10
    /**
1✔
11
     * @param {Object} source - An object that can contain all properties of a
1✔
12
     * Potree2Source
1✔
13
     * @param {string} source.url - folder url.
1✔
14
     * @param {string} source.file - metadata file name.
1✔
15
     *
1✔
16
     * This `metadata` file stores information about the potree cloud 2.0 in JSON format. the structure is :
1✔
17
     *
1✔
18
     * * __`version`__ - The metadata.json format may change over time. The version number is
1✔
19
     * necessary so that parsers know how to interpret the data.
1✔
20
     * * __`name`__ - Point cloud name.
1✔
21
     * * __`description`__ - Point cloud description.
1✔
22
     * * __`points`__ - Total number of points.
1✔
23
     * * __`projection`__ - Point cloud geographic projection system.
1✔
24
     * * __`hierarchy`__ - Information about point cloud hierarchy (first chunk size, step size, octree depth).
1✔
25
     * * __`offset`__ - Position offset used to determine the global point position.
1✔
26
     * * __`scale`__ - Point cloud scale.
1✔
27
     * * __`spacing`__ - The minimum distance between points at root level.
1✔
28
     * * __`boundingBox`__ - Contains the minimum and maximum of the axis aligned bounding box. This bounding box is cubic and aligned to fit to the octree root.
1✔
29
     * * __`encoding`__ - Encoding type: BROTLI or DEFAULT (uncompressed).
1✔
30
     * * __`attributes`__ - Array of attributes (position,  intensity, return number, number of returns, classification, scan angle rank, user data, point source id, gps-time, rgb).
1✔
31
     * ```
1✔
32
     * {
1✔
33
     *     version: '2.0',
1✔
34
     *     name: "sample",
1✔
35
     *     description: "",
1✔
36
     *     points: 534909153,
1✔
37
     *     projection: "",
1✔
38
     *     hierarchy: {
1✔
39
     *         firstChunkSize: 1276,
1✔
40
     *         stepSize: 4,
1✔
41
     *         depth: 16
1✔
42
     *     },
1✔
43
     *     offset: [1339072.07, 7238866.339, 85.281],
1✔
44
     *     scale: [0.001, 0.001, 0.002],
1✔
45
     *     spacing: 24.476062500005355,
1✔
46
     *     boundingBox: {
1✔
47
     *         min: [1339072.07, 7238866.339, 85.281],
1✔
48
     *         max: [1342205.0060000008, 7241999.275, 3218.2170000006854]
1✔
49
     *     },
1✔
50
     *     encoding: "BROTLI",
1✔
51
     *     attributes: [
1✔
52
     *          {
1✔
53
     *              name: "position",
1✔
54
     *              description: "",
1✔
55
     *              size: 12,
1✔
56
     *              numElements: 3,
1✔
57
     *              elementSize: 4,
1✔
58
     *              type: "int32",
1✔
59
     *              min: [-0.74821299314498901, -2.7804059982299805, 2.5478212833404541],
1✔
60
     *              max: [2.4514148223438199, 1.4893437627414672, 7.1957106576508663]
1✔
61
     *          },
1✔
62
     *          {
1✔
63
     *              name: "intensity",
1✔
64
     *              description: "",
1✔
65
     *              size: 2,
1✔
66
     *              numElements: 1,
1✔
67
     *              elementSize: 2,
1✔
68
     *              type: "uint16",
1✔
69
     *              min: [0],
1✔
70
     *              max: [0]
1✔
71
     *          },{
1✔
72
     *              name: "return number",
1✔
73
     *              description: "",
1✔
74
     *              size: 1,
1✔
75
     *              numElements: 1,
1✔
76
     *              elementSize: 1,
1✔
77
     *              type: "uint8",
1✔
78
     *              min: [0],
1✔
79
     *              max: [0]
1✔
80
     *          },{
1✔
81
     *              name: "number of returns",
1✔
82
     *              description: "",
1✔
83
     *              size: 1,
1✔
84
     *              numElements: 1,
1✔
85
     *              elementSize: 1,
1✔
86
     *              type: "uint8",
1✔
87
     *              min: [0],
1✔
88
     *              max: [0]
1✔
89
     *          },{
1✔
90
     *              name: "classification",
1✔
91
     *              description: "",
1✔
92
     *              size: 1,
1✔
93
     *              numElements: 1,
1✔
94
     *              elementSize: 1,
1✔
95
     *              type: "uint8",
1✔
96
     *              min: [0],
1✔
97
     *              max: [0]
1✔
98
     *          },{
1✔
99
     *              name: "scan angle rank",
1✔
100
     *              description: "",
1✔
101
     *              size: 1,
1✔
102
     *              numElements: 1,
1✔
103
     *              elementSize: 1,
1✔
104
     *              type: "uint8",
1✔
105
     *              min: [0],
1✔
106
     *              max: [0]
1✔
107
     *          },{
1✔
108
     *              name: "user data",
1✔
109
     *              description: "",
1✔
110
     *              size: 1,
1✔
111
     *              numElements: 1,
1✔
112
     *              elementSize: 1,
1✔
113
     *              type: "uint8",
1✔
114
     *              min: [0],
1✔
115
     *              max: [0]
1✔
116
     *          },{
1✔
117
     *              name: "point source id",
1✔
118
     *              description: "",
1✔
119
     *              size: 2,
1✔
120
     *              numElements: 1,
1✔
121
     *              elementSize: 2,
1✔
122
     *              type: "uint16",
1✔
123
     *              min: [0],
1✔
124
     *              max: [0]
1✔
125
     *          },{
1✔
126
     *              name: "gps-time",
1✔
127
     *              description: "",
1✔
128
     *              size: 8,
1✔
129
     *              numElements: 1,
1✔
130
     *              elementSize: 8,
1✔
131
     *              type: "double",
1✔
132
     *              min: [0],
1✔
133
     *              max: [0]
1✔
134
     *          },{
1✔
135
     *              name: "rgb",
1✔
136
     *              description: "",
1✔
137
     *              size: 6,
1✔
138
     *              numElements: 3,
1✔
139
     *              elementSize: 2,
1✔
140
     *              type: "uint16",
1✔
141
     *              min: [5632, 5376, 4864],
1✔
142
     *              max: [65280, 65280, 65280]
1✔
143
     *          }
1✔
144
     *     ]
1✔
145
     * }
1✔
146
     * ```
1✔
147
     *
1✔
148
     * @extends Source
1✔
149
     */
1✔
150
    constructor(source) {
1✔
151
        if (!source.file) {
5!
152
            throw new Error('New Potree2Source: file is required');
×
153
        }
×
154

5✔
155
        super(source);
5✔
156
        this.file = source.file;
5✔
157
        this.fetcher = Fetcher.arrayBuffer;
5✔
158

5✔
159
        this.whenReady = (source.metadata ? Promise.resolve(source.metadata) : Fetcher.json(`${this.url}/${this.file}`, this.networkOptions))
5✔
160
            .then((metadata) => {
5✔
161
                this.metadata = metadata;
5✔
162
                this.pointAttributes = metadata.attributes;
5✔
163
                this.baseurl = `${this.url}`;
5✔
164
                this.extension = 'bin';
5✔
165
                this.parser = Potree2BinParser.parse;
5✔
166

5✔
167
                return metadata;
5✔
168
            });
5✔
169
    }
5✔
170
}
1✔
171

1✔
172
export default Potree2Source;
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