apply patch-3531-A0.diff from trac ticket #3531
This commit is contained in:
@@ -150,7 +150,23 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
* the <matrixIds> property. Defaults to 0 (no zoom offset).
|
||||
*/
|
||||
zoomOffset: 0,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: serverResolutions
|
||||
* {Array} A list of all resolutions available on the server. Only set this
|
||||
* property if the map resolutions differ from the server. This
|
||||
* property serves two purposes. (a) <serverResolutions> can include
|
||||
* resolutions that the server supports and that you don't want to
|
||||
* provide with this layer; you can also look at <zoomOffset>, which is
|
||||
* an alternative to <serverResolutions> for that specific purpose.
|
||||
* (b) The map can work with resolutions that aren't supported by
|
||||
* the server, i.e. that aren't in <serverResolutions>. When the
|
||||
* map is displayed in such a resolution data for the closest
|
||||
* server-supported resolution is loaded and the layer div is
|
||||
* stretched as necessary.
|
||||
*/
|
||||
serverResolutions: null,
|
||||
|
||||
/**
|
||||
* Property: formatSuffixMap
|
||||
* {Object} a map between WMTS 'format' request parameter and tile image file suffix
|
||||
@@ -308,6 +324,17 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
// copy/set any non-init, non-simple values here
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getIdentifier
|
||||
* Get the current index in the matrixIds array.
|
||||
*/
|
||||
getIdentifier: function() {
|
||||
return this.serverResolutions != null ?
|
||||
OpenLayers.Util.indexOf(this.serverResolutions,
|
||||
this.getServerResolution()) :
|
||||
this.getServerZoom() + this.zoomOffset;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getMatrix
|
||||
@@ -316,7 +343,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
getMatrix: function() {
|
||||
var matrix;
|
||||
if (!this.matrixIds || this.matrixIds.length === 0) {
|
||||
matrix = {identifier: this.map.getZoom() + this.zoomOffset};
|
||||
matrix = {identifier: this.getIdentifier()};
|
||||
} else {
|
||||
// get appropriate matrix given the map scale if possible
|
||||
if ("scaleDenominator" in this.matrixIds[0]) {
|
||||
@@ -324,7 +351,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
var denom =
|
||||
OpenLayers.METERS_PER_INCH *
|
||||
OpenLayers.INCHES_PER_UNIT[this.units] *
|
||||
this.map.getResolution() / 0.28E-3;
|
||||
this.getServerResolution() / 0.28E-3;
|
||||
var diff = Number.POSITIVE_INFINITY;
|
||||
var delta;
|
||||
for (var i=0, ii=this.matrixIds.length; i<ii; ++i) {
|
||||
@@ -336,7 +363,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
}
|
||||
} else {
|
||||
// fall back on zoom as index
|
||||
matrix = this.matrixIds[this.map.getZoom() + this.zoomOffset];
|
||||
matrix = this.matrixIds[this.getIdentifier()];
|
||||
}
|
||||
}
|
||||
return matrix;
|
||||
@@ -356,7 +383,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
* (respectively) of the given location within the target tile.
|
||||
*/
|
||||
getTileInfo: function(loc) {
|
||||
var res = this.map.getResolution();
|
||||
var res = this.getServerResolution();
|
||||
|
||||
var fx = (loc.lon - this.tileOrigin.lon) / (res * this.tileSize.w);
|
||||
var fy = (this.tileOrigin.lat - loc.lat) / (res * this.tileSize.h);
|
||||
|
||||
Reference in New Issue
Block a user