-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More layer matching control with priority and exclusive #2036
Comments
Now that I'm implementing this for Tangram ES, I've found a potentially unintuitive loophole of sorts. Let's say we have some layers like this: layers:
layer_a:
layer_aa:
priority: 2
draw:
group_0:
color: red
layer_b:
layer_bb:
priority: 1
draw:
group_0:
color: blue A feature will match both We've recognized this problem before and decided to disambiguate cases like this using the lexical order of the layer's fully-qualified name. In this case, that would mean that @bcamper Does this track with your understanding of the feature? And does Tangram JS do the same disambiguation for layers at the same depth that aren't siblings? |
@matteblair thanks, it mostly does :) However, in this case, what I would expect and observe in Tangram JS is that the draw parameters from This is also referred to in the original PR quoted above:
I agree about the potential confusion in cases such as this. For this initial round, the syntax was enforced amongst a single group of sub-layers. I'm totally open to revising the logic (since AFAIK this feature is still pretty nascent in terms of actual use) if you have other suggestions? I guess it would be possible to apply the |
Oook, getting back to this now. I was kind of muddling a few statements together in the previous post.
Now I've got a good handle on this feature. The PR to add this should be up very soon. |
Tangram ES sister issue to PR #705.
What @bcamper said over there:
This PR introduces two new keywords --
priority
andexclusive
-- for scenelayers
, to enable greater control over feature filter matching and styling composition.Background
Tangram layer matching has always been inclusive, meaning a feature can match multiple layers (at multiple levels of the layer style tree), which are then merged to determine the final rendering parameters. Composing complex sub-layer trees can be used to capture both feature and zoom-dependent styling along orthogonal dimensions, for example varying road line widths and colors by separate criteria.
However, two in many ways simpler behaviors have not been easily expressed with the current layer syntax:
New Syntax
The
priority
andexclusive
keywords address these cases, and can be used both separately and together.priority
: allows for the explicit definition of the matching order for sibling layers (alphabetical by layer name is still used as the default / fallback).exclusive
: marking a layer asexclusive
ensures that when that layer matches, no other sibling layers (and their cascading sub-layers, etc.) will; when multipleexclusive
layers match, the higher priority layer wins.For example,
exclusive
could express a singleif-else
filter condition:When used together,
priority
andexclusive
can be used for chainedif-elseif-else
filter cases, to ensure that only one of an ordered set of conditions matches:Separate from "flow control" cases,
priority
can simply be used on its own to disambiguate the precedence of multiple layers without reliance on naming conventions.Implementation
The implementation is a fairly narrow impact on the layer matching logic:
When determining layer matching and merging order:
priority
value are matched first, with values sorted from lowest to highest (e.g.priority: 1
is matched beforepriority: 2
).priority
are matched after, and continue to be sorted lexically.Matching operation:
exclusive
matches, all further matching at that level in the layer tree ceases and the matching layer is used (matching continues for thatexclusive
layer's child/descendant layers).exclusive
, the first one (according to the order described above) is used.The text was updated successfully, but these errors were encountered: