@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 6.82 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/Collection.js";import t from"../core/CollectionFlattener.js";import s from"../core/Error.js";import{clone as i}from"../core/lang.js";import{loadAll as o}from"../core/loadAll.js";import a from"../core/Logger.js";import{MultiOriginJSONMixin as l}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as n}from"../core/promiseUtils.js";import{join as p}from"../core/urlUtils.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{reader as y}from"../core/accessorSupport/decorators/reader.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"../geometry/SpatialReference.js";import m from"./Layer.js";import h from"./buildingSublayers/BuildingComponentSublayer.js";import f from"./buildingSublayers/BuildingGroupSublayer.js";import{APIKeyMixin as b}from"./mixins/APIKeyMixin.js";import{ArcGISService as g}from"./mixins/ArcGISService.js";import{CustomParametersMixin as S}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as v}from"./mixins/OperationalLayer.js";import{PortalLayer as j}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as w}from"./mixins/ScaleRangeLayer.js";import{SceneService as _,SaveOperationType as I}from"./mixins/SceneService.js";import{findAssociatedFeatureService as L}from"./support/associatedFeatureServiceUtils.js";import O from"./support/BuildingFilter.js";import T from"./support/BuildingSummaryStatistics.js";import{sceneLayerFullExtent as x,legendEnabled as A,readOnlyService as E,elevationInfo as F}from"./support/commonProperties.js";import{logInvalidElevationInfoWarning as P,elevationModeRequiredMessage as B,featureExpressionUnsupportedMessage as K}from"../support/elevationInfoUtils.js";const C=r.ofType(O),R=i(f.sublayersProperty),M=R.json?.origins;M&&(M["web-scene"]={type:[h],write:{enabled:!0,overridePolicy:()=>({enabled:!1})}},M["portal-item"]={type:[h],write:{enabled:!0,overridePolicy:()=>({enabled:!1})}});let U=class extends(_(g(v(j(w(l(S(b(m))))))))){constructor(e){super(e),this.operationalLayerType="BuildingSceneLayer",this.allSublayers=new t({getCollections:()=>[this.sublayers],getChildrenFunction:e=>"building-group"===e.type?e.sublayers:null}),this.sublayers=null,this._allSublayerOverrides=null,this.filters=new C,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,r,t){const s=f.readSublayers(e,r,t);return f.forEachSublayer(s,(e=>e.layer=this)),this._allSublayerOverrides&&(H(s,this._allSublayerOverrides),this._allSublayerOverrides=null),s}write(e,r){return e=super.write(e,r),!r||"web-scene"!==r.origin&&"portal-item"!==r.origin||(this.sublayers?G(this.sublayers,e,r):this._allSublayerOverrides&&V(this._allSublayerOverrides,e,r)),e}read(e,r){if(super.read(e,r),("web-scene"===r?.origin||"portal-item"===r?.origin)&&Array.isArray(e?.sublayers)){const t=k(e.sublayers,r);this.sublayers?N(this.sublayers,t):(this._allSublayerOverrides??=new Map,this._allSublayerOverrides.set(r.origin,t))}}readSummaryStatistics(e,r){if("string"==typeof r.statisticsHRef){const e=p(this.parsedUrl?.path,r.statisticsHRef);return new T({url:e})}return null}set elevationInfo(e){null!=e&&"absolute-height"!==e.mode||this._set("elevationInfo",e),this._validateElevationInfo(e)}load(e){const r=null!=e?e.signal:null,t=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(n).then((()=>this._fetchService(r))).then((()=>this._fetchAssociatedFeatureService(r)));return this.addResolvingPromise(t),Promise.resolve(this)}loadAll(){return o(this,(e=>{f.forEachSublayer(this.sublayers,(r=>{"building-group"!==r.type&&e(r)})),this.summaryStatistics&&e(this.summaryStatistics)}))}async saveAs(e,r){return this._debouncedSaveOperations(I.SAVE_AS,{...r,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"building-scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"building-scene"};return this._debouncedSaveOperations(I.SAVE,e)}validateLayer(e){if(!e.layerType||"Building"!==e.layerType)throw new s("buildingscenelayer:layer-type-not-supported","BuildingSceneLayer does not support this layer type",{layerType:e.layerType})}_getTypeKeywords(){return["Building"]}async _fetchAssociatedFeatureService(e){try{const{portalItem:r}=await L(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e});this.associatedFeatureServiceItem=r}catch(r){a.getLogger(this).warn("Associated feature service item could not be loaded",r)}}_validateElevationInfo(e){const r="Building scene layers";P(a.getLogger(this),B(r,"absolute-height",e)),P(a.getLogger(this),K(r,e))}};function H(e,r){r.forEach((r=>N(e,r)))}function N(e,r){const{overrides:t,context:s}=r;f.forEachSublayer(e,(e=>e.read(t.get(e.id),s)))}function k(e,r){const t=new Map;for(const i of e)null!=i&&"object"==typeof i&&"number"==typeof i.id?t.set(i.id,i):r.messages?.push(new s("building-scene-layer:invalid-sublayer-override","Invalid value for sublayer override. Not an object or no id specified.",{value:i}));return{overrides:t,context:r}}function G(e,r,t){const s=[];f.forEachSublayer(e,(e=>{const r=e.write({},t);Object.keys(r).length>1&&s.push(r)})),s.length>0&&(r.sublayers=s)}function V(e,r,t){const s=t?.origin&&e.get(t.origin);s&&(r.sublayers=[],s.overrides.forEach((e=>{r.sublayers.push(i(e))})))}e([u({type:["BuildingSceneLayer"]})],U.prototype,"operationalLayerType",void 0),e([u({readOnly:!0})],U.prototype,"allSublayers",void 0),e([u(R)],U.prototype,"sublayers",void 0),e([y("service","sublayers")],U.prototype,"readSublayers",null),e([u({type:C,nonNullable:!0,json:{write:!0}})],U.prototype,"filters",void 0),e([u({type:String,json:{write:!0}})],U.prototype,"activeFilterId",void 0),e([u({readOnly:!0,type:T})],U.prototype,"summaryStatistics",void 0),e([y("summaryStatistics",["statisticsHRef"])],U.prototype,"readSummaryStatistics",null),e([u({type:[String],json:{read:!1}})],U.prototype,"outFields",void 0),e([u(x)],U.prototype,"fullExtent",void 0),e([u(A)],U.prototype,"legendEnabled",void 0),e([u({type:["show","hide","hide-children"]})],U.prototype,"listMode",void 0),e([u(E(d))],U.prototype,"spatialReference",void 0),e([u(F)],U.prototype,"elevationInfo",null),e([u({json:{read:!1},readOnly:!0})],U.prototype,"type",void 0),e([u()],U.prototype,"associatedFeatureServiceItem",void 0),U=e([c("esri.layers.BuildingSceneLayer")],U);const $=U;export{$ as default};