Saturday, 1 September 2018

postgis - WFS-T Edit using OpenLayers, Geoserver, PostgreSQL ("error performing insert")


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



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...