Remove the tilePixelRatio option from ol.source.VectorTile

This commit is contained in:
Andreas Hocevar
2017-08-02 23:57:29 +02:00
parent b3be7e7ba9
commit d4d371a4c2
8 changed files with 32 additions and 32 deletions

View File

@@ -325,11 +325,8 @@ ol.renderer.canvas.VectorTileLayer.prototype.getReplayTransform_ = function(tile
* @return {number} The tile's pixel ratio.
*/
ol.renderer.canvas.VectorTileLayer.prototype.getTilePixelRatio_ = function(source, tile) {
var extent = tile.getExtent();
return extent ?
ol.extent.getWidth(extent) /
ol.size.toSize(source.getTileGrid().getTileSize(tile.tileCoord[0]))[0] :
source.getTilePixelRatio();
return ol.extent.getWidth(tile.getExtent()) /
ol.size.toSize(source.getTileGrid().getTileSize(tile.tileCoord[0]))[0];
};

View File

@@ -141,7 +141,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
extent: extent,
minZoom: resource.zoomMin,
maxZoom: maxZoom,
tileSize: tileSize / this.getTilePixelRatio()
tileSize: tileSize / (this.hidpi_ ? 2 : 1)
});
this.tileGrid = tileGrid;

View File

@@ -244,12 +244,11 @@ ol.source.Tile.prototype.getTileCacheForProjection = function(projection) {
/**
* Get the tile pixel ratio for this source. Subclasses may override this
* method, which is meant to return a supported pixel ratio that matches the
* provided `opt_pixelRatio` as close as possible. When no `opt_pixelRatio` is
* provided, it is meant to return `this.tilePixelRatio_`.
* @param {number=} opt_pixelRatio Pixel ratio.
* provided `pixelRatio` as close as possible.
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
ol.source.Tile.prototype.getTilePixelRatio = function(opt_pixelRatio) {
ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) {
return this.tilePixelRatio_;
};

View File

@@ -40,7 +40,6 @@ ol.source.VectorTile = function(options) {
tileLoadFunction: options.tileLoadFunction ?
options.tileLoadFunction : ol.VectorImageTile.defaultLoadFunction,
tileUrlFunction: options.tileUrlFunction,
tilePixelRatio: options.tilePixelRatio,
url: options.url,
urls: options.urls,
wrapX: options.wrapX === undefined ? true : options.wrapX
@@ -141,10 +140,8 @@ ol.source.VectorTile.prototype.getTileGridForProjection = function(projection) {
/**
* @inheritDoc
*/
ol.source.VectorTile.prototype.getTilePixelRatio = function(opt_pixelRatio) {
return opt_pixelRatio == undefined ?
ol.source.UrlTile.prototype.getTilePixelRatio.call(this, opt_pixelRatio) :
opt_pixelRatio;
ol.source.VectorTile.prototype.getTilePixelRatio = function(pixelRatio) {
return pixelRatio;
};

View File

@@ -93,7 +93,7 @@ ol.VectorTile.prototype.disposeInternal = function() {
* @return {ol.Extent} The extent.
*/
ol.VectorTile.prototype.getExtent = function() {
return this.extent_;
return this.extent_ || ol.VectorTile.DEFAULT_EXTENT;
};
@@ -180,7 +180,12 @@ ol.VectorTile.prototype.onError = function() {
/**
* Sets the extent of the vector tile.
* Sets the extent of the vector tile. For tiles in projections with
* `tile-pixels` as units, this should be set to
* `[0, 0, tilePixelSize, tilePixelSize]` by the source's `tileLoadFunction`.
* `tilePixelSize` is calculated by multiplying the tile size with the tile
* pixel ratio. When using `ol.format.MVT`, the format's `getLastExtent()`
* method returns the correct extent. The default is `[0, 0, 4096, 4096]`.
* @param {ol.Extent} extent The extent.
* @api
*/
@@ -227,3 +232,10 @@ ol.VectorTile.prototype.setReplayGroup = function(layer, key, replayGroup) {
ol.VectorTile.prototype.setLoader = function(loader) {
this.loader_ = loader;
};
/**
* @const
* @type {ol.Extent}
*/
ol.VectorTile.DEFAULT_EXTENT = [0, 0, 4096, 4096];