diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/geometry/resample.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/geometry/resample.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/symbol_bucket.cpp | 10 |
3 files changed, 8 insertions, 12 deletions
diff --git a/src/mbgl/geometry/resample.cpp b/src/mbgl/geometry/resample.cpp index 2fd4a8fd88..ed086fefd4 100644 --- a/src/mbgl/geometry/resample.cpp +++ b/src/mbgl/geometry/resample.cpp @@ -17,17 +17,17 @@ 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, - int offset) { + float offset) { maxScale = std::round(std::fmax(std::fmin(8.0f, maxScale / 2.0f), 1.0f)); spacing *= tilePixelRatio / maxScale; - offset *= tilePixelRatio / maxScale; + offset *= tilePixelRatio; 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 = spacing - offset;; - float markedDistance = 0.0f; + float distance = 0.0f; + float markedDistance = offset != 0.0f ? offset - spacing : offset; int added = 0; Anchors points; diff --git a/src/mbgl/geometry/resample.hpp b/src/mbgl/geometry/resample.hpp index febb6360d5..ce7eba2f1b 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 offset); + float minScale, float maxScale, float tilePixelRatio, float offset); } #endif diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 9d9636b399..44cc3816a3 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -238,8 +238,7 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping Anchors anchors; if (properties.placement == PlacementType::Line) { - float textResampleOffset = 0; - float iconResampleOffset = 0; + float resampleOffset = 0; if (shaping.size()) { float minX = std::numeric_limits<float>::infinity(); @@ -249,15 +248,12 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping maxX = std::max(maxX, glyph.x); } const float labelLength = maxX - minX; - textResampleOffset = (labelLength / 2.0 + glyphSize) * fontScale; - } - if (image) { - iconResampleOffset = image.w; + resampleOffset = (labelLength / 2.0 + glyphSize * 2.0) * fontScale; } // Line labels anchors = resample(line, properties.min_distance, minScale, collision.maxPlacementScale, - collision.tilePixelRatio, std::max(iconResampleOffset, textResampleOffset)); + collision.tilePixelRatio, resampleOffset); // Sort anchors by segment so that we can start placement with the // anchors that can be shown at the lowest zoom levels. |