From 2d9c2907ad3936baeff1395f28a1175a048a2de0 Mon Sep 17 00:00:00 2001 From: Michael Kutzner <174690291+MichaelKutzner@users.noreply.github.com> Date: Thu, 19 Dec 2024 09:54:54 +0100 Subject: [PATCH] Fix step size for mixed HGT tiles --- src/preprocessing/elevation/hgt_raster.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/preprocessing/elevation/hgt_raster.cc b/src/preprocessing/elevation/hgt_raster.cc index fc36d69..6d06315 100644 --- a/src/preprocessing/elevation/hgt_raster.cc +++ b/src/preprocessing/elevation/hgt_raster.cc @@ -68,10 +68,19 @@ ::osr::elevation_t hgt_raster::get(::osr::point const& point) const { } step_size hgt_raster::get_step_size() const { - return tiles_.empty() - ? step_size{} - : std::visit([](auto const& t) { return t.get_step_size(); }, - tiles_.front()); + auto steps = step_size{.x_ = std::numeric_limits::quiet_NaN(), + .y_ = std::numeric_limits::quiet_NaN()}; + for (auto const& tile : tiles_) { + auto const s = + std::visit([](auto const& t) { return t.get_step_size(); }, tile); + if (std::isnan(steps.x_) || s.x_ < steps.x_) { + steps.x_ = s.x_; + } + if (std::isnan(steps.y_) || s.y_ < steps.y_) { + steps.y_ = s.y_; + } + } + return steps; } std::optional hgt_raster::open(fs::path const& path) {