Flip extent coordinates for projections with ne* axis order
This commit is contained in:
@@ -461,7 +461,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
}
|
||||
|
||||
let wrapX = false;
|
||||
const switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';
|
||||
const switchXY = projection.getAxisOrientation().substr(0, 2) == 'ne';
|
||||
|
||||
let matrix = matrixSetObj.TileMatrix[0];
|
||||
|
||||
@@ -491,12 +491,20 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
|
||||
const resolution =
|
||||
(matrix.ScaleDenominator * 0.00028) / projection.getMetersPerUnit(); // WMTS 1.0.0: standardized rendering pixel size
|
||||
const origin = switchOriginXY
|
||||
const origin = switchXY
|
||||
? [matrix.TopLeftCorner[1], matrix.TopLeftCorner[0]]
|
||||
: matrix.TopLeftCorner;
|
||||
const tileSpanX = matrix.TileWidth * resolution;
|
||||
const tileSpanY = matrix.TileHeight * resolution;
|
||||
const matrixSetExtent = matrixSetObj['BoundingBox'];
|
||||
let matrixSetExtent = matrixSetObj['BoundingBox'];
|
||||
if (matrixSetExtent && switchXY) {
|
||||
matrixSetExtent = [
|
||||
matrixSetExtent[1],
|
||||
matrixSetExtent[0],
|
||||
matrixSetExtent[3],
|
||||
matrixSetExtent[2],
|
||||
];
|
||||
}
|
||||
let extent = [
|
||||
origin[0] + tileSpanX * selectedMatrixLimit.MinTileCol,
|
||||
// add one to get proper bottom/right coordinate
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -475,6 +475,34 @@ describe('ol/source/WMTS', function () {
|
||||
expectDelta(extent[3], expectedMatrixSetExtend[3]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when creating options from epsg:4326 capabilities with BoundingBox', function () {
|
||||
const parser = new WMTSCapabilities();
|
||||
let capabilities;
|
||||
before(function (done) {
|
||||
afterLoadText(
|
||||
'spec/ol/format/wmts/capabilities_epsg4326_with_boundingbox.xml',
|
||||
function (xml) {
|
||||
try {
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('returns correct bounding box when the layer has BoundingBox', function () {
|
||||
const options = optionsFromCapabilities(capabilities, {
|
||||
layer: 's2cloudless-2020',
|
||||
});
|
||||
|
||||
const extent = options.tileGrid.getExtent();
|
||||
expect(extent).to.eql([-180, -90, 180, 90]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('set wrap x by bounding box if available', function () {
|
||||
const parser = new WMTSCapabilities();
|
||||
let capabilities;
|
||||
|
||||
Reference in New Issue
Block a user