[OpenLayers-Users] Cluster strategy : cluster coord update proposition

Didrik Pinte lists at dipole-consulting.com
Thu Dec 11 15:46:41 EST 2008


On Thu, 2008-12-11 at 11:29 -0700, Tim Schaub wrote:
> Hey-
> 
> Didrik Pinte wrote:
> > The cluster (x,y) position is created using the first feature.geometry
> > coordinates. To have a cluster that is "at the center" of the data it
> > clusters, I would propose to update its position using all the feature
> > added to the cluster. Something like this :
> > 
> >      addToCluster: function(cluster, feature) {
> > +        //update pos of the cluster to the mean pos of the features
> > +        var bounds = cluster.geometry.getBounds();
> > +        bounds.extend(feature.geometry.getBounds(););
> >          cluster.cluster.push(feature);
> >          cluster.attributes.count += 1;
> > +        cluster.geometry = bounds.getCenterLonLat();
> >      },
> > 
> 
> Currently, if you have a cluster centered at 0, 0 and your cluster 
> distance is 20, the cluster geometry will represent all features within 
> 20 pixels of the cluster.
> 
> This definition can be achieved with a simple and efficient algorithm: 
> pick a location and gather all features within some distance.
> 
> If you think instead that the cluster position should be the centroid of 
> all features within some distance of the first unclustered feature, then 
> the resulting cluster (feature) does not have this same definition.  I'm 
> not saying this is bad, but you could no longer say "this cluster 
> represents all features within X distance of this point."  (Instead, the 
> cluster definition would be something like "the centroid of all features 
> within X distance of the first feature included in the cluster.)
> 
> And, if you want to determine the geometric center of your cluster, you 
> should not do so in the way you suggest above.  That algorithm weighs 
> more heavily each feature added (the new location is the mean of the 
> newest feature and the mean of all previous features).
> 
> So, if you want to determine the centroid of a cluster of points, keep 
> them all and after the cluster is done, calculate the centroid.
> 
> And, if you are really wanting the cluster to represent the centroid, 
> then you should be accounting for the full geometry of each feature in 
> the cluster - not just the center point of the bounds.
> 
> I just thought the existing definition & algorithm was a nice 
> combination of simple and efficient.
> 
> Tim

Hi Tim,

Thansk for the excellent explanation. I was just thinking at a "better"
way for the problem I consider. We use clustering to groups trees in
urban area's. Most of them are along the streets and thus the clusters
seem not really at the right place intuitively. That is why I wanted to
modify the behaviour.

Didrik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081211/7a82e149/attachment.bin


More information about the Users mailing list