mapsforge / vtm

OpenGL vector map library - running on Android, iOS, Desktop and browser.
GNU Lesser General Public License v3.0
270 stars 89 forks source link

Marker clustering #312

Closed devemux86 closed 7 years ago

devemux86 commented 7 years ago

Implement clustering in adjacent markers.

clusters

devemux86 commented 7 years ago

See PR #296 and #310 by @nebular.

devemux86 commented 7 years ago

Closed via #296 and #310.

The implementation can be improved in cluster calculation and rendering.

mcbridet commented 7 years ago

Is this on the current snapshot on sonatype? Looks like it has been updated recently but I could not import the new classes.

devemux86 commented 7 years ago

Should be in latest snapshots and I see they were built successfully.

Perhaps you need to somehow force Gradle to update them "now" in your build? e.g. see a way in integration guide

mcbridet commented 7 years ago

Thanks! Ended up pulling it to make a few changes anyway.

devemux86 commented 7 years ago

Ended up pulling it to make a few changes anyway.

Any improvement is welcome! :slightly_smiling_face:

nebular commented 7 years ago

If I can be of any help please don't hesitate to ask :)

mcbridet commented 7 years ago

I might do, it's very much spaghetti code at the moment!

The only big issue I am having right now is the overlapping of clusters. It's a bit confusing when clusters end up on top of each other, and I am trying to avoid this by increasing the grid size (to limited success). I'm going to persevere and see what I end up with. ;)

nebular commented 7 years ago

The reason why that happens is that the "cluster" is really the first element with its bitmap changed, so, for example, if there's a succession of spaced markers, the latest ones will not be clustered together until they "invade" the first item position.

What would solve the situation is, when one item act as a cluster, to update its position to the middle point. Probably a good approach would be to store the new calculated coordinates in new properties inInternalItem.Clustered and, if the item acts as a cluster, use those coordinates instead of the original ones.

Incrementing the GRIDSIZE as you have experienced, kind of hides the problem, but depending on how the markers are spaced it can happen again. This week I'm busy with a project deadline, the next one (if you don't fix it before) I will gladly try to improve the algorythm.

mcbridet commented 7 years ago

Very interesting, thanks for the info!

devemux86 commented 7 years ago

What seems a bit strange, from user's perspective, is that during zoom in / out the clusters are created in non deterministic way, like each time a random clustering happens.