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.geom.MultiPolygon');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
@@ -89,7 +88,7 @@ ol.inherits(ol.geom.MultiPolygon, ol.geom.SimpleGeometry);
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
|
||||
goog.asserts.assert(polygon.getLayout() == this.layout,
|
||||
ol.DEBUG && console.assert(polygon.getLayout() == this.layout,
|
||||
'layout of polygon should match layout');
|
||||
/** @type {Array.<number>} */
|
||||
var ends;
|
||||
@@ -280,7 +279,7 @@ ol.geom.MultiPolygon.prototype.getSimplifiedGeometryInternal = function(squaredT
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.MultiPolygon.prototype.getPolygon = function(index) {
|
||||
goog.asserts.assert(0 <= index && index < this.endss_.length,
|
||||
ol.DEBUG && console.assert(0 <= index && index < this.endss_.length,
|
||||
'index should be in between 0 and the length of this.endss_');
|
||||
if (index < 0 || this.endss_.length <= index) {
|
||||
return null;
|
||||
@@ -390,13 +389,13 @@ ol.geom.MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout
|
||||
* @param {Array.<Array.<number>>} endss Endss.
|
||||
*/
|
||||
ol.geom.MultiPolygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, endss) {
|
||||
goog.asserts.assert(endss, 'endss must be truthy');
|
||||
ol.DEBUG && console.assert(endss, 'endss must be truthy');
|
||||
if (!flatCoordinates || flatCoordinates.length === 0) {
|
||||
goog.asserts.assert(endss.length === 0, 'the length of endss should be 0');
|
||||
ol.DEBUG && console.assert(endss.length === 0, 'the length of endss should be 0');
|
||||
} else {
|
||||
goog.asserts.assert(endss.length > 0, 'endss cannot be an empty array');
|
||||
ol.DEBUG && console.assert(endss.length > 0, 'endss cannot be an empty array');
|
||||
var ends = endss[endss.length - 1];
|
||||
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 value of ends');
|
||||
}
|
||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||
@@ -419,7 +418,7 @@ ol.geom.MultiPolygon.prototype.setPolygons = function(polygons) {
|
||||
layout = polygon.getLayout();
|
||||
} else {
|
||||
// FIXME better handle the case of non-matching layouts
|
||||
goog.asserts.assert(polygon.getLayout() == layout,
|
||||
ol.DEBUG && console.assert(polygon.getLayout() == layout,
|
||||
'layout of polygon should be layout');
|
||||
}
|
||||
var offset = flatCoordinates.length;
|
||||
|
||||
Reference in New Issue
Block a user