[GIS] How to set a maximum amount of features to be drawn in every zoom level

featuresgeneralizationopenlayers-2

I want to apply a form of generalization/specialization to my OpenLayers map. Is there a way to set the amount of WFS features to be rendered based on the zoom level?

In GeoServer you can set the maximum amount of features but not based on a zoom level. Would something like this be possible?

Best Answer

I think a good way to minimize unneccessary traffic is to use a BBOX-Strategy:

new OpenLayers.Layer.Vector("WFS", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.WFS({
                    url:  "http://demo.opengeo.org/geoserver/wfs",
                    featureType: "tasmania_roads",
                    featureNS: "http://www.openplans.org/topp"
                })
            });

Otherwise you can use "maxFeatures=xxxx" to limit the number of features delivered but with this solution you can't decide with features will be sent back.

http://example.com/geoserver/wfs?
  service=wfs&
  version=1.1.0&
  request=GetFeature&
  typeName=namespace:featuretype&
  maxFeatures=N