Hello,
I am using an ExternalGraphicFactory that returns an ImageIcon to display symbols for surface observations in GeoServer, and so I have registered my class in GeoTools with the META-INF/services/org.geotools.renderer.style.ExternalGraphicFactory file. The problem is, any SLD containing such custom URLs won't validate due to "not a valid 'anyURI' value", and when a layer with such an SLD is viewed, rather than handing the href to my Factory, GeoServer has an error:
15 Jan 01:54:09 ERROR [geoserver.ows] -
java.lang.RuntimeException: Errors while inspecting the location of an external graphic
...
Caused by: java.net.MalformedURLException: unknown protocol: sfcobs
at java.net.URL.<init>(URL.java:574)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at org.geotools.styling.ExternalGraphicImpl.getLocation(ExternalGraphicImpl.java:65)
at org.geotools.styling.StyleAttributeExtractor.visit(StyleAttributeExtractor.java:446)
... 65 more
I checked the mailing list, and there doesn't seem to be a lot of discussion of the ExternalGraphicFactory system.
Here's a small SLD example; the URL looks like sfcobs://vv={$obs_vv} , where ${obs_vv} comes from the Feature.
<sld:StyledLayerDescriptor version="1.0.0" xmlns:gml="http://www.opengis.net/gml"
xmlns:ows="http://www.opengis.net/ows" xmlns:sld="http://www.opengis.net/sld"
xmlns:wms="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/ows http://sun420:8888/geoserver/schemas/sld/GetMap.xsd">
<sld:NamedLayer>
<sld:Name>Not working</sld:Name>
<UserStyle xmlns="http://www.opengis.net/sld">
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<sld:Graphic>
<sld:ExternalGraphic>
<sld:OnlineResource
xlink:href="sfcobs://vv=${obs_vv}"/>
<Format>image/png</Format>
</sld:ExternalGraphic>
<sld:Size>15.0</sld:Size>
</sld:Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</sld:NamedLayer>
</sld:StyledLayerDescriptor>
This seems close to the example SLD on http://geotools.codehaus.org/Dynamic+SLD+Graphic+objects .
Has anyone got a Factory to work with such non-standard URLs?
--
Nissim Chudnoff