What is the most efficient way of clustering coordinates on the server side? Examples?
Here is an example of exactly what I need (although I can't use third party vendors)
http://www.crunchpanorama.com/
PostgreSQL, Python platform, Google Maps.
What is the most efficient way of clustering coordinates on the server side? Examples?
Here is an example of exactly what I need (although I can't use third party vendors)
http://www.crunchpanorama.com/
PostgreSQL, Python platform, Google Maps.
Have look at using a quadtree.
(You are using the quadtree or grid to reduce your search space. Otherwise your are O(n^2) on the number of items you have)
I have posted this link a couple times before. It's written for the Static Maps API in PHP, but you can port it to Python. It should get you started on the clustering algorithm.
I have a Google Maps application which sends a request to the server containing the map bounds and zoom level whenever the map is moved. The server gets all the markers within the bounds, clusters them, and returns a list of markers to be added to the map.
UPDATE: 30k markers would probably be too many to cluster every time someone moves the map. However, if the users have no control of which markers are visible, you have a solution: pre-cluster the markers. I believe that this is how sites like the one you posted work. Every time you update your set of markers, run the clusterer and save the results for each zoom level. Use your set of pre-clustered markers to decide which markers to send to the browser when the user moves the map.
I think the site you post as example is using client side clustering. Example of that you can find on http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/examples/
look at http://www.geocubes.com they provide a solution for clustering a high amount of markers
I use server side clustering on my site (Canadian real estate and rentals); but I modify my search depending on the zoom. When I am zoomed into the city level, I limit the search to return 1000 results, and if some of the results are overlapping, I cluster them.
At higher zoom levels, I show summary details for the city, province or country.
For the actual clustering algorithm, I am using Django and Python and the source can be found here.
Hope this can meet your need
http://www.quanative.com/2010/01/01/server-side-marker-clustering-for-google-maps-with-python/