UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 6.88 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i}from"../../../core/handleUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import s from"../../../core/ReactiveMap.js";import{property as n,subclass as l}from"../../../core/accessorSupport/decorators.js";import{projectAsync as h}from"../../../geometry/projectionUtils.js";import{hydrateGraphic as a}from"../../../layers/graphics/hydratedFeatures.js";import{combineTimeExtent as o,hasTimeOptions as p}from"../../../layers/support/timeSupport.js";import u from"../../../rest/support/AttributeBinsQuery.js";import g from"../../../rest/support/Query.js";import{isGraphic as y}from"../../../support/graphicInstanceUtils.js";import{LayerView3D as c}from"./LayerView3D.js";import{attributeLookup as d}from"./support/attributeUtils.js";import{normalizeHighlightTarget as m,emptyHighlightHandle as f,isObjectId as P}from"./support/highlightUtils.js";import{RefreshableLayerView as b}from"../../layers/RefreshableLayerView.js";import{getHighlightName as v}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as w,isInEffectiveScaleRange as I}from"../../support/layerViewUtils.js";const _=_=>{const j=b(c(_));let S=class extends j{constructor(){super(...arguments),this.updatePolicy=1,this.slicePlaneEnabled=!1,this._highlightCounter=new s,this.fullExtentInLocalViewSpatialReference=null,this.supportsHeightUnitConversion=!0}initialize(){const e=this.layer;"isTable"in e&&e.isTable?this.addResolvingPromise(Promise.reject(new t("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e}))):(this.addResolvingPromise(this._validateGeometryType()),this.addResolvingPromise((async()=>{if(this.destroyed)return;this.fullExtentInLocalViewSpatialReference="local"===this.view.viewingMode?await h(this.layer.fullExtent,this.view.spatialReference).catch(()=>null):null;const e=await this.createGraphicsPipeline();this.destroyed?e.destroy():(this.graphicsPipeline=e,await e.when())})()),this.notifyChange("updating"))}destroy(){this.graphicsPipeline=r(this.graphicsPipeline)}get dataUpdating(){return!!this.graphicsPipeline?.dataUpdating}get legendEnabled(){return this.canResume()&&this.graphicsPipeline?.legendEnabled}get visibleAtCurrentScale(){return w()?I(this.layer.effectiveScaleRange,this.view.scale):!this.graphicsPipeline?.scaleVisibilitySuspended}get symbologySnappingSupported(){return this.graphicsPipeline.symbologySnappingSupported}get hasAllFeatures(){return this.graphicsPipeline.hasAllFeatures}get hasAllFeaturesInView(){return this.graphicsPipeline.hasAllFeaturesInView}get hasFullGeometries(){return this.graphicsPipeline.hasFullGeometries}get timeExtent(){return o(p(this.layer)?this.layer:null,this.view?.timeExtent,this._get("timeExtent"))}get highlightIds(){return Array.from(this._highlightCounter.keys())}get hasHighlight(){return this.highlightIds.length>0}getHit(e,t){const i=this.graphicsPipeline.findGraphic(t=>t.uid===e);if(null==i)return null;const r=a(i,this.layer,this.layer.graphicOrigin);return{type:"graphic",graphic:r,layer:r.layer}}whenGraphicBounds(e,t){return this.graphicsPipeline?.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.graphicsPipeline?.computeAttachmentOrigin(e,t)}async elevationAlignPointsInFeatures(e,t){return this.graphicsPipeline.elevationAlignPointsInFeatures(e,t)}async queryForSymbologySnapping(e,t){return this.graphicsPipeline.graphicsQuery.queryForSymbologySnapping(e,t)}queryAggregates(e,t){throw new Error("missing implementation")}queryFeatures(e,t){return this.graphicsPipeline.graphicsQuery.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this.graphicsPipeline.graphicsQuery.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this.graphicsPipeline.graphicsQuery.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryAttributeBins(e,t){return this.graphicsPipeline.graphicsQuery.executeAttributeBinsQuery(this._ensureAttributeBinsQuery(e),t?.signal)}queryExtent(e,t){return this.graphicsPipeline.graphicsQuery.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return null==e?this.createQuery():g.from(e)}_ensureAttributeBinsQuery(e){const t=u.from(e);return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}_addHighlightIds(e){this._highlightCounter.batch(()=>{for(const t of e){const e=this._highlightCounter.get(t)??0;this._highlightCounter.set(t,e+1)}})}_removeHighlightIds(e){this._highlightCounter.batch(()=>{for(const t of e){let e=this._highlightCounter.get(t);null!=e&&(e--,e>0?this._highlightCounter.set(t,e):this._highlightCounter.delete(t))}})}highlight(e,t){const r=v(t),s=this.layer.objectIdField,n=m(e);if(0===n.length)return f;if(y(n[0])){const e=n;if(null!=d(this.layer.fieldsIndex,e[0].attributes,s)){const t=e.map(e=>d(this.layer.fieldsIndex,e.attributes,s)),n=this.graphicsPipeline.highlightByObjectIds(t,r);return this._addHighlightIds(t),i(()=>{this._removeHighlightIds(t),n.remove()})}return this.graphicsPipeline.highlightByGraphics(e,r)}if(P(n[0])){const e=n;this._addHighlightIds(e);const t=this.graphicsPipeline.highlightByObjectIds(e,r);return i(()=>{t.remove(),this._removeHighlightIds(e)})}return f}maskOccludee(e){return this.graphicsPipeline.maskOccludee(e)}getSuspendInfo(){return{...super.getSuspendInfo(),...this.graphicsPipeline.suspendInfo}}isUpdating(){return!(!this.graphicsPipeline||this.graphicsPipeline.destroyed)&&!(!this.graphicsPipeline?.updating&&this.view?.groundView?.ready)}async _validateGeometryType(){switch(this.layer.geometryType){case"multipatch":case"multipoint":throw new t("featurelayerview3d:unsupported-geometry-type","Unsupported geometry type ${geometryType}",{geometryType:this.layer.geometryType})}}get performanceInfo(){return this.graphicsPipeline.performanceInfo}};return e([n()],S.prototype,"graphicsPipeline",void 0),e([n({readOnly:!0})],S.prototype,"dataUpdating",null),e([n()],S.prototype,"suspended",void 0),e([n({readOnly:!0})],S.prototype,"legendEnabled",null),e([n({readOnly:!0})],S.prototype,"visibleAtCurrentScale",null),e([n()],S.prototype,"updating",void 0),e([n({readOnly:!0})],S.prototype,"updatePolicy",void 0),e([n({type:Boolean})],S.prototype,"slicePlaneEnabled",void 0),e([n({readOnly:!0})],S.prototype,"suspendInfo",void 0),e([n()],S.prototype,"symbologySnappingSupported",null),e([n({readOnly:!0})],S.prototype,"hasAllFeatures",null),e([n({readOnly:!0})],S.prototype,"hasAllFeaturesInView",null),e([n({readOnly:!0})],S.prototype,"hasFullGeometries",null),e([n({readOnly:!0})],S.prototype,"timeExtent",null),e([n()],S.prototype,"highlightIds",null),e([n()],S.prototype,"hasHighlight",null),S=e([l("esri.views.3d.layers.FeatureLikeLayerViewBase3D")],S),S};export{_ as FeatureLikeLayerViewBase3D};