UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.79 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import e from"../../../../Color.js";import t from"../../../../Graphic.js";import i from"../../../../core/Collection.js";import s from"../../../../geometry/Polygon.js";import o from"../../../../symbols/FillSymbol3DLayer.js";import r from"../../../../symbols/PointSymbol3D.js";import a from"../../../../symbols/PolygonSymbol3D.js";import l from"../../../../symbols/TextSymbol3DLayer.js";import n from"../../../../symbols/callouts/LineCallout3D.js";import h from"../../../../symbols/callouts/LineCallout3DBorder.js";import c from"../../../../symbols/support/Symbol3DVerticalOffset.js";import{TilingScheme as m}from"../../terrain/TilingScheme.js";const p=[[0,179,255],[117,62,128],[0,104,255],[215,189,166],[32,0,193],[98,162,206],[102,112,129],[52,125,0],[142,118,246],[138,83,0],[92,122,255],[122,55,83],[0,142,255],[81,40,179],[0,200,244],[13,24,127],[0,170,147],[19,58,241],[22,44,35]];class y{constructor(e,t,s){this._loadingGraphics=new Map,this._loadedGraphics=new Map,this._pendingGraphics=new Map,this._dataExtentGraphic=null,this._enabled=!0,this._tileFetcher=e,this._view=s,this._tilingScheme=new m(t),this._loadedSymbols=p.map((e=>new a({symbolLayers:new i([new o({material:{color:[e[0],e[1],e[2],.6]},outline:{color:"black",size:1}})])}))),this._loadingSymbols=[new a({symbolLayers:new i([new o({material:{color:[200,200,200,.4]},outline:{color:[30,30,30],size:1}})])})],this._pendingSymbols=[new a({symbolLayers:new i([new o({material:{color:[100,100,100,.4]},outline:{color:[30,30,30],size:1}})])})],this._dataExtentSymbol=new a({symbolLayers:new i([new o({material:{color:[0,0,0,0]},outline:{color:"green",size:4}})])})}destroy(){this.enabled=!1}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.update()}update(){this._enabled?(this._synchronizeMaps(this._loadingGraphics,{filter:e=>e.isFetching,symbols:this._loadingSymbols}),this._synchronizeMaps(this._loadedGraphics,{filter:e=>!e.isFetching,symbols:this._loadedSymbols}),this._synchronizeMaps(this._pendingGraphics,{filter:e=>!e.isFetching,symbols:this._pendingSymbols}),this.showDataExtent(this._tileFetcher.filterExtent)):(this._loadingGraphics.forEach((e=>{this._view.graphics.removeMany(e)})),this._loadingGraphics.clear(),this._loadedGraphics.forEach((e=>{this._view.graphics.removeMany(e)})),this._loadedGraphics.clear(),this._pendingGraphics.forEach((e=>{this._view.graphics.removeMany(e)})),this._pendingGraphics.clear(),this._dataExtentGraphic&&(this._view.graphics.remove(this._dataExtentGraphic),this._dataExtentGraphic=null))}showDataExtent(e){if(this._dataExtentGraphic&&(this._view.graphics.remove(this._dataExtentGraphic),this._dataExtentGraphic=null),null==e)return;const i=s.fromExtent(e);this._dataExtentGraphic=new t({geometry:i,symbol:this._dataExtentSymbol}),this._view.graphics.add(this._dataExtentGraphic)}_synchronizeMaps(s,o){const a=[];s.forEach(((e,t)=>{const i=this._tileFetcher.test.getFeatureTileById(t);i&&o.filter(i)||(this._view.graphics.removeMany(e),a.push(t))})),a.forEach((e=>s.delete(e))),this._tileFetcher.test.forEachFeatureTile((a=>{if(o.filter(a)&&!s.has(a.id)){const[m,p,y]=a.descriptor.lij;this._tilingScheme.ensureMaxLod(m);const d=this._tilingScheme.getExtentGeometry(m,p,y),_=[new t({geometry:d,symbol:o.symbols[m%o.symbols.length]}),new t({geometry:d.center,symbol:new r({verticalOffset:new c({screenLength:40/.75}),callout:new n({color:new e("white"),border:new h({color:new e("black")})}),symbolLayers:new i([new l({text:`${m}/${p}/${y}`,halo:{color:"white",size:1/.75},material:{color:"black"},size:16})])})})];s.set(a.id,_),this._view.graphics.addMany(_)}}))}}export{y as FeatureTileFetcher3DDebugger};