| 52 | // moving data around every time the grid is resized. |
| 53 | |
| 54 | GDALGrid::GDALGrid(double xOrigin, double yOrigin, size_t width, size_t height, double edgeLength, |
| 55 | double radius, int outputTypes, size_t windowSize, double power, bool binMode, |
| 56 | std::vector<int> percentileValues) : |
| 57 | m_windowSize(windowSize), m_edgeLength(edgeLength), m_radius(radius), m_power(power), |
| 58 | m_outputTypes(outputTypes), m_binMode(binMode) |
| 59 | { |
| 60 | if (width > (size_t)(std::numeric_limits<int>::max)() || |
| 61 | height > (size_t)(std::numeric_limits<int>::max)()) |
| 62 | { |
| 63 | std::ostringstream oss; |
| 64 | oss << "Grid width or height is too large. Width and height are " |
| 65 | "limited to " << (std::numeric_limits<int>::max)() << " cells." |
| 66 | "Try setting bounds or increasing resolution."; |
| 67 | throw error(oss.str()); |
| 68 | } |
| 69 | RasterLimits limits(xOrigin, yOrigin, width, height, edgeLength); |
| 70 | |
| 71 | m_count.reset(new Rasterd(limits)); |
| 72 | if (m_outputTypes & statMin) |
| 73 | m_min.reset(new Rasterd(limits, (std::numeric_limits<double>::max)())); |
| 74 | if (m_outputTypes & statMax) |
| 75 | m_max.reset(new Rasterd(limits, std::numeric_limits<double>::lowest())); |
| 76 | if (m_outputTypes & statIdw) |
| 77 | { |
| 78 | m_idw.reset(new Rasterd(limits)); |
| 79 | m_idwDist.reset(new Rasterd(limits)); |
| 80 | } |
| 81 | if ((m_outputTypes & statMean) || (m_outputTypes & statStdDev)) |
| 82 | m_mean.reset(new Rasterd(limits)); |
| 83 | if (m_outputTypes & statStdDev) |
| 84 | m_stdDev.reset(new Rasterd(limits)); |
| 85 | //!! We do binmode checks in the writer, so probably not needed here |
| 86 | for (auto& p : percentileValues) |
| 87 | { |
| 88 | if (p > 0 && p < 100) |
| 89 | m_pctls.emplace(p, new Rasterd(limits)); |
| 90 | else |
| 91 | { |
| 92 | std::ostringstream oss; |
| 93 | oss << "Invalid percentile value: " << p << ". Percentiles are limited to " << |
| 94 | "0-100 integer values."; |
| 95 | throw error(oss.str()); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | int GDALGrid::width() const |
| 101 | { |