[Users] WFS-T problems with postGIS
Andreas Hocevar
ahocevar at opengeo.org
Tue Sep 21 11:35:37 CEST 2010
Hi,
I don't see anything wrong with your code and the WFS request. I seem to remember that there are issues when WFS-T inserting to an empty feature type, but for a more qualified reply you may want to ask your question on the geoserver-users list.
Regards,
Andreas.
On Sep 21, 2010, at 11:22 , Viggo Lunde wrote:
> Hi
> I was in Foss4G Barcelona and got this great tutorial on GeoExt Editng.
> And it works very well on shape-files in geoserver.
> But we want to use postGIS and have tried to make a testtable like this.
>
> Column | Type |
> Modifiers
> --------+-----------------------+---------------------------------------
> --------+-----------------------+-----------------------
> fid | integer | not null default
> nextval('test.wfstrans2_fid_seq'::regclass)
> info | character varying(40) |
> geo | geometry |
> Indexes:
> "wfstrans2_pkey" PRIMARY KEY, btree (fid)
> "geoidx_test__wfstrans2" gist (geo)
> Check constraints:
> "enforce_dims_geo" CHECK (st_ndims(geo) = 2)
> "enforce_geotype_geo" CHECK (geometrytype(geo) = 'POLYGON'::text OR geo IS NULL)
> "enforce_srid_geo" CHECK (st_srid(geo) = 32632)
>
>
> The client posts this:
>
> <wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Insert><feature:wfstrans2 xmlns:feature="http://www.skogoglandskap.no"><feature:geo><gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:32632"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">523671.86,6839648 447847.86,6788196 558875.86,6790904 523671.86,6839648</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></feature:geo><feature:info>test1</feature:info></feature:wfstrans2></wfs:Insert></wfs:Transaction>
>
>
> And i get this errormessage:
>
> <?xml version="1.0" encoding="UTF-8"?><wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://kartutv7:80/geoserver_intern/schemas/wfs/1.0.0/WFS-transaction.xsd"><wfs:InsertResult><ogc:FeatureId fid="none"/></wfs:InsertResult> <wfs:TransactionResult> <wfs:Status> <wfs:FAILED/> </wfs:Status> <wfs:Message>Error performing insert</wfs:Message> </wfs:TransactionResult></wfs:WFS_TransactionResponse>
>
> My wfs_editor.html looks like this:
>
>
>
> <html>
> <head>
> <title>GeoExt WFS Editor</title>
>
> <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
> <script type="text/javascript" src="ext/ext-all.js"></script>
> <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />
> <script src="openlayers/lib/OpenLayers.js"></script>
>
> <script type="text/javascript" src="geoext/lib/GeoExt.js"></script>
>
> <script type="text/javascript">
> Ext.BLANK_IMAGE_URL = "ext/resources/images/default/s.gif";
>
> Ext.onReady(function() {
>
> /*var saveStrategy = new OpenLayers.Strategy.Save({
> onCommit: function() {
> saveStrategy.layer.refresh();
> }
> });*/
> var saveStrategy = new OpenLayers.Strategy.Save();
> var baseLayer = new OpenLayers.Layer.WMS( "Gråtone", "
> http://kart7.skogoglandskap.no/bakgrunn/wms.topo2.graatone
> ",
> {layers: 'topo2_graatone_WMS', 'format':'image/png', 'transparent':'false' },
> {isBaseLayer: true, singleTile: true, buffer:0,ratio:1});
>
> var layer = new OpenLayers.Layer.Vector("vector", {
> strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy],
> //strategies: [new OpenLayers.Strategy.Fixed()],
> protocol: new OpenLayers.Protocol.WFS({
> url: "/geoserver_intern/wms",
> version: "1.0.0",
> geometryName: "geo",
> featureType: "wfstrans2",
> featureNS: "
> http://www.skogoglandskap.no
> ",
> srsName: "EPSG:32632"
> })
> });
>
> var store = new GeoExt.data.FeatureStore({
> fields: [
> {name: "info", type: "string"}/*,
> {name: "fid", type: "int"}*/
> ],
> layer: layer,
> addFeatureFilter: function(feature) {
> return feature.state !== OpenLayers.State.DELETE;
> }
>
> });
>
> var drawControl = new OpenLayers.Control.DrawFeature(
> layer,
> OpenLayers.Handler.Polygon,
> {handlerOptions: {multi: true}}
> );
>
>
> var mapPanel = new GeoExt.MapPanel({
> title: "Map",
> region: "west",
> width: 400,
> layers: [baseLayer,layer],
> //extent: new OpenLayers.Bounds(234758, 6402776, 1339075, 8020511),
> map: {
> projection: new OpenLayers.Projection("EPSG:32632"),
> displayProjection: new OpenLayers.Projection("EPSG:32632"),
> maxExtent: new OpenLayers.Bounds(-570684.15,6424344.35,1596363.87,7964447.65),
> units: "m",
> maxResolution: 2708.0,
> numZoomLevels: 15,
> controls: [ new OpenLayers.Control.PanZoomBar(),
> new OpenLayers.Control.MousePosition({'prefix':'UTM 32: ','numDigits':0})
> ]
> },
> bbar: [
> new GeoExt.Action({
> control: drawControl,
> text: "Create",
> enableToggle: true
> }), {
> text: "Delete",
> handler: function() {
> gridPanel.getSelectionModel().each(function(rec) {
> var feature = rec.get("feature");
> modifyControl.unselectFeature(feature);
> store.remove(rec);
> if(feature.state !== OpenLayers.State.INSERT) {
> feature.state = OpenLayers.State.DELETE;
> layer.addFeatures([feature]);
> }
> });
> }
> }, "->", {
> text: "Save",
> handler: function() {
> store.commitChanges();
> saveStrategy.save();
> }
> }
>
> ]
> });
>
> mapPanel.map.addControl(drawControl);
>
>
> var modifyControl = new OpenLayers.Control.ModifyFeature(layer);
> mapPanel.map.addControl(modifyControl);
> modifyControl.activate();
>
>
>
> var gridPanel = new Ext.grid.EditorGridPanel({
> title: "Feature Table - Manhattan (NY) landmarks",
> region: "center",
> viewConfig: {forceFit: true},
> store: store,
> listeners: {
> afteredit: function(e) {
> var feature = e.record.get("feature");
> if(feature.state !== OpenLayers.State.INSERT) {
> feature.state = OpenLayers.State.UPDATE;
> }
> }
> },
> sm: new GeoExt.grid.FeatureSelectionModel({
> selectControl: modifyControl.selectControl,
> singleSelect: true
> }),
> cm: new Ext.grid.ColumnModel({
> defaults: {
> sortable: true,
> editor: {xtype: "textfield"}
> },
> columns: [
> {header: "Info", dataIndex: "info"}/*,
> {header: "Id", dataIndex: "fid"}*/
> ]
> })
> });
>
>
> var mainPanel = new Ext.Panel({
> renderTo: document.body,
> layout: "border",
> height: 450,
> width: 800,
> items: [gridPanel, mapPanel]
> });
> });
> </script>
> </head>
> <body>
> </body>
> </html>
>
>
>
>
> I am running geoserver 2.0.0
> Anyone knows whats wrong.
>
> Best regards
> Viggo Lunde
> Skog og landskap
> Norway
>
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list