-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathvls.js
More file actions
48 lines (45 loc) · 1.53 KB
/
Copy pathvls.js
File metadata and controls
48 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var vls = (function () {
return {
name: 'VLS',
description: 'Visual Library Server, by semantics',
urls: [
/\/(thumbview|pageview|zoom)\/\d+$/
],
contents: [],
findFile: function getInfoFile(baseUrl, callback) {
var url = baseUrl.replace(/\/(thumbview|pageview|zoom)\//, '/zoom/');
callback(url);
},
open: function (url) {
ZoomManager.getFile(url, { type: 'xml' }, function (doc, xhr) {
var vars = {};
var varNodes = doc.getElementsByTagName('var');
for (var i = 0; i < varNodes.length; i++) {
vars[varNodes[i].getAttribute('id')] = varNodes[i].getAttribute('value');
}
var mapNode = doc.getElementById('map');
var id = mapNode ? mapNode.getAttribute('vls:ot_id') : null;
if (!id) {
throw new Error('Unable to extract image ID');
}
var width = parseInt(mapNode.getAttribute('vls:width'));
var height = parseInt(mapNode.getAttribute('vls:height'));
var path = ['/image/tiler/square', id, 0].join('/');
var tileSize = parseInt(vars['zoomTileSize']);
// Workaround: avoid cropping at the bottom
height = (Math.floor((height - 1) / tileSize) + 1) * tileSize;
ZoomManager.readyToRender({
origin: url,
path: path,
width: width,
height: height,
tileSize: 1024,
});
});
},
getTileURL: function (x, y, zoom, data) {
return [data.path, x, y].join('/');
},
};
})();
ZoomManager.addDezoomer(vls);