MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / serializeMetadataToDisk

Method serializeMetadataToDisk

outofcore/src/outofcore_base_data.cpp:131–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129 ////////////////////////////////////////////////////////////////////////////////
130
131 void
132 OutofcoreOctreeBaseMetadata::serializeMetadataToDisk ()
133 {
134 if (LOD_num_points_.empty ())
135 return;
136
137 // Create JSON object
138 std::shared_ptr<cJSON> idx (cJSON_CreateObject (), cJSON_Delete);
139
140 cJSON* name = cJSON_CreateString (tree_name_.c_str ());
141 cJSON* version = cJSON_CreateNumber ( __PCL_OUTOFCORE_VERSION__ );
142 cJSON* pointtype = cJSON_CreateString (point_type_.c_str ());
143 cJSON* lod = cJSON_CreateNumber (static_cast<double> (levels_of_depth_));
144
145 // cJSON does not allow 64 bit ints. Have to put the points in a double to
146 // use this api, will allow counts up to 2^52 points to be stored correctly
147 //or split into LSB MSB?
148 std::vector<double> lodPoints_db;
149 lodPoints_db.insert (lodPoints_db.begin (), LOD_num_points_.begin (), LOD_num_points_.end ());
150
151 cJSON* numpts = cJSON_CreateDoubleArray ( &(lodPoints_db.front ()), static_cast<int>(lodPoints_db.size ()));
152
153 cJSON_AddItemToObject (idx.get (), "name", name);
154 cJSON_AddItemToObject (idx.get (), "version", version);
155 cJSON_AddItemToObject (idx.get (), "pointtype", pointtype);
156 cJSON_AddItemToObject (idx.get (), "lod", lod);
157 cJSON_AddItemToObject (idx.get (), "numpts", numpts);
158 cJSON_AddStringToObject(idx.get(), "coord_system", coordinate_system_.c_str());
159
160 char* idx_txt = cJSON_Print (idx.get ());
161
162 std::ofstream f (metadata_filename_.string ().c_str (), std::ios::out | std::ios::trunc);
163 f << idx_txt;
164 f.close ();
165
166 free (idx_txt);
167 }
168
169 ////////////////////////////////////////////////////////////////////////////////
170

Callers 1

Calls 13

cJSON_CreateObjectFunction · 0.85
cJSON_CreateStringFunction · 0.85
cJSON_CreateNumberFunction · 0.85
cJSON_CreateDoubleArrayFunction · 0.85
cJSON_AddItemToObjectFunction · 0.85
cJSON_PrintFunction · 0.85
emptyMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected