17 std::vector<double> new_raster_data(
_header.n_rows *
_header.n_cols *
20 for (std::size_t row(0); row <
_header.n_rows; row++)
22 for (std::size_t col(0); col <
_header.n_cols; col++)
24 const std::size_t idx(row *
_header.n_cols + col);
25 for (std::size_t new_row(row * scaling);
26 new_row < (row + 1) * scaling;
29 const std::size_t idx0(new_row *
_header.n_cols * scaling);
30 for (std::size_t new_col(col * scaling);
31 new_col < (col + 1) * scaling;
78 double const xPos((pnt[0] -
_header.origin[0]) /
_header.cell_size);
79 double const yPos((pnt[1] -
_header.origin[1]) /
_header.cell_size);
81 double const xIdx(std::floor(xPos));
82 double const yIdx(std::floor(yPos));
85 double const xShift = std::abs((xPos - xIdx) - 0.5);
86 double const yShift = std::abs((yPos - yIdx) - 0.5);
87 Eigen::Vector4d weight = {(1 - xShift) * (1 - yShift),
88 xShift * (1 - yShift), xShift * yShift,
89 (1 - xShift) * yShift};
92 int const xShiftIdx = (xPos - xIdx >= 0.5) ? 1 : -1;
93 int const yShiftIdx = (yPos - yIdx >= 0.5) ? 1 : -1;
94 std::array<int, 4>
const x_nb = {{0, xShiftIdx, xShiftIdx, 0}};
95 std::array<int, 4>
const y_nb = {{0, 0, yShiftIdx, yShiftIdx}};
98 Eigen::Vector4d pix_val{};
99 unsigned no_data_count(0);
100 for (
unsigned j = 0; j < 4; ++j)
104 if ((xIdx + x_nb[j]) < 0 || (yIdx + y_nb[j]) < 0 ||
105 (xIdx + x_nb[j]) > (
_header.n_cols - 1) ||
106 (yIdx + y_nb[j]) > (
_header.n_rows - 1))
112 pix_val[j] =
_raster_data[
static_cast<std::size_t
>(yIdx + y_nb[j]) *
114 static_cast<std::size_t
>(xIdx + x_nb[j])];
118 if (std::abs(pix_val[j] -
_header.no_data) <
119 std::numeric_limits<double>::epsilon())
127 if (no_data_count > 0)
129 if (no_data_count == 4 || weight.sum() == 0)
134 weight /= weight.sum();
138 return weight.dot(pix_val);