From 1b3af5d26d6b8dfce8c10ada9fa29b77be2f314e Mon Sep 17 00:00:00 2001 From: bartvde Date: Tue, 9 Feb 2010 06:26:06 +0000 Subject: [PATCH] add ability to write out a WFS Transaction without a geometry, r=tschaub (closes #2033) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10033 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/WFST/v1.js | 8 ++++--- tests/Format/WFST/v1.html | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Format/WFST/v1.js b/lib/OpenLayers/Format/WFST/v1.js index a32cd9bab2..4ebed5d8b3 100644 --- a/lib/OpenLayers/Format/WFST/v1.js +++ b/lib/OpenLayers/Format/WFST/v1.js @@ -226,9 +226,11 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { } // add in geometry - this.writeNode( - "Property", {name: this.geometryName, value: feature}, node - ); + if (this.geometryName !== null) { + this.writeNode( + "Property", {name: this.geometryName, value: feature}, node + ); + } // add in attributes for(var key in feature.attributes) { diff --git a/tests/Format/WFST/v1.html b/tests/Format/WFST/v1.html index e6d69fce77..78064fc4ca 100644 --- a/tests/Format/WFST/v1.html +++ b/tests/Format/WFST/v1.html @@ -63,6 +63,32 @@ } } + function test_write_no_geometry(t) { + var format = new OpenLayers.Format.WFST({ + featureNS: "http://www.openplans.org/topp", + featureType: "states", + featurePrefix: "topp", + geometryName: null + }); + + var feature = new OpenLayers.Feature.Vector(null, {foo: "bar"}); + feature.state = OpenLayers.State.UPDATE; + feature.fid = "fid.36"; + + t.plan(1); + var snippets = { + "UpdateNoGeometry": 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 without geometry created correctly"); + } + } + function readXML(id) { var xml = document.getElementById(id).firstChild.nodeValue; return new OpenLayers.Format.XML().read(xml).documentElement; @@ -166,5 +192,16 @@ --> +