Fix exporting empty vector layers to OWSContext.

When a vector layer is exported to an OWSContext document, we throw an
exception when the layer contains no features, and the geometries are to be
exported inside of an InlineGeometry-element.

This commit fixes this behaviour by exporting sth. like this in such cases:

<Layer name="vector" hidden="0">i
  <ows:Title xmlns:ows="http://www.opengis.net/ows"/>
  <InlineGeometry/>
</Layer>
This commit is contained in:
Marc Jansen
2012-11-20 10:38:25 +01:00
parent 12046503ca
commit 798d2b2cb7
2 changed files with 42 additions and 2 deletions

View File

@@ -423,8 +423,11 @@ OpenLayers.Format.OWSContext.v0_3_1 = OpenLayers.Class(OpenLayers.Format.XML, {
return node;
},
"InlineGeometry": function(layer) {
var node = this.createElementNSPlus("InlineGeometry");
this.writeNode("gml:boundedBy", layer.getDataExtent(), node);
var node = this.createElementNSPlus("InlineGeometry"),
dataExtent = layer.getDataExtent();
if (dataExtent !== null) {
this.writeNode("gml:boundedBy", layer.getDataExtent(), node);
}
for (var i=0, len=layer.features.length; i<len; i++) {
this.writeNode("gml:featureMember", layer.features[i], node);
}