From 663e7af0d2853e66da5e3104a61494ef708ecc21 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 15 Apr 2014 10:09:25 +0200 Subject: [PATCH] Use ol.extent.getWidth and ol.extent.getHeight --- src/ol/source/imagecanvassource.js | 4 ++-- src/ol/source/imagewmssource.js | 8 ++++---- src/ol/source/mapguidesource.js | 4 ++-- src/ol/source/wmtssource.js | 4 ++-- src/ol/view2d.js | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ol/source/imagecanvassource.js b/src/ol/source/imagecanvassource.js index 33d5a9a0fe..9204595de0 100644 --- a/src/ol/source/imagecanvassource.js +++ b/src/ol/source/imagecanvassource.js @@ -71,8 +71,8 @@ ol.source.ImageCanvas.prototype.getImage = extent = extent.slice(); ol.extent.scaleFromCenter(extent, this.ratio_); - var width = (extent[2] - extent[0]) / resolution; - var height = (extent[3] - extent[1]) / resolution; + var width = ol.extent.getWidth(extent) / resolution; + var height = ol.extent.getHeight(extent) / resolution; var size = [width * pixelRatio, height * pixelRatio]; var canvasElement = this.canvasFunction_( diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index 41440cf829..98703fa280 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -217,8 +217,8 @@ ol.source.ImageWMS.prototype.getImage = var centerX = (extent[0] + extent[2]) / 2; var centerY = (extent[1] + extent[3]) / 2; if (this.ratio_ != 1) { - var halfWidth = this.ratio_ * (extent[2] - extent[0]) / 2; - var halfHeight = this.ratio_ * (extent[3] - extent[1]) / 2; + var halfWidth = this.ratio_ * ol.extent.getWidth(extent) / 2; + var halfHeight = this.ratio_ * ol.extent.getHeight(extent) / 2; extent[0] = centerX - halfWidth; extent[1] = centerY - halfHeight; extent[2] = centerX + halfWidth; @@ -228,8 +228,8 @@ ol.source.ImageWMS.prototype.getImage = var imageResolution = resolution / pixelRatio; // Compute an integer width and height. - var width = Math.ceil((extent[2] - extent[0]) / imageResolution); - var height = Math.ceil((extent[3] - extent[1]) / imageResolution); + var width = Math.ceil(ol.extent.getWidth(extent) / imageResolution); + var height = Math.ceil(ol.extent.getHeight(extent) / imageResolution); // Modify the extent to match the integer width and height. extent[0] = centerX - imageResolution * width / 2; diff --git a/src/ol/source/mapguidesource.js b/src/ol/source/mapguidesource.js index 449e0adaa0..7092de9474 100644 --- a/src/ol/source/mapguidesource.js +++ b/src/ol/source/mapguidesource.js @@ -107,8 +107,8 @@ ol.source.MapGuide.prototype.getImage = extent = extent.slice(); ol.extent.scaleFromCenter(extent, this.ratio_); } - var width = (extent[2] - extent[0]) / resolution; - var height = (extent[3] - extent[1]) / resolution; + var width = ol.extent.getWidth(extent) / resolution; + var height = ol.extent.getHeight(extent) / resolution; var size = [width * pixelRatio, height * pixelRatio]; var imageUrl = this.imageUrlFunction_(extent, size, projection); diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 19a2db4796..ca5383f83a 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -159,8 +159,8 @@ ol.source.WMTS = function(options) { extent[0] === projectionExtent[0] && extent[2] === projectionExtent[2]) { var numCols = Math.ceil( - (extent[2] - extent[0]) / - (tileExtent[2] - tileExtent[0])); + ol.extent.getWidth(extent) / + ol.extent.getWidth(tileExtent)); x = goog.math.modulo(x, numCols); tmpTileCoord.z = tileCoord.z; tmpTileCoord.x = x; diff --git a/src/ol/view2d.js b/src/ol/view2d.js index e8df7039b1..72f67bd150 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -283,8 +283,8 @@ goog.exportProperty( * @return {number} Resolution. */ ol.View2D.prototype.getResolutionForExtent = function(extent, size) { - var xResolution = (extent[2] - extent[0]) / size[0]; - var yResolution = (extent[3] - extent[1]) / size[1]; + var xResolution = ol.extent.getWidth(extent) / size[0]; + var yResolution = ol.extent.getHeight(extent) / size[1]; return Math.max(xResolution, yResolution); };