google / marzipano

A 360° media viewer for the modern web.
http://www.marzipano.net
Apache License 2.0
2.01k stars 998 forks source link

Marzipano ImageUrlSource with Zoomify #247

Open ahoedt opened 5 years ago

ahoedt commented 5 years ago

Hello,

Is it possible to use Marzipano with URL like this: "Tilegroup[0-3]/z-x-y.jpg" ?

The URL is generated via Zoomify Converter.

Alex

tjgq commented 5 years ago

If the x,y,z are zero-based, you can use a string with placeholders, e.g. https://github.com/google/marzipano/blob/master/demos/transitions/index.js#L36.

For more complex cases, write a custom function to convert tile coordinates into URLs, e.g. https://github.com/google/marzipano/blob/master/demos/cube-multi-res/index.js#L34.

ahoedt commented 5 years ago

Hello,

Unfortunately I miss a data (besides the z, x, y, f), it is "tilegroup" which is calculated like that on Zoomify : https://github.com/moravianlibrary/AndroidZoomifyViewer/blob/master/lib/src/main/java/cz/mzk/tiledimageview/images/zoomify/ZoomifyImageManager.java#L208

The structure of the tiles is as follows : /tiles/TileGroup0/{z}-{x}-{y}.jpg /TileGroup1/{z}-{x}-{y}.jpg /TileGroup2/{z}-{x}-{y}.jpg

Thanks.

Alex

tjgq commented 5 years ago

I believe the tilegroup can be calculated from x, y, z given the image dimensions and the tile size. See e.g. https://github.com/lovasoa/dezoomify-py/blob/master/dezoomify.py#L696.

ahoedt commented 5 years ago

Thanks a lot for the help, however the zoom level of Marzipano is between 0 and 1 or Zoomify between 1 and 6+.

I will continue to do tests : ` function getTileIndex(level, x, y) { var index = x + y * parseInt(Math.ceil(Math.floor(panoWidth / Math.pow(2, maxZoomLevel - level)) / tileSize));

for(var i in level) {
    index += parseInt(Math.ceil(Math.floor(panoWidth / Math.pow(2, maxZoomLevel - i)) / tileSize)) * parseInt(Math.ceil(Math.floor(panoHeight / Math.pow(2, maxZoomLevel - i)) / tileSize));
}

return index;

};

var source = new Marzipano.ImageUrlSource(function(tile) { var tileSize = 256, tile_index = getTileIndex(marzipano.view().zoom(), tile.x, tile.y), tile_group = Math.floor(tile_index / tileSize);

newUrl = "/zoomify/TileGroup"+tile_group+"/"+tile.z+"-"+tile.x+"-"+tile.y+".jpg";

}); `

But that does not work :/