| 353 | } |
| 354 | |
| 355 | void CopcWriter::write(const PointViewPtr v) |
| 356 | { |
| 357 | using namespace copcwriter; |
| 358 | |
| 359 | if (v->empty()) |
| 360 | { |
| 361 | log()->get(LogLevel::Warning) << "writers.copc skipping empty point view.\n"; |
| 362 | return; |
| 363 | } |
| 364 | |
| 365 | if (++b->viewCount > 1) |
| 366 | log()->get(LogLevel::Warning) << "writers.copc does not support multiple views " |
| 367 | "and will overwrite files for earlier views. Consider adding a merge filter.\n"; |
| 368 | |
| 369 | BOX3D box; |
| 370 | v->calculateBounds(box); |
| 371 | |
| 372 | Grid grid(box, v->size()); |
| 373 | |
| 374 | CellManager mgr(v); |
| 375 | |
| 376 | for (PointRef p : *v) |
| 377 | { |
| 378 | double x = p.getFieldAs<double>(Dimension::Id::X); |
| 379 | double y = p.getFieldAs<double>(Dimension::Id::Y); |
| 380 | double z = p.getFieldAs<double>(Dimension::Id::Z); |
| 381 | double t = p.getFieldAs<double>(Dimension::Id::GpsTime); |
| 382 | double r = p.getFieldAs<double>(Dimension::Id::ReturnNumber); |
| 383 | b->stats[(int)stats::Index::X].insert(x); |
| 384 | b->stats[(int)stats::Index::Y].insert(y); |
| 385 | b->stats[(int)stats::Index::Z].insert(z); |
| 386 | b->stats[(int)stats::Index::GpsTime].insert(t); |
| 387 | b->stats[(int)stats::Index::ReturnNumber].insert(r); |
| 388 | |
| 389 | VoxelKey key = grid.key(x, y, z); |
| 390 | PointViewPtr& cell = mgr.get(key); |
| 391 | cell->appendPoint(*v, p.pointId()); |
| 392 | } |
| 393 | |
| 394 | // New cells from reprocessing go on the reprocessing manager. They get merged |
| 395 | // at the end. |
| 396 | //ABELL - This should be threaded. These reprocessors should be able to run independently |
| 397 | // since their data doesn't overlap spatially. Probably need a separate CellManager |
| 398 | // for each that is merged under lock at completion. |
| 399 | CellManager reprocessMgr(v); |
| 400 | auto it = mgr.begin(); |
| 401 | while (it != mgr.end()) |
| 402 | { |
| 403 | PointViewPtr& v = it->second; |
| 404 | if (v->size() >= MaxPointsPerNode) |
| 405 | { |
| 406 | Reprocessor r(reprocessMgr, v, grid); |
| 407 | r.run(); |
| 408 | // Remove the reprocessed cell from the manager. |
| 409 | it = mgr.erase(it); |
| 410 | } |
| 411 | else |
| 412 | it++; |
nothing calls this directly
no test coverage detected