UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 4.28 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import e from"../../../../Color.js";import t from"../../../../Graphic.js";import i from"../../../../core/Collection.js";import s from"../../../../core/Handles.js";import{watch as o,initial as r}from"../../../../core/reactiveUtils.js";import a from"../../../../geometry/Polygon.js";import l from"../../../../symbols/FillSymbol3DLayer.js";import n from"../../../../symbols/PointSymbol3D.js";import h from"../../../../symbols/PolygonSymbol3D.js";import c from"../../../../symbols/TextSymbol3DLayer.js";import m from"../../../../symbols/callouts/LineCallout3D.js";import d from"../../../../symbols/callouts/LineCallout3DBorder.js";import p from"../../../../symbols/support/Symbol3DVerticalOffset.js";import{TilingScheme as y}from"../../terrain/TilingScheme.js";const _=[[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 b{constructor(e,t,o){this._tileFetcher=e,this._view=o,this._handles=new s,this._loadingGraphics=new Map,this._loadingSymbols=[new h({symbolLayers:new i([new l({material:{color:[200,200,200,.4]},outline:{color:[30,30,30],size:1}})])})],this._loadedGraphics=new Map,this._loadedSymbols=_.map((e=>new h({symbolLayers:new i([new l({material:{color:[e[0],e[1],e[2],.6]},outline:{color:"black",size:1}})])}))),this._pendingGraphics=new Map,this._pendingSymbols=[new h({symbolLayers:new i([new l({material:{color:[100,100,100,.4]},outline:{color:[30,30,30],size:1}})])})],this._dataExtentGraphic=null,this._dataExtentSymbol=new h({symbolLayers:new i([new l({material:{color:[0,0,0,0]},outline:{color:"green",size:4}})])}),this._enabled=!0,this._tilingScheme=new y(t),this.update()}destroy(){this.enabled=!1,this._handles.destroy()}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.update()}update(){this._enabled?(this._synchronizeMaps(this._loadingGraphics,{filter:({isFetching:e})=>e,symbols:this._loadingSymbols}),this._synchronizeMaps(this._loadedGraphics,{filter:e=>!e.isFetching,symbols:this._loadedSymbols}),this._synchronizeMaps(this._pendingGraphics,{filter:({isFetching:e})=>!e,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=a.fromExtent(e);this._dataExtentGraphic=new t({geometry:i,symbol:this._dataExtentSymbol}),this._view.graphics.add(this._dataExtentGraphic)}_synchronizeMaps(e,t){const i=this._tileFetcher.featureTiles;e.forEach(((s,o)=>{const r=i.get(o);r&&t.filter(r)||(this._view.graphics.removeMany(s),e.delete(o))})),this._handles.removeAll(),i.forEach((i=>{t.filter(i)&&!e.has(i.id)&&this._handles.add(o((()=>i.fetchInformation),(()=>this._showTile(i,e,t)),r))}))}_showTile(s,o,r){const[a,l,h]=s.descriptor.lij,{numFeatures:y,featureLimit:_,features:b}=s;this._tilingScheme.ensureMaxLod(a);const g=this._tilingScheme.getExtentGeometry(a,l,h),w=new t({geometry:g,symbol:r.symbols[a%r.symbols.length]}),f=`Tile ${s.id}\nloaded/limit/total\n${b?.length}/${_}/${y}\nres ${Math.round(s.displayingResolution)} ${s.featuresMissing?"some":"all"}\n${s.fetchInformation.value}`,u=new t({geometry:g.center,symbol:new n({verticalOffset:new p({screenLength:40/.75}),callout:new m({color:new e("white"),border:new d({color:new e("black")})}),symbolLayers:new i([new c({text:f,halo:{color:"white",size:1/.75},material:{color:"black"},size:16})])})}),G=o.get(s.id);G&&this._view.graphics.removeMany(G);const v=[w,u];o.set(s.id,v),this._view.graphics.addMany(v)}}export{b as FeatureTileFetcher3DDebugger};