diff --git a/lib/OpenLayers/Format/GML.js b/lib/OpenLayers/Format/GML.js index c7cfa10c88..f07d3ac0f2 100644 --- a/lib/OpenLayers/Format/GML.js +++ b/lib/OpenLayers/Format/GML.js @@ -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} 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]*\?>/, ''); // Remove XML Prolog t.eq(output, multilinestring, "MultiLine geometry round trips correctly."); + } function test_Format_GML_read_point_geom(t) { t.plan(3); @@ -325,6 +326,17 @@ t.eq(output, multilinestring_xy, "MultiLine geometry round trips correctly."); } + function test_buildGeometryNode_bounds(t) { + t.plan(1); + var parser = new OpenLayers.Format.GML(); + var bounds = new OpenLayers.Bounds(-180, -90, 180, 90); + var output, expect; + + // test that bounds are written as gml:Box + var output = parser.buildGeometryNode(bounds); + var expect = '-180,-90 180,90'; + t.xml_eq(output, expect, "[xy true] Bounds correctly written as gml:Box"); + } var test_content = ['\n\n \n \n -1254041.389711702250906.9515983529\n -634517.1199908922762236.2940800377\n \n \n \n \n -634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0\n WY\n \n \n \n\n', '