Search in sources :

Example 16 with MutableRule

use of org.geotoolkit.style.MutableRule in project geotoolkit by Geomatys.

the class MapfileToSLDProcess method convert.

private void convert(final MutableStyledLayerDescriptor sld, final Feature feature) throws ProcessException {
    final Collection<Feature> layers = (Collection<Feature>) feature.getPropertyValue(MAP_LAYER.toString());
    for (final Feature mflayer : layers) {
        // create an sld layer
        final MutableNamedLayer sldLayer = SLDF.createNamedLayer();
        sld.layers().add(sldLayer);
        final String name = String.valueOf(mflayer.getPropertyValue(LAYER_NAME.toString()));
        sldLayer.setName(name);
        sldLayer.setDescription(SF.description(name, name));
        // create the style
        final MutableStyle sldStyle = SF.style();
        sldLayer.styles().add(sldStyle);
        final MutableFeatureTypeStyle fts = SF.featureTypeStyle();
        sldStyle.featureTypeStyles().add(fts);
        final Double minscale = (Double) mflayer.getPropertyValue(LAYER_MINSCALEDENOM.toString());
        final Double maxscale = (Double) mflayer.getPropertyValue(LAYER_MAXSCALEDENOM.toString());
        final Collection<Feature> classes = (Collection<Feature>) mflayer.getPropertyValue(LAYER_CLASS.toString());
        for (final Feature clazz : classes) {
            final MutableRule rule = createRule(mflayer, minscale, maxscale, clazz);
            fts.rules().add(rule);
        }
    }
}
Also used : MutableRule(org.geotoolkit.style.MutableRule) MutableStyle(org.geotoolkit.style.MutableStyle) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) Collection(java.util.Collection) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) Feature(org.opengis.feature.Feature)

Example 17 with MutableRule

use of org.geotoolkit.style.MutableRule in project geotoolkit by Geomatys.

the class Styles method scaleRule.

// ////////////////////////////////////////////////////////////////////
// RULES /////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
public static MutableStyle scaleRule() {
    final MutableRule over = SF.rule();
    over.setMinScaleDenominator(1000000);
    over.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.RED), null));
    final MutableRule under = SF.rule();
    under.setMaxScaleDenominator(1000000);
    under.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.GREEN), null));
    final MutableStyle style = SF.style();
    final MutableFeatureTypeStyle fts = SF.featureTypeStyle();
    fts.rules().add(over);
    fts.rules().add(under);
    style.featureTypeStyles().add(fts);
    return style;
}
Also used : MutableRule(org.geotoolkit.style.MutableRule) MutableStyle(org.geotoolkit.style.MutableStyle) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle)

Example 18 with MutableRule

use of org.geotoolkit.style.MutableRule in project geotoolkit by Geomatys.

the class Styles method filterRule.

public static MutableStyle filterRule() {
    final MutableRule over = SF.rule();
    over.setFilter(FF.greaterOrEqual(FF.property("POP_CNTRY"), FF.literal(5000000)));
    over.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.RED), null));
    final MutableRule under = SF.rule();
    under.setFilter(FF.less(FF.property("POP_CNTRY"), FF.literal(5000000)));
    under.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.GREEN), null));
    final MutableStyle style = SF.style();
    final MutableFeatureTypeStyle fts = SF.featureTypeStyle();
    fts.rules().add(over);
    fts.rules().add(under);
    style.featureTypeStyles().add(fts);
    return style;
}
Also used : MutableRule(org.geotoolkit.style.MutableRule) MutableStyle(org.geotoolkit.style.MutableStyle) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle)

Aggregations

MutableRule (org.geotoolkit.style.MutableRule)18 MutableFeatureTypeStyle (org.geotoolkit.style.MutableFeatureTypeStyle)8 Symbolizer (org.opengis.style.Symbolizer)7 MutableStyle (org.geotoolkit.style.MutableStyle)6 Feature (org.opengis.feature.Feature)5 Expression (org.opengis.filter.Expression)5 Filter (org.opengis.filter.Filter)5 Rule (org.opengis.style.Rule)5 ArrayList (java.util.ArrayList)4 LineSymbolizer (org.opengis.style.LineSymbolizer)4 PointSymbolizer (org.opengis.style.PointSymbolizer)4 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)4 List (java.util.List)3 FeatureType (org.opengis.feature.FeatureType)3 ValueReference (org.opengis.filter.ValueReference)3 FeatureTypeStyle (org.opengis.style.FeatureTypeStyle)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 JAXBElement (javax.xml.bind.JAXBElement)2