Skip to content

Commit

Permalink
floating point values for priority style param (#2011)
Browse files Browse the repository at this point in the history
* floating point values for priority style param

- floating point values for priority will be used soon once
tilezen/vector-datasource#988 lands in
tilzen tiles

* Add dummy floats for priority to test

- TODO: replace with collision data function when tilezen tiles support
this
  • Loading branch information
tallytalwar authored Jan 23, 2019
1 parent e4ebb42 commit 5b2f67c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion core/src/scene/styleContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(number);
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions core/src/scene/styleParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(result);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -493,6 +491,8 @@ std::string StyleParam::toString() const {
case StyleParamKey::outline_join:
if (!value.is<uint32_t>()) break;
return k + std::to_string(value.get<uint32_t>());
case StyleParamKey::priority:
case StyleParamKey::text_priority:
case StyleParamKey::miter_limit:
case StyleParamKey::angle:
case StyleParamKey::outline_miter_limit:
Expand Down
4 changes: 2 additions & 2 deletions core/src/style/pointStyleBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions core/src/style/textStyleBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,15 @@ 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;
glm::vec2 defaultBuffer = glm::vec2(p.fontSize * 0.25f);

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)) {
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions scenes/scene.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ layers:
texture: pois
sprite: shield
# sprite: function() { return feature.network }
priority: 2
priority: 2.5
color: white
size: 24px
placement: midpoint
Expand Down Expand Up @@ -368,7 +368,7 @@ layers:
text:
repeat_distance: 200px
repeat_group: road_labels
priority: 2
priority: 2.5
font:
stroke: { color: white, width: 4 }
transform: capitalize
Expand Down Expand Up @@ -480,7 +480,7 @@ layers:
draw:
points:
sprite: tree
priority: 2
priority: 2.5
size: 16px
text:
font:
Expand All @@ -499,7 +499,7 @@ layers:
points:
visible: false
text:
priority: 2
priority: 2.5
font:
size: 9pt
style: italic
Expand Down Expand Up @@ -555,7 +555,7 @@ layers:
draw: { points: { sprite: museum } }
station:
filter: { kind: [station] }
draw: { points: { sprite: train, priority: 2 } }
draw: { points: { sprite: train, priority: 2.5 } }
hospital:
filter: { kind: [hospital, pharmacy] }
draw: { points: { sprite: hospital } }
Expand Down

0 comments on commit 5b2f67c

Please sign in to comment.