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

Implementation of the second-pass clustering algorithm to prevent ann… #102

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

deem0n
Copy link

@deem0n deem0n commented Aug 7, 2015

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.

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.

1 participant