Manual class transform
This commit is contained in:
@@ -41,18 +41,23 @@ import RBush from '../structs/RBush.js';
|
||||
* @param {string} type Type.
|
||||
* @param {module:ol/Feature=} opt_feature Feature.
|
||||
*/
|
||||
export const VectorSourceEvent = function(type, opt_feature) {
|
||||
export class VectorSourceEvent {
|
||||
|
||||
Event.call(this, type);
|
||||
constructor(type, opt_feature) {
|
||||
|
||||
/**
|
||||
* The feature being added or removed.
|
||||
* @type {module:ol/Feature|undefined}
|
||||
* @api
|
||||
*/
|
||||
this.feature = opt_feature;
|
||||
Event.call(this, type);
|
||||
|
||||
/**
|
||||
* The feature being added or removed.
|
||||
* @type {module:ol/Feature|undefined}
|
||||
* @api
|
||||
*/
|
||||
this.feature = opt_feature;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
inherits(VectorSourceEvent, Event);
|
||||
|
||||
|
||||
@@ -158,120 +163,124 @@ inherits(VectorSourceEvent, Event);
|
||||
* @param {module:ol/source/Vector~Options=} opt_options Vector source options.
|
||||
* @api
|
||||
*/
|
||||
const VectorSource = function(opt_options) {
|
||||
class VectorSource {
|
||||
|
||||
const options = opt_options || {};
|
||||
constructor(opt_options) {
|
||||
|
||||
Source.call(this, {
|
||||
attributions: options.attributions,
|
||||
projection: undefined,
|
||||
state: SourceState.READY,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
});
|
||||
const options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/featureloader~FeatureLoader}
|
||||
*/
|
||||
this.loader_ = UNDEFINED;
|
||||
Source.call(this, {
|
||||
attributions: options.attributions,
|
||||
projection: undefined,
|
||||
state: SourceState.READY,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/format/Feature|undefined}
|
||||
*/
|
||||
this.format_ = options.format;
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/featureloader~FeatureLoader}
|
||||
*/
|
||||
this.loader_ = UNDEFINED;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.overlaps_ = options.overlaps == undefined ? true : options.overlaps;
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/format/Feature|undefined}
|
||||
*/
|
||||
this.format_ = options.format;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|module:ol/featureloader~FeatureUrlFunction|undefined}
|
||||
*/
|
||||
this.url_ = options.url;
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.overlaps_ = options.overlaps == undefined ? true : options.overlaps;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|module:ol/featureloader~FeatureUrlFunction|undefined}
|
||||
*/
|
||||
this.url_ = options.url;
|
||||
|
||||
if (options.loader !== undefined) {
|
||||
this.loader_ = options.loader;
|
||||
} else if (this.url_ !== undefined) {
|
||||
assert(this.format_, 7); // `format` must be set when `url` is set
|
||||
// create a XHR feature loader for "url" and "format"
|
||||
this.loader_ = xhr(this.url_, /** @type {module:ol/format/Feature} */ (this.format_));
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/source/Vector~LoadingStrategy}
|
||||
*/
|
||||
this.strategy_ = options.strategy !== undefined ? options.strategy : allStrategy;
|
||||
|
||||
const useSpatialIndex =
|
||||
options.useSpatialIndex !== undefined ? options.useSpatialIndex : true;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/structs/RBush.<module:ol/Feature>}
|
||||
*/
|
||||
this.featuresRtree_ = useSpatialIndex ? new RBush() : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/structs/RBush.<{extent: module:ol/extent~Extent}>}
|
||||
*/
|
||||
this.loadedExtentsRtree_ = new RBush();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object.<string, module:ol/Feature>}
|
||||
*/
|
||||
this.nullGeometryFeatures_ = {};
|
||||
|
||||
/**
|
||||
* A lookup of features by id (the return from feature.getId()).
|
||||
* @private
|
||||
* @type {!Object.<string, module:ol/Feature>}
|
||||
*/
|
||||
this.idIndex_ = {};
|
||||
|
||||
/**
|
||||
* A lookup of features without id (keyed by getUid(feature)).
|
||||
* @private
|
||||
* @type {!Object.<string, module:ol/Feature>}
|
||||
*/
|
||||
this.undefIdIndex_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Object.<string, Array.<module:ol/events~EventsKey>>}
|
||||
*/
|
||||
this.featureChangeKeys_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/Collection.<module:ol/Feature>}
|
||||
*/
|
||||
this.featuresCollection_ = null;
|
||||
|
||||
let collection, features;
|
||||
if (options.features instanceof Collection) {
|
||||
collection = options.features;
|
||||
features = collection.getArray();
|
||||
} else if (Array.isArray(options.features)) {
|
||||
features = options.features;
|
||||
}
|
||||
if (!useSpatialIndex && collection === undefined) {
|
||||
collection = new Collection(features);
|
||||
}
|
||||
if (features !== undefined) {
|
||||
this.addFeaturesInternal(features);
|
||||
}
|
||||
if (collection !== undefined) {
|
||||
this.bindFeaturesCollection_(collection);
|
||||
}
|
||||
|
||||
if (options.loader !== undefined) {
|
||||
this.loader_ = options.loader;
|
||||
} else if (this.url_ !== undefined) {
|
||||
assert(this.format_, 7); // `format` must be set when `url` is set
|
||||
// create a XHR feature loader for "url" and "format"
|
||||
this.loader_ = xhr(this.url_, /** @type {module:ol/format/Feature} */ (this.format_));
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/source/Vector~LoadingStrategy}
|
||||
*/
|
||||
this.strategy_ = options.strategy !== undefined ? options.strategy : allStrategy;
|
||||
|
||||
const useSpatialIndex =
|
||||
options.useSpatialIndex !== undefined ? options.useSpatialIndex : true;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/structs/RBush.<module:ol/Feature>}
|
||||
*/
|
||||
this.featuresRtree_ = useSpatialIndex ? new RBush() : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/structs/RBush.<{extent: module:ol/extent~Extent}>}
|
||||
*/
|
||||
this.loadedExtentsRtree_ = new RBush();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object.<string, module:ol/Feature>}
|
||||
*/
|
||||
this.nullGeometryFeatures_ = {};
|
||||
|
||||
/**
|
||||
* A lookup of features by id (the return from feature.getId()).
|
||||
* @private
|
||||
* @type {!Object.<string, module:ol/Feature>}
|
||||
*/
|
||||
this.idIndex_ = {};
|
||||
|
||||
/**
|
||||
* A lookup of features without id (keyed by getUid(feature)).
|
||||
* @private
|
||||
* @type {!Object.<string, module:ol/Feature>}
|
||||
*/
|
||||
this.undefIdIndex_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Object.<string, Array.<module:ol/events~EventsKey>>}
|
||||
*/
|
||||
this.featureChangeKeys_ = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/Collection.<module:ol/Feature>}
|
||||
*/
|
||||
this.featuresCollection_ = null;
|
||||
|
||||
let collection, features;
|
||||
if (options.features instanceof Collection) {
|
||||
collection = options.features;
|
||||
features = collection.getArray();
|
||||
} else if (Array.isArray(options.features)) {
|
||||
features = options.features;
|
||||
}
|
||||
if (!useSpatialIndex && collection === undefined) {
|
||||
collection = new Collection(features);
|
||||
}
|
||||
if (features !== undefined) {
|
||||
this.addFeaturesInternal(features);
|
||||
}
|
||||
if (collection !== undefined) {
|
||||
this.bindFeaturesCollection_(collection);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
inherits(VectorSource, Source);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user