public void testTextSymbolizerVendorParams() { TextSymbolizer textSymb = sf.createTextSymbolizer(); textSymb.getOptions().put("autoWrap", "100"); textSymb.accept(visitor); TextSymbolizer clone = (TextSymbolizer) visitor.getCopy(); assertCopy(textSymb, clone); assertEqualsContract(textSymb, clone); assertEquals(1, clone.getOptions().size()); assertEquals("100", clone.getOptions().get("autoWrap")); }
public void testRasterSymbolizerDuplication() { // create a default RasterSymbolizer RasterSymbolizer original = sb.createRasterSymbolizer(); // duplicate it original.accept(visitor); RasterSymbolizer copy = (RasterSymbolizer) visitor.getCopy(); // compare it assertNotNull(copy); assertEquals(original, copy); }
public void testExternalMark() throws URISyntaxException { OnLineResourceImpl or = new OnLineResourceImpl(); or.setLinkage(new URI("ttf://wingdings")); ExternalMark externalMark = sf.externalMark(or, "ttf", 15); Mark mark = sf.createMark(); mark.setExternalMark(externalMark); Mark clone = visitor.copy(mark); assertCopy(mark, clone); assertCopy(mark.getExternalMark(), clone.getExternalMark()); ExternalMark emCopy = clone.getExternalMark(); assertEquals("ttf", emCopy.getFormat()); assertEquals("ttf://wingdings", emCopy.getOnlineResource().getLinkage().toASCIIString()); assertEquals(15, emCopy.getMarkIndex()); }
public void testGraphic() { Graphic graphic = sf.getDefaultGraphic(); graphic.addMark(sf.getDefaultMark()); Graphic clone = (Graphic) visitor.copy(graphic); assertCopy(graphic, clone); assertEqualsContract(clone, graphic); assertEquals(clone.getSymbols().length, graphic.getSymbols().length); Graphic notEq = sf.getDefaultGraphic(); assertEqualsContract(clone, notEq, graphic); }
public void testPointSymbolizerWithGeomFunction() throws Exception { URL urlExternal = getClass().getResource("/data/sld/blob.gif"); ExternalGraphic extg = sb.createExternalGraphic(urlExternal, "image/svg+xml"); Graphic graphic = sb.createGraphic(extg, null, null); PointSymbolizer pointSymb = sb.createPointSymbolizer(graphic); // Set a function as geometry Function geomFunc = ff.function("centroid", ff.property("thr_geom")); pointSymb.setGeometry(geomFunc); pointSymb.accept(visitor); PointSymbolizer copy = (PointSymbolizer) visitor.getCopy(); assertEquals( "Any Expression set as Geometry must be correctly replicated", geomFunc, copy.getGeometry()); }
public void testPolygonSymbolizerWithGeometryFunction() { PolygonSymbolizer symb = sf.createPolygonSymbolizer(); // Set a function as geometry Function geomFunc = ff.function("centroid", ff.property("thr_geom")); symb.setGeometry(geomFunc); PolygonSymbolizer copy = (PolygonSymbolizer) visitor.copy(symb); // compare it assertEquals( "Any Expression set as Geometry must be correctly replicated", geomFunc, copy.getGeometry()); }
public void testTextSymbolizerWithGeometryFunction() { TextSymbolizer symb = sf.createTextSymbolizer(); // Set a function as geometry Function geomFunc = ff.function("centroid", ff.property("the_geom")); symb.setGeometry(geomFunc); TextSymbolizer copy = (TextSymbolizer) visitor.copy(symb); // compare it assertEquals( "Any Expression set as Geometry must be correctly replicated", geomFunc, copy.getGeometry()); }
public void testLineSymbolizerWithGeometryFunction() { LineSymbolizer lineSymb = sf.createLineSymbolizer(); // Set a function as geometry Function geomFunc = ff.function("centroid", ff.property("thr_geom")); lineSymb.setGeometry(geomFunc); LineSymbolizer copy = (LineSymbolizer) visitor.copy(lineSymb); // compare it assertEquals( "Any Expression set as Geometry must be correctly replicated", geomFunc, copy.getGeometry()); }
public void testContrastEnhancementDuplication() throws Exception { ContrastEnhancement ce = sf.createContrastEnhancement(); ce.setGammaValue(sb.literalExpression(0.5)); ce.setMethod(ContrastMethod.HISTOGRAM); ce.accept(visitor); ContrastEnhancement ce2 = (ContrastEnhancement) visitor.getCopy(); assertEquals( "Gamma value incorrest after duplication", ((Literal) ce.getGammaValue()).getValue(), ((Literal) ce2.getGammaValue()).getValue()); assertEquals( "ContrastMethod must be equal after duplication ", ce.getMethod(), ce2.getMethod()); }
public void testLineSymbolizerWithPerpendicularOffset() { LineSymbolizer ls = sf.createLineSymbolizer(); ls.setPerpendicularOffset(ff.literal(0.88)); // copy LineSymbolizer copy = (LineSymbolizer) visitor.copy(ls); // compare assertEquals( "PerpendicularOffset of LineSymbolizer has not been correctly duplicated", ls.getPerpendicularOffset(), copy.getPerpendicularOffset()); }
public void testColorMapEntryDuplication() throws Exception { ColorMapEntry cme = sf.createColorMapEntry(); cme.setColor(sb.colorExpression(Color.YELLOW)); cme.setLabel("thelabel"); cme.setQuantity(sb.literalExpression(66.66)); cme.setOpacity(sb.literalExpression(0.77)); cme.accept(visitor); ColorMapEntry cme2 = (ColorMapEntry) visitor.getCopy(); assertEquals( "Colormaps LABEL must be equal after duplication ", cme.getLabel(), cme2.getLabel()); assertEquals( "Colormaps QUANTITY must be equal after duplication ", cme.getQuantity(), cme2.getQuantity()); assertEquals( "Colormaps COLOR must be equal after duplication ", cme.getColor(), cme2.getColor()); assertEquals( "Colormaps OPACITY must be equal after duplication ", cme.getOpacity(), cme2.getOpacity()); }
public void testRasterSymbolizerDuplicationWithGeometryFunction() { // create a default RasterSymbolizer RasterSymbolizer original = sb.createRasterSymbolizer(); // Set a function as geometry Function geomFunc = ff.function("centroid", ff.property("thr_geom")); original.setGeometry(geomFunc); // duplicate it original.accept(visitor); RasterSymbolizer copy = (RasterSymbolizer) visitor.getCopy(); // compare it assertEquals( "Any Expression set as Geometry must be correctly replicated", geomFunc, copy.getGeometry()); }
public void testStyleDuplication() throws IllegalFilterException { // create a style Style oldStyle = sb.createStyle("FTSName", sf.createPolygonSymbolizer()); oldStyle.getFeatureTypeStyles()[0].setSemanticTypeIdentifiers( new String[] {"simple", "generic:geometry"}); // duplicate it oldStyle.accept(visitor); Style newStyle = (Style) visitor.getCopy(); // compare it assertNotNull(newStyle); assertEquals(2, newStyle.getFeatureTypeStyles()[0].getSemanticTypeIdentifiers().length); }
assertEquals( "Graphic of TextSymbolizer2 has not been correctly duplicated", gr, copy.getGraphic()); assertEquals( "Graphic of TextSymbolizer2 has not been correctly duplicated", gr.getOpacity(), copy.getGraphic().getOpacity()); assertEquals( "Graphic of TextSymbolizer2 has not been correctly duplicated", gr.getSize(), copy.getGraphic().getSize()); assertEquals( "Snippet of TextSymbolizer2 has not been correctly duplicated", snippet, copy.getSnippet()); assertEquals( "FeatureDescription of TextSymbolizer2 has not been correctly duplicated", fD, copy.getFeatureDescription()); assertEquals( "OtherText of TextSymbolizer2 has not been correctly duplicated", otherText.getTarget(), copy.getOtherText().getTarget()); assertEquals( "OtherText of TextSymbolizer2 has not been correctly duplicated", otherText.getText(),
/** * Test SelectedChannelType copy with Expression * * @throws Exception */ @Test public void testSelectedChannelTypeDuplication() throws Exception { final String b1 = "b1"; SelectedChannelType sct = sf.createSelectedChannelType( ff.function("env", ff.literal(b1), ff.literal("1")), sf.createContrastEnhancement()); sct.accept(visitor); SelectedChannelType clone = (SelectedChannelType) visitor.getCopy(); assertEquals(sct, clone); } }
public void testRasterSymbolizerWithOverlapBehavior() throws Exception { RasterSymbolizer rasterSymb1 = sf.createRasterSymbolizer(); rasterSymb1.setOverlapBehavior(OverlapBehavior.AVERAGE); rasterSymb1.accept(visitor); RasterSymbolizer clone1 = (RasterSymbolizer) visitor.getCopy(); assertEquals(clone1.getOverlapBehavior(), rasterSymb1.getOverlapBehavior()); // Try literal expression RasterSymbolizer rasterSymbLiteral = sf.createRasterSymbolizer(); rasterSymbLiteral.setOverlap(ff.literal(OverlapBehavior.EARLIEST_ON_TOP.toString())); rasterSymbLiteral.accept(visitor); RasterSymbolizer cloneLiteral = (RasterSymbolizer) visitor.getCopy(); assertEquals(cloneLiteral.getOverlapBehavior(), rasterSymbLiteral.getOverlapBehavior()); assertEquals(cloneLiteral.getOverlap(), rasterSymbLiteral.getOverlap()); // Try with invalid expression string RasterSymbolizer rasterSymb3 = sf.createRasterSymbolizer(); try { rasterSymb3.setOverlap(ff.literal("invalid string")); } catch (IllegalArgumentException e) { // Expected result } catch (Exception e) { fail(); } // Compare rastersymbolizer overlap behaviour RasterSymbolizer notEq = sf.createRasterSymbolizer(); assertFalse(Utilities.equals(notEq.getOverlapBehavior(), rasterSymb1.getOverlapBehavior())); }
public void testRasterSymbolizerWithUOM() throws Exception { RasterSymbolizer rasterSymb = sf.createRasterSymbolizer(); rasterSymb.setUnitOfMeasure(UomOgcMapping.FOOT.getUnit()); rasterSymb.accept(visitor); RasterSymbolizer clone = (RasterSymbolizer) visitor.getCopy(); assertEquals(clone.getUnitOfMeasure(), rasterSymb.getUnitOfMeasure()); RasterSymbolizer notEq = sf.createRasterSymbolizer(); assertFalse(Utilities.equals(notEq.getUnitOfMeasure(), rasterSymb.getUnitOfMeasure())); }