From 7459bbce5d15b9e141fa4ed1f72b4b29c14b1a9e Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Tue, 19 Aug 2025 19:58:27 +0200 Subject: [PATCH 1/2] Remove out-of-date comment --- src/expire-tiles.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/expire-tiles.cpp b/src/expire-tiles.cpp index 1cd584f25..098d8e710 100644 --- a/src/expire-tiles.cpp +++ b/src/expire-tiles.cpp @@ -7,14 +7,6 @@ * For a full list of authors see the git log. */ -/* - * Dirty tile list generation - * - * Please refer to the OpenPisteMap expire_tiles.py script for a demonstration - * of how to make use of the output: - * http://subversion.nexusuk.org/projects/openpistemap/trunk/scripts/expire_tiles.py - */ - #include #include #include From 9da8045aa4933f16b66dcd7793997b6bd92c878c Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Tue, 8 Jul 2025 21:37:19 +0200 Subject: [PATCH 2/2] Fix various clang-tidy issues with the expire code * Don't use var of type double as loop variable clang-analyzer-security.FloatLoopCounter * Use const where possible * Explicit conversion --- src/expire-tiles.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/expire-tiles.cpp b/src/expire-tiles.cpp index 098d8e710..2730b1d2c 100644 --- a/src/expire-tiles.cpp +++ b/src/expire-tiles.cpp @@ -173,16 +173,14 @@ void expire_tiles::from_line_segment(geom::point_t const &a, double const x_step = x_len / hyp_len; double const y_step = y_len / hyp_len; - for (double step = 0; step <= hyp_len; step += 0.4) { - /* Interpolate points 1 tile width apart */ - double next_step = step + 0.4; - if (next_step > hyp_len) { - next_step = hyp_len; - } - double x1 = tilec_a.x() + ((double)step * x_step); - double y1 = tilec_a.y() + ((double)step * y_step); - double x2 = tilec_a.x() + ((double)next_step * x_step); - double y2 = tilec_a.y() + ((double)next_step * y_step); + for (int i = 0; i <= hyp_len / 0.4; ++i) { + double const step = i * 0.4; + double const next_step = std::min(hyp_len, (i + 1) * 0.4); + + double const x1 = tilec_a.x() + (step * x_step); + double y1 = tilec_a.y() + (step * y_step); + double const x2 = tilec_a.x() + (next_step * x_step); + double y2 = tilec_a.y() + (next_step * y_step); /* The line (x1,y1),(x2,y2) is up to 1 tile width long x1 will always be <= x2 @@ -192,11 +190,11 @@ void expire_tiles::from_line_segment(geom::point_t const &a, if (y1 > y2) { std::swap(y1, y2); } - for (int x = x1 - expire_config.buffer; x <= x2 + expire_config.buffer; - ++x) { + for (int x = static_cast(x1 - expire_config.buffer); + x <= static_cast(x2 + expire_config.buffer); ++x) { uint32_t const norm_x = normalise_tile_x_coord(x); - for (int y = y1 - expire_config.buffer; - y <= y2 + expire_config.buffer; ++y) { + for (int y = static_cast(y1 - expire_config.buffer); + y <= static_cast(y2 + expire_config.buffer); ++y) { if (y >= 0) { expire_tile(norm_x, static_cast(y)); }