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.source.BingMaps');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
@@ -91,7 +90,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
|
||||
}
|
||||
//var copyright = response.copyright; // FIXME do we need to display this?
|
||||
var resource = response.resourceSets[0].resources[0];
|
||||
goog.asserts.assert(resource.imageWidth == resource.imageHeight,
|
||||
ol.DEBUG && console.assert(resource.imageWidth == resource.imageHeight,
|
||||
'resource has imageWidth equal to imageHeight, i.e. is square');
|
||||
var maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
|
||||
|
||||
@@ -122,7 +121,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
|
||||
* @return {string|undefined} Tile URL.
|
||||
*/
|
||||
function(tileCoord, pixelRatio, projection) {
|
||||
goog.asserts.assert(ol.proj.equivalent(
|
||||
ol.DEBUG && console.assert(ol.proj.equivalent(
|
||||
projection, sourceProjection),
|
||||
'projections are equivalent');
|
||||
if (!tileCoord) {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
goog.provide('ol.source.Cluster');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.events.EventType');
|
||||
@@ -55,9 +54,9 @@ ol.source.Cluster = function(options) {
|
||||
* @return {ol.geom.Point} Cluster calculation point.
|
||||
*/
|
||||
this.geometryFunction_ = options.geometryFunction || function(feature) {
|
||||
var geometry = feature.getGeometry();
|
||||
goog.asserts.assert(geometry instanceof ol.geom.Point,
|
||||
'feature geometry is a ol.geom.Point instance');
|
||||
var geometry = /** @type {ol.geom.Point} */ (feature.getGeometry());
|
||||
ol.assert(geometry instanceof ol.geom.Point,
|
||||
10); // The default `geometryFunction` can only handle `ol.geom.Point` geometries
|
||||
return geometry;
|
||||
};
|
||||
|
||||
@@ -137,7 +136,7 @@ ol.source.Cluster.prototype.cluster_ = function() {
|
||||
ol.extent.buffer(extent, mapDistance, extent);
|
||||
|
||||
var neighbors = this.source_.getFeaturesInExtent(extent);
|
||||
goog.asserts.assert(neighbors.length >= 1, 'at least one neighbor found');
|
||||
ol.DEBUG && console.assert(neighbors.length >= 1, 'at least one neighbor found');
|
||||
neighbors = neighbors.filter(function(neighbor) {
|
||||
var uid = ol.getUid(neighbor).toString();
|
||||
if (!(uid in clustered)) {
|
||||
@@ -151,7 +150,7 @@ ol.source.Cluster.prototype.cluster_ = function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(
|
||||
ol.DEBUG && console.assert(
|
||||
Object.keys(clustered).length == this.source_.getFeatures().length,
|
||||
'number of clustered equals number of features in the source');
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.source.ImageArcGISRest');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.events');
|
||||
@@ -196,7 +195,7 @@ ol.source.ImageArcGISRest.prototype.getImageLoadFunction = function() {
|
||||
*/
|
||||
ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
|
||||
|
||||
goog.asserts.assert(this.url_ !== undefined, 'url is defined');
|
||||
ol.DEBUG && console.assert(this.url_ !== undefined, 'url is defined');
|
||||
|
||||
// ArcGIS Server only wants the numeric portion of the projection ID.
|
||||
var srid = projection.getCode().split(':').pop();
|
||||
@@ -213,7 +212,7 @@ ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixe
|
||||
.replace(/MapServer\/?$/, 'MapServer/export')
|
||||
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
|
||||
if (modifiedUrl == url) {
|
||||
goog.asserts.fail('Unknown Rest Service', url);
|
||||
ol.assert(false, 50); // `options.featureTypes` should be an Array
|
||||
}
|
||||
return ol.uri.appendParams(modifiedUrl, params);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.source.Image');
|
||||
goog.provide('ol.source.ImageEvent');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.ImageState');
|
||||
goog.require('ol.array');
|
||||
@@ -38,7 +37,7 @@ ol.source.Image = function(options) {
|
||||
*/
|
||||
this.resolutions_ = options.resolutions !== undefined ?
|
||||
options.resolutions : null;
|
||||
goog.asserts.assert(!this.resolutions_ ||
|
||||
ol.DEBUG && console.assert(!this.resolutions_ ||
|
||||
ol.array.isSorted(this.resolutions_,
|
||||
function(a, b) {
|
||||
return b - a;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.source.ImageVector');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.transform');
|
||||
@@ -169,7 +168,7 @@ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
goog.asserts.assert(feature !== undefined, 'passed a feature');
|
||||
ol.DEBUG && console.assert(feature !== undefined, 'passed a feature');
|
||||
var key = ol.getUid(feature).toString();
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
goog.provide('ol.source.ImageWMS');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.events');
|
||||
@@ -136,7 +135,7 @@ ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
|
||||
*/
|
||||
ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
|
||||
|
||||
goog.asserts.assert(!('VERSION' in params),
|
||||
ol.DEBUG && console.assert(!('VERSION' in params),
|
||||
'key VERSION is not allowed in params');
|
||||
|
||||
if (this.url_ === undefined) {
|
||||
@@ -269,7 +268,7 @@ ol.source.ImageWMS.prototype.getImageLoadFunction = function() {
|
||||
*/
|
||||
ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
|
||||
|
||||
goog.asserts.assert(this.url_ !== undefined, 'url is defined');
|
||||
ol.assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()`
|
||||
|
||||
params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
|
||||
|
||||
@@ -295,7 +294,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio,
|
||||
params['DPI'] = 90 * pixelRatio;
|
||||
break;
|
||||
default:
|
||||
goog.asserts.fail('unknown serverType configured');
|
||||
ol.assert(false, 8); // Unknown `serverType` configured
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -312,7 +311,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio,
|
||||
}
|
||||
params['BBOX'] = bbox.join(',');
|
||||
|
||||
return ol.uri.appendParams(this.url_, params);
|
||||
return ol.uri.appendParams(/** @type {string} */ (this.url_), params);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ goog.provide('ol.source.Raster');
|
||||
goog.provide('ol.source.RasterEvent');
|
||||
goog.provide('ol.source.RasterEventType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.transform');
|
||||
goog.require('ol.ImageCanvas');
|
||||
goog.require('ol.TileQueue');
|
||||
@@ -425,7 +424,7 @@ ol.source.Raster.createRenderer_ = function(source) {
|
||||
} else if (source instanceof ol.source.Image) {
|
||||
renderer = ol.source.Raster.createImageRenderer_(source);
|
||||
} else {
|
||||
goog.asserts.fail('Unsupported source type: ' + source);
|
||||
ol.DEBUG && console.assert(false, 'Unsupported source type: ' + source);
|
||||
}
|
||||
return renderer;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.source.Stamen');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.source.OSM');
|
||||
goog.require('ol.source.XYZ');
|
||||
@@ -89,11 +88,11 @@ ol.source.Stamen = function(options) {
|
||||
|
||||
var i = options.layer.indexOf('-');
|
||||
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
|
||||
goog.asserts.assert(provider in ol.source.StamenProviderConfig,
|
||||
ol.DEBUG && console.assert(provider in ol.source.StamenProviderConfig,
|
||||
'known provider configured');
|
||||
var providerConfig = ol.source.StamenProviderConfig[provider];
|
||||
|
||||
goog.asserts.assert(options.layer in ol.source.StamenLayerConfig,
|
||||
ol.DEBUG && console.assert(options.layer in ol.source.StamenLayerConfig,
|
||||
'known layer configured');
|
||||
var layerConfig = ol.source.StamenLayerConfig[options.layer];
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.source.TileArcGISRest');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.object');
|
||||
@@ -112,7 +111,7 @@ ol.source.TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize
|
||||
.replace(/MapServer\/?$/, 'MapServer/export')
|
||||
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
|
||||
if (modifiedUrl == url) {
|
||||
goog.asserts.fail('Unknown Rest Service', url);
|
||||
ol.assert(false, 50); // Cannot determine Rest Service from url
|
||||
}
|
||||
return ol.uri.appendParams(modifiedUrl, params);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.source.TileImage');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.TileCache');
|
||||
goog.require('ol.TileState');
|
||||
@@ -175,7 +174,7 @@ ol.source.TileImage.prototype.getTileGridForProjection = function(projection) {
|
||||
this.tileGridForProjection[projKey] =
|
||||
ol.tilegrid.getForProjection(projection);
|
||||
}
|
||||
return this.tileGridForProjection[projKey];
|
||||
return /** @type {!ol.tilegrid.TileGrid} */ (this.tileGridForProjection[projKey]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -207,7 +206,7 @@ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) {
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @param {string} key The key set on the tile.
|
||||
* @return {ol.Tile} Tile.
|
||||
* @return {!ol.Tile} Tile.
|
||||
* @private
|
||||
*/
|
||||
ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key) {
|
||||
@@ -237,7 +236,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
|
||||
!this.getProjection() ||
|
||||
!projection ||
|
||||
ol.proj.equivalent(this.getProjection(), projection)) {
|
||||
return this.getTileInternal(z, x, y, pixelRatio, projection);
|
||||
return this.getTileInternal(z, x, y, pixelRatio, /** @type {!ol.proj.Projection} */ (projection));
|
||||
} else {
|
||||
var cache = this.getTileCacheForProjection(projection);
|
||||
var tileCoord = [z, x, y];
|
||||
@@ -250,7 +249,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
|
||||
if (tile && tile.key == key) {
|
||||
return tile;
|
||||
} else {
|
||||
var sourceProjection = this.getProjection();
|
||||
var sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection());
|
||||
var sourceTileGrid = this.getTileGridForProjection(sourceProjection);
|
||||
var targetTileGrid = this.getTileGridForProjection(projection);
|
||||
var wrappedTileCoord =
|
||||
@@ -283,16 +282,15 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
|
||||
* @param {number} x Tile coordinate x.
|
||||
* @param {number} y Tile coordinate y.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @param {!ol.proj.Projection} projection Projection.
|
||||
* @return {!ol.Tile} Tile.
|
||||
* @protected
|
||||
*/
|
||||
ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) {
|
||||
var /** @type {ol.Tile} */ tile = null;
|
||||
var tile = null;
|
||||
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
var key = this.getKey();
|
||||
if (!this.tileCache.containsKey(tileCoordKey)) {
|
||||
goog.asserts.assert(projection, 'argument projection is truthy');
|
||||
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
|
||||
this.tileCache.set(tileCoordKey, tile);
|
||||
} else {
|
||||
@@ -303,8 +301,8 @@ ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, pr
|
||||
// cases we attempt to assign an interim tile to the new tile.
|
||||
var /** @type {ol.Tile} */ interimTile = tile;
|
||||
if (tile.interimTile && tile.interimTile.key == key) {
|
||||
goog.asserts.assert(tile.interimTile.getState() == ol.TileState.LOADED);
|
||||
goog.asserts.assert(tile.interimTile.interimTile === null);
|
||||
ol.DEBUG && console.assert(tile.interimTile.getState() == ol.TileState.LOADED);
|
||||
ol.DEBUG && console.assert(tile.interimTile.interimTile === null);
|
||||
tile = tile.interimTile;
|
||||
if (interimTile.getState() == ol.TileState.LOADED) {
|
||||
tile.interimTile = interimTile;
|
||||
@@ -325,7 +323,6 @@ ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, pr
|
||||
this.tileCache.replace(tileCoordKey, tile);
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(tile);
|
||||
return tile;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
goog.provide('ol.source.TileJSON');
|
||||
goog.provide('ol.tilejson');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
@@ -118,7 +117,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
|
||||
}
|
||||
|
||||
if (tileJSON.scheme !== undefined) {
|
||||
goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
|
||||
ol.DEBUG && console.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
|
||||
}
|
||||
var minZoom = tileJSON.minzoom || 0;
|
||||
var maxZoom = tileJSON.maxzoom || 22;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.source.Tile');
|
||||
goog.provide('ol.source.TileEvent');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol');
|
||||
goog.require('ol.TileCache');
|
||||
@@ -217,7 +216,7 @@ ol.source.Tile.prototype.getTileGrid = function() {
|
||||
|
||||
/**
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @return {ol.tilegrid.TileGrid} Tile grid.
|
||||
* @return {!ol.tilegrid.TileGrid} Tile grid.
|
||||
*/
|
||||
ol.source.Tile.prototype.getTileGridForProjection = function(projection) {
|
||||
if (!this.tileGrid) {
|
||||
@@ -283,7 +282,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction = function(tileCoord, op
|
||||
var projection = opt_projection !== undefined ?
|
||||
opt_projection : this.getProjection();
|
||||
var tileGrid = this.getTileGridForProjection(projection);
|
||||
goog.asserts.assert(tileGrid, 'tile grid needed');
|
||||
ol.DEBUG && console.assert(tileGrid, 'tile grid needed');
|
||||
if (this.getWrapX() && projection.isGlobal()) {
|
||||
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.source.TileUTFGrid');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.async.nextTick');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Tile');
|
||||
@@ -69,7 +68,7 @@ ol.source.TileUTFGrid = function(options) {
|
||||
} else if (options.tileJSON) {
|
||||
this.handleTileJSONResponse(options.tileJSON);
|
||||
} else {
|
||||
goog.asserts.fail('Either url or tileJSON options must be provided');
|
||||
ol.assert(false, 51); // Either `url` or `tileJSON` options must be provided
|
||||
}
|
||||
};
|
||||
ol.inherits(ol.source.TileUTFGrid, ol.source.Tile);
|
||||
@@ -175,7 +174,7 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
|
||||
}
|
||||
|
||||
if (tileJSON.scheme !== undefined) {
|
||||
goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
|
||||
ol.DEBUG && console.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
|
||||
}
|
||||
var minZoom = tileJSON.minzoom || 0;
|
||||
var maxZoom = tileJSON.maxzoom || 22;
|
||||
@@ -229,7 +228,7 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
|
||||
} else {
|
||||
goog.asserts.assert(projection, 'argument projection is truthy');
|
||||
ol.DEBUG && console.assert(projection, 'argument projection is truthy');
|
||||
var tileCoord = [z, x, y];
|
||||
var urlTileCoord =
|
||||
this.getTileCoordForTileUrlFunction(tileCoord, projection);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
goog.provide('ol.source.TileWMS');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.object');
|
||||
@@ -117,7 +116,7 @@ ol.inherits(ol.source.TileWMS, ol.source.TileImage);
|
||||
*/
|
||||
ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
|
||||
|
||||
goog.asserts.assert(!('VERSION' in params),
|
||||
ol.DEBUG && console.assert(!('VERSION' in params),
|
||||
'key VERSION is not allowed in params');
|
||||
|
||||
var projectionObj = ol.proj.get(projection);
|
||||
@@ -239,7 +238,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE
|
||||
params['DPI'] = 90 * pixelRatio;
|
||||
break;
|
||||
default:
|
||||
goog.asserts.fail('unknown serverType configured');
|
||||
ol.assert(false, 52); // Unknown `serverType` configured
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ goog.provide('ol.source.Vector');
|
||||
goog.provide('ol.source.VectorEvent');
|
||||
goog.provide('ol.source.VectorEventType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.CollectionEventType');
|
||||
@@ -105,10 +104,9 @@ ol.source.Vector = function(opt_options) {
|
||||
if (options.loader !== undefined) {
|
||||
this.loader_ = options.loader;
|
||||
} else if (this.url_ !== undefined) {
|
||||
goog.asserts.assert(this.format_ !== undefined,
|
||||
'format must be set when url is set');
|
||||
ol.assert(this.format_, 7); // `format` must be set when `url` is set
|
||||
// create a XHR feature loader for "url" and "format"
|
||||
this.loader_ = ol.featureloader.xhr(this.url_, this.format_);
|
||||
this.loader_ = ol.featureloader.xhr(this.url_, /** @type {ol.format.Feature} */ (this.format_));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +232,7 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
|
||||
* @private
|
||||
*/
|
||||
ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) {
|
||||
goog.asserts.assert(!(featureKey in this.featureChangeKeys_),
|
||||
ol.DEBUG && console.assert(!(featureKey in this.featureChangeKeys_),
|
||||
'key (%s) not yet registered in featureChangeKey', featureKey);
|
||||
this.featureChangeKeys_[featureKey] = [
|
||||
ol.events.listen(feature, ol.events.EventType.CHANGE,
|
||||
@@ -262,8 +260,8 @@ ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) {
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
goog.asserts.assert(!(featureKey in this.undefIdIndex_),
|
||||
'Feature already added to the source');
|
||||
ol.assert(!(featureKey in this.undefIdIndex_),
|
||||
30); // The passed `feature` was already added to the source
|
||||
this.undefIdIndex_[featureKey] = feature;
|
||||
}
|
||||
return valid;
|
||||
@@ -331,7 +329,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
|
||||
* @private
|
||||
*/
|
||||
ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
|
||||
goog.asserts.assert(!this.featuresCollection_,
|
||||
ol.DEBUG && console.assert(!this.featuresCollection_,
|
||||
'bindFeaturesCollection can only be called once');
|
||||
var modifyingCollection = false;
|
||||
ol.events.listen(this, ol.source.VectorEventType.ADDFEATURE,
|
||||
@@ -353,20 +351,16 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
|
||||
ol.events.listen(collection, ol.CollectionEventType.ADD,
|
||||
function(evt) {
|
||||
if (!modifyingCollection) {
|
||||
var feature = evt.element;
|
||||
goog.asserts.assertInstanceof(feature, ol.Feature);
|
||||
modifyingCollection = true;
|
||||
this.addFeature(feature);
|
||||
this.addFeature(/** @type {ol.Feature} */ (evt.element));
|
||||
modifyingCollection = false;
|
||||
}
|
||||
}, this);
|
||||
ol.events.listen(collection, ol.CollectionEventType.REMOVE,
|
||||
function(evt) {
|
||||
if (!modifyingCollection) {
|
||||
var feature = evt.element;
|
||||
goog.asserts.assertInstanceof(feature, ol.Feature);
|
||||
modifyingCollection = true;
|
||||
this.removeFeature(feature);
|
||||
this.removeFeature(/** @type {ol.Feature} */ (evt.element));
|
||||
modifyingCollection = false;
|
||||
}
|
||||
}, this);
|
||||
@@ -401,11 +395,11 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
|
||||
if (this.featuresCollection_) {
|
||||
this.featuresCollection_.clear();
|
||||
}
|
||||
goog.asserts.assert(ol.object.isEmpty(this.featureChangeKeys_),
|
||||
ol.DEBUG && console.assert(ol.object.isEmpty(this.featureChangeKeys_),
|
||||
'featureChangeKeys is an empty object now');
|
||||
goog.asserts.assert(ol.object.isEmpty(this.idIndex_),
|
||||
ol.DEBUG && console.assert(ol.object.isEmpty(this.idIndex_),
|
||||
'idIndex is an empty object now');
|
||||
goog.asserts.assert(ol.object.isEmpty(this.undefIdIndex_),
|
||||
ol.DEBUG && console.assert(ol.object.isEmpty(this.undefIdIndex_),
|
||||
'undefIdIndex is an empty object now');
|
||||
|
||||
if (this.featuresRtree_) {
|
||||
@@ -458,7 +452,7 @@ ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect = function(coordinat
|
||||
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
|
||||
return this.forEachFeatureInExtent(extent, function(feature) {
|
||||
var geometry = feature.getGeometry();
|
||||
goog.asserts.assert(geometry, 'feature geometry is defined and not null');
|
||||
ol.DEBUG && console.assert(geometry, 'feature geometry is defined and not null');
|
||||
if (geometry.containsCoordinate(coordinate)) {
|
||||
return callback.call(opt_this, feature);
|
||||
} else {
|
||||
@@ -524,7 +518,7 @@ ol.source.Vector.prototype.forEachFeatureIntersectingExtent = function(extent, c
|
||||
*/
|
||||
function(feature) {
|
||||
var geometry = feature.getGeometry();
|
||||
goog.asserts.assert(geometry,
|
||||
ol.DEBUG && console.assert(geometry,
|
||||
'feature geometry is defined and not null');
|
||||
if (geometry.intersectsExtent(extent)) {
|
||||
var result = callback.call(opt_this, feature);
|
||||
@@ -564,9 +558,7 @@ ol.source.Vector.prototype.getFeatures = function() {
|
||||
features, ol.object.getValues(this.nullGeometryFeatures_));
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(features !== undefined,
|
||||
'Neither featuresRtree_ nor featuresCollection_ are available');
|
||||
return features;
|
||||
return /** @type {Array.<ol.Feature>} */ (features);
|
||||
};
|
||||
|
||||
|
||||
@@ -597,7 +589,7 @@ ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
|
||||
* @api
|
||||
*/
|
||||
ol.source.Vector.prototype.getFeaturesInExtent = function(extent) {
|
||||
goog.asserts.assert(this.featuresRtree_,
|
||||
ol.DEBUG && console.assert(this.featuresRtree_,
|
||||
'getFeaturesInExtent does not work when useSpatialIndex is set to false');
|
||||
return this.featuresRtree_.getInExtent(extent);
|
||||
};
|
||||
@@ -629,7 +621,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
|
||||
var closestPoint = [NaN, NaN];
|
||||
var minSquaredDistance = Infinity;
|
||||
var extent = [-Infinity, -Infinity, Infinity, Infinity];
|
||||
goog.asserts.assert(this.featuresRtree_,
|
||||
ol.DEBUG && console.assert(this.featuresRtree_,
|
||||
'getClosestFeatureToCoordinate does not work with useSpatialIndex set ' +
|
||||
'to false');
|
||||
var filter = opt_filter ? opt_filter : ol.functions.TRUE;
|
||||
@@ -640,7 +632,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
|
||||
function(feature) {
|
||||
if (filter(feature)) {
|
||||
var geometry = feature.getGeometry();
|
||||
goog.asserts.assert(geometry,
|
||||
ol.DEBUG && console.assert(geometry,
|
||||
'feature geometry is defined and not null');
|
||||
var previousMinSquaredDistance = minSquaredDistance;
|
||||
minSquaredDistance = geometry.closestPointXY(
|
||||
@@ -672,7 +664,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
|
||||
* @api stable
|
||||
*/
|
||||
ol.source.Vector.prototype.getExtent = function() {
|
||||
goog.asserts.assert(this.featuresRtree_,
|
||||
ol.DEBUG && console.assert(this.featuresRtree_,
|
||||
'getExtent does not work when useSpatialIndex is set to false');
|
||||
return this.featuresRtree_.getExtent();
|
||||
};
|
||||
@@ -753,7 +745,7 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
|
||||
} else {
|
||||
if (this.idIndex_[sid] !== feature) {
|
||||
removed = this.removeFromIdIndex_(feature);
|
||||
goog.asserts.assert(removed,
|
||||
ol.DEBUG && console.assert(removed,
|
||||
'Expected feature to be removed from index');
|
||||
this.idIndex_[sid] = feature;
|
||||
}
|
||||
@@ -761,11 +753,11 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
|
||||
} else {
|
||||
if (!(featureKey in this.undefIdIndex_)) {
|
||||
removed = this.removeFromIdIndex_(feature);
|
||||
goog.asserts.assert(removed,
|
||||
ol.DEBUG && console.assert(removed,
|
||||
'Expected feature to be removed from index');
|
||||
this.undefIdIndex_[featureKey] = feature;
|
||||
} else {
|
||||
goog.asserts.assert(this.undefIdIndex_[featureKey] === feature,
|
||||
ol.DEBUG && console.assert(this.undefIdIndex_[featureKey] === feature,
|
||||
'feature keyed under %s in undefIdKeys', featureKey);
|
||||
}
|
||||
}
|
||||
@@ -840,7 +832,7 @@ ol.source.Vector.prototype.removeFeature = function(feature) {
|
||||
*/
|
||||
ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
|
||||
var featureKey = ol.getUid(feature).toString();
|
||||
goog.asserts.assert(featureKey in this.featureChangeKeys_,
|
||||
ol.DEBUG && console.assert(featureKey in this.featureChangeKeys_,
|
||||
'featureKey exists in featureChangeKeys');
|
||||
this.featureChangeKeys_[featureKey].forEach(ol.events.unlistenByKey);
|
||||
delete this.featureChangeKeys_[featureKey];
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.source.WMTS');
|
||||
goog.provide('ol.source.WMTSRequestEncoding');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
@@ -308,16 +307,16 @@ ol.source.WMTS.prototype.updateDimensions = function(dimensions) {
|
||||
ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
|
||||
// TODO: add support for TileMatrixLimits
|
||||
goog.asserts.assert(config['layer'],
|
||||
ol.DEBUG && console.assert(config['layer'],
|
||||
'config "layer" must not be null');
|
||||
|
||||
var layers = wmtsCap['Contents']['Layer'];
|
||||
var l = ol.array.find(layers, function(elt, index, array) {
|
||||
return elt['Identifier'] == config['layer'];
|
||||
});
|
||||
goog.asserts.assert(l, 'found a matching layer in Contents/Layer');
|
||||
ol.DEBUG && console.assert(l, 'found a matching layer in Contents/Layer');
|
||||
|
||||
goog.asserts.assert(l['TileMatrixSetLink'].length > 0,
|
||||
ol.DEBUG && console.assert(l['TileMatrixSetLink'].length > 0,
|
||||
'layer has TileMatrixSetLink');
|
||||
var tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
|
||||
var idx, matrixSet;
|
||||
@@ -347,7 +346,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
matrixSet = /** @type {string} */
|
||||
(l['TileMatrixSetLink'][idx]['TileMatrixSet']);
|
||||
|
||||
goog.asserts.assert(matrixSet, 'TileMatrixSet must not be null');
|
||||
ol.DEBUG && console.assert(matrixSet, 'TileMatrixSet must not be null');
|
||||
|
||||
var format = /** @type {string} */ (l['Format'][0]);
|
||||
if ('format' in config) {
|
||||
@@ -371,12 +370,12 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var key = elt['Identifier'];
|
||||
var value = elt['Default'];
|
||||
if (value !== undefined) {
|
||||
goog.asserts.assert(ol.array.includes(elt['Value'], value),
|
||||
ol.DEBUG && console.assert(ol.array.includes(elt['Value'], value),
|
||||
'default value contained in values');
|
||||
} else {
|
||||
value = elt['Value'][0];
|
||||
}
|
||||
goog.asserts.assert(value !== undefined, 'value could be found');
|
||||
ol.DEBUG && console.assert(value !== undefined, 'value could be found');
|
||||
dimensions[key] = value;
|
||||
});
|
||||
}
|
||||
@@ -385,7 +384,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var matrixSetObj = ol.array.find(matrixSets, function(elt, index, array) {
|
||||
return elt['Identifier'] == matrixSet;
|
||||
});
|
||||
goog.asserts.assert(matrixSetObj,
|
||||
ol.DEBUG && console.assert(matrixSetObj,
|
||||
'found matrixSet in Contents/TileMatrixSet');
|
||||
|
||||
var projection;
|
||||
@@ -422,21 +421,21 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var requestEncoding = config['requestEncoding'];
|
||||
requestEncoding = requestEncoding !== undefined ? requestEncoding : '';
|
||||
|
||||
goog.asserts.assert(
|
||||
ol.DEBUG && console.assert(
|
||||
ol.array.includes(['REST', 'RESTful', 'KVP', ''], requestEncoding),
|
||||
'requestEncoding (%s) is one of "REST", "RESTful", "KVP" or ""',
|
||||
requestEncoding);
|
||||
|
||||
if ('OperationsMetadata' in wmtsCap && 'GetTile' in wmtsCap['OperationsMetadata']) {
|
||||
var gets = wmtsCap['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'];
|
||||
goog.asserts.assert(gets.length >= 1);
|
||||
ol.DEBUG && console.assert(gets.length >= 1);
|
||||
|
||||
for (var i = 0, ii = gets.length; i < ii; ++i) {
|
||||
var constraint = ol.array.find(gets[i]['Constraint'], function(element) {
|
||||
return element['name'] == 'GetEncoding';
|
||||
});
|
||||
var encodings = constraint['AllowedValues']['Value'];
|
||||
goog.asserts.assert(encodings.length >= 1);
|
||||
ol.DEBUG && console.assert(encodings.length >= 1);
|
||||
|
||||
if (requestEncoding === '') {
|
||||
// requestEncoding not provided, use the first encoding from the list
|
||||
@@ -460,7 +459,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
}
|
||||
});
|
||||
}
|
||||
goog.asserts.assert(urls.length > 0, 'At least one URL found');
|
||||
ol.DEBUG && console.assert(urls.length > 0, 'At least one URL found');
|
||||
|
||||
return {
|
||||
urls: urls,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.source.Zoomify');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.TileState');
|
||||
@@ -66,7 +65,7 @@ ol.source.Zoomify = function(opt_options) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goog.asserts.fail();
|
||||
ol.assert(false, 53); // Unknown `tierSizeCalculation` configured
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user