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 can't get the Openlayers and Geoserver work with WFS-T editing a vector layer.

I have a layer of points where the Native SRS is EPSG:32639.

After trying a lot of combinations, I ended up with two not working solutions.

1) a. On the server I set 'Declared SRS' to EPSG:32639 and make SRS hadling 'Force declared'. b. In Openlayers i set projection: new OpenLayers.Projection("EPSG:32639") for the layer.

it submits

<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326"<gml:coordinates decimal="." cs="," ts=" ">241602.05063766203,4958072.672210057</gml:coordinates>

and gets

'PointOutsideEnvelopeException: 241602.05063766203 outside of (-180.0,180.0)'

2) a. On the server I set 'Declared SRS' to EPSG:4326 and make SRS hadling 'Reproject native to declared'. b. In Openlayers i set projection: new OpenLayers.Projection("EPSG:4326") for the layer.

it successfully commits my changes to the database, but the coordinates in the database are wrong - degrees as for 4326 instead of meters of 32639.

The Firebug shows that it submits degrees.

I have proj4js enabled on the client side.

Any other combination including playing with 'displayProjection' of the map leads to not even displaying the points of my layer on the map.

Seems like Openlayers tells projection 4326 all the time AND the geoserver is unable to reproject the coordinates when receiving them from the client.

On the server, I tried unsetting Services / WFS / GML2 / Override GML Attributes checkbox with no success.

I am in a dead end, please help.

Some code snippets:

        Proj4js.defs["EPSG:32639"] = "+proj=utm +zone=39 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";


            new OpenLayers.Layer.Vector('Wells', {
                isBaseLayer: false,
                defaultLabelField: 'NAME',
                strategies: [new OpenLayers.Strategy.BBOX(), config.saveStrategy],
                protocol: new OpenLayers.Protocol.WFS({
                    url: config.vectorWfs,
                    featureType: "Wells_PRS",
                    featureNS: "http://gisxxxx",
                    geometryName: "GEOM"
                }),
                schema: config.vectorWfs + "/DescribeFeatureType?version=1.1.0&typename=gisxxxx:Wells_PRS"
                //,projection: new OpenLayers.Projection("EPSG:4326")
                ,version: "1.1.0"
                ,projection: new OpenLayers.Projection("EPSG:32639")
            }), 







            th.map = new OpenLayers.Map(th.body.dom.id, {
                controls: [
                    new OpenLayers.Control.Navigation(),
                    new OpenLayers.Control.PanZoom(),
                    new OpenLayers.Control.LayerSwitcher(),
                    new OpenLayers.Control.ArgParser(),
                    new OpenLayers.Control.Attribution()
                    ,
                    new OpenLayers.Control.MousePosition(
                        {div:document.getElementById("coordinates")}) 
                ],
                layers: layers
                //, displayProjection: new OpenLayers.Projection("EPSG:4326")
                //projection: new OpenLayers.Projection("EPSG:4326")
            });

            var editingBar = new OpenLayers.Control.EditingToolbar(layers[2]);
            var save = new OpenLayers.Control.Button({
                title: "Save Changes",
                trigger: function() {
                    //if(edit.feature) {
                    //    edit.selectControl.unselectAll();
                    //}
                    config.saveStrategy.save();
                // alert('saved');
                }//,
                //displayClass: "olControlSaveFeatures"
            });
            editingBar.addControls([
                save, 
                new config.DeleteFeature(layers[2], {title: "Delete Feature"})
            ]);
            th.map.addControl(editingBar);

This all done reading this link:

http://www.gistutor.com/openlayers/22-advanced-openlayers-tutorials/47-openlayers-wfs-t-using-a-geoserver-hosted-postgis-layer.html

share|improve this question
    
What projection is your baselayer in? I suspect 4326 and that is overriding what is set in the vector layer. Step 2 above will never work as your are just lying to the server and it will get confused. –  iant May 31 '12 at 9:20
    
The baselayer is in 4326; if I comment out the projection 32639 in the layer settings (on the client side), it doesn't display any points. I guess it's a command to reproject points on the client –  fedd May 31 '12 at 9:43
1  
you need to add a baselayer that is in 32639 or explicitly reproject the points you are sending to GeoServer –  iant May 31 '12 at 11:54
    
thanks! what function or event haldler would be the best place to do it? –  fedd May 31 '12 at 11:58
add comment

1 Answer

up vote 2 down vote accepted

On the protocol definition, you need to set srsName:

        new OpenLayers.Layer.Vector('Wells', {
            strategies: [new OpenLayers.Strategy.BBOX(), config.saveStrategy],
            protocol: new OpenLayers.Protocol.WFS({
                url: config.vectorWfs,
                featureType: "Wells_PRS",
                featureNS: "http://gisxxxx",
                geometryName: "GEOM",
                srsName: 'EPSG:4326'
            }),
            version: "1.1.0"
        }),

You do not need proj4js.

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.