21 June 2010

How to built save feature for WFS?

Dear All:
I try to built my own WFS server , I have Featureserver + mod_python +postgis on my local pc.
If I use OpenLayers.Control.ModifyFeature(wfs) method, how can I catch the modified feature and post it to FS?
I try to collect all features from wfs layer, and send it back to featureserver. it doesn't work.
I have already try some example from OL examples . and I could not find a lot of information about it in ol maillinglist.
It would be thanksful that somebody can point out where I should go.
Here is some code from my:

            drawControls = {
                    point: new OpenLayers.Control.DrawFeature(vectors,
                    line: new OpenLayers.Control.DrawFeature(vectors,
                    polygon: new OpenLayers.Control.DrawFeature(vectors,
                    editPolygon:new OpenLayers.Control.ModifyFeature(wfs, {
                        title: "Modify polygon"}))

var arr = [];
            var j = 0;
            for(var i =0; i<wfs.features.length;i++){
                if(wfs.features[i].gml.featureType == "polygon"){
                    arr[j] = wfs2.features[i];
            json = geojson.write(arr);

            new OpenLayers.Ajax.Request(url,
                     {   method: 'post',
                         postBody: json,
                         requestHeaders: ['Accept', 'application/json'],
                         onSuccess: success,
                         onFailure: function(xhr) {
                           $('info').innerHTML = "Failed upload (status code "+xhr.status+"). Check your URL."

all the best


No comments: