Server side clustering - cluster (feature) geometry

I am trying to implement server side clustering and show it using `OpenLayers`. I am using this good material as an example. As a clustering result, a get some list of features, some of them are clusters. Like this (it is an output of previous example):

``````Array (
[0] => Array (
[0] => Array ( [id] => marker_3 [lat] => 59.431602 [lon] => 24.757563 )
[1] => Array ( [id] => marker_4 [lat] => 59.437843 [lon] => 24.765759 )
[2] => Array ( [id] => marker_6 [lat] => 59.434776 [lon] => 24.756681 )
)
[1] => Array ( [id] => marker_5 [lat] => 59.439644 [lon] => 24.779041 )
[2] => Array ( [id] => marker_2 [lat] => 59.432365 [lon] => 24.742992 )
[3] => Array ( [id] => marker_1 [lat] => 59.441193 [lon] => 24.729494 )
)
``````

where 0 element is cluster containing 3 features. But how can I compute this clusters geometry? Or how can I visualize it using `OpenLayers`?

-
Any suggestions? – Bob Jan 25 '13 at 16:01

Is there a particular reason why you are doing it server-side? OpenLayers contains the ability to cluster vector features client-side. The benefit of doing it client-side is that OpenLayers will take care of the clustering for you as you zoom in and out of the map rather than you having to do it server-side. Clustering can be added to the vector layer using a strategy - more details here and an example here.

If there is a reason for doing it server-side then you could style the point feature (I'm assuming these are points) by applying a scale factor to the radius of the circle which could be based on the number of elements in the cluster. Decide on a base size for all your normal points, lets say 10px, and then add 2px for each additional point in the cluster. So, if you have a cluster of 10 points then you would make the size of the point denoting the cluster to be 30px - 10px + (10 * 2px).

To further distinguish them you could also add a label showing the number of points in the cluster.

The OpenLayers website contains lots of examples of styling features.

-

I ran into a similar problem and solved it with a combination of client-side clustering, server-side clustering and data-culling by viewport. You can find a detailed description in Mapping Large Data Sets.

-

Have to look at SaaS solutions, for example http://clustermash.com are able to cluster at least 8 million locations from the GeoNames DB on one of their demos?

-