Change getUid return type from number to string
This commit is contained in:
@@ -42,7 +42,7 @@ import {create as createTransform, apply as applyTransform} from './transform.js
|
||||
* @property {null|import("./extent.js").Extent} extent
|
||||
* @property {import("./coordinate.js").Coordinate} focus
|
||||
* @property {number} index
|
||||
* @property {Object<number, import("./layer/Layer.js").State>} layerStates
|
||||
* @property {Object<string, import("./layer/Layer.js").State>} layerStates
|
||||
* @property {Array<import("./layer/Layer.js").State>} layerStatesArray
|
||||
* @property {import("./transform.js").Transform} pixelToCoordinateTransform
|
||||
* @property {Array<PostRenderFunction>} postRenderFunctions
|
||||
@@ -1068,7 +1068,7 @@ class PluggableMap extends BaseObject {
|
||||
}
|
||||
const view = this.getView();
|
||||
if (view) {
|
||||
this.viewport_.setAttribute('data-view', getUid(view).toString());
|
||||
this.viewport_.setAttribute('data-view', getUid(view));
|
||||
this.viewPropertyListenerKey_ = listen(
|
||||
view, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleViewPropertyChanged_, this);
|
||||
@@ -1304,8 +1304,7 @@ class PluggableMap extends BaseObject {
|
||||
* @param {import("./Feature.js").default} feature Feature.
|
||||
*/
|
||||
skipFeature(feature) {
|
||||
const featureUid = getUid(feature).toString();
|
||||
this.skippedFeatureUids_[featureUid] = true;
|
||||
this.skippedFeatureUids_[getUid(feature)] = true;
|
||||
this.render();
|
||||
}
|
||||
|
||||
@@ -1340,8 +1339,7 @@ class PluggableMap extends BaseObject {
|
||||
* @param {import("./Feature.js").default} feature Feature.
|
||||
*/
|
||||
unskipFeature(feature) {
|
||||
const featureUid = getUid(feature).toString();
|
||||
delete this.skippedFeatureUids_[featureUid];
|
||||
delete this.skippedFeatureUids_[getUid(feature)];
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class Tile extends EventTarget {
|
||||
/**
|
||||
* Lookup of start times for rendering transitions. If the start time is
|
||||
* equal to -1, the transition is complete.
|
||||
* @type {Object<number, number>}
|
||||
* @type {Object<string, number>}
|
||||
*/
|
||||
this.transitionStarts_ = {};
|
||||
|
||||
@@ -244,7 +244,7 @@ class Tile extends EventTarget {
|
||||
|
||||
/**
|
||||
* Get the alpha value for rendering.
|
||||
* @param {number} id An id for the renderer.
|
||||
* @param {string} id An id for the renderer.
|
||||
* @param {number} time The render frame time.
|
||||
* @return {number} A number between 0 and 1.
|
||||
*/
|
||||
@@ -272,7 +272,7 @@ class Tile extends EventTarget {
|
||||
* Determine if a tile is in an alpha transition. A tile is considered in
|
||||
* transition if tile.getAlpha() has not yet been called or has been called
|
||||
* and returned 1.
|
||||
* @param {number} id An id for the renderer.
|
||||
* @param {string} id An id for the renderer.
|
||||
* @return {boolean} The tile is in transition.
|
||||
*/
|
||||
inTransition(id) {
|
||||
@@ -284,7 +284,7 @@ class Tile extends EventTarget {
|
||||
|
||||
/**
|
||||
* Mark a transition as complete.
|
||||
* @param {number} id An id for the renderer.
|
||||
* @param {string} id An id for the renderer.
|
||||
*/
|
||||
endTransition(id) {
|
||||
if (this.transition_) {
|
||||
|
||||
@@ -191,7 +191,7 @@ class VectorImageTile extends Tile {
|
||||
* @return {CanvasRenderingContext2D} The rendering context.
|
||||
*/
|
||||
getContext(layer) {
|
||||
const key = getUid(layer).toString();
|
||||
const key = getUid(layer);
|
||||
if (!(key in this.context_)) {
|
||||
this.context_[key] = createCanvasContext2D();
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class VectorImageTile extends Tile {
|
||||
* @return {ReplayState} The replay state.
|
||||
*/
|
||||
getReplayState(layer) {
|
||||
const key = getUid(layer).toString();
|
||||
const key = getUid(layer);
|
||||
if (!(key in this.replayState_)) {
|
||||
this.replayState_[key] = {
|
||||
dirty: false,
|
||||
|
||||
@@ -788,7 +788,7 @@ class Modify extends PointerInteraction {
|
||||
for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
|
||||
const segmentDataMatch = segmentDataMatches[i];
|
||||
const segment = segmentDataMatch.segment;
|
||||
let uid = String(getUid(segmentDataMatch.feature));
|
||||
let uid = getUid(segmentDataMatch.feature);
|
||||
const depth = segmentDataMatch.depth;
|
||||
if (depth) {
|
||||
uid += '-' + depth.join('-'); // separate feature components
|
||||
@@ -1038,7 +1038,7 @@ class Modify extends PointerInteraction {
|
||||
for (i = dragSegments.length - 1; i >= 0; --i) {
|
||||
dragSegment = dragSegments[i];
|
||||
segmentData = dragSegment[0];
|
||||
uid = String(getUid(segmentData.feature));
|
||||
uid = getUid(segmentData.feature);
|
||||
if (segmentData.depth) {
|
||||
// separate feature components
|
||||
uid += '-' + segmentData.depth.join('-');
|
||||
|
||||
@@ -250,7 +250,7 @@ class Select extends Interaction {
|
||||
* An association between selected feature (key)
|
||||
* and layer (value)
|
||||
* @private
|
||||
* @type {Object<number, import("../layer/Layer.js").default>}
|
||||
* @type {Object<string, import("../layer/Layer.js").default>}
|
||||
*/
|
||||
this.featureLayerAssociation_ = {};
|
||||
|
||||
@@ -267,8 +267,7 @@ class Select extends Interaction {
|
||||
* @private
|
||||
*/
|
||||
addFeatureLayerAssociation_(feature, layer) {
|
||||
const key = getUid(feature);
|
||||
this.featureLayerAssociation_[key] = layer;
|
||||
this.featureLayerAssociation_[getUid(feature)] = layer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,9 +298,8 @@ class Select extends Interaction {
|
||||
* @api
|
||||
*/
|
||||
getLayer(feature) {
|
||||
const key = getUid(feature);
|
||||
return (
|
||||
/** @type {VectorLayer} */ (this.featureLayerAssociation_[key])
|
||||
/** @type {VectorLayer} */ (this.featureLayerAssociation_[getUid(feature)])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -372,8 +370,7 @@ class Select extends Interaction {
|
||||
* @private
|
||||
*/
|
||||
removeFeatureLayerAssociation_(feature) {
|
||||
const key = getUid(feature);
|
||||
delete this.featureLayerAssociation_[key];
|
||||
delete this.featureLayerAssociation_[getUid(feature)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class Snap extends PointerInteraction {
|
||||
this.featuresListenerKeys_ = [];
|
||||
|
||||
/**
|
||||
* @type {Object<number, import("../events.js").EventsKey>}
|
||||
* @type {Object<string, import("../events.js").EventsKey>}
|
||||
* @private
|
||||
*/
|
||||
this.featureChangeListenerKeys_ = {};
|
||||
@@ -135,7 +135,7 @@ class Snap extends PointerInteraction {
|
||||
/**
|
||||
* Extents are preserved so indexed segment can be quickly removed
|
||||
* when its feature geometry changes
|
||||
* @type {Object<number, import("../extent.js").Extent>}
|
||||
* @type {Object<string, import("../extent.js").Extent>}
|
||||
* @private
|
||||
*/
|
||||
this.indexedFeaturesExtents_ = {};
|
||||
@@ -144,7 +144,7 @@ class Snap extends PointerInteraction {
|
||||
* If a feature geometry changes while a pointer drag|move event occurs, the
|
||||
* feature doesn't get updated right away. It will be at the next 'pointerup'
|
||||
* event fired.
|
||||
* @type {!Object<number, import("../Feature.js").default>}
|
||||
* @type {!Object<string, import("../Feature.js").default>}
|
||||
* @private
|
||||
*/
|
||||
this.pendingFeatures_ = {};
|
||||
|
||||
@@ -123,7 +123,7 @@ class LayerGroup extends BaseLayer {
|
||||
const layersArray = layers.getArray();
|
||||
for (let i = 0, ii = layersArray.length; i < ii; i++) {
|
||||
const layer = layersArray[i];
|
||||
this.listenerKeys_[getUid(layer).toString()] = [
|
||||
this.listenerKeys_[getUid(layer)] = [
|
||||
listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this),
|
||||
listen(layer, EventType.CHANGE, this.handleLayerChange_, this)
|
||||
];
|
||||
@@ -138,8 +138,7 @@ class LayerGroup extends BaseLayer {
|
||||
*/
|
||||
handleLayersAdd_(collectionEvent) {
|
||||
const layer = /** @type {import("./Base.js").default} */ (collectionEvent.element);
|
||||
const key = getUid(layer).toString();
|
||||
this.listenerKeys_[key] = [
|
||||
this.listenerKeys_[getUid(layer)] = [
|
||||
listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this),
|
||||
listen(layer, EventType.CHANGE, this.handleLayerChange_, this)
|
||||
];
|
||||
@@ -152,7 +151,7 @@ class LayerGroup extends BaseLayer {
|
||||
*/
|
||||
handleLayersRemove_(collectionEvent) {
|
||||
const layer = /** @type {import("./Base.js").default} */ (collectionEvent.element);
|
||||
const key = getUid(layer).toString();
|
||||
const key = getUid(layer);
|
||||
this.listenerKeys_[key].forEach(unlistenByKey);
|
||||
delete this.listenerKeys_[key];
|
||||
this.changed();
|
||||
|
||||
@@ -597,9 +597,7 @@ class CanvasReplay extends VectorContext {
|
||||
switch (type) {
|
||||
case CanvasInstruction.BEGIN_GEOMETRY:
|
||||
feature = /** @type {import("../../Feature.js").default|import("../Feature.js").default} */ (instruction[1]);
|
||||
if ((skipFeatures &&
|
||||
skippedFeaturesHash[getUid(feature).toString()]) ||
|
||||
!feature.getGeometry()) {
|
||||
if ((skipFeatures && skippedFeaturesHash[getUid(feature)]) || !feature.getGeometry()) {
|
||||
i = /** @type {number} */ (instruction[2]);
|
||||
} else if (opt_hitExtent !== undefined && !intersects(
|
||||
opt_hitExtent, feature.getGeometry().getExtent())) {
|
||||
|
||||
@@ -255,7 +255,7 @@ class WebGLCircleReplay extends WebGLReplay {
|
||||
* @inheritDoc
|
||||
*/
|
||||
drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {
|
||||
let i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||
let i, start, end, nextStyle, groupStart, feature, featureIndex;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = this.startIndices[featureIndex + 1];
|
||||
for (i = this.styleIndices_.length - 1; i >= 0; --i) {
|
||||
@@ -269,9 +269,8 @@ class WebGLCircleReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
if (skippedFeaturesHash[getUid(feature)] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
@@ -300,7 +299,7 @@ class WebGLCircleReplay extends WebGLReplay {
|
||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||
*/
|
||||
drawReplaySkipping_(gl, context, skippedFeaturesHash) {
|
||||
let i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||
let i, start, end, nextStyle, groupStart, feature, featureIndex, featureStart;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = start = this.startIndices[featureIndex + 1];
|
||||
for (i = this.styleIndices_.length - 1; i >= 0; --i) {
|
||||
@@ -314,9 +313,8 @@ class WebGLCircleReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
featureStart = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid]) {
|
||||
if (skippedFeaturesHash[getUid(feature)]) {
|
||||
if (start !== end) {
|
||||
this.drawElements(gl, context, start, end);
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ class WebGLLineStringReplay extends WebGLReplay {
|
||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||
*/
|
||||
drawReplaySkipping_(gl, context, skippedFeaturesHash) {
|
||||
let i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||
let i, start, end, nextStyle, groupStart, feature, featureIndex, featureStart;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = start = this.startIndices[featureIndex + 1];
|
||||
for (i = this.styleIndices_.length - 1; i >= 0; --i) {
|
||||
@@ -548,9 +548,8 @@ class WebGLLineStringReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
featureStart = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid]) {
|
||||
if (skippedFeaturesHash[getUid(feature)]) {
|
||||
if (start !== end) {
|
||||
this.drawElements(gl, context, start, end);
|
||||
gl.clear(gl.DEPTH_BUFFER_BIT);
|
||||
@@ -572,7 +571,7 @@ class WebGLLineStringReplay extends WebGLReplay {
|
||||
* @inheritDoc
|
||||
*/
|
||||
drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {
|
||||
let i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||
let i, start, end, nextStyle, groupStart, feature, featureIndex;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = this.startIndices[featureIndex + 1];
|
||||
for (i = this.styleIndices_.length - 1; i >= 0; --i) {
|
||||
@@ -584,9 +583,8 @@ class WebGLLineStringReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
if (skippedFeaturesHash[getUid(feature)] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
|
||||
@@ -927,7 +927,7 @@ class WebGLPolygonReplay extends WebGLReplay {
|
||||
* @inheritDoc
|
||||
*/
|
||||
drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {
|
||||
let i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||
let i, start, end, nextStyle, groupStart, feature, featureIndex;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = this.startIndices[featureIndex + 1];
|
||||
for (i = this.styleIndices_.length - 1; i >= 0; --i) {
|
||||
@@ -939,9 +939,8 @@ class WebGLPolygonReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
if (skippedFeaturesHash[getUid(feature)] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
@@ -970,7 +969,7 @@ class WebGLPolygonReplay extends WebGLReplay {
|
||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||
*/
|
||||
drawReplaySkipping_(gl, context, skippedFeaturesHash) {
|
||||
let i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||
let i, start, end, nextStyle, groupStart, feature, featureIndex, featureStart;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = start = this.startIndices[featureIndex + 1];
|
||||
for (i = this.styleIndices_.length - 1; i >= 0; --i) {
|
||||
@@ -982,9 +981,8 @@ class WebGLPolygonReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
featureStart = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid]) {
|
||||
if (skippedFeaturesHash[getUid(feature)]) {
|
||||
if (start !== end) {
|
||||
this.drawElements(gl, context, start, end);
|
||||
gl.clear(gl.DEPTH_BUFFER_BIT);
|
||||
|
||||
@@ -244,7 +244,7 @@ class WebGLTextureReplay extends WebGLReplay {
|
||||
for (i = 0; i < ii; ++i) {
|
||||
image = images[i];
|
||||
|
||||
uid = getUid(image).toString();
|
||||
uid = getUid(image);
|
||||
if (uid in texturePerImage) {
|
||||
texture = texturePerImage[uid];
|
||||
} else {
|
||||
@@ -371,8 +371,7 @@ class WebGLTextureReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] <= groupEnd) {
|
||||
const feature = this.startIndicesFeature[featureIndex];
|
||||
|
||||
const featureUid = getUid(feature).toString();
|
||||
if (skippedFeaturesHash[featureUid] !== undefined) {
|
||||
if (skippedFeaturesHash[getUid(feature)] !== undefined) {
|
||||
// feature should be skipped
|
||||
if (start !== end) {
|
||||
// draw the features so far
|
||||
@@ -402,7 +401,7 @@ class WebGLTextureReplay extends WebGLReplay {
|
||||
* @inheritDoc
|
||||
*/
|
||||
drawHitDetectionReplayOneByOne(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {
|
||||
let i, groupStart, start, end, feature, featureUid;
|
||||
let i, groupStart, start, end, feature;
|
||||
let featureIndex = this.startIndices.length - 1;
|
||||
const hitDetectionTextures = this.getHitDetectionTextures();
|
||||
for (i = hitDetectionTextures.length - 1; i >= 0; --i) {
|
||||
@@ -415,9 +414,8 @@ class WebGLTextureReplay extends WebGLReplay {
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
if (skippedFeaturesHash[getUid(feature)] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
|
||||
@@ -138,7 +138,7 @@ class LayerRenderer extends Observable {
|
||||
* @param {import("../PluggableMap.js").FrameState} frameState Frame state.
|
||||
*/
|
||||
const postRenderFunction = function(tileSource, map, frameState) {
|
||||
const tileSourceKey = getUid(tileSource).toString();
|
||||
const tileSourceKey = getUid(tileSource);
|
||||
if (tileSourceKey in frameState.usedTiles) {
|
||||
tileSource.expireCache(frameState.viewState.projection,
|
||||
frameState.usedTiles[tileSourceKey]);
|
||||
@@ -160,7 +160,7 @@ class LayerRenderer extends Observable {
|
||||
*/
|
||||
updateUsedTiles(usedTiles, tileSource, z, tileRange) {
|
||||
// FIXME should we use tilesToDrawByZ instead?
|
||||
const tileSourceKey = getUid(tileSource).toString();
|
||||
const tileSourceKey = getUid(tileSource);
|
||||
const zKey = z.toString();
|
||||
if (tileSourceKey in usedTiles) {
|
||||
if (zKey in usedTiles[tileSourceKey]) {
|
||||
@@ -206,7 +206,7 @@ class LayerRenderer extends Observable {
|
||||
opt_tileCallback,
|
||||
opt_this
|
||||
) {
|
||||
const tileSourceKey = getUid(tileSource).toString();
|
||||
const tileSourceKey = getUid(tileSource);
|
||||
if (!(tileSourceKey in frameState.wantedTiles)) {
|
||||
frameState.wantedTiles[tileSourceKey] = {};
|
||||
}
|
||||
|
||||
@@ -123,9 +123,8 @@ class MapRenderer extends Disposable {
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function forEachFeatureAtCoordinate(feature, layer) {
|
||||
const key = getUid(feature).toString();
|
||||
const managed = frameState.layerStates[getUid(layer)].managed;
|
||||
if (!(key in frameState.skippedFeatureUids && !managed)) {
|
||||
if (!(getUid(feature) in frameState.skippedFeatureUids && !managed)) {
|
||||
return callback.call(thisArg, feature, managed ? layer : null);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +206,7 @@ class MapRenderer extends Disposable {
|
||||
* @return {import("./Layer.js").default} Layer renderer.
|
||||
*/
|
||||
getLayerRenderer(layer) {
|
||||
const layerKey = getUid(layer).toString();
|
||||
const layerKey = getUid(layer);
|
||||
if (layerKey in this.layerRenderers_) {
|
||||
return this.layerRenderers_[layerKey];
|
||||
} else {
|
||||
|
||||
@@ -244,7 +244,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
const key = getUid(feature).toString();
|
||||
const key = getUid(feature);
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
return callback.call(thisArg, feature, layer);
|
||||
|
||||
@@ -269,7 +269,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
const key = getUid(feature).toString();
|
||||
const key = getUid(feature);
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
return callback.call(thisArg, feature, layer);
|
||||
|
||||
@@ -38,7 +38,7 @@ const GEOMETRY_RENDERERS = {
|
||||
* @return {number} Order.
|
||||
*/
|
||||
export function defaultOrder(feature1, feature2) {
|
||||
return getUid(feature1) - getUid(feature2);
|
||||
return parseInt(getUid(feature1), 10) - parseInt(getUid(feature2), 10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
const key = getUid(feature).toString();
|
||||
const key = getUid(feature);
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
return callback.call(thisArg, feature, layer);
|
||||
|
||||
@@ -162,7 +162,7 @@ class Cluster extends VectorSource {
|
||||
|
||||
for (let i = 0, ii = features.length; i < ii; i++) {
|
||||
const feature = features[i];
|
||||
if (!(getUid(feature).toString() in clustered)) {
|
||||
if (!(getUid(feature) in clustered)) {
|
||||
const geometry = this.geometryFunction(feature);
|
||||
if (geometry) {
|
||||
const coordinates = geometry.getCoordinates();
|
||||
@@ -171,7 +171,7 @@ class Cluster extends VectorSource {
|
||||
|
||||
let neighbors = this.source.getFeaturesInExtent(extent);
|
||||
neighbors = neighbors.filter(function(neighbor) {
|
||||
const uid = getUid(neighbor).toString();
|
||||
const uid = getUid(neighbor);
|
||||
if (!(uid in clustered)) {
|
||||
clustered[uid] = true;
|
||||
return true;
|
||||
|
||||
@@ -192,7 +192,7 @@ class RasterSource extends ImageSource {
|
||||
const layerStatesArray = getLayerStatesArray(this.renderers_);
|
||||
|
||||
/**
|
||||
* @type {Object<number, import("../layer/Layer.js").State>}
|
||||
* @type {Object<string, import("../layer/Layer.js").State>}
|
||||
*/
|
||||
const layerStates = {};
|
||||
for (let i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||
|
||||
@@ -203,7 +203,7 @@ class TileImage extends UrlTile {
|
||||
if (this.tileGrid && (!thisProj || equivalent(thisProj, projection))) {
|
||||
return this.tileGrid;
|
||||
} else {
|
||||
const projKey = getUid(projection).toString();
|
||||
const projKey = getUid(projection);
|
||||
if (!(projKey in this.tileGridForProjection)) {
|
||||
this.tileGridForProjection[projKey] = getTileGridForProjection(projection);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ class TileImage extends UrlTile {
|
||||
const thisProj = this.getProjection(); if (!thisProj || equivalent(thisProj, projection)) {
|
||||
return this.tileCache;
|
||||
} else {
|
||||
const projKey = getUid(projection).toString();
|
||||
const projKey = getUid(projection);
|
||||
if (!(projKey in this.tileCacheForProjection)) {
|
||||
this.tileCacheForProjection[projKey] = new TileCache(this.tileCache.highWaterMark);
|
||||
}
|
||||
@@ -379,7 +379,7 @@ class TileImage extends UrlTile {
|
||||
if (ENABLE_RASTER_REPROJECTION) {
|
||||
const proj = getProjection(projection);
|
||||
if (proj) {
|
||||
const projKey = getUid(proj).toString();
|
||||
const projKey = getUid(proj);
|
||||
if (!(projKey in this.tileGridForProjection)) {
|
||||
this.tileGridForProjection[projKey] = tilegrid;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class UrlTile extends TileSource {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object<number, boolean>}
|
||||
* @type {!Object<string, boolean>}
|
||||
*/
|
||||
this.tileLoadingKeys_ = {};
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ class VectorSource extends Source {
|
||||
* @protected
|
||||
*/
|
||||
addFeatureInternal(feature) {
|
||||
const featureKey = getUid(feature).toString();
|
||||
const featureKey = getUid(feature);
|
||||
|
||||
if (!this.addToIndex_(featureKey, feature)) {
|
||||
return;
|
||||
@@ -383,7 +383,7 @@ class VectorSource extends Source {
|
||||
|
||||
for (let i = 0, length = features.length; i < length; i++) {
|
||||
const feature = features[i];
|
||||
const featureKey = getUid(feature).toString();
|
||||
const featureKey = getUid(feature);
|
||||
if (this.addToIndex_(featureKey, feature)) {
|
||||
newFeatures.push(feature);
|
||||
}
|
||||
@@ -391,7 +391,7 @@ class VectorSource extends Source {
|
||||
|
||||
for (let i = 0, length = newFeatures.length; i < length; i++) {
|
||||
const feature = newFeatures[i];
|
||||
const featureKey = getUid(feature).toString();
|
||||
const featureKey = getUid(feature);
|
||||
this.setupChangeEvents_(featureKey, feature);
|
||||
|
||||
const geometry = feature.getGeometry();
|
||||
@@ -799,7 +799,7 @@ class VectorSource extends Source {
|
||||
*/
|
||||
handleFeatureChange_(event) {
|
||||
const feature = /** @type {import("../Feature.js").default} */ (event.target);
|
||||
const featureKey = getUid(feature).toString();
|
||||
const featureKey = getUid(feature);
|
||||
const geometry = feature.getGeometry();
|
||||
if (!geometry) {
|
||||
if (!(featureKey in this.nullGeometryFeatures_)) {
|
||||
@@ -855,8 +855,7 @@ class VectorSource extends Source {
|
||||
if (id !== undefined) {
|
||||
return id in this.idIndex_;
|
||||
} else {
|
||||
const featureKey = getUid(feature).toString();
|
||||
return featureKey in this.undefIdIndex_;
|
||||
return getUid(feature) in this.undefIdIndex_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,7 +923,7 @@ class VectorSource extends Source {
|
||||
* @api
|
||||
*/
|
||||
removeFeature(feature) {
|
||||
const featureKey = getUid(feature).toString();
|
||||
const featureKey = getUid(feature);
|
||||
if (featureKey in this.nullGeometryFeatures_) {
|
||||
delete this.nullGeometryFeatures_[featureKey];
|
||||
} else {
|
||||
@@ -943,7 +942,7 @@ class VectorSource extends Source {
|
||||
* @protected
|
||||
*/
|
||||
removeFeatureInternal(feature) {
|
||||
const featureKey = getUid(feature).toString();
|
||||
const featureKey = getUid(feature);
|
||||
this.featureChangeKeys_[featureKey].forEach(unlistenByKey);
|
||||
delete this.featureChangeKeys_[featureKey];
|
||||
const id = feature.getId();
|
||||
|
||||
@@ -37,7 +37,7 @@ class RBush {
|
||||
* A mapping between the objects added to this rbush wrapper
|
||||
* and the objects that are actually added to the internal rbush.
|
||||
* @private
|
||||
* @type {Object<number, Entry>}
|
||||
* @type {Object<string, Entry>}
|
||||
*/
|
||||
this.items_ = {};
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class Fill {
|
||||
if (Array.isArray(color) || typeof color == 'string') {
|
||||
this.checksum_ = 'f' + asString(/** @type {import("../Color.js").Color|string} */ (color));
|
||||
} else {
|
||||
this.checksum_ = getUid(this.color_).toString();
|
||||
this.checksum_ = getUid(this.color_);
|
||||
}
|
||||
} else {
|
||||
this.checksum_ = 'f-';
|
||||
|
||||
@@ -149,7 +149,7 @@ class Icon extends ImageStyle {
|
||||
5); // `imgSize` must be set when `image` is provided
|
||||
|
||||
if ((src === undefined || src.length === 0) && image) {
|
||||
src = /** @type {HTMLImageElement} */ (image).src || getUid(image).toString();
|
||||
src = /** @type {HTMLImageElement} */ (image).src || getUid(image);
|
||||
}
|
||||
assert(src !== undefined && src.length > 0,
|
||||
6); // A defined and non-empty `src` or `image` must be provided
|
||||
|
||||
@@ -259,7 +259,7 @@ class Stroke {
|
||||
if (typeof this.color_ === 'string') {
|
||||
this.checksum_ += this.color_;
|
||||
} else {
|
||||
this.checksum_ += getUid(this.color_).toString();
|
||||
this.checksum_ += getUid(this.color_);
|
||||
}
|
||||
} else {
|
||||
this.checksum_ += '-';
|
||||
|
||||
@@ -43,11 +43,11 @@ let uidCounter_ = 0;
|
||||
* as a strictly increasing sequence. Adapted from goog.getUid.
|
||||
*
|
||||
* @param {Object} obj The object to get the unique ID for.
|
||||
* @return {number} The unique ID for the object.
|
||||
* @return {string} The unique ID for the object.
|
||||
* @api
|
||||
*/
|
||||
export function getUid(obj) {
|
||||
return obj.ol_uid || (obj.ol_uid = ++uidCounter_);
|
||||
return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,7 +112,7 @@ class WebGLContext extends Disposable {
|
||||
bindBuffer(target, buf) {
|
||||
const gl = this.getGL();
|
||||
const arr = buf.getArray();
|
||||
const bufferKey = String(getUid(buf));
|
||||
const bufferKey = getUid(buf);
|
||||
if (bufferKey in this.bufferCache_) {
|
||||
const bufferCacheEntry = this.bufferCache_[bufferKey];
|
||||
gl.bindBuffer(target, bufferCacheEntry.buffer);
|
||||
@@ -139,7 +139,7 @@ class WebGLContext extends Disposable {
|
||||
*/
|
||||
deleteBuffer(buf) {
|
||||
const gl = this.getGL();
|
||||
const bufferKey = String(getUid(buf));
|
||||
const bufferKey = getUid(buf);
|
||||
const bufferCacheEntry = this.bufferCache_[bufferKey];
|
||||
if (!gl.isContextLost()) {
|
||||
gl.deleteBuffer(bufferCacheEntry.buffer);
|
||||
@@ -204,7 +204,7 @@ class WebGLContext extends Disposable {
|
||||
* @return {WebGLShader} Shader.
|
||||
*/
|
||||
getShader(shaderObject) {
|
||||
const shaderKey = String(getUid(shaderObject));
|
||||
const shaderKey = getUid(shaderObject);
|
||||
if (shaderKey in this.shaderCache_) {
|
||||
return this.shaderCache_[shaderKey];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user