-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
Add sorting of features before drawing #2438
Conversation
There was a problem hiding this 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.
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. |
See issue #2421.
This PR introduce a
SortFeature()
function, which is used to sort features before drawing. In theBaseLayer
implementation, this functions return the given features untouched. In theMemoryLayer
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.