Remove goog.asserts.*
This pull requests replaces type check hint assertions with type casts, library sanity check assertions with conditional console.assert statements in debug mode, and runtime sanity checks with assertions that throw an ol.AssertionError with an error code for lookup outside the library.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.reproj.Image');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.ImageBase');
|
||||
@@ -195,8 +194,8 @@ ol.reproj.Image.prototype.load = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Image.prototype.unlistenSource_ = function() {
|
||||
goog.asserts.assert(this.sourceListenerKey_,
|
||||
ol.DEBUG && console.assert(this.sourceListenerKey_,
|
||||
'this.sourceListenerKey_ should not be null');
|
||||
ol.events.unlistenByKey(this.sourceListenerKey_);
|
||||
ol.events.unlistenByKey(/** @type {!ol.EventsKey} */ (this.sourceListenerKey_));
|
||||
this.sourceListenerKey_ = null;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.reproj.Tile');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
@@ -182,9 +181,8 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
sourceExtent, this.sourceZ_);
|
||||
|
||||
var tilesRequired = sourceRange.getWidth() * sourceRange.getHeight();
|
||||
if (!goog.asserts.assert(
|
||||
tilesRequired < ol.RASTER_REPROJECTION_MAX_SOURCE_TILES,
|
||||
'reasonable number of tiles is required')) {
|
||||
if (ol.DEBUG && !(tilesRequired < ol.RASTER_REPROJECTION_MAX_SOURCE_TILES)) {
|
||||
console.assert(false, 'reasonable number of tiles is required');
|
||||
this.state = ol.TileState.ERROR;
|
||||
return;
|
||||
}
|
||||
@@ -286,7 +284,7 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
|
||||
var leftToLoad = 0;
|
||||
|
||||
goog.asserts.assert(!this.sourcesListenerKeys_,
|
||||
ol.DEBUG && console.assert(!this.sourcesListenerKeys_,
|
||||
'this.sourcesListenerKeys_ should be null');
|
||||
|
||||
this.sourcesListenerKeys_ = [];
|
||||
@@ -304,7 +302,7 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
state == ol.TileState.EMPTY) {
|
||||
ol.events.unlistenByKey(sourceListenKey);
|
||||
leftToLoad--;
|
||||
goog.asserts.assert(leftToLoad >= 0,
|
||||
ol.DEBUG && console.assert(leftToLoad >= 0,
|
||||
'leftToLoad should not be negative');
|
||||
if (leftToLoad === 0) {
|
||||
this.unlistenSources_();
|
||||
@@ -334,7 +332,7 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Tile.prototype.unlistenSources_ = function() {
|
||||
goog.asserts.assert(this.sourcesListenerKeys_,
|
||||
ol.DEBUG && console.assert(this.sourcesListenerKeys_,
|
||||
'this.sourcesListenerKeys_ should not be null');
|
||||
this.sourcesListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||
this.sourcesListenerKeys_ = null;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.reproj.Triangulation');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.math');
|
||||
goog.require('ol.proj');
|
||||
@@ -118,7 +117,7 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
|
||||
// Fix coordinates (ol.proj returns wrapped coordinates, "unwrap" here).
|
||||
// This significantly simplifies the rest of the reprojection process.
|
||||
|
||||
goog.asserts.assert(this.sourceWorldWidth_ !== null);
|
||||
ol.DEBUG && console.assert(this.sourceWorldWidth_ !== null);
|
||||
var leftBound = Infinity;
|
||||
this.triangles_.forEach(function(triangle, i, arr) {
|
||||
leftBound = Math.min(leftBound,
|
||||
@@ -202,6 +201,7 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
|
||||
var sourceQuadExtent = ol.extent.boundingExtent([aSrc, bSrc, cSrc, dSrc]);
|
||||
var sourceCoverageX = this.sourceWorldWidth_ ?
|
||||
ol.extent.getWidth(sourceQuadExtent) / this.sourceWorldWidth_ : null;
|
||||
var sourceWorldWidth = /** @type {number} */ (this.sourceWorldWidth_);
|
||||
|
||||
// when the quad is wrapped in the source projection
|
||||
// it covers most of the projection extent, but not fully
|
||||
@@ -251,12 +251,11 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
|
||||
|
||||
var dx;
|
||||
if (wrapsX) {
|
||||
goog.asserts.assert(this.sourceWorldWidth_);
|
||||
var centerSrcEstimX =
|
||||
(ol.math.modulo(aSrc[0], this.sourceWorldWidth_) +
|
||||
ol.math.modulo(cSrc[0], this.sourceWorldWidth_)) / 2;
|
||||
(ol.math.modulo(aSrc[0], sourceWorldWidth) +
|
||||
ol.math.modulo(cSrc[0], sourceWorldWidth)) / 2;
|
||||
dx = centerSrcEstimX -
|
||||
ol.math.modulo(centerSrc[0], this.sourceWorldWidth_);
|
||||
ol.math.modulo(centerSrc[0], sourceWorldWidth);
|
||||
} else {
|
||||
dx = (aSrc[0] + cSrc[0]) / 2 - centerSrc[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user