| 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 |
no test coverage detected