UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 5.14 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{HandleOwnerMixin as r}from"../../../../core/HandleOwner.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{isSome as s,applySome as o,mapOr as a,toNullable as n}from"../../../../core/maybe.js";import{throwIfAborted as l,ignoreAbortErrors as u}from"../../../../core/promiseUtils.js";import{watch as p,on as c,initial as d,sync as h}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as g}from"../../../../core/accessorSupport/decorators/subclass.js";import{ObservableValue as f}from"../../../../core/accessorSupport/tracking/ObservableValue.js";import{elevationContextAffectsAlignment as m}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as S}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as _}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{convertSnappingCandidate as v,makeGetGroundElevation as w}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as b}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as I}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as j}from"./featureServiceSource/FeatureServiceTilesSimple.js";import O from"../../../support/debugFlags.js";let T=class extends(r(t)){get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get updating(){return this._workerHandle?.updating||this.updatingHandles.updating}get configuration(){const{view:e}=this,t=s(e)?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._workerHandle=null,this._debug=null}initialize(){let e;const t=this.view;if(s(t))switch(t.type){case"2d":this._tilesOfInterest=new S({view:t,layer:this._layer}),e=this._workerHandle=new I;break;case"3d":{const{resourceController:r}=t,i=this._layer,s=t.whenLayerView(i);this._tilesOfInterest=new _({view:t}),e=this._workerHandle=new I({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,t)=>{const r=await s;return l(t),r.elevationAlignPointsInFeatures(e,t)},queryForSymbologySnapping:async(e,t)=>{const r=await s;return l(t),r.queryForSymbologySnapping(e,t)}});const h=new f(null);s.then((e=>h.set(e))),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;m(t,r)&&u(e.notifyElevationSourceChange())})),p((()=>i.elevationInfo),(()=>u(e.notifyElevationSourceChange())),d),p((()=>o(h.get(),(({processor:e})=>e?.renderer))),(()=>u(e.notifySymbologyChange())),d),p((()=>a(h.get(),!1,(e=>e.symbologySnappingSupported))),(t=>u(e.setSymbologySnappingSupported(t))),d),c((()=>n(h.get())?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new j({layer:this._layer}),e=this._workerHandle=new I;this.handles.add([i(e)]),u(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this.updatingHandles.add((()=>this._updateTilesParameters),(()=>u(e.updateTiles(this._updateTilesParameters,null))),d),this.handles.add([p((()=>this.configuration),(t=>u(e.configure(t,null))),h)]),s(t)&&this.handles.add(p((()=>O.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new b({view:t,handle:e}),this.handles.add(i(this._debug),"debug")):!r&&this._debug&&this.handles.remove("debug")}),d)),this.handles.add(this.layerSource.layer.on("apply-edits",(t=>{u(e.applyEdits(t,null))})))}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._getGroundElevation;return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>v(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}get _getGroundElevation(){return w(this.view)}};e([y({constructOnly:!0})],T.prototype,"spatialReference",void 0),e([y({constructOnly:!0})],T.prototype,"layerSource",void 0),e([y({constructOnly:!0})],T.prototype,"view",void 0),e([y()],T.prototype,"_tilesOfInterest",void 0),e([y({readOnly:!0})],T.prototype,"_updateTilesParameters",null),e([y({readOnly:!0})],T.prototype,"updating",null),e([y({readOnly:!0})],T.prototype,"configuration",null),e([y({readOnly:!0})],T.prototype,"availability",null),e([y()],T.prototype,"_getGroundElevation",null),T=e([g("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],T);export{T as FeatureServiceSnappingSource};