Rename _ol_Collection_ to Collection
This commit is contained in:
@@ -41,7 +41,7 @@ export var CollectionOptions;
|
||||
* @template T
|
||||
* @api
|
||||
*/
|
||||
var _ol_Collection_ = function(opt_array, opt_options) {
|
||||
var Collection = function(opt_array, opt_options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
@@ -69,14 +69,14 @@ var _ol_Collection_ = function(opt_array, opt_options) {
|
||||
|
||||
};
|
||||
|
||||
inherits(_ol_Collection_, BaseObject);
|
||||
inherits(Collection, BaseObject);
|
||||
|
||||
|
||||
/**
|
||||
* Remove all elements from the collection.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.clear = function() {
|
||||
Collection.prototype.clear = function() {
|
||||
while (this.getLength() > 0) {
|
||||
this.pop();
|
||||
}
|
||||
@@ -90,7 +90,7 @@ _ol_Collection_.prototype.clear = function() {
|
||||
* @return {ol.Collection.<T>} This collection.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.extend = function(arr) {
|
||||
Collection.prototype.extend = function(arr) {
|
||||
var i, ii;
|
||||
for (i = 0, ii = arr.length; i < ii; ++i) {
|
||||
this.push(arr[i]);
|
||||
@@ -106,7 +106,7 @@ _ol_Collection_.prototype.extend = function(arr) {
|
||||
* index and the array). The return value is ignored.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.forEach = function(f) {
|
||||
Collection.prototype.forEach = function(f) {
|
||||
var array = this.array_;
|
||||
for (var i = 0, ii = array.length; i < ii; ++i) {
|
||||
f(array[i], i, array);
|
||||
@@ -122,7 +122,7 @@ _ol_Collection_.prototype.forEach = function(f) {
|
||||
* @return {!Array.<T>} Array.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.getArray = function() {
|
||||
Collection.prototype.getArray = function() {
|
||||
return this.array_;
|
||||
};
|
||||
|
||||
@@ -133,7 +133,7 @@ _ol_Collection_.prototype.getArray = function() {
|
||||
* @return {T} Element.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.item = function(index) {
|
||||
Collection.prototype.item = function(index) {
|
||||
return this.array_[index];
|
||||
};
|
||||
|
||||
@@ -144,7 +144,7 @@ _ol_Collection_.prototype.item = function(index) {
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.getLength = function() {
|
||||
Collection.prototype.getLength = function() {
|
||||
return (/** @type {number} */ this.get(Property.LENGTH));
|
||||
};
|
||||
|
||||
@@ -155,14 +155,14 @@ _ol_Collection_.prototype.getLength = function() {
|
||||
* @param {T} elem Element.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.insertAt = function(index, elem) {
|
||||
Collection.prototype.insertAt = function(index, elem) {
|
||||
if (this.unique_) {
|
||||
this.assertUnique_(elem);
|
||||
}
|
||||
this.array_.splice(index, 0, elem);
|
||||
this.updateLength_();
|
||||
this.dispatchEvent(
|
||||
new _ol_Collection_.Event(CollectionEventType.ADD, elem));
|
||||
new Collection.Event(CollectionEventType.ADD, elem));
|
||||
};
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ _ol_Collection_.prototype.insertAt = function(index, elem) {
|
||||
* @return {T|undefined} Element.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.pop = function() {
|
||||
Collection.prototype.pop = function() {
|
||||
return this.removeAt(this.getLength() - 1);
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ _ol_Collection_.prototype.pop = function() {
|
||||
* @return {number} New length of the collection.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.push = function(elem) {
|
||||
Collection.prototype.push = function(elem) {
|
||||
if (this.unique_) {
|
||||
this.assertUnique_(elem);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ _ol_Collection_.prototype.push = function(elem) {
|
||||
* @return {T|undefined} The removed element or undefined if none found.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.remove = function(elem) {
|
||||
Collection.prototype.remove = function(elem) {
|
||||
var arr = this.array_;
|
||||
var i, ii;
|
||||
for (i = 0, ii = arr.length; i < ii; ++i) {
|
||||
@@ -218,12 +218,12 @@ _ol_Collection_.prototype.remove = function(elem) {
|
||||
* @return {T|undefined} Value.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.removeAt = function(index) {
|
||||
Collection.prototype.removeAt = function(index) {
|
||||
var prev = this.array_[index];
|
||||
this.array_.splice(index, 1);
|
||||
this.updateLength_();
|
||||
this.dispatchEvent(
|
||||
new _ol_Collection_.Event(CollectionEventType.REMOVE, prev));
|
||||
new Collection.Event(CollectionEventType.REMOVE, prev));
|
||||
return prev;
|
||||
};
|
||||
|
||||
@@ -234,7 +234,7 @@ _ol_Collection_.prototype.removeAt = function(index) {
|
||||
* @param {T} elem Element.
|
||||
* @api
|
||||
*/
|
||||
_ol_Collection_.prototype.setAt = function(index, elem) {
|
||||
Collection.prototype.setAt = function(index, elem) {
|
||||
var n = this.getLength();
|
||||
if (index < n) {
|
||||
if (this.unique_) {
|
||||
@@ -243,9 +243,9 @@ _ol_Collection_.prototype.setAt = function(index, elem) {
|
||||
var prev = this.array_[index];
|
||||
this.array_[index] = elem;
|
||||
this.dispatchEvent(
|
||||
new _ol_Collection_.Event(CollectionEventType.REMOVE, prev));
|
||||
new Collection.Event(CollectionEventType.REMOVE, prev));
|
||||
this.dispatchEvent(
|
||||
new _ol_Collection_.Event(CollectionEventType.ADD, elem));
|
||||
new Collection.Event(CollectionEventType.ADD, elem));
|
||||
} else {
|
||||
var j;
|
||||
for (j = n; j < index; ++j) {
|
||||
@@ -259,7 +259,7 @@ _ol_Collection_.prototype.setAt = function(index, elem) {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_ol_Collection_.prototype.updateLength_ = function() {
|
||||
Collection.prototype.updateLength_ = function() {
|
||||
this.set(Property.LENGTH, this.array_.length);
|
||||
};
|
||||
|
||||
@@ -269,7 +269,7 @@ _ol_Collection_.prototype.updateLength_ = function() {
|
||||
* @param {T} elem Element.
|
||||
* @param {number=} opt_except Optional index to ignore.
|
||||
*/
|
||||
_ol_Collection_.prototype.assertUnique_ = function(elem, opt_except) {
|
||||
Collection.prototype.assertUnique_ = function(elem, opt_except) {
|
||||
for (var i = 0, ii = this.array_.length; i < ii; ++i) {
|
||||
if (this.array_[i] === elem && i !== opt_except) {
|
||||
throw new AssertionError(58);
|
||||
@@ -288,7 +288,7 @@ _ol_Collection_.prototype.assertUnique_ = function(elem, opt_except) {
|
||||
* @param {ol.CollectionEventType} type Type.
|
||||
* @param {*=} opt_element Element.
|
||||
*/
|
||||
_ol_Collection_.Event = function(type, opt_element) {
|
||||
Collection.Event = function(type, opt_element) {
|
||||
|
||||
Event.call(this, type);
|
||||
|
||||
@@ -300,6 +300,6 @@ _ol_Collection_.Event = function(type, opt_element) {
|
||||
this.element = opt_element;
|
||||
|
||||
};
|
||||
inherits(_ol_Collection_.Event, Event);
|
||||
inherits(Collection.Event, Event);
|
||||
|
||||
export default _ol_Collection_;
|
||||
export default Collection;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/PluggableMap
|
||||
*/
|
||||
import {getUid, inherits} from './index.js';
|
||||
import _ol_Collection_ from './Collection.js';
|
||||
import Collection from './Collection.js';
|
||||
import CollectionEventType from './CollectionEventType.js';
|
||||
import MapBrowserEvent from './MapBrowserEvent.js';
|
||||
import MapBrowserEventHandler from './MapBrowserEventHandler.js';
|
||||
@@ -276,13 +276,13 @@ var PluggableMap = function(options) {
|
||||
* @type {ol.Collection.<ol.control.Control>}
|
||||
* @protected
|
||||
*/
|
||||
this.controls = optionsInternal.controls || new _ol_Collection_();
|
||||
this.controls = optionsInternal.controls || new Collection();
|
||||
|
||||
/**
|
||||
* @type {ol.Collection.<ol.interaction.Interaction>}
|
||||
* @protected
|
||||
*/
|
||||
this.interactions = optionsInternal.interactions || new _ol_Collection_();
|
||||
this.interactions = optionsInternal.interactions || new Collection();
|
||||
|
||||
/**
|
||||
* @type {ol.Collection.<ol.Overlay>}
|
||||
@@ -1457,9 +1457,9 @@ function createOptionsInternal(options) {
|
||||
var controls;
|
||||
if (options.controls !== undefined) {
|
||||
if (Array.isArray(options.controls)) {
|
||||
controls = new _ol_Collection_(options.controls.slice());
|
||||
controls = new Collection(options.controls.slice());
|
||||
} else {
|
||||
assert(options.controls instanceof _ol_Collection_,
|
||||
assert(options.controls instanceof Collection,
|
||||
47); // Expected `controls` to be an array or an `ol.Collection`
|
||||
controls = options.controls;
|
||||
}
|
||||
@@ -1468,9 +1468,9 @@ function createOptionsInternal(options) {
|
||||
var interactions;
|
||||
if (options.interactions !== undefined) {
|
||||
if (Array.isArray(options.interactions)) {
|
||||
interactions = new _ol_Collection_(options.interactions.slice());
|
||||
interactions = new Collection(options.interactions.slice());
|
||||
} else {
|
||||
assert(options.interactions instanceof _ol_Collection_,
|
||||
assert(options.interactions instanceof Collection,
|
||||
48); // Expected `interactions` to be an array or an `ol.Collection`
|
||||
interactions = options.interactions;
|
||||
}
|
||||
@@ -1479,14 +1479,14 @@ function createOptionsInternal(options) {
|
||||
var overlays;
|
||||
if (options.overlays !== undefined) {
|
||||
if (Array.isArray(options.overlays)) {
|
||||
overlays = new _ol_Collection_(options.overlays.slice());
|
||||
overlays = new Collection(options.overlays.slice());
|
||||
} else {
|
||||
assert(options.overlays instanceof _ol_Collection_,
|
||||
assert(options.overlays instanceof Collection,
|
||||
49); // Expected `overlays` to be an array or an `ol.Collection`
|
||||
overlays = options.overlays;
|
||||
}
|
||||
} else {
|
||||
overlays = new _ol_Collection_();
|
||||
overlays = new Collection();
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/control
|
||||
*/
|
||||
import _ol_Collection_ from './Collection.js';
|
||||
import Collection from './Collection.js';
|
||||
import Attribution from './control/Attribution.js';
|
||||
import Rotate from './control/Rotate.js';
|
||||
import Zoom from './control/Zoom.js';
|
||||
@@ -23,7 +23,7 @@ export function defaults(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
|
||||
var controls = new _ol_Collection_();
|
||||
var controls = new Collection();
|
||||
|
||||
var zoomControl = options.zoom !== undefined ? options.zoom : true;
|
||||
if (zoomControl) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/control/OverviewMap
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Collection_ from '../Collection.js';
|
||||
import Collection from '../Collection.js';
|
||||
import PluggableMap from '../PluggableMap.js';
|
||||
import MapEventType from '../MapEventType.js';
|
||||
import MapProperty from '../MapProperty.js';
|
||||
@@ -116,8 +116,8 @@ var OverviewMap = function(opt_options) {
|
||||
* @private
|
||||
*/
|
||||
this.ovmap_ = new PluggableMap({
|
||||
controls: new _ol_Collection_(),
|
||||
interactions: new _ol_Collection_(),
|
||||
controls: new Collection(),
|
||||
interactions: new Collection(),
|
||||
view: options.view
|
||||
});
|
||||
var ovmap = this.ovmap_;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/interaction
|
||||
*/
|
||||
import _ol_Collection_ from './Collection.js';
|
||||
import Collection from './Collection.js';
|
||||
import Kinetic from './Kinetic.js';
|
||||
import DoubleClickZoom from './interaction/DoubleClickZoom.js';
|
||||
import DragPan from './interaction/DragPan.js';
|
||||
@@ -41,7 +41,7 @@ export function defaults(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
|
||||
var interactions = new _ol_Collection_();
|
||||
var interactions = new Collection();
|
||||
|
||||
var kinetic = new Kinetic(-0.005, 0.05, 100);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/interaction/Modify
|
||||
*/
|
||||
import {getUid, inherits} from '../index.js';
|
||||
import _ol_Collection_ from '../Collection.js';
|
||||
import Collection from '../Collection.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import Feature from '../Feature.js';
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
@@ -195,7 +195,7 @@ var _ol_interaction_Modify_ = function(options) {
|
||||
var features;
|
||||
if (options.source) {
|
||||
this.source_ = options.source;
|
||||
features = new _ol_Collection_(this.source_.getFeatures());
|
||||
features = new Collection(this.source_.getFeatures());
|
||||
_ol_events_.listen(this.source_, VectorEventType.ADDFEATURE,
|
||||
this.handleSourceAdd_, this);
|
||||
_ol_events_.listen(this.source_, VectorEventType.REMOVEFEATURE,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/interaction/Snap
|
||||
*/
|
||||
import {getUid, inherits} from '../index.js';
|
||||
import _ol_Collection_ from '../Collection.js';
|
||||
import Collection from '../Collection.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import _ol_coordinate_ from '../coordinate.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
@@ -221,7 +221,7 @@ _ol_interaction_Snap_.prototype.handleFeatureAdd_ = function(evt) {
|
||||
var feature;
|
||||
if (evt instanceof VectorSource.Event) {
|
||||
feature = evt.feature;
|
||||
} else if (evt instanceof _ol_Collection_.Event) {
|
||||
} else if (evt instanceof Collection.Event) {
|
||||
feature = evt.element;
|
||||
}
|
||||
this.addFeature(/** @type {ol.Feature} */ (feature));
|
||||
@@ -236,7 +236,7 @@ _ol_interaction_Snap_.prototype.handleFeatureRemove_ = function(evt) {
|
||||
var feature;
|
||||
if (evt instanceof VectorSource.Event) {
|
||||
feature = evt.feature;
|
||||
} else if (evt instanceof _ol_Collection_.Event) {
|
||||
} else if (evt instanceof Collection.Event) {
|
||||
feature = evt.element;
|
||||
}
|
||||
this.removeFeature(/** @type {ol.Feature} */ (feature));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/interaction/Translate
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Collection_ from '../Collection.js';
|
||||
import Collection from '../Collection.js';
|
||||
import BaseObject from '../Object.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
@@ -100,7 +100,7 @@ _ol_interaction_Translate_.handleDownEvent_ = function(event) {
|
||||
this.lastCoordinate_ = event.coordinate;
|
||||
_ol_interaction_Translate_.handleMoveEvent_.call(this, event);
|
||||
|
||||
var features = this.features_ || new _ol_Collection_([this.lastFeature_]);
|
||||
var features = this.features_ || new Collection([this.lastFeature_]);
|
||||
|
||||
this.dispatchEvent(
|
||||
new _ol_interaction_Translate_.Event(
|
||||
@@ -123,7 +123,7 @@ _ol_interaction_Translate_.handleUpEvent_ = function(event) {
|
||||
this.lastCoordinate_ = null;
|
||||
_ol_interaction_Translate_.handleMoveEvent_.call(this, event);
|
||||
|
||||
var features = this.features_ || new _ol_Collection_([this.lastFeature_]);
|
||||
var features = this.features_ || new Collection([this.lastFeature_]);
|
||||
|
||||
this.dispatchEvent(
|
||||
new _ol_interaction_Translate_.Event(
|
||||
@@ -146,7 +146,7 @@ _ol_interaction_Translate_.handleDragEvent_ = function(event) {
|
||||
var deltaX = newCoordinate[0] - this.lastCoordinate_[0];
|
||||
var deltaY = newCoordinate[1] - this.lastCoordinate_[1];
|
||||
|
||||
var features = this.features_ || new _ol_Collection_([this.lastFeature_]);
|
||||
var features = this.features_ || new Collection([this.lastFeature_]);
|
||||
|
||||
features.forEach(function(feature) {
|
||||
var geom = feature.getGeometry();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/layer/Group
|
||||
*/
|
||||
import {getUid, inherits} from '../index.js';
|
||||
import _ol_Collection_ from '../Collection.js';
|
||||
import Collection from '../Collection.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import BaseObject from '../Object.js';
|
||||
import ObjectEventType from '../ObjectEventType.js';
|
||||
@@ -64,14 +64,14 @@ var LayerGroup = function(opt_options) {
|
||||
|
||||
if (layers) {
|
||||
if (Array.isArray(layers)) {
|
||||
layers = new _ol_Collection_(layers.slice(), {unique: true});
|
||||
layers = new Collection(layers.slice(), {unique: true});
|
||||
} else {
|
||||
assert(layers instanceof _ol_Collection_,
|
||||
assert(layers instanceof Collection,
|
||||
43); // Expected `layers` to be an array or an `ol.Collection`
|
||||
layers = layers;
|
||||
}
|
||||
} else {
|
||||
layers = new _ol_Collection_(undefined, {unique: true});
|
||||
layers = new Collection(undefined, {unique: true});
|
||||
}
|
||||
|
||||
this.setLayers(layers);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import {getUid, inherits, nullFunction} from '../index.js';
|
||||
import _ol_Collection_ from '../Collection.js';
|
||||
import Collection from '../Collection.js';
|
||||
import CollectionEventType from '../CollectionEventType.js';
|
||||
import ObjectEventType from '../ObjectEventType.js';
|
||||
import {extend} from '../array.js';
|
||||
@@ -131,14 +131,14 @@ var VectorSource = function(opt_options) {
|
||||
this.featuresCollection_ = null;
|
||||
|
||||
var collection, features;
|
||||
if (options.features instanceof _ol_Collection_) {
|
||||
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 _ol_Collection_(features);
|
||||
collection = new Collection(features);
|
||||
}
|
||||
if (features !== undefined) {
|
||||
this.addFeaturesInternal(features);
|
||||
|
||||
Reference in New Issue
Block a user