diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 0028ee6100..a96ff72c58 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -446,15 +446,16 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { } else { var gets = wmtsCap['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get']; - var constraint = goog.array.find(gets[0]['Constraint'], - function(elt, index, array) { - return elt['name'] == 'GetEncoding'; - }); - var encodings = constraint['AllowedValues']['Value']; - if (encodings.length > 0 && goog.array.contains(encodings, 'KVP')) { - requestEncoding = ol.source.WMTSRequestEncoding.KVP; - urls.push(/** @type {string} */ (gets[0]['href'])); - + for (var i = 0, ii = gets.length; i < ii; ++i) { + var constraint = goog.array.find(gets[i]['Constraint'], + function(elt, index, array) { + return elt['name'] == 'GetEncoding'; + }); + var encodings = constraint['AllowedValues']['Value']; + if (encodings.length > 0 && goog.array.contains(encodings, 'KVP')) { + requestEncoding = ol.source.WMTSRequestEncoding.KVP; + urls.push(/** @type {string} */ (gets[i]['href'])); + } } } goog.asserts.assert(urls.length > 0, 'At least one URL found'); diff --git a/test/spec/ol/format/wmts/arcgis.xml b/test/spec/ol/format/wmts/arcgis.xml new file mode 100644 index 0000000000..d98f965335 --- /dev/null +++ b/test/spec/ol/format/wmts/arcgis.xml @@ -0,0 +1,408 @@ + + + + + Demographics_USA_Population_Density + OGC WMTS + 1.0.0 + + + + + + + + + + RESTful + + + + + + + + KVP + + + + + + + + + + + + + RESTful + + + + + + + KVP + + + + + + + + + + + Demographics_USA_Population_Density + Demographics_USA_Population_Density + + -1.98402303899E7 2144435.3407000005 + -7452840.4651999995 1.1536810662600003E7 + + + -178.2278219969978 18.910787002877576 + -66.95000499993604 71.38957425051252 + + + image/png + + default028mm + + + + GoogleMapsCompatible + + + + + + TileMatrix using 0.28mm + The tile matrix set that has scale values calculated based on the dpi + defined by OGC specification (dpi assumes 0.28mm as the physical distance of a + pixel). + default028mm + urn:ogc:def:crs:EPSG::3857 + + 0 + 5.590822640285016E8 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 1 + 1 + + + 1 + 2.7954113201425034E8 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 1 + 1 + + + 2 + 1.3977056600712562E8 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 2 + 2 + + + 3 + 6.988528300356235E7 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 3 + 4 + + + 4 + 3.494264150178117E7 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 6 + 8 + + + 5 + 1.7471320750890587E7 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 11 + 15 + + + 6 + 8735660.375445293 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 21 + 29 + + + 7 + 4367830.187722647 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 41 + 58 + + + 8 + 2183915.0938617955 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 81 + 115 + + + 9 + 1091957.5469304253 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 161 + 229 + + + 10 + 545978.7734656851 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 322 + 458 + + + 11 + 272989.38673237007 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 644 + 915 + + + 12 + 136494.69336618503 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 1287 + 1829 + + + 13 + 68247.34668309252 + -2.0037508342787E7 2.0037508342787E7 + 256 + 256 + 2573 + 3658 + + + + GoogleMapsCompatible + the wellknown 'GoogleMapsCompatible' tile matrix set defined by OGC WMTS + specification + GoogleMapsCompatible + urn:ogc:def:crs:EPSG:6.18.3:3857 + urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible + + 0 + 559082264.0287178 + -20037508.34278925 20037508.34278925 + 256 + 256 + 1 + 1 + + + 1 + 279541132.0143589 + -20037508.34278925 20037508.34278925 + 256 + 256 + 2 + 2 + + + 2 + 139770566.0071794 + -20037508.34278925 20037508.34278925 + 256 + 256 + 4 + 4 + + + 3 + 69885283.00358972 + -20037508.34278925 20037508.34278925 + 256 + 256 + 8 + 8 + + + 4 + 34942641.50179486 + -20037508.34278925 20037508.34278925 + 256 + 256 + 16 + 16 + + + 5 + 17471320.75089743 + -20037508.34278925 20037508.34278925 + 256 + 256 + 32 + 32 + + + 6 + 8735660.375448715 + -20037508.34278925 20037508.34278925 + 256 + 256 + 64 + 64 + + + 7 + 4367830.187724357 + -20037508.34278925 20037508.34278925 + 256 + 256 + 128 + 128 + + + 8 + 2183915.093862179 + -20037508.34278925 20037508.34278925 + 256 + 256 + 256 + 256 + + + 9 + 1091957.546931089 + -20037508.34278925 20037508.34278925 + 256 + 256 + 512 + 512 + + + 10 + 545978.7734655447 + -20037508.34278925 20037508.34278925 + 256 + 256 + 1024 + 1024 + + + 11 + 272989.3867327723 + -20037508.34278925 20037508.34278925 + 256 + 256 + 2048 + 2048 + + + 12 + 136494.6933663862 + -20037508.34278925 20037508.34278925 + 256 + 256 + 4096 + 4096 + + + 13 + 68247.34668319309 + -20037508.34278925 20037508.34278925 + 256 + 256 + 8192 + 8192 + + + 14 + 34123.67334159654 + -20037508.34278925 20037508.34278925 + 256 + 256 + 16384 + 16384 + + + 15 + 17061.83667079827 + -20037508.34278925 20037508.34278925 + 256 + 256 + 32768 + 32768 + + + 16 + 8530.918335399136 + -20037508.34278925 20037508.34278925 + 256 + 256 + 65536 + 65536 + + + 17 + 4265.459167699568 + -20037508.34278925 20037508.34278925 + 256 + 256 + 131072 + 131072 + + + 18 + 2132.729583849784 + -20037508.34278925 20037508.34278925 + 256 + 256 + 262144 + 262144 + + + + + diff --git a/test/spec/ol/source/wmtssource.test.js b/test/spec/ol/source/wmtssource.test.js index 6ebb225abc..41e7c57299 100644 --- a/test/spec/ol/source/wmtssource.test.js +++ b/test/spec/ol/source/wmtssource.test.js @@ -18,8 +18,7 @@ describe('ol.source.WMTS', function() { it('can create KVP options from spec/ol/format/wmts/ogcsample.xml', function() { - var options; - options = ol.source.WMTS.optionsFromCapabilities( + var options = ol.source.WMTS.optionsFromCapabilities( capabilities, { layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857' }); @@ -49,8 +48,7 @@ describe('ol.source.WMTS', function() { it('can create REST options from spec/ol/format/wmts/ogcsample.xml', function() { - var options; - options = ol.source.WMTS.optionsFromCapabilities( + var options = ol.source.WMTS.optionsFromCapabilities( capabilities, { layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857', requestEncoding: 'REST' }); @@ -134,6 +132,36 @@ describe('ol.source.WMTS', function() { }); }); + + describe('when creating options from Esri capabilities', function() { + var parser = new ol.format.WMTSCapabilities(); + var capabilities; + before(function(done) { + afterLoadText('spec/ol/format/wmts/arcgis.xml', function(xml) { + try { + capabilities = parser.read(xml); + } catch (e) { + done(e); + } + done(); + }); + }); + + it('can create KVP options from spec/ol/format/wmts/arcgis.xml', + function() { + var options = ol.source.WMTS.optionsFromCapabilities( + capabilities, { + layer: 'Demographics_USA_Population_Density', + matrixSet: 'default028mm' + }); + + expect(options.urls).to.be.an('array'); + expect(options.urls).to.have.length(1); + expect(options.urls[0]).to.be.eql( + 'http://services.arcgisonline.com/arcgis/rest/services/' + + 'Demographics/USA_Population_Density/MapServer/WMTS?'); + }); + }); }); goog.require('ol.format.WMTSCapabilities');