minor syntax cleanups to markers placement - no functional change

This commit is contained in:
Dane Springmeyer 2013-01-17 12:45:10 -08:00
parent eb8b2552ef
commit 038159385b

View file

@ -74,12 +74,12 @@ public:
allow_overlap_(allow_overlap), allow_overlap_(allow_overlap),
marker_width_((size_ * tr_).width()), marker_width_((size_ * tr_).width()),
done_(false), done_(false),
last_x(.0), last_x(0.0),
last_y(.0), last_y(0.0),
next_x(.0), next_x(0.0),
next_y(.0), next_y(0.0),
error_(.0), error_(0.0),
spacing_left_(.0), spacing_left_(0.0),
marker_nr_(0) marker_nr_(0)
{ {
if (spacing >= 0) if (spacing >= 0)
@ -104,7 +104,7 @@ public:
done_ = agg::is_stop(locator_.vertex(&next_x, &next_y)); done_ = agg::is_stop(locator_.vertex(&next_x, &next_y));
last_x = next_x; last_x = next_x;
last_y = next_y; // Force request of new segment last_y = next_y; // Force request of new segment
error_ = 0; error_ = 0.0;
marker_nr_ = 0; marker_nr_ = 0;
} }
@ -133,9 +133,10 @@ public:
error = 0: Perfect position. error = 0: Perfect position.
error < 0: Marker too near to the beginning of the path. error < 0: Marker too near to the beginning of the path.
*/ */
if (marker_nr_++ == 0) if (marker_nr_ == 0)
{ {
//First marker //First marker
marker_nr_++;
spacing_left_ = spacing_ / 2; spacing_left_ = spacing_ / 2;
} }
else else
@ -143,7 +144,8 @@ public:
spacing_left_ = spacing_; spacing_left_ = spacing_;
} }
spacing_left_ -= error_; 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 //Loop exits when a position is found or when no more segments are available
while (true) while (true)
{ {
@ -153,15 +155,15 @@ public:
set_spacing_left(marker_width_/2); //Only moves forward set_spacing_left(marker_width_/2); //Only moves forward
} }
//Error for this marker is too large. Skip to the next position. //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_) if (error_ > spacing_)
{ {
error_ = 0; //Avoid moving backwards MAPNIK_LOG_WARN(markers_placement) << "Extremely large error (" << error_ << ") in markers_placement. Please file a bug report.";
MAPNIK_LOG_WARN(markers_placement) << "Extremely large error in markers_placement. Please file a bug report."; error_ = 0.0; //Avoid moving backwards
} }
spacing_left_ += spacing_ - error_; spacing_left_ += spacing_ - error_;
error_ = 0; error_ = 0.0;
} }
double dx = next_x - last_x; double dx = next_x - last_x;
double dy = next_y - last_y; double dy = next_y - last_y;