Skip to content

feat: added ContinuousZoomEuclideanCentroidAlgorithm #1559

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kikoso
Copy link
Collaborator

@kikoso kikoso commented Aug 13, 2025

This PR adds the ContinuousZoomEuclideanCentroidAlgorithm , a new clustering algorithm to fix some issues present in the NonHierarchicalDistanceBasedAlgorithm (namely, aggresivevity while clustering). It avoids the limitations of NonHierarchicalDistanceBasedAlgorithm, like abrupt clustering changes when zoom crosses integer levels and the square-based proximity check.

The algorithm works with continuous zoom, computing the clustering radius using the fractional zoom level, so the threshold changes smoothly as you zoom in or out. This makes clustering more natural and visually consistent.

It also uses Euclidean distance to decide cluster membership. The quadtree search still uses a square for performance, but items are only added to a cluster if they fall within a circular radius, avoiding the diagonal over-merging problem.

This comes as a separate algorithm instead of changing NonHierarchicalDistanceBasedAlgorithm, so we don’t introduce any behavior changes for existing users.

@kikoso
Copy link
Collaborator Author

kikoso commented Aug 13, 2025

@stefano-maggiolo, I can't add you as a reviewer, but feel free to take a look. I have added a test, but while doing it I am thinking if it could make sense to add a sample activity that showcase the behavior for the algorithms.

@googlemaps-bot
Copy link
Contributor

googlemaps-bot commented Aug 13, 2025

Code Coverage

Overall Project 35.75% 🍏
Files changed 100% 🍏

File Coverage
ContinuousZoomEuclideanCentroidAlgorithm.java 100% 🍏
NonHierarchicalDistanceBasedAlgorithm.java 93.91% 🍏

Copy link

@stefano-maggiolo stefano-maggiolo left a comment

Choose a reason for hiding this comment

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

Looks good to me, but can we have a version that combine this and the Centroid version?

@kikoso kikoso changed the title feat: added ContinuousZoomEuclideanAlgorithm feat: added ContinuousZoomEuclideanCentroidAlgorithm Aug 13, 2025
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.

4 participants