77 * For a full list of authors see the git log.
88 */
99
10- /*
11- * Dirty tile list generation
12- *
13- * Please refer to the OpenPisteMap expire_tiles.py script for a demonstration
14- * of how to make use of the output:
15- * http://subversion.nexusuk.org/projects/openpistemap/trunk/scripts/expire_tiles.py
16- */
17-
1810#include < algorithm>
1911#include < cerrno>
2012#include < cmath>
@@ -182,16 +174,14 @@ void expire_tiles::from_line_segment(geom::point_t const &a,
182174 double const x_step = x_len / hyp_len;
183175 double const y_step = y_len / hyp_len;
184176
185- for (double step = 0 ; step <= hyp_len; step += 0.4 ) {
186- /* Interpolate points 1 tile width apart */
187- double next_step = step + 0.4 ;
188- if (next_step > hyp_len) {
189- next_step = hyp_len;
190- }
191- double x1 = tilec_a.x () + ((double )step * x_step);
192- double y1 = tilec_a.y () + ((double )step * y_step);
193- double x2 = tilec_a.x () + ((double )next_step * x_step);
194- double y2 = tilec_a.y () + ((double )next_step * y_step);
177+ for (int i = 0 ; i <= hyp_len / 0.4 ; ++i) {
178+ double const step = i * 0.4 ;
179+ double const next_step = std::min (hyp_len, (i + 1 ) * 0.4 );
180+
181+ double const x1 = tilec_a.x () + (step * x_step);
182+ double y1 = tilec_a.y () + (step * y_step);
183+ double const x2 = tilec_a.x () + (next_step * x_step);
184+ double y2 = tilec_a.y () + (next_step * y_step);
195185
196186 /* The line (x1,y1),(x2,y2) is up to 1 tile width long
197187 x1 will always be <= x2
@@ -201,11 +191,11 @@ void expire_tiles::from_line_segment(geom::point_t const &a,
201191 if (y1 > y2) {
202192 std::swap (y1, y2);
203193 }
204- for (int x = x1 - expire_config.buffer ; x <= x2 + expire_config. buffer ;
205- ++x) {
194+ for (int x = static_cast < int >( x1 - expire_config.buffer ) ;
195+ x <= static_cast < int >(x2 + expire_config. buffer ); ++x) {
206196 uint32_t const norm_x = normalise_tile_x_coord (x);
207- for (int y = y1 - expire_config.buffer ;
208- y <= y2 + expire_config.buffer ; ++y) {
197+ for (int y = static_cast < int >( y1 - expire_config.buffer ) ;
198+ y <= static_cast < int >( y2 + expire_config.buffer ) ; ++y) {
209199 if (y >= 0 ) {
210200 expire_tile (norm_x, static_cast <uint32_t >(y));
211201 }
0 commit comments