Remove goog.isDef from snapinteraction
This commit is contained in:
@@ -6,6 +6,7 @@ goog.require('goog.asserts');
|
|||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEvent');
|
goog.require('ol.CollectionEvent');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol.CollectionEventType');
|
||||||
@@ -54,19 +55,19 @@ ol.interaction.Snap = function(opt_options) {
|
|||||||
handleUpEvent: ol.interaction.Snap.handleUpEvent_
|
handleUpEvent: ol.interaction.Snap.handleUpEvent_
|
||||||
});
|
});
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.source.Vector}
|
* @type {ol.source.Vector}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.source_ = goog.isDef(options.source) ? options.source : null;
|
this.source_ = options.source ? options.source : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Collection.<ol.Feature>}
|
* @type {ol.Collection.<ol.Feature>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.features_ = goog.isDef(options.features) ? options.features : null;
|
this.features_ = options.features ? options.features : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array.<goog.events.Key>}
|
* @type {Array.<goog.events.Key>}
|
||||||
@@ -114,8 +115,8 @@ ol.interaction.Snap = function(opt_options) {
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ?
|
this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ?
|
||||||
options.pixelTolerance : 10;
|
/** @type {number} */ (options.pixelTolerance) : 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number}
|
* @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number}
|
||||||
@@ -159,10 +160,11 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer);
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
|
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 geometry = feature.getGeometry();
|
||||||
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
|
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
|
||||||
if (goog.isDef(segmentWriter)) {
|
if (segmentWriter) {
|
||||||
var feature_uid = goog.getUid(feature);
|
var feature_uid = goog.getUid(feature);
|
||||||
this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent(
|
this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent(
|
||||||
ol.extent.createEmpty());
|
ol.extent.createEmpty());
|
||||||
@@ -210,7 +212,7 @@ ol.interaction.Snap.prototype.getFeatures_ = function() {
|
|||||||
} else if (!goog.isNull(this.source_)) {
|
} else if (!goog.isNull(this.source_)) {
|
||||||
features = this.source_.getFeatures();
|
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;
|
return features;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -286,7 +288,8 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
|
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 feature_uid = goog.getUid(feature);
|
||||||
var extent = this.indexedFeaturesExtents_[feature_uid];
|
var extent = this.indexedFeaturesExtents_[feature_uid];
|
||||||
if (extent) {
|
if (extent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user