You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's the goal of structure config? Set rendering order for buckets, rendering some of the buckets several times (e.g. road casings and roads). Considering this, we can simplify the config dramatically by making it an array of bucket names with occasional custom postfixes thrown in for referencing by class styles. The same sample:
This change will make fiddling with z-oder and adding new layers a lot easier. If we introduce bucket groups as discussed in #276, we can ditch groups in structure config and leave it to bucket config.
The purpose of structure is to define the order the buckets are drawn in, and the class applied to a bucket. E.g. you can use the same bucket multiple times (as with the road layers) and draw the same data with multiple different styles. name actually refers to the class name. Separating them with : is possible, but then we'd have to spell out the class name, rather than just using the suffix. Otherwise we're going to introduce too much magic behavior.
Going to a flat array probably won't happen. The bucket groups you propose are conceptually different from what the groups in the structure array do: In here, we are grouping multiple buckets to be rendered to a framebuffer before they are globally composited onto the main canvas. During compositing, you can then specify texture effects (like blur, colorization, opacity, etc.).
@kkaefer yeah, we would refer to them the same way when styling (e.g. "tunnel_large:casing": { ... }), no magic. The purpose is just to remove unnecessary repetition in the structure config, as structure class names refer to bucket names 100% of the time.
Didn't know about compositing, I see that in the code now — makes sense.
as structure class names refer to bucket names 100% of the time
No, they don't. In the sample stylesheet, you can see that a structure element refers to a bucket object and a class name, but there is no 1:1 matching between buckets and class names.
@kkaefer they do with the exception of _casing classes, which why I suggested introducing postfixes like :casing. In terms of referring from styles, there's no difference between tunnel_large_casing and tunnel_large:casing (they're just strings), but with the latter, we can imply tunnel_large bucket instead of having such a verbose config. That's what I meant in the initial post.
Sure, that works in /this/ case, but you can't make a general rule from this special case from the fact that they only differ by _casing in our stylesheet; that is just coincidence.
@kkaefer as far as I understand, what class names we choose is just a convention. Each class still has exactly one associated bucket. So whether we reflect that in class name and let developers differentiate with postfixes when needed (and imply when not), or leave as is, is a matter of convention. I'm just following Convention over configuration principle here. Details like this may look insignificant, but they're important if we're planning on winning over a lot of developers, judging from my experience building Leaflet community.
Convention over configuration (also known as coding by convention) is a software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility.
The phrase essentially means a developer only needs to specify unconventional aspects of the application. For example, if there's a class Sale in the model, the corresponding table in the database is called “sales” by default. It is only if one deviates from this convention, such as calling the table “products_sold”, that one needs to write code regarding these names.
When the convention implemented by the tool matches the desired behavior, it behaves as expected without having to write configuration files. Only when the desired behavior deviates from the implemented convention is explicit configuration required.
Is this being actively worked on? I don't really know what I'm doing so I'm probably misusing the config all over the place, but here's a note on how I've been using it that seems different from what's being described above:
I rearranged the auto styling so that most of the road style classes (name) have three buckets associated with each of them. E.g, the street class has the buckets bridge_street, road_street, and tunnel_street associate with it. These need to be separate buckets because of their drawing order, but they are styled exactly the same.
Activity
kkaefer commentedon Feb 10, 2014
The purpose of
structureis to define the order the buckets are drawn in, and the class applied to a bucket. E.g. you can use the same bucket multiple times (as with the road layers) and draw the same data with multiple different styles.nameactually refers to the class name. Separating them with:is possible, but then we'd have to spell out the class name, rather than just using the suffix. Otherwise we're going to introduce too much magic behavior.Going to a flat array probably won't happen. The bucket groups you propose are conceptually different from what the groups in the
structurearray do: In here, we are grouping multiple buckets to be rendered to a framebuffer before they are globally composited onto the main canvas. During compositing, you can then specify texture effects (like blur, colorization, opacity, etc.).mourner commentedon Feb 10, 2014
@kkaefer yeah, we would refer to them the same way when styling (e.g.
"tunnel_large:casing": { ... }), no magic. The purpose is just to remove unnecessary repetition in the structure config, as structure class names refer to bucket names 100% of the time.Didn't know about compositing, I see that in the code now — makes sense.
kkaefer commentedon Feb 10, 2014
No, they don't. In the sample stylesheet, you can see that a structure element refers to a bucket object and a class name, but there is no 1:1 matching between buckets and class names.
mourner commentedon Feb 10, 2014
@kkaefer they do with the exception of
_casingclasses, which why I suggested introducing postfixes like:casing. In terms of referring from styles, there's no difference betweentunnel_large_casingandtunnel_large:casing(they're just strings), but with the latter, we can implytunnel_largebucket instead of having such a verbose config. That's what I meant in the initial post.kkaefer commentedon Feb 10, 2014
Sure, that works in /this/ case, but you can't make a general rule from this special case from the fact that they only differ by _casing in our stylesheet; that is just coincidence.
mourner commentedon Feb 10, 2014
@kkaefer as far as I understand, what class names we choose is just a convention. Each class still has exactly one associated bucket. So whether we reflect that in class name and let developers differentiate with postfixes when needed (and imply when not), or leave as is, is a matter of convention. I'm just following Convention over configuration principle here. Details like this may look insignificant, but they're important if we're planning on winning over a lot of developers, judging from my experience building Leaflet community.
nickidlugash commentedon Feb 25, 2014
Is this being actively worked on? I don't really know what I'm doing so I'm probably misusing the config all over the place, but here's a note on how I've been using it that seems different from what's being described above:
I rearranged the auto styling so that most of the road style classes (
name) have three buckets associated with each of them. E.g, thestreetclass has the bucketsbridge_street,road_street, andtunnel_streetassociate with it. These need to be separate buckets because of their drawing order, but they are styled exactly the same.mourner commentedon Mar 28, 2014
Closing in favor of #356
Merge pull request mapbox#279 from mapbox/hover