Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm experimenting with a simple web mapping service build on PostGIS/GeoServer/OpenLayers stack on Win 2008 Server.

I overlay vector layer from PostGIS using:

var Index1v = new OpenLayers.Layer.Vector("Index1 v", {
    strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: new OpenLayers.Protocol.WFS({
            version: "1.1.0",
            url: "http://localhost:1979/geoserver/wfs",
            featureType: "bern_poly_s100",
            featureNS: "http://www.ispm.ch",
            srsName: "EPSG:900913"
        })
});

Layer displays correctly, but in plain, default[?] style from GeoServer.

I've got a SLD style file build with uDig and it seems to be correct since WMS service is using it without any problems. Can I use it to style WFS layer as well?

share|improve this question
add comment

4 Answers 4

up vote 6 down vote accepted

Take a look at OL's SLD.html example. They use SLD to style GML, but should work for WFS (a vector layer) as well.

Credit: OL's Nabble.com forum

share|improve this answer
    
That's cool - I didn't know you could do that. –  iant Dec 8 '10 at 19:46
    
I've never used it but I thought I saw it somewhere before, so had to research the good old trusty Nabble.com forum. However lets keep filling out the SO GIS board as well. –  Vadim Dec 8 '10 at 19:51
2  
But in a way you're right that you're still responsible for styling it on the client, right? It's not on the server. But you can style with a pre-made SLD on the client. –  Vadim Dec 8 '10 at 19:52
add comment

Short answer is no - WFS sends you the data and then you are responsible for styling it in the client. OpenLayers uses a stylemap to style a vector layer. See http://docs.openlayers.org/library/feature_styling.html for details of how to style a vector layer.

share|improve this answer
    
Thanks. That's what I was afraid of. –  radek Dec 8 '10 at 18:02
add comment

Yes, you could load the wfs-layer into openlayers, then parse the sld-file into an openlayers-stylemap, and apply it to the wfs-layer.

Alternatively, you could attach the sld to the geoserver-wfs-layer as the default sld. Then load the wfs-layer into openlayers and specify an image-format (e.g. image/png or image/jpeg) in the request parameter. Once loaded, store it as an Openlayers.Layer.WMS-object. This will render the layer as a raster layer with the attached sld already applied by geoserver.

share|improve this answer
add comment

The OGC definition for sld say that is for WMS

The OpenGIS® Styled Layer Descriptor (SLD) Profile of the OpenGIS® Web Map Service (WMS) Encoding Standard

so !

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.