Skip to content

Commit

Permalink
Fix step size for mixed HGT tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKutzner committed Dec 19, 2024
1 parent 90df5c1 commit 2d9c290
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/preprocessing/elevation/hgt_raster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>::quiet_NaN(),
.y_ = std::numeric_limits<double>::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::hgt_tile> hgt_raster::open(fs::path const& path) {
Expand Down

0 comments on commit 2d9c290

Please sign in to comment.