UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 3.97 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as i,toNullable as r,unwrap as o}from"../../../../core/maybe.js";import{throwIfAborted as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{watch as s,initial as p,on as l}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 c}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as g}from"../../../../support/elevationInfoUtils.js";import{makeFilter as u,makeSnappingQuery as h}from"../snappingUtils.js";import{convertSnappingCandidate as m,makeGetGroundElevation as d}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as v}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as f}from"./symbologySnappingCandidates.js";let w=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,r=i(e)&&"3d"===e.type;if(!r||"subtype-group"===t.type)return v();const o=async(i,r)=>(await a(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return v(r,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=i(e)&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return S(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return i(e)&&"3d"===e.type&&"subtype-group"!==t.type?f(this._symbologySnappingSupported,(async(i,r)=>{const o=await e.whenLayerView(t);return n(r),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},r)})):f()}get _symbologySnappingSupported(){return i(this._layerView3D)&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;i(e)&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;g(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),s((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),p),s((()=>i(this._layerView3D)?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),p),l((()=>r(this._layerView3D)?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,r=i.source;if(!r?.querySnapping)return[];const a=u(i),s=h(e,o(this.view)?.type??"2d",a),p=await r.querySnapping(s,{signal:t});n(t);const l=await this._snappingElevationAligner.alignCandidates(p.candidates,t);n(t);const y=await this._symbologySnappingFetcher.fetch(l,t);n(t);const c=0===y.length?l:[...l,...y],g=this._snappingElevationFilter.filter(s,c),d=this._getGroundElevation;return g.map((e=>m(e,d)))}get _getGroundElevation(){return d(this.view)}};e([y({constructOnly:!0})],w.prototype,"layerSource",void 0),e([y({constructOnly:!0})],w.prototype,"view",void 0),e([y()],w.prototype,"_snappingElevationAligner",null),e([y()],w.prototype,"_snappingElevationFilter",null),e([y()],w.prototype,"_symbologySnappingFetcher",null),e([y()],w.prototype,"_layerView3D",void 0),e([y()],w.prototype,"_symbologySnappingSupported",null),e([y()],w.prototype,"_getGroundElevation",null),w=e([c("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],w);export{w as FeatureCollectionSnappingSource};