From b6529ba5ba29e6fe1704c08a58978e088278b2cc Mon Sep 17 00:00:00 2001 From: Varun Talwar Date: Fri, 18 Jan 2019 17:27:16 -0800 Subject: [PATCH] floating point values for priority style param - floating point values for priority will be used soon once https://github.com/tilezen/vector-datasource/issues/988 lands in tilzen tiles --- core/src/scene/styleContext.cpp | 3 ++- core/src/scene/styleParam.cpp | 10 +++++----- core/src/style/pointStyleBuilder.cpp | 4 ++-- core/src/style/textStyleBuilder.cpp | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/src/scene/styleContext.cpp b/core/src/scene/styleContext.cpp index 3b1f57bf61..1b469acc3f 100644 --- a/core/src/scene/styleContext.cpp +++ b/core/src/scene/styleContext.cpp @@ -313,6 +313,8 @@ bool StyleContext::evalStyle(FunctionID _id, StyleParamKey _key, StyleParam::Val break; } case StyleParamKey::angle: + case StyleParamKey::priority: + case StyleParamKey::text_priority: case StyleParamKey::text_font_stroke_width: case StyleParamKey::placement_min_length_ratio: { _val = static_cast(number); @@ -326,7 +328,6 @@ bool StyleContext::evalStyle(FunctionID _id, StyleParamKey _key, StyleParam::Val } case StyleParamKey::order: case StyleParamKey::outline_order: - case StyleParamKey::priority: case StyleParamKey::color: case StyleParamKey::outline_color: case StyleParamKey::text_font_fill: diff --git a/core/src/scene/styleParam.cpp b/core/src/scene/styleParam.cpp index 44e10244dc..db8c557606 100644 --- a/core/src/scene/styleParam.cpp +++ b/core/src/scene/styleParam.cpp @@ -285,9 +285,7 @@ StyleParam::Value StyleParam::parseNode(StyleParamKey key, const YAML::Node& nod break; case StyleParamKey::order: case StyleParamKey::outline_order: - case StyleParamKey::priority: - case StyleParamKey::text_max_lines: - case StyleParamKey::text_priority: { + case StyleParamKey::text_max_lines: { int result = -1; if (YamlUtil::getInt(node, result)) { return static_cast(result); @@ -350,6 +348,8 @@ StyleParam::Value StyleParam::parseNode(StyleParamKey key, const YAML::Node& nod LOGW("Invalid angle value: %s", Dump(node).c_str()); break; } + case StyleParamKey::priority: + case StyleParamKey::text_priority: case StyleParamKey::miter_limit: case StyleParamKey::outline_miter_limit: case StyleParamKey::placement_min_length_ratio: @@ -477,9 +477,7 @@ std::string StyleParam::toString() const { case StyleParamKey::order: case StyleParamKey::text_order: case StyleParamKey::outline_order: - case StyleParamKey::priority: case StyleParamKey::text_max_lines: - case StyleParamKey::text_priority: case StyleParamKey::color: case StyleParamKey::outline_color: case StyleParamKey::outline_style: @@ -493,6 +491,8 @@ std::string StyleParam::toString() const { case StyleParamKey::outline_join: if (!value.is()) break; return k + std::to_string(value.get()); + case StyleParamKey::priority: + case StyleParamKey::text_priority: case StyleParamKey::miter_limit: case StyleParamKey::angle: case StyleParamKey::outline_miter_limit: diff --git a/core/src/style/pointStyleBuilder.cpp b/core/src/style/pointStyleBuilder.cpp index e0ae5c767d..417a1db421 100644 --- a/core/src/style/pointStyleBuilder.cpp +++ b/core/src/style/pointStyleBuilder.cpp @@ -131,12 +131,12 @@ auto PointStyleBuilder::applyRule(const DrawRule& _rule) const -> Parameters { _rule.get(StyleParamKey::offset, p.labelOptions.offset); _rule.get(StyleParamKey::buffer, p.labelOptions.buffer); - uint32_t priority = 0; + float priority = 0; std::string repeatGroup; StyleParam::Width repeatDistance; if (_rule.get(StyleParamKey::priority, priority)) { - p.labelOptions.priority = (float)priority; + p.labelOptions.priority = priority; } _rule.get(StyleParamKey::sprite_default, p.spriteDefault); diff --git a/core/src/style/textStyleBuilder.cpp b/core/src/style/textStyleBuilder.cpp index ef9c7ddb95..ede2e8d819 100644 --- a/core/src/style/textStyleBuilder.cpp +++ b/core/src/style/textStyleBuilder.cpp @@ -618,7 +618,7 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule, _rule.get(StyleParamKey::text_max_lines, p.maxLines); - uint32_t priority = 0; + float priority = 0; size_t repeatGroupHash = 0; std::string repeatGroup; StyleParam::Width repeatDistance; @@ -626,7 +626,7 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule, if (_iconText) { if (_rule.get(StyleParamKey::text_priority, priority)) { - p.labelOptions.priority = (float)priority; + p.labelOptions.priority = priority; } _rule.get(StyleParamKey::text_collide, p.labelOptions.collide); if (!_rule.get(StyleParamKey::text_interactive, p.interactive)) { @@ -668,7 +668,7 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule, } } else { if (_rule.get(StyleParamKey::priority, priority)) { - p.labelOptions.priority = (float)priority; + p.labelOptions.priority = priority; } _rule.get(StyleParamKey::collide, p.labelOptions.collide); _rule.get(StyleParamKey::interactive, p.interactive);