-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathiipimage.js
More file actions
52 lines (52 loc) · 1.88 KB
/
Copy pathiipimage.js
File metadata and controls
52 lines (52 loc) · 1.88 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
49
50
51
52
var iipimage = (function(){
return {
"name" : "IIPImage",
"description": "IIPImage image server",
"urls" : [
/^((?!topview).)*\?FIF=.*$/ // Topview uses FIF= but is not compatible with iipimage
],
"contents" : [
/\?FIF=/
],
"findFile" : function getInfoFile (baseUrl, callback) {
if (baseUrl.indexOf("?FIF=") > -1) {
return callback(baseUrl);
}
ZoomManager.getFile(baseUrl, {type:"htmltext"}, function (text) {
var fifMatch = text.match(/["']([^"']*?\?FIF=.*?)["']/);
if (fifMatch) {
var path = fifMatch[1];
var url = ZoomManager.resolveRelative(path, baseUrl);
return callback(url);
}
throw new Error("No IIPImage-related URL found.");
});
},
"open" : function (url) {
var baseUrl = url.match(/^.*\?FIF=[^&]*/)[0];
var infoUrl = baseUrl + "&OBJ=Max-size&OBJ=Tile-size&OBJ=Resolution-number";
ZoomManager.getFile(infoUrl, {type:"text"}, function (text, xhr) {
var sizeMatch = text.match(/Max-size:(\d+) (\d+)/);
var tileSizeMatch = text.match(/Tile-size:(\d+) (\d+)/);
var zoomMatch = text.match(/Resolution-number:(\d+)/);
if (!sizeMatch || !tileSizeMatch ||
sizeMatch.length !== 3 || tileSizeMatch.length !== 3) {
throw new Error("Invalid IIPImage information file.");
}
var data = {
"origin": baseUrl,
"width" : parseInt(sizeMatch[1]),
"height" : parseInt(sizeMatch[2]),
"tileSize" : parseInt(tileSizeMatch[1]),
"maxZoomLevel" : parseInt(zoomMatch[1])-1
};
ZoomManager.readyToRender(data);
});
},
"getTileURL" : function (x, y, zoom, data) {
var index = x + y * data.nbrTilesX;
return data.origin + "&JTL=" + zoom + "," + index;
}
};
})();
ZoomManager.addDezoomer(iipimage);