@arcgis/core 4.28.0-rc.2 → 4.28.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0e354096ad8817971eed.js → 02d235849ba93541d7ad.js} +1 -1
- package/assets/esri/core/workers/chunks/0422c5160491fbcf01dc.js +1 -0
- package/assets/esri/core/workers/chunks/224e79f6c172da444e0a.js +1 -0
- package/assets/esri/core/workers/chunks/{ca3d5803cdf035d7389d.js → 30776102fbab294bfe7b.js} +1 -1
- package/assets/esri/core/workers/chunks/{61dec8399919b278b636.js → 3ac9001b19a90faf5573.js} +1 -1
- package/assets/esri/core/workers/chunks/41081c921037e543a22f.js +1 -0
- package/assets/esri/core/workers/chunks/4564a7885d045a850887.js +1 -0
- package/assets/esri/core/workers/chunks/4adf3a8c6b49c381a633.js +1 -0
- package/assets/esri/core/workers/chunks/{2721aa6b6941b28b9758.js → 63c8bf00120a4e67f5b0.js} +1 -1
- package/assets/esri/core/workers/chunks/74951370a341f02d3714.js +1 -0
- package/assets/esri/core/workers/chunks/{fa6103e3d4e857b0035b.js → 78e2fa121760383b08ec.js} +9 -6
- package/assets/esri/core/workers/chunks/7b8377b3a9f78f9d3613.js +1 -0
- package/assets/esri/core/workers/chunks/{fd28400141a6751327ae.js → 7cf7f2b991a7cbdad2ce.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a723bb4a341f645e5fe.js → 83b8141f0c80e3448012.js} +1 -1
- package/assets/esri/core/workers/chunks/934c32c49bb9e21482fd.js +1 -0
- package/assets/esri/core/workers/chunks/969a82b674eda9f8720f.js +1 -0
- package/assets/esri/core/workers/chunks/a1e16c33f1843dbdce26.js +1 -0
- package/assets/esri/core/workers/chunks/{d07235ce2765a25b9be4.js → a50ec5b647a160199cb2.js} +1 -1
- package/assets/esri/core/workers/chunks/{77923afde29ae1ff10ca.js → b6e86e179f99b5cf8dff.js} +1 -1
- package/assets/esri/core/workers/chunks/c3ddf5dbc34f118002df.js +1 -0
- package/assets/esri/core/workers/chunks/{7b3d5f044c96e2c2af11.js → d191267d91a53db42956.js} +1 -1
- package/assets/esri/core/workers/chunks/ffa330a19a09679212fb.js +1 -0
- package/assets/esri/themes/base/widgets/_BasemapGallery.scss +3 -9
- package/assets/esri/themes/base/widgets/_Legend.scss +1 -1
- package/assets/esri/themes/base/widgets/_TimeZoneLabel.scss +3 -3
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/interfaces.d.ts +1254 -262
- package/kernel.js +1 -1
- package/layers/GroupLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/queryValidationUtils.js +1 -1
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/save/groupLayerUtils.js +1 -1
- package/layers/save/utils.js +1 -1
- package/layers/support/ImageElement.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/Subtype.d.ts +4 -0
- package/layers/support/Subtype.js +1 -1
- package/layers/support/imageryRendererUtils.js +1 -1
- package/networks/Network.js +1 -1
- package/package.json +1 -1
- package/portal/support/jsonContext.js +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/rest/featureService/FeatureService.d.ts +4 -0
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/featureService/utils.d.ts +4 -0
- package/rest/query/operations/query.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/versionManagement/VersionManagementService.d.ts +4 -0
- package/versionManagement/VersionManagementService.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/input/handlers/KeyPan.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/DragManipulation.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
- package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/support/PBFDecoder.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOPool.js +5 -0
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -6
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/DirectionalPad.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/TimeZoneLabel.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/00da3c16741a9bc47f3a.js +0 -1
- package/assets/esri/core/workers/chunks/0e4646d14fa0775bf463.js +0 -1
- package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +0 -1
- package/assets/esri/core/workers/chunks/51b8913dff24e693bd25.js +0 -1
- package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +0 -1
- package/assets/esri/core/workers/chunks/7388fd97e7b1a2142744.js +0 -1
- package/assets/esri/core/workers/chunks/92d8f75e616afa5c761e.js +0 -1
- package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +0 -1
- package/assets/esri/core/workers/chunks/b251d8a856dc8b9406e0.js +0 -1
- package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +0 -1
- package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +0 -1
- package/assets/esri/core/workers/chunks/fc95b1a36ed68b851400.js +0 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -4
- package/widgets/DirectionalPad.d.ts +0 -4
package/kernel.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as r}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="4.28";let t,i=e;i="4.28.0-rc.
|
|
5
|
+
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as r}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="4.28";let t,i=e;i="4.28.0-rc.3";function n(o){t=o}function m(s){const r=t?.findCredential(s);return r?.token?o(s,"token",r.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,r as revision,n as setId,e as version};
|
package/layers/GroupLayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/CollectionFlattener.js";import{loadAll as t}from"../core/loadAll.js";import i from"../core/Logger.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{debounce as o,throwIfAbortError as a}from"../core/promiseUtils.js";import{watch as l,syncAndInitial as p,on as n,sync as d}from"../core/reactiveUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{getProperties as c}from"../core/accessorSupport/utils.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{writer as u}from"../core/accessorSupport/decorators/writer.js";import{OriginId as b}from"../core/accessorSupport/PropertyOrigin.js";import v from"./Layer.js";import{BlendLayer as f}from"./mixins/BlendLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as g}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as w}from"./mixins/ScaleRangeLayer.js";import{layerLookupMap as L}from"./support/lazyLayerLoader.js";import S from"../portal/PortalItem.js";import{createFlattenedTablesCollection as _}from"../support/collectionUtils.js";import{LayersMixin as I}from"../support/LayersMixin.js";import{TablesMixin as O}from"../support/TablesMixin.js";import{WebSceneTag as M}from"../support/tagSymbols.js";import{SaveOperationType as x}from"../webdoc/interfaces.js";import{beforeSave as P}from"../webdoc/support/saveUtils.js";import{getLayerJSON as A}from"../webdoc/support/writeUtils.js";let V=class extends(f(w(j(g(O(I(s(v)))))))){constructor(e){super(e),this.allLayers=new r({getCollections:()=>[this.layers],getChildrenFunction:e=>"layers"in e?e.layers:null}),this.allTables=_(this),this.fullExtent=void 0,this.operationalLayerType="GroupLayer",this.spatialReference=void 0,this.type="group",this._debouncedSaveOperations=o((async(e,r,t)=>{const{save:i,saveAs:s}=await import("./save/groupLayerUtils.js");switch(e){case x.SAVE:return i(this,r);case x.SAVE_AS:return s(this,t,r)}}))}initialize(){this._enforceVisibility(this.visibilityMode,this.visible),this.addHandles([l((()=>{let e=this.parent;for(;e&&"parent"in e&&e.parent;)e=e.parent;return e&&M in e}),(e=>{const r="prevent-adding-tables";this.removeHandles(r),e&&(this.tables.removeAll(),this.addHandles(n((()=>this.tables),"before-add",(e=>{e.preventDefault(),i.getLogger(this).errorOnce("tables","tables in group layers in a webscene are not supported. Please move the tables from the group layer to the webscene if you want to persist them.")})),r))}),p),l((()=>this.visible),this._onVisibilityChange.bind(this),d)])}destroy(){this.allLayers.destroy(),this.allTables.destroy()}get sourceIsPortalItem(){return this.portalItem&&this.originIdOf("portalItem")===b.USER}_writeLayers(e,r,t,i){const s=[];if(!e)return s;e.forEach((e=>{const r=A(e,i.webmap?i.webmap.getLayerJSONFromResourceInfo(e):null,i);r?.layerType&&s.push(r)})),r.layers=s}set portalItem(e){this._set("portalItem",e)}readPortalItem(e,r,t){const{itemId:i,layerType:s}=r;if("GroupLayer"===s&&i)return new S({id:i,portal:t?.portal})}writePortalItem(e,r){e?.id&&(r.itemId=e.id)}set visibilityMode(e){const r=this._get("visibilityMode")!==e;this._set("visibilityMode",e),r&&this._enforceVisibility(e,this.visible)}async beforeSave(){return P(this)}load(e){const r=this.loadFromPortal({supportedTypes:["Feature Service","Feature Collection","Group Layer","Scene Service"],layerModuleTypeMap:L},e).catch((e=>{if(a(e),this.sourceIsPortalItem)throw e}));return this.addResolvingPromise(r),Promise.resolve(this)}async loadAll(){return t(this,(e=>{e(this.layers,this.tables)}))}async save(e){return this._debouncedSaveOperations(x.SAVE,e)}async saveAs(e,r){return this._debouncedSaveOperations(x.SAVE_AS,r,e)}layerAdded(e){e.visible&&"exclusive"===this.visibilityMode?this._turnOffOtherLayers(e):"inherited"===this.visibilityMode&&(e.visible=this.visible),this.hasHandles(e.uid)?console.error(`Layer readded to Grouplayer: uid=${e.uid}`):this.addHandles(l((()=>e.visible),(r=>this._onChildVisibilityChange(e,r)),d),e.uid)}layerRemoved(e){this.removeHandles(e.uid),this._enforceVisibility(this.visibilityMode,this.visible)}_turnOffOtherLayers(e){this.layers.forEach((r=>{r!==e&&(r.visible=!1)}))}_enforceVisibility(e,r){if(!c(this).initialized)return;const t=this.layers;let i=t.find((e=>e.visible));switch(e){case"exclusive":t.length&&!i&&(i=t.at(0),i.visible=!0),this._turnOffOtherLayers(i);break;case"inherited":t.forEach((e=>{e.visible=r}))}}_onVisibilityChange(e){"inherited"===this.visibilityMode&&this.layers.forEach((r=>{r.visible=e}))}_onChildVisibilityChange(e,r){switch(this.visibilityMode){case"exclusive":r?this._turnOffOtherLayers(e):this._isAnyLayerVisible()||(e.visible=!0);break;case"inherited":e.visible=this.visible}}_isAnyLayerVisible(){return this.layers.some((e=>e.visible))}};e([y({readOnly:!0,dependsOn:[]})],V.prototype,"allLayers",void 0),e([y({readOnly:!0})],V.prototype,"allTables",void 0),e([y({json:{read:!0,write:!0}})],V.prototype,"blendMode",void 0),e([y()],V.prototype,"fullExtent",void 0),e([y({readOnly:!0})],V.prototype,"sourceIsPortalItem",null),e([y({json:{read:!1,write:{ignoreOrigin:!0}}})],V.prototype,"layers",void 0),e([u("layers")],V.prototype,"_writeLayers",null),e([y({type:["GroupLayer"]})],V.prototype,"operationalLayerType",void 0),e([y({json:{origins:{"web-map":{read:!1,write:{overridePolicy(e,r,t){return{enabled:"Group Layer"===e?.type&&t?.initiator!==this}}}},"web-scene":{read:!1,write:!1}}}})],V.prototype,"portalItem",null),e([h("web-map","portalItem",["itemId"])],V.prototype,"readPortalItem",null),e([u("web-map","portalItem",{itemId:{type:String}})],V.prototype,"writePortalItem",null),e([y()],V.prototype,"spatialReference",void 0),e([y({json:{read:!1},readOnly:!0,value:"group"})],V.prototype,"type",void 0),e([y({type:["independent","inherited","exclusive"],value:"independent",json:{write:!0,origins:{"web-map":{type:["independent","exclusive"],write:(e,r,t)=>{"inherited"!==e&&(r[t]=e)}}}}})],V.prototype,"visibilityMode",null),V=e([m("esri.layers.GroupLayer")],V);const E=V;export{E as default};
|
package/layers/SceneLayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
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 i}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import a from"../core/Collection.js";import n from"../core/Error.js";import l from"../core/Logger.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as d,isAbortError as y}from"../core/promiseUtils.js";import{whenOnce as u}from"../core/reactiveUtils.js";import{join as c}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as v}from"../core/accessorSupport/PropertyOrigin.js";import b from"./Layer.js";import{APIKeyMixin as I}from"./mixins/APIKeyMixin.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{EditBusLayer as L}from"./mixins/EditBusLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as F}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{SceneService as _,SaveOperationType as O}from"./mixins/SceneService.js";import{isHostedAgolService as E}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as A}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as P}from"./support/capabilities.js";import{elevationInfo as T,labelsVisible as D,legendEnabled as U,popupEnabled as x,screenSizePerspectiveEnabled as R}from"./support/commonProperties.js";import{computeEffectiveEditingEnabled as q,getGlobalIdToObjectIdMap as C}from"./support/featureLayerUtils.js";import{FeatureReduction as G}from"./support/FeatureReduction.js";import Q from"./support/FeatureReductionSelection.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import k from"./support/FieldsIndex.js";import{fixRendererFields as V,unpackFieldNames as K}from"./support/fieldUtils.js";import{I3SNodePageDefinition as H,I3SMaterialDefinition as M,I3STextureSetDefinition as $,I3SGeometryDefinition as z}from"./support/I3SLayerDefinitions.js";import W from"./support/LabelClass.js";import{reader as B}from"./support/labelingInfo.js";import Z from"./support/LayerFloorInfo.js";import{layerLookupMap as J}from"./support/lazyLayerLoader.js";import{RangeInfo as X}from"./support/RangeInfo.js";import Y from"./support/SceneFilter.js";import{loadStyleRenderer as ee}from"../renderers/support/styleUtils.js";import te from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as re,elevationModeUnsupportedMessage as ie,featureExpressionUnsupportedMessage as se}from"../support/elevationInfoUtils.js";import{sceneLayerEditingEnabled as oe}from"../support/featureFlags.js";import{createPopupTemplate as ae}from"../support/popupUtils.js";import{queryAttributesFromCachedAttributesId as ne}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as le,getFetchPopupTemplate as pe}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as de}from"../webdoc/support/opacityUtils.js";const ye=new Set(["3DObject","Point"]),ue=N();let ce=class extends(L(_(w(j(F(S(p(I(o(b)))))))))){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 a,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,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null)}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 e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new k(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:H.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&q(this.associatedLayer)}get geometryType(){return fe[this.profile]||"mesh"}set renderer(e){V(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(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:P;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,I=!!this.associatedLayer?.infoFor3D&&oe();return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:I&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:I&&c&&b,supportsDelete:I&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return 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 this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&he[r]?he[r]:(l.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=null!=e?e.signal:null;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(d),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await ee(this,{origin:"service"},t),V(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){l.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new te;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],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 queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=K(this.fieldsIndex,await le(this,pe(this)));return ne(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new n("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s}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:(l.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return ae(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new n("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 n("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 n("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new n("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const i of this.statisticsInfo)if(i.name===r.name){const e=c(this.parsedUrl.path,i.href);return s(e,{query:{f:"json",token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new n("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(O.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(O.SAVE,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");let i=t;await this.load();const s=this.associatedLayer;if(!s)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");await s.load();const{globalIdField:o}=s;return E(s.url)&&s.infoFor3D&&null!=e.deleteFeatures&&null!=o&&(i={...i,globalIdToObjectId:await C(s,e.deleteFeatures,o)}),r(this,s.source,e,i)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}on(e,t){return super.on(e,t)}validateLayer(e){if(e.layerType&&!ye.has(e.layerType))throw new n("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 n("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 n("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,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new n("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new n("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 n("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=!!this.associatedLayer?.fields?.some((t=>t&&e.name===t.name)),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!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(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled"],t=f(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===v.SERVICE||o===v.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.editingInfo?.lastEditDate,t=this.associatedLayer?.serverGens,r=this.associatedLayer?.getAtOrigin("fullExtent","service");if(!oe()||null==this.associatedLayer?.infoFor3D||!r||!E(this.associatedLayer?.url)||!e||this.serviceUpdateTimeStamp?.lastUpdate===e.getTime()||!this.serviceUpdateTimeStamp&&t?.minServerGen===t?.serverGen)return;f(this).setAtOrigin("fullExtent",r.clone(),v.SERVICE)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await A(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,apiKey:this.apiKey,signal:e}),s=await J.FeatureLayer();this.associatedLayer=new s({url:t,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await u((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?l.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):l.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&re(l.getLogger(this),ie("Mesh scene layers","relative-to-scene",e)),re(l.getLogger(this),se("Scene layers",e))}};e([h({types:{key:"type",base:G,typeMap:{selection:Q}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],ce.prototype,"featureReduction",void 0),e([h({type:[X],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],ce.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],ce.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],ce.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],ce.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],ce.prototype,"type",void 0),e([h({...ue.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"fields",void 0),e([h()],ce.prototype,"types",null),e([h()],ce.prototype,"typeIdField",null),e([h()],ce.prototype,"templates",null),e([h()],ce.prototype,"formTemplate",null),e([h({readOnly:!0,clonable:!1})],ce.prototype,"fieldsIndex",null),e([h({type:Z,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],ce.prototype,"floorInfo",void 0),e([h(ue.outFields)],ce.prototype,"outFields",void 0),e([h({type:H,readOnly:!0,json:{read:!1}})],ce.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],ce.prototype,"readNodePages",null),e([h({type:[M],readOnly:!0})],ce.prototype,"materialDefinitions",void 0),e([h({type:[$],readOnly:!0})],ce.prototype,"textureSetDefinitions",void 0),e([h({type:[z],readOnly:!0})],ce.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],ce.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],ce.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],ce.prototype,"statisticsInfo",void 0),e([h({type:a.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],ce.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ce.prototype,"definitionExpression",void 0),e([h({type:Y,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],ce.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],ce.prototype,"path",void 0),e([h(T)],ce.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],ce.prototype,"effectiveEditingEnabled",null),e([h({type:String})],ce.prototype,"geometryType",null),e([h(D)],ce.prototype,"labelsVisible",void 0),e([h({type:[W],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:B},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:B},write:!0}})],ce.prototype,"labelingInfo",void 0),e([h(U)],ce.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?de(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],ce.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"semantic",void 0),e([h({types:i,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],ce.prototype,"renderer",null),e([h({json:{read:!1}})],ce.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],ce.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],ce.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ce.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ce.prototype,"relationships",null),e([h(x)],ce.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],ce.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"defaultPopupTemplate",null),e([h({type:String,json:{read:!1}})],ce.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],ce.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],ce.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],ce.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],ce.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],ce.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],ce.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],ce.prototype,"normalReferenceFrame",void 0),e([h(R)],ce.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"serviceItemId",void 0),ce=e([g("esri.layers.SceneLayer")],ce);const he={"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"},fe={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},me=ce;export{me as default};
|
|
5
|
+
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 i}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import a from"../core/Collection.js";import n from"../core/Error.js";import l from"../core/Logger.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as d,isAbortError as y}from"../core/promiseUtils.js";import{whenOnce as u}from"../core/reactiveUtils.js";import{join as c}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as v}from"../core/accessorSupport/PropertyOrigin.js";import b from"./Layer.js";import{APIKeyMixin as I}from"./mixins/APIKeyMixin.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{EditBusLayer as L}from"./mixins/EditBusLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as F}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{SceneService as _,SaveOperationType as O}from"./mixins/SceneService.js";import{isHostedAgolService as E}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as A}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as P}from"./support/capabilities.js";import{elevationInfo as T,labelsVisible as D,legendEnabled as U,popupEnabled as x,screenSizePerspectiveEnabled as R}from"./support/commonProperties.js";import{computeEffectiveEditingEnabled as q,getGlobalIdToObjectIdMap as C}from"./support/featureLayerUtils.js";import{FeatureReduction as G}from"./support/FeatureReduction.js";import Q from"./support/FeatureReductionSelection.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import k from"./support/FieldsIndex.js";import{fixRendererFields as V,unpackFieldNames as $}from"./support/fieldUtils.js";import{I3SNodePageDefinition as K,I3SMaterialDefinition as H,I3STextureSetDefinition as M,I3SGeometryDefinition as z}from"./support/I3SLayerDefinitions.js";import W from"./support/LabelClass.js";import{reader as B}from"./support/labelingInfo.js";import Z from"./support/LayerFloorInfo.js";import{layerLookupMap as J}from"./support/lazyLayerLoader.js";import{RangeInfo as X}from"./support/RangeInfo.js";import Y from"./support/SceneFilter.js";import{loadStyleRenderer as ee}from"../renderers/support/styleUtils.js";import te from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as re,elevationModeUnsupportedMessage as ie,featureExpressionUnsupportedMessage as se}from"../support/elevationInfoUtils.js";import{sceneLayerEditingEnabled as oe}from"../support/featureFlags.js";import{createPopupTemplate as ae}from"../support/popupUtils.js";import{queryAttributesFromCachedAttributesId as ne}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as le,getFetchPopupTemplate as pe}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as de}from"../webdoc/support/opacityUtils.js";const ye=new Set(["3DObject","Point"]),ue=N();let ce=class extends(L(_(w(j(F(S(p(I(o(b)))))))))){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 a,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,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null)}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 e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new k(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:K.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&q(this.associatedLayer)}get geometryType(){return fe[this.profile]||"mesh"}set renderer(e){V(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(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:P;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,I=!!this.associatedLayer?.infoFor3D&&oe();return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:I&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:I&&c&&b,supportsDelete:I&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return 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 this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&he[r]?he[r]:(l.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=null!=e?e.signal:null;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(d),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await ee(this,{origin:"service"},t),V(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){l.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new te;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],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 queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=$(this.fieldsIndex,await le(this,pe(this)));return ne(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new n("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s}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:(l.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return ae(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new n("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 n("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 n("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new n("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const i of this.statisticsInfo)if(i.name===r.name){const e=c(this.parsedUrl.path,i.href);return s(e,{query:{f:"json",token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new n("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(O.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(O.SAVE,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");let i=t;await this.load();const s=this.associatedLayer;if(!s)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");await s.load();const{globalIdField:o}=s,a=!!s.infoFor3D,l=i?.globalIdUsed??!0;if(a&&null==o)throw new n(`${this.type}-layer:not-editable`,"Valid globalIdField expected on editable SceneLayer");if(a&&!l)throw new n(`${this.type}-layer:globalid-required`,"globalIdUsed must not be false for SceneLayer editing as globalIds are required.");return E(s.url)&&a&&null!=e.deleteFeatures&&null!=o&&(i={...i,globalIdToObjectId:await C(s,e.deleteFeatures,o)}),r(this,s.source,e,i)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}on(e,t){return super.on(e,t)}validateLayer(e){if(e.layerType&&!ye.has(e.layerType))throw new n("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 n("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 n("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,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new n("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new n("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 n("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=!!this.associatedLayer?.fields?.some((t=>t&&e.name===t.name)),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!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(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled"],t=f(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===v.SERVICE||o===v.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.editingInfo?.lastEditDate,t=this.associatedLayer?.serverGens,r=this.associatedLayer?.getAtOrigin("fullExtent","service");if(!oe()||null==this.associatedLayer?.infoFor3D||!r||!E(this.associatedLayer?.url)||!e||this.serviceUpdateTimeStamp?.lastUpdate===e.getTime()||!this.serviceUpdateTimeStamp&&t?.minServerGen===t?.serverGen)return;f(this).setAtOrigin("fullExtent",r.clone(),v.SERVICE)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await A(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,apiKey:this.apiKey,signal:e}),s=await J.FeatureLayer();this.associatedLayer=new s({url:t,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await u((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?l.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):l.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&re(l.getLogger(this),ie("Mesh scene layers","relative-to-scene",e)),re(l.getLogger(this),se("Scene layers",e))}};e([h({types:{key:"type",base:G,typeMap:{selection:Q}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],ce.prototype,"featureReduction",void 0),e([h({type:[X],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],ce.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],ce.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],ce.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],ce.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],ce.prototype,"type",void 0),e([h({...ue.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"fields",void 0),e([h()],ce.prototype,"types",null),e([h()],ce.prototype,"typeIdField",null),e([h()],ce.prototype,"templates",null),e([h()],ce.prototype,"formTemplate",null),e([h({readOnly:!0,clonable:!1})],ce.prototype,"fieldsIndex",null),e([h({type:Z,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],ce.prototype,"floorInfo",void 0),e([h(ue.outFields)],ce.prototype,"outFields",void 0),e([h({type:K,readOnly:!0,json:{read:!1}})],ce.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],ce.prototype,"readNodePages",null),e([h({type:[H],readOnly:!0})],ce.prototype,"materialDefinitions",void 0),e([h({type:[M],readOnly:!0})],ce.prototype,"textureSetDefinitions",void 0),e([h({type:[z],readOnly:!0})],ce.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],ce.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],ce.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],ce.prototype,"statisticsInfo",void 0),e([h({type:a.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],ce.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ce.prototype,"definitionExpression",void 0),e([h({type:Y,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],ce.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],ce.prototype,"path",void 0),e([h(T)],ce.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],ce.prototype,"effectiveEditingEnabled",null),e([h({type:String})],ce.prototype,"geometryType",null),e([h(D)],ce.prototype,"labelsVisible",void 0),e([h({type:[W],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:B},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:B},write:!0}})],ce.prototype,"labelingInfo",void 0),e([h(U)],ce.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?de(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],ce.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"semantic",void 0),e([h({types:i,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],ce.prototype,"renderer",null),e([h({json:{read:!1}})],ce.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],ce.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],ce.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ce.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ce.prototype,"relationships",null),e([h(x)],ce.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],ce.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"defaultPopupTemplate",null),e([h({type:String,json:{read:!1}})],ce.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],ce.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],ce.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],ce.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],ce.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],ce.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],ce.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],ce.prototype,"normalReferenceFrame",void 0),e([h(R)],ce.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"serviceItemId",void 0),ce=e([g("esri.layers.SceneLayer")],ce);const he={"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"},fe={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},me=ce;export{me as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import has from"../../../core/has.js";import i from"../../../core/Logger.js";import s from"../../../core/PooledArray.js";import{EsriPromiseMixin as a}from"../../../core/Promise.js";import{isAbortError as r}from"../../../core/promiseUtils.js";import{watch as d,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as u}from"../../../geometry/projection/projectBoundingRect.js";import{create as _,intersectsSphere as c}from"../../../geometry/support/aaBoundingRect.js";import{makeDehydratedPoint as p}from"../dehydratedPoint.js";import{PromiseQueue as g}from"../../support/PromiseQueue.js";import{viewingModeFromString as m}from"../../../views/ViewingMode.js";import{I3SClientNodeLoader as y}from"../../../views/3d/layers/i3s/I3SClientNodeLoader.js";import{addCallback as f}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as x}from"../../../views/3d/layers/i3s/I3SIndex.js";import b from"../../../views/3d/layers/i3s/I3SLodHandling.js";import{NodeState as N,CacheState as w}from"../../../views/3d/layers/i3s/I3SNode.js";import v from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as C}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as D,getIndexCrs as L,findIntersectingNodes as S}from"../../../views/3d/layers/i3s/I3SUtil.js";import V from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{FadeDirection as I}from"../../../views/3d/layers/support/I3SLayerView.js";import{toBoundingRect as A}from"../../../views/3d/support/extentUtils.js";import{ClientType as M,maxDownloadSlots as O}from"../../../views/3d/support/index.js";import{minQuality as F}from"../../../views/3d/support/MemoryController.js";import{extractSafeScaleBounds as P,scaleBoundsPredicate as U}from"../../../views/support/layerViewUtils.js";import{noBudget as q}from"../../../views/support/Scheduler.js";const G="esri.layers.graphics.controllers.I3SOnDemandController",j=i.getLogger(G),T=100,Q=2,E=1e4,H=1e-4,k=1.2,R=500,B=1.5;let z=class extends(a(t)){get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store?.lodType}get isGraphics3D(){return"points"===this.layer.profile}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(null==this.layer.priority||"High"===this.layer.priority)}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(M.I3S_INDEX);return new C(e,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(M.I3S_DATA);return new C(e,this.layer.apiKey)}get crsVertex(){return D(this.layer)}get crsIndex(){return L(this.layer)}get layer(){return this.layerView.i3slayer}get running(){return this.updating}get rootNodeVisible(){if(this._index){const e=this._index.rootNode;if(e)return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}get requiredAttributes(){return this._requiredAttributes}constructor(e){super(e),this.screenSizeFactor=0,this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.scaleVisibilityEnabled=!0,this.worker=null,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._idleStateCallbacks=null,this._newLoadingNodes=new s({deallocator:null}),this._loadedNodeScales=new Map,this._modificationsNodeFilteringArray=new s,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._idleQueue=new g,this._elevationUpdateNodes=new s({deallocator:null}),this._errorCount=0}initialize(){const{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new b(e),this._defaultGeometrySchema=t.store.defaultGeometrySchema,this.disableIDBCache=has("disable-feature:idb-cache"),"fields"in t&&(this._fields=t.fields,this._attributeStorageInfo=t.attributeStorageInfo),this.addResolvingPromise(Promise.all([t.indexInfo,t.when(),e.when()]).then((([i])=>{if(this.destroyed||!e||e.destroyed||!i)return;const{view:s,clientGeometry:a}=e,{resourceController:r}=s;if(this._setClippingArea(s.clippingArea),this.addHandles([d((()=>s?.pointsOfInterest?.focus?.renderLocation),(e=>this._pointOfInterestChanged(e)),o),d((()=>s.quality),(()=>this._setCameraDirty()),n),d((()=>e.contentVisible),(e=>{const t=e?()=>this._updateIdleState(!0):()=>this._updateViewData(),i=e?()=>this._updateIdleState(!1):()=>{};e&&null!=this._index&&this._index.invalidateAllElevationRanges(),this._idleStateCallbacks?(e||this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=r.scheduler.registerIdleStateCallbacks(t,i)}),o),f(e.view.resourceController.scheduler,this),d((()=>e.uncompressedTextureDownsamplingEnabled),(()=>this.restartNodeLoading())),d((()=>[this.featureTarget,this.fixedFeatureTarget]),(()=>{this._setCameraDirty(),this._stableFeatureLOD=!1})),d((()=>s.state?.contentCamera),(()=>this._setCameraDirty())),d((()=>t.elevationInfo),(e=>this._elevationInfoChanged(e))),d((()=>t.effectiveScaleRange),(()=>this._scaleBoundsChanged())),d((()=>e.lodFactor),(()=>this._setCameraDirty())),d((()=>e.availableFields),(()=>this._requiredFieldsChange())),d((()=>e.holeFilling),(e=>null!=this._index&&(this._index.holeFilling=e)))]),this._updateScaleHandles(),this._viewportQueries=new V(this.crsIndex,s.renderCoordsHelper,s.state.contentCamera,!s.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?s.basemapTerrain:s.elevationProvider,m(s.viewingMode),this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._clientNodeLoader=new y(this.layer.uid,this.crsIndex,s.renderCoordsHelper.spatialReference,s.resourceController.memoryController,this.worker),this._index=new x(t,i,this.indexStreamController,this._clientNodeLoader,this._viewportQueries,j,e.holeFilling,(t=>e.isNodeLoaded(t)),(t=>e.isNodeReloading(t)),(e=>this._shouldLoadNode(e)),(e=>this._enableFromGPUCache(e,N.Leaf)),(e=>this._needsUpdate(e)),(()=>!this.indexStreamController.busy),(t=>e.computeVisibilityObb?e.computeVisibilityObb(t):null),e?.computeNodeFiltering?t=>e.computeNodeFiltering(t):void 0),this._index.updateElevationInfo(this.layer.elevationInfo,this.isMeshPyramid||this.isGraphics3D),this._index.imModificationsChanged(!!e.hasModifications),this._index.layerFilterChanged(!!e.hasGeometryFilter),null!=a){for(const e of a)this._addMesh(e.mesh,e.oid);this.addHandles(a.on("change",(e=>{for(const t of e.removed)this._removeMesh(t.oid);for(const t of e.added)this._addMesh(t.mesh,t.oid)})))}this._startNodeLoading()}))),this._tmpPoint=p(0,0,0,this.crsIndex)}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;null!=t&&i?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll((e=>{const i=t.getNode(e);null!=i&&this._modificationsNodeFilteringArray.push(i)})),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._nodeLoader=null,K.prune(),null!=W&&(W.hide(),W=null)}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map((i=>{const s=$(e,i),a=$(t,i);return s>=0&&a>=0?{index:s,name:t[a].name,field:t[a],attributeStorageInfo:e[s]}:null})).filter((e=>null!=e&&e.name!==i))}_requiredFieldsChange(){const e=this._getRequiredAttributes();X(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=_();A(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){null!=this._viewportQueries&&(this._viewportQueries.setPointOfInterest(e),null!=this._index&&(this._index.progressiveLoadPenalty=J.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),null!=this._viewportQueries&&null!=this._index&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}_addMesh(e,t){if(null==this._index)return;const i=this._clientNodeLoader.createMeshNodeInfo(e,t),s=this._index.addClientNodeToIndex(i.id,i.mbs);this._clientNodeLoader.addMeshNode(s,i),this._evaluateUpdating(),this.notifyChange("rootNodeVisible")}_removeMesh(e){const t=this._clientNodeLoader.getMeshNodeIndex(e);if(null!=t){if(null==this._index)throw new Error("delayed removal of client side i3s node geometry not supported yet.");{const e=(e,t)=>{this.layerView.removeNode(t),this._loadedNodeScales.delete(t),this._clientNodeLoader.removeNode(e),this.layerView.deleteCachedNodeData&&null!=e&&this.layerView.deleteCachedNodeData(e),this.layerView.deleteCachedGPUData?.(this.layerView.loadCachedGPUData?.(t))},i=(e,t,i)=>{this._clientNodeLoader.updateNodeIndex(e,t,i),this.layerView.updateNodeIndex&&this.layerView.updateNodeIndex(t,i)};this._index.removeClientNodeFromIndex(t,e,i),this.notifyChange("rootNodeVisible")}}}updateElevationChanged(e,t){const i=this._index;if(null==i?.rootNode||null==t)return null;this.crsIndex.equals(t)||(u(e,t,Y,this.crsIndex),e=Y);const s=this._elevationUpdateNodes;return s.clear(),S(e,i.rootNode,i,(e=>s.push(e.index))),s.length&&(s.forAll((e=>i.updateElevationChanged(e))),this._setCameraDirty()),s}removeAllGeometryObbs(){null!=this._index&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return null!=this._viewportQueries?this._viewportQueries.getRenderMbs(e):null}_elevationInfoChanged(e){null!=this._index&&(this._index.updateElevationInfo(e,this.isMeshPyramid||this.isGraphics3D),this._setCameraDirty())}_updateScaleHandles(){const e="scale-bounds";this.removeHandles(e),this._areScaleBoundsActive&&this.addHandles(this.layerView.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),e)}_scaleBoundsChanged(){this._areScaleBoundsActive||this._loadedNodeScales.clear(),this._updateScaleHandles(),this._setCameraDirty()}_scaleUpdateHandler(e){this._updateScaleInBoundingRect(e.extent,e.spatialReference),this._setCameraDirty()}_updateScaleInBoundingRect(e,t){const i=this._index;if(null==i)return;null!=i.rootNode&&u(e,t,Y,this.crsIndex)&&this._loadedNodeScales.forEach(((e,t)=>{const s=i.getNode(t);null!=s&&c(Y,s.mbs)&&this._loadedNodeScales.set(t,this._computeScale(s))}))}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get _areScaleBoundsActive(){const{minScale:e,maxScale:t}=P(this.layer);return this.scaleVisibilityEnabled&&(e>0||t>0)}get unloadedMemoryEstimate(){return null!=this._index&&this.layerView.contentVisible?this._index.unloadedMemoryEstimate*this._lodDropFactor:0}async _loadNodeData(e,t){return e.index<0?this._clientNodeLoader.loadNodeData(e.id,t):this._nodeLoader.loadNodeData(e,t)}async _loadAttributes(e,t,i){return(e.index<0?this._clientNodeLoader:this._nodeLoader).loadAttributes(e,t,i)}get indexDepth(){return null!=this._index?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData||(this._disableMemCache=!0),this._disableMemCache=e}runTask(e,t){return this.layerView.contentVisible?this.layerView.visible&&null!=this._index?(this._processWithErrorLogging(e,t),this._index.maxPriority):-1/0:(this._updateViewData(),this._evaluateUpdating(),-1/0)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(i){this._errorCount<50?j.error("Error during processing: "+i):50===this._errorCount&&j.error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),null!=this._nodeLoader&&null!=this._index&&(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this._isIntegratedMesh&&(e.enabled=!1),e.run((()=>this._processIndex(e))),this._updateFeatureLOD(),e.run((()=>this._processCache(e))),this._isIntegratedMesh&&(e.enabled=!0),e.run((()=>this._processNodes(e,t))),this._idleQueue.runTask(e),e.run((()=>this._prefetchIndex())),t.numIndexLoading+=this._index.indexLoading,t.numNodesLoading+=this._downloadingCount,e.run((()=>this._lodHandling.lodGlobalHandling(e))),this._evaluateUpdating())}_processIndex(e){if(null==this._index)return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update(Array.from(this._loadingNodes.keys()),e,(e=>this.updateNodeModificationStatus(e))),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(null==this._index||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||null==this._index||null==this._viewportQueries)return;const e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.indexMissing>R){if(this._featureLOD<=H)return;this._featureLOD/=B,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=E||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this._lod,a=this._index.checkFeatureTarget(t,s);a!==s&&(this._featureLOD=a/this._baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*k||e&&i.estimate>t))return;if(this._featureLOD<=H)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(E,Math.max(H,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(null==t)return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);null!=s&&(!this.layerView.isNodeLoaded(s.index)&&this._isNodeInScaleBounds(s));s=t.getParent(s.index))if(this._enableFromGPUCache(s,N.Hole)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(null==this._index)return!1;let i=(this._isIdle?T:Q)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());null!=t&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const a=this._index.getNode(s.add.back());if(null==a||a.cacheState!==w.Cached&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(a),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach((e=>e.abort())),this._loadingNodes.clear(),this._updatingNodes.forEach((e=>e.abort())),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=Q)&&(this._downloadingCount<O&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView){if(this.layerView.contentVisible){const i=(null!=this._index?this._index.indexMissing:0)+3*(null!=this._index?this._index.updates.add.length:0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.running||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||null!=this._index&&this._index.isPrefetching),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}else e=this._cameraDirty,t=e?0:1;this.updating=e,this.updatingProgress=t}}_updateViewData(){if(!this._cameraDirty||null==this._index||null==this._viewportQueries)return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this.screenSizeFactor=1/(t.perScreenPixelRatio/2),this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=J.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.quality<1?1:this.layerView.progressiveLoadFactor}get _lod(){return this._featureLOD*this._baseLOD}get _baseLOD(){const e=this.layerView.lodFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*this.layerView.view.quality}get _lodDropFactor(){if(this.fixedFeatureTarget)return 1;return(Math.min(this.layerView.view.quality,.5)-F)/(.5-F)}isGeometryVisible(e){return!!this._index?.isGeometryVisible(e.index)}updateVisibility(e){this._index?.invalidateNodeVisibilityCache(e)}invalidateGeometryVisibility(e){this._index?.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){this._index?.invalidateVisibilityObbs()}modificationsChanged(){this._index?.imModificationsChanged(!!this.layerView.hasModifications),this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e))&&(!(null==this._index||!this._index.isGeometryVisible(e.index))&&this._isNodeInScaleBounds(e))}_shouldDropNode(e){if(null==this._viewportQueries)return!1;const t=this._lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||null==e||null==this._viewportQueries)return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,uncompressedTextureDownsamplingEnabled:this.layerView.uncompressedTextureDownsamplingEnabled,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new v(this.layer,this.dataStreamController,j,this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e=>this._isNodeInScaleBounds(e)),((e,t)=>this._removeNodes(e,t,Z.fadeout)),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(null==t||null==this._viewportQueries)return!1;K.clear(),this.layerView.getLoadedNodeIndices(K);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return K.filterInPlace((e=>{const i=t.getNode(e);return null==i||!t.isGeometryVisible(e)||s(i)||!this._isNodeInScaleBounds(i)})),K.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(K,e,Z.pop),!(i&&this._lodDropFactor<1)&&(0===K.length||(K.clear(),!1))}markNodeToRemove(e){K.push(e)}removeMarkedNodes(){this._removeNodes(K,q,Z.pop)}_removeNodes(e,t,i){const s=e.length;if(0!==s&&!t.done){for(null!=this._index&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),a=this._index;i===Z.fadeout&&this.layerView.nodeFadeoutEnabled&&null!=a&&a.isGeometryVisible(s)?this.layerView.fadeNode(s,I.FadeOut,!0):this.layerView.removeNode(s),t.madeProgress()}if(this._loadedNodeScales.size>0)for(let t=e.length;t<s;t++){const i=e.data[t];this._loadedNodeScales.delete(i)}}}_needsUpdate(e){if(e.resources.isEmpty||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}async _updateLoadedNode(e){const t=new AbortController;this._updatingNodes.set(e.index,t),this._evaluateUpdating();try{const i=X(this.layerView.getLoadedAttributes(e.index),this._requiredAttributes);let s=null;s=i?await Promise.resolve(this.layerView.getAttributeData(e.index)):await this._loadAttributes(e,this._requiredAttributes,t.signal),await this.schedule((()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:s},t.signal)),t.signal)}catch(i){if(!r(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)}this._updatingNodes.delete(e.index),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void j.error("already loading node "+e.index);const t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).then((i=>{i&&null!=this._index&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())})).catch((e=>{if(!r(e))throw e})).finally((()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()}))}_loadAndAddNode(e,t){return e.cacheState===w.Uncached?this._loadUncached(e,t).then((()=>!1)):this._loadCached(e,t).then((t=>!t&&(e.cacheState=w.Uncached,!0))).catch((t=>!r(t)&&(e.cacheState=w.Uncached,!0)))}_enableFromGPUCache(e,t){if(this._disableMemCache||null==this._index)return!1;if(t===N.Hole&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e.index);return null!=t?.attributeInfo&&X(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){null!=this._index&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateLoadStatus(e,t){const i=this._index;null!=i&&i.updateChildrenLoaded(e,t?1:-1)}async _loadCached(e,t){if(this._enableFromGPUCache(e,N.Leaf))return!0;const i=this.layerView;if(this.disableIDBCache||!i.loadCachedNodeData||!i.addCachedNodeData)return!1;const s=(t,i)=>this._nodeLoader.loadTextures(e,t,i),a=(t,i)=>this._clientNodeLoader.loadTextures(e,t,i),r=e.index>=0?s:a,d=await this.schedule((()=>i.loadCachedNodeData(e,t,r)),t);if(null==d)return!1;const o=this._requiredAttributes,n=await this.reschedule((()=>this._loadAttributes(e,o,t)),t);return await this.reschedule((()=>i.addCachedNodeData(e,d,{loadedAttributes:o,attributeData:n},t)),t),this._nodeAdded(),!0}_loadUncached(e,t){return this._downloadingCount++,this._loadNodeData(e,t).catch((e=>{throw this._downloadingCount--,e})).then((i=>(this._downloadingCount--,this.schedule((()=>this.layerView.addNode(e,i,t)),t)))).then((()=>{this._nodeAdded(),e.cacheState=w.Cached})).catch((t=>{if(!r(t))throw j.error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,null!=this._index&&this._index.requestUpdate(),t}))}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&null!=this._index&&this._index.resetFailedNodes())}_getScale(e){if(this._loadedNodeScales.has(e.index))return this._loadedNodeScales.get(e.index);const t=this._computeScale(e);return this.layerView.isNodeLoaded(e.index)&&this._loadedNodeScales.set(e.index,t),t}_computeScale(e){this._tmpPoint.x=e.mbs[0],this._tmpPoint.y=e.mbs[1],this._tmpPoint.z=e.mbs[2];const t=e.mbs[3];return this.layerView.view.basemapTerrain.getSphereScale(this._tmpPoint,t)}_isNodeInScaleBounds(e){if(!this._areScaleBoundsActive)return!0;const t=this._getScale(e),{minScale:i,maxScale:s}=P(this.layer);return U(t,i,s)}updateStats(e){this.isGraphics3D&&(e.detail=this._featureLOD,e.target=this.featureTarget*this._baseLOD),this._index?.updateStats(e)}get test(){const e=this;return{index:this._index,set disableUpdates(t){e._updatesDisabled=t,t?e.cancelNodeLoading():e.requestUpdate()},set disableIDBCache(t){e.disableIDBCache=t},set ignoreServiceObb(t){null!=e._index&&(e._index.ignoreServiceObb=t)},shouldLoadNode:t=>e._shouldLoadNode(t)}}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),null!=this._index&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;null!=t&&t.layerFilterChanged(e),this._setCameraDirty()}};e([l({readOnly:!0})],z.prototype,"isMeshPyramid",null),e([l({readOnly:!0})],z.prototype,"isGraphics3D",null),e([l({readOnly:!0})],z.prototype,"useMaximumNumberOfFeatures",null),e([l({readOnly:!0})],z.prototype,"indexStreamController",null),e([l({readOnly:!0})],z.prototype,"dataStreamController",null),e([l({readOnly:!0})],z.prototype,"crsVertex",null),e([l({readOnly:!0})],z.prototype,"crsIndex",null),e([l()],z.prototype,"screenSizeFactor",void 0),e([l()],z.prototype,"featureTarget",void 0),e([l()],z.prototype,"fixedFeatureTarget",void 0),e([l()],z.prototype,"layerView",void 0),e([l()],z.prototype,"layer",null),e([l()],z.prototype,"updating",void 0),e([l({readOnly:!0})],z.prototype,"running",null),e([l()],z.prototype,"updatingProgress",void 0),e([l({readOnly:!0})],z.prototype,"leavesReached",void 0),e([l({constructOnly:!0})],z.prototype,"scaleVisibilityEnabled",void 0),e([l({constructOnly:!0})],z.prototype,"worker",void 0),e([l({readOnly:!0,dependsOn:[]})],z.prototype,"rootNodeVisible",null),z=e([h(G)],z);const K=new s({deallocator:null});let W;function X(e,t){return null!=e&&e.length===t.length&&e.every((e=>$(t,e.name)>=0))}function $(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const J={factorIM:.2,factor3dObject:.05,distancePenalty:10},Y=_();var Z;!function(e){e[e.pop=0]="pop",e[e.fadeout=1]="fadeout"}(Z||(Z={}));const ee=z;export{ee as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import has from"../../../core/has.js";import i from"../../../core/Logger.js";import s from"../../../core/PooledArray.js";import{EsriPromiseMixin as a}from"../../../core/Promise.js";import{isAbortError as r}from"../../../core/promiseUtils.js";import{watch as d,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as u}from"../../../geometry/projection/projectBoundingRect.js";import{create as _,intersectsSphere as c}from"../../../geometry/support/aaBoundingRect.js";import{makeDehydratedPoint as p}from"../dehydratedPoint.js";import{PromiseQueue as g}from"../../support/PromiseQueue.js";import{viewingModeFromString as m}from"../../../views/ViewingMode.js";import{I3SClientNodeLoader as y}from"../../../views/3d/layers/i3s/I3SClientNodeLoader.js";import{addCallback as x}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as f}from"../../../views/3d/layers/i3s/I3SIndex.js";import b from"../../../views/3d/layers/i3s/I3SLodHandling.js";import{NodeState as N,CacheState as w}from"../../../views/3d/layers/i3s/I3SNode.js";import v from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as C}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as D,getIndexCrs as L,findIntersectingNodes as S}from"../../../views/3d/layers/i3s/I3SUtil.js";import V from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{FadeDirection as I}from"../../../views/3d/layers/support/I3SLayerView.js";import{toBoundingRect as A}from"../../../views/3d/support/extentUtils.js";import{ClientType as M,maxDownloadSlots as O}from"../../../views/3d/support/index.js";import{minQuality as F}from"../../../views/3d/support/MemoryController.js";import{extractSafeScaleBounds as P,scaleBoundsPredicate as U}from"../../../views/support/layerViewUtils.js";import{noBudget as q}from"../../../views/support/Scheduler.js";const G="esri.layers.graphics.controllers.I3SOnDemandController",j=i.getLogger(G),T=100,Q=2,E=1e4,H=1e-4,R=1.2,k=500,B=1.5;let z=class extends(a(t)){get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store?.lodType}get isGraphics3D(){return"points"===this.layer.profile}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(null==this.layer.priority||"High"===this.layer.priority)}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(M.I3S_INDEX);return new C(e,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(M.I3S_DATA);return new C(e,this.layer.apiKey)}get crsVertex(){return D(this.layer)}get crsIndex(){return L(this.layer)}get layer(){return this.layerView.i3slayer}get running(){return this.updating}get rootNodeVisible(){if(this._index){const e=this._index.rootNode;if(e)return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}get requiredAttributes(){return this._requiredAttributes}constructor(e){super(e),this.screenSizeFactor=0,this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.scaleVisibilityEnabled=!0,this.worker=null,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._idleStateCallbacks=null,this._newLoadingNodes=new s({deallocator:null}),this._loadedNodeScales=new Map,this._modificationsNodeFilteringArray=new s,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._idleQueue=new g,this._elevationUpdateNodes=new s({deallocator:null}),this._errorCount=0}initialize(){const{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new b(e),this._defaultGeometrySchema=t.store.defaultGeometrySchema,this.disableIDBCache=has("disable-feature:idb-cache"),"fields"in t&&(this._fields=t.fields,this._attributeStorageInfo=t.attributeStorageInfo),this.addResolvingPromise(Promise.all([t.indexInfo,t.when(),e.when()]).then((([i])=>{if(this.destroyed||!e||e.destroyed||!i)return;const{view:s,clientGeometry:a}=e,{resourceController:r}=s;if(this._setClippingArea(s.clippingArea),this.addHandles([d((()=>s?.pointsOfInterest?.focus?.renderLocation),(e=>this._pointOfInterestChanged(e)),o),d((()=>s.quality),(()=>this._setCameraDirty()),n),d((()=>e.contentVisible),(e=>{const t=e?()=>this._updateIdleState(!0):()=>this._updateViewData(),i=e?()=>this._updateIdleState(!1):()=>{};e&&null!=this._index&&this._index.invalidateAllElevationRanges(),this._idleStateCallbacks?(e||this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=r.scheduler.registerIdleStateCallbacks(t,i)}),o),x(e.view.resourceController.scheduler,this),d((()=>e.uncompressedTextureDownsamplingEnabled),(()=>this.restartNodeLoading())),d((()=>[this.featureTarget,this.fixedFeatureTarget]),(()=>{this._setCameraDirty(),this._stableFeatureLOD=!1})),d((()=>s.state?.contentCamera),(()=>this._setCameraDirty())),d((()=>t.elevationInfo),(e=>this._elevationInfoChanged(e))),d((()=>t.effectiveScaleRange),(()=>this._scaleBoundsChanged())),d((()=>e.lodFactor),(()=>this._setCameraDirty())),d((()=>e.availableFields),(()=>this._requiredFieldsChange())),d((()=>e.holeFilling),(e=>null!=this._index&&(this._index.holeFilling=e)))]),this._updateScaleHandles(),this._viewportQueries=new V(this.crsIndex,s.renderCoordsHelper,s.state.contentCamera,!s.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?s.basemapTerrain:s.elevationProvider,m(s.viewingMode),this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._clientNodeLoader=new y(this.layer.uid,{indexSR:this.crsIndex,vertexSR:this.crsVertex,renderSR:s.renderCoordsHelper.spatialReference,localMode:"local"===s.viewingMode},s.resourceController.memoryController,this.worker),this._index=new f(t,i,this.indexStreamController,this._clientNodeLoader,this._viewportQueries,j,e.holeFilling,(t=>e.isNodeLoaded(t)),(t=>e.isNodeReloading(t)),(e=>this._shouldLoadNode(e)),(e=>this._enableFromGPUCache(e,N.Leaf)),(e=>this._needsUpdate(e)),(()=>!this.indexStreamController.busy),(t=>e.computeVisibilityObb?e.computeVisibilityObb(t):null),e?.computeNodeFiltering?t=>e.computeNodeFiltering(t):void 0),this._index.updateElevationInfo(this.layer.elevationInfo,this.isMeshPyramid||this.isGraphics3D),this._index.imModificationsChanged(!!e.hasModifications),this._index.layerFilterChanged(!!e.hasGeometryFilter),null!=a){for(const e of a)this._addMesh(e.mesh,e.oid);this.addHandles(a.on("change",(e=>{for(const t of e.removed)this._removeMesh(t.oid);for(const t of e.added)this._addMesh(t.mesh,t.oid)})))}this._startNodeLoading()}))),this._tmpPoint=p(0,0,0,this.crsIndex)}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;null!=t&&i?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll((e=>{const i=t.getNode(e);null!=i&&this._modificationsNodeFilteringArray.push(i)})),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._nodeLoader=null,K.prune(),null!=W&&(W.hide(),W=null)}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map((i=>{const s=$(e,i),a=$(t,i);return s>=0&&a>=0?{index:s,name:t[a].name,field:t[a],attributeStorageInfo:e[s]}:null})).filter((e=>null!=e&&e.name!==i))}_requiredFieldsChange(){const e=this._getRequiredAttributes();X(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=_();A(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){null!=this._viewportQueries&&(this._viewportQueries.setPointOfInterest(e),null!=this._index&&(this._index.progressiveLoadPenalty=J.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),null!=this._viewportQueries&&null!=this._index&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}_addMesh(e,t){if(null==this._index)return;const i=this._clientNodeLoader.createMeshNodeInfo(e,t),s=this._index.addClientNodeToIndex(i.id,i.mbs);this._clientNodeLoader.addMeshNode(s,i),this._evaluateUpdating(),this.notifyChange("rootNodeVisible")}_removeMesh(e){const t=this._clientNodeLoader.getMeshNodeIndex(e);if(null!=t){if(null==this._index)throw new Error("delayed removal of client side i3s node geometry not supported yet.");{const e=(e,t)=>{this.layerView.removeNode(t),this._loadedNodeScales.delete(t),this._clientNodeLoader.removeNode(e),this.layerView.deleteCachedNodeData&&null!=e&&this.layerView.deleteCachedNodeData(e),this.layerView.deleteCachedGPUData?.(this.layerView.loadCachedGPUData?.(t))},i=(e,t,i)=>{this._clientNodeLoader.updateNodeIndex(e,t,i),this.layerView.updateNodeIndex&&this.layerView.updateNodeIndex(t,i)};this._index.removeClientNodeFromIndex(t,e,i),this.notifyChange("rootNodeVisible")}}}updateElevationChanged(e,t){const i=this._index;if(null==i?.rootNode||null==t)return null;this.crsIndex.equals(t)||(u(e,t,Y,this.crsIndex),e=Y);const s=this._elevationUpdateNodes;return s.clear(),S(e,i.rootNode,i,(e=>s.push(e.index))),s.length&&(s.forAll((e=>i.updateElevationChanged(e))),this._setCameraDirty()),s}removeAllGeometryObbs(){null!=this._index&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return null!=this._viewportQueries?this._viewportQueries.getRenderMbs(e):null}_elevationInfoChanged(e){null!=this._index&&(this._index.updateElevationInfo(e,this.isMeshPyramid||this.isGraphics3D),this._setCameraDirty())}_updateScaleHandles(){const e="scale-bounds";this.removeHandles(e),this._areScaleBoundsActive&&this.addHandles(this.layerView.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),e)}_scaleBoundsChanged(){this._areScaleBoundsActive||this._loadedNodeScales.clear(),this._updateScaleHandles(),this._setCameraDirty()}_scaleUpdateHandler(e){this._updateScaleInBoundingRect(e.extent,e.spatialReference),this._setCameraDirty()}_updateScaleInBoundingRect(e,t){const i=this._index;if(null==i)return;null!=i.rootNode&&u(e,t,Y,this.crsIndex)&&this._loadedNodeScales.forEach(((e,t)=>{const s=i.getNode(t);null!=s&&c(Y,s.mbs)&&this._loadedNodeScales.set(t,this._computeScale(s))}))}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get _areScaleBoundsActive(){const{minScale:e,maxScale:t}=P(this.layer);return this.scaleVisibilityEnabled&&(e>0||t>0)}get unloadedMemoryEstimate(){return null!=this._index&&this.layerView.contentVisible?this._index.unloadedMemoryEstimate*this._lodDropFactor:0}async _loadNodeData(e,t){return e.index<0?this._clientNodeLoader.loadNodeData(e.id,t):this._nodeLoader.loadNodeData(e,t)}async _loadAttributes(e,t,i){return(e.index<0?this._clientNodeLoader:this._nodeLoader).loadAttributes(e,t,i)}get indexDepth(){return null!=this._index?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData||(this._disableMemCache=!0),this._disableMemCache=e}runTask(e,t){return this.layerView.contentVisible?this.layerView.visible&&null!=this._index?(this._processWithErrorLogging(e,t),this._index.maxPriority):-1/0:(this._updateViewData(),this._evaluateUpdating(),-1/0)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(i){this._errorCount<50?j.error("Error during processing: "+i):50===this._errorCount&&j.error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),null!=this._nodeLoader&&null!=this._index&&(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this._isIntegratedMesh&&(e.enabled=!1),e.run((()=>this._processIndex(e))),this._updateFeatureLOD(),e.run((()=>this._processCache(e))),this._isIntegratedMesh&&(e.enabled=!0),e.run((()=>this._processNodes(e,t))),this._idleQueue.runTask(e),e.run((()=>this._prefetchIndex())),t.numIndexLoading+=this._index.indexLoading,t.numNodesLoading+=this._downloadingCount,e.run((()=>this._lodHandling.lodGlobalHandling(e))),this._evaluateUpdating())}_processIndex(e){if(null==this._index)return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update(Array.from(this._loadingNodes.keys()),e,(e=>this.updateNodeModificationStatus(e))),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(null==this._index||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||null==this._index||null==this._viewportQueries)return;const e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.indexMissing>k){if(this._featureLOD<=H)return;this._featureLOD/=B,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=E||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this._lod,a=this._index.checkFeatureTarget(t,s);a!==s&&(this._featureLOD=a/this._baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*R||e&&i.estimate>t))return;if(this._featureLOD<=H)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(E,Math.max(H,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(null==t)return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);null!=s&&(!this.layerView.isNodeLoaded(s.index)&&this._isNodeInScaleBounds(s));s=t.getParent(s.index))if(this._enableFromGPUCache(s,N.Hole)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(null==this._index)return!1;let i=(this._isIdle?T:Q)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());null!=t&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const a=this._index.getNode(s.add.back());if(null==a||a.cacheState!==w.Cached&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(a),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach((e=>e.abort())),this._loadingNodes.clear(),this._updatingNodes.forEach((e=>e.abort())),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=Q)&&(this._downloadingCount<O&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView){if(this.layerView.contentVisible){const i=(null!=this._index?this._index.indexMissing:0)+3*(null!=this._index?this._index.updates.add.length:0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.running||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||null!=this._index&&this._index.isPrefetching),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}else e=this._cameraDirty,t=e?0:1;this.updating=e,this.updatingProgress=t}}_updateViewData(){if(!this._cameraDirty||null==this._index||null==this._viewportQueries)return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this.screenSizeFactor=1/(t.perScreenPixelRatio/2),this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=J.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.quality<1?1:this.layerView.progressiveLoadFactor}get _lod(){return this._featureLOD*this._baseLOD}get _baseLOD(){const e=this.layerView.lodFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*this.layerView.view.quality}get _lodDropFactor(){if(this.fixedFeatureTarget)return 1;return(Math.min(this.layerView.view.quality,.5)-F)/(.5-F)}isGeometryVisible(e){return!!this._index?.isGeometryVisible(e.index)}updateVisibility(e){this._index?.invalidateNodeVisibilityCache(e)}invalidateGeometryVisibility(e){this._index?.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){this._index?.invalidateVisibilityObbs()}modificationsChanged(){this._index?.imModificationsChanged(!!this.layerView.hasModifications),this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e))&&(!(null==this._index||!this._index.isGeometryVisible(e.index))&&this._isNodeInScaleBounds(e))}_shouldDropNode(e){if(null==this._viewportQueries)return!1;const t=this._lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||null==e||null==this._viewportQueries)return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,uncompressedTextureDownsamplingEnabled:this.layerView.uncompressedTextureDownsamplingEnabled,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new v(this.layer,this.dataStreamController,j,this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e=>this._isNodeInScaleBounds(e)),((e,t)=>this._removeNodes(e,t,Z.fadeout)),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(null==t||null==this._viewportQueries)return!1;K.clear(),this.layerView.getLoadedNodeIndices(K);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return K.filterInPlace((e=>{const i=t.getNode(e);return null==i||!t.isGeometryVisible(e)||s(i)||!this._isNodeInScaleBounds(i)})),K.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(K,e,Z.pop),!(i&&this._lodDropFactor<1)&&(0===K.length||(K.clear(),!1))}markNodeToRemove(e){K.push(e)}removeMarkedNodes(){this._removeNodes(K,q,Z.pop)}_removeNodes(e,t,i){const s=e.length;if(0!==s&&!t.done){for(null!=this._index&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),a=this._index;i===Z.fadeout&&this.layerView.nodeFadeoutEnabled&&null!=a&&a.isGeometryVisible(s)?this.layerView.fadeNode(s,I.FadeOut,!0):this.layerView.removeNode(s),t.madeProgress()}if(this._loadedNodeScales.size>0)for(let t=e.length;t<s;t++){const i=e.data[t];this._loadedNodeScales.delete(i)}}}_needsUpdate(e){if(e.resources.isEmpty||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}async _updateLoadedNode(e){const t=new AbortController;this._updatingNodes.set(e.index,t),this._evaluateUpdating();try{const i=X(this.layerView.getLoadedAttributes(e.index),this._requiredAttributes);let s=null;s=i?await Promise.resolve(this.layerView.getAttributeData(e.index)):await this._loadAttributes(e,this._requiredAttributes,t.signal),await this.schedule((()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:s},t.signal)),t.signal)}catch(i){if(!r(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)}this._updatingNodes.delete(e.index),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void j.error("already loading node "+e.index);const t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).then((i=>{i&&null!=this._index&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())})).catch((e=>{if(!r(e))throw e})).finally((()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()}))}_loadAndAddNode(e,t){return e.cacheState===w.Uncached?this._loadUncached(e,t).then((()=>!1)):this._loadCached(e,t).then((t=>!t&&(e.cacheState=w.Uncached,!0))).catch((t=>!r(t)&&(e.cacheState=w.Uncached,!0)))}_enableFromGPUCache(e,t){if(this._disableMemCache||null==this._index)return!1;if(t===N.Hole&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e.index);return null!=t?.attributeInfo&&X(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){null!=this._index&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateLoadStatus(e,t){const i=this._index;null!=i&&i.updateChildrenLoaded(e,t?1:-1)}async _loadCached(e,t){if(this._enableFromGPUCache(e,N.Leaf))return!0;const i=this.layerView;if(this.disableIDBCache||!i.loadCachedNodeData||!i.addCachedNodeData)return!1;const s=(t,i)=>this._nodeLoader.loadTextures(e,t,i),a=(t,i)=>this._clientNodeLoader.loadTextures(e,t,i),r=e.index>=0?s:a,d=await this.schedule((()=>i.loadCachedNodeData(e,t,r)),t);if(null==d)return!1;const o=this._requiredAttributes,n=await this.reschedule((()=>this._loadAttributes(e,o,t)),t);return await this.reschedule((()=>i.addCachedNodeData(e,d,{loadedAttributes:o,attributeData:n},t)),t),this._nodeAdded(),!0}_loadUncached(e,t){return this._downloadingCount++,this._loadNodeData(e,t).catch((e=>{throw this._downloadingCount--,e})).then((i=>(this._downloadingCount--,this.schedule((()=>this.layerView.addNode(e,i,t)),t)))).then((()=>{this._nodeAdded(),e.cacheState=w.Cached})).catch((t=>{if(!r(t))throw j.error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,null!=this._index&&this._index.requestUpdate(),t}))}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&null!=this._index&&this._index.resetFailedNodes())}_getScale(e){if(this._loadedNodeScales.has(e.index))return this._loadedNodeScales.get(e.index);const t=this._computeScale(e);return this.layerView.isNodeLoaded(e.index)&&this._loadedNodeScales.set(e.index,t),t}_computeScale(e){this._tmpPoint.x=e.mbs[0],this._tmpPoint.y=e.mbs[1],this._tmpPoint.z=e.mbs[2];const t=e.mbs[3];return this.layerView.view.basemapTerrain.getSphereScale(this._tmpPoint,t)}_isNodeInScaleBounds(e){if(!this._areScaleBoundsActive)return!0;const t=this._getScale(e),{minScale:i,maxScale:s}=P(this.layer);return U(t,i,s)}updateStats(e){this.isGraphics3D&&(e.detail=this._featureLOD,e.target=this.featureTarget*this._baseLOD),this._index?.updateStats(e)}get test(){const e=this;return{index:this._index,set disableUpdates(t){e._updatesDisabled=t,t?e.cancelNodeLoading():e.requestUpdate()},set disableIDBCache(t){e.disableIDBCache=t},set ignoreServiceObb(t){null!=e._index&&(e._index.ignoreServiceObb=t)},shouldLoadNode:t=>e._shouldLoadNode(t)}}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),null!=this._index&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;null!=t&&t.layerFilterChanged(e),this._setCameraDirty()}};e([l({readOnly:!0})],z.prototype,"isMeshPyramid",null),e([l({readOnly:!0})],z.prototype,"isGraphics3D",null),e([l({readOnly:!0})],z.prototype,"useMaximumNumberOfFeatures",null),e([l({readOnly:!0})],z.prototype,"indexStreamController",null),e([l({readOnly:!0})],z.prototype,"dataStreamController",null),e([l({readOnly:!0})],z.prototype,"crsVertex",null),e([l({readOnly:!0})],z.prototype,"crsIndex",null),e([l()],z.prototype,"screenSizeFactor",void 0),e([l()],z.prototype,"featureTarget",void 0),e([l()],z.prototype,"fixedFeatureTarget",void 0),e([l()],z.prototype,"layerView",void 0),e([l()],z.prototype,"layer",null),e([l()],z.prototype,"updating",void 0),e([l({readOnly:!0})],z.prototype,"running",null),e([l()],z.prototype,"updatingProgress",void 0),e([l({readOnly:!0})],z.prototype,"leavesReached",void 0),e([l({constructOnly:!0})],z.prototype,"scaleVisibilityEnabled",void 0),e([l({constructOnly:!0})],z.prototype,"worker",void 0),e([l({readOnly:!0,dependsOn:[]})],z.prototype,"rootNodeVisible",null),z=e([h(G)],z);const K=new s({deallocator:null});let W;function X(e,t){return null!=e&&e.length===t.length&&e.every((e=>$(t,e.name)>=0))}function $(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const J={factorIM:.2,factor3dObject:.05,distancePenalty:10},Y=_();var Z;!function(e){e[e.pop=0]="pop",e[e.fadeout=1]="fadeout"}(Z||(Z={}));const ee=z;export{ee as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../core/Error.js";import{numericFieldTypes as t,allDateAndTimeFieldTypes as i,validateFields as s,validateWhere as r,validateHaving as o}from"./attributeSupport.js";import{checkProjectionSupport as n}from"./projectionSupport.js";import{checkSpatialQuerySupport as a}from"./spatialQuerySupport.js";import{loadArcade as l}from"../../../support/arcadeOnDemand.js";const u="unsupported-query";async function c(t,{fieldsIndex:i,geometryType:s,spatialReference:r,availableFields:o}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(u,"Unsupported query options",{query:t});return p(i,o,t),f(i,o,t),Promise.all([a(t,s,r),n(r,t.outSR)]).then((()=>t))}function p(t,i,o){const{outFields:n,orderByFields:a,returnDistinctValues:l,outStatistics:c}=o,p=c?c.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(a&&a.length>0){const e=" asc",r=" desc",n=a.map((t=>{const i=t.toLowerCase();return i.includes(e)?i.split(e)[0]:i.includes(r)?i.split(r)[0]:t})).filter((e=>!p.includes(e)));s(t,i,n,{expressionName:"orderByFields",query:o})}if(n&&n.length>0)s(t,i,n,{expressionName:"outFields",query:o});else if(l)throw new e(u,"outFields should be specified for returnDistinctValues",{query:o});r(t,i,o.where,o)}const d=new Set([...t,...i]);function f(t,i,r){const{outStatistics:n,groupByFieldsForStatistics:a,having:l}=r,c=a?.length,p=n?.length;if(l){if(!c||!p)throw new e(u,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:r});o(t,i,l,n,r)}if(p){if(!h(n))return;const o=n.map((e=>e.onStatisticField)).filter(Boolean);s(t,i,o,{expressionName:"onStatisticFields",query:r}),c&&s(t,i,a,{expressionName:"groupByFieldsForStatistics",query:r});for(const a of n){const{onStatisticField:o,statisticType:n}=a;if(("percentile_disc"===n||"percentile_cont"===n)&&"statisticParameters"in a){const{statisticParameters:t}=a;if(!t)throw new e(u,"statisticParameters should be set for percentile type",{definition:a,query:r})}else t.get(o)&&"count"!==n&&"min"!==n&&"max"!==n&&s(t,i,[o],{expressionName:`outStatistics with '${n}' statistic type`,allowedFieldTypes:d,query:r})}}}async function m(t,i,{fieldsIndex:s,geometryType:r,spatialReference:o,availableFields:l}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(u,"Unsupported query options",{query:t});return p(s,l,t),Promise.all([y(s,l,i,t),a(t,r,o),n(o,t.outSR)]).then((()=>t))}async function y(t,i,r,o){let n=[];if(r.valueExpression){const{arcadeUtils:e}=await l();n=e.extractFieldNames(r.valueExpression)}if(r.field&&n.push(r.field),r.field2&&n.push(r.field2),r.field3&&n.push(r.field3),r.normalizationField&&n.push(r.normalizationField),!n.length&&!r.valueExpression)throw new e(u,"field or valueExpression is required",{params:r});s(t,i,n,{expressionName:"statistics",query:o})}function h(e){return null!=e&&e.every((e=>"exceedslimit"!==e.statisticType))}export{c as validateQuery,m as validateStatisticsQuery};
|
|
5
|
+
import e from"../../../core/Error.js";import{numericFieldTypes as t,allDateAndTimeFieldTypes as i,validateFields as s,validateWhere as r,validateHaving as o}from"./attributeSupport.js";import{checkProjectionSupport as n}from"./projectionSupport.js";import{checkSpatialQuerySupport as a}from"./spatialQuerySupport.js";import{loadArcade as l}from"../../../support/arcadeOnDemand.js";const u="unsupported-query";async function c(t,{fieldsIndex:i,geometryType:s,spatialReference:r,availableFields:o}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption&&"xyFootprint"!==t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(u,"Unsupported query options",{query:t});return p(i,o,t),f(i,o,t),Promise.all([a(t,s,r),n(r,t.outSR)]).then((()=>t))}function p(t,i,o){const{outFields:n,orderByFields:a,returnDistinctValues:l,outStatistics:c}=o,p=c?c.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(a&&a.length>0){const e=" asc",r=" desc",n=a.map((t=>{const i=t.toLowerCase();return i.includes(e)?i.split(e)[0]:i.includes(r)?i.split(r)[0]:t})).filter((e=>!p.includes(e)));s(t,i,n,{expressionName:"orderByFields",query:o})}if(n&&n.length>0)s(t,i,n,{expressionName:"outFields",query:o});else if(l)throw new e(u,"outFields should be specified for returnDistinctValues",{query:o});r(t,i,o.where,o)}const d=new Set([...t,...i]);function f(t,i,r){const{outStatistics:n,groupByFieldsForStatistics:a,having:l}=r,c=a?.length,p=n?.length;if(l){if(!c||!p)throw new e(u,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:r});o(t,i,l,n,r)}if(p){if(!h(n))return;const o=n.map((e=>e.onStatisticField)).filter(Boolean);s(t,i,o,{expressionName:"onStatisticFields",query:r}),c&&s(t,i,a,{expressionName:"groupByFieldsForStatistics",query:r});for(const a of n){const{onStatisticField:o,statisticType:n}=a;if(("percentile_disc"===n||"percentile_cont"===n)&&"statisticParameters"in a){const{statisticParameters:t}=a;if(!t)throw new e(u,"statisticParameters should be set for percentile type",{definition:a,query:r})}else t.get(o)&&"count"!==n&&"min"!==n&&"max"!==n&&s(t,i,[o],{expressionName:`outStatistics with '${n}' statistic type`,allowedFieldTypes:d,query:r})}}}async function m(t,i,{fieldsIndex:s,geometryType:r,spatialReference:o,availableFields:l}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(u,"Unsupported query options",{query:t});return p(s,l,t),Promise.all([y(s,l,i,t),a(t,r,o),n(o,t.outSR)]).then((()=>t))}async function y(t,i,r,o){let n=[];if(r.valueExpression){const{arcadeUtils:e}=await l();n=e.extractFieldNames(r.valueExpression)}if(r.field&&n.push(r.field),r.field2&&n.push(r.field2),r.field3&&n.push(r.field3),r.normalizationField&&n.push(r.normalizationField),!n.length&&!r.valueExpression)throw new e(u,"field or valueExpression is required",{params:r});s(t,i,n,{expressionName:"statistics",query:o})}function h(e){return null!=e&&e.every((e=>"exceedslimit"!==e.statisticType))}export{c as validateQuery,m as validateStatisticsQuery};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../request.js";import{getOrCreateMapValue as t}from"../../core/MapUtils.js";import{throwIfAborted as s}from"../../core/promiseUtils.js";import{join as o}from"../../core/urlUtils.js";import{Version as i}from"../../core/Version.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{OriginId as n}from"../../core/accessorSupport/PropertyOrigin.js";import c from"../../geometry/Extent.js";import u from"../../geometry/SpatialReference.js";import{parse as y}from"../support/arcgisLayerUrl.js";import{id as m,popupEnabled as d}from"../support/commonProperties.js";import{isHostedLayer as h}from"../../portal/support/portalItemUtils.js";const f=f=>{let b=class extends f{constructor(){super(...arguments),this.capabilities=void 0,this.copyright=null,this.fullExtent=null,this.legendEnabled=!0,this.spatialReference=null,this.version=void 0,this._allLayersAndTablesMap=null}readCapabilities(e,r){const t=r.capabilities&&r.capabilities.split(",").map((e=>e.toLowerCase().trim()));if(!t)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};const s=this.type,o="tile"!==s&&!!r.supportsDynamicLayers,a=t.includes("query"),p=t.includes("map"),l=!!r.exportTilesAllowed,n=t.includes("tilemap"),c=t.includes("data"),u="tile"!==s&&(!r.tileInfo||o),y="tile"!==s&&(!r.tileInfo||o),m="tile"!==s,d=r.cimVersion&&i.parse(r.cimVersion),h=d?.since(1,4)??!1,f=d?.since(2,0)??!1;return{operations:{supportsExportMap:p,supportsExportTiles:l,supportsIdentify:a,supportsQuery:c,supportsTileMap:n},exportMap:p?{supportsArcadeExpressionForLabeling:h,supportsSublayersChanges:m,supportsDynamicLayers:o,supportsSublayerVisibility:u,supportsSublayerDefinitionExpression:y,supportsCIMSymbols:f}:null,exportTiles:l?{maxExportTilesCount:+r.maxExportTilesCount}:null}}readVersion(e,r){let t=r.currentVersion;return t||(t=r.hasOwnProperty("capabilities")||r.hasOwnProperty("tables")?10:r.hasOwnProperty("supportedImageFormatTypes")?9.31:9.3),t}async fetchRelatedService(e){const r=this.portalItem;if(!r||!h(r))return null;this._relatedFeatureServicePromise||(this._relatedFeatureServicePromise=r.fetchRelatedItems({relationshipType:"Service2Service",direction:"reverse"},e).then((e=>e.find((e=>"Feature Service"===e.type))??null),(()=>null)));const t=await this._relatedFeatureServicePromise;return s(e),t?{itemId:t.id,url:t.url}:null}async fetchSublayerInfo(e,t){const{source:s}=e;if(this?.portalItem&&"tile"===this.type&&"map-layer"===s?.type&&h(this.portalItem)&&e.originIdOf("url")<n.SERVICE){const r=await this.fetchRelatedService(t);r&&(e.url=o(r.url,s.mapLayerId.toString()),e.layerItemId=r.itemId)}const{url:i}=e;let a;if("data-layer"===s.type){a=(await r(i,{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey},...t})).data}else if(i&&e.originIdOf("url")>n.SERVICE)try{
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../request.js";import{getOrCreateMapValue as t}from"../../core/MapUtils.js";import{throwIfAborted as s}from"../../core/promiseUtils.js";import{join as o}from"../../core/urlUtils.js";import{Version as i}from"../../core/Version.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{OriginId as n}from"../../core/accessorSupport/PropertyOrigin.js";import c from"../../geometry/Extent.js";import u from"../../geometry/SpatialReference.js";import{parse as y}from"../support/arcgisLayerUrl.js";import{id as m,popupEnabled as d}from"../support/commonProperties.js";import{isHostedLayer as h}from"../../portal/support/portalItemUtils.js";const f=f=>{let b=class extends f{constructor(){super(...arguments),this.capabilities=void 0,this.copyright=null,this.fullExtent=null,this.legendEnabled=!0,this.spatialReference=null,this.version=void 0,this._allLayersAndTablesMap=null}readCapabilities(e,r){const t=r.capabilities&&r.capabilities.split(",").map((e=>e.toLowerCase().trim()));if(!t)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};const s=this.type,o="tile"!==s&&!!r.supportsDynamicLayers,a=t.includes("query"),p=t.includes("map"),l=!!r.exportTilesAllowed,n=t.includes("tilemap"),c=t.includes("data"),u="tile"!==s&&(!r.tileInfo||o),y="tile"!==s&&(!r.tileInfo||o),m="tile"!==s,d=r.cimVersion&&i.parse(r.cimVersion),h=d?.since(1,4)??!1,f=d?.since(2,0)??!1;return{operations:{supportsExportMap:p,supportsExportTiles:l,supportsIdentify:a,supportsQuery:c,supportsTileMap:n},exportMap:p?{supportsArcadeExpressionForLabeling:h,supportsSublayersChanges:m,supportsDynamicLayers:o,supportsSublayerVisibility:u,supportsSublayerDefinitionExpression:y,supportsCIMSymbols:f}:null,exportTiles:l?{maxExportTilesCount:+r.maxExportTilesCount}:null}}readVersion(e,r){let t=r.currentVersion;return t||(t=r.hasOwnProperty("capabilities")||r.hasOwnProperty("tables")?10:r.hasOwnProperty("supportedImageFormatTypes")?9.31:9.3),t}async fetchRelatedService(e){const r=this.portalItem;if(!r||!h(r))return null;this._relatedFeatureServicePromise||(this._relatedFeatureServicePromise=r.fetchRelatedItems({relationshipType:"Service2Service",direction:"reverse"},e).then((e=>e.find((e=>"Feature Service"===e.type))??null),(()=>null)));const t=await this._relatedFeatureServicePromise;return s(e),t?{itemId:t.id,url:t.url}:null}async fetchSublayerInfo(e,t){const{source:s}=e;if(this?.portalItem&&"tile"===this.type&&"map-layer"===s?.type&&h(this.portalItem)&&e.originIdOf("url")<n.SERVICE){const r=await this.fetchRelatedService(t);r&&(e.url=o(r.url,s.mapLayerId.toString()),e.layerItemId=r.itemId)}const{url:i}=e;let a;if("data-layer"===s.type){a=(await r(i,{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey},...t})).data}else if(i&&e.originIdOf("url")>n.SERVICE)try{const e=await this._fetchAllLayersAndTablesFromService(i),r=y(i)?.sublayer??s.mapLayerId;a=e.get(r)}catch{}else{let r=e.id;"map-layer"===s?.type&&(r=s.mapLayerId);try{a=(await this.fetchAllLayersAndTables(t)).get(r)}catch{}}return a}async fetchAllLayersAndTables(e){return this._fetchAllLayersAndTablesFromService(this.parsedUrl?.path,e)}async _fetchAllLayersAndTablesFromService(e,i){await this.load(i),this._allLayersAndTablesMap||=new Map;const a=y(e),p=t(this._allLayersAndTablesMap,a?.url.path,(()=>r(o(a?.url.path,"/layers"),{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey}}).then((e=>{const r=new Map;for(const t of e.data.layers)r.set(t.id,t);return{result:r}}),(e=>({error:e}))))),l=await p;if(s(i),"result"in l)return l.result;throw l.error}};return e([a({readOnly:!0})],b.prototype,"capabilities",void 0),e([p("service","capabilities",["capabilities","exportTilesAllowed","maxExportTilesCount","supportsDynamicLayers","tileInfo"])],b.prototype,"readCapabilities",null),e([a({json:{read:{source:"copyrightText"}}})],b.prototype,"copyright",void 0),e([a({type:c})],b.prototype,"fullExtent",void 0),e([a(m)],b.prototype,"id",void 0),e([a({type:Boolean,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend"}}})],b.prototype,"legendEnabled",void 0),e([a(d)],b.prototype,"popupEnabled",void 0),e([a({type:u})],b.prototype,"spatialReference",void 0),e([a({readOnly:!0})],b.prototype,"version",void 0),e([p("version",["currentVersion","capabilities","tables","supportedImageFormatTypes"])],b.prototype,"readVersion",null),b=e([l("esri.layers.mixins.ArcGISMapService")],b),b};export{f as ArcGISMapService};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{save as e,saveAs as
|
|
5
|
+
import{save as e,saveAs as r}from"./utils.js";import{createForGroupLayerItemWrite as t}from"../../portal/support/jsonContext.js";import{TypeKeyword as s,hasTypeKeyword as a,addTypeKeyword as o}from"../../portal/support/portalItemUtils.js";import{saveResources as n}from"../../webdoc/support/saveUtils.js";const i="Group Layer",u="group-layer-save",c="group-layer-save-as",l=s.GROUP_LAYER_MAP;function p(e){return{isValid:"group"===e.type,errorMessage:"Layer.type should be 'group'"}}function m(e){return{isValid:a(e,l),errorMessage:`Layer.portalItem.typeKeywords should have '${l}'`}}function y(e){const r=e.layerJSON;return Promise.resolve(r&&Object.keys(r).length?r:null)}async function f(e,r){r.title||=e.title,o(r,l)}async function v(r,s){return e({layer:r,itemType:i,validateLayer:p,validateItem:m,createJSONContext:e=>t(e,r),createItemData:y,errorNamePrefix:u,saveResources:async(e,t)=>(r.sourceIsPortalItem||await e.removeAllResources().catch((()=>{})),n(r.resourceReferences,t))},s)}async function d(e,s,a){return r({layer:e,itemType:i,validateLayer:p,createJSONContext:r=>t(r,e),createItemData:y,errorNamePrefix:c,newItem:s,setItemProperties:f,saveResources:(r,t)=>n(e.resourceReferences,t)},a)}export{v as save,d as saveAs};
|
package/layers/save/utils.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import r from"../../portal/Portal.js";import o from"../../portal/PortalItem.js";import{createForItemWrite as a}from"../../portal/support/jsonContext.js";import{addTypeKeyword as i,TypeKeyword as n}from"../../portal/support/portalItemUtils.js";import{validateSaveAPIKey as s}from"../../webdoc/saveAPIKeyUtils.js";function l(t,r,o){const a=o(t);if(!a.isValid)throw new e(`${r}:invalid-parameters`,a.errorMessage,{layer:t})}async function p(e){const{layer:t,errorNamePrefix:r,validateLayer:o}=e;await t.load(),l(t,r,o)}function m(e,t){return`Layer (title: ${e.title}, id: ${e.id}) of type '${e.declaredClass}' ${t}`}function
|
|
5
|
+
import e from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import r from"../../portal/Portal.js";import o from"../../portal/PortalItem.js";import{createForItemWrite as a}from"../../portal/support/jsonContext.js";import{addTypeKeyword as i,TypeKeyword as n}from"../../portal/support/portalItemUtils.js";import{validateSaveAPIKey as s}from"../../webdoc/saveAPIKeyUtils.js";function l(t,r,o){const a=o(t);if(!a.isValid)throw new e(`${r}:invalid-parameters`,a.errorMessage,{layer:t})}async function p(e){const{layer:t,errorNamePrefix:r,validateLayer:o}=e;await t.load(),l(t,r,o)}function m(e,t){return`Layer (title: ${e.title}, id: ${e.id}) of type '${e.declaredClass}' ${t}`}function c(t){const{item:r,itemType:o,errorNamePrefix:a,layer:i,validateItem:n}=t;if(s(r),r.type!==o)throw new e(`${a}:portal-item-wrong-type`,`Portal item type should be "${o}"`,{item:r,layer:i});if(n){const t=n(r);if(!t.isValid)throw new e(`${a}:invalid-parameters`,t.errorMessage,{layer:i})}}function d(t){const{layer:r,errorNamePrefix:o}=t,{portalItem:a}=r;if(!a)throw new e(`${o}:portal-item-not-set`,m(r,"requires the portalItem property to be set"));if(!a.loaded)throw new e(`${o}:portal-item-not-loaded`,m(r,"cannot be saved to a portal item that does not exist or is inaccessible"));c({...t,item:a})}function u(e){const{newItem:t,itemType:a}=e;let i=o.from(t);return i.id&&(i=i.clone(),i.id=null),i.type??=a,i.portal??=r.getDefault(),c({...e,item:i}),i}function f(t,r){let o=(t.messages??[]).filter((({type:e})=>"error"===e)).map((({name:t,message:r,details:o})=>new e(t,r,o)));if(t.blockedRelativeUrls&&(o=o.concat(t.blockedRelativeUrls.map((t=>new e("url:unsupported",`Relative url '${t}' is not supported`))))),r?.ignoreUnsupported&&(o=o.filter((({name:e})=>"layer:unsupported"!==e&&"symbol:unsupported"!==e&&"symbol-layer:unsupported"!==e&&"property:unsupported"!==e&&"url:unsupported"!==e))),o.length>0)throw new e("layer-write:unsupported","Failed to save layer due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:o})}async function y(e,t,r){"beforeSave"in e&&"function"==typeof e.beforeSave&&await e.beforeSave();const o=e.write({},t);return await Promise.all(t.resources?.pendingOperations??[]),f(t,r),o}function w(e){i(e,n.JSAPI),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}async function v(e,t,r){const o=e.portal;await o.signIn(),await(o.user?.addItem({item:e,data:t,folder:r?.folder}))}async function I(e,r){const{layer:o,createItemData:i,createJSONContext:n,saveResources:s}=e;await p(e),d(e);const l=o.portalItem,m=n?n(l):a(l),c=await y(o,m,r),u=await i({layer:o,layerJSON:c},l);return w(l),await l.update({data:u}),t(m),await(s?.(l,m)),l}async function b(e,r){const{layer:o,createItemData:i,createJSONContext:n,setItemProperties:s,saveResources:l}=e;await p(e);const m=u(e),c=n?n(m):a(m),d=await y(o,c,r),f=await i({layer:o,layerJSON:d},m);return await s(o,m),w(m),await v(m,f,r),o.portalItem=m,t(c),await(l?.(m,c)),m}export{v as addItem,m as createErrorMessage,d as ensureItemConfig,l as ensureLayerConfig,y as getLayerJSON,u as getPortalItem,I as save,b as saveAs,w as setCommonItemProperties};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../request.js";import r from"../../core/Error.js";import{getImageData as o}from"../../core/imageUtils.js";import{isDataProtocol as n,isBlobProtocol as i,isAbsolute as s,dataToBlob as a,join as l}from"../../core/urlUtils.js";import{generateUUID as m}from"../../core/uuid.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../../core/accessorSupport/decorators/writer.js";import d from"./MediaElementBase.js";import{getResourceContentExtension as g}from"../../portal/support/resourceExtension.js";import{f,t as y,i as v,M as j}from"../../chunks/persistableUrlUtils.js";let I=class extends d{constructor(t){super(t),this.animationOptions=null,this.content=null,this.image=null,this.type="image",this.image=null}load(){const t=this.image;if("string"==typeof t){const e=o(t).then((t=>{this._set("content",t)}));this.addResolvingPromise(e)}else if(t instanceof HTMLImageElement){const e=t.decode().then((()=>{this._set("content",t)}));this.addResolvingPromise(e)}else t?this._set("content",t):this.addResolvingPromise(Promise.reject(new r("image-element:invalid-image-type","Invalid image type",{image:t})));return Promise.resolve(this)}get contentWidth(){return null==this.content?0:this.content instanceof HTMLImageElement?this.content.naturalWidth:this.content.width}get contentHeight(){return null==this.content?0:this.content instanceof HTMLImageElement?this.content.naturalHeight:this.content.height}readImage(t,e,r){return f(e.url,r)}writeImage(t,e,r,o){if(null==t)return;const a=o?.portalItem,l=o?.resources;if(!a||!l)return void("string"==typeof t&&(e[r]=y(t,o)));const m="string"!=typeof t||n(t)||i(t)?null:t;if(m){if(null==v(m))return void(e[r]=m);const t=y(m,{...o,verifyItemRelativeUrls:o?.verifyItemRelativeUrls?{writtenUrls:o.verifyItemRelativeUrls.writtenUrls,rootPath:void 0}:void 0},j.NO);if(a&&t&&!s(t))return l.toKeep.push({resource:a.resourceFromPath(t),compress:!1}),void(e[r]=t)}e[r]="<pending>",l.pendingOperations.push(w(t).then((t=>{const o=H(t,a);e[r]=o.itemRelativeUrl,l.toAdd.push({resource:o,content:{type:"blob",blob:t},compress:!1,finish:t=>{this.image=t.url}})})))}};t([c()],I.prototype,"animationOptions",void 0),t([c({readOnly:!0})],I.prototype,"content",void 0),t([c({readOnly:!0})],I.prototype,"contentWidth",null),t([c({readOnly:!0})],I.prototype,"contentHeight",null),t([c({json:{name:"url",type:String}})],I.prototype,"image",void 0),t([p("image",["url"])],I.prototype,"readImage",null),t([h("image")],I.prototype,"writeImage",null),t([c({readOnly:!0,json:{name:"mediaType"}})],I.prototype,"type",void 0),I=t([u("esri.layers.support.ImageElement")],I);const b=I;async function w(t){if("string"==typeof t){if(n(t))return a(t);return(await e(t,{responseType:"blob"})).data}return new Promise((e=>E(t).toBlob(e)))}function E(t){if(t instanceof HTMLCanvasElement)return t;const e=t instanceof HTMLImageElement?t.naturalWidth:t.width,r=t instanceof HTMLImageElement?t.naturalHeight:t.height,o=document.createElement("canvas"),n=o.getContext("2d");return o.width=e,o.height=r,t instanceof HTMLImageElement?n.drawImage(t,0,0,t.width,t.height):t instanceof ImageData&&n.putImageData(t,0,0),o}function H(t,e){const r=m(),o=`${l("media",r)}.${g({type:"blob",blob:t})}`;return e.resourceFromPath(o)}export{b as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.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{rendererTypes as t,webSceneRendererTypes as i}from"../../renderers/support/types.js";import o from"../../request.js";import{isSymbol3D as s}from"../../symbols.js";import a from"../../core/Collection.js";import l from"../../core/Error.js";import has from"../../core/has.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import{clone as p}from"../../core/lang.js";import y from"../../core/Loadable.js";import d from"../../core/Logger.js";import{MultiOriginJSONMixin as u}from"../../core/MultiOriginJSONSupport.js";import{sqlAnd as c}from"../../core/sql.js";import{objectToQuery as f}from"../../core/urlUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as h}from"../../core/accessorSupport/decorators/cast.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";import{ensureInteger as I,ensureType as w,Integer as v,ensureClass as j}from"../../core/accessorSupport/ensureType.js";import{OriginId as L,nameToId as D}from"../../core/accessorSupport/PropertyOrigin.js";import{getProperties as E}from"../../core/accessorSupport/utils.js";import x from"../graphics/sources/support/QueryTask.js";import F from"./FeatureType.js";import P from"./Field.js";import O from"./FieldsIndex.js";import T from"./LabelClass.js";import{validateLabelingInfo as _}from"./labelingInfo.js";import A from"./LayerFloorInfo.js";import{getFeatureLayerCapabilities as V}from"./serviceCapabilitiesUtils.js";import{DataLayerSource as M}from"./source/DataLayerSource.js";import{MapLayerSource as N}from"./source/MapLayerSource.js";import q from"../../rest/support/AttachmentQuery.js";import R from"../../rest/support/Query.js";import{createPopupTemplate as U}from"../../support/popupUtils.js";import k from"../../geometry/Extent.js";import{featureGeometryTypeKebabDictionary as C}from"../../geometry/support/typeUtils.js";var Q;function B(e){return null!=e&&"esriSMS"===e.type}function J(e,r,t){const i=this.originIdOf(r)>=D(t.origin);return{ignoreOrigin:!0,allowNull:i,enabled:!!t&&("map-image"===t.layer?.type&&(t.writeSublayerStructure||i))}}function $(e,r,t){return{enabled:!!t&&("tile"===t.layer?.type&&(t.origin&&this.originIdOf(r)>=D(t.origin)||this._isOverridden(r)))}}function G(e,r,t){return{ignoreOrigin:!0,enabled:t&&t.writeSublayerStructure||!1}}function H(e,r,t){return{ignoreOrigin:!0,enabled:!!t&&(t.writeSublayerStructure||this.originIdOf(r)>=D(t.origin))}}let z=0;const K=new Set;K.add("layer"),K.add("parent"),K.add("loaded"),K.add("loadStatus"),K.add("loadError"),K.add("loadWarnings");let W=Q=class extends(u(n(y))){constructor(e){super(e),this.capabilities=void 0,this.maxScaleRange={minScale:0,maxScale:0},this.fields=null,this.fullExtent=null,this.geometryType=null,this.globalIdField=null,this.legendEnabled=!0,this.objectIdField=null,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.sourceJSON=null,this.title=null,this.typeIdField=null,this.type="sublayer",this.types=null,this._lastParsedUrl=null}async load(e){return this.addResolvingPromise((async()=>{const{layer:r,url:t}=this;if(!r&&!t)throw new l("sublayer:missing-layer","Sublayer can't be loaded without being part of a layer",{sublayer:this});const i=r?await r.fetchSublayerInfo(this,e):(await o(t,{responseType:"json",query:{f:"json"},...e})).data;i&&(this.sourceJSON=i,this.read({layerDefinition:i},{origin:"service"}))})()),this}readCapabilities(e,r){r=r.layerDefinition||r;const{operations:{supportsQuery:t,supportsQueryAttachments:i},query:{supportsFormatPBF:o},data:{supportsAttachment:s}}=V(r,this.url);return{exportMap:{supportsModification:!!r.canModifyLayer},operations:{supportsQuery:t,supportsQueryAttachments:i},data:{supportsAttachment:s},query:{supportsFormatPBF:o}}}get defaultPopupTemplate(){return this.createPopupTemplate()}set definitionExpression(e){this._setAndNotifyLayer("definitionExpression",e)}get effectiveScaleRange(){const{minScale:e,maxScale:r}=this;return{minScale:e,maxScale:r}}readMaxScaleRange(e,r){return{minScale:r.minScale??0,maxScale:r.maxScale??0}}get fieldsIndex(){return new O(this.fields||[])}set floorInfo(e){this._setAndNotifyLayer("floorInfo",e)}readGlobalIdFieldFromService(e,r){if((r=r.layerDefinition||r).globalIdField)return r.globalIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeGlobalID"===t.type)return t.name}get id(){const e=this._get("id");return e??z++}set id(e){this._get("id")!==e&&(!1!==this.layer?.capabilities?.exportMap?.supportsDynamicLayers?this._set("id",e):this._logLockedError("id","capability not available 'layer.capabilities.exportMap.supportsDynamicLayers'"))}set labelingInfo(e){this._setAndNotifyLayer("labelingInfo",e)}writeLabelingInfo(e,r,t,i){e&&e.length&&(r.layerDefinition={drawingInfo:{labelingInfo:e.map((e=>e.write({},i)))}})}set labelsVisible(e){this._setAndNotifyLayer("labelsVisible",e)}set layer(e){this._set("layer",e),this.sublayers&&this.sublayers.forEach((r=>r.layer=e))}set listMode(e){this._set("listMode",e)}set minScale(e){this._setAndNotifyLayer("minScale",e)}readMinScale(e,r){return r.minScale||r.layerDefinition?.minScale||0}set maxScale(e){this._setAndNotifyLayer("maxScale",e)}readMaxScale(e,r){return r.maxScale||r.layerDefinition?.maxScale||0}readObjectIdFieldFromService(e,r){if((r=r.layerDefinition||r).objectIdField)return r.objectIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeOID"===t.type)return t.name}set opacity(e){this._setAndNotifyLayer("opacity",e)}readOpacity(e,r){const t=r.layerDefinition;return 1-.01*((null!=t?.transparency?t.transparency:t?.drawingInfo?.transparency)??0)}writeOpacity(e,r,t,i){r.layerDefinition={drawingInfo:{transparency:100-100*e}}}writeParent(e,r){this.parent&&this.parent!==this.layer?r.parentLayerId=I(this.parent.id):r.parentLayerId=-1}get queryTask(){if(!this.layer)return null;const{spatialReference:e}=this.layer,r="gdbVersion"in this.layer?this.layer.gdbVersion:void 0,{capabilities:t,fieldsIndex:i}=this,o=has("featurelayer-pbf")&&t?.query.supportsFormatPBF,s=t?.operations?.supportsQueryAttachments??!1;return new x({url:this.url,pbfSupported:o,fieldsIndex:i,gdbVersion:r,sourceSpatialReference:e,queryAttachmentsSupported:s})}set renderer(e){if(e)for(const r of e.getSymbols())if(s(r)){d.getLogger(this).warn("Sublayer renderer should use 2D symbols");break}this._setAndNotifyLayer("renderer",e)}get source(){return this._get("source")||new N({mapLayerId:this.id})}set source(e){this._setAndNotifyLayer("source",e)}set sublayers(e){this._handleSublayersChange(e,this._get("sublayers")),this._set("sublayers",e)}castSublayers(e){return w(a.ofType(Q),e)}writeSublayers(e,r,t){this.sublayers?.length&&(r[t]=this.sublayers.map((e=>e.id)).toArray().reverse())}readTypeIdField(e,r){let t=(r=r.layerDefinition||r).typeIdField;if(t&&r.fields){t=t.toLowerCase();const e=r.fields.find((e=>e.name.toLowerCase()===t));e&&(t=e.name)}return t}get url(){const e=this.layer?.parsedUrl??this._lastParsedUrl,r=this.source;if(!e)return null;if(this._lastParsedUrl=e,"map-layer"===r?.type)return`${e.path}/${r.mapLayerId}`;const t={layer:JSON.stringify({source:this.source})};return`${e.path}/dynamicLayer?${f(t)}`}set url(e){this._overrideIfSome("url",e)}set visible(e){this._setAndNotifyLayer("visible",e)}writeVisible(e,r,t,i){r[t]=this.getAtOrigin("defaultVisibility","service")||e}clone(){const{store:e}=E(this),r=new Q;return E(r).store=e.clone(K),this.commitProperty("url"),r._lastParsedUrl=this._lastParsedUrl,r}createPopupTemplate(e){return U(this,e)}createQuery(){return new R({returnGeometry:!0,where:this.definitionExpression||"1=1"})}async createFeatureLayer(){if(this.hasOwnProperty("sublayers"))return null;const{layer:e}=this,r=e?.parsedUrl,t=new(0,(await import("../FeatureLayer.js")).default)({url:r?.path});return r&&this.source&&("map-layer"===this.source.type?t.layerId=this.source.mapLayerId:t.dynamicDataSource=this.source),null!=e?.refreshInterval&&(t.refreshInterval=e.refreshInterval),this.definitionExpression&&(t.definitionExpression=this.definitionExpression),this.floorInfo&&(t.floorInfo=p(this.floorInfo)),this.originIdOf("labelingInfo")>L.SERVICE&&(t.labelingInfo=p(this.labelingInfo)),this.originIdOf("labelsVisible")>L.DEFAULTS&&(t.labelsVisible=this.labelsVisible),this.originIdOf("legendEnabled")>L.DEFAULTS&&(t.legendEnabled=this.legendEnabled),this.originIdOf("visible")>L.DEFAULTS&&(t.visible=this.visible),this.originIdOf("minScale")>L.DEFAULTS&&(t.minScale=this.minScale),this.originIdOf("maxScale")>L.DEFAULTS&&(t.maxScale=this.maxScale),this.originIdOf("opacity")>L.DEFAULTS&&(t.opacity=this.opacity),this.originIdOf("popupTemplate")>L.DEFAULTS&&(t.popupTemplate=p(this.popupTemplate)),this.originIdOf("renderer")>L.SERVICE&&(t.renderer=p(this.renderer)),"data-layer"===this.source?.type&&(t.dynamicDataSource=this.source.clone()),this.originIdOf("title")>L.DEFAULTS&&(t.title=this.title),"map-image"===e?.type&&e.originIdOf("customParameters")>L.DEFAULTS&&(t.customParameters=e.customParameters),"tile"===e?.type&&e.originIdOf("customParameters")>L.DEFAULTS&&(t.customParameters=e.customParameters),t}getField(e){return this.fieldsIndex.get(e)}getFeatureType(e){const{typeIdField:r,types:t}=this;if(!r||!e)return null;const i=e.attributes?e.attributes[r]:void 0;if(null==i)return null;let o=null;return t?.some((e=>{const{id:r}=e;return null!=r&&(r.toString()===i.toString()&&(o=e),!!o)})),o}getFieldDomain(e,r){const t=r?.feature,i=this.getFeatureType(t);if(i){const r=i.domains&&i.domains[e];if(r&&"inherited"!==r.type)return r}return this._getLayerDomain(e)}async queryAttachments(e,r){await this.load(),e=q.from(e);const t=this.capabilities;if(!t?.data?.supportsAttachment)throw new l("queryAttachments:not-supported","this layer doesn't support attachments");const{attachmentTypes:i,objectIds:o,globalIds:s,num:a,size:n,start:p,where:y}=e;if(!t?.operations?.supportsQueryAttachments){if(i?.length>0||s?.length>0||n?.length>0||a||p||y)throw new l("queryAttachments:option-not-supported","when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",e)}if(!(o?.length||s?.length||y))throw new l("queryAttachments:invalid-query","'objectIds', 'globalIds', or 'where' are required to perform attachment query",e);return this.queryTask.executeAttachmentQuery(e,r)}async queryFeatures(e=this.createQuery(),r){if(await this.load(),!this.capabilities.operations.supportsQuery)throw new l("queryFeatures:not-supported","this layer doesn't support queries.");if(!this.url)throw new l("queryFeatures:not-supported","this layer has no url.");const t=await this.queryTask.execute(e,{...r,query:{...this.layer?.customParameters,token:this.layer?.apiKey}});if(t?.features)for(const i of t.features)i.sourceLayer=this;return t}toExportImageJSON(e){const r={id:this.id,source:this.source?.toJSON()||{mapLayerId:this.id,type:"mapLayer"}},t=c(e,this.definitionExpression);null!=t&&(r.definitionExpression=t);const i=["renderer","labelingInfo","opacity","labelsVisible"].reduce(((e,r)=>(e[r]=this.originIdOf(r),e)),{}),o=Object.keys(i).some((e=>i[e]>L.SERVICE));if(o){const e=r.drawingInfo={};if(i.renderer>L.SERVICE&&(e.renderer=this.renderer?this.renderer.toJSON():null),i.labelsVisible>L.SERVICE&&(e.showLabels=this.labelsVisible),this.labelsVisible&&i.labelingInfo>L.SERVICE)if(this.labelingInfo){!this.loaded&&this.labelingInfo?.some((e=>!e.labelPlacement))&&d.getLogger(this).warnOnce(`A Sublayer (title: ${this.title}, id: ${this.id}) has an undefined 'labelPlacement' and so labels cannot be displayed. Either define a valid 'labelPlacement' or call Sublayer.load() to use a default value based on geometry type.`,{sublayer:this});let r=this.labelingInfo;null!=this.geometryType&&(r=_(this.labelingInfo,C.toJSON(this.geometryType))),e.showLabels=!0,e.labelingInfo=r.filter((e=>e.labelPlacement)).map((e=>e.toJSON({origin:"service",layer:this.layer})))}else e.showLabels=!1;i.opacity>L.SERVICE&&(e.transparency=100-100*this.opacity),this._assignDefaultSymbolColors(e.renderer)}return r}_assignDefaultSymbolColors(e){this._forEachSimpleMarkerSymbols(e,(e=>{e.color||"esriSMSX"!==e.style&&"esriSMSCross"!==e.style||(e.outline?.color?e.color=e.outline.color:e.color=[0,0,0,0])}))}_forEachSimpleMarkerSymbols(e,r){if(e){const t=("uniqueValueInfos"in e?e.uniqueValueInfos:"classBreakInfos"in e?e.classBreakInfos:null)??[];for(const e of t)B(e.symbol)&&r(e.symbol);"symbol"in e&&B(e.symbol)&&r(e.symbol),"defaultSymbol"in e&&B(e.defaultSymbol)&&r(e.defaultSymbol)}}_setAndNotifyLayer(e,r){const t=this.layer,i=this._get(e);let o,s;switch(e){case"definitionExpression":case"floorInfo":o="supportsSublayerDefinitionExpression";break;case"minScale":case"maxScale":case"visible":o="supportsSublayerVisibility";break;case"labelingInfo":case"labelsVisible":case"opacity":case"renderer":case"source":o="supportsDynamicLayers",s="supportsModification"}const a=E(this).getDefaultOrigin();if("service"!==a){if(o&&!1===this.layer?.capabilities?.exportMap?.[o])return void this._logLockedError(e,`capability not available 'layer.capabilities.exportMap.${o}'`);if(s&&!1===this.capabilities?.exportMap[s])return void this._logLockedError(e,`capability not available 'capabilities.exportMap.${s}'`)}"source"!==e||"not-loaded"===this.loadStatus?(this._set(e,r),"service"!==a&&i!==r&&t&&t.emit&&t.emit("sublayer-update",{propertyName:e,target:this})):this._logLockedError(e,"'source' can't be changed after calling sublayer.load()")}_handleSublayersChange(e,r){r&&(r.forEach((e=>{e.parent=null,e.layer=null})),this.removeAllHandles()),e&&(e.forEach((e=>{e.parent=this,e.layer=this.layer})),this.addHandles([e.on("after-add",(({item:e})=>{e.parent=this,e.layer=this.layer})),e.on("after-remove",(({item:e})=>{e.parent=null,e.layer=null})),e.on("before-changes",(e=>{const r=this.layer?.capabilities?.exportMap?.supportsSublayersChanges;null==r||r||(d.getLogger(this).error(new l("sublayer:sublayers-non-modifiable","Sublayer can't be added, moved, or removed from the layer's sublayers",{sublayer:this,layer:this.layer})),e.preventDefault())}))]))}_logLockedError(e,r){const{layer:t,declaredClass:i}=this;d.getLogger(i).error(new l("sublayer:locked",`Property '${String(e)}' can't be changed on Sublayer from the layer '${t?.id}'`,{reason:r,sublayer:this,layer:t}))}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}};W.test={isMapImageLayerOverridePolicy:e=>e===G||e===J,isTileImageLayerOverridePolicy:e=>e===$},e([m({readOnly:!0})],W.prototype,"capabilities",void 0),e([b("service","capabilities",["layerDefinition.canModifyLayer","layerDefinition.capabilities"])],W.prototype,"readCapabilities",null),e([m()],W.prototype,"defaultPopupTemplate",null),e([m({type:String,value:null,json:{name:"layerDefinition.definitionExpression",write:{allowNull:!0,overridePolicy:J}}})],W.prototype,"definitionExpression",null),e([m({readOnly:!0})],W.prototype,"effectiveScaleRange",null),e([b("service","maxScaleRange",["minScale","maxScale"])],W.prototype,"readMaxScaleRange",null),e([m({type:[P],json:{origins:{service:{read:{source:"layerDefinition.fields"}}}}})],W.prototype,"fields",void 0),e([m({readOnly:!0})],W.prototype,"fieldsIndex",null),e([m({type:A,value:null,json:{name:"layerDefinition.floorInfo",read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo",overridePolicy:J},origins:{"web-scene":{read:!1,write:!1}}}})],W.prototype,"floorInfo",null),e([m({type:k,json:{read:{source:"layerDefinition.extent"}}})],W.prototype,"fullExtent",void 0),e([m({type:C.apiValues,json:{origins:{service:{name:"layerDefinition.geometryType",read:{reader:C.read}}}}})],W.prototype,"geometryType",void 0),e([m({type:String})],W.prototype,"globalIdField",void 0),e([b("service","globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],W.prototype,"readGlobalIdFieldFromService",null),e([m({type:v,json:{write:{ignoreOrigin:!0}}})],W.prototype,"id",null),e([m({value:null,type:[T],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo"},write:{target:"layerDefinition.drawingInfo.labelingInfo",overridePolicy:G}}})],W.prototype,"labelingInfo",null),e([S("labelingInfo")],W.prototype,"writeLabelingInfo",null),e([m({type:Boolean,value:!0,json:{read:{source:"layerDefinition.drawingInfo.showLabels"},write:{target:"layerDefinition.drawingInfo.showLabels",overridePolicy:G}}})],W.prototype,"labelsVisible",null),e([m({value:null})],W.prototype,"layer",null),e([m({type:String,json:{write:{overridePolicy:$}}})],W.prototype,"layerItemId",void 0),e([m({type:Boolean,value:!0,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend",overridePolicy:H}}})],W.prototype,"legendEnabled",void 0),e([m({type:["show","hide","hide-children"],value:"show",json:{read:!1,write:!1,origins:{"web-scene":{read:!0,write:!0}}}})],W.prototype,"listMode",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"minScale",null),e([b("minScale",["minScale","layerDefinition.minScale"])],W.prototype,"readMinScale",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"maxScale",null),e([b("maxScale",["maxScale","layerDefinition.maxScale"])],W.prototype,"readMaxScale",null),e([m({type:String})],W.prototype,"objectIdField",void 0),e([b("service","objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],W.prototype,"readObjectIdFieldFromService",null),e([m({type:Number,value:1,json:{write:{target:"layerDefinition.drawingInfo.transparency",overridePolicy:G}}})],W.prototype,"opacity",null),e([b("opacity",["layerDefinition.drawingInfo.transparency","layerDefinition.transparency"])],W.prototype,"readOpacity",null),e([S("opacity")],W.prototype,"writeOpacity",null),e([m({json:{type:v,write:{target:"parentLayerId",writerEnsuresNonNull:!0,overridePolicy:G}}})],W.prototype,"parent",void 0),e([S("parent")],W.prototype,"writeParent",null),e([m({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,r)=>!r.disablePopup},write:{target:"disablePopup",overridePolicy:H,writer(e,r,t){r[t]=!e}}}})],W.prototype,"popupEnabled",void 0),e([m({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy:H}}})],W.prototype,"popupTemplate",void 0),e([m({readOnly:!0})],W.prototype,"queryTask",null),e([m({types:t,value:null,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G},origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G}}}}})],W.prototype,"renderer",null),e([m({types:{key:"type",base:null,typeMap:{"data-layer":M,"map-layer":N}},cast(e){if(e){if("mapLayerId"in e)return j(N,e);if("dataSource"in e)return j(M,e)}return e},json:{name:"layerDefinition.source",write:{overridePolicy:G}}})],W.prototype,"source",null),e([m()],W.prototype,"sourceJSON",void 0),e([m({value:null,json:{type:[v],write:{target:"subLayerIds",allowNull:!0,overridePolicy:G}}})],W.prototype,"sublayers",null),e([h("sublayers")],W.prototype,"castSublayers",null),e([S("sublayers")],W.prototype,"writeSublayers",null),e([m({type:String,json:{name:"name",write:{overridePolicy:H}}})],W.prototype,"title",void 0),e([m({type:String})],W.prototype,"typeIdField",void 0),e([m({json:{read:!1},readOnly:!0,value:"sublayer"})],W.prototype,"type",void 0),e([b("typeIdField",["layerDefinition.typeIdField"])],W.prototype,"readTypeIdField",null),e([m({type:[F],json:{origins:{service:{read:{source:"layerDefinition.types"}}}}})],W.prototype,"types",void 0),e([m({type:String,json:{name:"layerUrl",write:{overridePolicy:$}}})],W.prototype,"url",null),e([m({type:Boolean,value:!0,json:{read:{source:"defaultVisibility"},write:{target:"defaultVisibility",overridePolicy:G}}})],W.prototype,"visible",null),e([S("visible")],W.prototype,"writeVisible",null),W=Q=e([g("esri.layers.support.Sublayer")],W);const X=W;export{X as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.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{rendererTypes as t,webSceneRendererTypes as i}from"../../renderers/support/types.js";import o from"../../request.js";import{isSymbol3D as a}from"../../symbols.js";import s from"../../core/Collection.js";import l from"../../core/Error.js";import has from"../../core/has.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import{clone as p}from"../../core/lang.js";import y from"../../core/Loadable.js";import d from"../../core/Logger.js";import{MultiOriginJSONMixin as u}from"../../core/MultiOriginJSONSupport.js";import{sqlAnd as c}from"../../core/sql.js";import{objectToQuery as f}from"../../core/urlUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as h}from"../../core/accessorSupport/decorators/cast.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";import{ensureInteger as I,ensureType as w,Integer as v,ensureClass as j}from"../../core/accessorSupport/ensureType.js";import{OriginId as L,nameToId as D}from"../../core/accessorSupport/PropertyOrigin.js";import{getProperties as E}from"../../core/accessorSupport/utils.js";import F from"../graphics/sources/support/QueryTask.js";import x from"./FeatureType.js";import P from"./Field.js";import O from"./FieldsIndex.js";import T from"./LabelClass.js";import{validateLabelingInfo as _}from"./labelingInfo.js";import A from"./LayerFloorInfo.js";import{getFeatureLayerCapabilities as V}from"./serviceCapabilitiesUtils.js";import{DataLayerSource as M}from"./source/DataLayerSource.js";import{MapLayerSource as N}from"./source/MapLayerSource.js";import q from"../../rest/support/AttachmentQuery.js";import C from"../../rest/support/Query.js";import{createPopupTemplate as R}from"../../support/popupUtils.js";import U from"../../geometry/Extent.js";import{featureGeometryTypeKebabDictionary as k}from"../../geometry/support/typeUtils.js";var Q;function B(e){return null!=e&&"esriSMS"===e.type}function J(e,r,t){const i=this.originIdOf(r)>=D(t.origin);return{ignoreOrigin:!0,allowNull:i,enabled:!!t&&("map-image"===t.layer?.type&&(t.writeSublayerStructure||i))}}function $(e,r,t){return{enabled:!!t&&("tile"===t.layer?.type&&(t.origin&&this.originIdOf(r)>=D(t.origin)||this._isOverridden(r)))}}function G(e,r,t){return{ignoreOrigin:!0,enabled:t&&t.writeSublayerStructure||!1}}function H(e,r,t){return{ignoreOrigin:!0,enabled:!!t&&(t.writeSublayerStructure||this.originIdOf(r)>=D(t.origin))}}let z=0;const K=new Set;K.add("layer"),K.add("parent"),K.add("loaded"),K.add("loadStatus"),K.add("loadError"),K.add("loadWarnings");let W=Q=class extends(u(n(y))){constructor(e){super(e),this.capabilities=void 0,this.maxScaleRange={minScale:0,maxScale:0},this.fields=null,this.fullExtent=null,this.geometryType=null,this.globalIdField=null,this.legendEnabled=!0,this.objectIdField=null,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.sourceJSON=null,this.title=null,this.typeIdField=null,this.type="sublayer",this.types=null,this._lastParsedUrl=null}async load(e){return this.addResolvingPromise((async()=>{const{layer:r,url:t}=this;if(!r&&!t)throw new l("sublayer:missing-layer","Sublayer can't be loaded without being part of a layer",{sublayer:this});const i=r?await r.fetchSublayerInfo(this,e):(await o(t,{responseType:"json",query:{f:"json"},...e})).data;i&&(this.sourceJSON=i,this.read({layerDefinition:i},{origin:"service"}))})()),this}readCapabilities(e,r){r=r.layerDefinition||r;const{operations:{supportsQuery:t,supportsQueryAttachments:i},query:{supportsFormatPBF:o},data:{supportsAttachment:a}}=V(r,this.url);return{exportMap:{supportsModification:!!r.canModifyLayer},operations:{supportsQuery:t,supportsQueryAttachments:i},data:{supportsAttachment:a},query:{supportsFormatPBF:o}}}get defaultPopupTemplate(){return this.createPopupTemplate()}set definitionExpression(e){this._setAndNotifyLayer("definitionExpression",e)}get effectiveScaleRange(){const{minScale:e,maxScale:r}=this;return{minScale:e,maxScale:r}}readMaxScaleRange(e,r){return{minScale:(r=r.layerDefinition||r).minScale??0,maxScale:r.maxScale??0}}get fieldsIndex(){return new O(this.fields||[])}set floorInfo(e){this._setAndNotifyLayer("floorInfo",e)}readGlobalIdFieldFromService(e,r){if((r=r.layerDefinition||r).globalIdField)return r.globalIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeGlobalID"===t.type)return t.name}get id(){const e=this._get("id");return e??z++}set id(e){this._get("id")!==e&&(!1!==this.layer?.capabilities?.exportMap?.supportsDynamicLayers?this._set("id",e):this._logLockedError("id","capability not available 'layer.capabilities.exportMap.supportsDynamicLayers'"))}set labelingInfo(e){this._setAndNotifyLayer("labelingInfo",e)}writeLabelingInfo(e,r,t,i){e&&e.length&&(r.layerDefinition={drawingInfo:{labelingInfo:e.map((e=>e.write({},i)))}})}set labelsVisible(e){this._setAndNotifyLayer("labelsVisible",e)}set layer(e){this._set("layer",e),this.sublayers&&this.sublayers.forEach((r=>r.layer=e))}set listMode(e){this._set("listMode",e)}set minScale(e){this._setAndNotifyLayer("minScale",e)}readMinScale(e,r){return r.minScale||r.layerDefinition?.minScale||0}set maxScale(e){this._setAndNotifyLayer("maxScale",e)}readMaxScale(e,r){return r.maxScale||r.layerDefinition?.maxScale||0}readObjectIdFieldFromService(e,r){if((r=r.layerDefinition||r).objectIdField)return r.objectIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeOID"===t.type)return t.name}set opacity(e){this._setAndNotifyLayer("opacity",e)}readOpacity(e,r){const t=r.layerDefinition;return 1-.01*((null!=t?.transparency?t.transparency:t?.drawingInfo?.transparency)??0)}writeOpacity(e,r,t,i){r.layerDefinition={drawingInfo:{transparency:100-100*e}}}writeParent(e,r){this.parent&&this.parent!==this.layer?r.parentLayerId=I(this.parent.id):r.parentLayerId=-1}get queryTask(){if(!this.layer)return null;const{spatialReference:e}=this.layer,r="gdbVersion"in this.layer?this.layer.gdbVersion:void 0,{capabilities:t,fieldsIndex:i}=this,o=has("featurelayer-pbf")&&t?.query.supportsFormatPBF,a=t?.operations?.supportsQueryAttachments??!1;return new F({url:this.url,pbfSupported:o,fieldsIndex:i,gdbVersion:r,sourceSpatialReference:e,queryAttachmentsSupported:a})}set renderer(e){if(e)for(const r of e.getSymbols())if(a(r)){d.getLogger(this).warn("Sublayer renderer should use 2D symbols");break}this._setAndNotifyLayer("renderer",e)}get source(){return this._get("source")||new N({mapLayerId:this.id})}set source(e){this._setAndNotifyLayer("source",e)}set sublayers(e){this._handleSublayersChange(e,this._get("sublayers")),this._set("sublayers",e)}castSublayers(e){return w(s.ofType(Q),e)}writeSublayers(e,r,t){this.sublayers?.length&&(r[t]=this.sublayers.map((e=>e.id)).toArray().reverse())}readTitle(e,r){return r.layerDefinition?.name??r.name}readTypeIdField(e,r){let t=(r=r.layerDefinition||r).typeIdField;if(t&&r.fields){t=t.toLowerCase();const e=r.fields.find((e=>e.name.toLowerCase()===t));e&&(t=e.name)}return t}get url(){const e=this.layer?.parsedUrl??this._lastParsedUrl,r=this.source;if(!e)return null;if(this._lastParsedUrl=e,"map-layer"===r?.type)return`${e.path}/${r.mapLayerId}`;const t={layer:JSON.stringify({source:this.source})};return`${e.path}/dynamicLayer?${f(t)}`}set url(e){this._overrideIfSome("url",e)}set visible(e){this._setAndNotifyLayer("visible",e)}writeVisible(e,r,t,i){r[t]=this.getAtOrigin("defaultVisibility","service")||e}clone(){const{store:e}=E(this),r=new Q;return E(r).store=e.clone(K),this.commitProperty("url"),r._lastParsedUrl=this._lastParsedUrl,r}createPopupTemplate(e){return R(this,e)}createQuery(){return new C({returnGeometry:!0,where:this.definitionExpression||"1=1"})}async createFeatureLayer(){if(this.hasOwnProperty("sublayers"))return null;const e=(await import("../FeatureLayer.js")).default,{layer:r,url:t}=this;let i;if(t&&this.originIdOf("url")>L.SERVICE)i=new e({url:t});else{if(!r?.parsedUrl)throw new l("createFeatureLayer:missing-information","Cannot create a FeatureLayer without a url or a parent layer");{const t=r.parsedUrl;i=new e({url:t.path}),t&&this.source&&("map-layer"===this.source.type?i.layerId=this.source.mapLayerId:i.dynamicDataSource=this.source)}}return null!=r?.refreshInterval&&(i.refreshInterval=r.refreshInterval),this.definitionExpression&&(i.definitionExpression=this.definitionExpression),this.floorInfo&&(i.floorInfo=p(this.floorInfo)),this.originIdOf("labelingInfo")>L.SERVICE&&(i.labelingInfo=p(this.labelingInfo)),this.originIdOf("labelsVisible")>L.DEFAULTS&&(i.labelsVisible=this.labelsVisible),this.originIdOf("legendEnabled")>L.DEFAULTS&&(i.legendEnabled=this.legendEnabled),this.originIdOf("visible")>L.DEFAULTS&&(i.visible=this.visible),this.originIdOf("minScale")>L.DEFAULTS&&(i.minScale=this.minScale),this.originIdOf("maxScale")>L.DEFAULTS&&(i.maxScale=this.maxScale),this.originIdOf("opacity")>L.DEFAULTS&&(i.opacity=this.opacity),this.originIdOf("popupTemplate")>L.DEFAULTS&&(i.popupTemplate=p(this.popupTemplate)),this.originIdOf("renderer")>L.SERVICE&&(i.renderer=p(this.renderer)),"data-layer"===this.source?.type&&(i.dynamicDataSource=this.source.clone()),this.originIdOf("title")>L.DEFAULTS&&(i.title=this.title),"map-image"===r?.type&&r.originIdOf("customParameters")>L.DEFAULTS&&(i.customParameters=r.customParameters),"tile"===r?.type&&r.originIdOf("customParameters")>L.DEFAULTS&&(i.customParameters=r.customParameters),i}getField(e){return this.fieldsIndex.get(e)}getFeatureType(e){const{typeIdField:r,types:t}=this;if(!r||!e)return null;const i=e.attributes?e.attributes[r]:void 0;if(null==i)return null;let o=null;return t?.some((e=>{const{id:r}=e;return null!=r&&(r.toString()===i.toString()&&(o=e),!!o)})),o}getFieldDomain(e,r){const t=r?.feature,i=this.getFeatureType(t);if(i){const r=i.domains&&i.domains[e];if(r&&"inherited"!==r.type)return r}return this._getLayerDomain(e)}async queryAttachments(e,r){await this.load(),e=q.from(e);const t=this.capabilities;if(!t?.data?.supportsAttachment)throw new l("queryAttachments:not-supported","this layer doesn't support attachments");const{attachmentTypes:i,objectIds:o,globalIds:a,num:s,size:n,start:p,where:y}=e;if(!t?.operations?.supportsQueryAttachments){if(i?.length>0||a?.length>0||n?.length>0||s||p||y)throw new l("queryAttachments:option-not-supported","when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",e)}if(!(o?.length||a?.length||y))throw new l("queryAttachments:invalid-query","'objectIds', 'globalIds', or 'where' are required to perform attachment query",e);return this.queryTask.executeAttachmentQuery(e,r)}async queryFeatures(e=this.createQuery(),r){if(await this.load(),!this.capabilities.operations.supportsQuery)throw new l("queryFeatures:not-supported","this layer doesn't support queries.");if(!this.url)throw new l("queryFeatures:not-supported","this layer has no url.");const t=await this.queryTask.execute(e,{...r,query:{...this.layer?.customParameters,token:this.layer?.apiKey}});if(t?.features)for(const i of t.features)i.sourceLayer=this;return t}toExportImageJSON(e){const r={id:this.id,source:this.source?.toJSON()||{mapLayerId:this.id,type:"mapLayer"}},t=c(e,this.definitionExpression);null!=t&&(r.definitionExpression=t);const i=["renderer","labelingInfo","opacity","labelsVisible"].reduce(((e,r)=>(e[r]=this.originIdOf(r),e)),{}),o=Object.keys(i).some((e=>i[e]>L.SERVICE));if(o){const e=r.drawingInfo={};if(i.renderer>L.SERVICE&&(e.renderer=this.renderer?this.renderer.toJSON():null),i.labelsVisible>L.SERVICE&&(e.showLabels=this.labelsVisible),this.labelsVisible&&i.labelingInfo>L.SERVICE)if(this.labelingInfo){!this.loaded&&this.labelingInfo?.some((e=>!e.labelPlacement))&&d.getLogger(this).warnOnce(`A Sublayer (title: ${this.title}, id: ${this.id}) has an undefined 'labelPlacement' and so labels cannot be displayed. Either define a valid 'labelPlacement' or call Sublayer.load() to use a default value based on geometry type.`,{sublayer:this});let r=this.labelingInfo;null!=this.geometryType&&(r=_(this.labelingInfo,k.toJSON(this.geometryType))),e.showLabels=!0,e.labelingInfo=r.filter((e=>e.labelPlacement)).map((e=>e.toJSON({origin:"service",layer:this.layer})))}else e.showLabels=!1;i.opacity>L.SERVICE&&(e.transparency=100-100*this.opacity),this._assignDefaultSymbolColors(e.renderer)}return r}_assignDefaultSymbolColors(e){this._forEachSimpleMarkerSymbols(e,(e=>{e.color||"esriSMSX"!==e.style&&"esriSMSCross"!==e.style||(e.outline?.color?e.color=e.outline.color:e.color=[0,0,0,0])}))}_forEachSimpleMarkerSymbols(e,r){if(e){const t=("uniqueValueInfos"in e?e.uniqueValueInfos:"classBreakInfos"in e?e.classBreakInfos:null)??[];for(const e of t)B(e.symbol)&&r(e.symbol);"symbol"in e&&B(e.symbol)&&r(e.symbol),"defaultSymbol"in e&&B(e.defaultSymbol)&&r(e.defaultSymbol)}}_setAndNotifyLayer(e,r){const t=this.layer,i=this._get(e);let o,a;switch(e){case"definitionExpression":case"floorInfo":o="supportsSublayerDefinitionExpression";break;case"minScale":case"maxScale":case"visible":o="supportsSublayerVisibility";break;case"labelingInfo":case"labelsVisible":case"opacity":case"renderer":case"source":o="supportsDynamicLayers",a="supportsModification"}const s=E(this).getDefaultOrigin();if("service"!==s){if(o&&!1===this.layer?.capabilities?.exportMap?.[o])return void this._logLockedError(e,`capability not available 'layer.capabilities.exportMap.${o}'`);if(a&&!1===this.capabilities?.exportMap[a])return void this._logLockedError(e,`capability not available 'capabilities.exportMap.${a}'`)}"source"!==e||"not-loaded"===this.loadStatus?(this._set(e,r),"service"!==s&&i!==r&&t&&t.emit&&t.emit("sublayer-update",{propertyName:e,target:this})):this._logLockedError(e,"'source' can't be changed after calling sublayer.load()")}_handleSublayersChange(e,r){r&&(r.forEach((e=>{e.parent=null,e.layer=null})),this.removeAllHandles()),e&&(e.forEach((e=>{e.parent=this,e.layer=this.layer})),this.addHandles([e.on("after-add",(({item:e})=>{e.parent=this,e.layer=this.layer})),e.on("after-remove",(({item:e})=>{e.parent=null,e.layer=null})),e.on("before-changes",(e=>{const r=this.layer?.capabilities?.exportMap?.supportsSublayersChanges;null==r||r||(d.getLogger(this).error(new l("sublayer:sublayers-non-modifiable","Sublayer can't be added, moved, or removed from the layer's sublayers",{sublayer:this,layer:this.layer})),e.preventDefault())}))]))}_logLockedError(e,r){const{layer:t,declaredClass:i}=this;d.getLogger(i).error(new l("sublayer:locked",`Property '${String(e)}' can't be changed on Sublayer from the layer '${t?.id}'`,{reason:r,sublayer:this,layer:t}))}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}};W.test={isMapImageLayerOverridePolicy:e=>e===G||e===J,isTileImageLayerOverridePolicy:e=>e===$},e([m({readOnly:!0})],W.prototype,"capabilities",void 0),e([b("service","capabilities",["layerDefinition.canModifyLayer","layerDefinition.capabilities"])],W.prototype,"readCapabilities",null),e([m()],W.prototype,"defaultPopupTemplate",null),e([m({type:String,value:null,json:{name:"layerDefinition.definitionExpression",write:{allowNull:!0,overridePolicy:J}}})],W.prototype,"definitionExpression",null),e([m({readOnly:!0})],W.prototype,"effectiveScaleRange",null),e([b("service","maxScaleRange",["minScale","maxScale"])],W.prototype,"readMaxScaleRange",null),e([m({type:[P],json:{origins:{service:{read:{source:"layerDefinition.fields"}}}}})],W.prototype,"fields",void 0),e([m({readOnly:!0})],W.prototype,"fieldsIndex",null),e([m({type:A,value:null,json:{name:"layerDefinition.floorInfo",read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo",overridePolicy:J},origins:{"web-scene":{read:!1,write:!1}}}})],W.prototype,"floorInfo",null),e([m({type:U,json:{read:{source:"layerDefinition.extent"}}})],W.prototype,"fullExtent",void 0),e([m({type:k.apiValues,json:{origins:{service:{name:"layerDefinition.geometryType",read:{reader:k.read}}}}})],W.prototype,"geometryType",void 0),e([m({type:String})],W.prototype,"globalIdField",void 0),e([b("service","globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],W.prototype,"readGlobalIdFieldFromService",null),e([m({type:v,json:{write:{ignoreOrigin:!0}}})],W.prototype,"id",null),e([m({value:null,type:[T],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo"},write:{target:"layerDefinition.drawingInfo.labelingInfo",overridePolicy:G}}})],W.prototype,"labelingInfo",null),e([S("labelingInfo")],W.prototype,"writeLabelingInfo",null),e([m({type:Boolean,value:!0,json:{read:{source:"layerDefinition.drawingInfo.showLabels"},write:{target:"layerDefinition.drawingInfo.showLabels",overridePolicy:G}}})],W.prototype,"labelsVisible",null),e([m({value:null})],W.prototype,"layer",null),e([m({type:String,json:{write:{overridePolicy:$}}})],W.prototype,"layerItemId",void 0),e([m({type:Boolean,value:!0,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend",overridePolicy:H}}})],W.prototype,"legendEnabled",void 0),e([m({type:["show","hide","hide-children"],value:"show",json:{read:!1,write:!1,origins:{"web-scene":{read:!0,write:!0}}}})],W.prototype,"listMode",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"minScale",null),e([b("minScale",["minScale","layerDefinition.minScale"])],W.prototype,"readMinScale",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"maxScale",null),e([b("maxScale",["maxScale","layerDefinition.maxScale"])],W.prototype,"readMaxScale",null),e([m({type:String})],W.prototype,"objectIdField",void 0),e([b("service","objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],W.prototype,"readObjectIdFieldFromService",null),e([m({type:Number,value:1,json:{write:{target:"layerDefinition.drawingInfo.transparency",overridePolicy:G}}})],W.prototype,"opacity",null),e([b("opacity",["layerDefinition.drawingInfo.transparency","layerDefinition.transparency"])],W.prototype,"readOpacity",null),e([S("opacity")],W.prototype,"writeOpacity",null),e([m({json:{type:v,write:{target:"parentLayerId",writerEnsuresNonNull:!0,overridePolicy:G}}})],W.prototype,"parent",void 0),e([S("parent")],W.prototype,"writeParent",null),e([m({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,r)=>!r.disablePopup},write:{target:"disablePopup",overridePolicy:H,writer(e,r,t){r[t]=!e}}}})],W.prototype,"popupEnabled",void 0),e([m({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy:H}}})],W.prototype,"popupTemplate",void 0),e([m({readOnly:!0})],W.prototype,"queryTask",null),e([m({types:t,value:null,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G},origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G}}}}})],W.prototype,"renderer",null),e([m({types:{key:"type",base:null,typeMap:{"data-layer":M,"map-layer":N}},cast(e){if(e){if("mapLayerId"in e)return j(N,e);if("dataSource"in e)return j(M,e)}return e},json:{name:"layerDefinition.source",write:{overridePolicy:G}}})],W.prototype,"source",null),e([m()],W.prototype,"sourceJSON",void 0),e([m({value:null,json:{type:[v],write:{target:"subLayerIds",allowNull:!0,overridePolicy:G}}})],W.prototype,"sublayers",null),e([h("sublayers")],W.prototype,"castSublayers",null),e([S("sublayers")],W.prototype,"writeSublayers",null),e([m({type:String,json:{name:"name",write:{overridePolicy:H}}})],W.prototype,"title",void 0),e([b("service","title",["name","layerDefinition.name"])],W.prototype,"readTitle",null),e([m({type:String})],W.prototype,"typeIdField",void 0),e([m({json:{read:!1},readOnly:!0,value:"sublayer"})],W.prototype,"type",void 0),e([b("typeIdField",["layerDefinition.typeIdField"])],W.prototype,"readTypeIdField",null),e([m({type:[x],json:{origins:{service:{read:{source:"layerDefinition.types"}}}}})],W.prototype,"types",void 0),e([m({type:String,json:{name:"layerUrl",write:{overridePolicy:$}}})],W.prototype,"url",null),e([m({type:Boolean,value:!0,json:{read:{source:"defaultVisibility"},write:{target:"defaultVisibility",overridePolicy:G}}})],W.prototype,"visible",null),e([S("visible")],W.prototype,"writeVisible",null),W=Q=e([g("esri.layers.support.Sublayer")],W);const X=W;export{X as default};
|