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 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: " Error performing insert: Error inserting features" or " Update error: Error occured updating features"

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

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
Sorry, forgot to mention that:I use Geoserver 2.1.4 and PostGIS 2.0 for PostgreSQL 9.1. –  Cat Sep 24 '12 at 14:14
    
then you'll need this step –  iant Sep 24 '12 at 14:24
    
thank you so very much - with the legacy.sql functions it finally works! –  Cat Sep 25 '12 at 13:59
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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!! –  Cat Sep 25 '12 at 13:56
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.