Adding support to the gml parser for serializing OpenLayers.Bounds as gml:Box. This gives the filter format (and the sld format) the ability to write spatial filters (that have bounds as a value). r=me (closes #1543)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7955 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-09-04 21:44:52 +00:00
parent d046680c65
commit c066796698
2 changed files with 40 additions and 5 deletions

View File

@@ -139,7 +139,7 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
// only accept on geometry per feature - look for highest "order"
var order = ["MultiPolygon", "Polygon",
"MultiLineString", "LineString",
"MultiPoint", "Point", "Envelope"];
"MultiPoint", "Point", "Envelope", "Box"];
var type, nodeList, geometry, parser;
for(var i=0; i<order.length; ++i) {
type = order[i];
@@ -804,6 +804,23 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
gml.appendChild(polyMember);
}
return gml;
},
/**
* Method: buildGeometry.bounds
* Given an OpenLayers bounds, create a GML box.
*
* Parameters:
* bounds - {<OpenLayers.Geometry.Bounds>} A bounds object.
*
* Returns:
* {DOMElement} A GML box node.
*/
bounds: function(bounds) {
var gml = this.createElementNS(this.gmlns, "gml:Box");
gml.appendChild(this.buildCoordinatesNode(bounds));
return gml;
}
},
@@ -825,11 +842,17 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
coordinatesNode.setAttribute("decimal", ".");
coordinatesNode.setAttribute("cs", ",");
coordinatesNode.setAttribute("ts", " ");
var points = (geometry.components) ? geometry.components : [geometry];
var parts = [];
for(var i=0; i<points.length; i++) {
parts.push(points[i].x + "," + points[i].y);
if(geometry instanceof OpenLayers.Bounds){
parts.push(geometry.left + "," + geometry.bottom);
parts.push(geometry.right + "," + geometry.top);
} else {
var points = (geometry.components) ? geometry.components : [geometry];
for(var i=0; i<points.length; i++) {
parts.push(points[i].x + "," + points[i].y);
}
}
var txtNode = this.createTextNode(parts.join(" "));