@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 6.32 kB
JavaScript
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import i from"../../../../../core/Handles.js";import{isSome as s}from"../../../../../core/maybe.js";import{createDeferred as r,throwIfAborted as n}from"../../../../../core/promiseUtils.js";import{watch as a,whenOnce as o,sync as l}from"../../../../../core/reactiveUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../../../../../core/support/WatchUpdatingTracking.js";import c from"../../../../../geometry/SpatialReference.js";import h from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import g from"../../../../../layers/support/TileInfo.js";import m from"../../../../../rest/support/Query.js";import y from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as _}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as F}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as I}from"./FeatureServiceTileStore.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=r(),this._elevationAligner=_(),this._elevationFilter=S(),this._symbologyCandidatesFetcher=v(),this._handles=new i,this._updatingHandles=new u,this._editsUpdatingHandles=new u,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={points:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return n(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return n(t),s}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear(),this._handles?.destroy()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fields:n}=e.serviceInfo,{hasZ:o}=e,d=c.fromJSON(e.spatialReference);this._spatialReference=d,this._featureStore=new h({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new f({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fields:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:r}),this._featureFetcher=new F({store:new I({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:d,sourceSpatialReference:c.fromJSON(e.serviceInfo.spatialReference)});const p="3d"===e.configuration.viewType;return this._elevationAligner=_(p,{elevationInfo:s(e.elevationInfo)?y.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures,spatialReference:d}),this._elevationFilter=S(p),this._handles.add([a((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),l),a((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),{result:{}}}async fetchCandidates(e,t){await this._whenSetup.promise,n(t);const i=E(e),r=s(t)?t.signal:null,a=await this._queryEngine.executeQueryForSnapping(i,r);n(r);const o=await this._elevationAligner.alignCandidates(a.candidates,r);n(r);const l=await this._symbologyCandidatesFetcher.fetch(o,r);n(r);const d=0===l.length?o:o.concat(l);return{result:{candidates:this._elevationFilter.filter(i,d)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=s(e.tileInfo)?g.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),await o((()=>!this.updatingExcludingEdits),t),n(t),j}async getDebugInfo(e,t){return n(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),n(t);const i=r();return this._pendingApplyEdits.set(e.id,i),this._featureFetcher.applyEdits(i.promise),this._editsUpdatingHandles.addPromise(i.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),n(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=v(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=s(e.filter)?m.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([d({readOnly:!0})],w.prototype,"updating",null),e([d({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([d()],w.prototype,"_isInitializing",void 0),w=e([p("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const b=w;function E(e){return{point:e.point,mode:e.mode,distance:e.distance,types:e.types,query:s(e.filter)?e.filter:{where:"1=1"}}}const j={result:{}};export{b as default};