Skip to content

Commit 429a58a

Browse files
committed
feat: replaced methods in NonHierarchicalDistanceBasedAlgorithm.java
1 parent d9cc5d4 commit 429a58a

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

library/src/main/java/com/google/maps/android/clustering/algo/ContinuousZoomEuclideanAlgorithm.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.maps.android.clustering.Cluster;
2020
import com.google.maps.android.clustering.ClusterItem;
2121
import com.google.maps.android.geometry.Bounds;
22-
import com.google.maps.android.geometry.Point;
2322

2423
import java.util.ArrayList;
2524
import java.util.Collection;
@@ -122,30 +121,4 @@ public Set<? extends Cluster<T>> getClusters(float zoom) {
122121
}
123122
return results;
124123
}
125-
126-
/**
127-
* Calculates the squared Euclidean distance between two points.
128-
*
129-
* @param a the first point
130-
* @param b the second point
131-
* @return the squared Euclidean distance between {@code a} and {@code b}
132-
*/
133-
private double distanceSquared(Point a, Point b) {
134-
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
135-
}
136-
137-
/**
138-
* Creates a square bounding box centered at a point with the specified span.
139-
*
140-
* @param p the center point
141-
* @param span the total width/height of the bounding box
142-
* @return the {@link Bounds} object representing the search area
143-
*/
144-
private Bounds createBoundsFromSpan(Point p, double span) {
145-
double halfSpan = span / 2;
146-
return new Bounds(
147-
p.x - halfSpan, p.x + halfSpan,
148-
p.y - halfSpan, p.y + halfSpan
149-
);
150-
}
151124
}

library/src/main/java/com/google/maps/android/clustering/algo/NonHierarchicalDistanceBasedAlgorithm.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,25 @@ public int getMaxDistanceBetweenClusteredItems() {
247247
return mMaxDistance;
248248
}
249249

250-
private double distanceSquared(Point a, Point b) {
250+
/**
251+
* Calculates the squared Euclidean distance between two points.
252+
*
253+
* @param a the first point
254+
* @param b the second point
255+
* @return the squared Euclidean distance between {@code a} and {@code b}
256+
*/
257+
protected double distanceSquared(Point a, Point b) {
251258
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
252259
}
253260

254-
private Bounds createBoundsFromSpan(Point p, double span) {
261+
/**
262+
* Creates a square bounding box centered at a point with the specified span.
263+
*
264+
* @param p the center point
265+
* @param span the total width/height of the bounding box
266+
* @return the {@link Bounds} object representing the search area
267+
*/
268+
protected Bounds createBoundsFromSpan(Point p, double span) {
255269
// TODO: Use a span that takes into account the visual size of the marker, not just its
256270
// LatLng.
257271
double halfSpan = span / 2;

library/src/test/java/com/google/maps/android/clustering/algo/ContinuousZoomEuclideanAlgorithmTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Float getZIndex() {
6666
public void testContinuousZoomMergesClosePairAtLowZoomAndSeparatesAtHighZoom() {
6767
ContinuousZoomEuclideanAlgorithm<TestClusterItem> algo =
6868
new ContinuousZoomEuclideanAlgorithm<>();
69-
69+
7070
Collection<TestClusterItem> items = Arrays.asList(
7171
new TestClusterItem(10.0, 10.0),
7272
new TestClusterItem(10.0001, 10.0001), // very close to the first

0 commit comments

Comments
 (0)