summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2016-01-20 16:00:37 -0800
committerAnsis Brammanis <brammanis@gmail.com>2016-01-20 16:58:24 -0800
commited0488d2e0e2166f5e2708abc34abe471b39c4ba (patch)
tree97c5b68d069177b9033a8d0ed018f68897ee9f28 /src
parent0fda834397b5d937fb5843143ae8df8b27dd8954 (diff)
downloadqtlocation-mapboxgl-ed0488d2e0e2166f5e2708abc34abe471b39c4ba.tar.gz
[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
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/text/check_max_angle.cpp4
1 files changed, 2 insertions, 2 deletions
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<Coordinate> &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<Coordinate> &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<float>(current, next);