From ea6ba305a6286173345633ac53a8b7e37551c7fb Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Tue, 1 Oct 2024 13:39:31 -0400 Subject: [PATCH] Use rounding for quarantine Replaces flooring in quarantine by rounding. The tests here still pass. The r.pops.spread test requires adjustment which can be previewed here: https://github.com/ncsu-landscape-dynamics/pops-core/pull/218 --- include/pops/quarantine.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/pops/quarantine.hpp b/include/pops/quarantine.hpp index 6720ab5c..7453398c 100644 --- a/include/pops/quarantine.hpp +++ b/include/pops/quarantine.hpp @@ -147,20 +147,20 @@ class QuarantineEscapeAction DistDir closest; if (directions_.at(Direction::N) && (i - n) * north_south_resolution_ < mindist) { - mindist = static_cast(std::floor((i - n) * north_south_resolution_)); + mindist = std::lround((i - n) * north_south_resolution_); closest = std::make_tuple(mindist, Direction::N); } if (directions_.at(Direction::S) && (s - i) * north_south_resolution_ < mindist) { - mindist = static_cast(std::floor((s - i) * north_south_resolution_)); + mindist = std::lround((s - i) * north_south_resolution_); closest = std::make_tuple(mindist, Direction::S); } if (directions_.at(Direction::E) && (e - j) * west_east_resolution_ < mindist) { - mindist = static_cast(std::floor((e - j) * west_east_resolution_)); + mindist = std::lround((e - j) * west_east_resolution_); closest = std::make_tuple(mindist, Direction::E); } if (directions_.at(Direction::W) && (j - w) * west_east_resolution_ < mindist) { - mindist = static_cast(std::floor((j - w) * west_east_resolution_)); + mindist = std::lround((j - w) * west_east_resolution_); closest = std::make_tuple(mindist, Direction::W); } return closest;