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

iTowns / itowns / 9649841056

24 Jun 2024 05:33PM UTC coverage: 89.754% (+0.1%) from 89.614%
9649841056

Pull #2137

github

web-flow
Merge 71a1097ac into 58fc8bb38
Pull Request #2137: feature: Add potree 2.0 parser

2822 of 3719 branches covered (75.88%)

Branch coverage included in aggregate %.

1319 of 1413 new or added lines in 11 files covered. (93.35%)

1 existing line in 1 file now uncovered.

24613 of 26848 relevant lines covered (91.68%)

904.74 hits per line

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

98.91
/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
 * @classdesc
1✔
7
 * Potree2Source are object containing informations on how to fetch potree 2.0 points cloud resources.
1✔
8
 *
1✔
9
 *
1✔
10
 */
1✔
11

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

5✔
160
        super(source);
5✔
161
        this.file = source.file;
5✔
162
        this.fetcher = Fetcher.arrayBuffer;
5✔
163

5✔
164
        this.whenReady = (source.metadata ? Promise.resolve(source.metadata) : Fetcher.json(`${this.url}/${this.file}`, this.networkOptions))
1✔
165
            .then((metadata) => {
1✔
166
                this.metadata = metadata;
1✔
167
                this.pointAttributes = metadata.attributes;
1✔
168
                this.baseurl = `${this.url}`;
1✔
169
                this.extension = 'bin';
1✔
170
                this.parser = Potree2BinParser.parse;
1✔
171

1✔
172
                return metadata;
1✔
173
            });
1✔
174
    }
1✔
175
}
1✔
176

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