@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.29 kB
JavaScript
import e from"../../../../Graphic.js";import{isNone as t}from"../../../../core/maybe.js";import i from"../../../../geometry/Polygon.js";import s from"../../../../symbols/FillSymbol3DLayer.js";import a from"../../../../symbols/PointSymbol3D.js";import o from"../../../../symbols/PolygonSymbol3D.js";import r from"../../../../symbols/TextSymbol3DLayer.js";import{TilingScheme as h}from"../../terrain/TilingScheme.js";const l=[[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 n{constructor(e,t,i){this._loadingGraphics=new Map,this._loadedGraphics=new Map,this._pendingGraphics=new Map,this._dataExtentGraphic=null,this._enabled=!0,this._tileFetcher=e,this._view=i,this._tilingScheme=new h(t),this._loadedSymbols=l.map((e=>new o(new s({material:{color:[e[0],e[1],e[2],.6]},outline:{color:"black",size:1}})))),this._loadingSymbols=[new o(new s({material:{color:[200,200,200,.4]},outline:{color:[30,30,30],size:1}}))],this._pendingSymbols=[new o(new s({material:{color:[100,100,100,.4]},outline:{color:[30,30,30],size:1}}))],this._dataExtentSymbol=new o(new s({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(s){if(this._dataExtentGraphic&&(this._view.graphics.remove(this._dataExtentGraphic),this._dataExtentGraphic=null),t(s))return;const a=i.fromExtent(s);this._dataExtentGraphic=new e({geometry:a,symbol:this._dataExtentSymbol}),this._view.graphics.add(this._dataExtentGraphic)}_synchronizeMaps(t,i){const s=[];t.forEach(((e,t)=>{const a=this._tileFetcher.test.getFeatureTileById(t);a&&i.filter(a)||(this._view.graphics.removeMany(e),s.push(t))})),s.forEach((e=>t.delete(e))),this._tileFetcher.test.forEachFeatureTile((s=>{if(i.filter(s)&&!t.has(s.id)){const[o,h,l]=s.descriptor.lij;this._tilingScheme.ensureMaxLod(o);const n=this._tilingScheme.getExtentGeometry(o,h,l),c=[new e({geometry:n,symbol:i.symbols[o%i.symbols.length]}),new e({geometry:n.center,symbol:new a({verticalOffset:{screenLength:40/.75},callout:{type:"line",color:"white",border:{color:"black"}},symbolLayers:[new r({text:`${o}/${h}/${l}`,halo:{color:"white",size:1/.75},material:{color:"black"},size:16})]})})];t.set(s.id,c),this._view.graphics.addMany(c)}}))}}export{n as FeatureTileFetcher3DDebugger};