@Test public void testLineOffset() throws Exception { // See GEOT-3912 String yaml = "line:\n" + " stroke-color: '#555555'\n" + " stroke-width: 1.0\n" + " offset: 5"; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer l = SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(l.getPerpendicularOffset(), is(literal(5))); // SLD/SE 1.1 feature that may not be supported by renderer }
@Test public void testMultiplyCompositeBaseOnSymbolizer() throws Exception { String yaml = "line:\n" + " x-composite-base: true\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("options", hasEntry("composite-base", "true"))); }
@Test public void testMultiplyCompositeOnSymbolizer() throws Exception { String yaml = "line:\n" + " x-composite: multiply\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("options", hasEntry("composite", "multiply"))); }
@Test public void testUomFoot() throws Exception { String yaml = "line:\n" + " uom: foot\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.FOOT.getUnit()))); }
@Test public void testUomPixel() throws Exception { String yaml = "line:\n" + " uom: pixel\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.PIXEL.getUnit()))); }
@Test public void testUomMetre() throws Exception { String yaml = "line:\n" + " uom: metre\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.METRE.getUnit()))); }
@Test public void testUomSymbol() throws Exception { String yaml = "line:\n" + " uom: m\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.METRE.getUnit()))); }
@Test public void testStrokeLinejoinDefault() throws Exception { String yaml = "line:\n" + " stroke-color: \"#ff0000\"\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("stroke", hasProperty("lineJoin", literal("miter")))); }
@Test public void testStrokeLinejoinBevel() throws Exception { String yaml = "line:\n" + " stroke-linejoin: bevel\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("stroke", hasProperty("lineJoin", literal("bevel")))); }
@Test public void testStrokeLinejoinMitre() throws Exception { String yaml = "line:\n" + " stroke-linejoin: mitre\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("stroke", hasProperty("lineJoin", literal("mitre")))); }
@Test public void testUomAmerican() throws Exception { String yaml = "line:\n" + " uom: meter\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.METRE.getUnit()))); }
@Test public void testLineSimple() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Simple Line</Title> // <FeatureTypeStyle> // <Rule> // <LineSymbolizer> // <Stroke> // <CssParameter name="stroke">#000000</CssParameter> // <CssParameter name="stroke-width">3</CssParameter> // </Stroke> // </LineSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("line", "simple.sld"); LineSymbolizer line = SLD.lineSymbolizer(style); assertEquals(Color.black, SLD.lineColor(line)); assertEquals(3, SLD.lineWidth(line)); }
@Test public void testUomSEURL() throws Exception { String yaml = "line:\n" + " uom: " + UomOgcMapping.FOOT.getSEString() + "\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("unitOfMeasure", sameInstance(UomOgcMapping.FOOT.getUnit()))); }
LineSymbolizer line = SLD.lineSymbolizer(style); assertEquals(Color.red, SLD.color(line));
LineSymbolizer line = SLD.lineSymbolizer(featureStyle); line = SLD.lineSymbolizer(featureStyle);
@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testStrokeGraphicFill() throws Exception { String yaml = "line:\n" + " stroke-graphic-fill:\n" + " symbols:\n" + " - mark:\n" + " shape: circle\n" + " fill-color: '#995555'\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("stroke", hasProperty("graphicFill"))); Graphic g = p.getStroke().getGraphicFill(); List<GraphicalSymbol> symbols = g.graphicalSymbols(); ((Mark) symbols.get(0)).getFill().getColor(); assertThat( symbols, (Matcher) hasItems( allOf( instanceOf(Mark.class), hasProperty("wellKnownName", literal("circle")), hasProperty( "fill", hasProperty( "color", literal(isColor("995555"))))))); }
@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testStrokeGraphic() throws Exception { String yaml = "line:\n" + " stroke-graphic:\n" + " symbols:\n" + " - mark:\n" + " shape: circle\n" + " fill-color: '#995555'\n" + ""; StyledLayerDescriptor sld = Ysld.parse(yaml); LineSymbolizer p = (LineSymbolizer) SLD.lineSymbolizer(SLD.defaultStyle(sld)); assertThat(p, hasProperty("stroke", hasProperty("graphicStroke"))); Graphic g = p.getStroke().getGraphicStroke(); List<GraphicalSymbol> symbols = g.graphicalSymbols(); ((Mark) symbols.get(0)).getFill().getColor(); assertThat( symbols, (Matcher) hasItems( allOf( instanceOf(Mark.class), hasProperty("wellKnownName", literal("circle")), hasProperty( "fill", hasProperty( "color", literal(isColor("995555"))))))); }
@Test public void testLineWithDashedline() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Dashed line</Title> // <FeatureTypeStyle> // <Rule> // <LineSymbolizer> // <Stroke> // <CssParameter name="stroke">#0000FF</CssParameter> // <CssParameter name="stroke-width">3</CssParameter> // <CssParameter name="stroke-dasharray">5 2</CssParameter> // </Stroke> // </LineSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("line", "dashed-line.sld"); LineSymbolizer line = SLD.lineSymbolizer(style); assertEquals(Color.blue, SLD.color(line)); assertEquals(3, SLD.width(line)); assertEquals(5f, SLD.lineDash(line)[0], 0.1); assertEquals(2f, SLD.lineDash(line)[1], 0.1); }
@Test public void testLineWithDefaultLabel() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Line with default label</Title> // <FeatureTypeStyle> // <Rule> // <LineSymbolizer> // <Stroke> // <CssParameter name="stroke">#FF0000</CssParameter> // </Stroke> // </LineSymbolizer> // <TextSymbolizer> // <Label> // <ogc:PropertyName>name</ogc:PropertyName> // </Label> // <Font /> // <Fill> // <CssParameter name="fill">#000000</CssParameter> // </Fill> // </TextSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("line", "default-label.sld"); LineSymbolizer line = SLD.lineSymbolizer(style); assertEquals(Color.red, SLD.color(line)); TextSymbolizer text = SLD.textSymbolizer(style); assertEquals("name", SLD.textLabelString(text)); assertEquals(Color.black, SLD.color(text.getFill())); }
LineSymbolizer line = SLD.lineSymbolizer(style); assertEquals(4f, SLD.lineDash(line)[0], 0.1); assertEquals(6f, SLD.lineDash(line)[1], 0.1);