[OpenLayers-Commits] r11031 - in trunk/openlayers: lib/OpenLayers/Format/WFST tests/Format/WFST

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Jan 13 14:37:35 EST 2011


Author: tschaub
Date: 2011-01-13 11:37:35 -0800 (Thu, 13 Jan 2011)
New Revision: 11031

Modified:
   trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
   trunk/openlayers/tests/Format/WFST/v1.html
Log:
Allow WFS transactions with null geometry. r=ahocevar (closes #3010)

Modified: trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js	2011-01-13 14:09:03 UTC (rev 11030)
+++ trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js	2011-01-13 19:37:35 UTC (rev 11031)
@@ -289,9 +289,11 @@
                 var node;
                 if(obj instanceof OpenLayers.Feature.Vector) {
                     node = this.createElementNSPlus("wfs:Value");
-                    this.srsName = this.getSrsName(obj);
-                    var geom = this.writeNode("feature:_geometry", obj.geometry).firstChild;
-                    node.appendChild(geom);
+                    if (obj.geometry) {
+                        this.srsName = this.getSrsName(obj);
+                        var geom = this.writeNode("feature:_geometry", obj.geometry).firstChild;
+                        node.appendChild(geom);
+                    }
                 } else {
                     node = this.createElementNSPlus("wfs:Value", {value: obj});                
                 }

Modified: trunk/openlayers/tests/Format/WFST/v1.html
===================================================================
--- trunk/openlayers/tests/Format/WFST/v1.html	2011-01-13 14:09:03 UTC (rev 11030)
+++ trunk/openlayers/tests/Format/WFST/v1.html	2011-01-13 19:37:35 UTC (rev 11031)
@@ -89,6 +89,32 @@
         }
     }
 
+    function test_update_null_geometry(t) {
+        var format = new OpenLayers.Format.WFST({
+            featureNS: "http://www.openplans.org/topp",
+            featureType: "states",
+            featurePrefix: "topp",
+            geometryName: "the_geom"
+        });
+
+        var feature = new OpenLayers.Feature.Vector(null, {foo: "bar"});
+        feature.state = OpenLayers.State.UPDATE;
+        feature.fid = "fid.36";
+
+        t.plan(1);
+        var snippets = {
+            "UpdateNullGeometry": feature
+        };
+
+        var arg;
+        for (var snippet in snippets) {
+            arg = snippets[snippet]
+            var expected = readXML(snippet);
+            var got = format.writers["wfs"]["Update"].apply(format, [arg]);
+            t.xml_eq(got, expected, snippet + " request with null geometry created correctly");
+        }
+    }
+
     function test_write_multiple(t) {
 
         var format = new OpenLayers.Format.WFST({
@@ -232,5 +258,20 @@
     </ogc:Filter>
 </wfs:Update>
 --></div>
+<div id="UpdateNullGeometry"><!--
+<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
+    <wfs:Property>
+        <wfs:Name>the_geom</wfs:Name>
+        <wfs:Value></wfs:Value>
+    </wfs:Property>
+    <wfs:Property>
+        <wfs:Name>foo</wfs:Name>
+        <wfs:Value>bar</wfs:Value>
+    </wfs:Property>
+    <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
+        <ogc:FeatureId fid="fid.36"/>
+    </ogc:Filter>
+</wfs:Update>
+--></div>
 </body>
 </html>



More information about the Commits mailing list