Making it more convenient to create WMTS layers from capabilities documents. The format now has a createLayer method that takes a capabilities response object and a layer configuration object. This returns a properly configured WMTS layer based on the layer and matrix definition found in the capabilities. Unless otherwise specified, the layer name will be derived from the advertised title, and the style identifier will be the advertised default. r=ahocevar (closes #2676)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10449 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
var numOfStyles = layer.styles.length;
|
||||
t.eq(numOfStyles, 2, "correct count of styles");
|
||||
t.eq(layer.styles[0].identifier, "DarkBlue", "style 0 identifier is correct");
|
||||
t.eq(layer.styles[0].isDefault, "true", "style 0 isDefault is correct");
|
||||
t.eq(layer.styles[0].isDefault, true, "style 0 isDefault is correct");
|
||||
t.eq(layer.styles[0].title, "Dark Blue", "style 0 title is correct");
|
||||
t.eq(layer.styles[1].identifier, "thickAndRed", "style 1 identifier is correct");
|
||||
t.ok(!layer.styles[1].isDefault, "style 1 isDefault is correct");
|
||||
@@ -108,6 +108,54 @@
|
||||
t.eq(bigWorld.matrixIds[1].topLeftCorner.lon, -180, "tileMatrix 1 topLeftCorner.lon is correct");
|
||||
t.eq(bigWorld.matrixIds[1].topLeftCorner.lat, 84, "tileMatrix 1 topLeftCorner.lat is correct");
|
||||
}
|
||||
|
||||
function test_createLayer(t) {
|
||||
t.plan(6);
|
||||
|
||||
var format = new OpenLayers.Format.WMTSCapabilities();
|
||||
|
||||
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||
var doc = new OpenLayers.Format.XML().read(xml);
|
||||
|
||||
var caps = format.read(doc);
|
||||
var layer;
|
||||
|
||||
var success = true;
|
||||
try {
|
||||
// incomplete config (missing matrixSet)
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "coastlines"
|
||||
});
|
||||
} catch (err) {
|
||||
success = false;
|
||||
}
|
||||
t.ok(!success, "createLayer throws error if provided incomplete layer config");
|
||||
|
||||
// bogus layer identifier
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "foo",
|
||||
matrixSet: "BigWorld"
|
||||
});
|
||||
t.eq(layer, undefined, "createLayer returns undefined given bad layer identifier");
|
||||
|
||||
// bogus matrixSet identifier
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "coastlines",
|
||||
matrixSet: "TheWorld"
|
||||
});
|
||||
t.eq(layer, undefined, "createLayer returns undefined given bad matrixSet identifier");
|
||||
|
||||
layer = format.createLayer(caps, {
|
||||
layer: "coastlines",
|
||||
matrixSet: "BigWorld"
|
||||
});
|
||||
t.ok(layer instanceof OpenLayers.Layer.WMTS, "correct instance");
|
||||
|
||||
t.eq(layer.matrixIds.length, 2, "correct matrixIds length");
|
||||
t.eq(layer.name, "Coastlines", "correct layer title");
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user