Skip to content
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

Add feature sorting mechanism #2421

Open
pauldendulk opened this issue Jan 13, 2024 · 2 comments
Open

Add feature sorting mechanism #2421

pauldendulk opened this issue Jan 13, 2024 · 2 comments

Comments

@pauldendulk
Copy link
Member

The problem
A common requirement for map display is to be able to specify the order in which features are drawn. For instance, when drawing cities you may want to put the biggest cities on top.

The proposed solution
Not decided yet.

Option: Provide custom sorting function
We just introduced a ZOrder. This is used in the MemoryLayer but not anywhere else. In order to make this consistent we need to start sorting on ZOrder everywhere else. This puts a burden on all layer implementations. Also use of the ZOrder may not always be the easiest solution. In some cases the user already has some object with a field indicating the order. Now the ZOrder has to be assigned in the user code. An alternative that I am thinking about is to provide a function to do the sorting. It has a default implementation, or perhaps no implementation, in which case the provider determines the order. The user can provide a function which takes the list of features as input on which to apply custom sorting logic. Any field (or fields) could be used. Advantages: We can remove ZOrder (one property less). We do not have to implement sorting on ZOrder for all layers (and perhaps providers?).

Note, Currently the IFeature has some fixed properties and has the option for 'custom properties' through the dictionary. This solution was introduced in SharpMap, long ago. Nowadays there are alternative options, like generics. This is a separate feature request but may be related.

@charlenni
Copy link
Member

You are right, there could be a better way of sorting. And much better, if there is no need for sorting at all (faster).

I looked into other map libraries, and they used ZOrder or ZIndex for this. So it was the most obvious way.

@charlenni
Copy link
Member

See PR #2438.

Perhaps we should remove a special sorting function for all existing layers (MemoryLayer included) and let the user decide, which is the right one to use. This would be possible with the given implementation in PR #2438.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants