Layer.TileCache, Layer.TMS: support a subset of server resolutions. r=tschaub (closes #1944)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8932 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2009-03-02 08:21:01 +00:00
parent 4dc36e4d80
commit a0678fa739
5 changed files with 70 additions and 6 deletions

View File

@@ -34,6 +34,13 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
*/
tileOrigin: null,
/**
* APIProperty: serverResolutions
* {Array} A list of all resolutions available on the server. Only set this
* property if the map resolutions differs from the server.
*/
serverResolutions: null,
/**
* Constructor: OpenLayers.Layer.TMS
*
@@ -98,7 +105,7 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
var z = this.map.getZoom();
var z = this.serverResolutions != null ? this.serverResolutions.indexOf(res) : this.map.getZoom();
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
var url = this.url;
if (url instanceof Array) {

View File

@@ -33,6 +33,13 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {
*/
format: 'image/png',
/**
* APIProperty: serverResolutions
* {Array} A list of all resolutions available on the server. Only set this
* property if the map resolutions differs from the server.
*/
serverResolutions: null,
/**
* Constructor: OpenLayers.Layer.TileCache
* Create a new read only TileCache layer.
@@ -98,7 +105,7 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {
var size = this.tileSize;
var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));
var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h));
var tileZ = this.map.zoom;
var tileZ = this.serverResolutions != null ? this.serverResolutions.indexOf(res) : this.map.getZoom();
/**
* Zero-pad a positive integer.
* number - {Int}