Search in sources :

Example 1 with ScaleRangeFilter

use of org.polymap.core.style.model.feature.ScaleRangeFilter in project polymap4-core by Polymap4.

the class StyleCompositeSerializer method defaultFeatureTypeStyle.

protected FeatureTypeStyle defaultFeatureTypeStyle(org.geotools.styling.Style result, Style style, Symbolizer... symbolizers) {
    Rule rule = sf.createRule();
    // handle visibleIf
    FilterStyleProperty visibleIf = (FilterStyleProperty) style.visibleIf.get();
    if (visibleIf instanceof ScaleRangeFilter) {
        rule.setMinScaleDenominator(((ScaleRangeFilter) visibleIf).minScale.get());
        rule.setMaxScaleDenominator(((ScaleRangeFilter) visibleIf).maxScale.get());
    } else if (visibleIf instanceof ConstantFilter) {
        Filter filter = ((ConstantFilter) visibleIf).filter();
        if (!filter.equals(Filter.INCLUDE)) {
            rule.setFilter(filter);
        }
    } else {
        throw new RuntimeException("Unhandled Style.visibleIf type: " + visibleIf.getClass());
    }
    for (Symbolizer s : symbolizers) {
        rule.symbolizers().add(s);
    }
    ;
    FeatureTypeStyle fts = sf.createFeatureTypeStyle();
    fts.rules().add(rule);
    result.featureTypeStyles().add(fts);
    return fts;
}
Also used : ScaleRangeFilter(org.polymap.core.style.model.feature.ScaleRangeFilter) ConstantFilter(org.polymap.core.style.model.feature.ConstantFilter) Filter(org.opengis.filter.Filter) FilterStyleProperty(org.polymap.core.style.model.feature.FilterStyleProperty) ConstantFilter(org.polymap.core.style.model.feature.ConstantFilter) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) Symbolizer(org.geotools.styling.Symbolizer) ScaleRangeFilter(org.polymap.core.style.model.feature.ScaleRangeFilter)

Aggregations

FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)1 Rule (org.geotools.styling.Rule)1 Symbolizer (org.geotools.styling.Symbolizer)1 Filter (org.opengis.filter.Filter)1 ConstantFilter (org.polymap.core.style.model.feature.ConstantFilter)1 FilterStyleProperty (org.polymap.core.style.model.feature.FilterStyleProperty)1 ScaleRangeFilter (org.polymap.core.style.model.feature.ScaleRangeFilter)1