}
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();
while (it.hasNext()) {
SimpleFeature feature = it.next();
if (rule.isElseFilter() || rule.getFilter() == null) {
rules.add(rule);
break;
} else if (rule.getFilter().evaluate(feature)) {
rules.add(rule);
break;
}
}
} catch (IOException e) {
// cannot happen !
}
}
}
}
featureLayer.getUserData().put(USERDATA_KEY_STYLE_RULES, rules);
return featureLayer;
}