From ed0488d2e0e2166f5e2708abc34abe471b39c4ba Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 20 Jan 2016 16:00:37 -0800 Subject: [core] improve text-max-angle check Instead of using the absolute value of the sum of angles, use the sum of the absolute values of angles. This helps avoid labels on lines with sharp zig zags. for example, the "Central Campus Mall" label in issue #2998 --- src/mbgl/text/check_max_angle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mbgl/text/check_max_angle.cpp b/src/mbgl/text/check_max_angle.cpp index 6e94c2ec17..bb32e4235e 100644 --- a/src/mbgl/text/check_max_angle.cpp +++ b/src/mbgl/text/check_max_angle.cpp @@ -51,7 +51,7 @@ bool checkMaxAngle(const std::vector &line, Anchor &anchor, const fl float angleDelta = util::angle_to(prev, current) - util::angle_to(current, next); // restrict angle to -pi..pi range - angleDelta = std::fmod(angleDelta + 3 * M_PI, M_PI * 2) - M_PI; + angleDelta = std::fabs(std::fmod(angleDelta + 3 * M_PI, M_PI * 2) - M_PI); recentCorners.emplace(anchorDistance, angleDelta); recentAngleDelta += angleDelta; @@ -63,7 +63,7 @@ bool checkMaxAngle(const std::vector &line, Anchor &anchor, const fl } // the sum of angles within the window area exceeds the maximum allowed value. check fails. - if (std::fabs(recentAngleDelta) > maxAngle) return false; + if (recentAngleDelta > maxAngle) return false; index++; anchorDistance += util::dist(current, next); -- cgit v1.2.1