Merge pull request #6139 from bartvde/wmts-proj

Match equivalent projections from WMTS caps
This commit is contained in:
Bart van den Eijnden
2016-11-16 18:27:33 +01:00
committed by GitHub
2 changed files with 18 additions and 3 deletions

View File

@@ -317,9 +317,14 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var tileMatrixSet = ol.array.find(tileMatrixSets, function(el) {
return el['Identifier'] == elt['TileMatrixSet'];
});
return tileMatrixSet['SupportedCRS'].replace(
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'
) == config['projection'];
var supportedCRS = tileMatrixSet['SupportedCRS'].replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3');
var proj1 = ol.proj.get(supportedCRS);
var proj2 = ol.proj.get(config['projection']);
if (proj1 && proj2) {
return ol.proj.equivalent(proj1, proj2);
} else {
return supportedCRS == config['projection'];
}
});
} else {
idx = ol.array.findIndex(l['TileMatrixSetLink'],

View File

@@ -95,6 +95,16 @@ describe('ol.source.WMTS', function() {
expect(options.matrixSet).to.be.eql('google3857');
});
it('can find a MatrixSet by equivalent SRS identifier', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
projection: 'EPSG:900913',
requestEncoding: 'REST'
});
expect(options.matrixSet).to.be.eql('google3857');
});
});
describe('when creating tileUrlFunction', function() {