-
- All Implemented Interfaces:
-
com.google.maps.android.clustering.algo.Algorithm
public class NonHierarchicalDistanceBasedAlgorithm<T extends ClusterItem> extends AbstractAlgorithm<T>
A simple clustering algorithm with O(nlog n) performance. Resulting clusters are not hierarchical.
High level algorithm:1. Iterate over items in the order they were added (candidate clusters).2. Create a cluster with the center of the item. 3. Add all items that are within a certain distance to the cluster. 4. Move any items out of an existing cluster if they are closer to another cluster. 5. Remove those items from the list of candidate clusters.
Clusters have the center of the first element (not the centroid of the items within it).
-
-
Method Summary
Modifier and Type Method Description boolean
addItem(T item)
Adds an item to the algorithm boolean
addItems(Collection<T> items)
Adds a collection of items to the algorithm void
clearItems()
boolean
removeItem(T item)
Removes an item from the algorithm boolean
removeItems(Collection<T> items)
Removes a collection of items from the algorithm boolean
updateItem(T item)
Updates the provided item in the algorithm Set<out Cluster<T>>
getClusters(float zoom)
Collection<T>
getItems()
void
setMaxDistanceBetweenClusteredItems(int maxDistance)
int
getMaxDistanceBetweenClusteredItems()
-
-
Method Detail
-
addItem
boolean addItem(T item)
Adds an item to the algorithm
- Parameters:
item
- the item to be added
-
addItems
boolean addItems(Collection<T> items)
Adds a collection of items to the algorithm
- Parameters:
items
- the items to be added
-
clearItems
void clearItems()
-
removeItem
boolean removeItem(T item)
Removes an item from the algorithm
- Parameters:
item
- the item to be removed
-
removeItems
boolean removeItems(Collection<T> items)
Removes a collection of items from the algorithm
- Parameters:
items
- the items to be removed
-
updateItem
boolean updateItem(T item)
Updates the provided item in the algorithm
- Parameters:
item
- the item to be updated
-
getClusters
Set<out Cluster<T>> getClusters(float zoom)
-
getItems
Collection<T> getItems()
-
setMaxDistanceBetweenClusteredItems
void setMaxDistanceBetweenClusteredItems(int maxDistance)
-
getMaxDistanceBetweenClusteredItems
int getMaxDistanceBetweenClusteredItems()
-
-
-
-