Move max subdivision and max triangle width to triangulation module

This commit is contained in:
Tim Schaub
2017-12-12 16:35:03 -07:00
parent 4b0dad27f5
commit 60f6736360
2 changed files with 26 additions and 30 deletions

View File

@@ -62,30 +62,6 @@ export var ENABLE_WEBGL = true;
export var DEBUG_WEBGL = true;
/**
* TODO: move this to Triangulation.js
* @type {number} Maximum number of subdivision steps during raster
* reprojection triangulation. Prevents high memory usage and large
* number of proj4 calls (for certain transformations and areas).
* At most `2*(2^this)` triangles are created for each triangulated
* extent (tile/image). Default is `10`.
*/
export var RASTER_REPROJECTION_MAX_SUBDIVISION = 10;
/**
* TODO: move this to Triangulation.js
* @type {number} Maximum allowed size of triangle relative to world width.
* When transforming corners of world extent between certain projections,
* the resulting triangulation seems to have zero error and no subdivision
* is performed.
* If the triangle width is more than this (relative to world width; 0-1),
* subdivison is forced (up to `RASTER_REPROJECTION_MAX_SUBDIVISION`).
* Default is `0.25`.
*/
export var RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH = 0.25;
/**
* TODO: move this to renderer/vector.js
* @type {number} Tolerance for geometry simplification in device pixels.
@@ -211,8 +187,6 @@ export default {
ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION,
ENABLE_WEBGL: ENABLE_WEBGL,
DEBUG_WEBGL: DEBUG_WEBGL,
RASTER_REPROJECTION_MAX_SUBDIVISION: RASTER_REPROJECTION_MAX_SUBDIVISION,
RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH: RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH,
SIMPLIFY_TOLERANCE: SIMPLIFY_TOLERANCE,
HAS_WEBGL: HAS_WEBGL,
WEBGL_MAX_TEXTURE_SIZE: WEBGL_MAX_TEXTURE_SIZE,

View File

@@ -1,11 +1,33 @@
/**
* @module ol/reproj/Triangulation
*/
import {RASTER_REPROJECTION_MAX_SUBDIVISION, RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH} from '../index.js';
import _ol_extent_ from '../extent.js';
import _ol_math_ from '../math.js';
import _ol_proj_ from '../proj.js';
/**
* @type {number} Maximum number of subdivision steps during raster
* reprojection triangulation. Prevents high memory usage and large
* number of proj4 calls (for certain transformations and areas).
* At most `2*(2^this)` triangles are created for each triangulated
* extent (tile/image).
*/
var MAX_SUBDIVISION = 10;
/**
* @type {number} Maximum allowed size of triangle relative to world width.
* When transforming corners of world extent between certain projections,
* the resulting triangulation seems to have zero error and no subdivision
* is performed.
* If the triangle width is more than this (relative to world width; 0-1),
* subdivison is forced (up to `MAX_SUBDIVISION`).
* Default is `0.25`.
*/
var MAX_TRIANGLE_WIDTH = 0.25;
/**
* @classdesc
* Class containing triangulation of the given target extent.
@@ -112,7 +134,7 @@ var _ol_reproj_Triangulation_ = function(sourceProj, targetProj, targetExtent,
destinationTopLeft, destinationTopRight,
destinationBottomRight, destinationBottomLeft,
sourceTopLeft, sourceTopRight, sourceBottomRight, sourceBottomLeft,
RASTER_REPROJECTION_MAX_SUBDIVISION);
MAX_SUBDIVISION);
if (this.wrapsXInSource_) {
var leftBound = Infinity;
@@ -213,11 +235,11 @@ _ol_reproj_Triangulation_.prototype.addQuad_ = function(a, b, c, d,
var targetCoverageX =
_ol_extent_.getWidth(targetQuadExtent) / this.targetWorldWidth_;
needsSubdivision |=
targetCoverageX > RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH;
targetCoverageX > MAX_TRIANGLE_WIDTH;
}
if (!wrapsX && this.sourceProj_.isGlobal() && sourceCoverageX) {
needsSubdivision |=
sourceCoverageX > RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH;
sourceCoverageX > MAX_TRIANGLE_WIDTH;
}
}