Skip to content

Instantly share code, notes, and snippets.

@Arty2
Created November 12, 2015 12:42
Show Gist options
  • Save Arty2/ba059c3fc3e0927cf976 to your computer and use it in GitHub Desktop.
Save Arty2/ba059c3fc3e0927cf976 to your computer and use it in GitHub Desktop.
Strip tiles from http://acropolis-gis.ysma.gr/ (requires tweaking the code)
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
/*
reference:
http://acropolis-gis.ysma.gr/sites/default/files/Walls/krpano.xml
http://acropolis-gis.ysma.gr/sites/default/files/katopsi/krpano.xml
eg.: http://orbitlab.s3.amazonaws.com/projects/katopsi/gigaorthos/East_Wall.tiles/l5/05_06.jpg
*/
// var set = 'http://orbitlab.s3.amazonaws.com/projects/katopsi/gigaorthos/East_Wall.tiles/l6/', w = 38500, h = 11000;
// var set = 'http://orbitlab.s3.amazonaws.com/projects/katopsi/gigaorthos/East_Wall.tiles/l5/', w = 19250, h = 5500;
var set = 'http://orbitlab.s3.amazonaws.com/projects/katopsi/gigaorthos/External_South_E0.tiles/l4/', w = 3720, h = 6144;
var tile = 512;
var cols = Math.ceil(w/tile) + 1,
rows = Math.ceil(h/tile) + 1;
var canvas = document.getElementById('canvas');
canvas.width = tile * cols;
canvas.height = tile * rows;
var img = canvas.getContext('2d');
var tiles = [];
var i = 0;
for (var r = 1; r < rows; r++) {
for (var c = 1; c < cols; c++) {
tiles[i] = new Image();
tiles[i].src = set + ('00' + r).slice(-2) + '_' + ('00' + c).slice(-2) + '.jpg';
//console.log(tiles[i].src);
i++;
}
}
alert('wait for it to load...');
var i = 0;
for (var r = 1; r < rows; r++) {
for (var c = 1; c < cols; c++) {
img.drawImage(tiles[i], c * tile, r * tile);
i++;
}
}
// save canvas image as data url (png format by default)
window.location = canvas.toDataURL();
</script>
<noscript>enable javascript</noscript>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment