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 sorting of features before drawing #2438

Merged
merged 9 commits into from Jan 17, 2024

Conversation

charlenni
Copy link
Member

See issue #2421.

This PR introduce a SortFeature() function, which is used to sort features before drawing. In the BaseLayer implementation, this functions return the given features untouched. In the MemoryLayer implementation this function is replaced by a function, that orders the features by ZOrder and Id by default (perhaps this should be reverted and the default function should use). With this, it is possible to use whatever sorting algorithm you like.

Copy link
Member

@pauldendulk pauldendulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! By letting this VisibleFeatureInterator do the sorting you have to call it only once (instead of calling it in the layer).

With this change setting the IFeature.ZOrder on a non-MemoryLayer will still have no effect. This will surprise users. One solution is to move the default sort function to the BaseLayer. Another would be to remove the ZOrder altogether. I am thinking about the generic Data field on the IFeature which could contain a ZOrder, or any other field that the users could use for sorting.

@pauldendulk pauldendulk merged commit 35bcc33 into Mapsui:main Jan 17, 2024
5 checks passed
@charlenni
Copy link
Member Author

I found a little problem here. The MapInfo result is not in the right order. We check the layers in reverse order (topmost first), but don't respect the order of the features inside the layers. The first drawn feature should be the last one to check. So the sort order of the features inside a layer has to be reversed.

@charlenni charlenni deleted the add-orderoffeaturetoalllayers branch January 20, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants