Correctly reproject projections with undefined units

This commit is contained in:
Petr Sloup
2015-08-25 17:35:07 +02:00
parent aad5f94556
commit 14e20e23a0
3 changed files with 27 additions and 32 deletions

View File

@@ -117,27 +117,6 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
var targetResolution = targetTileGrid.getResolution(z);
var errorThresholdInPixels = goog.isDef(opt_errorThreshold) ?
opt_errorThreshold : ol.DEFAULT_RASTER_REPROJ_ERROR_THRESHOLD;
// in source units
var errorThreshold = targetResolution * errorThresholdInPixels *
targetProj.getMetersPerUnit() / sourceProj.getMetersPerUnit();
/**
* @private
* @type {!ol.reproj.Triangulation}
*/
this.triangulation_ = new ol.reproj.Triangulation(
sourceProj, targetProj, limitedTargetExtent, maxSourceExtent,
errorThreshold);
if (this.triangulation_.getTriangles().length === 0) {
// no valid triangles -> EMPTY
this.state = ol.TileState.EMPTY;
return;
}
var targetCenter = ol.extent.getCenter(limitedTargetExtent);
var sourceResolution = ol.reproj.calculateSourceResolution(
sourceProj, targetProj, targetCenter, targetResolution);
@@ -149,6 +128,23 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
return;
}
var errorThresholdInPixels = goog.isDef(opt_errorThreshold) ?
opt_errorThreshold : ol.DEFAULT_RASTER_REPROJ_ERROR_THRESHOLD;
/**
* @private
* @type {!ol.reproj.Triangulation}
*/
this.triangulation_ = new ol.reproj.Triangulation(
sourceProj, targetProj, limitedTargetExtent, maxSourceExtent,
sourceResolution * errorThresholdInPixels);
if (this.triangulation_.getTriangles().length === 0) {
// no valid triangles -> EMPTY
this.state = ol.TileState.EMPTY;
return;
}
this.srcZ_ = sourceTileGrid.getZForResolution(sourceResolution);
var srcExtent = this.triangulation_.calculateSourceExtent();