summaryrefslogtreecommitdiff
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
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
-rw-r--r--package.json2
-rw-r--r--src/mbgl/text/check_max_angle.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/package.json b/package.json
index 0e5a024c0a..4a5492ae6b 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,7 @@
],
"devDependencies": {
"aws-sdk": "^2.2.21",
- "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#bc0272cdde41d027a5df1ca8fb3aa1bc49aa8149",
+ "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#2f4d8ed044a3c962a43d62de0608b752eb68052c",
"node-gyp": "^3.2.1",
"request": "^2.67.0",
"tape": "^4.2.2"
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);