-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Style spec: Add ability to sort features #4361
Comments
Small point, I'd suggest using a string like "asc" rather than subverting comparison operators (">"). They look like the filter attributes (which are comparisons) but the behaviour is unrelated. It might even be better to use a different term which makes clearer the relationship between the sort order and the display order. I don't necessarily know whether an "ascending" order means that ID 5 is drawn above or below ID 3. I don't know what that term would be though :) |
In the iOS and macOS SDKs, it may be desirable to expose this sort option to the runtime styling API as a |
Waiting very much for this one to land. Can't really guarantee features get properly serialised to MVT keeping postgres sorting, so it's really important to have control for feature rendering order on client. Along with data-driven functions, this adds possibilities to reduce number of layers, "bigly". |
tagging in @mapbox/gl 🎉 |
@kkaefer do you have a sense of the lift involved in implementing this feature? |
To be able to sort features, we'd have to generate a sort key for every feature (likely an expression) in a layer. If we supported sorting by multiple keys (in case of equality), we'd want subsequent keys to be generated lazily. Either way, this relies on the ability to know all features within a layer as they are processed. When combined with custom sources, this assumption may no longer be true if they are streaming in some way. However, in the worst case, we could disallow sorting on custom sources (since the generating code is supposed to generate features in the right order). |
I've used the sort property to style road features based on 'layer' attribute of OSM data as follow, but the map renders all layes in the same z-order. What's the problem?
|
@harry-wilson the syntax described in the original post is a proposal. It is not implemented. |
@kkaefer The symbl-sort-key and other |
Yeah, let's create a new issue if we discover missing functionality. |
With data driven styling, we can render more features in a single layer. However, this means that the order of the features in the source dictates the rendering order. It'd be useful to add a capability to sort/group features before they are parsed into a bucket.
The sorting step would come after the filter step and before the features are transformed into actual buffers. Here's a style syntax suggestion:
Sort rules are applied in order, so if items have an identical
class
, we're going to sort them byarea
in descending order. In the array, we're first supplying the sort field, then the sort order. We can either specify<
for descending,>
for ascending, and an array with explicitly listed items for discrete value ordering (all items that do not match a discrete value are going last and will have subsequent sort rules applied).See #1349 for a similar discussion.
The text was updated successfully, but these errors were encountered: