From 0915fb72a2e6f48a343fe9ac6121c1a2a42c0321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 14 Sep 2012 17:16:46 +0200 Subject: [PATCH] Add RESTful compatibility support --- lib/OpenLayers/Format/WMTSCapabilities.js | 9 ++- tests/Format/WMTSCapabilities/v1_0_0.html | 83 ++++++++++++++++++++++- 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index b23bf2bd66..29b8af7ac1 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -139,8 +139,13 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers // Get first get method if (http.get[0].constraints) { var constraints = http.get[0].constraints; - if (!constraints.GetEncoding.allowedValues.KVP && - constraints.GetEncoding.allowedValues.REST) { + var allowedValues = constraints.GetEncoding.allowedValues; + + // The OGC documentation is not clear if we should use + // REST or RESTful, ArcGis use RESTful, + // and OpenLayers use REST. + if (!allowedValues.KVP && + (allowedValues.REST || allowedValues.RESTful)) { requestEncoding = "REST"; } } diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index c5229df4c1..f4fadeb614 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -150,7 +150,7 @@ } function test_createLayer(t) { - t.plan(42); + t.plan(43); var format = new OpenLayers.Format.WMTSCapabilities(); @@ -308,6 +308,15 @@ requestEncoding: 'KVP' }); t.eq(layer.url[0], "http://wmts.geo.admin.ch/kvp", "correct kvp url 2"); + + // test RESTfull + xml = document.getElementById("arcgis").firstChild.nodeValue; + doc = new OpenLayers.Format.XML().read(xml); + caps = format.read(doc); + layer = format.createLayer(caps, { + layer: "WorldTimeZones" + }); + t.eq(layer.requestEncoding, "REST", "correct requestEncoding (in RESTfull)"); } function test_parse_projection(t) { @@ -875,6 +884,78 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml --> +