Merge branch '2.12' of github.com:openlayers/openlayers
This commit is contained in:
@@ -651,14 +651,18 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: getServerZoom
|
* Method: getServerZoom
|
||||||
* Return the zoom value corresponding to the best zoom supported by the server
|
* Return the zoom value corresponding to the best matching server
|
||||||
* resolution.
|
* resolution, taking into account <serverResolutions> and <zoomOffset>.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Number} The closest server supported zoom.
|
* {Number} The closest server supported zoom. This is not the map zoom
|
||||||
|
* level, but an index of the server's resolutions array.
|
||||||
*/
|
*/
|
||||||
getServerZoom: function() {
|
getServerZoom: function() {
|
||||||
return this.map.getZoomForResolution(this.getServerResolution());
|
var resolution = this.getServerResolution();
|
||||||
|
return this.serverResolutions ?
|
||||||
|
OpenLayers.Util.indexOf(this.serverResolutions, resolution) :
|
||||||
|
this.map.getZoomForResolution(resolution) + (this.zoomOffset || 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -173,9 +173,7 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
var res = this.getServerResolution();
|
var res = this.getServerResolution();
|
||||||
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
|
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 y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
|
||||||
var z = this.serverResolutions != null ?
|
var z = this.getServerZoom();
|
||||||
OpenLayers.Util.indexOf(this.serverResolutions, res) :
|
|
||||||
this.getServerZoom() + this.zoomOffset;
|
|
||||||
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
|
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
|
||||||
var url = this.url;
|
var url = this.url;
|
||||||
if (OpenLayers.Util.isArray(url)) {
|
if (OpenLayers.Util.isArray(url)) {
|
||||||
|
|||||||
@@ -332,10 +332,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
* Get the current index in the matrixIds array.
|
* Get the current index in the matrixIds array.
|
||||||
*/
|
*/
|
||||||
getIdentifier: function() {
|
getIdentifier: function() {
|
||||||
return this.serverResolutions != null ?
|
return this.getServerZoom();
|
||||||
OpenLayers.Util.indexOf(this.serverResolutions,
|
|
||||||
this.getServerResolution()) :
|
|
||||||
this.getServerZoom() + this.zoomOffset;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,10 +143,7 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
(res * this.tileSize.w));
|
(res * this.tileSize.w));
|
||||||
var y = Math.round((this.maxExtent.top - bounds.top) /
|
var y = Math.round((this.maxExtent.top - bounds.top) /
|
||||||
(res * this.tileSize.h));
|
(res * this.tileSize.h));
|
||||||
var resolutions = this.serverResolutions || this.resolutions;
|
var z = this.getServerZoom();
|
||||||
var z = this.zoomOffset == 0 ?
|
|
||||||
OpenLayers.Util.indexOf(resolutions, res) :
|
|
||||||
this.getServerZoom() + this.zoomOffset;
|
|
||||||
|
|
||||||
if (this.wrapDateLine) {
|
if (this.wrapDateLine) {
|
||||||
var limit = Math.pow(2, z);
|
var limit = Math.pow(2, z);
|
||||||
|
|||||||
@@ -837,12 +837,12 @@
|
|||||||
layer.serverResolutions = [2, 1];
|
layer.serverResolutions = [2, 1];
|
||||||
resolution = 1;
|
resolution = 1;
|
||||||
zoom = layer.getServerZoom();
|
zoom = layer.getServerZoom();
|
||||||
t.eq(zoom, 3, '[3] getServerZoom return value is correct');
|
t.eq(zoom, 1, '[3] getServerZoom return value is correct');
|
||||||
|
|
||||||
layer.serverResolutions = [2];
|
layer.serverResolutions = [2];
|
||||||
resolution = 0.5;
|
resolution = 0.5;
|
||||||
zoom = layer.getServerZoom();
|
zoom = layer.getServerZoom();
|
||||||
t.eq(zoom, 2, '[4] getServerZoom return value is correct');
|
t.eq(zoom, 0, '[4] getServerZoom return value is correct');
|
||||||
|
|
||||||
var exc;
|
var exc;
|
||||||
layer.serverResolutions = [0.5];
|
layer.serverResolutions = [0.5];
|
||||||
|
|||||||
Reference in New Issue
Block a user