Skip to content

Commit

Permalink
support for tarzoom in javasceript and build_tarzoom preserve tiles s…
Browse files Browse the repository at this point in the history
…izes.
  • Loading branch information
ponchio committed Jul 28, 2024
1 parent c0862e3 commit fd6b614
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
33 changes: 33 additions & 0 deletions js/relight-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,39 @@ initTree: function() {

break;

case "tarzoom":
t.tarzoom =[];
t.metaDataURL = t.url + "/" + t.img + ".tzi";
t.getTileURL = function (image, x, y, level) {
var prefix = image.substr(0, image.lastIndexOf("."));
var base = t.url + '/' + t.img + '.tzb';

return base + ilevel + '/' + x + '_' + y + t.suffix;
};

this.getTileURL = (rasterid, tile) => {
const tar = this.tarzoom[rasterid];
tile.start = tar.offsets[tile.index];
tile.end = tar.offsets[tile.index+1];
return tar.url;
};

t.parseMetaData = function (response) {
if (!response.ok) {
throw new Error("Failed loading " + url + ": " + response.statusText);
}
let json = await response.json();
json.url = url.substr(0, url.lastIndexOf(".")) + '.tzb';
Object.assign(t, json);
t.suffix = t.format;
var max = Math.max(t.width, t.height)/t.tilesize;
t.nlevels = Math.ceil(Math.log(max) / Math.LN2) + 1;
t.tarzoom.push(json);
};

break;


case "zoomify":
t.overlap = 0; //overlap is not specified!
t.metaDataURL = t.url + "/" + t.img + "/ImageProperties.xml";
Expand Down
10 changes: 7 additions & 3 deletions scripts/build_tarzoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

import re, os, sys, json, glob, shutil

tilesize_re = re.compile('TileSize="(\d+)"')
overlap_re = re.compile('Overlap="(\d+)"')
width_re = re.compile('Width="(\d+)"')
height_re = re.compile('Height="(\d+)"')
pos_re = re.compile("(\d+)_(\d+).jp.*g")

tilesize = 256
overlap = 0

format = 'jpg'

def tarzoom(basename):
index = { "tilesize": tilesize, "overlap": 0, "format":format, "offsets": [0] }

index = { "format":format, "offsets": [0] }

print(basename)
with open(basename + '.dzi') as f:
contents = f.read()
w = index['width'] = int(width_re.search(contents).group(1))
h = index['height'] = int(height_re.search(contents).group(1))
tilesize = index['tilesize'] = int(tilesize_re.search(contents).group(1))
overlap = index['overlap'] = int(overlap_re.search(contents).group(1))


data = open(basename + ".tzb", 'wb')
Expand Down

0 comments on commit fd6b614

Please sign in to comment.