Re-use ol.Extent objects

This commit is contained in:
Tom Payne
2013-04-09 17:30:46 +02:00
parent ee8e565be2
commit fe03ebe99c
6 changed files with 20 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.math');
goog.require('goog.object');
goog.require('goog.uri.utils');
goog.require('ol.Extent');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.TileUrlFunctionType');
@@ -113,6 +114,7 @@ ol.source.WMTS = function(options) {
}));
}
var tmpExtent = new ol.Extent(0, 0, 0, 0);
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
function(tileCoord, projection) {
@@ -138,7 +140,7 @@ ol.source.WMTS = function(options) {
tmpTileCoord.z = tileCoord.z;
tmpTileCoord.x = x;
tmpTileCoord.y = tileCoord.y;
tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord);
tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
}
if (!tileExtent.intersects(extent)) {
return null;

View File

@@ -61,6 +61,7 @@ ol.source.XYZ = function(options) {
var extent = options.extent;
if (goog.isDefAndNotNull(extent)) {
var tmpExtent = new ol.Extent(0, 0, 0, 0);
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
function(tileCoord) {
@@ -76,7 +77,7 @@ ol.source.XYZ = function(options) {
tmpTileCoord.z = tileCoord.z;
tmpTileCoord.x = x;
tmpTileCoord.y = tileCoord.y;
var tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord);
var tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
// FIXME we shouldn't need a typecast here
if (!tileExtent.intersects(/** @type {ol.Extent} */ (extent))) {
return null;