From 4791bac6753e16ef910a47c514e48b355e20295f Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Fri, 16 Jan 2015 16:29:58 -0500 Subject: [PATCH] scale dashes by line-gap-width if present https://github.com/mapbox/mapbox-gl-js/pull/860#issuecomment-68788411 js: a5fb9f9fb5c7ea056b6ec228e0b398815cc0d356 --- src/mbgl/style/style_layer.cpp | 12 ++++++++++-- src/mbgl/style/style_properties.hpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp index 54dfff300..8f580715d 100644 --- a/src/mbgl/style/style_layer.cpp +++ b/src/mbgl/style/style_layer.cpp @@ -188,8 +188,16 @@ void StyleLayer::applyStyleProperties(const float z, const times applyStyleProperty(PropertyKey::LineDashArray, line.dash_array, z, now); applyStyleProperty(PropertyKey::LineImage, line.image, z, now); - // for scaling dasharrays - applyStyleProperty(PropertyKey::LineWidth, line.dash_line_width, std::floor(z), now + 10000); + // scale dash width by line-gap-width if present + applyStyleProperty(PropertyKey::LineGapWidth, line.dash_line_width, std::floor(z), now + 10000); + if (line.dash_line_width <= 0) { + // otherwise scale by line-width + applyStyleProperty(PropertyKey::LineWidth, line.dash_line_width, std::floor(z), now + 10000); + if (line.dash_line_width <= 0) { + // otherwise scale by default line-width value + line.dash_line_width = line.width; + } + } } template <> diff --git a/src/mbgl/style/style_properties.hpp b/src/mbgl/style/style_properties.hpp index c5149b2d1..fe6a2c250 100644 --- a/src/mbgl/style/style_properties.hpp +++ b/src/mbgl/style/style_properties.hpp @@ -38,7 +38,7 @@ struct LineProperties { float gap_width = 0; float blur = 0; std::vector dash_array; - float dash_line_width = 1; + float dash_line_width = 0; std::string image; inline bool isVisible() const {