UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 4.15 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as n,whenOrAbort as r}from"../../../../core/promiseUtils.js";import{watch as o,initial as a,on as l}from"../../../../core/reactiveUtils.js";import{sqlAnd as s}from"../../../../core/sql.js";import{property as p,subclass as y}from"../../../../core/accessorSupport/decorators.js";import{elevationContextAffectsAlignment as u}from"../../../../support/elevationInfoUtils.js";import{makeSnappingQuery as c}from"../snappingUtils.js";import{makeGetGroundElevation as g,convertSnappingCandidate as h}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as m}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as d}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"./symbologySnappingCandidates.js";let f=class extends t{get availability(){return 1}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return m();const n=async(i,n)=>(await r(e.whenLayerView(t),n)).elevationAlignPointsInFeatures(i,n);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:n})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?v(this._symbologySnappingSupported,async(i,r)=>{const o=await e.whenLayerView(t);return n(r),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},r)}):v()}get _layerView(){const{view:e}=this;if(null==e)return null;const{layer:t}=this.layerSource;return e.allLayerViews.find(e=>e.layer===t)}get _layerView3D(){const{view:e}=this;return null==e||"2d"===e.type?null:this._layerView}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",({context:e})=>{const{elevationInfo:i}=t;u(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()}),o(()=>t.elevationInfo,()=>this._snappingElevationAligner.notifyElevationSourceChange(),a),o(()=>null!=this._layerView3D?this._layerView3D.layer?.renderer:null,()=>this._symbologySnappingFetcher.notifySymbologyChange(),a),l(()=>this._layerView3D?.layer,["edits","apply-edits"],()=>this._symbologySnappingFetcher.notifySymbologyChange())])}constructor(e){super(e),this.view=null,this.updating=!1,this._memoizedMakeGetGroundElevation=i(g)}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,{source:r}=i;if(!r?.querySnapping)return[];const o=i.createQuery();this._layerView&&"effectiveDisplayFilter"in this._layerView&&(o.where=s(o.where,this._layerView.effectiveDisplayFilter?.where));const a=!("returnZ"in i&&!1===i.returnZ),l=c({parameters:e,returnZ:a,filter:o}),p=await r.querySnapping(l,{signal:t});n(t);const y=e.coordinateHelper.spatialReference,u=await this._snappingElevationAligner.alignCandidates(p.candidates,y,t);n(t);const g=await this._symbologySnappingFetcher.fetch(u,t);n(t);const m=0===g.length?u:[...u,...g],d=this._snappingElevationFilter.filter(l,m),v=this._memoizedMakeGetGroundElevation(this.view,y);return d.map(t=>h(t,e.mode,v))}};e([p({constructOnly:!0})],f.prototype,"layerSource",void 0),e([p({constructOnly:!0})],f.prototype,"view",void 0),e([p()],f.prototype,"_snappingElevationAligner",null),e([p()],f.prototype,"_snappingElevationFilter",null),e([p()],f.prototype,"_symbologySnappingFetcher",null),e([p()],f.prototype,"_layerView",null),e([p()],f.prototype,"_layerView3D",null),e([p()],f.prototype,"_symbologySnappingSupported",null),f=e([y("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],f);export{f as FeatureCollectionSnappingSource};