Move useLowResolutionTiles from layer renderer to tile source

This commit is contained in:
Tom Payne
2013-02-21 16:47:10 +01:00
parent 47e799ced0
commit 4c9b70fa5c
5 changed files with 22 additions and 26 deletions

View File

@@ -199,7 +199,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
} }
this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange); this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange);
this.useLowResolutionTiles(tileSource, z, frameState.extent); tileSource.useLowResolutionTiles(z, frameState.extent);
this.scheduleExpireCache(frameState, tileSource); this.scheduleExpireCache(frameState, tileSource);
var transform = this.transform_; var transform = this.transform_;

View File

@@ -217,7 +217,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
} }
this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange); this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange);
this.useLowResolutionTiles(tileSource, z, frameState.extent); tileSource.useLowResolutionTiles(z, frameState.extent);
this.scheduleExpireCache(frameState, tileSource); this.scheduleExpireCache(frameState, tileSource);
}; };

View File

@@ -3,7 +3,6 @@ goog.provide('ol.renderer.Layer');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.FrameState'); goog.require('ol.FrameState');
goog.require('ol.Image'); goog.require('ol.Image');
goog.require('ol.ImageState'); goog.require('ol.ImageState');
@@ -259,25 +258,3 @@ ol.renderer.Layer.prototype.updateWantedTiles =
} }
wantedTiles[tileSourceKey][coordKey] = true; wantedTiles[tileSourceKey][coordKey] = true;
}; };
/**
* @protected
* @param {ol.source.TileSource} tileSource Tile source.
* @param {number} z Z.
* @param {ol.Extent} extent Extent.
*/
ol.renderer.Layer.prototype.useLowResolutionTiles =
function(tileSource, z, extent) {
var tileGrid = tileSource.getTileGrid();
var tileRange, x, y, zKey;
// FIXME this should loop up to tileGrid's minZ when implemented
for (; z >= 0; --z) {
tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
tileSource.useTile(new ol.TileCoord(z, x, y));
}
}
}
};

View File

@@ -459,7 +459,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
} }
this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange); this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange);
this.useLowResolutionTiles(tileSource, z, frameState.extent); tileSource.useLowResolutionTiles(z, frameState.extent);
this.scheduleExpireCache(frameState, tileSource); this.scheduleExpireCache(frameState, tileSource);
goog.vec.Mat4.makeIdentity(this.texCoordMatrix_); goog.vec.Mat4.makeIdentity(this.texCoordMatrix_);

View File

@@ -121,6 +121,25 @@ ol.source.TileSource.prototype.getTileGrid = function() {
}; };
/**
* @param {number} z Z.
* @param {ol.Extent} extent Extent.
*/
ol.source.TileSource.prototype.useLowResolutionTiles = function(z, extent) {
var tileGrid = this.getTileGrid();
var tileRange, x, y, zKey;
// FIXME this should loop up to tileGrid's minZ when implemented
for (; z >= 0; --z) {
tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
this.useTile(new ol.TileCoord(z, x, y));
}
}
}
};
/** /**
* Marks a tile coord as being used, without triggering a load. * Marks a tile coord as being used, without triggering a load.
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.