[OpenLayers-Users] Adding new features: WFS-T PostGIS

Juan Arévalo arevaco90 at yahoo.es
Thu Aug 20 16:29:05 EDT 2009


Hi all,

In case that someone is stuck with the same problem that I had I attached
the code that works for me.

By the way, Can anyone point me to some examples using a web form to enter
and modify attributes store in a PostGIS DB via WFS-T?

Thanks for your help!


//WFS Layer

wfs3 = new OpenLayers.Layer.WFS(
                "Same Water Points",
                "http://localhost:8080/geoserver/wfs",
                {typename: 'cite:water_points'},
                {
                    typename: "water_points",
                    featureNS: "http://www.opengeospatial.net/cite",
                    extractAttributes: false,
                    commitReport: function(str) {
                        OpenLayers.Console.log(str);
                    }
                }
            );
	
		var saveStrategy = new OpenLayers.Strategy.Save({ 
       callback: function() { 
           alert('feature saved'); 
       } 
   }); 
	
map.addLayers([wfs3]);


//BUTTONS:

var panel = new OpenLayers.Control.Panel({
                displayClass: "olControlEditingToolbar"
            });
			
            var draw = new OpenLayers.Control.DrawFeature(
                wfs3, OpenLayers.Handler.Point,
                {
                    handlerOptions: {freehand: false, multi: true},
                    displayClass: "olControlDrawFeaturePoint"
                }
            );
            
			var modify = new OpenLayers.Control.ModifyFeature(wfs3, {
                title: "Modify Feature",
				displayClass: "olControlModifyFeature"
				});
                
			 var del = new DeleteFeature(wfs3, {title: "Delete Feature"});
	
				
			 var save = new OpenLayers.Control.Button({
                trigger: OpenLayers.Function.bind(wfs3.commit, wfs3),
                displayClass: "olControlEditingToolbar",
				title: "Guardar"
            });

			
			       
            panel.addControls([
                new OpenLayers.Control.Navigation(),
                save, del, modify, draw
            ]);

            map.addControl(panel);



Juan Arévalo wrote:
> 
> Hi All,
> I am trying to set up a WFS-T using Geoserver 1.7.6 and PostGres 8.4. I
> have tried with the following code in order to insert new features: 
> 
> 
> 
> //WFS LAYER:
> 
> wfs = new OpenLayers.Layer.WFS(
> 			
> 				"Cities",
> 				"http://localhost:8080/geoserver/wfs",
> 				{typename: 'cite:ciudades'},
> 				{featureNS: 'http://www.opengeospatial.net/cite',
> 				srsName:            'EPSG:4326', 
> 				version: "1.0.0",
> 
> 				//schema:
> "http://localhost:8080/geoserver/wfs?request=GetFeature&typeName=ciudades&outputformat=text/xml;%20subtype=gml/3.1.1",
> 				//schema:
> "http://localhost:8080/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=cite:ciudades",			  
> 				schema:  
> "http://127.0.0.1:8080/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=cite:ciudades",
> 				extractAttributes: true});
> 				wfs.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
> 
>                OpenLayers.Feature.Vector.style["default"]);
> 
> //SAVE BUTTON:
> 
> var save = new OpenLayers.Control.Button({
>                 trigger: OpenLayers.Function.bind(wfs.commit, wfs),
>                 displayClass: "olControlSaveFeatures"
>             });
> 
> 
> 
> When I click the save button I got this error:
> 
> 
> 
> WFS Transaction: FAILED <?xml version="1.0" ?>
> 
> <ServiceExceptionReport
> 
>    version="1.2.0"
> 
>    xmlns="http://www.opengis.net/ogc"
> 
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 
>    xsi:schemaLocation="http://www.opengis.net/ogc
> http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
> 
>    <ServiceException>
> 
>       Feature type &apos;featureMember&apos; is not available: 
> 
> </ServiceException></ServiceExceptionReport>
> 
> 
> 
> The geoserver log is as follow:
> 
> 
> 
> 2009-08-19 20:57:35,500 ERROR [geoserver.ows] - 
> org.geoserver.wfs.WFSTransactionException: Feature type 'featureMember' is
> not available: 
> 	at org.geoserver.wfs.Transaction.execute(Transaction.java:222)
> 	at org.geoserver.wfs.Transaction.transaction(Transaction.java:108)
> 	at
> org.geoserver.wfs.DefaultWebFeatureService.transaction(DefaultWebFeatureService.java:182)
> (...)
> 
> 
> 
> Does anyone have any idea on how to solve this issue?
> 
> It would be great if you can provide me with some working examples..
> 
> Thanks:)-
> 
> Juan
> 

-- 
View this message in context: http://n2.nabble.com/Adding-new-features-WFS-T-PostGIS-tp3474825p3481528.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list