Ticket #42 (closed defect: fixed)

Opened 9 months ago

Last modified 3 months ago

Make Transactional Insert works with OpenLayers 2.8+

Reported by: ol Owned by:
Priority: major Version: SVN
Keywords: Cc:
Triage Stage: Unreviewed State of Approval: Unnecessary
Attached Patches: None Complexity: Unknown
Compatibility: Unknown Specification: Unnecessary

Description

Alexander Schäfer (Intevation) detailled report:

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"

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@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&amp;version=1.0.0&amp;request=DescribeFeatureType&amp;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>

Change History

Changed 9 months ago by ol

Ok, just commited as r186, a fix to not use anymore prefix but href as namespace feature check. (a workaround for people who cannot recompile from SVN easily is to configure TinyOWS prefix to 'feature')

Waiting to your feedback,

Changed 9 months ago by ol

  • status changed from new to closed
  • resolution set to fixed

Changed 7 months ago by weddingdress

homecoming dresses homecoming dresses prom dress prom dresses prom dresses and wedding dress wedding dresses bridal gown discount wedding dresses quinceanera dress quinceanera dresses sweet dress sweet 16 dresses quinceanera gowns and prom dresses,wedding dresses wedding dresses wedding dress wedding dresses for wedding pary maternity wedding dresses,bridesmaid dress bridesmaid dress bridesmaid bridesmaid dresses dress prom dresses gowns prom gowns dresses and oil paintings oil painting oil painting oil paintings oil paintings wedding dresses wedding dresses and prom dress prom dresses prom prom dresses

Changed 5 months ago by mike3050

Changed 3 months ago by bobmarks

an overnight angular cheilitis treatment <a href="http://cheilitistreatment.com">cheilitis treatment</a> avilable now for those who suffer from angular cheilitis.

Changed 3 months ago by bobmarks

an overnight angular cheilitis treatment <a class="ext-link" href="http://cheilitistreatment.com/"><span class="icon">cheilitis treatment</span> available now for those who suffer from angular cheilitis.

Note: See TracTickets for help on using tickets.