summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2015-02-10 12:52:53 -0800
committerAnsis Brammanis <brammanis@gmail.com>2015-02-10 15:21:18 -0800
commit8e459c2a73e7dcdb4cf660cfe61d5c945d7a2513 (patch)
tree0f0d699078fbccb17afc49dc0007891fbb402bd1 /src/mbgl/geometry
parentfdcd1b888bf81a2421992b1a01c16606c858f55f (diff)
downloadqtlocation-mapboxgl-8e459c2a73e7dcdb4cf660cfe61d5c945d7a2513.tar.gz
improve line label density
Place the first label as close to the beginning of the line as possible. js: 316ed0bd9bff8cd430ad81d0b6397f396fbce124
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r--src/mbgl/geometry/resample.cpp7
-rw-r--r--src/mbgl/geometry/resample.hpp2
2 files changed, 5 insertions, 4 deletions
diff --git a/src/mbgl/geometry/resample.cpp b/src/mbgl/geometry/resample.cpp
index abb3ef1e3c..2fd4a8fd88 100644
--- a/src/mbgl/geometry/resample.cpp
+++ b/src/mbgl/geometry/resample.cpp
@@ -17,17 +17,18 @@ const std::array<std::vector<float>, 4> minScaleArrays = {{
Anchors resample(const std::vector<Coordinate> &vertices, float spacing,
const float /*minScale*/, float maxScale, const float tilePixelRatio,
- const int start) {
+ int offset) {
maxScale = std::round(std::fmax(std::fmin(8.0f, maxScale / 2.0f), 1.0f));
spacing *= tilePixelRatio / maxScale;
+ offset *= tilePixelRatio / maxScale;
const size_t index = util::clamp<size_t>(std::floor(std::log(maxScale) / std::log(2)), 0, minScaleArrays.size() - 1);
const std::vector<float> &minScales = minScaleArrays[index];
const size_t len = minScales.size();
- float distance = 0.0f;
+ float distance = spacing - offset;;
float markedDistance = 0.0f;
- int added = start;
+ int added = 0;
Anchors points;
diff --git a/src/mbgl/geometry/resample.hpp b/src/mbgl/geometry/resample.hpp
index bcfe4ca53d..febb6360d5 100644
--- a/src/mbgl/geometry/resample.hpp
+++ b/src/mbgl/geometry/resample.hpp
@@ -7,7 +7,7 @@
namespace mbgl {
Anchors resample(const std::vector<Coordinate> &vertices, float spacing,
- float minScale, float maxScale, float tilePixelRatio, int start = 0);
+ float minScale, float maxScale, float tilePixelRatio, int offset);
}
#endif