// we now replace the style filters by simple filters on an artificial extra style attribute
for (FeatureStyleInfo style : copy.getStyle().getFeatureStyles()) {
style.setFormula(STYLE_INDEX_ATTRIBUTE_NAME + " = " + style.getIndex());
}
// create the style
Style style = styleFactoryService.createStyle(layer, copy);
// estimate the buffer
MetaBufferEstimator estimator = new MetaBufferEstimator();
estimator.visit(style);
int bufferInPixels = estimator.getBuffer();
// expand area to include buffer
Rectangle tileInpix = mapContext.getViewport().getScreenArea();
ReferencedEnvelope metaArea = new ReferencedEnvelope(areaOfInterest);
metaArea.expandBy(bufferInPixels / tileInpix.getWidth() * areaOfInterest.getWidth(),
bufferInPixels / tileInpix.getHeight() * areaOfInterest.getHeight());
// fetch features in meta area
Crs layerCrs = vectorLayerService.getCrs(layer);
Envelope layerBounds = geoService.transform(metaArea, (Crs) areaOfInterest.getCoordinateReferenceSystem(),
layerCrs);
Filter filter = filterService.createBboxFilter(layerCrs, layerBounds,
layer.getLayerInfo().getFeatureInfo().getGeometryType().getName());
if (extraInfo.getFilter() != null) {
filter = filterService.createAndFilter(filter, filterService.parseFilter(extraInfo.getFilter()));
}
List<InternalFeature> features = vectorLayerService.getFeatures(vectorInfo.getServerLayerId(),
mapContext.getCoordinateReferenceSystem(), filter, extraInfo.getStyle(),
VectorLayerService.FEATURE_INCLUDE_ALL);
FeatureLayer featureLayer = new FeatureLayer(createCollection(features, layer,
mapContext.getCoordinateReferenceSystem(), style), style);
featureLayer.setTitle(vectorInfo.getLabel());
featureLayer.getUserData().put(USERDATA_KEY_SHOWING, extraInfo.isShowing());
List<Rule> rules = new ArrayList<Rule>();
double scaleDenominator = RendererUtilities.calculateOGCScale(mapContext.getAreaOfInterest(), (int) mapContext
.getViewport().getScreenArea().getWidth(), null);
// find the applicable rules
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
if (isWithInScale(rule, scaleDenominator)) {
FeatureIterator<SimpleFeature> it;
try {
it = featureLayer.getSimpleFeatureSource().getFeatures().features();