From 038159385b26a9a1e31e6435a3eac3c2cf6a938a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 17 Jan 2013 12:45:10 -0800 Subject: [PATCH] minor syntax cleanups to markers placement - no functional change --- include/mapnik/markers_placement.hpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index 803b23578..dd5019629 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -74,12 +74,12 @@ public: allow_overlap_(allow_overlap), marker_width_((size_ * tr_).width()), done_(false), - last_x(.0), - last_y(.0), - next_x(.0), - next_y(.0), - error_(.0), - spacing_left_(.0), + last_x(0.0), + last_y(0.0), + next_x(0.0), + next_y(0.0), + error_(0.0), + spacing_left_(0.0), marker_nr_(0) { if (spacing >= 0) @@ -104,7 +104,7 @@ public: done_ = agg::is_stop(locator_.vertex(&next_x, &next_y)); last_x = next_x; last_y = next_y; // Force request of new segment - error_ = 0; + error_ = 0.0; marker_nr_ = 0; } @@ -133,9 +133,10 @@ public: error = 0: Perfect position. error < 0: Marker too near to the beginning of the path. */ - if (marker_nr_++ == 0) + if (marker_nr_ == 0) { //First marker + marker_nr_++; spacing_left_ = spacing_ / 2; } else @@ -143,7 +144,8 @@ public: spacing_left_ = spacing_; } spacing_left_ -= error_; - error_ = 0; + error_ = 0.0; + double max_err_allowed = max_error_ * spacing_; //Loop exits when a position is found or when no more segments are available while (true) { @@ -153,15 +155,15 @@ public: set_spacing_left(marker_width_/2); //Only moves forward } //Error for this marker is too large. Skip to the next position. - if (abs(error_) > max_error_ * spacing_) + if (abs(error_) > max_err_allowed) { if (error_ > spacing_) { - error_ = 0; //Avoid moving backwards - MAPNIK_LOG_WARN(markers_placement) << "Extremely large error in markers_placement. Please file a bug report."; + MAPNIK_LOG_WARN(markers_placement) << "Extremely large error (" << error_ << ") in markers_placement. Please file a bug report."; + error_ = 0.0; //Avoid moving backwards } spacing_left_ += spacing_ - error_; - error_ = 0; + error_ = 0.0; } double dx = next_x - last_x; double dy = next_y - last_y;