BuildingComponentSublayer.js 9.1 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{webSceneRendererTypes as t}from"../../renderers/support/types.js";import o from"../../request.js";import s from"../../core/Error.js";import{JSONMap as i}from"../../core/jsonMap.js";import a from"../../core/Loadable.js";import n from"../../core/Logger.js";import{isSome as p,isNone as l}from"../../core/maybe.js";import{EsriPromiseMixin as d}from"../../core/Promise.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{enumeration as u}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as c}from"../../core/accessorSupport/decorators/reader.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/Extent.js";import f from"../../geometry/SpatialReference.js";import g from"../FeatureLayer.js";import j from"./BuildingSublayer.js";import{zeroCapabilities as b}from"../support/capabilities.js";import{popupEnabled as v}from"../support/commonProperties.js";import{defineFieldProperties as L}from"../support/fieldProperties.js";import S from"../support/FieldsIndex.js";import{fetchIndexInfo as F}from"../support/I3SIndexInfo.js";import{I3SNodePageDefinition as I,I3SMaterialDefinition as O,I3STextureSetDefinition as x,I3SGeometryDefinition as w}from"../support/I3SLayerDefinitions.js";import T from"../../rest/support/Query.js";import{createPopupTemplate as R}from"../../support/popupUtils.js";import q from"../../symbols/support/ElevationInfo.js";const P=n.getLogger("esri.layers.buildingSublayers.BuildingComponentSublayer"),D=L();let Q=class extends(a.LoadableMixin(d(j))){constructor(e){super(e),this.type="building-component",this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.fields=null,this.associatedLayer=null,this.outFields=null,this.listMode="show",this.renderer=null,this.definitionExpression=null,this.popupEnabled=!0,this.popupTemplate=null,this.layerType="3d-object"}get parsedUrl(){return this.layer?{path:`${this.layer.parsedUrl.path}/sublayers/${this.id}`,query:this.layer.parsedUrl.query}:null}get fieldsIndex(){return new S(this.fields)}readAssociatedLayer(e,r){const t=this.layer.associatedFeatureServiceItem,o=r.associatedLayerID;return p(t)&&"number"==typeof o?new g({portalItem:t,layerId:o}):null}get objectIdField(){if(null!=this.fields)for(const e of this.fields)if("oid"===e.type)return e.name;return null}get displayField(){return p(this.associatedLayer)?this.associatedLayer.displayField:null}get apiKey(){return this.layer.apiKey}get fullExtent(){return this.layer.fullExtent}get spatialReference(){return this.layer.spatialReference}get version(){return this.layer.version}get elevationInfo(){return this.layer.elevationInfo}get minScale(){return this.layer.minScale}get maxScale(){return this.layer.maxScale}get effectiveScaleRange(){return this.layer.effectiveScaleRange}get defaultPopupTemplate(){return this.createPopupTemplate()}load(e){const r=p(e)?e.signal:null,t=this._fetchService(r).then((()=>{this.indexInfo=F(this.parsedUrl.path,this.rootNode,this.nodePages,this.apiKey,P,r)}));return this.addResolvingPromise(t),Promise.resolve(this)}createPopupTemplate(e){return R(this,e)}async _fetchService(e){const r=(await o(this.parsedUrl.path,{query:{f:"json",token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,{origin:"service",url:this.parsedUrl})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,r){const t=this.getFeatureType(r?.feature)?.domains?.[e];return t&&"inherited"!==t.type?t:this.getField(e)?.domain??null}getFeatureType(e){return e&&p(this.associatedLayer)?this.associatedLayer.getFeatureType(e):null}get types(){return p(this.associatedLayer)?this.associatedLayer.types:[]}get typeIdField(){return p(this.associatedLayer)?this.associatedLayer.typeIdField:null}get geometryType(){return"3d-object"===this.layerType?"mesh":"point"}get profile(){return"3d-object"===this.layerType?"mesh-pyramids":"points"}get capabilities(){const e=p(this.associatedLayer)&&this.associatedLayer.capabilities?this.associatedLayer.capabilities:b,{query:r,data:{supportsZ:t,supportsM:o,isVersioned:s}}=e;return{query:r,data:{supportsZ:t,supportsM:o,isVersioned:s}}}createQuery(){const e=new T;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e}queryExtent(e,r){return this._getAssociatedLayerForQuery().then((t=>t.queryExtent(e||this.createQuery(),r)))}queryFeatureCount(e,r){return this._getAssociatedLayerForQuery().then((t=>t.queryFeatureCount(e||this.createQuery(),r)))}queryFeatures(e,r){return this._getAssociatedLayerForQuery().then((t=>t.queryFeatures(e||this.createQuery(),r))).then((e=>{if(e?.features)for(const r of e.features)r.layer=this.layer,r.sourceLayer=this;return e}))}queryObjectIds(e,r){return this._getAssociatedLayerForQuery().then((t=>t.queryObjectIds(e||this.createQuery(),r)))}getFieldUsageInfo(e){return this.fieldsIndex.has(e)?{supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1}:{supportsLabelingInfo:!1,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:p(this.associatedLayer)}}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return p(e)&&e.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),l(this.associatedLayer))throw new s("buildingscenelayer:query-not-available","BuildingSceneLayer component layer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new s("buildingscenelayer:query-not-available","BuildingSceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}};e([y({readOnly:!0})],Q.prototype,"parsedUrl",null),e([y({type:I,readOnly:!0})],Q.prototype,"nodePages",void 0),e([y({type:[O],readOnly:!0})],Q.prototype,"materialDefinitions",void 0),e([y({type:[x],readOnly:!0})],Q.prototype,"textureSetDefinitions",void 0),e([y({type:[w],readOnly:!0})],Q.prototype,"geometryDefinitions",void 0),e([y({readOnly:!0})],Q.prototype,"serviceUpdateTimeStamp",void 0),e([y({readOnly:!0})],Q.prototype,"store",void 0),e([y({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],Q.prototype,"rootNode",void 0),e([y({readOnly:!0})],Q.prototype,"attributeStorageInfo",void 0),e([y(D.fields)],Q.prototype,"fields",void 0),e([y({readOnly:!0})],Q.prototype,"fieldsIndex",null),e([y({readOnly:!0,type:g})],Q.prototype,"associatedLayer",void 0),e([c("service","associatedLayer",["associatedLayerID"])],Q.prototype,"readAssociatedLayer",null),e([y(D.outFields)],Q.prototype,"outFields",void 0),e([y({type:String,readOnly:!0})],Q.prototype,"objectIdField",null),e([y({readOnly:!0,type:String,json:{read:!1}})],Q.prototype,"displayField",null),e([y({readOnly:!0,type:String})],Q.prototype,"apiKey",null),e([y({readOnly:!0,type:h})],Q.prototype,"fullExtent",null),e([y({readOnly:!0,type:f})],Q.prototype,"spatialReference",null),e([y({readOnly:!0})],Q.prototype,"version",null),e([y({readOnly:!0,type:q})],Q.prototype,"elevationInfo",null),e([y({readOnly:!0,type:Number})],Q.prototype,"minScale",null),e([y({readOnly:!0,type:Number})],Q.prototype,"maxScale",null),e([y({readOnly:!0,type:Number})],Q.prototype,"effectiveScaleRange",null),e([y({type:["hide","show"],json:{write:!0}})],Q.prototype,"listMode",void 0),e([y({types:t,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],Q.prototype,"renderer",void 0),e([y({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Q.prototype,"definitionExpression",void 0),e([y(v)],Q.prototype,"popupEnabled",void 0),e([y({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],Q.prototype,"popupTemplate",void 0),e([y({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],Q.prototype,"normalReferenceFrame",void 0),e([y({readOnly:!0,json:{read:!1}})],Q.prototype,"defaultPopupTemplate",null),e([y()],Q.prototype,"types",null),e([y()],Q.prototype,"typeIdField",null),e([y({json:{write:!1}}),u(new i({"3DObject":"3d-object",Point:"point"}))],Q.prototype,"layerType",void 0),e([y()],Q.prototype,"geometryType",null),e([y()],Q.prototype,"profile",null),e([y({readOnly:!0,json:{read:!1}})],Q.prototype,"capabilities",null),Q=e([m("esri.layers.buildingSublayers.BuildingComponentSublayer")],Q);const E=Q;export{E as default};