UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 2.66 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import has from"../../../../core/has.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{PooledRBush as r}from"../../../../core/libs/rbush/PooledRBush.js";import{fromRect as o}from"../../../../geometry/support/aaBoundingBox.js";import{getObjectId as a}from"../../../../layers/graphics/dehydratedFeatures.js";let d=class extends e{constructor(t){super(t),this._index=new r(9,has("esri-csp-restrictions")?t=>({minX:t.extent[0],minY:t.extent[1],maxX:t.extent[2],maxY:t.extent[3]}):[".extent[0]",".extent[1]",".extent[2]",".extent[3]"]),this._missing=new Set,this._boundsByFeature=new Map,this.spatialReference=null,this.hasZ=null,this.hasM=null,this.objectIdField=null,this.updating=!1}setup(t){this._addMany(t)}destroy(){this._missing.clear(),this._index=i(this._index),this._boundsByFeature.clear(),this._boundsByFeature=null}update(){this._missing.size>0&&(this._addMany(Array.from(this._missing.values())),this.updating=!1,this._missing.clear())}get updatingRemaining(){return this._missing.size}queryGraphicUIDsInExtent(t,e,i){null!=e&&e.equals(this.spatialReference)&&(h.minX=t[0],h.minY=t[1],h.maxX=t[2],h.maxY=t[3],this.update(),this._index.search(h,t=>i(t.graphic.uid)))}add(t){this._missing.add(t),this.updating=!0}remove(t){if(this._missing.delete(t))return void(this.updating=this._missing.size>0);if(!t.extent)return;this._index.remove(t);const e=a(t.graphic,this._get("objectIdField"));null!=e&&this._boundsByFeature.delete(e)}_addMany(t){if(0===t.length)return;const e=this._get("objectIdField");for(const i of t){i.computeExtent(this.spatialReference);const t=a(i.graphic,e);null!=t&&this._boundsByFeature.set(t,i.extent)}this._index.load(t)}clear(){this._index.clear(),this._missing.clear(),this._boundsByFeature.clear(),this.updating=!1}forEachInBounds(t,e){h.minX=t[0],h.minY=t[1],h.maxX=t[2],h.maxY=t[3],this.update(),this._index.search(h,t=>{e(t)})}getBounds(t,e){this.update();const i=this._boundsByFeature.get(t);return i?o(e,i):null}};t([s({constructOnly:!0})],d.prototype,"spatialReference",void 0),t([s({constructOnly:!0})],d.prototype,"hasZ",void 0),t([s({constructOnly:!0})],d.prototype,"hasM",void 0),t([s({constructOnly:!0})],d.prototype,"objectIdField",void 0),t([s()],d.prototype,"updating",void 0),t([s({readOnly:!0})],d.prototype,"updatingRemaining",null),d=t([n("esri.views.3d.layers.graphics.SpatialIndex2D")],d);const h={minX:0,minY:0,maxX:0,maxY:0};export{d as SpatialIndex2D};