Add message to assertions.
This commit is contained in:
@@ -102,7 +102,8 @@ ol.style.AtlasManager.prototype.getInfo = function(id) {
|
||||
}
|
||||
/** @type {?ol.style.AtlasInfo} */
|
||||
var hitInfo = this.getInfo_(this.hitAtlases_, id);
|
||||
goog.asserts.assert(!goog.isNull(hitInfo));
|
||||
goog.asserts.assert(!goog.isNull(hitInfo),
|
||||
'hitInfo must not be null');
|
||||
|
||||
return this.mergeInfos_(info, hitInfo);
|
||||
};
|
||||
@@ -137,8 +138,10 @@ ol.style.AtlasManager.prototype.getInfo_ = function(atlases, id) {
|
||||
* entry, or `null` if the entry is not part of the atlases.
|
||||
*/
|
||||
ol.style.AtlasManager.prototype.mergeInfos_ = function(info, hitInfo) {
|
||||
goog.asserts.assert(info.offsetX === hitInfo.offsetX);
|
||||
goog.asserts.assert(info.offsetY === hitInfo.offsetY);
|
||||
goog.asserts.assert(info.offsetX === hitInfo.offsetX,
|
||||
'in order to merge, offsetX of info and hitInfo must be equal');
|
||||
goog.asserts.assert(info.offsetY === hitInfo.offsetY,
|
||||
'in order to merge, offsetY of info and hitInfo must be equal');
|
||||
return /** @type {ol.style.AtlasManagerInfo} */ ({
|
||||
offsetX: info.offsetX,
|
||||
offsetY: info.offsetY,
|
||||
@@ -194,7 +197,8 @@ ol.style.AtlasManager.prototype.add =
|
||||
/** @type {?ol.style.AtlasInfo} */
|
||||
var hitInfo = this.add_(true,
|
||||
id, width, height, renderHitCallback, opt_this);
|
||||
goog.asserts.assert(!goog.isNull(hitInfo));
|
||||
goog.asserts.assert(!goog.isNull(hitInfo),
|
||||
'hitInfo must not be null');
|
||||
|
||||
return this.mergeInfos_(info, hitInfo);
|
||||
};
|
||||
@@ -240,7 +244,7 @@ ol.style.AtlasManager.prototype.add_ =
|
||||
++ii;
|
||||
}
|
||||
}
|
||||
goog.asserts.fail();
|
||||
goog.asserts.fail('Failed to add to atlasmanager');
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -103,7 +103,8 @@ ol.style.Icon = function(opt_options) {
|
||||
if ((!goog.isDef(src) || src.length === 0) && !goog.isNull(image)) {
|
||||
src = image.src;
|
||||
}
|
||||
goog.asserts.assert(goog.isDef(src) && src.length > 0);
|
||||
goog.asserts.assert(goog.isDef(src) && src.length > 0,
|
||||
'must provide a defined and non-empty src');
|
||||
|
||||
/**
|
||||
* @type {ol.style.ImageState}
|
||||
@@ -529,8 +530,10 @@ ol.style.IconImage_.prototype.getSrc = function() {
|
||||
*/
|
||||
ol.style.IconImage_.prototype.load = function() {
|
||||
if (this.imageState_ == ol.style.ImageState.IDLE) {
|
||||
goog.asserts.assert(goog.isDef(this.src_));
|
||||
goog.asserts.assert(goog.isNull(this.imageListenerKeys_));
|
||||
goog.asserts.assert(goog.isDef(this.src_),
|
||||
'this.src_ must not be undefined');
|
||||
goog.asserts.assert(goog.isNull(this.imageListenerKeys_),
|
||||
'no listener keys existing');
|
||||
this.imageState_ = ol.style.ImageState.LOADING;
|
||||
this.imageListenerKeys_ = [
|
||||
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
|
||||
@@ -553,7 +556,8 @@ ol.style.IconImage_.prototype.load = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.style.IconImage_.prototype.unlistenImage_ = function() {
|
||||
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_));
|
||||
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_),
|
||||
'we must have listeners registered');
|
||||
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
@@ -593,7 +597,8 @@ goog.addSingletonGetter(ol.style.IconImageCache);
|
||||
* @return {string} Cache key.
|
||||
*/
|
||||
ol.style.IconImageCache.getKey = function(src, crossOrigin) {
|
||||
goog.asserts.assert(goog.isDef(crossOrigin));
|
||||
goog.asserts.assert(goog.isDef(crossOrigin),
|
||||
'argument crossOrigin must be defined');
|
||||
return crossOrigin + ':' + src;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,8 +28,9 @@ goog.require('ol.style.Stroke');
|
||||
*/
|
||||
ol.style.RegularShape = function(options) {
|
||||
|
||||
goog.asserts.assert(goog.isDef(options.radius) ||
|
||||
goog.isDef(options.radius1));
|
||||
goog.asserts.assert(
|
||||
goog.isDef(options.radius) || goog.isDef(options.radius1),
|
||||
'must provide either "radius" or "radius1"');
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -156,14 +156,16 @@ ol.style.Style.prototype.setGeometry = function(geometry) {
|
||||
this.geometryFunction_ = function(feature) {
|
||||
var result = feature.get(geometry);
|
||||
if (goog.isDefAndNotNull(result)) {
|
||||
goog.asserts.assertInstanceof(result, ol.geom.Geometry);
|
||||
goog.asserts.assertInstanceof(result, ol.geom.Geometry,
|
||||
'feature geometry must be an ol.geom.Geometry instance');
|
||||
}
|
||||
return result;
|
||||
};
|
||||
} else if (goog.isNull(geometry)) {
|
||||
this.geometryFunction_ = ol.style.defaultGeometryFunction;
|
||||
} else if (goog.isDef(geometry)) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry,
|
||||
'geometry must be an ol.geom.Geometry instance');
|
||||
this.geometryFunction_ = function() {
|
||||
return geometry;
|
||||
};
|
||||
@@ -218,7 +220,8 @@ ol.style.createStyleFunction = function(obj) {
|
||||
if (goog.isArray(obj)) {
|
||||
styles = obj;
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(obj, ol.style.Style);
|
||||
goog.asserts.assertInstanceof(obj, ol.style.Style,
|
||||
'obj geometry must be an ol.style.Style instance');
|
||||
styles = [obj];
|
||||
}
|
||||
styleFunction = goog.functions.constant(styles);
|
||||
@@ -358,6 +361,7 @@ ol.style.GeometryFunction;
|
||||
* @return {ol.geom.Geometry|undefined} Geometry to render.
|
||||
*/
|
||||
ol.style.defaultGeometryFunction = function(feature) {
|
||||
goog.asserts.assert(!goog.isNull(feature));
|
||||
goog.asserts.assert(!goog.isNull(feature),
|
||||
'feature must not be null');
|
||||
return feature.getGeometry();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user