Remove goog.isNull in source classes

This commit is contained in:
Marc Jansen
2015-09-29 15:20:51 +02:00
parent 30e2f44825
commit e1f477ad8c
18 changed files with 51 additions and 55 deletions

View File

@@ -130,7 +130,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
goog.asserts.assert(ol.proj.equivalent(
projection, sourceProjection),
'projections are equivalent');
if (goog.isNull(tileCoord)) {
if (!tileCoord) {
return undefined;
} else {
ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1],

View File

@@ -64,7 +64,7 @@ ol.source.ImageCanvas.prototype.getImage =
resolution = this.findNearestResolution(resolution);
var canvas = this.canvas_;
if (!goog.isNull(canvas) &&
if (canvas &&
this.renderedRevision_ == this.getRevision() &&
canvas.getResolution() == resolution &&
canvas.getPixelRatio() == pixelRatio &&
@@ -80,7 +80,7 @@ ol.source.ImageCanvas.prototype.getImage =
var canvasElement = this.canvasFunction_(
extent, resolution, pixelRatio, size, projection);
if (!goog.isNull(canvasElement)) {
if (canvasElement) {
canvas = new ol.ImageCanvas(extent, resolution, pixelRatio,
this.getAttributions(), canvasElement);
}

View File

@@ -132,7 +132,7 @@ ol.source.ImageMapGuide.prototype.getImage =
pixelRatio = this.hidpi_ ? pixelRatio : 1;
var image = this.image_;
if (!goog.isNull(image) &&
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&

View File

@@ -50,7 +50,7 @@ ol.source.Image = function(options) {
*/
this.resolutions_ = options.resolutions !== undefined ?
options.resolutions : null;
goog.asserts.assert(goog.isNull(this.resolutions_) ||
goog.asserts.assert(!this.resolutions_ ||
goog.array.isSorted(this.resolutions_,
function(a, b) {
return b - a;
@@ -75,7 +75,7 @@ ol.source.Image.prototype.getResolutions = function() {
*/
ol.source.Image.prototype.findNearestResolution =
function(resolution) {
if (!goog.isNull(this.resolutions_)) {
if (this.resolutions_) {
var idx = ol.array.linearFindNearest(this.resolutions_, resolution, 0);
resolution = this.resolutions_[idx];
}

View File

@@ -154,7 +154,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
*/
ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, skippedFeatureUids, callback) {
if (goog.isNull(this.replayGroup_)) {
if (!this.replayGroup_) {
return undefined;
} else {
/** @type {Object.<string, boolean>} */
@@ -292,7 +292,7 @@ ol.source.ImageVector.prototype.renderFeature_ =
*/
ol.source.ImageVector.prototype.setStyle = function(style) {
this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ?
this.styleFunction_ = !style ?
undefined : ol.style.createStyleFunction(this.style_);
this.changed();
};

View File

@@ -223,7 +223,7 @@ ol.source.ImageWMS.prototype.getImage =
extent[3] = centerY + imageResolution * height / 2;
var image = this.image_;
if (!goog.isNull(image) &&
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&

View File

@@ -319,7 +319,7 @@ ol.source.Raster.prototype.onWorkerComplete_ =
callback(err);
return;
}
if (goog.isNull(output)) {
if (!output) {
// job aborted
return;
}

View File

@@ -200,7 +200,7 @@ ol.source.TileArcGISRest.prototype.tileUrlFunction_ =
function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
if (goog.isNull(tileGrid)) {
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
}

View File

@@ -110,7 +110,7 @@ ol.source.TileDebug.prototype.getTile = function(z, x, y) {
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z));
var tileCoord = [z, x, y];
var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
var text = goog.isNull(textTileCoord) ? '' : ol.tilecoord.toString(
var text = !textTileCoord ? '' : ol.tilecoord.toString(
this.getTileCoordForTileUrlFunction(textTileCoord));
var tile = new ol.DebugTile_(tileCoord, tileSize, text);
this.tileCache.set(tileCoordKey, tile);

View File

@@ -95,7 +95,7 @@ ol.source.TileImage.prototype.getTile =
var tileCoord = [z, x, y];
var urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection);
var tileUrl = goog.isNull(urlTileCoord) ? undefined :
var tileUrl = !urlTileCoord ? undefined :
this.tileUrlFunction(urlTileCoord, pixelRatio, projection);
var tile = new this.tileClass(
tileCoord,

View File

@@ -78,8 +78,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
this.tileUrlFunction =
ol.TileUrlFunction.createFromTemplates(tileJSON.tiles, tileGrid);
if (tileJSON.attribution !== undefined &&
goog.isNull(this.getAttributions())) {
if (tileJSON.attribution !== undefined && !this.getAttributions()) {
var attributionExtent = extent !== undefined ?
extent : epsg4326Projection.getExtent();
/** @type {Object.<string, Array.<ol.TileRange>>} */

View File

@@ -195,7 +195,7 @@ ol.source.Tile.prototype.getTileGrid = function() {
* @return {ol.tilegrid.TileGrid} Tile grid.
*/
ol.source.Tile.prototype.getTileGridForProjection = function(projection) {
if (goog.isNull(this.tileGrid)) {
if (!this.tileGrid) {
return ol.tilegrid.getForProjection(projection);
} else {
return this.tileGrid;
@@ -231,7 +231,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction =
var projection = opt_projection !== undefined ?
opt_projection : this.getProjection();
var tileGrid = this.getTileGridForProjection(projection);
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed');
goog.asserts.assert(tileGrid, 'tile grid needed');
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
}

View File

@@ -81,7 +81,7 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() {
*/
ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
coordinate, resolution, callback, opt_this, opt_request) {
if (!goog.isNull(this.tileGrid)) {
if (this.tileGrid) {
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
coordinate, resolution);
var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile(
@@ -269,7 +269,7 @@ ol.source.TileUTFGridTile_.prototype.getImage = function(opt_context) {
* @return {Object}
*/
ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) {
if (goog.isNull(this.grid_) || goog.isNull(this.keys_) || !this.data_) {
if (!this.grid_ || !this.keys_ || !this.data_) {
return null;
}
var xRelative = (coordinate[0] - this.extent_[0]) /

View File

@@ -57,8 +57,7 @@ ol.source.TileVector = function(options) {
this.tileLoadFunction_ = options.tileLoadFunction !== undefined ?
options.tileLoadFunction : null;
goog.asserts.assert(!goog.isNull(this.format_) ||
!goog.isNull(this.tileLoadFunction_),
goog.asserts.assert(this.format_ || this.tileLoadFunction_,
'Either format or tileLoadFunction are required');
/**
@@ -252,7 +251,7 @@ ol.source.TileVector.prototype.getFeaturesInExtent = goog.abstractMethod;
ol.source.TileVector.prototype.getTileCoordForTileUrlFunction =
function(tileCoord, projection) {
var tileGrid = this.tileGrid_;
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed');
goog.asserts.assert(tileGrid, 'tile grid needed');
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
}
@@ -302,12 +301,12 @@ ol.source.TileVector.prototype.loadFeatures =
tileCoord[2] = y;
var urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection);
var url = goog.isNull(urlTileCoord) ? undefined :
var url = !urlTileCoord ? undefined :
tileUrlFunction(urlTileCoord, 1, projection);
if (url !== undefined) {
tiles[tileKey] = [];
var tileSuccess = goog.partial(success, tileKey);
if (!goog.isNull(this.tileLoadFunction_)) {
if (this.tileLoadFunction_) {
this.tileLoadFunction_(url, goog.bind(tileSuccess, this));
} else {
var loader = ol.featureloader.loadFeaturesXhr(url,

View File

@@ -135,7 +135,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
var projectionObj = ol.proj.get(projection);
var tileGrid = this.getTileGrid();
if (goog.isNull(tileGrid)) {
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projectionObj);
}
@@ -365,7 +365,7 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
if (goog.isNull(tileGrid)) {
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
}

View File

@@ -206,7 +206,7 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
var geometry = feature.getGeometry();
if (geometry) {
var extent = geometry.getExtent();
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.insert(extent, feature);
}
} else {
@@ -307,7 +307,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
this.nullGeometryFeatures_[featureKey] = feature;
}
}
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.load(extents, geometryFeatures);
}
@@ -323,7 +323,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
* @private
*/
ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
goog.asserts.assert(goog.isNull(this.featuresCollection_),
goog.asserts.assert(!this.featuresCollection_,
'bindFeaturesCollection can only be called once');
var modifyingCollection = false;
goog.events.listen(this, ol.source.VectorEventType.ADDFEATURE,
@@ -377,19 +377,19 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
var keys = this.featureChangeKeys_[featureId];
keys.forEach(goog.events.unlistenByKey);
}
if (goog.isNull(this.featuresCollection_)) {
if (!this.featuresCollection_) {
this.featureChangeKeys_ = {};
this.idIndex_ = {};
this.undefIdIndex_ = {};
}
} else {
var rmFeatureInternal = this.removeFeatureInternal;
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.forEach(rmFeatureInternal, this);
goog.object.forEach(this.nullGeometryFeatures_, rmFeatureInternal, this);
}
}
if (!goog.isNull(this.featuresCollection_)) {
if (this.featuresCollection_) {
this.featuresCollection_.clear();
}
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_),
@@ -399,7 +399,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
goog.asserts.assert(goog.object.isEmpty(this.undefIdIndex_),
'undefIdIndex is an empty object now');
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.clear();
}
this.loadedExtentsRtree_.clear();
@@ -424,9 +424,9 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
* @api stable
*/
ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) {
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
return this.featuresRtree_.forEach(callback, opt_this);
} else if (!goog.isNull(this.featuresCollection_)) {
} else if (this.featuresCollection_) {
return this.featuresCollection_.forEach(callback, opt_this);
}
};
@@ -483,9 +483,9 @@ ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect =
*/
ol.source.Vector.prototype.forEachFeatureInExtent =
function(extent, callback, opt_this) {
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
return this.featuresRtree_.forEachInExtent(extent, callback, opt_this);
} else if (!goog.isNull(this.featuresCollection_)) {
} else if (this.featuresCollection_) {
return this.featuresCollection_.forEach(callback, opt_this);
}
};
@@ -563,9 +563,9 @@ ol.source.Vector.prototype.getFeaturesCollection = function() {
*/
ol.source.Vector.prototype.getFeatures = function() {
var features;
if (!goog.isNull(this.featuresCollection_)) {
if (this.featuresCollection_) {
features = this.featuresCollection_.getArray();
} else if (!goog.isNull(this.featuresRtree_)) {
} else if (this.featuresRtree_) {
features = this.featuresRtree_.getAll();
if (!goog.object.isEmpty(this.nullGeometryFeatures_)) {
goog.array.extend(
@@ -605,7 +605,7 @@ ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
* @api
*/
ol.source.Vector.prototype.getFeaturesInExtent = function(extent) {
goog.asserts.assert(!goog.isNull(this.featuresRtree_),
goog.asserts.assert(this.featuresRtree_,
'getFeaturesInExtent does not work when useSpatialIndex is set to false');
return this.featuresRtree_.getInExtent(extent);
};
@@ -635,7 +635,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate =
var closestPoint = [NaN, NaN];
var minSquaredDistance = Infinity;
var extent = [-Infinity, -Infinity, Infinity, Infinity];
goog.asserts.assert(!goog.isNull(this.featuresRtree_),
goog.asserts.assert(this.featuresRtree_,
'getClosestFeatureToCoordinate does not work with useSpatialIndex set ' +
'to false');
this.featuresRtree_.forEachInExtent(extent,
@@ -675,7 +675,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate =
* @api stable
*/
ol.source.Vector.prototype.getExtent = function() {
goog.asserts.assert(!goog.isNull(this.featuresRtree_),
goog.asserts.assert(this.featuresRtree_,
'getExtent does not work when useSpatialIndex is set to false');
return this.featuresRtree_.getExtent();
};
@@ -706,7 +706,7 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
var geometry = feature.getGeometry();
if (!geometry) {
if (!(featureKey in this.nullGeometryFeatures_)) {
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.remove(feature);
}
this.nullGeometryFeatures_[featureKey] = feature;
@@ -715,11 +715,11 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
var extent = geometry.getExtent();
if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey];
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.insert(extent, feature);
}
} else {
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.update(extent, feature);
}
}
@@ -805,7 +805,7 @@ ol.source.Vector.prototype.removeFeature = function(feature) {
if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey];
} else {
if (!goog.isNull(this.featuresRtree_)) {
if (this.featuresRtree_) {
this.featuresRtree_.remove(feature);
}
}

View File

@@ -154,7 +154,7 @@ ol.source.WMTS = function(options) {
* @return {string|undefined} Tile URL.
*/
function(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) {
if (!tileCoord) {
return undefined;
} else {
var localContext = {
@@ -341,15 +341,14 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
/* jshint -W069 */
// TODO: add support for TileMatrixLimits
goog.asserts.assert(!goog.isNull(config['layer']),
goog.asserts.assert(config['layer'],
'config "layer" must not be null');
var layers = wmtsCap['Contents']['Layer'];
var l = goog.array.find(layers, function(elt, index, array) {
return elt['Identifier'] == config['layer'];
});
goog.asserts.assert(!goog.isNull(l),
'found a matching layer in Contents/Layer');
goog.asserts.assert(l, 'found a matching layer in Contents/Layer');
goog.asserts.assert(l['TileMatrixSetLink'].length > 0,
'layer has TileMatrixSetLink');
@@ -381,8 +380,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
matrixSet = /** @type {string} */
(l['TileMatrixSetLink'][idx]['TileMatrixSet']);
goog.asserts.assert(!goog.isNull(matrixSet),
'TileMatrixSet must not be null');
goog.asserts.assert(matrixSet, 'TileMatrixSet must not be null');
var format = /** @type {string} */ (l['Format'][0]);
if ('format' in config) {
@@ -420,7 +418,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var matrixSetObj = goog.array.find(matrixSets, function(elt, index, array) {
return elt['Identifier'] == matrixSet;
});
goog.asserts.assert(!goog.isNull(matrixSetObj),
goog.asserts.assert(matrixSetObj,
'found matrixSet in Contents/TileMatrixSet');
var projection;
@@ -440,7 +438,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
extent = ol.proj.transformExtent(
wgs84BoundingBox, 'EPSG:4326', projection);
var projectionExtent = projection.getExtent();
if (!goog.isNull(projectionExtent)) {
if (projectionExtent) {
// If possible, do a sanity check on the extent - it should never be
// bigger than the validity extent of the projection of a matrix set.
if (!ol.extent.containsExtent(projectionExtent, extent)) {

View File

@@ -104,7 +104,7 @@ ol.source.Zoomify = function(opt_options) {
* @return {string|undefined} Tile URL.
*/
function tileUrlFunction(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) {
if (!tileCoord) {
return undefined;
} else {
var tileCoordZ = tileCoord[0];