use of org.polymap.core.style.model.feature.PointStyle in project polymap4-core by Polymap4.
the class StyleModelTest method propertyMappedColors.
@Ignore
@Test
public void propertyMappedColors() {
FeatureStyle fs = repo.newFeatureStyle();
// point
PointStyle point = fs.members().createElement(PointStyle.defaults);
point.diameter.createValue(ConstantNumber.defaults(5.0));
point.fill.get().color.createValue(new ValueInitializer<FilterMappedColors>() {
@Override
public FilterMappedColors initialize(FilterMappedColors proto) throws Exception {
proto.add(ff.equals(ff.property("foo"), ff.literal("big")), new Color(255, 0, 0));
proto.add(ff.equals(ff.property("foo"), ff.literal("bigger")), new Color(0, 0, 255));
proto.add(ff.and(ff.notEqual(ff.property("foo"), ff.literal("big")), ff.notEqual(ff.property("foo"), ff.literal("bigger"))), new Color(0, 0, 255));
return proto;
}
});
fs.store();
log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
Style style = repo.serializedFeatureStyle(fs.id(), Style.class, OutputFormat.GEOSERVER).get();
List<FeatureTypeStyle> featureTypeStyles = style.featureTypeStyles();
assertEquals(1, featureTypeStyles.size());
assertEquals(Filter.INCLUDE, featureTypeStyles.get(0).rules().get(0).getFilter());
log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class, OutputFormat.OGC));
style = repo.serializedFeatureStyle(fs.id(), Style.class, OutputFormat.OGC).get();
featureTypeStyles = style.featureTypeStyles();
assertEquals(1, featureTypeStyles.size());
assertEquals("[ foo = big ]", featureTypeStyles.get(0).rules().get(0).getFilter().toString());
assertEquals("[ foo = bigger ]", featureTypeStyles.get(0).rules().get(1).getFilter().toString());
assertEquals("[[ foo != big ] AND [ foo != bigger ]]", featureTypeStyles.get(0).rules().get(2).getFilter().toString());
}
use of org.polymap.core.style.model.feature.PointStyle in project polymap4-core by Polymap4.
the class StyleModelTest method testScaleMappedNumbers.
@Test
public void testScaleMappedNumbers() throws Exception {
FeatureStyle fs = repo.newFeatureStyle();
PointStyle point = fs.members().createElement(PointStyle.defaults);
point.diameter.createValue(ScaleMappedPrimitives.defaults()).add(0, 1, new Double(1)).add(1, 2, new Double(2)).add(2, Double.POSITIVE_INFINITY, new Double(3));
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(3, fts.rules().size());
assertEqualsLiteral(1.0, ((PointSymbolizer) fts.rules().get(0).symbolizers().get(0)).getGraphic().getSize());
assertEqualsLiteral(2.0, ((PointSymbolizer) fts.rules().get(1).symbolizers().get(0)).getGraphic().getSize());
assertEqualsLiteral(3.0, ((PointSymbolizer) fts.rules().get(2).symbolizers().get(0)).getGraphic().getSize());
}
Aggregations