OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeoRasterTableFunctions.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __CUDACC__
18 
20 
21 RasterAggType get_raster_agg_type(const std::string& agg_type_str,
22  const bool is_fill_agg) {
23  const auto upper_agg_type_str = to_upper(agg_type_str);
24  const static std::map<std::string, RasterAggType> agg_type_map = {
25  {"COUNT", RasterAggType::COUNT},
26  {"MIN", RasterAggType::MIN},
27  {"MAX", RasterAggType::MAX},
28  {"SUM", RasterAggType::SUM},
29  {"AVG", RasterAggType::AVG},
30  {"GAUSS_AVG", RasterAggType::GAUSS_AVG},
31  {"BOX_AVG", RasterAggType::BOX_AVG}};
32  const auto itr = agg_type_map.find(upper_agg_type_str);
33  if (itr == agg_type_map.end()) {
35  }
36  if (is_fill_agg && itr->second == RasterAggType::AVG) {
38  } else if (!is_fill_agg && (itr->second == RasterAggType::BOX_AVG ||
39  itr->second == RasterAggType::GAUSS_AVG)) {
40  // GAUSS_AVG and BOX_AVG are fill-only aggregates
42  }
43  return itr->second;
44 }
45 
46 std::vector<double> generate_1d_gaussian_kernel(const int64_t fill_radius, double sigma) {
47  const int64_t kernel_size = fill_radius * 2 + 1;
48  std::vector<double> gaussian_kernel(kernel_size);
49  const double expr = 1.0 / (sigma * sqrt(2.0 * M_PI));
50  for (int64_t kernel_idx = -fill_radius; kernel_idx <= fill_radius; ++kernel_idx) {
51  gaussian_kernel[kernel_idx + fill_radius] =
52  expr * exp((kernel_idx * kernel_idx) / (-2.0 * (sigma * sigma)));
53  }
54  return gaussian_kernel;
55 }
56 
57 #endif // __CUDACC__
RasterAggType get_raster_agg_type(const std::string &agg_type_str, const bool is_fill_agg)
#define M_PI
Definition: constants.h:25
std::vector< double > generate_1d_gaussian_kernel(const int64_t fill_radius, double sigma)
std::string to_upper(const std::string &str)