auto-configure featureType and featureNS. p=bartvde (closes #3367)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12110 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-06-20 10:59:28 +00:00
parent 18ad6643b6
commit 30fc6ecd52
7 changed files with 140 additions and 19 deletions

View File

@@ -177,6 +177,21 @@
t.eq(attributes["LAND_KM"], "143986.61", "read LAND_KM");
}
function test_read_autoconfig(t) {
t.plan(5);
var doc = readXML("v2/topp-states.xml");
var format = new OpenLayers.Format.GML.v2();
var features = format.read(doc.documentElement);
t.eq(features.length, 3, "read 3 features");
var feature = features[0];
t.eq(feature.fid, "states.1", "read fid");
t.eq(feature.geometry.CLASS_NAME, "OpenLayers.Geometry.MultiPolygon",
"read multipolygon geometry");
t.eq(format.featureType, "states", "featureType correctly auto-configured");
t.eq(format.featureNS, "http://www.openplans.org/topp", "featureNS correctly auto-configured");
}
function test_boundedBy(t) {
t.plan(5);
@@ -248,6 +263,7 @@
t.eq(bounds.right, 337568, "bounds right correct");
t.eq(bounds.top, 6885985, "bounds top correct");
}
</script>
</head>
<body>

View File

@@ -212,6 +212,26 @@
t.eq(attributes["LAND_KM"], "143986.61", "read LAND_KM");
}
function test_read_autoconfig(t) {
t.plan(7);
var doc = readXML("v3/topp-states-wfs.xml");
var format = new OpenLayers.Format.GML.v3();
var features = format.read(doc.documentElement);
t.eq(features.length, 3, "read 3 features");
var feature = features[0];
t.eq(feature.fid, "states.1", "read fid");
t.eq(feature.geometry.CLASS_NAME, "OpenLayers.Geometry.MultiPolygon",
"read multipolygon geometry");
t.eq(format.featureType, "states", "featureType correctly auto-configured");
t.eq(format.featureNS, "http://www.openplans.org/topp", "featureNS correctly auto-configured");
t.eq(format.autoConfig, true, "autoConfig set to true");
format.autoConfig = false;
format.read(doc.documentElement);
t.eq(format.autoConfig, false, "now that featureNS is set, the format does not auto-configure again");
}
function test_emptyAttribute(t) {
t.plan(4);
var str =