Fix reprojection of raster sources with gutter
This commit is contained in:
@@ -163,7 +163,7 @@ ol.reproj.Image.prototype.reproject_ = function() {
|
||||
this.targetResolution_, this.targetExtent_, this.triangulation_, [{
|
||||
extent: this.sourceImage_.getExtent(),
|
||||
image: this.sourceImage_.getImage()
|
||||
}]);
|
||||
}], 0);
|
||||
}
|
||||
this.state = sourceState;
|
||||
this.changed();
|
||||
|
||||
@@ -101,12 +101,13 @@ ol.reproj.enlargeClipPoint_ = function(centroidX, centroidY, x, y) {
|
||||
* @param {Array.<{extent: ol.Extent,
|
||||
* image: (HTMLCanvasElement|Image|HTMLVideoElement)}>} sources
|
||||
* Array of sources.
|
||||
* @param {number} gutter Gutter of the sources.
|
||||
* @param {boolean=} opt_renderEdges Render reprojection edges.
|
||||
* @return {HTMLCanvasElement} Canvas with reprojected data.
|
||||
*/
|
||||
ol.reproj.render = function(width, height, pixelRatio,
|
||||
sourceResolution, sourceExtent, targetResolution, targetExtent,
|
||||
triangulation, sources, opt_renderEdges) {
|
||||
triangulation, sources, gutter, opt_renderEdges) {
|
||||
|
||||
var context = ol.dom.createCanvasContext2D(Math.round(pixelRatio * width),
|
||||
Math.round(pixelRatio * height));
|
||||
@@ -136,9 +137,12 @@ ol.reproj.render = function(width, height, pixelRatio,
|
||||
var srcWidth = ol.extent.getWidth(src.extent);
|
||||
var srcHeight = ol.extent.getHeight(src.extent);
|
||||
|
||||
stitchContext.drawImage(src.image,
|
||||
xPos * stitchScale, yPos * stitchScale,
|
||||
srcWidth * stitchScale, srcHeight * stitchScale);
|
||||
stitchContext.drawImage(
|
||||
src.image,
|
||||
gutter, gutter,
|
||||
src.image.width - 2 * gutter, src.image.height - 2 * gutter,
|
||||
xPos * stitchScale, yPos * stitchScale,
|
||||
srcWidth * stitchScale, srcHeight * stitchScale);
|
||||
});
|
||||
|
||||
var targetTopLeft = ol.extent.getTopLeft(targetExtent);
|
||||
|
||||
@@ -35,6 +35,7 @@ ol.reproj.TileFunctionType;
|
||||
* @param {ol.TileCoord} tileCoord Coordinate of the tile.
|
||||
* @param {ol.TileCoord} wrappedTileCoord Coordinate of the tile wrapped in X.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {number} gutter Gutter of the source tiles.
|
||||
* @param {ol.reproj.TileFunctionType} getTileFunction
|
||||
* Function returning source tiles (z, x, y, pixelRatio).
|
||||
* @param {number=} opt_errorThreshold Acceptable reprojection error (in px).
|
||||
@@ -42,7 +43,7 @@ ol.reproj.TileFunctionType;
|
||||
*/
|
||||
ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
targetProj, targetTileGrid, tileCoord, wrappedTileCoord,
|
||||
pixelRatio, getTileFunction,
|
||||
pixelRatio, gutter, getTileFunction,
|
||||
opt_errorThreshold,
|
||||
opt_renderEdges) {
|
||||
goog.base(this, tileCoord, ol.TileState.IDLE);
|
||||
@@ -59,6 +60,12 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
*/
|
||||
this.pixelRatio_ = pixelRatio;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.gutter_ = gutter;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement}
|
||||
@@ -269,7 +276,7 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
this.canvas_ = ol.reproj.render(width, height, this.pixelRatio_,
|
||||
sourceResolution, this.sourceTileGrid_.getExtent(),
|
||||
targetResolution, targetExtent, this.triangulation_, sources,
|
||||
this.renderEdges_);
|
||||
this.gutter_, this.renderEdges_);
|
||||
|
||||
this.state = ol.TileState.LOADED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user