Merge pull request #12409 from M393/wmts-bounding-box
Fix WMTS wrapX detection if WGS84BoundingBox is not set
This commit is contained in:
@@ -9,7 +9,7 @@ import {assign} from '../obj.js';
|
||||
import {containsExtent} from '../extent.js';
|
||||
import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js';
|
||||
import {createFromTileUrlFunctions, expandUrl} from '../tileurlfunction.js';
|
||||
import {equivalent, get as getProjection} from '../proj.js';
|
||||
import {equivalent, get as getProjection, transformExtent} from '../proj.js';
|
||||
import {find, findIndex, includes} from '../array.js';
|
||||
|
||||
/**
|
||||
@@ -497,9 +497,21 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
const wgs84BoundingBox = l['WGS84BoundingBox'];
|
||||
const wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent();
|
||||
extent = matrixSetExtent;
|
||||
wrapX =
|
||||
wgs84BoundingBox[0] === wgs84ProjectionExtent[0] &&
|
||||
wgs84BoundingBox[2] === wgs84ProjectionExtent[2];
|
||||
if (wgs84BoundingBox) {
|
||||
wrapX =
|
||||
wgs84BoundingBox[0] === wgs84ProjectionExtent[0] &&
|
||||
wgs84BoundingBox[2] === wgs84ProjectionExtent[2];
|
||||
} else {
|
||||
const wgs84MatrixSetExtent = transformExtent(
|
||||
matrixSetExtent,
|
||||
matrixSetObj['SupportedCRS'],
|
||||
'EPSG:4326'
|
||||
);
|
||||
// Ignore slight deviation from the correct x limits
|
||||
wrapX =
|
||||
wgs84MatrixSetExtent[0] - 1e-10 <= wgs84ProjectionExtent[0] &&
|
||||
wgs84MatrixSetExtent[2] + 1e-10 >= wgs84ProjectionExtent[2];
|
||||
}
|
||||
}
|
||||
|
||||
const tileGrid = createFromCapabilitiesMatrixSet(
|
||||
|
||||
1101
test/browser/spec/ol/format/wmts/capabilities_wrapx.xml
Normal file
1101
test/browser/spec/ol/format/wmts/capabilities_wrapx.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -458,6 +458,56 @@ describe('ol.source.WMTS', function () {
|
||||
expectDelta(extent[3], expectedMatrixSetExtend[3]);
|
||||
});
|
||||
});
|
||||
describe('set wrap x by bounding box if available', function () {
|
||||
const parser = new WMTSCapabilities();
|
||||
let capabilities;
|
||||
before(function (done) {
|
||||
afterLoadText(
|
||||
'spec/ol/format/wmts/capabilities_wrapx.xml',
|
||||
function (xml) {
|
||||
try {
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('sets wrapx when no bounding box is set', function () {
|
||||
const options = optionsFromCapabilities(capabilities, {
|
||||
layer: 'no-bb',
|
||||
matrixSet: 'EPSG:3857',
|
||||
crossOrigin: 'anonymous',
|
||||
});
|
||||
expect(options.wrapX).to.be(true);
|
||||
});
|
||||
it('sets wrapx when only wgs 84 bb is set', function () {
|
||||
const options = optionsFromCapabilities(capabilities, {
|
||||
layer: 'only-wgs84-bb',
|
||||
matrixSet: 'EPSG:3857',
|
||||
crossOrigin: 'anonymous',
|
||||
});
|
||||
expect(options.wrapX).to.be(true);
|
||||
});
|
||||
it('does not set wrapx when wgs84 bb is set', function () {
|
||||
const options = optionsFromCapabilities(capabilities, {
|
||||
layer: 'no-wrap-wgs84-bb',
|
||||
matrixSet: 'EPSG:3857',
|
||||
crossOrigin: 'anonymous',
|
||||
});
|
||||
expect(options.wrapX).to.be(false);
|
||||
});
|
||||
it('does not set wrapx when tile matrix does not wrap', function () {
|
||||
const options = optionsFromCapabilities(capabilities, {
|
||||
layer: 'no-wrap-tm',
|
||||
matrixSet: 'EPSG:3857',
|
||||
crossOrigin: 'anonymous',
|
||||
});
|
||||
expect(options.wrapX).to.be(false);
|
||||
});
|
||||
});
|
||||
describe('when creating options from capabilities with TileMatrixSetLink', function () {
|
||||
const parser = new WMTSCapabilities();
|
||||
let capabilities;
|
||||
|
||||
Reference in New Issue
Block a user