From 10deff9d5dfe220db0e12d483d3c5137fb8feb95 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Sun, 8 Jan 2017 09:04:12 +0000 Subject: [PATCH 1/2] remove unnecessary breaks --- src/text/text_layout.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/text/text_layout.cpp b/src/text/text_layout.cpp index 837ba0f45..34f77af39 100644 --- a/src/text/text_layout.cpp +++ b/src/text/text_layout.cpp @@ -63,31 +63,22 @@ pixel_position evaluate_displacement(double dx, double dy, directions_e dir) { case EXACT_POSITION: return pixel_position(dx,dy); - break; case NORTH: return pixel_position(0,-std::abs(dy)); - break; case EAST: return pixel_position(std::abs(dx),0); - break; case SOUTH: return pixel_position(0,std::abs(dy)); - break; case WEST: return pixel_position(-std::abs(dx),0); - break; case NORTHEAST: return pixel_position(std::abs(dx),-std::abs(dy)); - break; case SOUTHEAST: return pixel_position(std::abs(dx),std::abs(dy)); - break; case NORTHWEST: return pixel_position(-std::abs(dx),-std::abs(dy)); - break; case SOUTHWEST: return pixel_position(-std::abs(dx),std::abs(dy)); - break; default: return pixel_position(dx,dy); } From 4eae86b7bc750a08a7ab103a780d6b4bf951e1b1 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Sun, 8 Jan 2017 09:05:44 +0000 Subject: [PATCH 2/2] text simple placement: add center 'C' placement --- include/mapnik/text/text_properties.hpp | 3 ++- src/text/placements/simple.cpp | 1 + src/text/text_layout.cpp | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/mapnik/text/text_properties.hpp b/include/mapnik/text/text_properties.hpp index cd63ae93a..677cd3230 100644 --- a/include/mapnik/text/text_properties.hpp +++ b/include/mapnik/text/text_properties.hpp @@ -96,7 +96,8 @@ enum directions_e : std::uint8_t SOUTHEAST, NORTHWEST, SOUTHWEST, - EXACT_POSITION + EXACT_POSITION, + CENTER }; using fontset_map = std::map; diff --git a/src/text/placements/simple.cpp b/src/text/placements/simple.cpp index 1edb0c19b..24b3af621 100644 --- a/src/text/placements/simple.cpp +++ b/src/text/placements/simple.cpp @@ -57,6 +57,7 @@ struct direction_name : x3::symbols ("NW", NORTHWEST) ("SW", SOUTHWEST) ("X" , EXACT_POSITION) + ("C" , CENTER) ; } } names; diff --git a/src/text/text_layout.cpp b/src/text/text_layout.cpp index 34f77af39..9de48d44f 100644 --- a/src/text/text_layout.cpp +++ b/src/text/text_layout.cpp @@ -79,6 +79,8 @@ pixel_position evaluate_displacement(double dx, double dy, directions_e dir) return pixel_position(-std::abs(dx),-std::abs(dy)); case SOUTHWEST: return pixel_position(-std::abs(dx),std::abs(dy)); + case CENTER: + return pixel_position(0, 0); default: return pixel_position(dx,dy); }