You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
3.4 KiB
10 lines
3.4 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define(["exports","../../../core/CircularArray","../../../core/mathUtils"],function(g,h,k){class l{constructor(a,b,c,d,e=128){this._trackIdToObservations=new Map;this._idCounter=0;this._lastPurge=performance.now();this._addOrUpdated=new Map;this._removed=[];this._maxAge=0;this._timeInfo=c;this._purgeOptions=d;this.store=a;this.objectIdField=b;this.purgeInterval=e;this._useGeneratedIds="__esri_stream_id__"===this.objectIdField}removeById(a){this._removed.push(a)}removeByTrackId(a){if(a=this._trackIdToObservations.get(a))for(const b of a.entries)this._removed.push(b)}add(a){if(this._useGeneratedIds){var b= |
|
this._nextId();a.attributes[this.objectIdField]=b;a.objectId=b}else a.objectId=a.attributes[this.objectIdField];b=a.objectId;this._addOrUpdated.set(b,a);this._maxAge=Math.max(this._maxAge,a.attributes[this._timeInfo.startTimeField]);if(this._timeInfo.trackIdField){a=a.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(a)){const c=k.clamp(null!=this._purgeOptions?.maxObservations?this._purgeOptions.maxObservations:1E3,0,1E3);this._trackIdToObservations.set(a,new h(c))}b=this._trackIdToObservations.get(a)?.enqueue(b); |
|
null!=b&&(this._addOrUpdated.has(b)?this._addOrUpdated.delete(b):this._removed.push(b))}else null==this._trackIdLessObservations&&(this._trackIdLessObservations=new h(1E5)),this._trackIdLessObservations.enqueue(b)}checkForUpdates(){const a=this._getToAdd();var b=this._getToRemove();const c=performance.now();c-this._lastPurge>=this.purgeInterval&&(this._purge(c),this._lastPurge=c);const d=[];if(null!=b)for(var e of b){const f=this.store.removeById(e);null!=f&&d.push(f)}e=[];if(null!=a){b=new Set(b?? |
|
[]);for(const f of a)b.has(f.objectId)||(f.attributes.__esri_timestamp__=c,this.store.add(f),e.push(f))}return e.length||d?.length?(this.store.update(e,d),!0):!1}_getToAdd(){if(!this._addOrUpdated.size)return null;const a=Array(this._addOrUpdated.size);let b=0;this._addOrUpdated.forEach(c=>a[b++]=c);this._addOrUpdated.clear();return a}_getToRemove(){const a=this._removed;if(!this._removed.length)return null;this._removed=[];return a}_nextId(){const a=this._idCounter;this._idCounter=(this._idCounter+ |
|
1)%4294967294+1;return a}_purge(a){const b=this._purgeOptions;null!=b&&(this._purgeSomeByDisplayCount(b),this._purgeByAge(b),this._purgeByAgeReceived(a,b),this._purgeTracks())}_purgeSomeByDisplayCount(a){if(a.displayCount){var b=this.store.size;if(b>a.displayCount){if(this._timeInfo.trackIdField)for(const c of this._trackIdToObservations.values())if(b>a.displayCount&&c.size){const d=c.dequeue();this._removed.push(d);b--}if(null!=this._trackIdLessObservations)for(a=b-a.displayCount;0<a--;)b=this._trackIdLessObservations.dequeue(), |
|
null!=b&&this._removed.push(b)}}}_purgeByAge(a){const b=this._timeInfo?.startTimeField;if(a.age&&b){var c=this._maxAge-6E4*a.age;this.store.forEach(d=>{d.attributes[b]<c&&this._removed.push(d.objectId)})}}_purgeByAgeReceived(a,b){if(b.ageReceived){var c=a-6E4*b.ageReceived;this.store.forEach(d=>{d.attributes.__esri_timestamp__<c&&this._removed.push(d.objectId)})}}_purgeTracks(){this._trackIdToObservations.forEach((a,b)=>{0===a.size&&this._trackIdToObservations.delete(b)})}}g.StreamFeatureManager= |
|
l;g.defaultStreamIdField="__esri_stream_id__";g.esriTimestamp="__esri_timestamp__";Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}); |