Remove ol.DEBUG

This commit is contained in:
Tim Schaub
2016-12-29 09:09:24 -07:00
parent 7b9690a691
commit 137cdc04c8
128 changed files with 309 additions and 2027 deletions

View File

@@ -116,7 +116,6 @@ ol.source.BingMaps.prototype.getImagerySet = function() {
* @param {BingMapsImageryMetadataResponse} response Response.
*/
ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response) {
if (response.statusCode != 200 ||
response.statusDescription != 'OK' ||
response.authenticationResultCode != 'ValidCredentials' ||
@@ -132,8 +131,6 @@ 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];
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_;
var sourceProjection = this.getProjection();
@@ -164,9 +161,6 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
* @return {string|undefined} Tile URL.
*/
function(tileCoord, pixelRatio, projection) {
ol.DEBUG && console.assert(ol.proj.equivalent(
projection, sourceProjection),
'projections are equivalent');
if (!tileCoord) {
return undefined;
} else {
@@ -216,5 +210,4 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
this.setLogo(brandLogoUri);
this.setState(ol.source.State.READY);
};

View File

@@ -149,7 +149,6 @@ ol.source.Cluster.prototype.cluster_ = function() {
ol.extent.buffer(extent, mapDistance, extent);
var neighbors = this.source_.getFeaturesInExtent(extent);
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)) {
@@ -163,9 +162,6 @@ ol.source.Cluster.prototype.cluster_ = function() {
}
}
}
ol.DEBUG && console.assert(
Object.keys(clustered).length == this.source_.getFeatures().length,
'number of clustered equals number of features in the source');
};

View File

