UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) • 10.2 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import r from"../../PopupTemplate.js";import o from"../../request.js";import s from"../../core/Error.js";import{JSONMap as i}from"../../core/jsonMap.js";import{LoadableMixin as a}from"../../core/Loadable.js";import n from"../../core/Logger.js";import{EsriPromiseMixin as p}from"../../core/Promise.js";import{property as l,subclass as y}from"../../core/accessorSupport/decorators.js";import u from"../../geometry/Extent.js";import d from"../../geometry/SpatialReference.js";import c from"../../graphic/BuildingGraphicOrigin.js";import h from"../FeatureLayer.js";import m from"./BuildingSublayer.js";import{zeroCapabilities as f}from"../support/capabilities.js";import{popupEnabled as g}from"../support/commonProperties.js";import{getFieldDomain as j}from"../support/featureLayerUtils.js";import{defineFieldProperties as v}from"../support/fieldProperties.js";import b from"../support/FieldsIndex.js";import{unpackFieldNames as L}from"../support/fieldUtils.js";import{fetchIndexInfo as I}from"../support/I3SIndexInfo.js";import{I3SNodePageDefinition as S,I3SMaterialDefinition as F,I3STextureSetDefinition as O,I3SGeometryDefinition as w}from"../support/I3SLayerDefinitions.js";import{webSceneRendererTypes as x}from"../../renderers/support/typeUtils.js";import P from"../../rest/support/Query.js";import{isNumber as q}from"../../support/guards.js";import{createPopupTemplate as T}from"../../support/popupUtils.js";import Q from"../../symbols/support/ElevationInfo.js";import{queryAttributesFromCachedAttributesId as U}from"../../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as E,getFetchPopupTemplate as D}from"../../views/layers/support/popupUtils.js";import{reader as R}from"../../core/accessorSupport/decorators/reader.js";import{enumeration as A}from"../../core/accessorSupport/decorators/enumeration.js";const _=v();let N=class extends(a(p(m))){constructor(e){super(e),this.type="building-component",this.nodePages=null,this.materialDefinitions=[],this.textureSetDefinitions=[],this.geometryDefinitions=[],this.indexInfo=null,this.serviceUpdateTimeStamp=null,this.store=null,this.attributeStorageInfo=[],this.fields=[],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"}initialize(){this._set("graphicOrigin",new c(this))}get parsedUrl(){return this.layer?{path:`${this.layer.parsedUrl?.path}/sublayers/${this.id}`,query:this.layer.parsedUrl?.query}:{path:""}}get fieldsIndex(){return new b(this.fields)}readAssociatedLayer(e,t){const r=this.layer.associatedFeatureServiceItem,o=t.associatedLayerID;return null!=r&&"number"==typeof o?new h({portalItem:r,customParameters:this.customParameters,layerId:o}):null}get objectIdField(){if(null!=this.fields)for(const e of this.fields)if("oid"===e.type)return e.name;return""}get globalIdField(){if(null!=this.fields)for(const e of this.fields)if("global-id"===e.type)return e.name;return""}get displayField(){return null!=this.associatedLayer?this.associatedLayer.displayField:void 0}get apiKey(){return this.layer.apiKey}get customParameters(){return this.layer.customParameters}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 t=null!=e?e.signal:null,r=this._fetchService(t).then(()=>{this.indexInfo=I(this.parsedUrl.path,this.rootNode,this.nodePages,this.customParameters,this.apiKey,n.getLogger(this),t)});return this.addResolvingPromise(r),Promise.resolve(this)}createPopupTemplate(e){return T(this,e)}async _fetchService(e){const t=(await o(this.parsedUrl.path,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(t,{origin:"service",url:this.parsedUrl})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getField(e)?.domain??null;return this.associatedLayer?j(this.associatedLayer,e,t,r):r}getFeatureType(e){return e&&null!=this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return null!=this.associatedLayer?this.associatedLayer.types??[]:[]}get typeIdField(){return null!=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=null!=this.associatedLayer&&this.associatedLayer.capabilities?this.associatedLayer.capabilities:f,{query:t,operations:{supportsQuery:r},data:{supportsZ:o,supportsM:s,isVersioned:i}}=e;return{query:t,operations:{supportsQuery:r},data:{supportsZ:o,supportsM:s,isVersioned:i}}}createQuery(){const e=new P;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryExtent(e||this.createQuery(),t))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryFeatureCount(e||this.createQuery(),t))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryFeatures(e||this.createQuery(),t)).then(e=>{if(e?.features)for(const t of e.features)t.layer=this.layer,t.sourceLayer=this,t.origin=this.graphicOrigin;return e})}async queryObjectIds(e,t){const r=await this._getAssociatedLayerForQuery();return(await r.queryObjectIds(e||this.createQuery(),t)).filter(q)}async queryCachedAttributes(e,t){const r=L(this.fieldsIndex,await E(this,D(this)));return U(this.parsedUrl.path,this.attributeStorageInfo,e,t,r,this.apiKey,this.customParameters)}async queryCachedFeature(e,r){const o=await this.queryCachedAttributes(e,[r]);if(!o||0===o.length)throw new s("scenelayer:feature-not-in-cached-data","Feature not found in cached data");return new t({attributes:o[0],layer:this,sourceLayer:this})}getFieldUsageInfo(e){return this.fieldsIndex.has(e)?{supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1}:{supportsLabelingInfo:!1,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:null!=this.associatedLayer}}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return null!=e&&e.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),null==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([l({readOnly:!0})],N.prototype,"parsedUrl",null),e([l({type:S,readOnly:!0})],N.prototype,"nodePages",void 0),e([l({type:[F],readOnly:!0})],N.prototype,"materialDefinitions",void 0),e([l({type:[O],readOnly:!0})],N.prototype,"textureSetDefinitions",void 0),e([l({type:[w],readOnly:!0})],N.prototype,"geometryDefinitions",void 0),e([l({readOnly:!0})],N.prototype,"serviceUpdateTimeStamp",void 0),e([l({readOnly:!0})],N.prototype,"store",void 0),e([l({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],N.prototype,"rootNode",void 0),e([l({readOnly:!0})],N.prototype,"attributeStorageInfo",void 0),e([l(_.fields)],N.prototype,"fields",void 0),e([l({readOnly:!0})],N.prototype,"fieldsIndex",null),e([l({readOnly:!0,type:h})],N.prototype,"associatedLayer",void 0),e([R("service","associatedLayer",["associatedLayerID"])],N.prototype,"readAssociatedLayer",null),e([l(_.outFields)],N.prototype,"outFields",void 0),e([l({type:String,readOnly:!0})],N.prototype,"objectIdField",null),e([l({type:String,readOnly:!0})],N.prototype,"globalIdField",null),e([l({readOnly:!0,type:String,json:{read:!1}})],N.prototype,"displayField",null),e([l({readOnly:!0,type:String})],N.prototype,"apiKey",null),e([l({readOnly:!0,type:String})],N.prototype,"customParameters",null),e([l({readOnly:!0,type:u})],N.prototype,"fullExtent",null),e([l({readOnly:!0,type:d})],N.prototype,"spatialReference",null),e([l({readOnly:!0})],N.prototype,"version",null),e([l({readOnly:!0,type:Q})],N.prototype,"elevationInfo",null),e([l({readOnly:!0,type:Number})],N.prototype,"minScale",null),e([l({readOnly:!0,type:Number})],N.prototype,"maxScale",null),e([l({readOnly:!0,type:Number})],N.prototype,"effectiveScaleRange",null),e([l({type:["hide","show"],json:{write:!0}})],N.prototype,"listMode",void 0),e([l({types:x,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],N.prototype,"renderer",void 0),e([l({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],N.prototype,"definitionExpression",void 0),e([l(g)],N.prototype,"popupEnabled",void 0),e([l({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],N.prototype,"popupTemplate",void 0),e([l({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],N.prototype,"normalReferenceFrame",void 0),e([l({readOnly:!0,json:{read:!1}})],N.prototype,"defaultPopupTemplate",null),e([l({readOnly:!0})],N.prototype,"graphicOrigin",void 0),e([l()],N.prototype,"types",null),e([l()],N.prototype,"typeIdField",null),e([l({json:{write:!1}}),A(new i({"3DObject":"3d-object",Point:"point"}))],N.prototype,"layerType",void 0),e([l()],N.prototype,"geometryType",null),e([l()],N.prototype,"profile",null),e([l({readOnly:!0,json:{read:!1}})],N.prototype,"capabilities",null),e([l({readOnly:!0})],N.prototype,"statisticsInfo",void 0),N=e([y("esri.layers.buildingSublayers.BuildingComponentSublayer")],N);export{N as default};