Allow Zoomify url without TileGroup, z, x and y placeholder

This commit is contained in:
Andreas Hocevar
2017-02-10 10:41:23 +00:00
committed by Frederic Junod
parent a4a8d01bac
commit da4ddccad9
5 changed files with 28 additions and 23 deletions

View File

@@ -2,26 +2,9 @@
### Next release
#### `ol.source.Zoomify` `url` is now a template
#### Simpler `ol.source.Zoomify` `url` configuration
The `url` for the `ol.source.Zoomify` source is now a template. The `{x}`, `{y}`, `{z}` and `{TileGroup}` placeholders
must be included in the `url`.
If you had:
```js
new ol.source.Zoomify({
url: 'https://www.example.com/cgi-bin/iipsrv.fcgi?zoomify=/a/b/'
});
```
It needs to be changed to:
```js
new ol.source.Zoomify({
url: 'https://www.example.com/cgi-bin/iipsrv.fcgi?zoomify=/a/b/{TileGroup}/{z}-{x}-{y}.jpg'
});
```
And the `url` can now include subdomains:
Instead specifying a base url, the `url` for the `ol.source.Zoomify` source can now be a template. The `{TileGroup}`, `{x}`, `{y}`, `{z}` and placeholders must be included in the `url` in this case. the `url` can now also include subdomain placeholders:
```js
new ol.source.Zoomify({
url: 'https://{a-f}.example.com/cgi-bin/iipsrv.fcgi?zoomify=/a/b/{TileGroup}/{z}-{x}-{y}.jpg'

View File

@@ -8,7 +8,7 @@ var imgHeight = 6100;
var source = new ol.source.Zoomify({
url: 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' +
'/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/{TileGroup}/{z}-{x}-{y}.jpg',
'/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/',
size: [imgWidth, imgHeight],
crossOrigin: 'anonymous'
});

View File

@@ -6759,7 +6759,11 @@ olx.source.ZoomifyOptions.prototype.reprojectionErrorThreshold;
/**
* URL template. Must include `{x}`, `{y}`, `{z}` and `{TileGroup}` placeholders.
* URL template or base URL of the Zoomify service. A base URL is the fixed part
* of the URL, excluding the tile group, z, x, and y folder structure, e.g.
* `http://my.zoomify.info/IMAGE.TIF/`. A URL template must include
* `{TileGroup}`, `{x}`, `{y}`, and `{z}` placeholders, e.g.
* `http://my.zoomify.info/IMAGE.TIF/{TileGroup}/{z}-{x}-{y}.jpg`.
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
* used instead of defining each one separately in the `urls` option.
* @type {!string}

View File

@@ -83,7 +83,11 @@ ol.source.Zoomify = function(opt_options) {
resolutions: resolutions
});
var urls = ol.TileUrlFunction.expandUrl(options.url);
var url = options.url;
if (url && url.indexOf('{TileGroup}') == -1) {
url += '{TileGroup}/{z}-{x}-{y}.jpg';
}
var urls = ol.TileUrlFunction.expandUrl(url);
/**
* @param {string} template Template.

View File

@@ -167,7 +167,7 @@ describe('ol.source.Zoomify', function() {
describe('generated tileUrlFunction', function() {
it('creates an expected tileUrlFunction', function() {
it('creates an expected tileUrlFunction with template', function() {
var source = getZoomifySource();
var tileUrlFunction = source.getTileUrlFunction();
// zoomlevel 0
@@ -179,6 +179,20 @@ describe('ol.source.Zoomify', function() {
expect(tileUrlFunction([1, 1, -2])).to.eql('zoomify-url/TileGroup0/1-1-1.jpg');
});
it('creates an expected tileUrlFunction without template', function() {
var source = new ol.source.Zoomify({
url: 'zoomify-url/',
size: size
});
var tileUrlFunction = source.getTileUrlFunction();
// zoomlevel 0
expect(tileUrlFunction([0, 0, -1])).to.eql('zoomify-url/TileGroup0/0-0-0.jpg');
// zoomlevel 1
expect(tileUrlFunction([1, 0, -1])).to.eql('zoomify-url/TileGroup0/1-0-0.jpg');
expect(tileUrlFunction([1, 1, -1])).to.eql('zoomify-url/TileGroup0/1-1-0.jpg');
expect(tileUrlFunction([1, 0, -2])).to.eql('zoomify-url/TileGroup0/1-0-1.jpg');
expect(tileUrlFunction([1, 1, -2])).to.eql('zoomify-url/TileGroup0/1-1-1.jpg');
});
it('returns undefined if no tileCoord passed', function() {
var source = getZoomifySource();
var tileUrlFunction = source.getTileUrlFunction();