Allow WFS transactions with null geometry. r=ahocevar (closes #3010)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11031 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -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});
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user