Change getUid return type from number to string

This commit is contained in:
Frederic Junod
2018-10-17 08:58:50 +02:00
parent a85099a36b
commit 041836c645
33 changed files with 78 additions and 92 deletions

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -84,7 +84,7 @@ class UrlTile extends TileSource {
/**
* @private
* @type {!Object<number, boolean>}
* @type {!Object<string, boolean>}
*/
this.tileLoadingKeys_ = {};

View File

@@ -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();