Implementation of the second-pass clustering algorithm to prevent ann… #102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello !
Thanks for the nice code, I checked several other repos on github and found this implementation most mature and well written.
But still there are several things to improve, and I tried my best to provide feature to prevent annotations overlapping which is very annoying in my own project. I've extended the iOS Example application to demonstrate my changes and provided some (minimal) documentation.
Also, I fixed bug when annotation coordinates were not set to the new values in CCHMapClusterOperation.m line 167
if (annotationSetsAreUniqueLocations) { annotationForCell.coordinate = coordinate; }
there is no
else
clause and sometimes annotations were placed in the wrong grid cell.I tried to make my code fast, so some good old C arrays was used. Currently second-pass algorithm is quite simple: same block is called for each grid cell from top to bottom, left to right. On each step checks are made to the upper cell and to the left cell and if there are annotation overlapping, then annotation in the current cell get moved right and/or bottom to prevent overlapping.
Better way to do it is to merge overlapping annotations into bigger ones. My design allows several second-pass algorithms: just set block property
fixAnnotationPosition
to your own realization.