-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] Advanced label formatting using ["text-section"] expression #13904
Conversation
@asheemmamoowala @ryanhamley I'm trying to implement something similar in gl-js, to see if proposed solution is acceptable. Could you please comment if you see any problems with proposed solution? |
6e9f7f2
to
324ba40
Compare
New expression evaluates to formatted section id (string | number) that can be used within decision expressions, such as 'match' or 'case', so that each formatted section can have different paint properties.
324ba40
to
d02e1d1
Compare
d02e1d1
to
b1fcbd5
Compare
Benchmark result for rendering single frame (Manhattan, streets v7, zoom level 15). Formatted labels style has single formatted section and
|
class PropertyExpression final : public PropertyExpressionBase { | ||
public: | ||
// Second parameter to be used only for conversions from legacy functions. | ||
PropertyExpression(std::unique_ptr<expression::Expression> expression_, optional<T> defaultValue_ = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: = nullopt
const expression::EvaluationResult result = expression->evaluate(expression::EvaluationContext({zoom}, &feature)); | ||
T evaluate(const expression::EvaluationContext& context, T finalDefaultValue = T()) const { | ||
assert(canEvaluateWith(context)); | ||
const expression::EvaluationResult result = expression->evaluate(context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: const expression::EvaluationResult&
src/mbgl/layout/symbol_layout.cpp
Outdated
return (*options.id).match( | ||
[] (double t) -> expression::Value { return t; }, | ||
[] (const std::string& t) -> expression::Value { return t; }, | ||
[] (auto&) -> expression::Value { return {}; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we assert here?
src/mbgl/layout/symbol_layout.cpp
Outdated
} | ||
|
||
if (symbolInstance.writingModes & WritingModeType::Vertical) { | ||
const Range<float> sizeData = bucket->textSizeBinder->getVertexSizeData(feature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: const Range& sizeData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
Closing this, rewritten PR can be found here: #14062 |
This PR introduces
["text-section"]
expression that is evaluated to section id when symbol layer is laid out. It allows to use decision expressions to define section specific paint properties, for example:Symbol formatting using multiple sections. Section id assigned to each character.
TODO
Launch Checklist
Fixes: #13813
/cc @asheemmamoowala @ryanhamley