问题
I need to solve the problem of marking thousands of items on a map in a way that's accurate and readable and fast even when the user zooms out so that markers would overlap in confusing ways. It's an Android MapView
, but my questions are more general.
I am aware of Fluster, grid-based schemes, and various heuristics.
These algorithms appear to be inaccurate in that cluster markers don't correspond to the centroid. My application is safety critical, and the markers are fairly big, so approximation is not good enough.
After I invented an algorithm, I learned it was first used in the 80's. Its proper description is "agglomerative hierarchical geometric centroid clustering." Pseudcode as follows:
-- Greedy hierarchical clustering
given R the clearance radius of markers
let S be a set, initially singleton clusters containing exactly one marker each
loop
let <a,b> be the pair of clusters in S with closest centroids, distance d apart; (1)
if d >= 2R, exit the loop;
remove a and b from S;
insert new Cluster(a union b) into S;
end loop;
Now draw one marker at the centroid of each cluster.
I used an updateable Delaunay triangulation and a priority queue to make (1) efficient, but recently found that kd-trees with deletion will also work. The DT algorithm is the same asysmptotic complexity as kd-trees (O(n log n) average), but my guess is it will be faster in practice.
The questions:
- Are there better algorithms for finding the clusters? The greedy algorithm can result in fewer clusters than strictly needed to separate markers by the minmum amount. Finding the largest set is probably NP hard. Are there heuristics better than greedy?
- Is it worth trying the kd-tree in lieu of Delaunay triangulation? Performance of DT at 10,000 nodes is marginal on a fast tablet: up to 2 seconds after a zoom.
- Are there existing packages that place markers at cluster centroids?
来源:https://stackoverflow.com/questions/11748150/deconflicting-markers-in-map-overlays