@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 8.78 kB
JavaScript
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../Graphic.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isSome as s,isNone as l}from"../../../core/maybe.js";import{initial as a}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as u}from"../../../core/sql/WhereClause.js";import"../../../layers/buildingSublayers/BuildingComponentSublayer.js";import d from"../../../layers/support/FeatureFilter.js";import{fixFields as p,unpackFieldNames as h,populateMissingFields as y}from"../../../layers/support/fieldUtils.js";import c from"../../../rest/support/Query.js";import{BuildingSublayerView3DMixin as f}from"./BuildingSublayerView3D.js";import{I3SMeshView3D as g}from"./I3SMeshView3D.js";import{ForAllFeaturesVisibilityMode as m}from"./II3SMeshView3D.js";import{applyFilterMode as b}from"./i3s/BuildingFilterUtil.js";import{createGetFeatureExtent as F}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as _}from"./i3s/I3SMeshViewFilter.js";import{I3SQueryEngine as E}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as w}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as x}from"./i3s/I3SQueryFeatureStore.js";import{findFieldsCaseInsensitive as S,getIndexCrs as j}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as I}from"./support/DefinitionExpressionSceneLayerView.js";import v from"../../layers/BuildingComponentSublayerView.js";import{getRequiredFields as Q,getFetchPopupTemplate as q}from"../../layers/support/popupUtils.js";import{TaskPriority as L}from"../../support/Scheduler.js";let R=class extends(I(g(f(v)))){constructor(){super(...arguments),this.type="building-component-sublayer-3d",this.layerView=null,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!1,this.requiredFields=[],this.progressiveLoadFactor=1,this._queryEngine=null}get i3slayer(){return this.sublayer}get layerUid(){return this.sublayer.layer.uid}get sublayerUid(){return this.sublayer.uid}get layerId(){return this.sublayer.layer.id}get sublayerId(){return this.sublayer.id}get layerPopupEnabled(){return this.sublayer.popupEnabled}initialize(){this.updatingHandles.add((()=>[this.sublayer.renderer,this.definitionExpressionFields,this.filterExpressionFields]),(()=>this._updateRequiredFields())),this.updatingHandles.add((()=>this.sublayer.renderer),(e=>this._rendererChange(e)),a);const e=()=>this._filterChange();this.updatingHandles.add((()=>this.parsedDefinitionExpression),e),this.updatingHandles.add((()=>s(this._filter)?this._filter.sortedObjectIds:null),e),this.updatingHandles.add((()=>s(this._filter)?this._filter.parsedWhereClause:null),e),this.updatingHandles.add((()=>[s(this._filter)?this._filter.parsedGeometry:null,s(this.filter)?this.filter.spatialRelationship:null]),(()=>this._geometryFilterChange())),this.updatingHandles.add((()=>this.parsedFilterExpressions),(()=>this._updateSymbologyOverride()),a),this.addResolvingPromise(this._updateRequiredFields())}get lodFactor(){return this.view.qualitySettings.sceneService.object.lodFactor}get parsedFilterExpressions(){return"Overview"!==this.sublayer.modelName&&this.layerView?this.layerView.filterExpressions.map((([e,r])=>{let t;try{t=u.create(e,this.sublayer.fieldsIndex)}catch(a){return i.getLogger(this.declaredClass).error("Failed to parse filterExpression: "+a),null}if(!t.isStandardized)return i.getLogger(this.declaredClass).error("filterExpression is using non standard function"),null;const s=[],l=t.fieldNames;return S(l,this.sublayer.fields,{missingFields:s}),s.length>0?(i.getLogger(this.declaredClass).error(`filterExpression references unknown fields: ${s.join(", ")}`),null):[t,r]})).filter((e=>null!=e)):[]}get filter(){return s(this._filter)?this._filter.viewFilter:null}set filter(e){!l(e)&&_.checkSupport(e)?s(this._filter)?this._filter.viewFilter=e:this._filter=new _({viewFilter:e,layerFieldsIndex:this.sublayer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,r)=>this.addSqlFilter(e,r,this.logError)}):this._filter=null}isUpdating(){return super.isUpdating()||s(this._filter)&&this._filter.updating}_updateSymbologyOverride(){const e=this.parsedFilterExpressions;e.length>0?this._setSymbologyOverride(((r,t)=>{for(const[s,l]of e)try{if(s.testFeature(r))return b(t,l)}catch(i){this.logError(i)}return b(t,null)}),this.filterExpressionFields):this._setSymbologyOverride(null,null)}get filterExpressionFields(){return p(this.sublayer.fieldsIndex,this.parsedFilterExpressions.reduce(((e,[r])=>e.concat(r.fieldNames)),new Array))}get availableFields(){const e=this.sublayer,r=e.fieldsIndex;let t=this.requiredFields;if(e.outFields||e.layer.outFields){const i=[...e.outFields||[],...e.layer.outFields||[]];t=[...h(r,i),...t]}return p(r,t)}_createLayerGraphic(e){const t=new r(null,null,e);return t.layer=this.sublayer.layer,t.sourceLayer=this.sublayer,t}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}async fetchPopupFeatures(e,r){const t=this._validateFetchPopupFeatures(r);if(t)throw t;if(l(r)||!r.clientGraphics||0===r.clientGraphics.length)return[];const a=[],n=[],o=s(this.sublayer.associatedLayer)?await this.sublayer.associatedLayer.load():this.sublayer,u=h(this.sublayer.fieldsIndex,await Q(o,q(this.sublayer,r))),d=new Set;for(const i of r.clientGraphics)y(u,i,d)?n.push(i):a.push(i);return 0===n.length?a:(s(this.sublayer.associatedLayer)&&await this.sublayer.associatedLayer.load().catch((()=>i.getLogger(this.declaredClass).warn("Failed to load associated feature layer. Displaying popup attributes from cached attributes."))),this.whenGraphicAttributes(n,Array.from(d)).catch((()=>n)).then((e=>a.concat(e))))}async _updateRequiredFields(){const e=p(this.sublayer.fieldsIndex,[...this.sublayer.renderer?await this.sublayer.renderer.getRequiredFields(this.sublayer.fieldsIndex):[],...this.definitionExpressionFields||[],...this.filterExpressionFields||[]]);this._set("requiredFields",e)}_validateFetchPopupFeatures(e){const{sublayer:r}=this,{popupEnabled:i}=r;return i?q(r,e)?void 0:new t("buildingscenelayerview3d:fetchPopupFeatures","Layer does not define a popup template",{sublayer:r}):new t("buildingscenelayerview3d:fetchPopupFeatures","Popups are disabled",{sublayer:r})}getFilters(){const e=super.getFilters();return this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),s(this._filter)&&this._filter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return s(this.filter)?this.filter.createQuery(e):new c(e)}queryExtent(e,r){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),r?.signal)}queryFeatureCount(e,r){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),r?.signal)}queryFeatures(e,r){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),r?.signal).then((e=>{if(!e?.features)return e;const r=this.sublayer,t=r.layer;for(const i of e.features)i.layer=t,i.sourceLayer=r;return e}))}queryObjectIds(e,r){return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),r?.signal)}_ensureQueryEngine(){return l(this._queryEngine)&&(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=F(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new E({layerView:this,priority:L.FEATURE_QUERY_ENGINE,spatialIndex:new x({featureAdapter:new w({objectIdField:this.sublayer.objectIdField,attributeStorageInfo:this.sublayer.attributeStorageInfo,getFeatureExtent:e}),forAllFeatures:(e,r)=>this._forAllFeatures(((r,t,i)=>e({id:r,index:t,meta:i})),r,m.ALL_IN_CLIPPING_AREA),getFeatureExtent:e,sourceSpatialReference:j(this.sublayer),viewSpatialReference:this.view.spatialReference})})}_ensureQuery(e){return this._addDefinitionExpressionToQuery(l(e)?this.createQuery():c.from(e))}};e([n()],R.prototype,"i3slayer",null),e([n()],R.prototype,"layerView",void 0),e([n()],R.prototype,"lodFactor",null),e([n({readOnly:!0})],R.prototype,"parsedFilterExpressions",null),e([n({type:d})],R.prototype,"filter",null),e([n()],R.prototype,"_filter",void 0),e([n({type:[String],readOnly:!0})],R.prototype,"filterExpressionFields",null),e([n({type:[String],readOnly:!0})],R.prototype,"requiredFields",void 0),e([n({type:[String],readOnly:!0})],R.prototype,"availableFields",null),R=e([o("esri.views.3d.layers.BuildingComponentSublayerView3D")],R);const C=R;export{C as default};