RDB 2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
createSettings.hpp
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  *
4  * Copyright 2021 RIEGL Laser Measurement Systems
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  *
20  *******************************************************************************
21  */
22 /*!
23  *******************************************************************************
24  *
25  * \file createSettings.hpp
26  * \author RIEGL LMS GmbH, Austria
27  * \brief Database create settings
28  * \version 2015-10-14/AW: Initial version
29  * \version 2016-07-13/AW: Documentation of 'chunkSizeLOD' updated
30  * \version 2016-09-22/AW: Parameter 'cacheSize' changed from 32 to 64 bit type
31  * \version 2016-12-20/AW: New functions to load/save settings from/to JSON
32  * \version 2017-03-28/AW: Documentation of JSON load/save functions updated
33  * \version 2017-11-24/AW: Constructors declared as "explicit" (#2825)
34  * \version 2019-01-15/AW: Parameter 'chunkMode' added
35  * \version 2019-01-18/AW: Parameter 'lodMode' added
36  * \version 2019-02-15/AW: Fix C++ API wrapper of CreateSettings class
37  * \version 2019-10-30/AW: Parameter 'optimizePointID' added (#3458)
38  * \version 2020-02-21/AW: Class 'CreateSettings' is now context-free (#3544)
39  *
40  *******************************************************************************
41  */
42 
43 #ifndef RIEGL_RDB_POINTCLOUD_CREATESETTINGS_HPP
44 #define RIEGL_RDB_POINTCLOUD_CREATESETTINGS_HPP
45 
46 //---< INCLUDES >---------------------------------------------------------------
47 
48 #include "riegl/rdb/context.hpp"
50 
51 //---< NAMESPACE >--------------------------------------------------------------
52 
53 namespace riegl {
54 namespace rdb {
55 namespace pointcloud {
56 
57 //---< CLASS CreateSettings >---------------------------------------------------
58 /*!
59  * \brief Database create settings
60  *
61  * This class defines settings for creating a new point cloud database.
62  */
64 {
65 public:
66  /*!
67  * \brief Primary point attribute
68  *
69  * The primary point attribute defines the attribute that is used
70  * to sort and index the points. Usually the 3D point coordinates are
71  * used for that. The primary attribute is automatically added to the
72  * point cloud (using Pointcloud::attributeAdd()) and cannot be deleted.
73  *
74  * \see riegl::rdb::pointcloud::PointAttributes
75  */
77 
78 public:
79  /*!
80  * \brief Point chunk mode
81  *
82  * Points are internally organized in chunks (primary point attribute index
83  * tree leaves). The size of a chunk (in the dimension of the primary point
84  * attribute) may either be fixed (predefined) or adapted automatically so
85  * that the number of points in a chunk does not exceed a certain limit. In
86  * both cases, the "size" is defined by parameter CreateSettings::chunkSize
87  * and parameter CreateSettings::chunkMode defines the meaning of the value.
88  */
89  enum ChunkMode
90  {
91  /*!
92  * the chunk size defines the maximum number of points per chunk
93  * (the default mode)
94  */
96 
97  /*!
98  * the chunk size defines the edge length of a chunk as 2^N times
99  * resolution of the primary point attribute
100  */
102  };
103 
104  /*!
105  * \brief Point chunk mode
106  *
107  * Details see: CreateSettings::ChunkMode
108  *
109  * Default: CreateSettings::POINT_COUNT
110  */
111  uint32_t chunkMode;
112 
113  /*!
114  * \brief Point chunk size
115  *
116  * Details see: CreateSettings::ChunkMode
117  *
118  * Default: 65536 points
119  */
120  uint32_t chunkSize;
121 
122 public:
123  /*!
124  * \brief Level of detail mode
125  *
126  * A tree structure is used to sort and organize the point cloud. To create
127  * a coarse representation of the point cloud (level of detail = "LOD"), a
128  * number of equally distributed points is extracted from the tree leaf
129  * nodes and copied to the parent nodes.
130  *
131  * The parameter CreateSettings::chunkSizeLOD defines how many points to
132  * extract for LOD whereas the meaning of the value and the LOD creation
133  * algorithm are defined by the parameter CreateSettings::lodMode.
134  */
135  enum LodMode
136  {
137  /*!
138  * the LOD size defines the number of points to copy as a fraction of
139  * the total (original) number of points. So if the original point count
140  * is for example 19820526 and the size is set to 20%, then the number
141  * of LOD points to add is 3964106 (rounded) and the final total number
142  * of points is 23784632 (actual value may differ a little bit).
143  */
144  THINOUT = 1,
145 
146  /*!
147  * the LOD size defines the number of binary subdivisions of the LOD
148  * node's volume in each dimension. So if the primary point attribute
149  * for example has a length of 2 (2D data) and the LOD size is set to 8,
150  * then each LOD node is divided into 2^8 * 2^8 = 2^(8*2) = 2^16 = 65536
151  * sub-volumes. All points of the node's immediate sub-nodes that fall
152  * into one of the sub-volumes are merged to a single point and stored
153  * in the LOD node. The method to merge the attribute values of a group
154  * of points can be defined for each point attribute separately (details
155  * see class PointAttribute).
156  */
158  };
159 
160  /*!
161  * \brief Level of detail mode
162  *
163  * Details see: CreateSettings::LodMode
164  *
165  * Default: CreateSettings::THINOUT
166  */
167  uint32_t lodMode;
168 
169  /*!
170  * \brief Level of detail size
171  *
172  * Details see: CreateSettings::LodMode
173  *
174  * To disable LOD generation, set this parameter to zero (no matter which
175  * LOD mode is used).
176  *
177  * Default: 20 (i.e. 20% of the original point count).
178  *
179  * \note In RDB library versions before 2.0.850 this parameter had a
180  * different meaning. To retain compatibility, the parameter was
181  * not renamed to e.g. 'overheadLOD' - hence the strange name.
182  */
183  uint32_t chunkSizeLOD;
184 
185 public:
186  /*!
187  * \brief Point cache size
188  *
189  * The database engine may buffer read and write operations in an
190  * internal cache. This value defines the cache size in bytes (octets).
191  *
192  * Default: 500 MB
193  */
194  uint64_t cacheSize;
195 
196  /*!
197  * \brief Data compression level
198  *
199  * The database automatically compresses point data before it is
200  * stored. The compression level defines the compression quality,
201  * i.e. higher values produce smaller files.
202  *
203  * Range: 0..100 (i.e. percent)
204  * Default: 10%
205  */
207 
208  /*!
209  * \brief Point ID optimization
210  *
211  * Enable this option to apply optimizations to the point ID
212  * attribute (riegl.id) that can result in smaller files.
213  *
214  * Default: false
215  *
216  * \note No optimizations are applied when:
217  * - points were inserted in a previous transaction
218  * - buffers for the point ID (riegl.id) or dynamic point attributes
219  * (e.g. "riegl.selected", "riegl.visible") are passed to the insert
220  * query (QueryInsert class)
221  *
222  * \warning When optimizations are enabled, the point ID no longer
223  * reflects the order in which the points were inserted.
224  */
226 
227 public:
228  ~CreateSettings();
229 
230  /*!
231  * \brief Default constructor
232  *
233  * All properties are set to default values.
234  */
235  CreateSettings();
236 
237  /// \deprecated since 2.2.3 - use the context-free constructors instead
238  explicit CreateSettings(riegl::rdb::Context &context);
239 
240  /*!
241  * \brief Copy constructor
242  *
243  * All properties are copied from the given settings object.
244  */
245  CreateSettings(const CreateSettings &settings);
246 
247  /*!
248  * \brief Assignment operator
249  *
250  * All properties are copied from the given settings object.
251  */
252  CreateSettings& operator=(const CreateSettings &settings);
253 
254  /*!
255  * \brief Load settings from JSON string
256  *
257  * This function parses the given JSON string and applies all available
258  * properties - missing properties are silently ignored (i.e. the value
259  * remains unchanged). When parsing the JSON string fails, an exception
260  * is thrown.
261  *
262  * Example JSON string:
263  *
264  * {
265  * "primary_attribute": {
266  * "name": "riegl.xyz",
267  * "title": "XYZ",
268  * "description": "Cartesian point coordinates wrt. application coordinate system (0: X, 1: Y, 2: Z)",
269  * "unit_symbol": "m",
270  * "length": 3,
271  * "resolution": 0.00025,
272  * "minimum_value": -535000.0,
273  * "maximum_value": 535000.0,
274  * "default_value": 0.0,
275  * "storage_class": "variable",
276  * "compression_options": "shuffle",
277  * "scale_factor": 1.0
278  * },
279  * "chunk_mode": "point_count",
280  * "chunk_size": 65536,
281  * "lod_mode": "thinout",
282  * "chunk_size_lod": 20,
283  * "cache_size": 524288000,
284  * "compression_level": 10,
285  * "optimize_point_id": false
286  * }
287  */
288  void load(const std::string &json);
289 
290  /*!
291  * \brief Save settings to JSON string
292  * \see load()
293  */
294  std::string save() const;
295 
296 private:
297  friend class CreateSettingsWrapper;
298  void *data;
299 };
300 
301 }}} // namespace riegl::rdb::pointcloud
302 
303 #endif // RIEGL_RDB_POINTCLOUD_CREATESETTINGS_HPP
riegl::rdb::pointcloud::PointAttribute primaryAttribute
Primary point attribute.
Library context.
Definition: context.hpp:70
uint32_t chunkSize
Point chunk size.
RDB library context.
uint32_t lodMode
Level of detail mode.
std::string save() const
Save settings to JSON string.
bool optimizePointID
Point ID optimization.
Point attribute description.
uint8_t compressionLevel
Data compression level.
Point attribute description.
uint32_t chunkMode
Point chunk mode.
void load(const std::string &json)
Load settings from JSON string.
uint32_t chunkSizeLOD
Level of detail size.
CreateSettings & operator=(const CreateSettings &settings)
Assignment operator.
uint64_t cacheSize
Point cache size.
CreateSettings()
Default constructor.