public Layer createLayer(MapContext mapContext, ClientLayerInfo clientLayerInfo) throws GeomajasException {
if (!(clientLayerInfo instanceof ClientGeometryLayerInfo)) {
throw new IllegalStateException(
"GeometryLayerFactory.createLayer() should only be called using ClientGeometryLayerInfo");
}
ClientGeometryLayerInfo layerInfo = (ClientGeometryLayerInfo) clientLayerInfo;
LayerType layerType = layerInfo.getLayerType();
Style style = styleFactoryService.createStyle(layerType, layerInfo.getStyle());
GeometryDirectLayer layer = new GeometryDirectLayer(style, converterService.toInternal(layerType));
for (Geometry geom : layerInfo.getGeometries()) {
layer.getGeometries().add(converterService.toInternal(geom));
}
layer.getUserData().put(USERDATA_KEY_SHOWING, layerInfo.isShowing());
layer.setTitle(layerInfo.getLabel());
List<Rule> rules = new ArrayList<Rule>();
// all rules are needed for map/legend
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
rules.add(rule);