From a53fbf2ca3a677111b2b80670ac28f91d33ddb05 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 1 Aug 2007 10:57:27 +0000 Subject: [PATCH] applied patch that makes sure names of vertical roads are rendered in a consistent direction (from Cameron Patrick) --- src/placement_finder.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index ddd4d5116..13e1f4ab6 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -227,7 +227,7 @@ namespace mapnik double middle; //try draw text centered if (p->label_placement == line_placement) middle = (distance / 2.0) - (string_width/2.0); - else if (p->label_placement == point_placement) + else // (p->label_placement == point_placement) middle = distance / 2.0; if (num_labels % 2) //odd amount of labels @@ -370,7 +370,7 @@ namespace mapnik // angle text starts at and orientation angle = atan2(-dy, dx); - orientation = fabs(angle) > M_PI/2 ? -1 : 1; + orientation = (angle > 0.55*M_PI || angle < -0.45*M_PI) ? -1 : 1; distance -= target_distance; @@ -448,12 +448,12 @@ namespace mapnik if (displacement == 0.0) { x -= (((double)string_height/2.0) - 1.0)*cos(render_angle+M_PI/2); y += (((double)string_height/2.0) - 1.0)*sin(render_angle+M_PI/2); - } else if (displacement > 0.0) { - x -= ((displacement + (double)string_height) - 1.0)*cos(render_angle+M_PI/2); - y += ((displacement + (double)string_height) - 1.0)*sin(render_angle+M_PI/2); + } else if (displacement*orientation > 0.0) { + x -= ((fabs(displacement) - (double)string_height) + 1.0)*cos(render_angle+M_PI/2); + y += ((fabs(displacement) - (double)string_height) + 1.0)*sin(render_angle+M_PI/2); } else { // displacement < 0 - x -= ((displacement - (double)string_height) - 1.0)*cos(render_angle+M_PI/2); - y += ((displacement - (double)string_height) - 1.0)*sin(render_angle+M_PI/2); + x -= ((fabs(displacement) + (double)string_height) - 1.0)*cos(render_angle+M_PI/2); + y += ((fabs(displacement) + (double)string_height) - 1.0)*sin(render_angle+M_PI/2); } distance -= ci.width; next_char_x = ci.width*cos(render_angle);