| | 328 | function test_geometryTypes(t) { |
|---|
| | 329 | t.plan(8); |
|---|
| | 330 | var parser = new OpenLayers.Format.GML(); |
|---|
| | 331 | |
|---|
| | 332 | t.ok(parser.geometryTypes === null, "geometryTypes is null by default"); |
|---|
| | 333 | |
|---|
| | 334 | // test reading with null geometryTypes |
|---|
| | 335 | var data = parser.read(test_content[1]); |
|---|
| | 336 | t.eq(data.length, 2, "2 features read with null geometryTypes."); |
|---|
| | 337 | |
|---|
| | 338 | // test reading with ["Point"] geometryTypes |
|---|
| | 339 | parser.geometryTypes = ["Point"]; |
|---|
| | 340 | data = parser.read(test_content[1]); |
|---|
| | 341 | t.eq(data.length, 1, "1 feature read with ['Point'] geometryTypes."); |
|---|
| | 342 | t.ok(data[0].geometry instanceof OpenLayers.Geometry.Point, |
|---|
| | 343 | "only point geom read with ['Point'] geometryTypes."); |
|---|
| | 344 | |
|---|
| | 345 | // test reading with ["Polygon"] geometryTypes |
|---|
| | 346 | parser.geometryTypes = ["Polygon"]; |
|---|
| | 347 | data = parser.read(test_content[1]); |
|---|
| | 348 | t.eq(data.length, 1, "1 feature read with ['Polygon'] geometryTypes."); |
|---|
| | 349 | t.ok(data[0].geometry instanceof OpenLayers.Geometry.Polygon, |
|---|
| | 350 | "only point geom read with ['Polygon'] geometryTypes."); |
|---|
| | 352 | // test reading with ["Point", "Polygon"] geometryTypes |
|---|
| | 353 | parser.geometryTypes = ["Point", "Polygon"]; |
|---|
| | 354 | data = parser.read(test_content[1]); |
|---|
| | 355 | t.eq(data.length, 2, "2 feature read with ['Point', 'Polygon'] geometryTypes."); |
|---|
| | 356 | |
|---|
| | 357 | // test reading with ["foo"] geometryTypes |
|---|
| | 358 | parser.geometryTypes = ["foo"]; |
|---|
| | 359 | data = parser.read(test_content[1]); |
|---|
| | 360 | alert('f'); |
|---|
| | 361 | t.eq(data.length, 0, "0 features read with ['foo'] geometryTypes."); |
|---|
| | 362 | |
|---|
| | 363 | } |
|---|
| | 364 | |
|---|
| 329 | 365 | 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', |
|---|
| 330 | 366 | '<wfs:FeatureCollection' + |
|---|
| 331 | 367 | ' xmlns:fs="http://example.com/featureserver"' + |