12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.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 s}from"../renderers/support/types.js";import i from"../request.js";import o from"../core/Collection.js";import a from"../core/Error.js";import n from"../core/Logger.js";import{isSome as p,isNone as l}from"../core/maybe.js";import{MultiOriginJSONMixin as d}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as y,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as c}from"../core/reactiveUtils.js";import{join as f}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{getProperties as m}from"../core/accessorSupport/utils.js";import"../core/accessorSupport/ensureType.js";import{reader as g}from"../core/accessorSupport/decorators/reader.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as b}from"../core/accessorSupport/PropertyOrigin.js";import I from"./Layer.js";import{APIKeyMixin as j}from"./mixins/APIKeyMixin.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{EditBusLayer as L}from"./mixins/EditBusLayer.js";import{OperationalLayer as S}from"./mixins/OperationalLayer.js";import{PortalLayer as F}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as O}from"./mixins/ScaleRangeLayer.js";import{SceneService as T,SaveOperationType as E}from"./mixins/SceneService.js";import{zeroCapabilities as P}from"./support/capabilities.js";import{elevationInfo as _,labelsVisible as x,legendEnabled as A,popupEnabled as D,screenSizePerspectiveEnabled as U}from"./support/commonProperties.js";import{FeatureReduction as R}from"./support/FeatureReduction.js";import C from"./support/FeatureReductionSelection.js";import{FetchAssociatedFeatureLayer as q}from"./support/FetchAssociatedFeatureLayer.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import N from"./support/FieldsIndex.js";import{fixRendererFields as k,unpackFieldNames as G}from"./support/fieldUtils.js";import{I3SNodePageDefinition as V,I3SMaterialDefinition as K,I3STextureSetDefinition as M,I3SGeometryDefinition as $}from"./support/I3SLayerDefinitions.js";import W from"./support/LabelClass.js";import{reader as z}from"./support/labelingInfo.js";import B from"./support/LayerFloorInfo.js";import{RangeInfo as H}from"./support/RangeInfo.js";import Z from"./support/SceneFilter.js";import{loadStyleRenderer as J}from"../renderers/support/styleUtils.js";import X from"../rest/support/Query.js";import{sceneLayerEditingEnabled as Y}from"../support/featureFlags.js";import{createPopupTemplate as ee}from"../support/popupUtils.js";import{queryAttributesFromCachedAttributesId as te}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as re,getFetchPopupTemplate as se}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as ie}from"../webdoc/support/opacityUtils.js";const oe=["3DObject","Point"],ae=Q();let ne=class extends(L(T(w(S(F(O(d(j(I))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new o,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getFeatureType(t?.feature)?.domains?.[e];return r&&"inherited"!==r.type?r:this.getField(e)?.domain??null}getFeatureType(e){return null!=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 formTemplate(){return p(this.associatedLayer)?this.associatedLayer.formTemplate:null}get fieldsIndex(){return new N(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:V.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get geometryType(){return le[this.profile]||"mesh"}set renderer(e){k(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){const e=p(this.associatedLayer)&&this.associatedLayer.capabilities?this.associatedLayer.capabilities:P,{query:t,editing:{supportsGlobalId:r,supportsRollbackOnFailure:s,supportsUploadWithItemId:i,supportsReturnServiceEditsInSourceSpatialReference:o},data:{supportsZ:a,supportsM:n,isVersioned:l,supportsAttachment:d},operations:{supportsEditing:y,supportsAdd:u,supportsUpdate:c,supportsDelete:f,supportsQuery:h,supportsQueryAttachments:m}}=e,g=e.operations.supportsChangeTracking,v=Y();return{query:t,editing:{supportsGlobalId:r,supportsReturnServiceEditsInSourceSpatialReference:o,supportsRollbackOnFailure:s,supportsGeometryUpdate:!1,supportsUploadWithItemId:i},data:{supportsAttachment:d,supportsZ:a,supportsM:n,isVersioned:l},operations:{supportsQuery:h,supportsQueryAttachments:m,supportsEditing:y&&g,supportsAdd:v&&u&&g,supportsDelete:v&&f&&g,supportsUpdate:c&&g}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.userHasEditingPrivileges}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return p(this.associatedLayer)?this.associatedLayer.infoFor3D:null}get defaultPopupTemplate(){return p(this.associatedLayer)||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e))),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e))),e||void 0}get displayField(){return p(this.associatedLayer)?this.associatedLayer.displayField:null}readProfile(e,t){const r=t.store.profile;return null!=r&&pe[r]?pe[r]:(n.getLogger(this.declaredClass).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){const t=p(e)?e.signal:null,r=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(y).then((()=>this._fetchService(t))).then((()=>Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),p(this.filter)?this.filter.loadGeometries(this.spatialReference):null]))).then((()=>this._validateElevationInfo())).then((()=>this._applyAssociatedLayerOverrides())).then((()=>this._populateFieldUsageInfo())).then((()=>J(this,{origin:"service"},t))).then((()=>k(this.renderer,this.fieldsIndex))).then((()=>this.finishLoadEditablePortalLayer(e)));return this.addResolvingPromise(r),Promise.resolve(this)}async beforeSave(){p(this.filter)&&await this.load()}createQuery(){const e=new X;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,t.sourceLayer=this;return e}))}async queryCachedAttributes(e,t){const r=G(this.fieldsIndex,await re(this,se(this)));return te(this.parsedUrl.path,this.attributeStorageInfo,e,t,r)}async queryCachedFeature(e,r){const s=await this.queryCachedAttributes(e,[r]);if(!s||0===s.length)throw new a("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const i=new t;return i.attributes=s[0],i.layer=this,i.sourceLayer=this,i}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryObjectIds(e||this.createQuery(),t)))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryAttachments(e,t)))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(n.getLogger(this.declaredClass).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return ee(this,e)}_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 a("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new a("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some((t=>t.name===e))}async queryCachedStatistics(e,t){if(await this.load(t),!this.statisticsInfo)throw new a("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new a("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const s of this.statisticsInfo)if(s.name===r.name){const e=f(this.parsedUrl.path,s.href);return i(e,{query:{f:"json",token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new a("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(E.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(E.SAVE,e)}async applyEdits(e,t){const r=await import("./graphics/editingSupport.js");if(await this.load(),l(this.associatedLayer))throw new a(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),r.applyEdits(this,this.associatedLayer.source,e,t)}on(e,t){return super.on(e,t)}validateLayer(e){if(e.layerType&&!oe.includes(e.layerType))throw new a("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new a("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new a("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});function t(e,t){let r=!1,s=!1;if(null==e)r=!0,s=!0;else{const i=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,s=i;break;case"vertex-reference-frame":r=!0,s=!i;break;default:r=!1}}if(!r)throw new a("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!s)throw new a("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}t(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new a("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!(!this.attributeStorageInfo||!this.attributeStorageInfo.some((t=>t.name===e.name))),r=!!(p(this.associatedLayer)&&this.associatedLayer.fields&&this.associatedLayer.fields.some((t=>t&&e.name===t.name))),s={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=s}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides()}_applyAssociatedLayerFieldsOverrides(){if(l(this.associatedLayer)||!this.associatedLayer.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPopupOverrides(){if(l(this.associatedLayer))return;const e=["popupTemplate","popupEnabled"],t=m(this);for(let r=0;r<e.length;r++){const s=e[r],i=this.originIdOf(s),o=this.associatedLayer.originIdOf(s);i<o&&(o===b.SERVICE||o===b.PORTAL_ITEM)&&t.setAtOrigin(s,this.associatedLayer[s],o)}}async _setAssociatedFeatureLayer(e){if(!["mesh-pyramids","points"].includes(this.profile))return;const t=new q(this.parsedUrl,this.portalItem,this.apiKey,e);try{this.associatedLayer=await t.fetch()}catch(r){u(r)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await c((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?n.getLogger(this.declaredClass).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):n.getLogger(this.declaredClass).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;e&&("mesh-pyramids"===this.profile&&"relative-to-scene"===e.mode&&n.getLogger(this.declaredClass).warn(".elevationInfo=","Mesh scene layers don't support relative-to-scene elevation mode"),e.featureExpressionInfo&&"0"!==e.featureExpressionInfo.expression&&n.getLogger(this.declaredClass).warn(".elevationInfo=","Scene layers do not support featureExpressionInfo"))}};e([h({types:{key:"type",base:R,typeMap:{selection:C}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],ne.prototype,"featureReduction",void 0),e([h({type:[H],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],ne.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],ne.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],ne.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],ne.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],ne.prototype,"type",void 0),e([h({...ae.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ne.prototype,"fields",void 0),e([h()],ne.prototype,"types",null),e([h()],ne.prototype,"typeIdField",null),e([h()],ne.prototype,"formTemplate",null),e([h({readOnly:!0})],ne.prototype,"fieldsIndex",null),e([h({type:B,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],ne.prototype,"floorInfo",void 0),e([h(ae.outFields)],ne.prototype,"outFields",void 0),e([h({type:V,readOnly:!0,json:{read:!1}})],ne.prototype,"nodePages",void 0),e([g("service","nodePages",["nodePages","pointNodePages"])],ne.prototype,"readNodePages",null),e([h({type:[K],readOnly:!0})],ne.prototype,"materialDefinitions",void 0),e([h({type:[M],readOnly:!0})],ne.prototype,"textureSetDefinitions",void 0),e([h({type:[$],readOnly:!0})],ne.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],ne.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],ne.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],ne.prototype,"statisticsInfo",void 0),e([h({type:o.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],ne.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ne.prototype,"definitionExpression",void 0),e([h({type:Z,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],ne.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],ne.prototype,"path",void 0),e([h(_)],ne.prototype,"elevationInfo",null),e([h({type:String})],ne.prototype,"geometryType",null),e([h(x)],ne.prototype,"labelsVisible",void 0),e([h({type:[W],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:z},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:z},write:!0}})],ne.prototype,"labelingInfo",void 0),e([h(A)],ne.prototype,"legendEnabled",void 0),e([h({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?ie(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],ne.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ne.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ne.prototype,"semantic",void 0),e([h({types:s,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],ne.prototype,"renderer",null),e([h({json:{read:!1}})],ne.prototype,"cachedDrawingInfo",void 0),e([g("service","cachedDrawingInfo")],ne.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],ne.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],ne.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ne.prototype,"infoFor3D",null),e([h(D)],ne.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],ne.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],ne.prototype,"defaultPopupTemplate",null),e([h({type:String,json:{read:!1}})],ne.prototype,"objectIdField",void 0),e([g("service","objectIdField",["objectIdField","fields"])],ne.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],ne.prototype,"globalIdField",void 0),e([g("service","globalIdField",["globalIdField","fields"])],ne.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],ne.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],ne.prototype,"profile",void 0),e([g("service","profile",["store.profile"])],ne.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],ne.prototype,"normalReferenceFrame",void 0),e([h(U)],ne.prototype,"screenSizePerspectiveEnabled",void 0),ne=e([v("esri.layers.SceneLayer")],ne);const pe={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},le={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},de=ne;export{de as default};
|