UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 7.62 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{createTask as i}from"../../../../core/asyncUtils.js";import{destroyHandle as r}from"../../../../core/handleUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as a,ignoreAbortErrors as n}from"../../../../core/promiseUtils.js";import{initial as o,on as l,watch as d,sync as u,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{sqlAnd as h}from"../../../../core/sql.js";import{property as y,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as m}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as _}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as w}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as S}from"../snappingUtils.js";import{makeGetGroundElevation as v,convertSnappingCandidate as H}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as I}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as b}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as F}from"./featureServiceSource/FeatureServiceTilesSimple.js";import O from"../../../support/debugFlags.js";let E=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find(e=>e.layer===this._layer)}get _isSuspended(){if(m(this._layer)){if(!this.layerSource.sublayerSources.some(e=>e.enabled&&e.layer.visible))return!0}return this._snappingComplexityExceeded||!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get _snappingComplexityExceeded(){return!(!this._layerView||!("snappingComplexityExceeded"in this._layerView))&&this._layerView.snappingComplexityExceeded}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating||this._tilesOfInterest.updating}get _outFields(){const{view:e,_layerView:t,layerSource:i}=this,{layer:r}=i,{fieldsIndex:s,timeInfo:a,floorInfo:n,subtypeField:o}=r,l=t&&"filter"in t?t.filter:null,d=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&a){const{startField:e,endField:t}=a,i=s.get(e)?.name??e,r=s.get(t)?.name??t;i&&d.push(i),r&&d.push(r)}if(e?.map&&S(e.map)&&e.map.utilityNetworks?.find(e=>e.isUtilityLayer(r))){const e=r.fieldsIndex.get("assetGroup")?.name,t=r.fieldsIndex.get("assetType")?.name;e&&t&&(d.push(e),d.push(t))}if(r&&n?.floorField&&e?.floors?.length){const e=s.get(n.floorField)?.name??n.floorField;e&&d.push(e)}if(o){const e=s.get(o)?.name??o;e&&d.push(e)}return new Set(d)}get configuration(){const{view:e}=this,{apiKey:t,customParameters:i}=this._layer,r=null!=e?e.type:"2d",s=this._layer.createQuery();return this._layerView&&"effectiveDisplayFilter"in this._layerView&&(s.where=h(s.where,this._layerView.effectiveDisplayFilter?.where)),{filter:s,customParameters:t?{...i,token:t}:i,viewType:r}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new f,this._workerHandle=null,this._debug=null,this._memoizedMakeGetGroundElevation=s(v)}initialize(){let e;const t=this.view;if(null==t||t.destroyed)this._tilesOfInterest=new F({layer:this._layer}),e=this._workerHandle=new b;else switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new b({hasZ:this._layer.hasZ});break;case"3d":{const{resourceController:i}=t,r=this._layer;this._tilesOfInterest=new w({view:t}),e=this._workerHandle=new b({schedule:e=>i.immediate.schedule(e),hasZ:r.hasZ&&(r.returnZ??!0),elevationAlignPointsInFeatures:async(e,i)=>{const s=await t.whenLayerView(r);return a(i),s.elevationAlignPointsInFeatures(e,i)},queryForSymbologySnapping:async(e,i)=>{const s=await t.whenLayerView(r);return a(i),s.queryForSymbologySnapping(e,i)}}),this._updatingHandles.add(()=>r.elevationInfo,()=>n(e.notifyElevationSourceChange()),o),this._updatingHandles.add(()=>this._layerView?.layer?.renderer,()=>n(e.notifySymbologyChange()),o),this._updatingHandles.add(()=>this._layerView?.symbologySnappingSupported??!1,t=>n(e.setSymbologySnappingSupported(t)),o),this.addHandles([t.elevationProvider.on("elevation-change",({context:t})=>{const{elevationInfo:i}=r;_(t,i)&&n(e.notifyElevationSourceChange())}),l(()=>this._layerView?.layer,["edits","apply-edits","graphic-update"],()=>e.notifySymbologyChange())]);break}}this.addHandles([r(e)]),n(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add(()=>this._updateTilesParameters,()=>n(e.updateTiles(this._updateTilesParameters,null)),o),this.addHandles([d(()=>this.configuration,t=>n(e.configure(t,null)),u),d(()=>this._layer.historicMoment,t=>n(e.setHistoricMoment(t)),p),d(()=>this._isSuspended,t=>n(e.setSuspended(t)),p)]),this._updatingHandles.add(()=>this._outFields,t=>n(e.updateOutFields(t)),o),null!=t&&this.addHandles(d(()=>O.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES,i=>{i&&!this._debug?(this._debug=new I({view:t,handle:e}),this.addHandles(r(this._debug),"debug")):!i&&this._debug&&this.removeHandles("debug")},o)),this.addHandles([this.layerSource.layer.on("edits",t=>n(e.handleEdits(t,null))),this.layerSource.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))])}destroy(){this._updatingHandles.destroy(),this._tilesOfInterest.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){if(this._isSuspended)return[];const{coordinateHelper:i,point:r}=e;this._tilesOfInterest.pointOfInterest=i.arrayToPoint(r);const s=this._memoizedMakeGetGroundElevation(this.view,i.spatialReference),{candidates:a}=await this._workerHandle.fetchCandidates({...e},t);return a.map(t=>H(t,e.mode,s))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}_getOrLoadWhereFields(e,t){const{_whereModule:r}=this;if(!this._loadWhereModuleTask&&!r){const e=i(async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.default,this._whereModule});return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!r)return[];try{return r.create(e,{fieldsIndex:t}).fieldNames}catch(s){return[]}}};e([y({constructOnly:!0})],E.prototype,"spatialReference",void 0),e([y({constructOnly:!0})],E.prototype,"layerSource",void 0),e([y({constructOnly:!0})],E.prototype,"view",void 0),e([y()],E.prototype,"_tilesOfInterest",void 0),e([y({readOnly:!0})],E.prototype,"_updateTilesParameters",null),e([y()],E.prototype,"_layerView",null),e([y()],E.prototype,"_isSuspended",null),e([y()],E.prototype,"_snappingComplexityExceeded",null),e([y({readOnly:!0})],E.prototype,"updating",null),e([y()],E.prototype,"_outFields",null),e([y({readOnly:!0})],E.prototype,"configuration",null),e([y({readOnly:!0})],E.prototype,"availability",null),e([y()],E.prototype,"_loadWhereModuleTask",void 0),e([y()],E.prototype,"_whereModule",void 0),E=e([c("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],E);export{E as FeatureServiceSnappingSource};