[Users] average of an cluster attribute
François Boussuges
f.boussuges at gmail.com
Thu May 27 11:30:49 CEST 2010
Hello!
I use cluster strategy on my WFS layer (point layer), I have create two
context for the style of my layer:
-radius: the ${radius} determine the radius of the point in function of
the numbers of features in my cluster (this is OK).
-fillcolor: the ${fillcolor} determine the color of my point in function
on an attributs of my points (% spirale) , values of the attributs are
between 0 and 100. for one features by cluster it's ok but when I have
more than one feature by cluster the style is apply on the last value
(if I have 3 features in the cluster the fillcolor is calculate on the
third feature).
It is possible to make a average of the attributs for the cluster with
more than 1 features?
This is my script with the two functions:
var defStyle1 = new OpenLayers.Style({
pointRadius: "${radius}",
fillColor: "${fillColor}",
fillOpacity:1,
strokeColor: "#FFFF00",
strokeWidth: 1,
strokeOpacity: 1 }
/* context pour le cluster */
,{ context:/*
* {
* } }
*/
{ fillColor: function(feature) {
if(feature.cluster) {
sens_hor = 0;
for(var c = 0; c < feature.cluster.length; c++) {
i = feature.cluster[c].attributes.SPIRALE_GOUSSE_HORAIRE}
if (i>sens_hor){ sens_hor= i;
if(i > 50) return "#990000";
if(i<=50) return "#000099";}
} },
radius: function(feature) { var pix = 3; if(feature.cluster) { pix =
Math.min(feature.attributes.count, 7) *2; } return pix;}}
});
More information about the Users
mailing list