27 std::vector<double> new_raster_data(
_header.n_rows *
_header.n_cols *
30 for (std::size_t row(0); row <
_header.n_rows; row++)
32 for (std::size_t col(0); col <
_header.n_cols; col++)
34 const std::size_t idx(row *
_header.n_cols + col);
35 for (std::size_t new_row(row * scaling);
36 new_row < (row + 1) * scaling;
39 const std::size_t idx0(new_row *
_header.n_cols * scaling);
40 for (std::size_t new_col(col * scaling);
41 new_col < (col + 1) * scaling;
88 double const xPos((pnt[0] -
_header.origin[0]) /
_header.cell_size);
89 double const yPos((pnt[1] -
_header.origin[1]) /
_header.cell_size);
91 double const xIdx(std::floor(xPos));
92 double const yIdx(std::floor(yPos));
95 double const xShift = std::abs((xPos - xIdx) - 0.5);
96 double const yShift = std::abs((yPos - yIdx) - 0.5);
97 Eigen::Vector4d weight = {(1 - xShift) * (1 - yShift),
98 xShift * (1 - yShift), xShift * yShift,
99 (1 - xShift) * yShift};
102 int const xShiftIdx = (xPos - xIdx >= 0.5) ? 1 : -1;
103 int const yShiftIdx = (yPos - yIdx >= 0.5) ? 1 : -1;
104 std::array<int, 4>
const x_nb = {{0, xShiftIdx, xShiftIdx, 0}};
105 std::array<int, 4>
const y_nb = {{0, 0, yShiftIdx, yShiftIdx}};
108 Eigen::Vector4d pix_val{};
109 unsigned no_data_count(0);
110 for (
unsigned j = 0; j < 4; ++j)
114 if ((xIdx + x_nb[j]) < 0 || (yIdx + y_nb[j]) < 0 ||
115 (xIdx + x_nb[j]) > (
_header.n_cols - 1) ||
116 (yIdx + y_nb[j]) > (
_header.n_rows - 1))
122 pix_val[j] =
_raster_data[
static_cast<std::size_t
>(yIdx + y_nb[j]) *
124 static_cast<std::size_t
>(xIdx + x_nb[j])];
128 if (std::abs(pix_val[j] -
_header.no_data) <
129 std::numeric_limits<double>::epsilon())
137 if (no_data_count > 0)
139 if (no_data_count == 4)
144 weight /= weight.sum();
148 return weight.dot(pix_val);