@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 7.47 kB
JavaScript
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Error.js";import{destroyMaybe as t,isNone as s,get as o}from"../../../core/maybe.js";import{initial as i,whenOnce as n}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{hydrateGraphic as p}from"../../../layers/graphics/hydratedFeatures.js";import{FeatureTileController3D as c}from"../../../layers/graphics/controllers/FeatureTileController3D.js";import u from"../../../rest/support/Query.js";import{symbolHasExtrudeSymbolLayer as h}from"../../../symbols/support/utils.js";import{elevationAlignPointsInFeatures as d}from"./graphics/elevationAlignPointsInFeatures.js";import y from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as g}from"./graphics/QueryEngine.js";import{queryForSymbologySnapping as m}from"./graphics/queryForSymbologySnapping.js";import{HeatmapFeatureProcessor as f}from"./support/HeatmapFeatureProcessor.js";import{toViewIfLocal as b}from"./support/projectExtentUtils.js";import{UpdatePolicy as E}from"../webgl-engine/lib/UpdatePolicy.js";import{TaskPriority as v}from"../../support/Scheduler.js";const w=w=>{let _=class extends w{constructor(){super(...arguments),this.controller=null,this.updatePolicy=E.SYNC,this.suspendResumeExtentMode="computed",this.slicePlaneEnabled=!1,this.fullExtentInLocalViewSpatialReference=null,this.suspendResumeExtent=null,this._controllerCreated=!1,this.supportsHeightUnitConversion=!0,this._pendingController=null,this.queryEngine=null}initialize(){const e=this.layer;if("isTable"in e&&e.isTable)return void this.addResolvingPromise(Promise.reject(new r("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e})));this.addResolvingPromise(this._validateGeometryType()),this.updatingHandles.add((()=>this.layer.renderer),(e=>this._recreateProcessor(e)),i),this.addResolvingPromise((async()=>{const e=await b(this);this.fullExtentInLocalViewSpatialReference=e,await this._initializeController()})()),this.updatingHandles.add((()=>this.updatePolicy),(e=>this.processor.preferredUpdatePolicy=e));const t=()=>this.processor.featureStore;this.queryEngine=new g({context:{spatialReference:this.view.spatialReference,layer:this.layer,scheduler:this.view.resourceController.scheduler,get featureStore(){return t()},hasZ:this.hasZ,hasM:this.hasM},priority:v.FEATURE_QUERY_ENGINE}),this.notifyChange("updating")}destroy(){this._destroyPendingController(),this.controller=t(this.controller),this._set("processor",t(this.processor)),this.queryEngine=t(this.queryEngine),this.loadedGraphics=null}_destroyPendingController(){this._pendingController=t(this._pendingController)}get legendEnabled(){return this.canResume()&&this.processor?.legendEnabled}get graphics3DProcessor(){return"graphics-3d"===this.processor?.type?this.processor:null}get heatmapProcessor(){return"heatmap"===this.processor?.type?this.processor:null}get symbologySnappingSupported(){const e=this.layer?.renderer?.getSymbols();return e?.some(h)??!1}getHit(e){let r;return this.loadedGraphics?.forEach((t=>{t.uid===e&&(r=p(t,this.layer))})),r?{type:"graphic",graphic:r,layer:r.layer}:null}whenGraphicBounds(e,r){return this.processor?.whenGraphicBounds(e,r)}computeAttachmentOrigin(e,r){return this.processor?.computeAttachmentOrigin(e,r)}async elevationAlignPointsInFeatures(e,t){const o=this.graphics3DProcessor;if(s(o))throw new r("featurelayerview3d:missing-processor","A Graphics3D processor is needed to resolve graphics elevation.");return d(this.view,this.layer,(e=>o.getGraphics3DGraphicByObjectId(e)),e,t)}async queryForSymbologySnapping(e,r){return this.symbologySnappingSupported?m(this.graphics3DProcessor,e,r):{candidates:[],sourceCandidateIndices:[]}}queryFeatures(e,r){return this.queryEngine.executeQuery(this._ensureQuery(e),o(r,"signal"))}queryObjectIds(e,r){return this.queryEngine.executeQueryForIds(this._ensureQuery(e),o(r,"signal"))}queryFeatureCount(e,r){return this.queryEngine.executeQueryForCount(this._ensureQuery(e),o(r,"signal"))}queryExtent(e,r){return this.queryEngine.executeQueryForExtent(this._ensureQuery(e),o(r,"signal"))}_ensureQuery(e){return s(e)?this.createQuery():u.from(e)}highlight(e){return this.processor.highlight(e,this.layer.objectIdField)}maskOccludee(e){return this.processor.maskOccludee(e)}canResume(){return super.canResume()&&!this.processor?.scaleVisibilitySuspended}getSuspendInfo(){const e=super.getSuspendInfo();return this.processor?{...e,...this.processor.suspendInfo}:e}isUpdating(){return!(!this.processor||this.processor.destroyed)&&!(this._controllerCreated&&!this.controller?.updating&&this.view?.basemapTerrain?.ready&&!this.processor.updating)}async _initializeController(){const e=this.createController();this._pendingController=e,await e.when(),this._setControllerWhenInitialized(e)}async _setControllerWhenInitialized(e){try{await this.when()}catch(r){}this._controllerCreated=!0,this.notifyChange("updating"),this.isResolved()&&!this.destroyed?(await n((()=>this.view?.basemapTerrain?.ready)),this.beforeSetController(e),this._pendingController=null,this.controller=e,this.loadedGraphics=e.graphics,this.notifyChange("updating")):this._destroyPendingController()}_updateClippingExtent(e){if(this.clippingExtent=e,!this.controller)return!1;switch(this.controller.type){case"stream":return!1;case"feature-tile-3d":return this.controller.extent=e,!0}}async _validateGeometryType(){switch(this.layer.geometryType){case"multipatch":case"multipoint":throw new r("featurelayerview3d:unsupported-geometry-type","Unsupported geometry type ${geometryType}",{geometryType:this.layer.geometryType})}}_recreateProcessor(e){const r="heatmap"===e?.type,t="heatmap"===this.processor?.type,s=this.processor;if(s&&r===t)return;const o=r?new f({owner:this}):new y({owner:this,frustumVisibilityEnabled:!0,scaleVisibilityEnabled:!0,filterVisibilityEnabled:!0,timeExtentEnabled:!0,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!0,preferredUpdatePolicy:this.updatePolicy,updateClippingExtent:e=>this._updateClippingExtent(e)});this._set("processor",o),s?.destroy(),this.queryEngine?.clear(),this.addResolvingPromise(o.initializePromise)}_getResourceInfo(){const e=this.controller instanceof c?this.controller:null;return{displayedNumberOfFeatures:this.loadedGraphics.length,maximumNumberOfFeatures:e?.maximumNumberOfFeatures??-1,totalNumberOfFeatures:e?.serviceDataCount??-1,nodes:0,...this.processor.performanceInfo}}get performanceInfo(){return this._getResourceInfo()}};return e([a()],_.prototype,"loadedGraphics",void 0),e([a()],_.prototype,"suspended",void 0),e([a({readOnly:!0})],_.prototype,"legendEnabled",null),e([a()],_.prototype,"updating",void 0),e([a()],_.prototype,"controller",void 0),e([a()],_.prototype,"processor",void 0),e([a({readOnly:!0})],_.prototype,"updatePolicy",void 0),e([a({readOnly:!0})],_.prototype,"suspendResumeExtentMode",void 0),e([a({type:Boolean})],_.prototype,"slicePlaneEnabled",void 0),e([a({readOnly:!0})],_.prototype,"suspendInfo",void 0),e([a()],_.prototype,"graphics3DProcessor",null),e([a()],_.prototype,"heatmapProcessor",null),e([a()],_.prototype,"symbologySnappingSupported",null),_=e([l("esri.views.3d.layers.FeatureLikeLayerView3D")],_),_};export{w as FeatureLikeLayerView3D};