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

@@ -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);
}
}