[TinyOWS-users] INSERT is not working
Alexander Schäfer
alexander.schaefer at intevation.de
Thu Dec 17 03:34:26 EST 2009
Hello,
I use tinyows 0.7.0/SVN Version (Revision 185) as a WFS Server with OpenLayers
2.8. The update and delete feature works fine. But it is not possible for me
to save newly drawn features.
If I draw a polygon and save it, the request is successfully but only the id
(serial PK) stored in the database and neither the geometry nor its
attributes. If i reload the page all newly drawn features are gone.
The only way for me to work around this is to use the update function:
- Draw a new feature, save it,
- update the feature and than save it again.
After this the geometry with all attributes is stored.
I tried some changes to solve the problem but nothing works:
- Used WFS Version 1.1.0 and 1.0.0
- Created new table with POLYGON, LINE or POINT geometrycolumn and
draw/saved corresponding features
- Copied the successfully postrequest from the tinyows example
http://dev4.mapgears.com/bdga/bdgaWFS-T.html, fit it, and send it via
curl to my tinyows server, e.g. "curl xyz"
My Tinyows and OpenLayers Configuration and Requests
Tinyows config.xml
<tinyows online_resource="http://*******/cgi-bin/tinyows"
schema_dir="/usr/local/tinyows/schema/"
log="/tmp/tinyows.log"
>
<pg host="**********" user="postgres" password="********"
dbname="tinyows_demo
" port="5432"/>
<metadata name=""
title="TinyOWS Server - Demo Service"/>
<contact name="TinyOWS Server"
site="http://www.tinyows.org/"
email="tinyows-users at lists.maptools.org" />
<layer retrievable="1"
prefix="tows"
server="http://*******/"
name="world"
title="World Administrative Boundaries"/>
<layer retrievable="1"
writeable="1"
prefix="tows"
server="http://**********/"
name="france_linie"
title="French Administrative Sub Boundaries (IGN - GeoFLA
Departements)"/>
</tinyows>
_____________________________________________________________
OpenLayers Configuraion:
var saveStrategy = new OpenLayers.Strategy.Save();
var wfs = new OpenLayers.Layer.Vector("France", {
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
protocol: new OpenLayers.Protocol.WFS({
version: "1.0.0",
url: "http://********/cgi-bin/tinyows",
featureType: "france_linie",
featureNS: "http://*******/tows",
geometryName: "the_geom",
schema: "http://******/cgi-bin/tinyows?service=WFS&versio
n=1.0.0&request=DescribeFeatureType&TypeName=france_linie",
})
});
--------------------------------------------------------------------------------------------
onclick to save function from openlayers example:
http://openlayers.org/dev/examples/wfs-protocol-transactions.html
var DeleteFeature = OpenLayers.Class(OpenLayers.Control, {
initialize: function(layer, options) {
OpenLayers.Control.prototype.initialize.apply(this,
[options]);
this.layer = layer;
this.handler = new OpenLayers.Handler.Feature(
this, layer, {click: this.clickFeature}
);
},
clickFeature: function(feature) {
// if feature doesn't have a fid, destroy it
if(feature.fid == undefined) {
this.layer.destroyFeatures([feature]);
} else {
feature.state = OpenLayers.State.DELETE;
this.layer.events.triggerEvent("afterfeaturemodified",
{feature: feature});
feature.renderIntent = "select";
this.layer.drawFeature(feature);
}
},
setMap: function(map) {
this.handler.setMap(map);
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
CLASS_NAME: "OpenLayers.Control.DeleteFeature"
});
____________________________________________________________________
Insert Request which is only store the id but not the attributes
Geometry: Linestring
WFS Version 1.0.0
Insert Request
POST:
<?xml version="1.0"?>
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS"
version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd
http://*********/tows
http://**********/cgi-bin/tinyows?service=WFS&version=1.0.0&request=DescribeFeatureType&TypeName=france_linie2">
<wfs:Insert>
<feature:france_linie2 xmlns:feature="http://******/tows">
<feature:the_geom>
<gml:LineString xmlns:gml="http://www.opengis.net/gml"
srsName="EPSG:27582">
<gml:coordinates decimal="." cs=","
ts=" ">671270.13157895,2322786.3289474
685178.15789474,1942633.6096491</gml:coordinates>
</gml:LineString>
</feature:the_geom>
</feature:france_linie2>
</wfs:Insert>
</wfs:Transaction>
RESPONSE:
<?xml version="1.0" encoding="UTF-8"?>
<wfs:WFS_TransactionResponse version="1.0.0"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ogc="http://www.opengis.net/ogc"
xsi:schemaLocation='http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd'>
<wfs:InsertResult handle="TinyOWS-WFS-default-handle"><ogc:FeatureId
fid="france_linie2.80"/></wfs:InsertResult>
<wfs:TransactionResult>
<wfs:Status><wfs:SUCCESS/></wfs:Status>
</wfs:TransactionResult>
</wfs:WFS_TransactionResponse>
_____________________________________________________________
Alex
--
Alexander Schäfer | ++49-541-335083-0 | http://www.intevation.de/ |
Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
More information about the TinyOWS-users
mailing list