Remove goog.isDef from snapinteraction

This commit is contained in:
Marc Jansen
2015-09-23 20:14:41 +02:00
committed by Tim Schaub
parent 4b993727c8
commit c1c07e2f3c

View File

@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.CollectionEvent');
goog.require('ol.CollectionEventType');
@@ -54,19 +55,19 @@ ol.interaction.Snap = function(opt_options) {
handleUpEvent: ol.interaction.Snap.handleUpEvent_
});
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @type {ol.source.Vector}
* @private
*/
this.source_ = goog.isDef(options.source) ? options.source : null;
this.source_ = options.source ? options.source : null;
/**
* @type {ol.Collection.<ol.Feature>}
* @private
*/
this.features_ = goog.isDef(options.features) ? options.features : null;
this.features_ = options.features ? options.features : null;
/**
* @type {Array.<goog.events.Key>}
@@ -114,8 +115,8 @@ ol.interaction.Snap = function(opt_options) {
* @type {number}
* @private
*/
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ?
options.pixelTolerance : 10;
this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ?
/** @type {number} */ (options.pixelTolerance) : 10;
/**
* @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number}
@@ -159,10 +160,11 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer);
* @api
*/
ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
var listen = goog.isDef(opt_listen) ? opt_listen : true;
var listen = ol.isDef(opt_listen) ?
/** @type {boolean} */ (opt_listen) : true;
var geometry = feature.getGeometry();
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
if (goog.isDef(segmentWriter)) {
if (segmentWriter) {
var feature_uid = goog.getUid(feature);
this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent(
ol.extent.createEmpty());
@@ -210,7 +212,7 @@ ol.interaction.Snap.prototype.getFeatures_ = function() {
} else if (!goog.isNull(this.source_)) {
features = this.source_.getFeatures();
}
goog.asserts.assert(goog.isDef(features), 'features should be defined');
goog.asserts.assert(features !== undefined, 'features should be defined');
return features;
};
@@ -286,7 +288,8 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) {
* @api
*/
ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
var unlisten = goog.isDef(opt_unlisten) ? opt_unlisten : true;
var unlisten = ol.isDef(opt_unlisten) ?
/** @type {boolean} */ (opt_unlisten) : true;
var feature_uid = goog.getUid(feature);
var extent = this.indexedFeaturesExtents_[feature_uid];
if (extent) {