Skip to content

Commit

Permalink
[GEOT-4384] SE 1.1 graphic fill is not being parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Feb 3, 2013
1 parent 5fb2a16 commit 5fe31af
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Expand Up @@ -144,6 +144,9 @@ public Object parse(ElementInstance instance, Node node, Object value)
if (opacity != null) {
fill.setOpacity(opacity);
}
if(graphicFill != null) {
fill.setGraphicFill(graphicFill);
}

return fill;
}
Expand Down
Expand Up @@ -16,15 +16,20 @@
*/
package org.geotools.sld.v1_1;

import java.io.InputStream;
import java.net.URI;

import junit.framework.TestCase;

import org.geotools.styling.FeatureTypeStyle;
import org.geotools.styling.Graphic;
import org.geotools.styling.NamedLayer;
import org.geotools.styling.PolygonSymbolizer;
import org.geotools.styling.Rule;
import org.geotools.styling.Style;
import org.geotools.styling.StyledLayerDescriptor;
import org.geotools.xml.Parser;
import org.opengis.style.ExternalGraphic;

/**
*
Expand Down Expand Up @@ -89,8 +94,20 @@ public void testParseSLD() throws Exception {
PolygonSymbolizer sym = (PolygonSymbolizer) r.symbolizers().get(0);
}

public void testParseGraphicFill() throws Exception {
StyledLayerDescriptor sld = (StyledLayerDescriptor) parse("../graphicFill.xml");
NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
PolygonSymbolizer ps = (PolygonSymbolizer) layer.getStyles()[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
Graphic graphicFill = ps.getFill().getGraphicFill();
assertNotNull(graphicFill);
ExternalGraphic eg = (ExternalGraphic) graphicFill.graphicalSymbols().get(0);
assertEquals(new URI("http://maps.google.com/mapfiles/kml/pal2/icon4.png"), eg.getOnlineResource().getLinkage());

}

Object parse(String filename) throws Exception {
SLDConfiguration sld = new SLDConfiguration();
return new Parser(sld).parse(getClass().getResourceAsStream(filename));
InputStream location = getClass().getResourceAsStream(filename);
return new Parser(sld).parse(location);
}
}
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.1.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:se="http://www.opengis.net/se"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<se:Name>oge:natural</se:Name>
<UserStyle>
<se:FeatureTypeStyle>
<se:Rule>
<se:PolygonSymbolizer>
<se:Fill>
<se:GraphicFill>
<se:Graphic>
<se:ExternalGraphic>
<se:OnlineResource xlink:type="simple" xlink:href="http://maps.google.com/mapfiles/kml/pal2/icon4.png"/>
<se:Format>image/png</se:Format>
</se:ExternalGraphic>
<se:Size>20</se:Size>
</se:Graphic>
</se:GraphicFill>
</se:Fill>
</se:PolygonSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

0 comments on commit 5fe31af

Please sign in to comment.