use of org.polymap.core.style.model.feature.ConstantFilter in project polymap4-core by Polymap4.
the class FilterTest method visiblePoint.
@Test
public void visiblePoint() throws Exception {
FeatureStyle fs = repo.newFeatureStyle();
// point
PointStyle point = fs.members().createElement(PointStyle.defaults);
assertTrue(point.visibleIf.get() instanceof ConstantFilter);
point.visibleIf.createValue(initializeFilter(ff.equals(ff.property("prop"), ff.literal("literal"))));
point.diameter.createValue(ConstantNumber.defaults(23.0));
fs.store();
log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
org.geotools.styling.Style style = repo.serializedFeatureStyle(fs.id(), org.geotools.styling.Style.class).get();
Rule rule = style.featureTypeStyles().get(0).rules().get(0);
assertTrue(rule.getFilter() instanceof PropertyIsEqualTo);
PropertyIsEqualTo filter = (PropertyIsEqualTo) rule.getFilter();
assertTrue(filter.getExpression1() instanceof PropertyName);
assertEquals("prop", ((PropertyName) filter.getExpression1()).getPropertyName());
assertTrue(filter.getExpression2() instanceof Literal);
assertEquals("literal", ((Literal) filter.getExpression2()).getValue());
PointSymbolizer sym = (PointSymbolizer) rule.getSymbolizers()[0];
assertEquals(SLDSerializer2.ff.literal(23.0), sym.getGraphic().getSize());
}
use of org.polymap.core.style.model.feature.ConstantFilter in project polymap4-core by Polymap4.
the class StyleModelTest method testPolygon.
@Ignore
@Test
public void testPolygon() throws Exception {
FeatureStyle fs = repo.newFeatureStyle();
// point
PolygonStyle polygon = fs.members().createElement(PolygonStyle.defaults);
assertTrue(polygon.visibleIf.get() instanceof ConstantFilter);
polygon.fill.get().color.createValue(ConstantColor.defaults(1, 2, 3));
polygon.stroke.get().color.createValue(ConstantColor.defaults(100, 100, 100));
polygon.stroke.get().width.createValue(ConstantNumber.defaults(5.0));
polygon.stroke.get().opacity.createValue(FilterMappedPrimitives.defaults()).add(ff.equals(ff.literal(1), ff.literal(1)), 0.1).add(ff.equals(ff.literal(2), ff.literal(2)), 0.2);
polygon.stroke.get().strokeStyle.get().capStyle.createValue(ConstantStrokeCapStyle.defaults());
polygon.stroke.get().strokeStyle.get().dashStyle.createValue(ConstantStrokeDashStyle.defaults());
polygon.stroke.get().strokeStyle.get().joinStyle.createValue(ConstantStrokeJoinStyle.defaults());
fs.store();
log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
}
use of org.polymap.core.style.model.feature.ConstantFilter in project polymap4-core by Polymap4.
the class StyleModelTest method testSimplePolygon.
@Test
public void testSimplePolygon() throws Exception {
FeatureStyle fs = repo.newFeatureStyle();
PolygonStyle style = fs.members().createElement(PolygonStyle.defaults);
assertTrue(style.visibleIf.get() instanceof ConstantFilter);
style.fill.get().color.createValue(ConstantColor.defaults(0, 0, 0));
style.fill.get().opacity.createValue(ConstantNumber.defaults(0.0));
style.stroke.get().color.createValue(ConstantColor.defaults(100, 100, 100));
style.stroke.get().width.createValue(ConstantNumber.defaults(5.0));
style.stroke.get().opacity.createValue(ConstantNumber.defaults(0.5));
fs.store();
log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
Style result = repo.serializedFeatureStyle(fs.id(), Style.class).get();
assertEquals(1, result.featureTypeStyles().size());
FeatureTypeStyle fts = result.featureTypeStyles().get(0);
assertEquals(1, fts.rules().size());
Rule rule = fts.rules().get(0);
assertEquals(0, rule.getMinScaleDenominator(), 0);
assertEquals(Double.POSITIVE_INFINITY, rule.getMaxScaleDenominator(), 0);
assertEquals(1, rule.symbolizers().size());
assertNull(rule.getFilter());
PolygonSymbolizer polygon = (PolygonSymbolizer) rule.symbolizers().get(0);
assertEqualsLiteral(0.5, polygon.getStroke().getOpacity());
assertEqualsLiteral(5.0, polygon.getStroke().getWidth());
assertEqualsLiteral(0.0, polygon.getFill().getOpacity());
}
Aggregations