28 const bool is_fill_agg) {
29 const auto upper_agg_type_str =
to_upper(agg_type_str);
30 const static std::map<std::string, RasterAggType> agg_type_map = {
38 const auto itr = agg_type_map.find(upper_agg_type_str);
39 if (itr == agg_type_map.end()) {
52 template <RasterAggType AggType>
57 template <
typename Z,
typename Z2>
58 void operator()(
const Z2& input_z, Z& output_z,
const Z2 input_sentinel)
const {
59 if (input_z != input_sentinel) {
60 output_z = output_z == std::numeric_limits<Z>::lowest() ? 1 : output_z + 1;
67 template <
typename Z,
typename Z2>
68 void operator()(
const Z2& input_z, Z& output_z,
const Z2 input_sentinel)
const {
69 if (input_z != input_sentinel && input_z > output_z) {
77 template <
typename Z,
typename Z2>
78 void operator()(
const Z2& input_z, Z& output_z,
const Z2 input_sentinel)
const {
79 if (input_z != input_sentinel && input_z < output_z) {
87 template <
typename Z,
typename Z2>
88 void operator()(
const Z2& input_z, Z& output_z,
const Z2 input_sentinel)
const {
89 if (input_z != input_sentinel) {
91 output_z == std::numeric_limits<Z>::lowest() ? input_z : output_z + input_z;
100 template <
typename T,
typename Z>
126 template <
typename T2,
typename Z2>
131 const double bin_dim_meters,
132 const bool geographic_coords,
133 const bool align_bins_to_zero_based_grid);
135 template <
typename T2,
typename Z2>
140 const double bin_dim_meters,
141 const bool geographic_coords,
142 const bool align_bins_to_zero_based_grid,
164 const int64_t y_bin)
const {
169 return std::make_pair(bin_idx,
z_[bin_idx]);
173 if (x < x_min_ || x >
x_max_ || y < y_min_ || y >
y_max_) {
183 return std::make_pair(x, y);
187 const int64_t source_y_bin,
188 const Z source_z_offset)
const;
195 template <
typename T2,
typename Z2>
202 const int64_t neighborhood_fill_radius,
203 const bool fill_only_nulls,
208 const int64_t num_bins_radius,
209 std::vector<Z>& neighboring_bins)
const;
211 const std::vector<Z>& neighboring_cells,
212 const bool compute_slope_in_degrees)
const;
215 const bool compute_slope_in_degrees)
const;
226 const int64_t neighborhood_null_fill_radius)
const;
231 template <RasterAggType AggType,
typename T2,
typename Z2>
235 std::vector<Z>& output_z);
237 template <RasterAggType AggType>
239 std::vector<Z>& output_z,
240 const Z agg_sentinel);
242 template <RasterAggType AggType,
typename T2,
typename Z2>
246 std::vector<Z>& output_z,
250 const int64_t y_centroid_bin,
251 const int64_t bins_radius)
const;
253 template <RasterAggType AggType>
255 const int64_t y_centroid_bin,
256 const int64_t bins_radius,
259 template <RasterAggType AggType>
261 const bool fill_only_nulls);
263 const bool fill_only_nulls);
266 template <
typename T,
typename Z>
273 const T bin_dim_meters,
274 const bool geographic_coords,
275 const int64_t neighborhood_fill_radius,
276 const bool fill_only_nulls,
290 if (neighborhood_fill_radius > 0) {
292 neighborhood_fill_radius, fill_only_nulls, raster_fill_agg_type);
309 template <
typename T,
typename Z>
316 const T bin_dim_meters,
317 const bool geographic_coords,
318 const int64_t neighborhood_fill_radius,
319 const bool fill_only_nulls,
325 const std::string error_msg =
326 "Invalid Raster Aggregate Type: " + agg_type_str.
getString();
327 return mgr.ERROR_MESSAGE(error_msg);
337 neighborhood_fill_radius,
355 template <
typename T,
typename Z>
363 const T bin_dim_meters,
364 const bool geographic_coords,
365 const int64_t neighborhood_fill_radius,
366 const bool fill_only_nulls,
372 const std::string error_msg =
373 "Invalid Raster Aggregate Type: " + agg_type_str.
getString();
374 return mgr.ERROR_MESSAGE(error_msg);
378 const std::string error_msg =
379 "Invalid Raster Fill Aggregate Type: " + fill_agg_type_str.
getString();
380 return mgr.ERROR_MESSAGE(error_msg);
387 raster_fill_agg_type,
390 neighborhood_fill_radius,
409 template <
typename T,
typename Z>
417 const T bin_dim_meters,
418 const bool geographic_coords,
419 const int64_t neighborhood_fill_radius,
420 const bool fill_only_nulls,
430 const std::string error_msg =
431 "Invalid Raster Aggregate Type: " + agg_type_str.
getString();
432 return mgr.ERROR_MESSAGE(error_msg);
436 const std::string error_msg =
437 "Invalid Raster Fill Aggregate Type: " + fill_agg_type_str.
getString();
438 return mgr.ERROR_MESSAGE(error_msg);
455 if (neighborhood_fill_radius > 0) {
457 neighborhood_fill_radius, fill_only_nulls, raster_fill_agg_type);
473 template <
typename T,
typename Z>
480 const T bin_dim_meters,
481 const bool geographic_coords,
482 const int64_t neighborhood_fill_radius,
483 const bool fill_only_nulls,
484 const bool compute_slope_in_degrees,
492 const std::string error_msg =
493 "Invalid Raster Aggregate Type: " + agg_type_str.
getString();
494 return mgr.ERROR_MESSAGE(error_msg);
506 if (neighborhood_fill_radius > 0) {
511 const size_t output_rows =
514 output_slope, output_aspect, compute_slope_in_degrees);
Z offset_source_z_from_raster_z(const int64_t source_x_bin, const int64_t source_y_bin, const Z source_z_offset) const
bool get_nxn_neighbors_if_not_null(const int64_t x_bin, const int64_t y_bin, const int64_t num_bins_radius, std::vector< Z > &neighboring_bins) const
void operator()(const Z2 &input_z, Z &output_z, const Z2 input_sentinel) const
int64_t get_bin_idx_for_xy_coords(const T x, const T y) const
void setMetadata(TableFunctionManager &mgr) const
std::pair< Z, Z > calculate_slope_and_aspect_of_cell(const std::vector< Z > &neighboring_cells, const bool compute_slope_in_degrees) const
std::pair< T, T > get_xy_coords_for_bin_idx(const int64_t bin_idx) const
std::string getString() const
GeoRaster(const Column< T2 > &input_x, const Column< T2 > &input_y, const Column< Z2 > &input_z, const RasterAggType raster_agg_type, const double bin_dim_meters, const bool geographic_coords, const bool align_bins_to_zero_based_grid)
int64_t outputDenseColumns(TableFunctionManager &mgr, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z) const
void operator()(const Z2 &input_z, Z &output_z, const Z2 input_sentinel) const
void fill_bins_from_neighbors(const int64_t neighborhood_fill_radius, const bool fill_only_nulls, const RasterAggType raster_agg_type=RasterAggType::GAUSS_AVG)
void computeParallelReductionAggImpl(const std::vector< std::vector< Z >> &z_inputs, std::vector< Z > &output_z, const Z agg_sentinel)
const size_t max_inputs_per_thread
T get_y_bin(const T input) const
T get_x_bin(const T input) const
bool is_bin_out_of_bounds(const int64_t x_bin, const int64_t y_bin) const
static constexpr int64_t BIN_OUT_OF_BOUNDS
void align_bins_max_exclusive()
TEMPLATE_NOINLINE int32_t geo_rasterize_impl(TableFunctionManager &mgr, const Column< T > &input_x, const Column< T > &input_y, const Column< Z > &input_z, const RasterAggType raster_agg_type, const RasterAggType raster_fill_agg_type, const T bin_dim_meters, const bool geographic_coords, const int64_t neighborhood_fill_radius, const bool fill_only_nulls, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z)
int64_t x_y_bin_to_bin_index(const int64_t x_bin, const int64_t y_bin, const int64_t num_x_bins)
void fill_bins_from_gaussian_neighborhood(const int64_t neighborhood_fill_radius, const bool fill_only_nulls)
const bool geographic_coords_
void operator()(const Z2 &input_z, Z &output_z, const Z2 input_sentinel) const
void calculate_slope_and_aspect(Column< Z > &slope, Column< Z > &aspect, const bool compute_slope_in_degrees) const
const RasterAggType raster_agg_type_
void computeParallelImpl(const Column< T2 > &input_x, const Column< T2 > &input_y, const Column< Z2 > &input_z, std::vector< Z > &output_z, const size_t max_inputs_per_thread)
std::pair< int64_t, Z > get_bin_idx_and_z_val_for_xy_bin(const int64_t x_bin, const int64_t y_bin) const
Z fill_bin_from_box_neighborhood(const int64_t x_centroid_bin, const int64_t y_centroid_bin, const int64_t bins_radius, const ComputeAgg< AggType > &compute_agg) const
TEMPLATE_NOINLINE int32_t tf_geo_rasterize_slope__cpu_template(TableFunctionManager &mgr, const Column< T > &input_x, const Column< T > &input_y, const Column< Z > &input_z, const TextEncodingNone &agg_type_str, const T bin_dim_meters, const bool geographic_coords, const int64_t neighborhood_fill_radius, const bool fill_only_nulls, const bool compute_slope_in_degrees, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z, Column< Z > &output_slope, Column< Z > &output_aspect)
TEMPLATE_NOINLINE int32_t tf_geo_rasterize__cpu_template(TableFunctionManager &mgr, const Column< T > &input_x, const Column< T > &input_y, const Column< Z > &input_z, const TextEncodingNone &agg_type_str, const T bin_dim_meters, const bool geographic_coords, const int64_t neighborhood_fill_radius, const bool fill_only_nulls, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z)
void fill_bins_from_box_neighborhood(const int64_t neighborhood_fill_radius, const bool fill_only_nulls)
bool is_null(const Z value) const
void compute(const Column< T2 > &input_x, const Column< T2 > &input_y, const Column< Z2 > &input_z, const size_t max_inputs_per_thread)
Z fill_bin_from_avg_box_neighborhood(const int64_t x_centroid_bin, const int64_t y_centroid_bin, const int64_t bins_radius) const
std::pair< int64_t, int64_t > bin_to_x_y_bin_indexes(const int64_t bin, const int64_t num_x_bins)
void align_bins_max_inclusive()
RasterAggType get_raster_agg_type(const std::string &agg_type_str, const bool is_fill_agg)
void operator()(const Z2 &input_z, Z &output_z, const Z2 input_sentinel) const
void calculate_bins_and_scales()
void computeSerialImpl(const Column< T2 > &input_x, const Column< T2 > &input_y, const Column< Z2 > &input_z, std::vector< Z > &output_z)
#define TEMPLATE_NOINLINE