I'm doing this sql query using geoservers sql views:
SELECT kmeans, count(*), ST_BUFFER(ST_CENTROID(ST_Collect(geom)), qrt(count(*))*1000 ) AS geom FROM ( SELECT kmeans(ARRAY[ST_X(ST_CENTROID(geom)), ST_Y(ST_CENTROID(geom))], 10) OVER (), geom FROM data WHERE foo = %FOO% ) AS ksub GROUP BY kmeans ORDER BY kmeans
This always returns the same regardless which bounding box is requestet via the wms. But I want to use the bounding box in my WHERE clause. I know that the user gets a different result then if there are more tiles used to dislpay a map but that will be ok for me.