@@ -22,7 +22,6 @@ goog.require('ol.source.Source');
* @api
*/
ol.source.Image = function(options) {
ol.source.Source.call(this, {
attributions: options.attributions,
extent: options.extent,
@@ -37,11 +36,6 @@ ol.source.Image = function(options) {
*/
this.resolutions_ = options.resolutions !== undefined ?
options.resolutions : null;
ol.DEBUG && console.assert(!this.resolutions_ ||
ol.array.isSorted(this.resolutions_,
function(a, b) {
return b - a;
}, true), 'resolutions must be null or sorted in descending order');
/**
@@ -56,7 +50,6 @@ ol.source.Image = function(options) {
* @type {number}
*/
this.reprojectedRevision_ = 0;
};
ol.inherits(ol.source.Image, ol.source.Source);

View File

@@ -194,9 +194,6 @@ ol.source.ImageArcGISRest.prototype.getImageLoadFunction = function() {
* @private
*/
ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
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();
@@ -209,8 +206,8 @@ ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixe
var url = this.url_;
var modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
if (modifiedUrl == url) {
ol.asserts.assert(false, 50); // `options.featureTypes` should be an Array
}

View File

@@ -134,10 +134,6 @@ ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
* @api stable
*/
ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
ol.DEBUG && console.assert(!('VERSION' in params),
'key VERSION is not allowed in params');
if (this.url_ === undefined) {
return undefined;
}

View File

@@ -415,8 +415,6 @@ ol.source.Raster.createRenderer_ = function(source) {
renderer = ol.source.Raster.createTileRenderer_(source);
} else if (source instanceof ol.source.Image) {
renderer = ol.source.Raster.createImageRenderer_(source);
} else {
ol.DEBUG && console.assert(false, 'Unsupported source type: ' + source);
}
return renderer;
};

View File

@@ -16,15 +16,10 @@ goog.require('ol.source.XYZ');
* @api stable
*/
ol.source.Stamen = function(options) {
var i = options.layer.indexOf('-');
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
ol.DEBUG && console.assert(provider in ol.source.Stamen.ProviderConfig,
'known provider configured');
var providerConfig = ol.source.Stamen.ProviderConfig[provider];
ol.DEBUG && console.assert(options.layer in ol.source.Stamen.LayerConfig,
'known layer configured');
var layerConfig = ol.source.Stamen.LayerConfig[options.layer];
var url = options.url !== undefined ? options.url :
@@ -42,7 +37,6 @@ ol.source.Stamen = function(options) {
tileLoadFunction: options.tileLoadFunction,
url: url
});
};
ol.inherits(ol.source.Stamen, ol.source.XYZ);

View File

@@ -116,9 +116,6 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
extent = ol.extent.applyTransform(tileJSON.bounds, transform);
}
if (tileJSON.scheme !== undefined) {
ol.DEBUG && console.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
}
var minZoom = tileJSON.minzoom || 0;
var maxZoom = tileJSON.maxzoom || 22;
var tileGrid = ol.tilegrid.createXYZ({

View File

@@ -175,9 +175,6 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
extent = ol.extent.applyTransform(tileJSON.bounds, transform);
}
if (tileJSON.scheme !== undefined) {
ol.DEBUG && console.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
}
var minZoom = tileJSON.minzoom || 0;
var maxZoom = tileJSON.maxzoom || 22;
var tileGrid = ol.tilegrid.createXYZ({
@@ -230,7 +227,6 @@ 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 {
ol.DEBUG && console.assert(projection, 'argument projection is truthy');
var tileCoord = [z, x, y];
var urlTileCoord =
this.getTileCoordForTileUrlFunction(tileCoord, projection);

View File

@@ -115,10 +115,6 @@ ol.inherits(ol.source.TileWMS, ol.source.TileImage);
* @api stable
*/
ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
ol.DEBUG && console.assert(!('VERSION' in params),
'key VERSION is not allowed in params');
var projectionObj = ol.proj.get(projection);
var tileGrid = this.getTileGrid();

View File

@@ -202,8 +202,6 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
* @private
*/
ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) {
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,
this.handleFeatureChange_, this),
@@ -299,8 +297,6 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
* @private
*/
ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
ol.DEBUG && console.assert(!this.featuresCollection_,
'bindFeaturesCollection can only be called once');
var modifyingCollection = false;
ol.events.listen(this, ol.source.VectorEventType.ADDFEATURE,
function(evt) {
@@ -365,12 +361,6 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
if (this.featuresCollection_) {
this.featuresCollection_.clear();
}
ol.DEBUG && console.assert(ol.obj.isEmpty(this.featureChangeKeys_),
'featureChangeKeys is an empty object now');
ol.DEBUG && console.assert(ol.obj.isEmpty(this.idIndex_),
'idIndex is an empty object now');
ol.DEBUG && console.assert(ol.obj.isEmpty(this.undefIdIndex_),
'undefIdIndex is an empty object now');
if (this.featuresRtree_) {
this.featuresRtree_.clear();
@@ -422,7 +412,6 @@ 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();
ol.DEBUG && console.assert(geometry, 'feature geometry is defined and not null');
if (geometry.intersectsCoordinate(coordinate)) {
return callback.call(opt_this, feature);
} else {
@@ -488,8 +477,6 @@ ol.source.Vector.prototype.forEachFeatureIntersectingExtent = function(extent, c
*/
function(feature) {
var geometry = feature.getGeometry();
ol.DEBUG && console.assert(geometry,
'feature geometry is defined and not null');
if (geometry.intersectsExtent(extent)) {
var result = callback.call(opt_this, feature);
if (result) {
@@ -559,8 +546,6 @@ ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
* @api
*/
ol.source.Vector.prototype.getFeaturesInExtent = function(extent) {
ol.DEBUG && console.assert(this.featuresRtree_,
'getFeaturesInExtent does not work when useSpatialIndex is set to false');
return this.featuresRtree_.getInExtent(extent);
};
@@ -591,9 +576,6 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
var closestPoint = [NaN, NaN];
var minSquaredDistance = Infinity;
var extent = [-Infinity, -Infinity, Infinity, Infinity];
ol.DEBUG && console.assert(this.featuresRtree_,
'getClosestFeatureToCoordinate does not work with useSpatialIndex set ' +
'to false');
var filter = opt_filter ? opt_filter : ol.functions.TRUE;
this.featuresRtree_.forEachInExtent(extent,
/**
@@ -602,8 +584,6 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
function(feature) {
if (filter(feature)) {
var geometry = feature.getGeometry();
ol.DEBUG && console.assert(geometry,
'feature geometry is defined and not null');
var previousMinSquaredDistance = minSquaredDistance;
minSquaredDistance = geometry.closestPointXY(
x, y, closestPoint, minSquaredDistance);
@@ -634,8 +614,6 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
* @api stable
*/
ol.source.Vector.prototype.getExtent = function() {
ol.DEBUG && console.assert(this.featuresRtree_,
'getExtent does not work when useSpatialIndex is set to false');
return this.featuresRtree_.getExtent();
};
@@ -714,7 +692,6 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
}
}
var id = feature.getId();
var removed;
if (id !== undefined) {
var sid = id.toString();
if (featureKey in this.undefIdIndex_) {
@@ -722,21 +699,14 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
this.idIndex_[sid] = feature;
} else {
if (this.idIndex_[sid] !== feature) {
removed = this.removeFromIdIndex_(feature);
ol.DEBUG && console.assert(removed,
'Expected feature to be removed from index');
this.removeFromIdIndex_(feature);
this.idIndex_[sid] = feature;
}
}
} else {
if (!(featureKey in this.undefIdIndex_)) {
removed = this.removeFromIdIndex_(feature);
ol.DEBUG && console.assert(removed,
'Expected feature to be removed from index');
this.removeFromIdIndex_(feature);
this.undefIdIndex_[featureKey] = feature;
} else {
ol.DEBUG && console.assert(this.undefIdIndex_[featureKey] === feature,
'feature keyed under %s in undefIdKeys', featureKey);
}
}
this.changed();
@@ -810,8 +780,6 @@ ol.source.Vector.prototype.removeFeature = function(feature) {
*/
ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
var featureKey = ol.getUid(feature).toString();
ol.DEBUG && console.assert(featureKey in this.featureChangeKeys_,
'featureKey exists in featureChangeKeys');
this.featureChangeKeys_[featureKey].forEach(ol.events.unlistenByKey);
delete this.featureChangeKeys_[featureKey];
var id = feature.getId();

View File

@@ -296,19 +296,10 @@ ol.source.WMTS.prototype.updateDimensions = function(dimensions) {
* @api
*/
ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
// TODO: add support for TileMatrixLimits
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'];
});
ol.DEBUG && console.assert(l, 'found a matching layer in Contents/Layer');
ol.DEBUG && console.assert(l['TileMatrixSetLink'].length > 0,
'layer has TileMatrixSetLink');
var tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
var idx, matrixSet, matrixLimits;
if (l['TileMatrixSetLink'].length > 1) {
@@ -344,8 +335,6 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
matrixLimits = /** @type {Array.<Object>} */
(l['TileMatrixSetLink'][idx]['TileMatrixSetLimits']);
ol.DEBUG && console.assert(matrixSet, 'TileMatrixSet must not be null');
var format = /** @type {string} */ (l['Format'][0]);
if ('format' in config) {
format = config['format'];
@@ -367,13 +356,9 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
l['Dimension'].forEach(function(elt, index, array) {
var key = elt['Identifier'];
var value = elt['Default'];
if (value !== undefined) {
ol.DEBUG && console.assert(ol.array.includes(elt['Value'], value),
'default value contained in values');
} else {
if (value === undefined) {
value = elt['Value'][0];
}
ol.DEBUG && console.assert(value !== undefined, 'value could be found');
dimensions[key] = value;
});
}
@@ -382,8 +367,6 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var matrixSetObj = ol.array.find(matrixSets, function(elt, index, array) {
return elt['Identifier'] == matrixSet;
});
ol.DEBUG && console.assert(matrixSetObj,
'found matrixSet in Contents/TileMatrixSet');
var projection;
if ('projection' in config) {
@@ -419,21 +402,14 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var requestEncoding = config['requestEncoding'];
requestEncoding = requestEncoding !== undefined ? requestEncoding : '';
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'];
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'];
ol.DEBUG && console.assert(encodings.length >= 1);
if (requestEncoding === '') {
// requestEncoding not provided, use the first encoding from the list
@@ -457,7 +433,6 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
}
});
}
ol.DEBUG && console.assert(urls.length > 0, 'At least one URL found');
return {
urls: urls,
@@ -471,5 +446,4 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
dimensions: dimensions,
wrapX: wrapX
};
};