String geomName = featureInfo.getGeometryType().getName();
List<Rule> rules = new ArrayList<Rule>();
// for mixed geometries we add a filter to distinguish between geometry types
if (layerType == LayerType.GEOMETRY) {
// add the configured filter to a filter that selects point features only
Rule pointRule = styleBuilder.createRule(createGeometrySymbolizer(LayerType.POINT, featureStyle));
Filter pointFilter = filterService.createGeometryTypeFilter(geomName, "Point");
Filter multiPointFilter = filterService.createGeometryTypeFilter(geomName, "MultiPoint");
Filter pointsFilter = filterService.createLogicFilter(pointFilter, "or", multiPointFilter);
pointRule.setFilter(filterService.createLogicFilter(pointsFilter, "and", filter));
pointRule.setTitle(featureStyle.getName() + "(Point)");
// add the configured filter to a filter that selects line features only
Rule lineRule = styleBuilder.createRule(createGeometrySymbolizer(LayerType.LINESTRING, featureStyle));
Filter lineFilter = filterService.createGeometryTypeFilter(geomName, "LineString");
Filter multiLineFilter = filterService.createGeometryTypeFilter(geomName, "MultiLineString");
Filter linesFilter = filterService.createLogicFilter(lineFilter, "or", multiLineFilter);
lineRule.setFilter(filterService.createLogicFilter(linesFilter, "and", filter));
lineRule.setTitle(featureStyle.getName() + "(Line)");
// add the configured filter to a filter that selects polygon features only
Rule polygonRule = styleBuilder.createRule(createGeometrySymbolizer(LayerType.POLYGON, featureStyle));
Filter polygonFilter = filterService.createGeometryTypeFilter(geomName, "Polygon");
Filter multiPolygonFilter = filterService.createGeometryTypeFilter(geomName, "MultiPolygon");
Filter polygonsFilter = filterService.createLogicFilter(polygonFilter, "or", multiPolygonFilter);
polygonRule.setFilter(filterService.createLogicFilter(polygonsFilter, "and", filter));
polygonRule.setTitle(featureStyle.getName() + "(Polygon)");
rules.add(pointRule);
rules.add(lineRule);
rules.add(polygonRule);
} else {
Rule rule = styleBuilder.createRule(createGeometrySymbolizer(layerType, featureStyle));
if (filter.equals(Filter.INCLUDE)) {
rule.setElseFilter(true);
} else {
rule.setFilter(filter);
}
rule.setTitle(featureStyle.getName());
rules.add(rule);
}
return rules;
}