Use ol.extent.getWidth and ol.extent.getHeight
This commit is contained in:
@@ -71,8 +71,8 @@ ol.source.ImageCanvas.prototype.getImage =
|
|||||||
|
|
||||||
extent = extent.slice();
|
extent = extent.slice();
|
||||||
ol.extent.scaleFromCenter(extent, this.ratio_);
|
ol.extent.scaleFromCenter(extent, this.ratio_);
|
||||||
var width = (extent[2] - extent[0]) / resolution;
|
var width = ol.extent.getWidth(extent) / resolution;
|
||||||
var height = (extent[3] - extent[1]) / resolution;
|
var height = ol.extent.getHeight(extent) / resolution;
|
||||||
var size = [width * pixelRatio, height * pixelRatio];
|
var size = [width * pixelRatio, height * pixelRatio];
|
||||||
|
|
||||||
var canvasElement = this.canvasFunction_(
|
var canvasElement = this.canvasFunction_(
|
||||||
|
|||||||
@@ -217,8 +217,8 @@ ol.source.ImageWMS.prototype.getImage =
|
|||||||
var centerX = (extent[0] + extent[2]) / 2;
|
var centerX = (extent[0] + extent[2]) / 2;
|
||||||
var centerY = (extent[1] + extent[3]) / 2;
|
var centerY = (extent[1] + extent[3]) / 2;
|
||||||
if (this.ratio_ != 1) {
|
if (this.ratio_ != 1) {
|
||||||
var halfWidth = this.ratio_ * (extent[2] - extent[0]) / 2;
|
var halfWidth = this.ratio_ * ol.extent.getWidth(extent) / 2;
|
||||||
var halfHeight = this.ratio_ * (extent[3] - extent[1]) / 2;
|
var halfHeight = this.ratio_ * ol.extent.getHeight(extent) / 2;
|
||||||
extent[0] = centerX - halfWidth;
|
extent[0] = centerX - halfWidth;
|
||||||
extent[1] = centerY - halfHeight;
|
extent[1] = centerY - halfHeight;
|
||||||
extent[2] = centerX + halfWidth;
|
extent[2] = centerX + halfWidth;
|
||||||
@@ -228,8 +228,8 @@ ol.source.ImageWMS.prototype.getImage =
|
|||||||
var imageResolution = resolution / pixelRatio;
|
var imageResolution = resolution / pixelRatio;
|
||||||
|
|
||||||
// Compute an integer width and height.
|
// Compute an integer width and height.
|
||||||
var width = Math.ceil((extent[2] - extent[0]) / imageResolution);
|
var width = Math.ceil(ol.extent.getWidth(extent) / imageResolution);
|
||||||
var height = Math.ceil((extent[3] - extent[1]) / imageResolution);
|
var height = Math.ceil(ol.extent.getHeight(extent) / imageResolution);
|
||||||
|
|
||||||
// Modify the extent to match the integer width and height.
|
// Modify the extent to match the integer width and height.
|
||||||
extent[0] = centerX - imageResolution * width / 2;
|
extent[0] = centerX - imageResolution * width / 2;
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ ol.source.MapGuide.prototype.getImage =
|
|||||||
extent = extent.slice();
|
extent = extent.slice();
|
||||||
ol.extent.scaleFromCenter(extent, this.ratio_);
|
ol.extent.scaleFromCenter(extent, this.ratio_);
|
||||||
}
|
}
|
||||||
var width = (extent[2] - extent[0]) / resolution;
|
var width = ol.extent.getWidth(extent) / resolution;
|
||||||
var height = (extent[3] - extent[1]) / resolution;
|
var height = ol.extent.getHeight(extent) / resolution;
|
||||||
var size = [width * pixelRatio, height * pixelRatio];
|
var size = [width * pixelRatio, height * pixelRatio];
|
||||||
|
|
||||||
var imageUrl = this.imageUrlFunction_(extent, size, projection);
|
var imageUrl = this.imageUrlFunction_(extent, size, projection);
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ ol.source.WMTS = function(options) {
|
|||||||
extent[0] === projectionExtent[0] &&
|
extent[0] === projectionExtent[0] &&
|
||||||
extent[2] === projectionExtent[2]) {
|
extent[2] === projectionExtent[2]) {
|
||||||
var numCols = Math.ceil(
|
var numCols = Math.ceil(
|
||||||
(extent[2] - extent[0]) /
|
ol.extent.getWidth(extent) /
|
||||||
(tileExtent[2] - tileExtent[0]));
|
ol.extent.getWidth(tileExtent));
|
||||||
x = goog.math.modulo(x, numCols);
|
x = goog.math.modulo(x, numCols);
|
||||||
tmpTileCoord.z = tileCoord.z;
|
tmpTileCoord.z = tileCoord.z;
|
||||||
tmpTileCoord.x = x;
|
tmpTileCoord.x = x;
|
||||||
|
|||||||
@@ -283,8 +283,8 @@ goog.exportProperty(
|
|||||||
* @return {number} Resolution.
|
* @return {number} Resolution.
|
||||||
*/
|
*/
|
||||||
ol.View2D.prototype.getResolutionForExtent = function(extent, size) {
|
ol.View2D.prototype.getResolutionForExtent = function(extent, size) {
|
||||||
var xResolution = (extent[2] - extent[0]) / size[0];
|
var xResolution = ol.extent.getWidth(extent) / size[0];
|
||||||
var yResolution = (extent[3] - extent[1]) / size[1];
|
var yResolution = ol.extent.getHeight(extent) / size[1];
|
||||||
return Math.max(xResolution, yResolution);
|
return Math.max(xResolution, yResolution);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user