From 64c93918b1586067846171d407b4879e1a7fd914 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Mon, 7 Aug 2017 14:51:49 +0200 Subject: [PATCH 1/7] Start of the Potree file standard --- docs/potree-file-format.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docs/potree-file-format.md diff --git a/docs/potree-file-format.md b/docs/potree-file-format.md new file mode 100644 index 00000000..82904a58 --- /dev/null +++ b/docs/potree-file-format.md @@ -0,0 +1,23 @@ +# Potree Data Format + +_Note: This document is written based on the Potree 1.5 data format._ + +## Purpose + +TODO + +## Folder Structure + +TODO + +## Meta Information + +## Build Information + +## Index Files + +TODO + +## PointCloud Data files + +TODO From f9fc7550d259fb07481e95c408fce851bf45bd50 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Mon, 14 Aug 2017 03:26:57 +0200 Subject: [PATCH 2/7] First full document. --- docs/potree-file-format.md | 222 +++++++++++++++++++++++++++++++++++-- 1 file changed, 214 insertions(+), 8 deletions(-) diff --git a/docs/potree-file-format.md b/docs/potree-file-format.md index 82904a58..691df883 100644 --- a/docs/potree-file-format.md +++ b/docs/potree-file-format.md @@ -1,23 +1,229 @@ # Potree Data Format -_Note: This document is written based on the Potree 1.5 data format._ +_Note: This document is written based on the Potree 1.7 data format._ -## Purpose +## Overview -TODO +The Potree Data Format is … + +- … made for loading [PointCloud][PointCloud] data. +- … flexibly optimizable for different kinds of available information + _(see [PointCloud Data files](#pointcloud-data-files))_. +- … built for the web _(cachable, hostable on simple file storages)_. +- … split into several files & folders _(urls)_. +- … implemented using an [Octree][Octree] file structure. +- … implemented with very little overhead. ## Folder Structure -TODO +- `/cloud.js` - [Meta Information](#meta-information) +- `/sources.json` - [Build Information](#build-information) +- `//r/**/r**.hrc` - [Index Files](#index-files) +- `//r/**/r**.bin` - [PointCloud Data files](#pointcloud-data-files) +- `//r/**/r**.las` - [Las Data files](#las-data-files) +- `//r/**/r**.laz` - [Laz Data files](#laz-data-files) ## Meta Information +Global structure information about how the other files should be interpreted +will be stored in the `/cloud.js` file which contains [JSON][JSON] formatted +data _(name misleading)_. + +- `version` _(String)_ Version number in which this file is written _(1.7)_ is + the current version. +- `octreeDir` _(String)_ Folder that is used to load additional data. +- `points` _(Number)_ Amount of points contained in the whole pointcloud data +- `projection` _(String)_ This parameter is used to transform the point data to + the projection system used while visualizing the points. It has to be in a + format that is parsable by [proj.4][proj4]. + +- `boundingBox` _(Object)_ Bounding box of the world used to limit the initial + POV. + + - `lx` _(Number)_ Min X + - `ly` _(Number)_ Min Y + - `lz` _(Number)_ Min Z + - `ux` _(Number)_ Max X + - `uy` _(Number)_ Max Y + - `uz` _(Number)_ Max Z + +- `tightBoundingBox` _(Object)_ Bounding box of the actual points in the data + + - `lx` _(Number)_ Min X + - `ly` _(Number)_ Min Y + - `lz` _(Number)_ Min Z + - `ux` _(Number)_ Max X + - `uy` _(Number)_ Max Y + - `uz` _(Number)_ Max Z + +- `pointAttributes` _(String or Array)_ `LAZ` or `LAS` or... + + an _(Array)_ of attributes specifying the order and type of data stored in + the [Data files](#data-index-files). Its possible to be one of the following + keys: + + - `POSITION_CARTESIAN`: 3 _([float][Float])_ numbers: x, y, z + - `RGBA_PACKED`: 4 x _(uint8)_ numbers for the color: r, g, b, a + _(Note: Could it be that this is unused?)_ + - `COLOR_PACKED`: 3 x _(uint8)_ numbers for the color: r, g, b + - `RGB_PACKED`: 3 x _(uint8)_ numbers for the color: r, g, b + _(Note: Could it be that this is unused?)_ + - `NORMAL_FLOATS`: 3 x _(float)_ numbers: x', y', z' + _(Note: Could it be that this is unused?)_ + - `FILLER_1B`: _(uint8)_ number + _(Note: Could it be that this is unused?)_ + - `INTENSITY`: _(uint16)_ number specifying the point's intensity + - `CLASSIFICATION`: _(uint8)_ id for the class used. + - `NORMAL_SPHEREMAPPED`: _(Note: might need to be revisited, best don't use)_ + - `NORMAL_OCT16`: _(Note: might need to be revisited, best don't use)_ + - `NORMAL`: 3 x _(float)_ numbers: x', y', z' + + _Note:_ JavaScript operates exclusively with [`little endian`][LittleEndian] + number types. Which is why all types mentioned here are in little endian + as well. + +- `spacing`: _(Number)_ Space between points +- `scale`: _(Number)_ Scale applied to the floating point numbers +- `hierarchyStepSize`: _(Number)_ Amount of Octree levels before a new folder + hierarchy is expected. +- `hierarchy`: _(Array)_ **(deprecated)** The hierarchy of files, now loaded + through [index files](#index-files). + ## Build Information -## Index Files +When generating Potree data, the generator can **optionally** create a +`sources.json` file to keep information about the source-data that was used to +create the Potree data. -TODO +## Data & Index files -## PointCloud Data files +Depending on the `pointAttributes` [meta information](#meta-information) the +actual point data is stored in either [`.bin`](#poincloud-data-files), +[`.las`](#las-data-files) or [`.laz`](#laz-data-files) data files. -TODO +The path for each file consists of the `octreeDir` +[meta information](#meta-information) followed by a tree structure path. +In an octree there are 8 possible nodes in every hierarchy level. +Potree assumes `0`-`7` for each node in a hierarchy level. The +`hierarchyStepSize` information specifies the hierarchy depth after which +a new folder will be added to the hierarchy with the name of the sub-hiearchies +prefix. + +_Example:_ Given `octreeDir` is set to `data` and `pointAttributes` is set to +`laz` and `hierarchyStepSize` is set to `3`. This example shows a very small +, fictive, tree: + +``` + r + / \ + 0 3 + | / \ + 1 0 1 + | + 0 +``` + +The resulting data files would need to be stored like this: + +``` +|- cloud.js +\- data/ + \- r/ + |- r.hrc + |- r.laz + |- r0.laz + |- r01.laz + |- r3.laz + |- r30.laz + |- r31.laz + \- 310/ + |- r310.hrc + \- r310.laz +``` + +- `data/r/r.hrc` and `data/r/310/r310.hrc` are the [index files](#index-files) + specifying what sub tree nodes are available. +- `data/r/**/*.laz` contains the binary pointcloud data to be loaded +- `data/r/310/` is the subfolder created for the 3rd hierarchy level + +### Index Files + +As mentioned in the former section, the `.hrc` files contain the index structure +meaning a list of all the files stored within the directory tree. + +An index file contains a list of tuple values with the first being a `uint8` +"mask" and the second being `uint32` "number of points" of a hierarchy level. + +Per hierarchy level we have 8 possible nodes. To indicate whether a node exists +a simple binary mask is used: + +``` +0 → 1 +1 → 2 +2 → 8 +3 → 16 +4 → 32 +5 → 64 +6 → 128 +7 → 256 +``` + +So if in a hierarchy the child node 3 and node 7 exist then the hierarchies +mask has to be `16 | 256` → `272`. + +_Example:_ A simple, non-realistic tree: + +``` + 01234567 + | | + | \-------------\ + | | + \01234567 01234567 + | | + \01234567 P + | | + P P +``` + +Would have an index looking like this: + +- mask: `2 | 8 → 10`, points: `3` +- mask: `16`, points: `2` +- mask: `1 | 32 → 33`, points: `2` +- mask: `128`, points: `1` + +### PointCloud Data files + +The `.bin` files contains a list of points. For each point it contains a list +of binary data following the `pointAttributes` specified in the +[meta information](#meta-information). + +_Example:_ With `pointAttributes=['POSITION_CARTESIAN']`, the `.bin` file is a +sequence of points with each consisting of 3 `float` numbers. + +_Example2:_ With `pointAttributes=['POSITION_CARTESIAN','INTENSITY']`, the +`.bin` files contain a sequence of points consisting of 3 `float` numbers +followed by one `uint16` number. + +_Example3:_ With `pointAttributes=['INTENSITY','POSITION_CARTESIAN']`, the +`.bin` files contain a sequence of points consisting of one `uint16` number +followed by 3 `float` numbers. + +### Las Data files + +`.las` data files have to follow the [`las` specification][LasSpec]. Potree +supports up to [version 1.3][LasSpec1.3]. + +### Laz Data files + +Compressed [`.las`](#las-data-files) files. See [LasZip][LasZip]. + +[PointCloud]: https://en.wikipedia.org/wiki/Point_cloud +[Float]: https://en.wikipedia.org/wiki/IEEE_754#Formats +[JSON]: http://www.json.org/ +[proj.4]: http://proj4.org/projections/index.html +[Octree]: https://en.wikipedia.org/wiki/Octree +[LasSpec]: https://www.liblas.org/development/specifications.html#specifications +[LasSpec1.3]: https://www.liblas.org/_static/files/specifications/asprs_las_format_v13.pdf] +[LasZip]: http://www.laszip.org/ +[LittleEndian]: https://en.wikipedia.org/wiki/Endianness#Little-endian From fd2207bb3d1ffab85bd0ab483506b3316f19d951 Mon Sep 17 00:00:00 2001 From: potree Date: Tue, 15 Aug 2017 16:57:20 +0200 Subject: [PATCH 3/7] Update potree-file-format.md fixing some descriptions --- docs/potree-file-format.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/potree-file-format.md b/docs/potree-file-format.md index 691df883..4beee8c0 100644 --- a/docs/potree-file-format.md +++ b/docs/potree-file-format.md @@ -62,10 +62,10 @@ data _(name misleading)_. the [Data files](#data-index-files). Its possible to be one of the following keys: - - `POSITION_CARTESIAN`: 3 _([float][Float])_ numbers: x, y, z + - `POSITION_CARTESIAN`: 3 _(uint32)_ numbers: x, y, z - `RGBA_PACKED`: 4 x _(uint8)_ numbers for the color: r, g, b, a _(Note: Could it be that this is unused?)_ - - `COLOR_PACKED`: 3 x _(uint8)_ numbers for the color: r, g, b + - `COLOR_PACKED`: 4 x _(uint8)_ numbers for the color: r, g, b, a - `RGB_PACKED`: 3 x _(uint8)_ numbers for the color: r, g, b _(Note: Could it be that this is unused?)_ - `NORMAL_FLOATS`: 3 x _(float)_ numbers: x', y', z' @@ -78,12 +78,10 @@ data _(name misleading)_. - `NORMAL_OCT16`: _(Note: might need to be revisited, best don't use)_ - `NORMAL`: 3 x _(float)_ numbers: x', y', z' - _Note:_ JavaScript operates exclusively with [`little endian`][LittleEndian] - number types. Which is why all types mentioned here are in little endian - as well. + _Note:_ All types mentioned here are in little endian. -- `spacing`: _(Number)_ Space between points -- `scale`: _(Number)_ Scale applied to the floating point numbers +- `spacing`: _(Number)_ Space between points at the root node. This value is halved at each octree level. +- `scale`: _(Number)_ Scale applied to convert POSITION_CARTESIAN components from _uint32_ values to floating point values. The full transformation to world coordinates is ```position = (POSITION_CARTESIAN * scale) + boundingBox.min``` - `hierarchyStepSize`: _(Number)_ Amount of Octree levels before a new folder hierarchy is expected. - `hierarchy`: _(Array)_ **(deprecated)** The hierarchy of files, now loaded @@ -169,7 +167,7 @@ a simple binary mask is used: ``` So if in a hierarchy the child node 3 and node 7 exist then the hierarchies -mask has to be `16 | 256` → `272`. +mask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136). _Example:_ A simple, non-realistic tree: @@ -199,15 +197,15 @@ of binary data following the `pointAttributes` specified in the [meta information](#meta-information). _Example:_ With `pointAttributes=['POSITION_CARTESIAN']`, the `.bin` file is a -sequence of points with each consisting of 3 `float` numbers. +sequence of points with each consisting of 3 `uint32` numbers. _Example2:_ With `pointAttributes=['POSITION_CARTESIAN','INTENSITY']`, the -`.bin` files contain a sequence of points consisting of 3 `float` numbers +`.bin` files contain a sequence of points consisting of 3 `uint32` numbers followed by one `uint16` number. _Example3:_ With `pointAttributes=['INTENSITY','POSITION_CARTESIAN']`, the `.bin` files contain a sequence of points consisting of one `uint16` number -followed by 3 `float` numbers. +followed by 3 `uint32` numbers. ### Las Data files From a52c15e298da120df8e50341b97d683ff5857765 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 17 Aug 2017 02:30:23 +0200 Subject: [PATCH 4/7] Better readability binary masks As @potree [pointed out](https://github.com/potree/potree/pull/376#issuecomment-322493586), the binary mask example was not exactly easy to understand. I hope with a few formatting adjustments this has become better to read. --- docs/potree-file-format.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/potree-file-format.md b/docs/potree-file-format.md index 4beee8c0..739a3142 100644 --- a/docs/potree-file-format.md +++ b/docs/potree-file-format.md @@ -155,16 +155,16 @@ An index file contains a list of tuple values with the first being a `uint8` Per hierarchy level we have 8 possible nodes. To indicate whether a node exists a simple binary mask is used: -``` -0 → 1 -1 → 2 -2 → 8 -3 → 16 -4 → 32 -5 → 64 -6 → 128 -7 → 256 -``` +| Position | Mask | [Binary][bin] | +|----------|------|---------------| +| 0 | 1 | 0b00000001 | +| 1 | 2 | 0b00000010 | +| 2 | 8 | 0b00000100 | +| 3 | 16 | 0b00001000 | +| 4 | 32 | 0b00010000 | +| 5 | 64 | 0b00100000 | +| 6 | 128 | 0b01000000 | +| 7 | 256 | 0b10000000 | So if in a hierarchy the child node 3 and node 7 exist then the hierarchies mask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136). @@ -185,10 +185,12 @@ _Example:_ A simple, non-realistic tree: Would have an index looking like this: -- mask: `2 | 8 → 10`, points: `3` -- mask: `16`, points: `2` -- mask: `1 | 32 → 33`, points: `2` -- mask: `128`, points: `1` +| mask | points | +|------|--------| +| `0b00001010` (=10) | `3` | +| `0b00010000` (=32) | `2` | +| `0b00010001` (=65) | `2` | +| `0b01000000` (=128) | `1` | ### PointCloud Data files @@ -225,3 +227,4 @@ Compressed [`.las`](#las-data-files) files. See [LasZip][LasZip]. [LasSpec1.3]: https://www.liblas.org/_static/files/specifications/asprs_las_format_v13.pdf] [LasZip]: http://www.laszip.org/ [LittleEndian]: https://en.wikipedia.org/wiki/Endianness#Little-endian +[bin]: http://www.javascripttutorial.net/es6/octal-and-binary-literals/ From c165d196f228e918dae9999c03c36573c8c45016 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 17 Aug 2017 02:31:24 +0200 Subject: [PATCH 5/7] Binary number fix :sleepy: --- docs/potree-file-format.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/potree-file-format.md b/docs/potree-file-format.md index 739a3142..323560b7 100644 --- a/docs/potree-file-format.md +++ b/docs/potree-file-format.md @@ -189,7 +189,7 @@ Would have an index looking like this: |------|--------| | `0b00001010` (=10) | `3` | | `0b00010000` (=32) | `2` | -| `0b00010001` (=65) | `2` | +| `0b00100001` (=65) | `2` | | `0b01000000` (=128) | `1` | ### PointCloud Data files From c266f3391ffa7149f832426a18c94492fb17bf49 Mon Sep 17 00:00:00 2001 From: potree Date: Thu, 17 Aug 2017 09:28:43 +0200 Subject: [PATCH 6/7] Update potree-file-format.md fixed binary mask values --- docs/potree-file-format.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/potree-file-format.md b/docs/potree-file-format.md index 323560b7..f12bc738 100644 --- a/docs/potree-file-format.md +++ b/docs/potree-file-format.md @@ -159,12 +159,12 @@ a simple binary mask is used: |----------|------|---------------| | 0 | 1 | 0b00000001 | | 1 | 2 | 0b00000010 | -| 2 | 8 | 0b00000100 | -| 3 | 16 | 0b00001000 | -| 4 | 32 | 0b00010000 | -| 5 | 64 | 0b00100000 | -| 6 | 128 | 0b01000000 | -| 7 | 256 | 0b10000000 | +| 2 | 4 | 0b00000100 | +| 3 | 8 | 0b00001000 | +| 4 | 16 | 0b00010000 | +| 5 | 32 | 0b00100000 | +| 6 | 64 | 0b01000000 | +| 7 | 128 | 0b10000000 | So if in a hierarchy the child node 3 and node 7 exist then the hierarchies mask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136). @@ -188,9 +188,9 @@ Would have an index looking like this: | mask | points | |------|--------| | `0b00001010` (=10) | `3` | -| `0b00010000` (=32) | `2` | -| `0b00100001` (=65) | `2` | -| `0b01000000` (=128) | `1` | +| `0b00010000` (=16) | `2` | +| `0b00100001` (=33) | `2` | +| `0b01000000` (=64) | `1` | ### PointCloud Data files From 0df4f0d0ef0abe87793dc56ad56cc3aac5633354 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Mon, 21 Aug 2017 17:53:01 +0200 Subject: [PATCH 7/7] Better explained Thanks @mschuetz for the support this should satisfy good readers. --- docs/potree-file-format.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/potree-file-format.md b/docs/potree-file-format.md index f12bc738..ffa42acb 100644 --- a/docs/potree-file-format.md +++ b/docs/potree-file-format.md @@ -150,7 +150,8 @@ As mentioned in the former section, the `.hrc` files contain the index structure meaning a list of all the files stored within the directory tree. An index file contains a list of tuple values with the first being a `uint8` -"mask" and the second being `uint32` "number of points" of a hierarchy level. +"mask" and the second being `uint32` "number of points" of a hierarchy level +in a [breadth first level order][breadth-first]. Per hierarchy level we have 8 possible nodes. To indicate whether a node exists a simple binary mask is used: @@ -172,25 +173,24 @@ mask has to be `0b00001000 | 0b10000000` → `0b10001000` (=136). _Example:_ A simple, non-realistic tree: ``` - 01234567 - | | - | \-------------\ - | | - \01234567 01234567 - | | - \01234567 P - | | - P P +|- r1 +| | +| \- r14 (2 Points) +| +\- r3 + | + \- r36 (1 Point) ``` Would have an index looking like this: -| mask | points | -|------|--------| -| `0b00001010` (=10) | `3` | -| `0b00010000` (=16) | `2` | -| `0b00100001` (=33) | `2` | -| `0b01000000` (=64) | `1` | +| name | mask | points | +|------|--------------------|--------| +| r | `0b00001010` (=10) | `3` | +| r1 | `0b00010000` (=16) | `2` | +| r3 | `0b01000000` (=64) | `1` | +| r14 | `0b00000000` (=0) | `2` | +| r36 | `0b00000000` (=0) | `1` | ### PointCloud Data files @@ -228,3 +228,4 @@ Compressed [`.las`](#las-data-files) files. See [LasZip][LasZip]. [LasZip]: http://www.laszip.org/ [LittleEndian]: https://en.wikipedia.org/wiki/Endianness#Little-endian [bin]: http://www.javascripttutorial.net/es6/octal-and-binary-literals/ +[breadth-first]: https://en.wikipedia.org/wiki/Breadth-first_search