Merge pull request #7406 from lasselaakkonen/7390-zoomify-custom-extent
Add option to Zoomify source for setting custom extent
This commit is contained in:
@@ -7233,6 +7233,7 @@ olx.source.CartoDBOptions.prototype.account;
|
||||
* url: !string,
|
||||
* tierSizeCalculation: (string|undefined),
|
||||
* size: ol.Size,
|
||||
* extent: (ol.Extent|undefined),
|
||||
* transition: (number|undefined),
|
||||
* tileSize: (number|undefined)}}
|
||||
*/
|
||||
@@ -7325,6 +7326,17 @@ olx.source.ZoomifyOptions.prototype.tierSizeCalculation;
|
||||
olx.source.ZoomifyOptions.prototype.size;
|
||||
|
||||
|
||||
/**
|
||||
* Extent for the TileGrid that is created. Default sets the TileGrid in the
|
||||
* fourth quadrant, meaning extent is `[0, -height, width, 0]`. To change the
|
||||
* extent to the first quadrant (the default for OpenLayers 2) set the extent
|
||||
* as `[0, 0, width, height]`.
|
||||
* @type {ol.Extent|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.source.ZoomifyOptions.prototype.extent;
|
||||
|
||||
|
||||
/**
|
||||
* Duration of the opacity transition for rendering. To disable the opacity
|
||||
* transition, pass `transition: 0`.
|
||||
|
||||
@@ -33,6 +33,7 @@ ol.source.Zoomify = function(opt_options) {
|
||||
|
||||
var imageWidth = size[0];
|
||||
var imageHeight = size[1];
|
||||
var extent = options.extent || [0, -size[1], size[0], 0];
|
||||
var tierSizeInTiles = [];
|
||||
var tileSize = options.tileSize || ol.DEFAULT_TILE_SIZE;
|
||||
var tileSizeForTierSizeCalculation = tileSize;
|
||||
@@ -79,7 +80,6 @@ ol.source.Zoomify = function(opt_options) {
|
||||
}
|
||||
resolutions.reverse();
|
||||
|
||||
var extent = [0, -size[1], size[0], 0];
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
tileSize: tileSize,
|
||||
extent: extent,
|
||||
|
||||
@@ -25,6 +25,13 @@ describe('ol.source.Zoomify', function() {
|
||||
size: size
|
||||
});
|
||||
}
|
||||
function getZoomifySourceWithExtentInFirstQuadrant() {
|
||||
return new ol.source.Zoomify({
|
||||
url: zoomifyUrl,
|
||||
size: size,
|
||||
extent: [0, 0, size[0], size[1]]
|
||||
});
|
||||
}
|
||||
function getIIPSource() {
|
||||
return new ol.source.Zoomify({
|
||||
url: iipUrl,
|
||||
@@ -164,6 +171,31 @@ describe('ol.source.Zoomify', function() {
|
||||
expect(tileGrid.getTileSize()).to.eql(expectedTileSizes[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected extent', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
var expectedExtents = [
|
||||
[0, -size[1], size[0], 0],
|
||||
[0, 0, size[0], size[1]]
|
||||
];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getExtent()).to.eql(expectedExtents[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected origin', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
var expectedOrigins = [
|
||||
[0, 0],
|
||||
[0, size[1]]
|
||||
];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getOrigin()).to.eql(expectedOrigins[i]);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('tierSizeCalculation configuration', function() {
|
||||
|
||||
Reference in New Issue
Block a user