@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 7.54 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import i from"../core/Error.js";import{abortHandle as s}from"../core/handleUtils.js";import{clone as o}from"../core/lang.js";import{loadAll as l}from"../core/loadAll.js";import a from"../core/Logger.js";import{MultiOriginJSONSupportMixin as n}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as p,ignoreAbortErrors as u}from"../core/promiseUtils.js";import{whenOnce as y}from"../core/reactiveUtils.js";import{join as d}from"../core/urlUtils.js";import{property as c,subclass as m}from"../core/accessorSupport/decorators.js";import h from"../geometry/SpatialReference.js";import b from"./Layer.js";import g from"./buildingSublayers/BuildingComponentSublayer.js";import f from"./buildingSublayers/BuildingGroupSublayer.js";import{forEachBuildingSublayer as v}from"./buildingSublayers/utils.js";import{APIKeyMixin as S}from"./mixins/APIKeyMixin.js";import{ArcGISService as j}from"./mixins/ArcGISService.js";import{CustomParametersMixin as w}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as _}from"./mixins/OperationalLayer.js";import{PortalLayer as I}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as L}from"./mixins/ScaleRangeLayer.js";import{SceneService as O}from"./mixins/SceneService.js";import{findAssociatedFeatureService as T}from"./support/associatedFeatureServiceUtils.js";import P from"./support/BuildingFilter.js";import x from"./support/BuildingSummaryStatistics.js";import{sceneLayerFullExtent as F,legendEnabled as A,readOnlyService as B,elevationInfo as E}from"./support/commonProperties.js";import{logInvalidElevationInfoWarning as K,elevationModeRequiredMessage as C,featureExpressionUnsupportedMessage as U}from"../support/elevationInfoUtils.js";import{reader as $}from"../core/accessorSupport/decorators/reader.js";const R=t.ofType(P),M=o(f.sublayersProperty),H=M.json?.origins;H&&(H["web-scene"]={type:[g],write:{enabled:!0,overridePolicy:()=>({enabled:!1})}},H["portal-item"]={type:[g],write:{enabled:!0,overridePolicy:()=>({enabled:!1})}});let k=class extends(O(j(_(I(L(n(w(S(b))))))))){constructor(e){super(e),this.operationalLayerType="BuildingSceneLayer",this.allSublayers=new r({getCollections:()=>[this.sublayers],getChildrenFunction:e=>"building-group"===e.type?e.sublayers:null}),this.sublayers=null,this._allSublayerOverrides=null,this.filters=new R,this.activeFilterId=null,this.summaryStatistics=null,this.outFields=null,this.legendEnabled=!0,this.type="building-scene"}normalizeCtorArgs(e){return"string"==typeof e?{url:e}:e??{}}destroy(){this.allSublayers.destroy()}readSublayers(e,t,r){const i=f.readSublayers(e,t,r);return v(i,e=>e.layer=this),this._allSublayerOverrides&&(N(i,this._allSublayerOverrides),this._allSublayerOverrides=null),i}write(e,t){return e=super.write(e,t),!t||"web-scene"!==t.origin&&"portal-item"!==t.origin||(this.sublayers?z(this.sublayers,e,t):this._allSublayerOverrides&&J(this._allSublayerOverrides,e,t)),e}read(e,t){if(super.read(e,t),("web-scene"===t?.origin||"portal-item"===t?.origin)&&Array.isArray(e?.sublayers)){const r=W(e.sublayers,t);this.sublayers?G(this.sublayers,r):(this._allSublayerOverrides??=new Map,this._allSublayerOverrides.set(t.origin,r))}}readSummaryStatistics(e,t){if("string"==typeof t.statisticsHRef&&this.parsedUrl){const e=d(this.parsedUrl.path,t.statisticsHRef);return new x({url:e,apiKey:this.apiKey,customParameters:this.customParameters})}return null}set elevationInfo(e){null!=e&&"absolute-height"!==e.mode||this._set("elevationInfo",e),this._validateElevationInfo(e)}load(e){const t=null!=e?e.signal:null,r=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(p).then(()=>this._fetchService(t)).then(()=>this._fetchAssociatedFeatureService(t));return this.addResolvingPromise(r),Promise.resolve(this)}loadAll(){return l(this,e=>{v(this.sublayers,t=>{"building-group"!==t.type&&e(t)}),this.summaryStatistics&&e(this.summaryStatistics)})}async saveAs(e,t){return this._debouncedSaveOperations(1,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"building-scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"building-scene"};return this._debouncedSaveOperations(0,e)}validateLayer(e){if(!e.layerType||"Building"!==e.layerType)throw new i("buildingscenelayer:layer-type-not-supported","BuildingSceneLayer does not support this layer type",{layerType:e.layerType})}_getTypeKeywords(){return["Building"]}async _fetchAssociatedFeatureService(e){try{const{portalItem:t}=await T(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e});this.associatedFeatureServiceItem=t}catch(t){u(this._logWarningOnPopupEnabled())}}async _logWarningOnPopupEnabled(){const e=new AbortController;this.addHandles(s(e)),await y(()=>this.allSublayers.filter(e=>"building-component"===e.type).some(e=>e.popupEnabled&&null!=e.popupTemplate),e.signal);const t=this.allSublayers.filter(e=>"building-component"===e.type).filter(e=>e.popupEnabled&&null!=e.popupTemplate),r=[],i=[];for(const s of t){const e=s.title??`untitled ${s.id}`;s.attributeStorageInfo?r.push(e):i.push(e)}const o="\n ",l=r.length>0?`\nThe following sublayers will fall back to binary attributes for Popups:${o}${r.join(o)}`:"",n=i.length>0?`\nThe following sublayers have no binary attributes and will not work with Popups:${o}${i.join(o)}`:"";a.getLogger(this).warn(`Associated FeatureLayer could not be loaded for this BuildingSceneLayer: ${this.title}.`,l,n)}_validateElevationInfo(e){const t="Building scene layers";K(a.getLogger(this),C(t,"absolute-height",e)),K(a.getLogger(this),U(t,e))}};function N(e,t){t.forEach(t=>G(e,t))}function G(e,t){const{overrides:r,context:i}=t;v(e,e=>e.read(r.get(e.id),i))}function W(e,t){const r=new Map;for(const s of e)null!=s&&"object"==typeof s&&"number"==typeof s.id?r.set(s.id,s):t.messages?.push(new i("building-scene-layer:invalid-sublayer-override","Invalid value for sublayer override. Not an object or no id specified.",{value:s}));return{overrides:r,context:t}}function z(e,t,r){const i=[];v(e,e=>{const t=e.write({},r);Object.keys(t).length>1&&i.push(t)}),i.length>0&&(t.sublayers=i)}function J(e,t,r){const i=r?.origin&&e.get(r.origin);i&&(t.sublayers=[],i.overrides.forEach(e=>{t.sublayers.push(o(e))}))}e([c({type:["BuildingSceneLayer"]})],k.prototype,"operationalLayerType",void 0),e([c({readOnly:!0})],k.prototype,"allSublayers",void 0),e([c(M)],k.prototype,"sublayers",void 0),e([$("service","sublayers")],k.prototype,"readSublayers",null),e([c({type:R,nonNullable:!0,json:{write:!0}})],k.prototype,"filters",void 0),e([c({type:String,json:{write:!0}})],k.prototype,"activeFilterId",void 0),e([c({readOnly:!0,type:x})],k.prototype,"summaryStatistics",void 0),e([$("summaryStatistics",["statisticsHRef"])],k.prototype,"readSummaryStatistics",null),e([c({type:[String],json:{read:!1}})],k.prototype,"outFields",void 0),e([c(F)],k.prototype,"fullExtent",void 0),e([c(A)],k.prototype,"legendEnabled",void 0),e([c({type:["show","hide","hide-children"]})],k.prototype,"listMode",void 0),e([c(B(h))],k.prototype,"spatialReference",void 0),e([c(E)],k.prototype,"elevationInfo",null),e([c({json:{read:!1},readOnly:!0})],k.prototype,"type",void 0),e([c()],k.prototype,"associatedFeatureServiceItem",void 0),k=e([m("esri.layers.BuildingSceneLayer")],k);const q=k;export{q as default};