[OpenLayers-Dev] Deepzoom formatted tiles
Phil Scadden
p.scadden at gns.cri.nz
Tue Oct 2 13:13:52 PDT 2012
>Unfortunately, I cannot get openlayers to recognize this format (it
has 1 px image in folder 0, then increases in size until e. g. folder 6
starts with 256x256 tiles).
Create your layer as a TMS type. Override the getURL method and put in
one of your own (I have never heard of libvips but presumably you know
how to construct the relationship between a bounds and a tile).
Here is some code fragment that I used for a custom TMS.
function tms_getTileURL(bounds) {
adjustBounds(bounds, this.maxExtent);
var res = this.getServerResolution();
var defImage = "images/none.png";
var x = Math.round((bounds.left - this.maxExtent.left) / (res *
this.tileSize.w));
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res *
this.tileSize.h));
z = this.serverResolutions != null ?
OpenLayers.Util.indexOf(this.serverResolutions, res) : z +
this.zoomOffset;*/
var z = this.serverResolutions != null ?
OpenLayers.Util.indexOf(this.serverResolutions, res) :
this.getServerZoom() + this.zoomOffset;
if (this.tileExtent.left > this.tileExtent.right) {
var b1 = new OpenLayers.Bounds(this.tileExtent.left,
this.tileExtent.bottom, this.map.maxExtent.right, this.tileExtent.top);
var b2 = new OpenLayers.Bounds(this.map.maxExtent.left,
this.tileExtent.bottom, this.tileExtent.right, this.tileExtent.top);
if ((b1.intersectsBounds(bounds) ||
b2.intersectsBounds(bounds)) && z>= this.mapMinZoom ) {
return this.url + this.serviceVersion + "/" +
this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
} else {
return defImage;
}
} else {
if (this.tileExtent.intersectsBounds(bounds) && z >=
this.mapMinZoom ) {
return this.url + this.serviceVersion + "/" +
this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
} else {
return defImage;
}
}
}
I opened the layer as:
layer = new OpenLayers.Layer.TMS(name, path, {
type: 'png',
alpha: true,
serviceVersion: '',
layername: layerName,
tileExtent: new OpenLayers.Bounds(imageBounds.left,
imageBounds.bottom, imageBounds.right, imageBounds.top).transform(dproj,
proj),
mapMinZoom: imageMinZoom,
mapMaxZoom: imageMaxZoom,
getURL: tms_getTileURL,
displayOutsideMaxExtent: false,
zoomOffset: 0,
serverResolutions:serverRes
});
Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
More information about the Dev
mailing list