Merge pull request #3942 from ahocevar/matrixset-by-projection
Fix WMTS TileMatrixSet lookup by SRS identifier
This commit is contained in:
@@ -351,19 +351,25 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
|
|
||||||
goog.asserts.assert(l['TileMatrixSetLink'].length > 0,
|
goog.asserts.assert(l['TileMatrixSetLink'].length > 0,
|
||||||
'layer has TileMatrixSetLink');
|
'layer has TileMatrixSetLink');
|
||||||
|
var tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
|
||||||
var idx, matrixSet;
|
var idx, matrixSet;
|
||||||
if (l['TileMatrixSetLink'].length > 1) {
|
if (l['TileMatrixSetLink'].length > 1) {
|
||||||
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
if (goog.isDef(config['projection'])) {
|
||||||
function(elt, index, array) {
|
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
||||||
return elt['TileMatrixSet'] == config['matrixSet'];
|
function(elt, index, array) {
|
||||||
});
|
var tileMatrixSet = goog.array.find(tileMatrixSets, function(el) {
|
||||||
} else if (goog.isDef(config['projection'])) {
|
return el['Identifier'] == elt['TileMatrixSet'];
|
||||||
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
});
|
||||||
function(elt, index, array) {
|
return tileMatrixSet['SupportedCRS'].replace(
|
||||||
return elt['TileMatrixSet']['SupportedCRS'].replace(
|
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'
|
||||||
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'
|
) == config['projection'];
|
||||||
) == config['projection'];
|
});
|
||||||
});
|
} else {
|
||||||
|
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
||||||
|
function(elt, index, array) {
|
||||||
|
return elt['TileMatrixSet'] == config['matrixSet'];
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
idx = 0;
|
idx = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,16 @@ describe('ol.source.WMTS', function() {
|
|||||||
expect(options.dimensions).to.eql({});
|
expect(options.dimensions).to.eql({});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can find a MatrixSet by SRS identifier', function() {
|
||||||
|
var options = ol.source.WMTS.optionsFromCapabilities(
|
||||||
|
capabilities,
|
||||||
|
{ layer: 'BlueMarbleNextGeneration', projection: 'EPSG:3857',
|
||||||
|
requestEncoding: 'REST' });
|
||||||
|
|
||||||
|
expect(options.matrixSet).to.be.eql('google3857');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when creating tileUrlFunction', function() {
|
describe('when creating tileUrlFunction', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user