Re-use ol.TileCoord objects
This commit is contained in:
@@ -113,6 +113,7 @@ ol.source.WMTS = function(options) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||||
function(tileCoord, projection) {
|
function(tileCoord, projection) {
|
||||||
var tileGrid = this.getTileGrid();
|
var tileGrid = this.getTileGrid();
|
||||||
@@ -134,8 +135,10 @@ ol.source.WMTS = function(options) {
|
|||||||
(extent.maxX - extent.minX) /
|
(extent.maxX - extent.minX) /
|
||||||
(tileExtent.maxX - tileExtent.minX));
|
(tileExtent.maxX - tileExtent.minX));
|
||||||
x = goog.math.modulo(x, numCols);
|
x = goog.math.modulo(x, numCols);
|
||||||
tileExtent = tileGrid.getTileCoordExtent(
|
tmpTileCoord.z = tileCoord.z;
|
||||||
new ol.TileCoord(tileCoord.z, x, tileCoord.y));
|
tmpTileCoord.x = x;
|
||||||
|
tmpTileCoord.y = tileCoord.y;
|
||||||
|
tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord);
|
||||||
}
|
}
|
||||||
if (!tileExtent.intersects(extent)) {
|
if (!tileExtent.intersects(extent)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ ol.source.XYZ = function(options) {
|
|||||||
var extent = options.extent;
|
var extent = options.extent;
|
||||||
if (goog.isDefAndNotNull(extent)) {
|
if (goog.isDefAndNotNull(extent)) {
|
||||||
|
|
||||||
|
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||||
function(tileCoord) {
|
function(tileCoord) {
|
||||||
if (options.maxZoom < tileCoord.z) {
|
if (options.maxZoom < tileCoord.z) {
|
||||||
@@ -72,8 +73,10 @@ ol.source.XYZ = function(options) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var x = goog.math.modulo(tileCoord.x, n);
|
var x = goog.math.modulo(tileCoord.x, n);
|
||||||
var tileExtent = tileGrid.getTileCoordExtent(
|
tmpTileCoord.z = tileCoord.z;
|
||||||
new ol.TileCoord(tileCoord.z, x, tileCoord.y));
|
tmpTileCoord.x = x;
|
||||||
|
tmpTileCoord.y = tileCoord.y;
|
||||||
|
var tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord);
|
||||||
// FIXME we shouldn't need a typecast here
|
// FIXME we shouldn't need a typecast here
|
||||||
if (!tileExtent.intersects(/** @type {ol.Extent} */ (extent))) {
|
if (!tileExtent.intersects(/** @type {ol.Extent} */ (extent))) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -205,11 +205,13 @@ ol.tilegrid.TileGrid.prototype.getTileRangeExtent = function(z, tileRange) {
|
|||||||
*/
|
*/
|
||||||
ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndResolution = function(
|
ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndResolution = function(
|
||||||
extent, resolution) {
|
extent, resolution) {
|
||||||
var min = this.getTileCoordForXYAndResolution_(
|
var tileCoord = this.getTileCoordForXYAndResolution_(
|
||||||
extent.minX, extent.minY, resolution, false);
|
extent.minX, extent.minY, resolution, false);
|
||||||
var max = this.getTileCoordForXYAndResolution_(
|
var minX = tileCoord.x;
|
||||||
extent.maxX, extent.maxY, resolution, true);
|
var minY = tileCoord.y;
|
||||||
return new ol.TileRange(min.x, min.y, max.x, max.y);
|
tileCoord = this.getTileCoordForXYAndResolution_(
|
||||||
|
extent.maxX, extent.maxY, resolution, true, tileCoord);
|
||||||
|
return new ol.TileRange(minX, minY, tileCoord.x, tileCoord.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user