Skip to content

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
@dkhawk dkhawk merged commit b781ff8 into main Aug 19, 2025
11 checks passed
@dkhawk dkhawk deleted the feat/added_continuous_zoom_euclidean_algorithm branch August 19, 2025 22:15
googlemaps-bot pushed a commit that referenced this pull request Aug 19, 2025
# [3.15.0](v3.14.0...v3.15.0) (2025-08-19)

### Features

* added ContinuousZoomEuclideanCentroidAlgorithm ([#1559](#1559)) ([b781ff8](b781ff8))
@googlemaps-bot
Copy link
Contributor

🎉 This PR is included in version 3.15.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

dkhawk pushed a commit to Programmeister/android-maps-utils that referenced this pull request Aug 20, 2025
* feat: added ContinuousZoomEuclideanAlgorithm

* feat: added ContinuousZoomEuclideanAlgorithm

* feat: added ContinuousZoomEuclideanAlgorithm

* feat: replaced methods in NonHierarchicalDistanceBasedAlgorithm.java

* feat: refactored to create ContinuousZoomEuclideanCentroidAlgorithm.java
dkhawk pushed a commit to Programmeister/android-maps-utils that referenced this pull request Aug 20, 2025
# [3.15.0](googlemaps/android-maps-utils@v3.14.0...v3.15.0) (2025-08-19)

### Features

* added ContinuousZoomEuclideanCentroidAlgorithm ([googlemaps#1559](googlemaps#1559)) ([b781ff8](googlemaps@b781ff8))
@ColtonIdle
Copy link

Can we add some high level docs on when to use what? For example, it's pretty well discussed in this repo issues/prs that NonHierarchicalDistanceBasedAlgorithm is the goto when you have a ton of items, but maybe the readme can include a pros cons list or something? Thank you!

@kikoso
Copy link
Collaborator Author

kikoso commented Aug 25, 2025

@ColtonIdle , we were talking last week about adding an activity showcasing how all the algorithm works. We will work on this next - either a new sample, and/or documentation to showcase them.

@ColtonIdle
Copy link

Love it! thank you! im a maps noob, but have to use it in a few KMP apps now so I'm trying my best to provide a good UX for everyone!

@kikoso
Copy link
Collaborator Author

kikoso commented Aug 26, 2025

@ColtonIdle , this will be reviewed soon, but as a reference:

#1567

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants