Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes a bug where an explicit tileSize was not being honored #56

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion leaflet-iiif.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({
_this._setQuality();

// Unless an explicit tileSize is set, use a preferred tileSize
if (!_this.explicitTileSize) {
if (!_this._explicitTileSize) {
// Set the default first
_this.options.tileSize = 256;
if (data.tiles) {
// Image API 2.0 Case
_this.options.tileSize = data.tiles[0].width;
Expand Down
48 changes: 48 additions & 0 deletions spec/LTileLayerIiifSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,52 @@ describe('L.TileLayer.Iiif', function() {
});
});
});

describe('tileSize', function() {
var iiifLayer;

afterEach(function() {
iiifLayer.off('load');
});

describe('when not specified', function() {
it('uses the tileSize from info.json v2', function(done) {
iiifLayer = L.tileLayer.iiif('http://localhost:9876/base/fixtures/mlk/info.json');
map.addLayer(iiifLayer);
iiifLayer.on('load', function() {
expect(iiifLayer.options.tileSize).toBe(1024);
done();
});
});
it('uses the tileSize from info.json v1', function(done) {
iiifLayer = L.tileLayer.iiif('http://localhost:9876/base/fixtures/statue_info.json');
map.addLayer(iiifLayer);
iiifLayer.on('load', function() {
expect(iiifLayer.options.tileSize).toBe(1024);
done();
});
});
it('uses default tileSize (not specified in info.json)', function(done) {
iiifLayer = L.tileLayer.iiif('http://localhost:9876/base/fixtures/edge_case/info.json');
map.addLayer(iiifLayer);
iiifLayer.on('load', function() {
expect(iiifLayer.options.tileSize).toBe(256);
done();
});
});
});
describe('when specified', function() {
it('uses the explicitly defined one', function(done) {
iiifLayer = L.tileLayer.iiif('http://localhost:9876/base/fixtures/mlk/info.json', {
tileSize: 512
});
map.addLayer(iiifLayer);
iiifLayer.on('load', function() {
expect(iiifLayer.options.tileSize).toBe(512);
done();
});
});
});

});
});
21 changes: 21 additions & 0 deletions spec/fixtures/edge_case/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@context": "http://library.stanford.edu/iiif/image-api/1.1/context.json",
"@id": "http://ids.lib.harvard.edu/ids/iiif/25286610",
"width": 4132,
"height": 8176,
"scale_factors": [
1,
2,
4,
8,
16,
32
],
"formats": [
"jpg"
],
"qualities": [
"native"
],
"profile": "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1"
}