| 474 | } |
| 475 | |
| 476 | std::vector<double> SMRFilter::createZImin(PointViewPtr view) |
| 477 | { |
| 478 | // "As with many other ground filtering algorithms, the first step is |
| 479 | // generation of ZImin from the cell size parameter and the extent of the |
| 480 | // data." |
| 481 | std::vector<double> ZIminV(m_rows * m_cols, |
| 482 | std::numeric_limits<double>::quiet_NaN()); |
| 483 | |
| 484 | for (PointRef p : *view) |
| 485 | { |
| 486 | double x = p.getFieldAs<double>(Id::X); |
| 487 | double y = p.getFieldAs<double>(Id::Y); |
| 488 | double z = p.getFieldAs<double>(Id::Z); |
| 489 | |
| 490 | int c = static_cast<int>(floor((x - m_bounds.minx) / m_args->m_cell)); |
| 491 | int r = static_cast<int>(floor((y - m_bounds.miny) / m_args->m_cell)); |
| 492 | |
| 493 | size_t cell = c * m_rows + r; |
| 494 | if (z < ZIminV[cell] || std::isnan(ZIminV[cell])) |
| 495 | ZIminV[cell] = z; |
| 496 | } |
| 497 | |
| 498 | // "...some grid points of ZImin will go unfilled. To fill these values, we |
| 499 | // rely on computationally inexpensive image inpainting techniques. Image |
| 500 | // inpainting involves the replacement of the empty cells in an image (or |
| 501 | // matrix) with values calculated from other nearby values." |
| 502 | |
| 503 | //ABELL - We can eliminate this copy if we're OK with not writing |
| 504 | // both the filled and non-filled array to output. |
| 505 | std::vector<double> ZImin_fillV = ZIminV; |
| 506 | knnfill(view, ZImin_fillV); |
| 507 | |
| 508 | if (!m_args->m_dir.empty()) |
| 509 | { |
| 510 | std::string fname = |
| 511 | FileUtils::toAbsolutePath("zimin.tif", m_args->m_dir); |
| 512 | MatrixXd ZImin = Map<MatrixXd>(ZIminV.data(), m_rows, m_cols); |
| 513 | math::writeMatrix(ZImin, fname, "GTiff", m_args->m_cell, m_bounds, m_srs); |
| 514 | |
| 515 | fname = FileUtils::toAbsolutePath("zimin_fill.tif", m_args->m_dir); |
| 516 | MatrixXd ZImin_fill = Map<MatrixXd>(ZImin_fillV.data(), m_rows, m_cols); |
| 517 | math::writeMatrix(ZImin_fill, fname, "GTiff", m_args->m_cell, m_bounds, m_srs); |
| 518 | } |
| 519 | |
| 520 | return ZImin_fillV; |
| 521 | } |
| 522 | |
| 523 | std::vector<double> SMRFilter::createZInet(std::vector<double> const& ZImin, |
| 524 | std::vector<int> const& isNetCell) |
nothing calls this directly
no test coverage detected