Changeset 5238
- Timestamp:
- 11/21/07 10:53:32 (1 year ago)
- Files:
-
- trunk/openlayers/doc/authors.txt (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Format/GML.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Format/GeoRSS.js (modified) (5 diffs)
- trunk/openlayers/tests/Format/test_GML.html (modified) (3 diffs)
- trunk/openlayers/tests/Format/test_GeoRSS.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/doc/authors.txt
r3785 r5238 4 4 John Cole 5 5 Jeff Dege 6 Roald de Wit 6 7 Schuyler Erle 7 8 Christian López EspÃnola trunk/openlayers/lib/OpenLayers/Format/GML.js
r5028 r5238 73 73 74 74 /** 75 * APIProperty: xy 76 * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x) 77 * Changing is not recommended, a new Format should be instantiated. 78 */ 79 xy: true, 80 81 /** 75 82 * Constructor: OpenLayers.Format.GML 76 83 * Create a new parser for GML. … … 131 138 var order = ["MultiPolygon", "Polygon", 132 139 "MultiLineString", "LineString", 133 "MultiPoint", "Point" ];140 "MultiPoint", "Point", "Envelope"]; 134 141 var type, nodeList, geometry, parser; 135 142 for(var i=0; i<order.length; ++i) { … … 198 205 * 3) <gml:coord><gml:X>x</gml:X><gml:Y>y</gml:Y></gml:coord> 199 206 */ 200 var nodeList ;207 var nodeList, coordString; 201 208 var coords = []; 202 209 … … 204 211 var nodeList = this.getElementsByTagNameNS(node, this.gmlns, "pos"); 205 212 if(nodeList.length > 0) { 206 varcoordString = nodeList[0].firstChild.nodeValue;213 coordString = nodeList[0].firstChild.nodeValue; 207 214 coordString = coordString.replace(this.regExes.trimSpace, ""); 208 215 coords = coordString.split(this.regExes.splitSpace); … … 241 248 coords[2] = null; 242 249 } 243 return new OpenLayers.Geometry.Point(coords[0], coords[1], 250 251 if (this.xy) { 252 return new OpenLayers.Geometry.Point(coords[0], coords[1], 244 253 coords[2]); 254 } 255 else{ 256 return new OpenLayers.Geometry.Point(coords[1], coords[0], 257 coords[2]); 258 } 245 259 }, 246 260 … … 306 320 y = coords[j+1]; 307 321 z = (dim == 2) ? null : coords[j+2]; 308 points.push(new OpenLayers.Geometry.Point(x, y, z)); 322 if (this.xy) { 323 points.push(new OpenLayers.Geometry.Point(x, y, z)); 324 } else { 325 points.push(new OpenLayers.Geometry.Point(y, x, z)); 326 } 309 327 } 310 328 } … … 326 344 coords[2] = null; 327 345 } 328 points.push(new OpenLayers.Geometry.Point(coords[0], 346 if (this.xy) { 347 points.push(new OpenLayers.Geometry.Point(coords[0], 329 348 coords[1], 330 349 coords[2])); 350 } else { 351 points.push(new OpenLayers.Geometry.Point(coords[1], 352 coords[0], 353 coords[2])); 354 } 331 355 } 332 356 } … … 427 451 } 428 452 return new OpenLayers.Geometry.MultiPolygon(components); 453 }, 454 455 envelope: function(node) { 456 var components = []; 457 var coordString; 458 var envelope; 459 460 var lpoint = this.getElementsByTagNameNS(node, this.gmlns, "lowerCorner"); 461 if (lpoint.length > 0) { 462 var coords = []; 463 464 if(lpoint.length > 0) { 465 coordString = lpoint[0].firstChild.nodeValue; 466 coordString = coordString.replace(this.regExes.trimSpace, ""); 467 coords = coordString.split(this.regExes.splitSpace); 468 } 469 470 if(coords.length == 2) { 471 coords[2] = null; 472 } 473 if (this.xy) { 474 var lowerPoint = new OpenLayers.Geometry.Point(coords[0], coords[1],coords[2]); 475 } else { 476 var lowerPoint = new OpenLayers.Geometry.Point(coords[1], coords[0],coords[2]); 477 } 478 } 479 480 var upoint = this.getElementsByTagNameNS(node, this.gmlns, "upperCorner"); 481 if (upoint.length > 0) { 482 var coords = []; 483 484 if(upoint.length > 0) { 485 coordString = upoint[0].firstChild.nodeValue; 486 coordString = coordString.replace(this.regExes.trimSpace, ""); 487 coords = coordString.split(this.regExes.splitSpace); 488 } 489 490 if(coords.length == 2) { 491 coords[2] = null; 492 } 493 if (this.xy) { 494 var upperPoint = new OpenLayers.Geometry.Point(coords[0], coords[1],coords[2]); 495 } else { 496 var upperPoint = new OpenLayers.Geometry.Point(coords[1], coords[0],coords[2]); 497 } 498 } 499 500 if (lowerPoint && upperPoint) { 501 components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y)); 502 components.push(new OpenLayers.Geometry.Point(upperPoint.x, lowerPoint.y)); 503 components.push(new OpenLayers.Geometry.Point(upperPoint.x, upperPoint.y)); 504 components.push(new OpenLayers.Geometry.Point(lowerPoint.x, upperPoint.y)); 505 components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y)); 506 507 var ring = new OpenLayers.Geometry.LinearRing(components); 508 envelope = new OpenLayers.Geometry.Polygon([ring]); 509 } 510 return envelope; 429 511 } 430 512 }, trunk/openlayers/lib/OpenLayers/Format/GeoRSS.js
r4985 r5238 60 60 61 61 /** 62 * Property: gmlParse 63 * {Object} GML Format object for parsing features 64 * Non-API and only created if necessary 65 */ 66 gmlParser: null, 67 68 /** 69 * APIProperty: xy 70 * {Boolean} Order of the GML coordinate: true:(x,y) or false:(y,x) 71 * For GeoRSS the default is (y,x), therefore: false 72 */ 73 xy: false, 74 75 /** 62 76 * Constructor: OpenLayers.Format.GeoRSS 63 77 * Create a new parser for GeoRSS. … … 92 106 this.georssns, 93 107 "polygon"); 94 108 var where = this.getElementsByTagNameNS(item, 109 this.georssns, 110 "where"); 95 111 if (point.length > 0 || (lat.length > 0 && lon.length > 0)) { 112 var location; 96 113 if (point.length > 0) { 97 varlocation = OpenLayers.String.trim(114 location = OpenLayers.String.trim( 98 115 point[0].firstChild.nodeValue).split(/\s+/); 99 100 116 if (location.length !=2) { 101 varlocation = OpenLayers.String.trim(117 location = OpenLayers.String.trim( 102 118 point[0].firstChild.nodeValue).split(/\s*,\s*/); 103 119 } 104 120 } else { 105 varlocation = [parseFloat(lat[0].firstChild.nodeValue),121 location = [parseFloat(lat[0].firstChild.nodeValue), 106 122 parseFloat(lon[0].firstChild.nodeValue)]; 107 123 } 124 108 125 var geometry = new OpenLayers.Geometry.Point(parseFloat(location[1]), 109 parseFloat(location[0])); 126 parseFloat(location[0])); 127 110 128 } else if (line.length > 0) { 111 129 var coords = OpenLayers.String.trim(line[0].firstChild.nodeValue).split(/\s+/); 112 130 var components = []; 131 var point; 113 132 for (var i=0; i < coords.length; i+=2) { 114 var point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), parseFloat(coords[i])); 133 point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), 134 parseFloat(coords[i])); 115 135 components.push(point); 116 136 } … … 119 139 var coords = OpenLayers.String.trim(polygon[0].firstChild.nodeValue).split(/\s+/); 120 140 var components = []; 141 var point; 121 142 for (var i=0; i < coords.length; i+=2) { 122 var point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), parseFloat(coords[i])); 143 point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), 144 parseFloat(coords[i])); 123 145 components.push(point); 124 146 } 125 147 geometry = new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(components)]); 148 } else if (where.length > 0) { 149 if (!this.gmlParser) { 150 this.gmlParser = new OpenLayers.Format.GML({'xy': this.xy}); 151 } 152 var feature = this.gmlParser.parseFeature(where[0]); 153 geometry = feature.geometry; 126 154 } 127 155 return geometry; … … 140 168 createFeatureFromItem: function(item) { 141 169 var geometry = this.createGeometryFromItem(item); 170 142 171 /* Provide defaults for title and description */ 143 172 var title = this.getChildValue(item, "*", "title", this.featureTitle); … … 341 370 path = parts.join(" "); 342 371 } else { 343 path = geometry.y + " " + geometry.x;372 path = geometry.y + " " + geometry.x; 344 373 } 345 374 return this.createTextNode(path); trunk/openlayers/tests/Format/test_GML.html
r4429 r5238 74 74 t.eq(data[0].geometry.x, 1, "x coord correct"); 75 75 t.eq(data[0].geometry.y, 2, "y coord correct"); 76 } 76 } 77 77 function test_Format_GML_read_linestring_geom(t) { 78 78 t.plan(5); … … 153 153 t.eq(data[0].attributes['NAME'], "WY", "Simple Attribute data is read correctly."); 154 154 t.eq(data[0].attributes['LONGNAME'], "Wyoming", "Attribute data is read from CDATA node correctly."); 155 } 155 } 156 function test_Format_GML_read_envelope_geom(t) { 157 t.plan(13); 158 159 var envelope = shell_start + geoms['envelope'] + shell_end; 160 var parser = new OpenLayers.Format.GML(); 161 data = parser.read(envelope); 162 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Envelope GML returns correct classname"); 163 t.eq(data[0].geometry.components[0].components[0].x, 0, "first x coord correct"); 164 t.eq(data[0].geometry.components[0].components[0].y, 1, "first y coord correct"); 165 t.eq(data[0].geometry.components[0].components[1].x, 20, "second x coord correct"); 166 t.eq(data[0].geometry.components[0].components[1].y, 1, "second y coord correct"); 167 t.eq(data[0].geometry.components[0].components[2].x, 20, "third x coord correct"); 168 t.eq(data[0].geometry.components[0].components[2].y, 21, "third y coord correct"); 169 t.eq(data[0].geometry.components[0].components[3].x, 0, "fouth x coord correct"); 170 t.eq(data[0].geometry.components[0].components[3].y, 21, "fourth y coord correct"); 171 t.eq(data[0].geometry.components[0].components[4].x, 0, "fifth x coord correct"); 172 t.eq(data[0].geometry.components[0].components[4].y, 1, "fifth y coord correct"); 173 t.eq(data[0].geometry.components[0].components.length, 5, "coords length correct"); 174 t.eq(data[0].geometry.components.length, 1, "rings length correct"); 175 } 176 /////////////////////////////////////////////////////////////// 177 // tests the y x order of gml point 178 ///////////////////////////////////////////////////////////// 179 function test_Format_GML_read_point_geom_yx(t) { 180 t.plan(3); 181 182 var point = shell_start + geoms_yx['point'] + shell_end; 183 var parser = new OpenLayers.Format.GML({'xy':false}); 184 data = parser.read(point); 185 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Point", "Point GML returns correct classname"); 186 t.eq(data[0].geometry.x, 1, "x coord correct"); 187 t.eq(data[0].geometry.y, 2, "y coord correct"); 188 } 189 function test_Format_GML_read_linestring_geom_yx(t) { 190 t.plan(5); 191 192 var line = shell_start + geoms_yx['linestring'] + shell_end; 193 var parser = new OpenLayers.Format.GML({'xy':false}); 194 data = parser.read(line); 195 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.LineString", "LineString GML returns correct classname"); 196 t.eq(data[0].geometry.components[0].x, 1, "first x coord correct"); 197 t.eq(data[0].geometry.components[0].y, 2, "first y coord correct"); 198 t.eq(data[0].geometry.components[1].x, 4, "second x coord correct"); 199 t.eq(data[0].geometry.components[1].y, 5, "second y coord correct"); 200 } 201 function test_Format_GML_read_polygon_geom_yx(t) { 202 t.plan(7); 203 204 var polygon = shell_start + geoms_yx['polygon'] + shell_end; 205 var parser = new OpenLayers.Format.GML({'xy':false}); 206 data = parser.read(polygon); 207 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname"); 208 t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct"); 209 t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct"); 210 t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct"); 211 t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct"); 212 t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct"); 213 t.eq(data[0].geometry.components.length, 1, "rings length correct"); 214 } 215 function test_Format_GML_read_multipoint_geom_yx(t) { 216 t.plan(6); 217 218 var multipoint = shell_start + geoms_yx['multipoint'] + shell_end; 219 var parser = new OpenLayers.Format.GML({'xy':false}); 220 data = parser.read(multipoint); 221 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiPoint", "MultiPoint GML returns correct classname"); 222 t.eq(data[0].geometry.components[0].x, 1, "x coord correct"); 223 t.eq(data[0].geometry.components[0].y, 2, "y coord correct"); 224 t.eq(data[0].geometry.components.length, 2, "length correct"); 225 t.eq(data[0].geometry.components[1].x, 4, "x coord correct"); 226 t.eq(data[0].geometry.components[1].y, 5, "y coord correct"); 227 } 228 function test_Format_GML_read_multilinestring_geom_yx(t) { 229 t.plan(6); 230 231 var multilinestring = shell_start + geoms_yx['multilinestring'] + shell_end; 232 var parser = new OpenLayers.Format.GML({'xy':false}); 233 data = parser.read(multilinestring); 234 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiLineString", "MultiLineString GML returns correct classname"); 235 t.eq(data[0].geometry.components[0].components[0].x, 1, "x coord correct"); 236 t.eq(data[0].geometry.components[0].components[0].y, 2, "y coord correct"); 237 t.eq(data[0].geometry.components[0].components.length, 2, "length correct"); 238 t.eq(data[0].geometry.components[0].components[1].x, 4, "x coord correct"); 239 t.eq(data[0].geometry.components[0].components[1].y, 5, "y coord correct"); 240 241 } 242 function test_Format_GML_read_polygon_with_holes_geom_yx(t) { 243 t.plan(12); 244 245 var polygon_with_holes = shell_start + geoms_yx['polygon_with_holes'] + shell_end; 246 var parser = new OpenLayers.Format.GML({'xy':false}); 247 data = parser.read(polygon_with_holes); 248 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname"); 249 t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct"); 250 t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct"); 251 t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct"); 252 t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct"); 253 t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct"); 254 t.eq(data[0].geometry.components[1].components[0].x, 11, "first x coord correct"); 255 t.eq(data[0].geometry.components[1].components[0].y, 12, "first y coord correct"); 256 t.eq(data[0].geometry.components[1].components[1].x, 14, "second x coord correct"); 257 t.eq(data[0].geometry.components[1].components[1].y, 15, "second y coord correct"); 258 t.eq(data[0].geometry.components[1].components.length, 4, "coords length correct"); 259 t.eq(data[0].geometry.components.length, 2, "rings length correct"); 260 } 261 262 function test_Format_GML_read_envelope_geom_yx(t) { 263 t.plan(13); 264 265 var envelope = shell_start + geoms_yx['envelope'] + shell_end; 266 var parser = new OpenLayers.Format.GML({'xy':false}); 267 data = parser.read(envelope); 268 t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Envelope GML returns correct classname"); 269 t.eq(data[0].geometry.components[0].components[0].x, 0, "first x coord correct"); 270 t.eq(data[0].geometry.components[0].components[0].y, 1, "first y coord correct"); 271 t.eq(data[0].geometry.components[0].components[1].x, 20, "second x coord correct"); 272 t.eq(data[0].geometry.components[0].components[1].y, 1, "second y coord correct"); 273 t.eq(data[0].geometry.components[0].components[2].x, 20, "third x coord correct"); 274 t.eq(data[0].geometry.components[0].components[2].y, 21, "third y coord correct"); 275 t.eq(data[0].geometry.components[0].components[3].x, 0, "fouth x coord correct"); 276 t.eq(data[0].geometry.components[0].components[3].y, 21, "fourth y coord correct"); 277 t.eq(data[0].geometry.components[0].components[4].x, 0, "fifth x coord correct"); 278 t.eq(data[0].geometry.components[0].components[4].y, 1, "fifth y coord correct"); 279 t.eq(data[0].geometry.components[0].components.length, 5, "coords length correct"); 280 t.eq(data[0].geometry.components.length, 1, "rings length correct"); 281 } 282 283 function test_Format_GML_write_geoms_yx(t) { 284 t.plan(5); 285 var parser = new OpenLayers.Format.GML({'xy':false}); 286 287 var point_xy = shell_start + serialize_geoms['point'] + shell_end; 288 var point = shell_start + serialize_geoms_yx['point'] + shell_end; 289 data = parser.read(point); 290 var output = parser.write(data); 291 t.eq(output, point_xy, "Point geometry round trips correctly."); 292 293 var linestring_xy = shell_start + serialize_geoms['linestring'] + shell_end; 294 var linestring = shell_start + serialize_geoms_yx['linestring'] + shell_end; 295 data = parser.read(linestring); 296 var output = parser.write(data); 297 t.eq(output, linestring_xy, "Line geometry round trips correctly."); 298 299 var polygon_xy = shell_start + serialize_geoms['polygon'] + shell_end; 300 var polygon = shell_start + serialize_geoms_yx['polygon'] + shell_end; 301 data = parser.read(polygon); 302 var output = parser.write(data); 303 t.eq(output, polygon_xy, "Poly geometry round trips correctly."); 304 305 var multipoint_xy = shell_start + serialize_geoms['multipoint'] + shell_end; 306 var multipoint = shell_start + serialize_geoms_yx['multipoint'] + shell_end; 307 data = parser.read(multipoint); 308 var output = parser.write(data); 309 t.eq(output, multipoint_xy, "MultiPoint geometry round trips correctly."); 310 311 var multilinestring_xy = shell_start + serialize_geoms['multilinestring'] + shell_end; 312 var multilinestring = shell_start + serialize_geoms_yx['multilinestring'] + shell_end; 313 data = parser.read(multilinestring); 314 var output = parser.write(data); 315 t.eq(output, multilinestring_xy, "MultiLine geometry round trips correctly."); 316 } 317 156 318 157 319 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', … … 199 361 'polygon_with_holes': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 4,5 3,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>11,12 14,15 13,16 11,12</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>', 200 362 'multipoint': '<gml:MultiPoint><gml:Point><gml:coordinates>1,2,3</gml:coordinates></gml:Point><gml:Point><gml:coordinates>4,5,6</gml:coordinates></gml:Point></gml:MultiPoint>', 201 'multilinestring': '<gml:MultiLineString><gml:LineString><gml:coordinates>1,2,3 4,5,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>11,12,13 14,15,16</gml:coordinates></gml:LineString></gml:MultiLineString>' // , 363 'multilinestring': '<gml:MultiLineString><gml:LineString><gml:coordinates>1,2,3 4,5,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>11,12,13 14,15,16</gml:coordinates></gml:LineString></gml:MultiLineString>', 364 'envelope': '<gml:Envelope><gml:lowerCorner>0 1</gml:lowerCorner><gml:upperCorner>20 21</gml:upperCorner></gml:Envelope>' // , 202 365 // 'multipolygon_with_holes': '<gml:MultiPolygon><gml:Polygon><gml:outerBoundaryIs>1,2 4,5 3,6 1,2</gml:outerBoundaryIs><gml:innerBoundaryIs>11,12 14,15 13,16 11,12</gml:innerBoundaryIs></gml:Polygon><gml:Polygon><gml:outerBoundaryIs>101,102 104,105 103,106 101,102</gml:outerBoundaryIs><gml:innerBoundaryIs>111,112 114,115 113,116 111,112</gml:innerBoundaryIs></gml:Polygon></gml:MultiPolygon>' 203 366 }; 367 368 369 // 370 // The following data has the (x y) reordered to (y x), in 3 dimensions it goes from (x y z) to (y x z) 371 // 372 373 var serialize_geoms_yx = { 374 'point': '<gml:Point><gml:coordinates decimal="." cs="," ts=" ">2,1</gml:coordinates></gml:Point>', 375 'linestring': '<gml:LineString><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4</gml:coordinates></gml:LineString>', 376 'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>', 377 'multipoint': '<gml:MultiPoint><gml:pointMember><gml:Point><gml:coordinates decimal="." cs="," ts=" ">2,1</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates decimal="." cs="," ts=" ">5,4</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint>', 378 'multilinestring': '<gml:MultiLineString><gml:lineStringMember><gml:LineString><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates decimal="." cs="," ts=" ">12,11 15,14</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>' 379 }; 380 var geoms_yx = { 381 'point': '<gml:Point><gml:coordinates>2,1,3</gml:coordinates></gml:Point>', 382 'linestring': '<gml:LineString><gml:coordinates>2,1,3 5,4,6</gml:coordinates></gml:LineString>', 383 'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>', 384 'polygon_with_holes': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>12,11 15,14 16,13 12,11</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>', 385 'multipoint': '<gml:MultiPoint><gml:Point><gml:coordinates>2,1,3</gml:coordinates></gml:Point><gml:Point><gml:coordinates>5,4,6</gml:coordinates></gml:Point></gml:MultiPoint>', 386 'multilinestring': '<gml:MultiLineString><gml:LineString><gml:coordinates>2,1,3 5,4,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>12,11,13 15,14,16</gml:coordinates></gml:LineString></gml:MultiLineString>', 387 'envelope': '<gml:Envelope><gml:lowerCorner>1 0</gml:lowerCorner><gml:upperCorner>21 20</gml:upperCorner></gml:Envelope>' 388 }; 389 204 390 </script> 205 391 </head> trunk/openlayers/tests/Format/test_GeoRSS.html
r4779 r5238 45 45 } 46 46 } 47 function test_Format_GeoRSS_gml_roundtrip(t) { 48 t.plan(input_gml.length); 49 var parser = new OpenLayers.Format.GeoRSS(); 50 for(var i=0; i < input_gml.length; i++) { 51 var feed = shell_start_gml+input_gml[i]+shell_end_gml; 52 var data = parser.read(feed); 53 var out = parser.write(data); 54 t.eq(out, output_gml[i], "Output gave expected value"); 55 } 56 } 47 57 48 58 var shell_start = '<feed xmlns="http://www.w3.org/2005/Atom" \n xmlns:georss="http://www.georss.org/georss">\n <title>scribble</title>\n <id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id>\n <author><name>FeatureServer</name></author>\n'; … … 53 63 ]; 54 64 var output= ['<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/562.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">-5.9765625 -131.484375 -58.0078125 -112.5 -50.2734375 -32.34375 52.3828125 -114.609375 -35.5078125 -167.34375 -57.3046875 -146.953125 -34.1015625 -139.921875 -5.9765625 -131.484375</georss:polygon></item></rss>', 55 '<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: 00ccff<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/796.atom</link><georss:point xmlns:georss="http://www.georss.org/georss">75.5859375 15.46875</georss:point></item></rss>', 56 '<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 5</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 5<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/794.atom</link><georss:line xmlns:georss="http://www.georss.org/georss">28.828125 32.6953125 49.921875 34.8046875 39.375 58.0078125 39.375 58.0078125 40.078125 58.0078125 41.484375 58.0078125 43.59375 58.0078125 45.703125 58.7109375 47.8125 58.7109375 49.21875 58.7109375 51.328125 59.4140625 52.03125 59.4140625 54.140625 60.8203125 56.25 61.5234375 56.25 62.2265625 57.65625 62.2265625 57.65625 62.9296875 58.359375 63.6328125 58.359375 65.0390625 58.359375 65.7421875 59.0625 66.4453125 59.0625 67.1484375 59.0625 68.5546875 59.765625 69.9609375 59.765625 72.0703125 59.765625 73.4765625 59.765625 76.2890625 59.765625 78.3984375 59.765625 79.8046875 59.765625 81.9140625 59.765625 83.3203125 59.0625 84.7265625 59.0625 86.8359375 58.359375 87.5390625 58.359375 88.2421875 56.953125 89.6484375 56.25 91.0546875 54.84375 93.8671875 52.03125 96.6796875 51.328125 98.7890625 50.625 100.1953125 49.21875 102.3046875 48.515625 103.7109375 47.8125 104.4140625 47.109375 105.8203125 46.40625 106.5234375 46.40625 107.9296875 45.703125 109.3359375 45 110.7421875 43.59375 112.8515625 43.59375 114.2578125 43.59375 114.9609375 42.890625 117.0703125 42.890625 117.7734375 42.1875 118.4765625 42.1875 119.1796875 42.1875 119.8828125</georss:line></item></rss>']; 65 '<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: 00ccff<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/796.atom</link><georss:point xmlns:georss="http://www.georss.org/georss">75.5859375 15.46875</georss:point></item></rss>', 66 '<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 5</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 5<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/794.atom</link><georss:line xmlns:georss="http://www.georss.org/georss">28.828125 32.6953125 49.921875 34.8046875 39.375 58.0078125 39.375 58.0078125 40.078125 58.0078125 41.484375 58.0078125 43.59375 58.0078125 45.703125 58.7109375 47.8125 58.7109375 49.21875 58.7109375 51.328125 59.4140625 52.03125 59.4140625 54.140625 60.8203125 56.25 61.5234375 56.25 62.2265625 57.65625 62.2265625 57.65625 62.9296875 58.359375 63.6328125 58.359375 65.0390625 58.359375 65.7421875 59.0625 66.4453125 59.0625 67.1484375 59.0625 68.5546875 59.765625 69.9609375 59.765625 72.0703125 59.765625 73.4765625 59.765625 76.2890625 59.765625 78.3984375 59.765625 79.8046875 59.765625 81.9140625 59.765625 83.3203125 59.0625 84.7265625 59.0625 86.8359375 58.359375 87.5390625 58.359375 88.2421875 56.953125 89.6484375 56.25 91.0546875 54.84375 93.8671875 52.03125 96.6796875 51.328125 98.7890625 50.625 100.1953125 49.21875 102.3046875 48.515625 103.7109375 47.8125 104.4140625 47.109375 105.8203125 46.40625 106.5234375 46.40625 107.9296875 45.703125 109.3359375 45 110.7421875 43.59375 112.8515625 43.59375 114.2578125 43.59375 114.9609375 42.890625 117.0703125 42.890625 117.7734375 42.1875 118.4765625 42.1875 119.1796875 42.1875 119.8828125</georss:line></item></rss>' 67 ]; 68 69 var shell_start_gml = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss"> <title>scribble</title><id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id><author><name>FeatureServer</name></author>'; 70 var shell_end_gml = '</feed>'; 71 var input_gml = ['<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Point><gml:pos>0 10</gml:pos></gml:Point></georss:where></entry>', 72 '<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>110,-50 110,-10 155,-10 155,-50 110,-50</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></georss:where></entry>', 73 '<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:LineString><gml:coordinates>0,10 10,20</gml:coordinates></gml:LineString></georss:where></entry>', 74 '<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Envelope><gml:lowerCorner>0 1</gml:lowerCorner><gml:upperCorner>20 21</gml:upperCorner></gml:Envelope></georss:where></entry>' 75 ]; 76 var output_gml = ['<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:point xmlns:georss="http://www.georss.org/georss">0 10</georss:point></item></rss>', 77 '<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">110 -50 110 -10 155 -10 155 -50 110 -50</georss:polygon></item></rss>', 78 '<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:line xmlns:georss="http://www.georss.org/georss">0 10 10 20</georss:line></item></rss>', 79 '<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">0 1 0 21 20 21 20 1 0 1</georss:polygon></item></rss>' 80 ]; 57 81 58 82 </script>
