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:
Andreas Hocevar
2016-07-19 16:39:58 +02:00
parent f50f1f401c
commit 6f5ed17fc5
158 changed files with 1488 additions and 1629 deletions

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.Polygon');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.array');
goog.require('ol.extent');
@@ -89,7 +88,7 @@ ol.inherits(ol.geom.Polygon, ol.geom.SimpleGeometry);
* @api stable
*/
ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) {
goog.asserts.assert(linearRing.getLayout() == this.layout,
ol.DEBUG && console.assert(linearRing.getLayout() == this.layout,
'layout of linearRing should match layout');
if (!this.flatCoordinates) {
this.flatCoordinates = linearRing.getFlatCoordinates().slice();
@@ -237,7 +236,7 @@ ol.geom.Polygon.prototype.getLinearRingCount = function() {
* @api stable
*/
ol.geom.Polygon.prototype.getLinearRing = function(index) {
goog.asserts.assert(0 <= index && index < this.ends_.length,
ol.DEBUG && console.assert(0 <= index && index < this.ends_.length,
'index should be in between 0 and and length of this.ends_');
if (index < 0 || this.ends_.length <= index) {
return null;
@@ -358,13 +357,13 @@ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
*/
ol.geom.Polygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) {
if (!flatCoordinates) {
goog.asserts.assert(ends && ends.length === 0,
ol.DEBUG && console.assert(ends && ends.length === 0,
'ends must be an empty array');
} else if (ends.length === 0) {
goog.asserts.assert(flatCoordinates.length === 0,
ol.DEBUG && console.assert(flatCoordinates.length === 0,
'flatCoordinates should be an empty array');
} else {
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1],
ol.DEBUG && console.assert(flatCoordinates.length == ends[ends.length - 1],
'the length of flatCoordinates should be the last entry of ends');
}
this.setFlatCoordinatesInternal(layout, flatCoordinates);
@@ -461,7 +460,7 @@ ol.geom.Polygon.makeRegular = function(polygon, center, radius, opt_angle) {
var layout = polygon.getLayout();
var stride = polygon.getStride();
var ends = polygon.getEnds();
goog.asserts.assert(ends.length === 1, 'only 1 ring is supported');
ol.DEBUG && console.assert(ends.length === 1, 'only 1 ring is supported');
var sides = flatCoordinates.length / stride - 1;
var startAngle = opt_angle ? opt_angle : 0;
var angle, offset;