@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 5.41 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import r from"../../../core/Collection.js";import t from"../../../core/CollectionFlattener.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{initial as i,when as s,watch as a}from"../../../core/reactiveUtils.js";import{property as n,subclass as p}from"../../../core/accessorSupport/decorators.js";import{projectAsync as l}from"../../../geometry/projectionUtils.js";import c from"../../../rest/support/DirectionLine.js";import h from"../../../rest/support/DirectionPoint.js";import u from"../../../rest/support/PointBarrier.js";import d from"../../../rest/support/PolygonBarrier.js";import m from"../../../rest/support/PolylineBarrier.js";import y from"../../../rest/support/RouteInfo.js";import g from"../../../rest/support/Stop.js";import{LayerView3D as f}from"./LayerView3D.js";import{GraphicsProcessor as w}from"./graphics/GraphicsProcessor.js";import{LayerViewPerformanceInfo as v}from"./support/LayerViewPerformanceInfo.js";import{EventedSet as _}from"../support/EventedSet.js";import G from"../../layers/LayerView.js";import{getHighlightName as j}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as b,isInEffectiveScaleRange as V}from"../../support/layerViewUtils.js";function S(e){return e instanceof c||e instanceof h||e instanceof u||e instanceof d||e instanceof m||e instanceof y||e instanceof g}let I=class extends(f(G)){constructor(){super(...arguments),this.type="route-3d",this.loadedGraphics=new _,this._networkFeatureToGraphic=new Map,this._graphicToNetworkFeature=new Map,this.slicePlaneEnabled=!1,this.fullExtentInLocalViewSpatialReference=null}initialize(){this._set("processor",new w({owner:this,scaleVisibilityEnabled:!0,frustumVisibilityEnabled:!0})),this.addResolvingPromise(this.processor.initializePromise),this._updatingHandles.addOnCollectionChange(()=>this._routeItems,e=>this._routeItemsChanged(e),i),"local"===this.view.viewingMode&&this.addResolvingPromise((async()=>this.fullExtentInLocalViewSpatialReference=await l(this.layer.fullExtent,this.view.spatialReference).catch(()=>null))()),this.addHandles(s(()=>this.view?.groundView?.ready,()=>()=>this.notifyChange("updating"),{once:!0}))}destroy(){this._updatingHandles.removeAll(),this._networkFeatureToGraphic.clear(),this._graphicToNetworkFeature.clear(),this._set("processor",o(this.processor)),this._get("_routeItems")?.destroy()}get _routeItems(){return new t({getCollections:()=>[this.layer.pointBarriers,this.layer.polygonBarriers,this.layer.polylineBarriers,this.layer.stops,this.layer.directionLines,this.layer.directionPoints,null!=this.layer.routeInfo?new r([this.layer.routeInfo]):null]})}_routeItemsChanged(e){if(e.removed.length){this.loadedGraphics.removeMany(e.removed.map(e=>{const r=this._networkFeatureToGraphic.get(e);return this._networkFeatureToGraphic.delete(e),this._graphicToNetworkFeature.delete(r),r}));for(const r of e.removed)this.removeHandles(r)}if(e.added.length){this.loadedGraphics.addMany(e.added.map(e=>{const r=e.toGraphic();return this._networkFeatureToGraphic.set(e,r),this._graphicToNetworkFeature.set(r,e),r}));for(const r of e.added)this.addHandles([a(()=>r.geometry,(e,t)=>{this._updateGraphic(r,"geometry",e,t)}),a(()=>r.symbol,(e,t)=>{this._updateGraphic(r,"symbol",e,t)})],r)}}get legendEnabled(){return this.canResume()&&!this.processor?.frustumVisibilitySuspended}get visibleAtCurrentScale(){return b()?V(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}getSuspendInfo(){const e=super.getSuspendInfo();return e.outsideOfView=this.processor?.frustumVisibilitySuspended??!1,e}getHit(e){const r=this.processor.getHit(e,null);if("graphic"===r?.type){const e=this._graphicToNetworkFeature.get(r.graphic);if(e)return{type:"route",layer:this.layer,networkFeature:e}}return null}whenGraphicBounds(e,r){return this.processor.whenGraphicBounds(e,r)}computeAttachmentOrigin(e,r){return this.processor?.computeAttachmentOrigin(e,r)}getSymbolLayerSize(e,r){return this.processor.getSymbolLayerSize(e,r)}async queryGraphics(){return new r(this.loadedGraphics.toArray())}maskOccludee(e){return this.processor.maskOccludee(e)}highlight(e,r){return S(e)&&(e=this._networkFeatureToGraphic.get(e)),this.processor.highlight(e,j(r))}notifyContentGeometryUpdate(){this.emit("visible-geometry-changed")}get updatePolicy(){return this.processor?.graphicsCore.effectiveUpdatePolicy||1}isUpdating(){return!(!this.processor?.updating&&this.view?.groundView?.ready)}get performanceInfo(){return new v(this.processor?.graphicsCore.usedMemory??0,this.loadedGraphics.length,-1,-1,0,this.processor?.graphicsCore.performanceInfo??null)}_updateGraphic(e,r,t,o){const i=this._networkFeatureToGraphic.get(e);i[r]=t,k.graphic=i,k.property=r,k.oldValue=o,k.newValue=t,this.processor?.graphicsCore.graphicUpdateHandler(k),k.graphic=null}};e([n()],I.prototype,"_routeItems",null),e([n()],I.prototype,"loadedGraphics",void 0),e([n({readOnly:!0})],I.prototype,"legendEnabled",null),e([n({readOnly:!0})],I.prototype,"visibleAtCurrentScale",null),e([n()],I.prototype,"layer",void 0),e([n({readOnly:!0})],I.prototype,"processor",void 0),e([n({type:Boolean})],I.prototype,"slicePlaneEnabled",void 0),I=e([p("esri.views.3d.layers.RouteLayerView3D")],I);const k={graphic:null,property:null,oldValue:null,newValue:null},C=I;export{C as default};