Support pixelRatio during reprojection

This commit is contained in:
Petr Sloup
2015-08-12 18:48:09 +02:00
parent c2b21985f4
commit 3cc8291df4
5 changed files with 56 additions and 33 deletions
+10 -3
View File
@@ -43,6 +43,12 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
*/
this.renderEdges_ = goog.isDef(opt_renderEdges) ? opt_renderEdges : false;
/**
* @private
* @type {number}
*/
this.pixelRatio_ = pixelRatio;
/**
* @private
* @type {HTMLCanvasElement}
@@ -253,17 +259,18 @@ ol.reproj.Tile.prototype.reproject_ = function() {
var targetResolution = this.targetTileGrid_.getResolution(z);
var srcResolution = this.sourceTileGrid_.getResolution(this.srcZ_);
var width = goog.isNumber(size) ? size : size[0];
var height = goog.isNumber(size) ? size : size[1];
var width = this.pixelRatio_ * (goog.isNumber(size) ? size : size[0]);
var height = this.pixelRatio_ * (goog.isNumber(size) ? size : size[1]);
var context = ol.dom.createCanvasContext2D(width, height);
context.imageSmoothingEnabled = true;
context.scale(this.pixelRatio_, this.pixelRatio_);
if (sources.length > 0) {
var targetExtent = this.targetTileGrid_.getTileCoordExtent(tileCoord);
ol.reproj.renderTriangles(context,
srcResolution, this.sourceTileGrid_.getExtent(),
targetResolution, targetExtent, this.triangulation_, sources,
this.renderEdges_);
this.pixelRatio_, this.renderEdges_);
}
this.canvas_ = context.canvas;