diff --git a/lib/OpenLayers/Format/GML/Base.js b/lib/OpenLayers/Format/GML/Base.js index 6673a7b5e3..e22aa047a3 100644 --- a/lib/OpenLayers/Format/GML/Base.js +++ b/lib/OpenLayers/Format/GML/Base.js @@ -379,7 +379,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, { ); } if(container.bounds) { - feature.geometry.bounds = container.bounds; + feature.bounds = container.bounds; } obj.features.push(feature); }, diff --git a/tests/Format/GML/v2.html b/tests/Format/GML/v2.html index 0887a69e3e..48f6abe534 100644 --- a/tests/Format/GML/v2.html +++ b/tests/Format/GML/v2.html @@ -188,12 +188,13 @@ xy: false }); var features = format.read(doc.documentElement); - var geom = features[0].geometry; - t.ok(geom.bounds instanceof OpenLayers.Bounds, "geometry given a bounds"); - t.eq(geom.bounds.left.toFixed(2), "-91.52", "bounds left correct"); - t.eq(geom.bounds.bottom.toFixed(2), "36.99", "bounds bottom correct"); - t.eq(geom.bounds.right.toFixed(2), "-87.51", "bounds right correct"); - t.eq(geom.bounds.top.toFixed(2), "42.51", "bounds top correct"); + var bounds = features[0].bounds; + + t.ok(bounds instanceof OpenLayers.Bounds, "feature given a bounds"); + t.eq(bounds.left.toFixed(2), "-91.52", "bounds left correct"); + t.eq(bounds.bottom.toFixed(2), "36.99", "bounds bottom correct"); + t.eq(bounds.right.toFixed(2), "-87.51", "bounds right correct"); + t.eq(bounds.top.toFixed(2), "42.51", "bounds top correct"); } function test_write(t) { @@ -229,6 +230,24 @@ t.eq(features[0].namespace, "http://mapserver.gis.umn.edu/mapserver", "Namespace is set correctly on feature"); } + function test_noGeom(t) { + t.plan(7); + var doc = readXML("v2/nogeom.xml"); + var format = new OpenLayers.Format.GML.v2({ + featureType: "DEPARTEMENT", + featureNS: "http://server.fr/geoserver/loc" + }); + var features = format.read(doc.documentElement); + t.eq(features.length, 2, "Expected 2 features from GML with no geom"); + var feature = features[0]; + t.ok(feature.geometry == null, "feature 0 has no geometry"); + var bounds = feature.bounds; + t.ok(bounds && (bounds instanceof OpenLayers.Bounds), "feature 0 has been assigned bounds"); + t.eq(bounds.left, 209565, "bounds left correct"); + t.eq(bounds.bottom, 6785323, "bounds bottom correct"); + t.eq(bounds.right, 337568, "bounds right correct"); + t.eq(bounds.top, 6885985, "bounds top correct"); + } @@ -642,5 +661,8 @@
+
diff --git a/tests/Format/GML/v3.html b/tests/Format/GML/v3.html index 7677297b97..0a53c9a1a3 100644 --- a/tests/Format/GML/v3.html +++ b/tests/Format/GML/v3.html @@ -179,13 +179,13 @@ xy: false }); var features = format.read(doc.documentElement); - - var geom = features[0].geometry; - t.ok(geom.bounds instanceof OpenLayers.Bounds, "geometry given a bounds"); - t.eq(geom.bounds.left.toFixed(2), "-91.52", "bounds left correct"); - t.eq(geom.bounds.bottom.toFixed(2), "36.99", "bounds bottom correct"); - t.eq(geom.bounds.right.toFixed(2), "-87.51", "bounds right correct"); - t.eq(geom.bounds.top.toFixed(2), "42.51", "bounds top correct"); + var bounds = features[0].bounds; + + t.ok(bounds instanceof OpenLayers.Bounds, "feature given a bounds"); + t.eq(bounds.left.toFixed(2), "-91.52", "bounds left correct"); + t.eq(bounds.bottom.toFixed(2), "36.99", "bounds bottom correct"); + t.eq(bounds.right.toFixed(2), "-87.51", "bounds right correct"); + t.eq(bounds.top.toFixed(2), "42.51", "bounds top correct"); } function test_read(t) {