Remove the tilePixelRatio option from ol.source.VectorTile
This commit is contained in:
@@ -2,6 +2,16 @@
|
||||
|
||||
### Next release
|
||||
|
||||
#### `ol.source.VectorTile` no longer has a `tilePixelRatio` option
|
||||
|
||||
The `tilePixelRatio` option was only used for tiles in projections with `tile-pixels` as units. For tiles read with `ol.format.MVT` and the default tile loader, or tiles with the default pixel size of 4096 pixels, no changes are necessary. For the very rare cases that do not fall under these categories, a custom `tileLoadFunction` now needs to be configured on the `ol.source.VectorTile`. In addition to calling `tile.setFeatures()` and `tile.setProjection()`, it also needs to contain code like the following:
|
||||
```js
|
||||
var extent = tile.getFormat() instanceof ol.format.MVT ?
|
||||
tile.getLastExtent() :
|
||||
[0, 0, tilePixelRatio * tileSize, tilePixelRatio * tileSize];
|
||||
tile.setExtent(extent);
|
||||
```
|
||||
|
||||
#### `ol.animate` now takes the shortest arc for rotation animation
|
||||
|
||||
Usually rotation animations should animate along the shortest arc. There are rare occasions where a spinning animation effect is desired. So if you previously had something like
|
||||
|
||||
@@ -78,7 +78,6 @@ fetch(url).then(function(response) {
|
||||
var vectorSource = new ol.source.VectorTile({
|
||||
format: new ol.format.GeoJSON(),
|
||||
tileGrid: ol.tilegrid.createXYZ(),
|
||||
tilePixelRatio: 16,
|
||||
tileLoadFunction: function(tile) {
|
||||
var format = tile.getFormat();
|
||||
var tileCoord = tile.getTileCoord();
|
||||
|
||||
@@ -4898,7 +4898,6 @@ olx.source.TileImageOptions.prototype.wrapX;
|
||||
* ol.TileLoadFunctionType)|undefined),
|
||||
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* tilePixelRatio: (number|undefined),
|
||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined),
|
||||
@@ -5005,19 +5004,6 @@ olx.source.VectorTileOptions.prototype.tileGrid;
|
||||
olx.source.VectorTileOptions.prototype.tileLoadFunction;
|
||||
|
||||
|
||||
/**
|
||||
* The pixel ratio used by the tile service. For example, if the tile service
|
||||
* advertizes 512px by 512px tiles but actually sends tiles with coordinates in
|
||||
* the range of 0..4096 pixels, then `tilePixelRatio` should be set to `8`.
|
||||
* When {@link ol.format.MVT} is used to parse the features, this setting will
|
||||
* be overridden by the coordinate range advertized in the tile.
|
||||
* Default is `1`.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.source.VectorTileOptions.prototype.tilePixelRatio;
|
||||
|
||||
|
||||
/**
|
||||
* Optional function to get tile URL given a tile coordinate and the projection.
|
||||
* @type {ol.TileUrlFunctionType|undefined}
|
||||
|
||||
@@ -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];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user