6

I tried following the tutorials: http://www.gistutor.com/openlayers/22-advanced-openlayers-tutorials/47-openlayers-wfs-t-using-a-geoserver-hosted-postgis-layer.html and: http://apps.who.int/tools/geoserver/www/wfs-t.html

With the following results:

  • the delete-function works, ergo I am able to alter my data in the postgres file.
  • when inserting or editing a polygon I always get the answer:
<wfs:FAILED></wfs:FAILED> </wfs:Status> <wfs:Message>Error performing insert: Error inserting features</wfs:Message>

or

<wfs:InsertResult>
<ogc:FeatureId fid="none"></ogc:FeatureId>
</wfs:InsertResult>
<wfs:TransactionResult>
<wfs:Status>
<wfs:FAILED></wfs:FAILED>
</wfs:Status>
<wfs:Message>Update error: Error occured updating features</wfs:Message>

I made a simple file, using only one kind of projection (EPSG:32647)- still, same problem. Where do I go wrong?!

My Postgres Data-Table:

  • gid - Integer, not null
  • fid - double precision
  • geom - geometry(MultiPolygon,32647)

Here is my code:

function init(){
//Save-strategy
var saveStrategy = new OpenLayers.Strategy.Save();
//empty map, bounds are test-layer bounds (EPSG:32647) 
map = new OpenLayers.Map({
 div: "map",
 allOverlays: true,
 maxExtent: new OpenLayers.Bounds(
 653237.69439077,1519879.063165,655229.57939001,1520825.6733868
 )
 });
//WFS-Layer Test= editable data
var test = new OpenLayers.Layer.Vector("Editable Features", {
 strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy], 
 protocol: new OpenLayers.Protocol.WFS({
 url: "http://..../wfs",
 featurePrefix: 'testkf',
 featureNS: "http://.../testkf",
 featureType: "test",
 geometryName: "geom",
 })
});
map.addLayer(test);
//Toolbar:
 var panel = new OpenLayers.Control.Panel(
 {'displayClass': 'customEditingToolbar'}
 );
 var navigate = new OpenLayers.Control.Navigation({
 title: "Pan Map"
 });
 var draw = new OpenLayers.Control.DrawFeature(
 test, OpenLayers.Handler.Polygon,
 {
 title: "Draw Feature",
 displayClass: "olControlDrawFeaturePolygon",
 multi: true
 }
 );
 var edit = new OpenLayers.Control.ModifyFeature(test, {
 title: "Modify Feature",
 displayClass: "olControlModifyFeature"
 });
 var save = new OpenLayers.Control.Button({
 title: "Save Changes",
 trigger: function() {
 if(edit.feature) {
 edit.selectControl.unselectAll();
 }
 saveStrategy.save();
 },
 displayClass: "olControlSaveFeatures"
 });
panel.addControls([save, edit, draw, navigate]);
panel.defaultControl = navigate;
map.addControl(panel); 
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
}

Thanks for your help!!

Edit: I use Geoserver 2.1.4 and PostGIS 2.0 for PostgreSQL 9.1

ylka
1,0779 silver badges22 bronze badges
asked Sep 24, 2012 at 14:00

3 Answers 3

3

You don't say what versions of the software you are using but if it is a recent PostGIS (1.9+) and an older GeoServer (2.1.x -) then you will need to run the legacy.sql script to add geomFromText() (and other functions) back into PostGIS. See http://postgis.refractions.net/docs/PostGIS_FAQ.html#legacy_faq for more details.

answered Sep 24, 2012 at 14:12
3
  • Sorry, forgot to mention that:I use Geoserver 2.1.4 and PostGIS 2.0 for PostgreSQL 9.1. Commented Sep 24, 2012 at 14:14
  • then you'll need this step Commented Sep 24, 2012 at 14:24
  • thank you so very much - with the legacy.sql functions it finally works! Commented Sep 25, 2012 at 13:59
1

Most likely the insert statement is trying to insert something and there is some kind of conflict with the geometry field (e.g. dimension constraint of the geometry, coordinates, something else).

Enable debugging in the postgresql server and you will see the insert statement geoserver is creating. You can copy and paste that statement to psql, and the problem will (hopefully) be obvious from there.

answered Sep 24, 2012 at 17:21
0

try define projection for map, and srs in the wfs protocol. if you are using firebug then copy an paste the request in the geoserver demo. i think the problem is with postgis. i had to switch back to postgis1.5 and postgres9.0 to make it work.

answered Sep 25, 2012 at 6:51
1
  • I did define the projection for the map in an earlier version, but that alone did not do the trick. With the legacy.sql functions AND the projection-statements I finally had SUCCESS ;). So thanks!! Commented Sep 25, 2012 at 13:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.