@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.37 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{__decorate as e}from"tslib";import s from"../../Color.js";import o from"../../Graphic.js";import t from"../../core/Accessor.js";import l from"../../core/Collection.js";import{lerp as r}from"../../core/mathUtils.js";import{property as i,subclass as n}from"../../core/accessorSupport/decorators.js";import a from"../../symbols/PointSymbol3D.js";import h from"../../symbols/SimpleFillSymbol.js";import m from"../../symbols/TextSymbol.js";import y from"../../symbols/TextSymbol3DLayer.js";import p from"../../symbols/callouts/LineCallout3D.js";import b from"../../symbols/callouts/LineCallout3DBorder.js";import c from"../../symbols/support/Symbol3DVerticalOffset.js";const u=[[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]];let g=class extends t{constructor(e){super(e),this.updating=!1,this.enablePolygons=!0,this.enableLabels=!0,this._polygons=new Map,this._labels=new Map,this._symbols=u.map(e=>new h({color:[e[0],e[1],e[2],.6],outline:{color:"black",width:1}})),this._enabled=!0}initialize(){this.update()}destroy(){this._enabled=!1,this.clear()}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this.update())}getLabel(e){if(null!=e.label)return e.label;let s=e.lij.toString();return null!=e.loadPriority&&(s+=` (${e.loadPriority})`),e.measures&&(s+=`[${e.measures.lodLevel}]`),s}update(){if(!this._enabled)return void this.clear();const e=this.getTiles(),t=new Array,i=new Set(this._labels.size>0?this._labels.keys():this._polygons.keys());e.forEach((n,h)=>{const u=n.lij.toString();i.delete(u);const g=n.measures?.lodLevel??n.level,d=n.geometry;if(this.enablePolygons&&!this._polygons.has(u)){const e=n.polygonSymbol??this._symbols[g%this._symbols.length],s=new o({geometry:d,symbol:e});this._polygons.set(u,s),t.push(s)}if(this.enableLabels){const i=this.getLabel(n),g=h/(e.length-1),f=r(0,200,g),w=r(20,6,g)/.75,_=null!=n.loadPriority&&n.loadPriority>=e.length,v=new s([f,_?0:f,_?0:f]),j="3d"===this.view.type?()=>new a({verticalOffset:new c({screenLength:40/.75}),callout:new p({color:new s("white"),border:new b({color:new s("black")})}),symbolLayers:new l([new y({text:i,halo:{color:"white",size:1/.75},material:{color:v},size:w})])}):()=>new m({text:i,haloColor:"white",haloSize:1/.75,color:v,size:w}),S=this._labels.get(u);if(S){const e=j();null!=S.symbol&&JSON.stringify(e)===JSON.stringify(S.symbol)||(S.symbol=e)}else{const e=new o({geometry:d.extent.center,symbol:j()});this._labels.set(u,e),t.push(e)}}});const n=new Array;i.forEach(e=>{const s=this._polygons.get(e);null!=s&&(n.push(s),this._polygons.delete(e));const o=this._labels.get(e);null!=o&&(n.push(o),this._labels.delete(e))}),this.view.graphics.removeMany(n),this.view.graphics.addMany(t)}clear(){this.view.graphics.removeMany(Array.from(this._polygons.values())),this.view.graphics.removeMany(Array.from(this._labels.values())),this._polygons.clear(),this._labels.clear()}};e([i({constructOnly:!0})],g.prototype,"view",void 0),e([i({readOnly:!0})],g.prototype,"updating",void 0),e([i()],g.prototype,"enabled",null),g=e([n("esri.views.support.TileTreeDebugger")],g);export{g as TileTreeDebugger};