Merge pull request #9899 from LevN0/hidpi_TileArcGISRest

Add hidpi option for ol.source.TileArcGISRest
This commit is contained in:
Olivier Guyot
2019-09-23 15:05:45 +02:00
committed by GitHub
+13 -1
View File
@@ -24,6 +24,8 @@ import {appendParams} from '../uri.js';
* override the default service layer visibility. See * override the default service layer visibility. See
* http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/ * http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/
* for further reference. * for further reference.
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions, * @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid. Base this on the resolutions,
* tilesize and extent supported by the server. * tilesize and extent supported by the server.
* If this is not defined, a default grid will be used: if there is a projection * If this is not defined, a default grid will be used: if there is a projection
@@ -87,6 +89,12 @@ class TileArcGISRest extends TileImage {
*/ */
this.params_ = options.params || {}; this.params_ = options.params || {};
/**
* @private
* @type {boolean}
*/
this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
/** /**
* @private * @private
* @type {import("../extent.js").Extent} * @type {import("../extent.js").Extent}
@@ -165,7 +173,7 @@ class TileArcGISRest extends TileImage {
* @inheritDoc * @inheritDoc
*/ */
getTilePixelRatio(pixelRatio) { getTilePixelRatio(pixelRatio) {
return /** @type {number} */ (pixelRatio); return this.hidpi_ ? /** @type {number} */ (pixelRatio) : 1;
} }
/** /**
@@ -197,6 +205,10 @@ function tileUrlFunction(tileCoord, pixelRatio, projection) {
return undefined; return undefined;
} }
if (pixelRatio != 1 && !this.hidpi_) {
pixelRatio = 1;
}
const tileExtent = tileGrid.getTileCoordExtent( const tileExtent = tileGrid.getTileCoordExtent(
tileCoord, this.tmpExtent_); tileCoord, this.tmpExtent_);
let tileSize = toSize( let tileSize = toSize(