Changeset 7955
- Timestamp:
- 09/04/08 17:44:52 (3 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Format/GML.js (modified) (3 diffs)
- trunk/openlayers/tests/Format/GML.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Format/GML.js
r7654 r7955 140 140 var order = ["MultiPolygon", "Polygon", 141 141 "MultiLineString", "LineString", 142 "MultiPoint", "Point", "Envelope" ];142 "MultiPoint", "Point", "Envelope", "Box"]; 143 143 var type, nodeList, geometry, parser; 144 144 for(var i=0; i<order.length; ++i) { … … 805 805 } 806 806 return gml; 807 808 }, 809 810 /** 811 * Method: buildGeometry.bounds 812 * Given an OpenLayers bounds, create a GML box. 813 * 814 * Parameters: 815 * bounds - {<OpenLayers.Geometry.Bounds>} A bounds object. 816 * 817 * Returns: 818 * {DOMElement} A GML box node. 819 */ 820 bounds: function(bounds) { 821 var gml = this.createElementNS(this.gmlns, "gml:Box"); 822 gml.appendChild(this.buildCoordinatesNode(bounds)); 823 return gml; 807 824 } 808 825 }, … … 826 843 coordinatesNode.setAttribute("cs", ","); 827 844 coordinatesNode.setAttribute("ts", " "); 828 829 var points = (geometry.components) ? geometry.components : [geometry]; 845 830 846 var parts = []; 831 for(var i=0; i<points.length; i++) { 832 parts.push(points[i].x + "," + points[i].y); 847 848 if(geometry instanceof OpenLayers.Bounds){ 849 parts.push(geometry.left + "," + geometry.bottom); 850 parts.push(geometry.right + "," + geometry.top); 851 } else { 852 var points = (geometry.components) ? geometry.components : [geometry]; 853 for(var i=0; i<points.length; i++) { 854 parts.push(points[i].x + "," + points[i].y); 855 } 833 856 } 834 857 trunk/openlayers/tests/Format/GML.html
r6719 r7955 69 69 var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog 70 70 t.eq(output, multilinestring, "MultiLine geometry round trips correctly."); 71 71 72 } 72 73 function test_Format_GML_read_point_geom(t) { … … 326 327 } 327 328 329 function test_buildGeometryNode_bounds(t) { 330 t.plan(1); 331 var parser = new OpenLayers.Format.GML(); 332 var bounds = new OpenLayers.Bounds(-180, -90, 180, 90); 333 var output, expect; 334 335 // test that bounds are written as gml:Box 336 var output = parser.buildGeometryNode(bounds); 337 var expect = '<gml:Box xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="." cs="," ts=" ">-180,-90 180,90</gml:coordinates></gml:Box>'; 338 t.xml_eq(output, expect, "[xy true] Bounds correctly written as gml:Box"); 339 } 328 340 329 341 var test_content = ['<?xml version="1.0" encoding="utf-8" ?>\n<ogr:FeatureCollection\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://ogr.maptools.org/ testoutput.xsd"\n xmlns:ogr="http://ogr.maptools.org/"\n xmlns:gml="http://www.opengis.net/gml">\n <gml:boundedBy>\n <gml:Box>\n <gml:coord><gml:X>-1254041.389711702</gml:X><gml:Y>250906.9515983529</gml:Y></gml:coord>\n <gml:coord><gml:X>-634517.1199908922</gml:X><gml:Y>762236.2940800377</gml:Y></gml:coord>\n </gml:Box>\n </gml:boundedBy> \n <gml:featureMember>\n <ogr:states fid="F0">\n <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-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</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>\n <ogr:NAME>WY</ogr:NAME>\n <ogr:LONGNAME><![CDATA[Wyoming]]></ogr:LONGNAME>\n </ogr:states>\n </gml:featureMember>\n</ogr:FeatureCollection>\n',
