diff --git a/lib/OpenLayers/Format/WFST/v1.js b/lib/OpenLayers/Format/WFST/v1.js index efae86f133..cd936ae47e 100644 --- a/lib/OpenLayers/Format/WFST/v1.js +++ b/lib/OpenLayers/Format/WFST/v1.js @@ -289,9 +289,11 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { 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}); } diff --git a/tests/Format/WFST/v1.html b/tests/Format/WFST/v1.html index 9ec5d17087..34e8a08def 100644 --- a/tests/Format/WFST/v1.html +++ b/tests/Format/WFST/v1.html @@ -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 @@ --> +