0
votes

I don't understand this: I am using OpenLayers with high-resolution images, which I tiled in the Microsoft Deep Zoom format. This works well for 256x256 pixel tiles. However, I also have images tiled 192x192 pixel tiles.

In Microsoft Deep Zoom format, e. g. the image is 7,360 x 4,912 px (width x height). There are zoom levels 0 - 13 (13 being the full resolution image). In OpenLayers, I set zoom level 0 = 8 Deep Zoom. At this zoom level, the resolution of the image is 230 x 154 pixels. With 256x256 pixel tiles, OpenLayers correctly requests only one tile on zoom level 0, then 4 tiles on zoom level 1 and so forth.

With 192x192 tiles however, it loads 4 tiles from zoom level 0 (2 of which do not exist). Do you have a solution to that?

    function startOL(tileinput){
       var TileSize = tileinput;
       var MaxZoom = 5;
       var MinZoom = 0;
       //var PyramidWidth = TileSize * (1 << MaxZoom);
       var width = 12288;//7360
       var height = 4912;//4912;
       var extent = [0, 0, width, height];
       var center = ol.extent.getCenter(extent);

       var projection = new ol.proj.Projection({
           code: 'pixels',
           units: 'pixels',
           extent: extent
       });


       var map = new ol.Map({
           target: 'map',
           controls: ol.control.defaults({attribution: false}),
           layers: [
               new ol.layer.Tile({
                   wrapX: false,
                   extent: [0, 0, width , height],
                   source: new ol.source.XYZ({
                       tileUrlFunction: function(tileCoord, pixelRatio, projection){
                           if (!tileCoord) { return ""; }
                           // tileCoord is representing the location of a tile in a tile grid (z, x, y)
                           var z = tileCoord[0];
                           var x = tileCoord[1].toString();
                           var y = tileCoord[2].toString();

                           // add the part /1/1-0.jpg, --> {z}/{x}-{y}.jpg
                           z = z+7;
                           var path = "./EY1_2481-"+tileinput.toString()+"/EY1_2481-"+tileinput.toString()+"_files";
                           path += '/' + z.toString() + '/' + x + '_' + y + '.jpeg';
                           return path;
                       },
                       maxZoom: MaxZoom,
                       minZoom: MinZoom,
                       projection: projection,
                       tileSize: TileSize,
                       logo:false
                   })
               })
           ],
           view: new ol.View({
               center: ol.extent.getCenter(extent),
               zoom: 0,
               maxZoom: MaxZoom,
               minZoom: MinZoom,
               projection: projection
               // maxResolution:maxRes
           })
       });


   }

    $('#256').click(function(){
        $('.ol-viewport').remove();
        $('#size').text('256');
       startOL(256);
    });
    $('#192').click(function(){
        $('.ol-viewport').remove();

        $('#size').text('192');
        startOL(192);
    });
1

1 Answers

0
votes

Starting with v4.5.0, OpenLayers will support a tileSize option for ol.source.Zoomify. When you upgrade, instead of using ol.source.XYZ, simply use ol.source.Zoomify and configure it with a tileSize.