@arcgis/core 6.0.0-next.56 → 6.0.0-next.57
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/00c227bcecc28fe278bb.js +1 -0
- package/assets/esri/core/workers/chunks/{88df1b8b295d3aed649f.js → 10499abb7678e95d9f05.js} +1 -1
- package/assets/esri/core/workers/chunks/1afc8820c283ef785729.js +1 -0
- package/assets/esri/core/workers/chunks/1c874f86bfd0963aa3d2.js +1 -0
- package/assets/esri/core/workers/chunks/2a84c9a81ec2bed3d4e5.js +1 -0
- package/assets/esri/core/workers/chunks/2f31766bc0f9d1d70c5a.js +1 -0
- package/assets/esri/core/workers/chunks/35109db6a6be66f895f7.js +1 -0
- package/assets/esri/core/workers/chunks/373b140f92eda3857f82.js +1 -0
- package/assets/esri/core/workers/chunks/38bba952c38af5a150e7.js +1 -0
- package/assets/esri/core/workers/chunks/3aea09191b737dc1de70.js +1 -0
- package/assets/esri/core/workers/chunks/3fc4b7d0ee460fc96176.js +1 -0
- package/assets/esri/core/workers/chunks/457bd1bd37c67b61efe8.js +1 -0
- package/assets/esri/core/workers/chunks/601d668e70c5d72fe58c.js +1 -0
- package/assets/esri/core/workers/chunks/651e33be8bb3995d749f.js +1 -0
- package/assets/esri/core/workers/chunks/721f43554b9654481de7.js +1 -0
- package/assets/esri/core/workers/chunks/75274ac3ddf7c45f47d7.js +1 -0
- package/assets/esri/core/workers/chunks/80d1267606383ae537f2.js +1 -0
- package/assets/esri/core/workers/chunks/8920d0b11951b57d6a66.js +1 -0
- package/assets/esri/core/workers/chunks/92d97e0fcc20dd5f5ac4.js +1 -0
- package/assets/esri/core/workers/chunks/9ca84fa9423654061d05.js +1 -0
- package/assets/esri/core/workers/chunks/9e372af03d62fa5ad10e.js +1 -0
- package/assets/esri/core/workers/chunks/b10c534cbe311d17b7d5.js +1 -0
- package/assets/esri/core/workers/chunks/{dfa1b0308e5e82d1ddfe.js → be0133fa63c5d6545a7f.js} +1 -1
- package/assets/esri/core/workers/chunks/cb0e3614b78c78040662.js +1 -0
- package/assets/esri/core/workers/chunks/d22e3b5d836dffdf91cc.js +1 -0
- package/assets/esri/core/workers/chunks/e0341def2d81e679a200.js +1 -0
- package/assets/esri/core/workers/chunks/e42e9dd3c933f5f864ab.js +1 -0
- package/assets/esri/core/workers/chunks/f4fcf87da4495584223d.js +1 -0
- package/assets/esri/core/workers/chunks/f989588dfdbb69056491.js +1 -0
- package/assets/esri/core/workers/chunks/fc5b920f9756e11c2f88.js +1 -0
- package/chunks/Component.glsl.js +1 -0
- package/chunks/GlobalIllumination.glsl.js +12 -11
- package/chunks/GlobalIlluminationBlur.glsl.js +6 -4
- package/chunks/Terrain.glsl.js +24 -23
- package/chunks/Water.glsl.js +24 -23
- package/config.js +1 -1
- package/core/memoryEstimations.js +1 -1
- package/interfaces.d.ts +0 -1
- package/kernel.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/dehydratedFeatures.js +1 -1
- package/layers/graphics/transferFeatures.js +1 -1
- package/layers/support/fieldUtils.d.ts +129 -57
- package/layers/support/fieldUtils.js +1 -1
- package/networks/Network.js +1 -1
- package/networks/support/TopologyValidationJobInfo.js +1 -1
- package/package.json +2 -2
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/GroundAndIMSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/lastFrameUniforms.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +15 -12
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlur.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/globalIlluminationUniforms.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/getWaterColor.glsl.js +89 -0
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/assets/esri/core/workers/chunks/193a73a2c7f4f8482c21.js +0 -1
- package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +0 -1
- package/assets/esri/core/workers/chunks/2d4788be418a4e5f6606.js +0 -1
- package/assets/esri/core/workers/chunks/333140b18aeb5a50b654.js +0 -1
- package/assets/esri/core/workers/chunks/4761cd436abceee858bf.js +0 -1
- package/assets/esri/core/workers/chunks/4de08ead94660025075b.js +0 -1
- package/assets/esri/core/workers/chunks/56f227e1a9e51d1fd742.js +0 -1
- package/assets/esri/core/workers/chunks/5bd451c7db17ee8f0315.js +0 -1
- package/assets/esri/core/workers/chunks/5c34d49a6c9cc34b7626.js +0 -1
- package/assets/esri/core/workers/chunks/62ddd3a82864e26f009a.js +0 -1
- package/assets/esri/core/workers/chunks/703373f529c1c334cfad.js +0 -1
- package/assets/esri/core/workers/chunks/733c32d8091427d84de7.js +0 -1
- package/assets/esri/core/workers/chunks/860552f49f17de2f3353.js +0 -1
- package/assets/esri/core/workers/chunks/9b727f45dfea84357b57.js +0 -1
- package/assets/esri/core/workers/chunks/a05a2c2aaf0c288f9681.js +0 -1
- package/assets/esri/core/workers/chunks/ab76170c374fd67ce8cd.js +0 -1
- package/assets/esri/core/workers/chunks/aebd12488b4004e207a3.js +0 -1
- package/assets/esri/core/workers/chunks/c7b1c6d57603fa385c54.js +0 -1
- package/assets/esri/core/workers/chunks/cd8181600623e18f511c.js +0 -1
- package/assets/esri/core/workers/chunks/cef537fa9705dd1cf685.js +0 -1
- package/assets/esri/core/workers/chunks/d33403d578fbeecaf844.js +0 -1
- package/assets/esri/core/workers/chunks/ddbfa664e69612295785.js +0 -1
- package/assets/esri/core/workers/chunks/ded81c504bf44806ca7d.js +0 -1
- package/assets/esri/core/workers/chunks/e0466387b2ab54d706ca.js +0 -1
- package/assets/esri/core/workers/chunks/ee70be138831cc2a0f56.js +0 -1
- package/assets/esri/core/workers/chunks/efd6ea0966f60ab19520.js +0 -1
- package/assets/esri/core/workers/chunks/f23c4fd014126ea7abc6.js +0 -1
- package/assets/esri/core/workers/chunks/f6e40f3faf0c80cf1b3a.js +0 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +0 -70
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{runUntracked as i}from"../../../core/accessorSupport/tracking.js";import has from"../../../core/has.js";import{exactEquals as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import o from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{EsriPromiseMixin as l}from"../../../core/Promise.js";import{isAbortError as u}from"../../../core/promiseUtils.js";import{watch as d,sync as f,initial as p}from"../../../core/reactiveUtils.js";import{UpdatingHandles as m}from"../../../core/support/UpdatingHandles.js";import{create as h,fromValues as g}from"../../../geometry/support/aaBoundingRect.js";import{I3SClientNodeLoader as _}from"../../../views/3d/layers/i3s/I3SClientNodeLoader.js";import{I3SDataRequester as v}from"../../../views/3d/layers/i3s/I3SDataRequester.js";import{addCallback as y}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as b}from"../../../views/3d/layers/i3s/I3SIndex.js";import x from"../../../views/3d/layers/i3s/I3SLodHandling.js";import S from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{getVertexCrs as C,getIndexCrs as w,findIntersectingNodes as T}from"../../../views/3d/layers/i3s/I3SUtil.js";import E from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{groundNavigationConstants as D}from"../../../views/3d/state/utils/groundNavigationUtils.js";import{projectElevationUpdateExtent as O}from"../../../views/3d/support/elevationUpdateExtentUtils.js";import{toBoundingRect as k}from"../../../views/3d/support/extentUtils.js";import{minQuality as A}from"../../../views/3d/support/MemoryController.js";import{PromiseQueue as j}from"../../../views/support/PromiseQueue.js";import{noBudget as M}from"../../../views/support/Scheduler.js";const N=1e4,P=1e-4;let F=class extends l(t){get isMeshPyramid(){return this.layer.profile===`mesh-pyramids`||this.layer.store?.lodType===`MeshPyramid`}get isGraphics3D(){return this.layer.profile===`points`}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(this.layer.priority==null||this.layer.priority===`High`)}get indexRequester(){return new v(this.layer.customParameters,this.layer.apiKey)}get dataRequester(){return new v(this.layer.customParameters,this.layer.apiKey)}get crsVertex(){return C(this.layer)}get crsIndex(){return w(this.layer)}get layer(){return this.layerView.layer}get updating(){return this.running||this._updatingHandles.updating}get rootNodeVisible(){return i(()=>{if(this._index){let 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.featureTarget=5e4,this.fixedFeatureTarget=!1,this._updatingHandles=new m,this.running=!0,this.updatingProgress=1,this.leavesReached=!1,this.worker=null,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._newLoadingNodes=new c({deallocator:null}),this._modificationsNodeFilteringArray=new c,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=[],this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._idleQueue=new j,this._elevationUpdateNodes=new c({deallocator:null}),this._errorCount=0}initialize(){let{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new x(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(([n])=>{if(this.destroyed||!e||e.destroyed||!n)return;let{view:r,clientGeometry:i}=e;if(this._setClippingArea(r.clippingArea),this.addHandles([this._updatingHandles.add(()=>r?.pointsOfInterest?.focus?.renderLocation,e=>this._pointOfInterestChanged(e),{initial:!0,equals:a}),d(()=>r.quality,()=>this._setCameraDirty(),f),this._updatingHandles.add(()=>r.state.mode===2,t=>{this._updateIdleState(t),t&&(this._index?.resetFailedNodes(),e.contentVisible||this._updateViewData())},p),this._updatingHandles.add(()=>e.contentVisible,e=>{e&&this._index?.invalidateAllElevationRanges(),this.restartNodeLoading()},p),y(e.view.resourceController.scheduler,this),this._updatingHandles.add(()=>[this.featureTarget,this.fixedFeatureTarget],()=>{this._setCameraDirty(),this._stableFeatureLOD=!1}),this._updatingHandles.add(()=>r.state?.contentCamera,()=>this._setCameraDirty()),this._updatingHandles.add(()=>r.navigation.mode?.type,e=>{this._setCameraDirty(),this._index&&(this._index.isGroundNavigationMode=e===`ground`)}),this._updatingHandles.add(()=>t.elevationInfo,e=>this._elevationInfoChanged(e),f),this._updatingHandles.add(()=>e.lodFactor,()=>this._setCameraDirty()),this._updatingHandles.add(()=>e.availableFields,()=>this._requiredFieldsChange()),this._updatingHandles.add(()=>e.holeFilling,e=>this._index!=null&&(this._index.holeFilling=e))]),this._viewportQueries=new E(this.crsIndex,r.renderCoordsHelper,r.state.contentCamera,!r.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?r.groundView:r.elevationProvider,r.state.isGlobal,this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._clientNodeLoader=new _(this.layer.uid,{indexSR:this.crsIndex,vertexSR:this.crsVertex,renderSR:r.renderCoordsHelper.spatialReference},r.resourceController.memoryController,this.worker),this._index=new b(t,r.navigation.mode.type===`ground`,D.i3sNodeDownwardCheckDistanceInMeters/r.renderCoordsHelper.unitInMeters,n,this.indexRequester,this._clientNodeLoader,this._viewportQueries,o.getLogger(this),e.holeFilling,t=>e.isNodeLoaded(t),t=>e.isNodeReloading(t),e=>this._shouldLoadNode(e),e=>this._enableFromGPUCache(e,1),e=>this._needsUpdate(e),t=>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),i!=null){for(let e of i)this._addMesh(e.mesh,e.oid);this.addHandles(i.on(`change`,e=>{for(let t of e.removed)this._removeMesh(t.oid);for(let t of e.added)this._addMesh(t.mesh,t.oid)}))}this._startNodeLoading()}))}updateNodeModificationStatus(e){let t=this._index,n=this.layerView;t!=null&&n?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll(e=>{let n=t.getNode(e);n!=null&&this._modificationsNodeFilteringArray.push(n)}),n.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._updatingHandles.destroy(),this._nodeLoader=null,I.prune(),this._newLoadingNodes.prune(),this._modificationsNodeFilteringArray.prune(),this._elevationUpdateNodes.prune(),L!=null&&(L.hide(),L=null),this._index=null,this._lodHandling=s(this._lodHandling),this._nodeLoader=null,this._clientNodeLoader=null,this._viewportQueries=null,this._set(`worker`,null)}get viewportQueries(){return this._viewportQueries}_getRequiredAttributes(){if(this._attributeStorageInfo==null||!this._fields||!this.layerView.availableFields)return[];let e=this._attributeStorageInfo,t=this._fields,n=this.layer.objectIdField;return this.layerView.availableFields.map(n=>{let r=z(e,n),i=z(t,n);return r>=0&&i>=0?{index:r,name:t[i].name,field:t[i],attributeStorageInfo:e[r]}:null}).filter(e=>e!=null&&e.name!==n)}_requiredFieldsChange(){let e=this._getRequiredAttributes();R(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){let t=h();this._clippingArea=k(e,t,this.layerView.view.renderSpatialReference)?t:null}_pointOfInterestChanged(e){this._viewportQueries!=null&&(this._viewportQueries.setPointOfInterest(e),this._index!=null&&this._index.requestUpdate())}updateClippingArea(e){this._setClippingArea(e),this._viewportQueries!=null&&this._index!=null&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateRunning()}_addMesh(e,t){if(this._index==null)return;let n=this._clientNodeLoader.createMeshNodeInfo(e,t),r=this._index.addClientNodeToIndex(n.id,n.mbs);this._clientNodeLoader.addMeshNode(r,n),this._evaluateRunning(),this.notifyChange(`rootNodeVisible`)}_removeMesh(e){let t=this._clientNodeLoader.getMeshNodeIndex(e);if(t!=null){if(this._index!=null)this._index.removeClientNodeFromIndex(t,(e,t)=>{this.layerView.removeNode(t),this._clientNodeLoader.removeNode(e),this.layerView.deleteCachedNodeData&&e!=null&&this.layerView.deleteCachedNodeData(e),this.layerView.deleteCachedGPUData?.(this.layerView.loadCachedGPUData?.(t))},(e,t,n)=>{this._clientNodeLoader.updateNodeIndex(e,t,n),this.layerView.updateNodeIndex&&this.layerView.updateNodeIndex(t,n)}),this.notifyChange(`rootNodeVisible`);else throw Error(`delayed removal of client side i3s node geometry not supported yet.`)}}updateElevationChanged(e,t){let n=this._index,r=this._viewportQueries;if(n?.rootNode==null||t==null||r==null)return null;let i=r.elevationIntersectionSpatialReference;i.equals(t)||(O(e,t,B,i)||g(-1/0,-1/0,1/0,1/0,B),e=B);let a=this._elevationUpdateNodes;return a.clear(),T(e,n.rootNode,n,e=>a.push(e.index),r),a.length&&(a.forAll(e=>n.updateElevationChanged(e)),this._setCameraDirty()),a}removeAllGeometryObbs(){this._index!=null&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return this._viewportQueries==null?null:this._viewportQueries.calculateServiceMbsInRenderSRElevationAdjusted(e)}_elevationInfoChanged(e){this._index!=null&&(this._index.updateElevationInfo(e,this.isMeshPyramid||this.isGraphics3D),this._setCameraDirty())}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateRunning()}schedule(e,t){let n=this._idleQueue.push(e,t);return this._evaluateRunning(),n}reschedule(e,t){let n=this._idleQueue.unshift(e,t);return this._evaluateRunning(),n}get _isIntegratedMesh(){return this.layer.type===`integrated-mesh`}get unloadedMemoryEstimate(){return this._index==null||!this.layerView.contentVisible?0:this._index.unloadedMemoryEstimate*this._lodDropFactor}async _loadNodeData(e,t){return e.index<0?this._clientNodeLoader.loadNodeData(e.id,t):this._nodeLoader.loadNodeData(e,t)}async _loadAttributes(e,t,n){return(e.index<0?this._clientNodeLoader:this._nodeLoader).loadAttributes(e,t,n)}get indexDepth(){return this._index==null?0:this._index.maxLevel}set disableMemCache(e){this._disableMemCache=!this.layerView.loadCachedGPUData||!this.layerView.addCachedGPUData||e}runTask(e,t){return this.layerView.contentVisible?!this.layerView.visible||this._index==null?-1/0:(this._processWithErrorLogging(e,t),this._index.maxPriority):(this._updateViewData(),this._evaluateRunning(),-1/0)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(e){this._errorCount<50?o.getLogger(this).error(`Error during processing: ${e} at ${e.stack}`):this._errorCount===50&&o.getLogger(this).error(`Too many errors for this layer. Further errors will not be displayed.`),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),this._nodeLoader!=null&&this._index!=null&&(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._evaluateRunning())}_processIndex(e){if(this._index==null)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.pushAll(this._index.updates.missing));let t=this._index.featureEstimate.leavesReached;!this._index.isLoading&&t!==this._get(`leavesReached`)&&this._set(`leavesReached`,t)}return this._index.load()}_prefetchIndex(){return this._index==null||this._loadingNodes.size>0||this._index.updates.add.length>0?!1:this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||this._index==null||this._viewportQueries==null)return;let e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,n=this._index.featureEstimate;if(n.estimate=n.estimate||t/2,this._index.indexMissing>500){if(this._featureLOD<=P)return;this._featureLOD/=1.5,this._stableFeatureLOD=!1}else if(e&&n.estimate<t){if(n.leavesReached||this._featureLOD>=N||this._stableFeatureLOD)return;let e=Math.min(10,Math.max(t/n.estimate,1.001));this._featureLOD*=e;let r=this._lod,i=this._index.checkFeatureTarget(t,r);i!==r&&(this._featureLOD=i/this._baseLOD,this._stableFeatureLOD=!0)}else if(n.estimate>t*1.2||e&&n.estimate>t){if(this._featureLOD<=P)return;this._featureLOD/=1+(n.estimate/t-1)*.25,this._stableFeatureLOD=!1}else return;this._featureLOD=Math.min(N,Math.max(P,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){let t=this._index;if(t==null)return!1;for(;this._newLoadingNodes.length>0&&!e.done;){let n=this._newLoadingNodes.pop();for(let r=t.getParent(n);r!=null&&!this.layerView.isNodeLoaded(r.index);r=t.getParent(r.index)){if(!this._disableMemCache&&!t.useNodeAsHole(r.index)){e.enabled&&e.madeProgress();break}if(this._enableFromGPUCache(r,0)){e.madeProgress();break}}}return e.hasProgressed}_processNodes(e,t){if(this._index==null)return!1;let n=(this._isIdle?100:2)-this._loadingNodes.size,r=this._index.updates;for(r.cancel.forEach(this._cancelNode,this),r.cancel=[];r.remove.length>0&&!e.done;)this.layerView.removeNode(r.remove.pop()),e.madeProgress();for(;r.update.length>0&&!e.done;){let t=this._index.getNode(r.update.pop());t!=null&&(this._updateLoadedNode(t),e.madeProgress())}for(;r.add.length>0&&!e.done&&n>0;){--n;let i=this._index.getNode(r.add.back());if(i==null||i.cacheState!==2&&!this._hasNodeLoadToken(t))break;r.add.pop(),this._loadNode(i),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){let t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=2?!1:this.index==null||!this.dataRequester.isFull(this._index.urlPrefix)}_evaluateRunning(){let e=!1,t=0;if(this.layerView){if(!this.layerView.contentVisible)e=this._cameraDirty,t=+!e;else{let n=(this._index?.indexMissing??0)+(this._index?.updates.add.length??0)*3+this._loadingNodes.size*2;e=!!(n>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.updating||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||this._index!=null&&this._index.isPrefetching),n===0&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(n,this._progressMaxNumNodes),t=1-n/this._progressMaxNumNodes}this.running=e,this.updatingProgress=t}}_updateViewData(){if(!this._cameraDirty||this._index==null||this._viewportQueries==null)return;let e=this.layerView.view,{contentCamera:t,fixedContentCamera:n}=e.state;this._viewportQueries.updateCamera(t,!n||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),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(){let e=this.layerView.lodFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*this.layerView.view.quality}get _lodDropFactor(){return this.fixedFeatureTarget?1:(Math.min(this.layerView.view.quality,.5)-A)/(.5-A)}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)||this._index==null||!this._index.isGeometryVisible(e.index))}_shouldDropNode(e){if(this._viewportQueries==null)return!1;let t=this._lodDropFactor;return t>=1||!this._lodHandling.hasNoVisibleChildren(e)?!1:Math.abs(this._viewportQueries.calcCameraDistanceToCenterAndUpdateMinmax(e))-this._viewportQueries.minCenterDistance>(this._viewportQueries.maxCenterDistance-this._viewportQueries.minCenterDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;let e=this._index;if(this._updatesDisabled||e==null||this._viewportQueries==null)return;this._updateViewData(),this._requiredAttributesDirty&&=(this._requiredAttributes=this._getRequiredAttributes(),!1);let t={textureEncodings:this.layerView.supportedTextureEncodings,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new S(this.layer,this.dataRequester,o.getLogger(this),this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e,t)=>this._removeNodes(e,t,1),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateRunning()}isNodeLoading(){return this._nodeLoader!=null&&this._index!=null}cancelNodeLoading(){this.isNodeLoading()&&(this.indexRequester.cancelAll(),this.dataRequester.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateRunning())}_removeInvisibleNodes(e){let t=this._index;if(t==null||this._viewportQueries==null)return!1;I.clear(),this.layerView.getLoadedNodeIndices(I);let n=this._viewportQueries.maxCenterDistance===0,r=n?()=>!1:e=>this._shouldDropNode(e);return I.filterInPlace(e=>{let n=t.getNode(e);return n==null||!t.isGeometryVisible(e)||r(n)}),I.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(I,e,0),n&&this._lodDropFactor<1?!1:I.length===0||(I.clear(),!1)}markNodeToRemove(e){I.push(e)}removeMarkedNodes(){this._removeNodes(I,M,0)}_removeNodes(e,t,n){if(!(e.length===0||t.done))for(this._index!=null&&this._index.requestUpdate();e.length>0&&!t.done;){let r=e.pop(),i=this._index;n===1&&this.layerView.nodeFadeoutEnabled&&i!=null&&i.isGeometryVisible(r)?this.layerView.fadeNode(r,1,!0):this.layerView.removeNode(r),t.madeProgress()}}_needsUpdate(e){if(e.resources.isEmpty||this._updatingNodes.has(e.index))return!1;let t=this.layerView.getLoadedAttributes(e.index);return t!=null&&t!==this._requiredAttributes}async _updateLoadedNode(e){let t=new AbortController,n=this._requiredAttributes;this._updatingNodes.set(e.index,t),this._evaluateRunning();try{let r=R(this.layerView.getLoadedAttributes(e.index),n)?this.layerView.getAttributeData(e.index):await this._loadAttributes(e,n,t.signal);await this.schedule(()=>this.layerView.updateAttributes(e.index,{loadedAttributes:n,attributeData:r},t.signal),t.signal)}catch(r){if(!u(r)&&!t.signal.aborted)try{await this.layerView.updateAttributes(e.index,{loadedAttributes:n,attributeData:{}},t.signal)}catch(e){u(e)||o.getLogger(this).error(`#updateLoadedNode()`,this.layer,e)}}finally{this._updatingNodes.get(e.index)===t&&(this._updatingNodes.delete(e.index),this._evaluateRunning())}}_loadNode(e){if(this._loadingNodes.has(e.index)){o.getLogger(this).error(`already loading node `+e.index);return}let t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateRunning(),this._loadAndAddNode(e,t.signal).then(n=>{n&&this._index!=null&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())}).catch(()=>{}).finally(()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateRunning()})}_loadAndAddNode(e,t){return e.cacheState===1?this._loadUncached(e,t).then(()=>!1):this._loadCached(e,t).then(t=>!t&&(e.cacheState=1,!0)).catch(t=>!u(t)&&(e.cacheState=1,!0))}_enableFromGPUCache(e,t){if(this._disableMemCache||this._index==null)return!1;let n=this._loadCachedGPUData(e);return n?(this.layerView.addCachedGPUData(e,n,t),this._nodeAdded(),!0):!1}_loadCachedGPUData(e){let t=this.layerView.loadCachedGPUData(e.index);return t?.attributeInfo!=null&&R(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){this._index!=null&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateRunning()}updateLoadStatus(e,t){this._index?.updateChildrenLoaded(e,t?1:-1)}async _loadCached(e,t){if(this._enableFromGPUCache(e,1))return!0;let n=this.layerView;if(this.disableIDBCache||!n.loadCachedNodeData||!n.addCachedNodeData)return!1;let r=e.index>=0?(t,n)=>this._nodeLoader.loadTextures(e,t,n):t=>this._clientNodeLoader.loadTextures(e,t),i=await this.schedule(()=>n.loadCachedNodeData(e,t,r),t);if(i==null)return!1;let a=this._requiredAttributes,o=await this.reschedule(()=>this._loadAttributes(e,a,t),t);return await this.reschedule(()=>n.addCachedNodeData(e,i,{loadedAttributes:a,attributeData:o},t),t),this._nodeAdded(),!0}_loadUncached(e,t){return this._downloadingCount++,this._loadNodeData(e,t).then(n=>this.schedule(()=>this.layerView.addNode(e,n,t),t)).finally(()=>this._downloadingCount--).then(()=>{this._nodeAdded(),e.cacheState=2}).catch(t=>{if(!u(t))throw o.getLogger(this).error(`#loadNodeData()`,this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,this._index?.requestUpdate(),t})}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateRunning())}get test(){}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateRunning(),this._index!=null&&this._index.requestUpdate()}geometryFilterChanged(e){this._index?.layerFilterChanged(e),this._setCameraDirty()}};e([n({readOnly:!0})],F.prototype,`isMeshPyramid`,null),e([n({readOnly:!0})],F.prototype,`isGraphics3D`,null),e([n({readOnly:!0})],F.prototype,`useMaximumNumberOfFeatures`,null),e([n({readOnly:!0})],F.prototype,`indexRequester`,null),e([n({readOnly:!0})],F.prototype,`dataRequester`,null),e([n({readOnly:!0})],F.prototype,`crsVertex`,null),e([n({readOnly:!0})],F.prototype,`crsIndex`,null),e([n()],F.prototype,`featureTarget`,void 0),e([n()],F.prototype,`fixedFeatureTarget`,void 0),e([n()],F.prototype,`layerView`,void 0),e([n()],F.prototype,`layer`,null),e([n()],F.prototype,`_updatingHandles`,void 0),e([n()],F.prototype,`updating`,null),e([n()],F.prototype,`running`,void 0),e([n()],F.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],F.prototype,`leavesReached`,void 0),e([n({constructOnly:!0})],F.prototype,`worker`,void 0),e([n({readOnly:!0})],F.prototype,`rootNodeVisible`,null),F=e([r(`esri.layers.graphics.controllers.I3SOnDemandController`)],F);const I=new c({deallocator:null});let L;function R(e,t){return e!=null&&e.length===t.length&&e.every(e=>z(t,e.name)>=0)}function z(e,t){let n=t.toLowerCase();for(let t=0;t<e.length;t++)if(e[t].name.toLowerCase()===n)return t;return-1}const B=h(),V=F;export{V as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{runUntracked as i}from"../../../core/accessorSupport/tracking.js";import has from"../../../core/has.js";import{exactEquals as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import o from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{EsriPromiseMixin as l}from"../../../core/Promise.js";import{isAbortError as u}from"../../../core/promiseUtils.js";import{watch as d,sync as f,initial as p}from"../../../core/reactiveUtils.js";import{UpdatingHandles as m}from"../../../core/support/UpdatingHandles.js";import{create as h,fromValues as g}from"../../../geometry/support/aaBoundingRect.js";import{I3SClientNodeLoader as _}from"../../../views/3d/layers/i3s/I3SClientNodeLoader.js";import{I3SDataRequester as v}from"../../../views/3d/layers/i3s/I3SDataRequester.js";import{addCallback as y}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as b}from"../../../views/3d/layers/i3s/I3SIndex.js";import x from"../../../views/3d/layers/i3s/I3SLodHandling.js";import S from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{getVertexCrs as C,getIndexCrs as w,findIntersectingNodes as T}from"../../../views/3d/layers/i3s/I3SUtil.js";import E from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{groundNavigationConstants as D}from"../../../views/3d/state/utils/groundNavigationUtils.js";import{projectElevationUpdateExtent as O}from"../../../views/3d/support/elevationUpdateExtentUtils.js";import{toBoundingRect as k}from"../../../views/3d/support/extentUtils.js";import{minQuality as A}from"../../../views/3d/support/MemoryController.js";import{PromiseQueue as j}from"../../../views/support/PromiseQueue.js";import{noBudget as M}from"../../../views/support/Scheduler.js";const N=1e4,P=1e-4;let F=class extends l(t){get isMeshPyramid(){return this.layer.profile===`mesh-pyramids`||this.layer.store?.lodType===`MeshPyramid`}get isGraphics3D(){return this.layer.profile===`points`}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(this.layer.priority==null||this.layer.priority===`High`)}get indexRequester(){return new v(this.layer.customParameters,this.layer.apiKey)}get dataRequester(){return new v(this.layer.customParameters,this.layer.apiKey)}get crsVertex(){return C(this.layer)}get crsIndex(){return w(this.layer)}get layer(){return this.layerView.layer}get updating(){return this.running||this._updatingHandles.updating}get rootNodeVisible(){return i(()=>{if(this._index){let 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.featureTarget=5e4,this.fixedFeatureTarget=!1,this._updatingHandles=new m,this.running=!0,this.updatingProgress=1,this.leavesReached=!1,this.worker=null,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._newLoadingNodes=new c({deallocator:null}),this._modificationsNodeFilteringArray=new c,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=[],this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._idleQueue=new j,this._elevationUpdateNodes=new c({deallocator:null}),this._errorCount=0}initialize(){let{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new x(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(([n])=>{if(this.destroyed||!e||e.destroyed||!n)return;let{view:r,clientGeometry:i}=e;if(this._setClippingArea(r.clippingArea),this.addHandles([this._updatingHandles.add(()=>r?.pointsOfInterest?.focus?.renderLocation,e=>this._pointOfInterestChanged(e),{initial:!0,equals:a}),d(()=>r.quality,()=>this._setCameraDirty(),f),this._updatingHandles.add(()=>r.state.mode===2,t=>{this._updateIdleState(t),t&&(this._index?.resetFailedNodes(),e.contentVisible||this._updateViewData())},p),this._updatingHandles.add(()=>e.contentVisible,e=>{e&&this._index?.invalidateAllElevationRanges(),this.restartNodeLoading()},p),y(e.view.resourceController.scheduler,this),this._updatingHandles.add(()=>[this.featureTarget,this.fixedFeatureTarget],()=>{this._setCameraDirty(),this._stableFeatureLOD=!1}),this._updatingHandles.add(()=>r.state?.contentCamera,()=>this._setCameraDirty()),this._updatingHandles.add(()=>r.navigation.mode?.type,e=>{this._setCameraDirty(),this._index&&(this._index.isGroundNavigationMode=e===`ground`)}),this._updatingHandles.add(()=>t.elevationInfo,e=>this._elevationInfoChanged(e),f),this._updatingHandles.add(()=>e.lodFactor,()=>this._setCameraDirty()),this._updatingHandles.add(()=>e.availableFields,()=>this._requiredFieldsChange()),this._updatingHandles.add(()=>e.holeFilling,e=>this._index!=null&&(this._index.holeFilling=e))]),this._viewportQueries=new E(this.crsIndex,r.renderCoordsHelper,r.state.contentCamera,!r.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?r.groundView:r.elevationProvider,r.state.isGlobal,this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._clientNodeLoader=new _(this.layer.uid,{indexSR:this.crsIndex,vertexSR:this.crsVertex,renderSR:r.renderCoordsHelper.spatialReference},r.resourceController.memoryController,this.worker),this._index=new b(t,r.navigation.mode.type===`ground`,D.i3sNodeDownwardCheckDistanceInMeters/r.renderCoordsHelper.unitInMeters,n,this.indexRequester,this._clientNodeLoader,this._viewportQueries,o.getLogger(this),e.holeFilling,t=>e.isNodeLoaded(t),t=>e.isNodeReloading(t),e=>this._shouldLoadNode(e),e=>this._enableFromGPUCache(e,1),e=>this._needsUpdate(e),t=>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),i!=null){for(let e of i)this._addMesh(e.mesh,e.oid);this.addHandles(i.on(`change`,e=>{for(let t of e.removed)this._removeMesh(t.oid);for(let t of e.added)this._addMesh(t.mesh,t.oid)}))}this._startNodeLoading()}))}updateNodeModificationStatus(e){let t=this._index,n=this.layerView;t!=null&&n?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll(e=>{let n=t.getNode(e);n!=null&&this._modificationsNodeFilteringArray.push(n)}),n.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._updatingHandles.destroy(),this._nodeLoader=null,I.prune(),this._newLoadingNodes.prune(),this._modificationsNodeFilteringArray.prune(),this._elevationUpdateNodes.prune(),L!=null&&(L.hide(),L=null),this._index=null,this._lodHandling=s(this._lodHandling),this._nodeLoader=null,this._clientNodeLoader=null,this._viewportQueries=null,this._set(`worker`,null)}get viewportQueries(){return this._viewportQueries}_getRequiredAttributes(){if(this._attributeStorageInfo==null||!this._fields||!this.layerView.availableFields)return[];let e=this._attributeStorageInfo,t=this._fields,n=this.layer.objectIdField;return this.layerView.availableFields.map(n=>{let r=z(e,n),i=z(t,n);return r>=0&&i>=0?{index:r,name:t[i].name,field:t[i],attributeStorageInfo:e[r]}:null}).filter(e=>e!=null&&e.name!==n)}_requiredFieldsChange(){let e=this._getRequiredAttributes();R(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){let t=h();this._clippingArea=k(e,t,this.layerView.view.renderSpatialReference)?t:null}_pointOfInterestChanged(e){this._viewportQueries!=null&&(this._viewportQueries.setPointOfInterest(e),this._index!=null&&this._index.requestUpdate())}updateClippingArea(e){this._setClippingArea(e),this._viewportQueries!=null&&this._index!=null&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateRunning()}_addMesh(e,t){if(this._index==null)return;let n=this._clientNodeLoader.createMeshNodeInfo(e,t),r=this._index.addClientNodeToIndex(n.id,n.mbs);this._clientNodeLoader.addMeshNode(r,n),this._evaluateRunning(),this.notifyChange(`rootNodeVisible`)}_removeMesh(e){let t=this._clientNodeLoader.getMeshNodeIndex(e);if(t!=null){if(this._index!=null)this._index.removeClientNodeFromIndex(t,(e,t)=>{this.layerView.removeNode(t),this._clientNodeLoader.removeNode(e),this.layerView.deleteCachedNodeData&&e!=null&&this.layerView.deleteCachedNodeData(e),this.layerView.deleteCachedGPUData?.(this.layerView.loadCachedGPUData?.(t))},(e,t,n)=>{this._clientNodeLoader.updateNodeIndex(e,t,n),this.layerView.updateNodeIndex&&this.layerView.updateNodeIndex(t,n)}),this.notifyChange(`rootNodeVisible`);else throw Error(`delayed removal of client side i3s node geometry not supported yet.`)}}updateElevationChanged(e,t){let n=this._index,r=this._viewportQueries;if(n?.rootNode==null||t==null||r==null)return null;let i=r.elevationIntersectionSpatialReference;i.equals(t)||(O(e,t,B,i)||g(-1/0,-1/0,1/0,1/0,B),e=B);let a=this._elevationUpdateNodes;return a.clear(),T(e,n.rootNode,n,e=>a.push(e.index),r),a.length&&(a.forAll(e=>n.updateElevationChanged(e)),this._setCameraDirty()),a}removeAllGeometryObbs(){this._index!=null&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return this._viewportQueries==null?null:this._viewportQueries.calculateServiceMbsInRenderSRElevationAdjusted(e)}_elevationInfoChanged(e){this._index!=null&&(this._index.updateElevationInfo(e,this.isMeshPyramid||this.isGraphics3D),this._setCameraDirty())}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateRunning()}schedule(e,t){let n=this._idleQueue.push(e,t);return this._evaluateRunning(),n}reschedule(e,t){let n=this._idleQueue.unshift(e,t);return this._evaluateRunning(),n}get unloadedMemoryEstimate(){return this._index==null||!this.layerView.contentVisible?0:this._index.unloadedMemoryEstimate*this._lodDropFactor}async _loadNodeData(e,t){return e.index<0?this._clientNodeLoader.loadNodeData(e.id,t):this._nodeLoader.loadNodeData(e,t)}async _loadAttributes(e,t,n){return(e.index<0?this._clientNodeLoader:this._nodeLoader).loadAttributes(e,t,n)}get indexDepth(){return this._index==null?0:this._index.maxLevel}set disableMemCache(e){this._disableMemCache=!this.layerView.loadCachedGPUData||!this.layerView.addCachedGPUData||e}runTask(e,t){return this.layerView.contentVisible?!this.layerView.visible||this._index==null?-1/0:(this._processWithErrorLogging(e,t),this._index.maxPriority):(this._updateViewData(),this._evaluateRunning(),-1/0)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(e){this._errorCount<50?o.getLogger(this).error(`Error during processing: ${e} at ${e.stack}`):this._errorCount===50&&o.getLogger(this).error(`Too many errors for this layer. Further errors will not be displayed.`),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),this._nodeLoader!=null&&this._index!=null&&(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),e.run(()=>this._processIndex(e)),this._updateFeatureLOD(),e.run(()=>this._processCache(e)),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._evaluateRunning())}_processIndex(e){if(this._index==null)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.pushAll(this._index.updates.missing));let t=this._index.featureEstimate.leavesReached;!this._index.isLoading&&t!==this._get(`leavesReached`)&&this._set(`leavesReached`,t)}return this._index.load()}_prefetchIndex(){return this._index==null||this._loadingNodes.size>0||this._index.updates.add.length>0?!1:this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||this._index==null||this._viewportQueries==null)return;let e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,n=this._index.featureEstimate;if(n.estimate=n.estimate||t/2,this._index.indexMissing>500){if(this._featureLOD<=P)return;this._featureLOD/=1.5,this._stableFeatureLOD=!1}else if(e&&n.estimate<t){if(n.leavesReached||this._featureLOD>=N||this._stableFeatureLOD)return;let e=Math.min(10,Math.max(t/n.estimate,1.001));this._featureLOD*=e;let r=this._lod,i=this._index.checkFeatureTarget(t,r);i!==r&&(this._featureLOD=i/this._baseLOD,this._stableFeatureLOD=!0)}else if(n.estimate>t*1.2||e&&n.estimate>t){if(this._featureLOD<=P)return;this._featureLOD/=1+(n.estimate/t-1)*.25,this._stableFeatureLOD=!1}else return;this._featureLOD=Math.min(N,Math.max(P,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){let t=this._index;if(t==null)return!1;for(;this._newLoadingNodes.length>0&&!e.done;){let n=this._newLoadingNodes.pop();for(let r=t.getParent(n);r!=null&&!this.layerView.isNodeLoaded(r.index);r=t.getParent(r.index)){if(!this._disableMemCache&&!t.useNodeAsHole(r.index)){e.enabled&&e.madeProgress();break}if(this._enableFromGPUCache(r,0)){e.madeProgress();break}}}return e.hasProgressed}_processNodes(e,t){if(this._index==null)return!1;let n=(this._isIdle?100:2)-this._loadingNodes.size,r=this._index.updates;for(r.cancel.forEach(this._cancelNode,this),r.cancel=[];r.remove.length>0&&!e.done;)this.layerView.removeNode(r.remove.pop()),e.madeProgress();for(;r.update.length>0&&!e.done;){let t=this._index.getNode(r.update.pop());t!=null&&(this._updateLoadedNode(t),e.madeProgress())}for(;r.add.length>0&&!e.done&&n>0;){--n;let i=this._index.getNode(r.add.back());if(i==null||i.cacheState!==2&&!this._hasNodeLoadToken(t))break;r.add.pop(),this._loadNode(i),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){let t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=2?!1:this.index==null||!this.dataRequester.isFull(this._index.urlPrefix)}_evaluateRunning(){let e=!1,t=0;if(this.layerView){if(!this.layerView.contentVisible)e=this._cameraDirty,t=+!e;else{let n=(this._index?.indexMissing??0)+(this._index?.updates.add.length??0)*3+this._loadingNodes.size*2;e=!!(n>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.updating||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||this._index!=null&&this._index.isPrefetching),n===0&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(n,this._progressMaxNumNodes),t=1-n/this._progressMaxNumNodes}this.running=e,this.updatingProgress=t}}_updateViewData(){if(!this._cameraDirty||this._index==null||this._viewportQueries==null)return;let e=this.layerView.view,{contentCamera:t,fixedContentCamera:n}=e.state;this._viewportQueries.updateCamera(t,!n||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),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(){let e=this.layerView.lodFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*this.layerView.view.quality}get _lodDropFactor(){return this.fixedFeatureTarget?1:(Math.min(this.layerView.view.quality,.5)-A)/(.5-A)}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)||this._index==null||!this._index.isGeometryVisible(e.index))}_shouldDropNode(e){if(this._viewportQueries==null)return!1;let t=this._lodDropFactor;return t>=1||!this._lodHandling.hasNoVisibleChildren(e)?!1:Math.abs(this._viewportQueries.calcCameraDistanceToCenterAndUpdateMinmax(e))-this._viewportQueries.minCenterDistance>(this._viewportQueries.maxCenterDistance-this._viewportQueries.minCenterDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;let e=this._index;if(this._updatesDisabled||e==null||this._viewportQueries==null)return;this._updateViewData(),this._requiredAttributesDirty&&=(this._requiredAttributes=this._getRequiredAttributes(),!1);let t={textureEncodings:this.layerView.supportedTextureEncodings,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new S(this.layer,this.dataRequester,o.getLogger(this),this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e,t)=>this._removeNodes(e,t,1),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateRunning()}isNodeLoading(){return this._nodeLoader!=null&&this._index!=null}cancelNodeLoading(){this.isNodeLoading()&&(this.indexRequester.cancelAll(),this.dataRequester.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateRunning())}_removeInvisibleNodes(e){let t=this._index;if(t==null||this._viewportQueries==null)return!1;I.clear(),this.layerView.getLoadedNodeIndices(I);let n=this._viewportQueries.maxCenterDistance===0,r=n?()=>!1:e=>this._shouldDropNode(e);return I.filterInPlace(e=>{let n=t.getNode(e);return n==null||!t.isGeometryVisible(e)||r(n)}),I.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(I,e,0),n&&this._lodDropFactor<1?!1:I.length===0||(I.clear(),!1)}markNodeToRemove(e){I.push(e)}removeMarkedNodes(){this._removeNodes(I,M,0)}_removeNodes(e,t,n){if(!(e.length===0||t.done))for(this._index!=null&&this._index.requestUpdate();e.length>0&&!t.done;){let r=e.pop(),i=this._index;n===1&&this.layerView.nodeFadeoutEnabled&&i!=null&&i.isGeometryVisible(r)?this.layerView.fadeNode(r,1,!0):this.layerView.removeNode(r),t.madeProgress()}}_needsUpdate(e){if(e.resources.isEmpty||this._updatingNodes.has(e.index))return!1;let t=this.layerView.getLoadedAttributes(e.index);return t!=null&&t!==this._requiredAttributes}async _updateLoadedNode(e){let t=new AbortController,n=this._requiredAttributes;this._updatingNodes.set(e.index,t),this._evaluateRunning();try{let r=R(this.layerView.getLoadedAttributes(e.index),n)?this.layerView.getAttributeData(e.index):await this._loadAttributes(e,n,t.signal);await this.schedule(()=>this.layerView.updateAttributes(e.index,{loadedAttributes:n,attributeData:r},t.signal),t.signal)}catch(r){if(!u(r)&&!t.signal.aborted)try{await this.layerView.updateAttributes(e.index,{loadedAttributes:n,attributeData:{}},t.signal)}catch(e){u(e)||o.getLogger(this).error(`#updateLoadedNode()`,this.layer,e)}}finally{this._updatingNodes.get(e.index)===t&&(this._updatingNodes.delete(e.index),this._evaluateRunning())}}_loadNode(e){if(this._loadingNodes.has(e.index)){o.getLogger(this).error(`already loading node `+e.index);return}let t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateRunning(),this._loadAndAddNode(e,t.signal).then(n=>{n&&this._index!=null&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())}).catch(()=>{}).finally(()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateRunning()})}_loadAndAddNode(e,t){return e.cacheState===1?this._loadUncached(e,t).then(()=>!1):this._loadCached(e,t).then(t=>!t&&(e.cacheState=1,!0)).catch(t=>!u(t)&&(e.cacheState=1,!0))}_enableFromGPUCache(e,t){if(this._disableMemCache||this._index==null)return!1;let n=this._loadCachedGPUData(e);return n?(this.layerView.addCachedGPUData(e,n,t),this._nodeAdded(),!0):!1}_loadCachedGPUData(e){let t=this.layerView.loadCachedGPUData(e.index);return t?.attributeInfo!=null&&R(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){this._index!=null&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateRunning()}updateLoadStatus(e,t){this._index?.updateChildrenLoaded(e,t?1:-1)}async _loadCached(e,t){if(this._enableFromGPUCache(e,1))return!0;let n=this.layerView;if(this.disableIDBCache||!n.loadCachedNodeData||!n.addCachedNodeData)return!1;let r=e.index>=0?(t,n)=>this._nodeLoader.loadTextures(e,t,n):t=>this._clientNodeLoader.loadTextures(e,t),i=await this.schedule(()=>n.loadCachedNodeData(e,t,r),t);if(i==null)return!1;let a=this._requiredAttributes,o=await this.reschedule(()=>this._loadAttributes(e,a,t),t);return await this.reschedule(()=>n.addCachedNodeData(e,i,{loadedAttributes:a,attributeData:o},t),t),this._nodeAdded(),!0}_loadUncached(e,t){return this._downloadingCount++,this._loadNodeData(e,t).then(n=>this.schedule(()=>this.layerView.addNode(e,n,t),t)).finally(()=>this._downloadingCount--).then(()=>{this._nodeAdded(),e.cacheState=2}).catch(t=>{if(!u(t))throw o.getLogger(this).error(`#loadNodeData()`,this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,this._index?.requestUpdate(),t})}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateRunning())}get test(){}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateRunning(),this._index!=null&&this._index.requestUpdate()}geometryFilterChanged(e){this._index?.layerFilterChanged(e),this._setCameraDirty()}};e([n({readOnly:!0})],F.prototype,`isMeshPyramid`,null),e([n({readOnly:!0})],F.prototype,`isGraphics3D`,null),e([n({readOnly:!0})],F.prototype,`useMaximumNumberOfFeatures`,null),e([n({readOnly:!0})],F.prototype,`indexRequester`,null),e([n({readOnly:!0})],F.prototype,`dataRequester`,null),e([n({readOnly:!0})],F.prototype,`crsVertex`,null),e([n({readOnly:!0})],F.prototype,`crsIndex`,null),e([n()],F.prototype,`featureTarget`,void 0),e([n()],F.prototype,`fixedFeatureTarget`,void 0),e([n()],F.prototype,`layerView`,void 0),e([n()],F.prototype,`layer`,null),e([n()],F.prototype,`_updatingHandles`,void 0),e([n()],F.prototype,`updating`,null),e([n()],F.prototype,`running`,void 0),e([n()],F.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],F.prototype,`leavesReached`,void 0),e([n({constructOnly:!0})],F.prototype,`worker`,void 0),e([n({readOnly:!0})],F.prototype,`rootNodeVisible`,null),F=e([r(`esri.layers.graphics.controllers.I3SOnDemandController`)],F);const I=new c({deallocator:null});let L;function R(e,t){return e!=null&&e.length===t.length&&e.every(e=>z(t,e.name)>=0)}function z(e,t){let n=t.toLowerCase();for(let t=0;t<e.length;t++)if(e[t].name.toLowerCase()===n)return t;return-1}const B=h(),V=F;export{V as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{baseObjectMemory as e,estimateNumberArrayMemory as t,
|
|
2
|
+
import{baseObjectMemory as e,estimateNumberArrayMemory as t,estimateUniformNumberArraysMemory as n,estimateArrayReferencesMemory as r,estimateAttributesMemory as i}from"../../core/memoryEstimations.js";import{generateUID as a}from"../../core/uid.js";import o from"../../geometry/SpatialReference.js";import{empty as s,expandWithNestedArray as c}from"../../geometry/support/aaBoundingBox.js";import{empty as l,expandWithNestedArray as u}from"../../geometry/support/aaBoundingRect.js";import{unquantizePolyline as d,unquantizePolygon as f,unquantizeMultipoint as p,unquantizePoint as m}from"../../geometry/support/quantizationUtils.js";import{featureGeometryTypeKebabDictionary as h}from"../../geometry/support/typeUtils.js";import{getApproximateMaxDensificationSegments as g}from"../../views/2d/layers/graphics/densificationConstants.js";export{equals}from"./dehydratedFeatureComparison.js";class _{constructor(e,t,n){this.uid=e,this.geometry=t,this.attributes=n,this.visible=!0,this.objectId=null,this.centroid=null}}function v(e){return e.geometry!=null}class y{constructor(){this.exceededTransferLimit=!1,this.features=[],this.fields=[],this.hasM=!1,this.hasZ=!1,this.geometryType=null,this.objectIdFieldName=null,this.globalIdFieldName=null,this.geometryProperties=null,this.geohashFieldName=null,this.spatialReference=null,this.transform=null,this.missingAttributes=null}}function b(e,t){let n=h.fromJSON(e.geometryType),r=o.fromJSON(e.spatialReference),i=e.transform,a=e.objectIdFieldName,s=t?.maxStringAttributeLength,c=t?.maxStringAttributeFields,l;return{geometryType:n,features:e.features.map(t=>{let o=x(t,n,r,e.objectIdFieldName),u=o.geometry;if(j(o.attributes,c,s,e=>{l??=[];let t=A(o,a);t!=null&&l.push({objectId:t,attribute:e})}),u!=null&&i)switch(u.type){case`point`:o.geometry=m(i,u,u);break;case`multipoint`:o.geometry=p(i,u,u);break;case`polygon`:o.geometry=f(i,u,u);break;case`polyline`:o.geometry=d(i,u,u);break;case`extent`:case`mesh`:o.geometry=u}return o}),spatialReference:r,fields:e.fields??[],objectIdFieldName:e.objectIdFieldName,globalIdFieldName:e.globalIdFieldName,geohashFieldName:e.geohashFieldName,geometryProperties:e.geometryProperties,hasZ:e.hasZ,hasM:e.hasM,exceededTransferLimit:e.exceededTransferLimit,transform:null,missingAttributes:l}}function x(e,t,n,r){return{uid:a(),objectId:r&&e.attributes?e.attributes[r]:null,attributes:e.attributes,geometry:S(e.geometry,t,n),visible:!0}}function S(e,t,n){if(e==null)return null;switch(t){case`point`:{let t=e;return{x:t.x,y:t.y,z:t.z,m:t.m,hasZ:t.z!=null,hasM:t.m!=null,type:`point`,spatialReference:n}}case`polyline`:{let t=e;return{paths:t.paths,hasZ:!!t.hasZ,hasM:!!t.hasM,type:`polyline`,spatialReference:n}}case`polygon`:{let t=e;return{rings:t.rings,hasZ:!!t.hasZ,hasM:!!t.hasM,type:`polygon`,spatialReference:n}}case`multipoint`:{let t=e;return{points:t.points,hasZ:!!t.hasZ,hasM:!!t.hasM,type:`multipoint`,spatialReference:n}}}}function C(i){if(i==null)return 0;switch(i.type){case`point`:return e+10+8+24;case`polyline`:case`polygon`:{let t=0,a=2+ +!!i.hasZ+ +!!i.hasM,o=i.type===`polyline`?i.paths:i.rings;if((i.type===`polyline`?i.curvePaths:i.curveRings)?.length){let e=3*g()*128;t=8*e*a+e*128+32*(o.length+1)}else{t=r(o.length);for(let e of o)t+=n(e)}return e+64+t+34}case`multipoint`:{let t=n(i.points);return e+t+64+34+32}case`extent`:return e+10+64+34;case`mesh`:{let n=i.vertexAttributes;return e+t(n.position,n.normal,n.uv,n.tangent)}default:return e}}const w=43;function T(e){return 43+i(e.attributes)+C(e.geometry)}function E(e){if(e==null)return 0;switch(e.type){case`point`:return 1;case`polyline`:{let t=0;for(let n of e.paths)t+=n.length;return t}case`polygon`:{let t=0;for(let n of e.rings)t+=n.length;return t}case`multipoint`:return e.points.length;case`extent`:return 2;case`mesh`:{let t=e.vertexAttributes&&e.vertexAttributes.position;return t?t.length/3:0}default:return}}function D(e){if(e==null)return!1;switch(e.type){case`extent`:case`point`:return!0;case`polyline`:for(let t of e.paths)if(t.length>0)return!0;return!1;case`polygon`:for(let t of e.rings)if(t.length>0)return!0;return!1;case`multipoint`:return e.points.length>0;case`mesh`:return!e.loaded||e.vertexAttributes.position.length>0}}function O(e,t){switch(s(t),e.type===`mesh`&&(e=e.extent),e.type){case`point`:t[0]=t[3]=e.x,t[1]=t[4]=e.y,e.hasZ&&(t[2]=t[5]=e.z);break;case`polyline`:for(let n=0;n<e.paths.length;n++)c(t,e.paths[n],!!e.hasZ);break;case`polygon`:for(let n=0;n<e.rings.length;n++)c(t,e.rings[n],!!e.hasZ);break;case`multipoint`:c(t,e.points,!!e.hasZ);break;case`extent`:t[0]=e.xmin,t[1]=e.ymin,t[3]=e.xmax,t[4]=e.ymax,e.zmin!=null&&(t[2]=e.zmin),e.zmax!=null&&(t[5]=e.zmax)}return t}function k(e,t){switch(l(t),e.type===`mesh`&&(e=e.extent),e.type){case`point`:t[0]=t[2]=e.x,t[1]=t[3]=e.y;break;case`polyline`:for(let n=0;n<e.paths.length;n++)u(t,e.paths[n]);break;case`polygon`:for(let n=0;n<e.rings.length;n++)u(t,e.rings[n]);break;case`multipoint`:u(t,e.points);break;case`extent`:t[0]=e.xmin,t[1]=e.ymin,t[2]=e.xmax,t[3]=e.ymax}}function A(e,t){return e.objectId==null?e.attributes&&t?e.attributes[t]:null:e.objectId}function j(e,t,n,r){if(t?.size&&n!=null&&e)for(let i in e){if(!t.has(i))continue;let a=e[i];typeof a==`string`&&a.length>n&&(r(i),e[i]=``)}}export{_ as DehydratedFeatureClass,y as DehydratedFeatureSetClass,w as baseDehydratedGraphicMemory,O as computeAABB,k as computeAABR,C as estimateGeometryMemory,T as estimateSize,b as fromFeatureSetJSON,S as fromJSONGeometry,A as getObjectId,v as hasGeometry,D as hasVertices,E as numVertices,j as removeLargeStringAttributes};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{isPlainObject as e}from"../../core/lang.js";function t(e,t){if(c(e))return r(e,a,l(e),t)}function n(e,t,n){if(c(e)&&t)return r(t,e.type===`multipoint`?s:o,l(e),n)}function r(e,t,n,r){let i=t.vertexCount(e,n);if(i<1024)return;let a=t.partCount(e),o=`${r},${i},${a}`,s=Math.min(a,3),c=0,l=0;for(let r=0;r<s;++r){let i=s===1?0:Math.floor(r*(a-1)/(s-1));for(;c<i;)l+=t.partLength(e,c++,n)*n;let u=t.partLength(e,c,n);if(o+=`,${u}`,u>0)for(let r=0;r<3;++r){let i=r===0?0:r===1?Math.floor(u/2):Math.max(0,u-2);for(let r=0;r<n;++r){let a=t.coordinate(e,c,i,r,l,n);o+=`,${a.toFixed(5)}`}}}return o}function i(e,t,n){if(!e||!c(n)||!t)return!1;let{coords:r}=t,i=2+Number(!!e.hasZ)+Number(!!e.hasM),a=e.type===`multipoint`?s:o,l=u(n);if(a.partCount(t)!==l)return!1;let f=0;for(let e=0;e<l;++e){let o=d(n,e);if(a.partLength(t,e,i)!==o.length)return!1;for(let e of o)for(let t=0;t<i;++t)if(r[f++]!==e[t])return!1}return!0}const a={partCount:u,vertexCount(e){let t=0,n=u(e);for(let r=0;r<n;++r)t+=d(e,r).length;return t},partLength:(e,t)=>d(e,t).length,coordinate:(e,t,n,r)=>d(e,t)[n][r]},o={partCount:e=>e.lengths.length,vertexCount:(e,t)=>e.coords.length/t,partLength:(e,t)=>e.lengths[t],coordinate:(e,t,n,r,i,a)=>e.coords[i+n*a+r]},s={...o,partCount:()=>1,partLength:(e,t,n)=>e.coords.length/n};function c(t){return!!t&&e(t)&&(t.type===`polygon`||t.type===`polyline`||t.type===`multipoint`)&&!(t.type===`polygon`&&t.curveRings?.length)&&!(t.type===`polyline`&&t.curvePaths?.length)}function l(e){return 2+Number(!!e.hasZ)+Number(!!e.hasM)}function u(e){return e.type===`multipoint`?1:e.type===`polygon`?e.rings.length:e.paths.length}function d(e,t){return e.type===`multipoint`?e.points:e.type===`polygon`?e.rings[t]:e.paths[t]}function f(e,t,n){p(e.geometry,t,n)}function p(e,t,n){if(!e||(e.spatialReference=n,e.type===`extent`||e.type===`mesh`||e.type===`point`||!t))return;let{coords:r,lengths:i}=t,a=l(e),o=e.type===`multipoint`?[r.length/a]:i,s=
|
|
2
|
+
import{isPlainObject as e}from"../../core/lang.js";function t(e,t){if(c(e))return r(e,a,l(e),t)}function n(e,t,n){if(c(e)&&t)return r(t,e.type===`multipoint`?s:o,l(e),n)}function r(e,t,n,r){let i=t.vertexCount(e,n);if(i<1024)return;let a=t.partCount(e),o=`${r},${i},${a}`,s=Math.min(a,3),c=0,l=0;for(let r=0;r<s;++r){let i=s===1?0:Math.floor(r*(a-1)/(s-1));for(;c<i;)l+=t.partLength(e,c++,n)*n;let u=t.partLength(e,c,n);if(o+=`,${u}`,u>0)for(let r=0;r<3;++r){let i=r===0?0:r===1?Math.floor(u/2):Math.max(0,u-2);for(let r=0;r<n;++r){let a=t.coordinate(e,c,i,r,l,n);o+=`,${a.toFixed(5)}`}}}return o}function i(e,t,n){if(!e||!c(n)||!t)return!1;let{coords:r}=t,i=2+Number(!!e.hasZ)+Number(!!e.hasM),a=e.type===`multipoint`?s:o,l=u(n);if(a.partCount(t)!==l)return!1;let f=0;for(let e=0;e<l;++e){let o=d(n,e);if(a.partLength(t,e,i)!==o.length)return!1;for(let e of o)for(let t=0;t<i;++t)if(r[f++]!==e[t])return!1}return!0}const a={partCount:u,vertexCount(e){let t=0,n=u(e);for(let r=0;r<n;++r)t+=d(e,r).length;return t},partLength:(e,t)=>d(e,t).length,coordinate:(e,t,n,r)=>d(e,t)[n][r]},o={partCount:e=>e.lengths.length,vertexCount:(e,t)=>e.coords.length/t,partLength:(e,t)=>e.lengths[t],coordinate:(e,t,n,r,i,a)=>e.coords[i+n*a+r]},s={...o,partCount:()=>1,partLength:(e,t,n)=>e.coords.length/n};function c(t){return!!t&&e(t)&&(t.type===`polygon`||t.type===`polyline`||t.type===`multipoint`)&&!(t.type===`polygon`&&t.curveRings?.length)&&!(t.type===`polyline`&&t.curvePaths?.length)}function l(e){return 2+Number(!!e.hasZ)+Number(!!e.hasM)}function u(e){return e.type===`multipoint`?1:e.type===`polygon`?e.rings.length:e.paths.length}function d(e,t){return e.type===`multipoint`?e.points:e.type===`polygon`?e.rings[t]:e.paths[t]}function f(e,t,n){p(e.geometry,t,n)}function p(e,t,n){if(!e||(e.spatialReference=n,e.type===`extent`||e.type===`mesh`||e.type===`point`||!t))return;let{coords:r,lengths:i}=t,a=l(e),o=e.type===`multipoint`?[r.length/a]:i,s=Array(o.length).fill(null),c=0,u=0;if(a===2)for(let e of o){let t=Array(e).fill(null);for(let n=0;n<e;n++,c+=2)t[n]=[r[c],r[c+1]];s[u++]=t}else if(a===3)for(let e of o){let t=Array(e).fill(null);for(let n=0;n<e;n++,c+=3)t[n]=[r[c],r[c+1],r[c+2]];s[u++]=t}else for(let e of o){let t=Array(e).fill(null);for(let n=0;n<e;n++,c+=4)t[n]=[r[c],r[c+1],r[c+2],r[c+3]];s[u++]=t}e.type===`multipoint`?e.points=s[0]:e.type===`polygon`?e.rings=s:e.paths=s}export{f as completeDehydratedFeatureFromTransfer,p as completeDehydratedGeometryFromTransfer,t as geometryKey,i as identicalTransferGeometry,n as transferGeometryKey};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* [labeling](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#labelingInfo),
|
|
4
4
|
* [elevation](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#elevationInfo),
|
|
5
5
|
* [editor tracking](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#editFieldsInfo)
|
|
6
|
-
* and time span. Use [
|
|
6
|
+
* and time span. Use [getLayerFieldUsage()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/#getLayerFieldUsage) to find
|
|
7
7
|
* where source fields are used in layer configuration.
|
|
8
8
|
*
|
|
9
9
|
* @since 4.11
|
|
@@ -52,21 +52,21 @@ export function getDisplayFieldName(layer: FeatureLayer | CSVLayer | GeoJSONLaye
|
|
|
52
52
|
export function getElevationFields(layer: FeatureLayer | null | undefined): Promise<string[]>;
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* Defines the layer contract used by [getLayerFieldUsage()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/#getLayerFieldUsage)
|
|
56
|
+
* to identify field references in the layer's configuration.
|
|
57
57
|
*
|
|
58
58
|
* @since 6.0
|
|
59
59
|
*/
|
|
60
60
|
export interface LayerForFieldUsage {
|
|
61
|
-
/**
|
|
62
|
-
|
|
61
|
+
/** Loads the layer. The promise resolves when its fields and configuration are ready to inspect. */
|
|
62
|
+
load(): Promise<unknown>;
|
|
63
63
|
/** The source fields index used for case-insensitive reference lookup. */
|
|
64
64
|
readonly fieldsIndex: FieldsIndex<Field>;
|
|
65
65
|
/** The configured definition expression. */
|
|
66
66
|
readonly definitionExpression?: string | null;
|
|
67
67
|
/** The configured feature effect. */
|
|
68
68
|
readonly featureEffect?: FeatureEffect | null;
|
|
69
|
-
/** The configured display
|
|
69
|
+
/** The configured display filter. */
|
|
70
70
|
readonly displayFilterInfo?: DisplayFilterInfo | null;
|
|
71
71
|
/** The configured feature drawing order. */
|
|
72
72
|
readonly orderBy?: readonly OrderByInfo[] | null;
|
|
@@ -89,47 +89,100 @@ export interface LayerForFieldUsage {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* Identifies where a field is used in the layer's configuration.
|
|
93
|
+
* Use `type` to determine the corresponding `value` and `owner` types.
|
|
94
|
+
* The value is captured when the snapshot is collected. Configuration objects and owners are retained by reference, not cloned.
|
|
94
95
|
*
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* are reported as whole configuration objects owned by the layer or feature reduction.
|
|
115
|
-
* Each display filter's SQL value is owned by that filter. Each label expression
|
|
116
|
-
* and label filter is owned by its label class. Each aggregate definition is owned
|
|
117
|
-
* by its feature reduction. Each drawing-order entry is reported as an
|
|
118
|
-
* `OrderByInfo` owned by the layer, with type `"orderBy"`.
|
|
119
|
-
* A layer's separate `trackIdField` is reported with
|
|
120
|
-
* type `"trackIdField"`.
|
|
96
|
+
* The value and owner depend on the configuration:
|
|
97
|
+
* | `type` | `value` | `owner` |
|
|
98
|
+
* | --- | --- | --- |
|
|
99
|
+
* | `definitionExpression` | SQL expression, for example, [FeatureLayer.definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#definitionExpression) | layer |
|
|
100
|
+
* | `featureEffect` | FeatureEffect object, for example, [FeatureLayer.featureEffect](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#featureEffect) | layer |
|
|
101
|
+
* | `displayFilterInfo` | SQL expression, for example, [DisplayFilter.where](https://developers.arcgis.com/javascript/latest/references/core/layers/support/DisplayFilter/#where) | layer's [DisplayFilter](https://developers.arcgis.com/javascript/latest/references/core/layers/support/DisplayFilter/) |
|
|
102
|
+
* | `orderBy` | OrderByInfo object, for example, an entry in [FeatureLayer.orderBy](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#orderBy) | layer |
|
|
103
|
+
* | `renderer` | Renderer object, for example, [FeatureLayer.renderer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#renderer) | layer |
|
|
104
|
+
* | `popupTemplate` | PopupTemplate object, for example, [FeatureLayer.popupTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate) | layer |
|
|
105
|
+
* | `formTemplate` | FormTemplate object, for example, [FeatureLayer.formTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#formTemplate) | layer |
|
|
106
|
+
* | `timeInfo` | TimeInfo object, for example, [FeatureLayer.timeInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#timeInfo) | layer |
|
|
107
|
+
* | `trackIdField` | Field name, for example, [LayerForFieldUsage](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/#LayerForFieldUsage-trackIdField) | layer |
|
|
108
|
+
* | `labeling.expression` | Label expression string, for example, the expression in [LabelClass.labelExpressionInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/#labelExpressionInfo) | layer's [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) |
|
|
109
|
+
* | `labeling.where` | SQL expression, for example, [LabelClass.where](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/#where) | layer's [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) |
|
|
110
|
+
* | `featureReduction.fields` | AggregateField object, for example, an entry in [FeatureReductionCluster.fields](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionCluster/#fields) | layer's [featureReduction](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/FeatureReductionLayer/#FeatureReductionUnion) |
|
|
111
|
+
* | `featureReduction.renderer` | Renderer object, for example, [FeatureReductionCluster.renderer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionCluster/#renderer) | layer's [featureReduction](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/FeatureReductionLayer/#FeatureReductionUnion) |
|
|
112
|
+
* | `featureReduction.popupTemplate` | PopupTemplate object, for example, [FeatureReductionCluster.popupTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionCluster/#popupTemplate) | layer's [featureReduction](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/FeatureReductionLayer/#FeatureReductionUnion) |
|
|
113
|
+
* | `featureReduction.labeling.expression` | Label expression string, for example, the expression in [LabelClass.labelExpressionInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/#labelExpressionInfo) | [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) in `layer.featureReduction` |
|
|
114
|
+
* | `featureReduction.labeling.where` | SQL expression, for example, [LabelClass.where](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/#where) | [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) in `layer.featureReduction` |
|
|
121
115
|
*
|
|
122
116
|
* @since 6.0
|
|
123
117
|
*/
|
|
124
|
-
export type FieldUsageLocation =
|
|
118
|
+
export type FieldUsageLocation = {
|
|
119
|
+
readonly type: "definitionExpression";
|
|
120
|
+
readonly value: string;
|
|
121
|
+
readonly owner: LayerForFieldUsage;
|
|
122
|
+
} | {
|
|
123
|
+
readonly type: "featureEffect";
|
|
124
|
+
readonly value: FeatureEffect;
|
|
125
|
+
readonly owner: LayerForFieldUsage;
|
|
126
|
+
} | {
|
|
127
|
+
readonly type: "displayFilterInfo";
|
|
128
|
+
readonly value: string;
|
|
129
|
+
readonly owner: DisplayFilter;
|
|
130
|
+
} | {
|
|
131
|
+
readonly type: "orderBy";
|
|
132
|
+
readonly value: OrderByInfo;
|
|
133
|
+
readonly owner: LayerForFieldUsage;
|
|
134
|
+
} | {
|
|
135
|
+
readonly type: "renderer";
|
|
136
|
+
readonly value: RendererUnion;
|
|
137
|
+
readonly owner: LayerForFieldUsage;
|
|
138
|
+
} | {
|
|
139
|
+
readonly type: "labeling.expression";
|
|
140
|
+
readonly value: string;
|
|
141
|
+
readonly owner: LabelClass;
|
|
142
|
+
} | {
|
|
143
|
+
readonly type: "labeling.where";
|
|
144
|
+
readonly value: string;
|
|
145
|
+
readonly owner: LabelClass;
|
|
146
|
+
} | {
|
|
147
|
+
readonly type: "featureReduction.fields";
|
|
148
|
+
readonly value: AggregateField;
|
|
149
|
+
readonly owner: FeatureReductionCluster | FeatureReductionBinning;
|
|
150
|
+
} | {
|
|
151
|
+
readonly type: "featureReduction.renderer";
|
|
152
|
+
readonly value: RendererUnion;
|
|
153
|
+
readonly owner: FeatureReductionCluster | FeatureReductionBinning;
|
|
154
|
+
} | {
|
|
155
|
+
readonly type: "featureReduction.labeling.expression";
|
|
156
|
+
readonly value: string;
|
|
157
|
+
readonly owner: LabelClass;
|
|
158
|
+
} | {
|
|
159
|
+
readonly type: "featureReduction.labeling.where";
|
|
160
|
+
readonly value: string;
|
|
161
|
+
readonly owner: LabelClass;
|
|
162
|
+
} | {
|
|
163
|
+
readonly type: "featureReduction.popupTemplate";
|
|
164
|
+
readonly value: PopupTemplateInstance;
|
|
165
|
+
readonly owner: FeatureReductionCluster | FeatureReductionBinning;
|
|
166
|
+
} | {
|
|
167
|
+
readonly type: "popupTemplate";
|
|
168
|
+
readonly value: PopupTemplateInstance;
|
|
169
|
+
readonly owner: LayerForFieldUsage;
|
|
170
|
+
} | {
|
|
171
|
+
readonly type: "formTemplate";
|
|
172
|
+
readonly value: FormTemplate;
|
|
173
|
+
readonly owner: LayerForFieldUsage;
|
|
174
|
+
} | {
|
|
175
|
+
readonly type: "timeInfo";
|
|
176
|
+
readonly value: TimeInfo;
|
|
177
|
+
readonly owner: LayerForFieldUsage;
|
|
178
|
+
} | {
|
|
179
|
+
readonly type: "trackIdField";
|
|
180
|
+
readonly value: string;
|
|
181
|
+
readonly owner: LayerForFieldUsage;
|
|
182
|
+
};
|
|
125
183
|
|
|
126
184
|
/**
|
|
127
|
-
*
|
|
128
|
-
* Layer configuration and aggregate definitions are checked against the layer's
|
|
129
|
-
* fields. Feature-reduction renderer, label, and popup references are checked
|
|
130
|
-
* against the aggregate fields, except popup `$aggregatedFeatures` references,
|
|
131
|
-
* which use the source fields. A missing source dependency is reported on its
|
|
132
|
-
* aggregate definition, not repeated on the aggregate's consumers.
|
|
185
|
+
* Defines a field and its location used in the layer configuration but isn't part of the layer's fields.
|
|
133
186
|
*
|
|
134
187
|
* @since 6.0
|
|
135
188
|
*/
|
|
@@ -140,39 +193,44 @@ export type UnknownFieldUsage = FieldUsageLocation
|
|
|
140
193
|
};
|
|
141
194
|
|
|
142
195
|
/**
|
|
143
|
-
* A snapshot of
|
|
196
|
+
* A snapshot of field usage in a feature-like layer's configuration returned by [getLayerFieldUsage()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/#getLayerFieldUsage).
|
|
144
197
|
*
|
|
145
198
|
* @since 6.0
|
|
146
199
|
*/
|
|
147
200
|
export interface FeatureLikeLayerFieldUsage {
|
|
148
201
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
202
|
+
* Unknown fields are referenced by the layer but cannot be found in the applicable layer fields or aggregate fields.
|
|
203
|
+
* Entries identify these field names and their configuration types, values, and owning objects,
|
|
204
|
+
* sorted by `type`, or an empty array if all field references can be resolved.
|
|
205
|
+
* Repeated references to the same field within the same location are reported once.
|
|
151
206
|
*/
|
|
152
207
|
readonly unknownFields: readonly UnknownFieldUsage[];
|
|
153
208
|
/**
|
|
154
|
-
* Returns the configuration locations
|
|
155
|
-
*
|
|
156
|
-
*
|
|
209
|
+
* Returns the configuration locations where the specified field is used, sorted by `type`.
|
|
210
|
+
* Locations distinguish individual configuration values, such as label expressions, display filters, and aggregate field definitions.
|
|
211
|
+
* Repeated references to the field within the same location are reported once.
|
|
157
212
|
*
|
|
158
|
-
* @param fieldName -
|
|
159
|
-
* @returns
|
|
213
|
+
* @param fieldName - The name of a field present in the layer when [getLayerFieldUsage()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/#getLayerFieldUsage) ran. Lookup is case-insensitive.
|
|
214
|
+
* @returns Matching [FieldUsageLocation](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/#FieldUsageLocation) entries identifying the configuration type,
|
|
215
|
+
* value, and owning object, or an empty array if the field does not exist on the layer or is not referenced
|
|
216
|
+
* by the configuration inspected by this utility.
|
|
160
217
|
*/
|
|
161
218
|
getLocations(fieldName: string): readonly FieldUsageLocation[];
|
|
162
219
|
}
|
|
163
220
|
|
|
164
221
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
222
|
+
* Loads a feature-like layer and finds where its source fields are used, including in renderers, labels, popup templates, and filters.
|
|
223
|
+
* Supports layers implementing [LayerForFieldUsage](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/#LayerForFieldUsage), such as
|
|
224
|
+
* [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/), [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/), and [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/).
|
|
225
|
+
* If loading fails, the promise rejects with the layer's load error.
|
|
167
226
|
*
|
|
168
|
-
* Use
|
|
227
|
+
* Use it to identify dependencies before removing a field. Call it again after updating the layer configuration to get a new snapshot.
|
|
169
228
|
*
|
|
170
|
-
* @param layer - The
|
|
171
|
-
* @returns
|
|
229
|
+
* @param layer - The feature-like layer to load and inspect.
|
|
230
|
+
* @returns Field usage information with case-insensitive lookup by field name.
|
|
172
231
|
* @since 6.0
|
|
173
232
|
* @example
|
|
174
|
-
* await
|
|
175
|
-
* const usage = await fieldUtils.getFieldUsage(layer);
|
|
233
|
+
* const usage = await fieldUtils.getLayerFieldUsage(layer);
|
|
176
234
|
* console.log(usage.unknownFields);
|
|
177
235
|
* console.log(usage.getLocations("population"));
|
|
178
236
|
* // For layer.definitionExpression = "POPULATION < 100", includes:
|
|
@@ -183,8 +241,22 @@ export interface FeatureLikeLayerFieldUsage {
|
|
|
183
241
|
* console.log(location.value, location.owner); // SQL string and its LabelClass
|
|
184
242
|
* }
|
|
185
243
|
* }
|
|
244
|
+
* @example
|
|
245
|
+
* const usage = await fieldUtils.getLayerFieldUsage(layer);
|
|
246
|
+
* // Handle unknown fields by cleaning them from the layer configuration
|
|
247
|
+
* for (const unknownField of usage.unknownFields) {
|
|
248
|
+
* switch (unknownField.type) {
|
|
249
|
+
* case "definitionExpression": {
|
|
250
|
+
* unknownField.owner.definitionExpression = null;
|
|
251
|
+
* console.log(`cleaned field "${unknownField.fieldName}" from "${unknownField.type}"`);
|
|
252
|
+
* break;
|
|
253
|
+
* }
|
|
254
|
+
* default:
|
|
255
|
+
* console.error(`couldn't clean field "${unknownField.fieldName}" from "${unknownField.type}"`);
|
|
256
|
+
* }
|
|
257
|
+
* }
|
|
186
258
|
*/
|
|
187
|
-
export function
|
|
259
|
+
export function getLayerFieldUsage(layer: LayerForFieldUsage): Promise<FeatureLikeLayerFieldUsage>;
|
|
188
260
|
|
|
189
261
|
/**
|
|
190
262
|
* Returns an array of field names related to time.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import{getDeepValue as t,setDeepValue as n}from"../../core/object.js";import{union as r}from"../../core/SetUtils.js";import{parseWhereClause as i}from"../../core/sql.js";import{getFieldNameFromSimpleExpression as a}from"../../support/arcadeExpressionUtils.js";import{isStringOrNull as o,isString as s}from"../../support/guards.js";import{loadArcade as c}from"../../support/loadArcade.js";import{DomainValidationError as l,getDomainRange as u}from"./domainUtils.js";import{RequiredFieldsCollector as d,ReferencedFieldsCollector as ee}from"./FieldCollector.js";const f=/^([0-9_])/,p=/[^a-z0-9_\u0080-\uffff]+/gi;function m(e){return e==null?null:e.trim().replaceAll(p,`_`).replace(f,`F$1`)||null}const h=[`field`,`field2`,`field3`,`normalizationField`,`rotationInfo.field`,`proportionalSymbolInfo.field`,`proportionalSymbolInfo.normalizationField`,`colorInfo.field`,`colorInfo.normalizationField`],g=[`field`,`normalizationField`];function te(e,t){if(e!=null&&t!=null){for(let n of Array.isArray(e)?e:[e])if(_(h,n,t),`visualVariables`in n&&n.visualVariables)for(let e of n.visualVariables)_(g,e,t)}}function _(e,r,i){if(e)for(let a of e){let e=t(a,r),o=e&&typeof e!=`function`&&i.get(e);o&&n(a,o.name,r)}}function ne(e,t){if(e!=null&&t?.fields?.length){if(`startField`in e){let n=t.get(e.startField),r=t.get(e.endField);e.startField=n?.name??null,e.endField=r?.name??null}else{let n=t.get(e.startTimeField),r=t.get(e.endTimeField);e.startTimeField=n?.name??null,e.endTimeField=r?.name??null}e.trackIdField=t.get(e.trackIdField)?.name??null}}const v=new Set;function y(e,t){return!e||!t?[]:(v.clear(),new d(v,e).collectAll(t),Array.from(v).sort())}function re(e,t){return t==null||e==null?[]:t.includes(`*`)?(e.fields??[]).map(e=>e.name):t}function ie(e,t,n=1){if(!t||!e)return[];if(t.includes(`*`))return[`*`];let r=y(e,t);return r.length/e.fields.length>=n?[`*`]:r}async function b(e,t,n){let{fieldsIndex:r}=e;if(!n)return;let i=t?void 0:a(n);if(i)e.collect(i);else{let{arcadeUtils:i}=await c(),a=i.extractFieldNames(n,t?.partitions??r?.fields?.map(e=>e.name)),o=t?.index?e.withFieldsIndex(t.index):e;for(let e of a)o.collect(e)}}async function x(t,n){let{fieldsIndex:r}=t;if(n&&n!==`1=1`){let a=await i(n,r&&`getTimeZone`in r?r:null);if(!a.isStandardized)throw new e(`fieldUtils:collectFilterFields`,`Where clause is not standardized`,{where:n});t.collectAll(a.fieldNames)}}function ae({displayField:e,fields:t}){return e||(t?.length?S(t):null)}function S(e){return C(e,`name-or-title`)||C(e,`unique-identifier`)||C(e,`type-or-category`)||oe(e)}function oe(e){for(let t of e){if(!t?.name)continue;let e=t.name.toLowerCase();if(e.includes(`name`)||e.includes(`title`))return t.name}return null}function C(e,t){for(let n of e)if(n?.valueType&&n.valueType===t)return n.name;return null}async function se(e){if(!e)return[];let t=new Set;return await ce(new d(t,e.fieldsIndex),e),Array.from(t).sort()}async function ce(e,t){if(!t)return;let n=t.elevationInfo?.featureExpressionInfo;if(n)return n.collectRequiredFields(e)}async function w(e,t){t.onStatisticExpression?await b(e,null,t.onStatisticExpression.expression):e.collect(t.onStatisticField)}async function le(e,t,n){if(!t||!n||!(`fields`in n))return;let r=[],i=n.popupTemplate;r.push(T(e,i)),n.fields&&r.push(...n.fields.map(async t=>w(e,t))),await Promise.all(r)}async function ue(e,t,n){let r=[];for(let i of n){let n=t.get(i);n&&r.push(w(e,n))}await Promise.all(r)}async function de(t){if(!t.loaded)throw new e(`fieldUtils:layer-not-loaded`,`The layer must be loaded before inspecting field usage.`);let{fieldsIndex:n,featureEffect:r,formTemplate:i}=t,{timeInfo:a}=t,o=[],s=[];if(t.definitionExpression){let e=t.definitionExpression;s.push(h({type:`definitionExpression`,value:e,owner:t},t=>x(t,e)))}r&&s.push(h({type:`featureEffect`,value:r,owner:t},e=>pe(e,{timeInfo:a},r.filter)));for(let e of t.displayFilterInfo?.filters??[])if(e.where){let t=e.where;s.push(h({type:`displayFilterInfo`,value:t,owner:e},e=>x(e,t)))}for(let e of t.orderBy??[])s.push(h({type:`orderBy`,value:e,owner:t},t=>E(t,e)));let{renderer:c,popupTemplate:l,featureReduction:u}=t;if(c&&s.push(h({type:`renderer`,value:c,owner:t},e=>c.collectRequiredFields?.(e))),l&&s.push(h({type:`popupTemplate`,value:l,owner:t},e=>l.collectRequiredFields(e))),i&&s.push(h({type:`formTemplate`,value:i,owner:t},async e=>{await i.collectRequiredFields(e,t.relationships??void 0)})),g(t.labelingInfo),u&&`fieldsIndex`in u){let e=u.fieldsIndex;for(let t of e.fields)s.push(h({type:`featureReduction.fields`,value:t,owner:u},e=>w(e,t)));let{renderer:t,popupTemplate:r}=u;if(t&&s.push(h({type:`featureReduction.renderer`,value:t,owner:u},e=>t.collectRequiredFields?.(e),e)),r){let t={type:`featureReduction.popupTemplate`,value:r,owner:u};s.push(h(t,t=>r.collectRequiredFields(t,{partitions:new Map([[`$feature`,e.fields.map(e=>e.name)]])}),e),h(t,e=>T(e,r,{partitions:new Map([[`$aggregatedFeatures`,n.fields.map(e=>e.name)]])})))}g(u.labelingInfo,e)}if(a&&s.push(h({type:`timeInfo`,value:a,owner:t},e=>e.collectAll([a.startField,a.endField,a.trackIdField]))),t.trackIdField){let e=t.trackIdField;s.push(h({type:`trackIdField`,value:e,owner:t},t=>t.collect(e)))}await Promise.all(s);let f=new Map,p=[];for(let{location:e,fieldNames:t,unknownNames:r}of o){for(let t of Array.from(r).sort())p.some(n=>n.fieldName===t&&m(n,e))||p.push({...e,fieldName:t});let i=y(n,Array.from(t));for(let t of i){let r=n.get(t);if(!r)continue;let i=f.get(r);i||(i=[],f.set(r,i)),i.some(t=>m(t,e))||i.push(e)}}for(let e of f.values())e.sort((e,t)=>e.type.localeCompare(t.type));return p.sort((e,t)=>e.type.localeCompare(t.type)),{unknownFields:p,getLocations(e){let t=n.get(e);return(t&&f.get(t))??[]}};function m(e,t){return e.type===t.type&&e.owner===t.owner&&e.value===t.value}async function h(e,t,r){let i=new Set,a=new Set;o.push({location:e,fieldNames:i,unknownNames:a});let s=r?new Set:i,c=r??n;await t(new ee(s,c));for(let e of s)e&&e!==`*`&&!c.has(e)&&a.add(e);r&&await ue(new d(i,n),r,s)}function g(e,t){let n=t?`featureReduction.labeling.expression`:`labeling.expression`,r=t?`featureReduction.labeling.where`:`labeling.where`;for(let i of e??[]){let e=i.getLabelExpression(),a=i.labelExpressionInfo?.expression??i.labelExpression??e.expression;if(s.push(h({type:n,value:a,owner:i},t=>P(t,e),t)),i.where){let e=i.where;s.push(h({type:r,value:e,owner:i},t=>x(t,e),t))}}}}async function fe(e,t){let{fieldsIndex:n,trackInfo:r}=t;if(!t||!r||!n)return;let i=[r.latestObservations.renderer?.collectRequiredFields(e),r.previousObservations.renderer?.collectRequiredFields(e),r.trackLines.renderer?.collectRequiredFields(e)];r.popupTemplate&&i.push(T(e,r.popupTemplate));for(let t of[r.latestObservations.labelingInfo,r.previousObservations.labelingInfo,r.trackLines.labelingInfo])if(t)for(let n of t)i.push(N(e,n));await Promise.all(i)}async function T(e,t,n){let r=[];t?.expressionInfos&&r.push(...t.expressionInfos.map(t=>b(e,n,t.expression)));let i=t?.content;if(Array.isArray(i))for(let t of i)t.type===`expression`&&t.expressionInfo&&r.push(b(e,n,t.expressionInfo.expression));await Promise.all(r)}async function pe(e,t,n){t&&(t.timeInfo&&n?.timeExtent&&e.collectAll([t.timeInfo.startField,t.timeInfo.endField]),t.floorInfo&&e.collectAll([t.floorInfo.floorField]),n?.where!=null&&await x(e,n.where))}async function me(e,t,n){t&&n&&await Promise.all(n.map(t=>E(e,t)))}async function E(e,t){t&&(t.valueExpression?await b(e,null,t.valueExpression):t.field&&e.collect(t.field))}async function he(e){if(!e)return[];let t=`timeInfo`in e&&e.timeInfo;return t?y(e.fieldsIndex,[e.trackIdField,t.startField,t.endField]):[]}function ge(e){return e?y(e.fieldsIndex,k(e)):[]}function D(e){if(!e)return[];let t=e.geometryFieldsInfo;return t?y(e.fieldsIndex,[t.shapeAreaField,t.shapeLengthField]):[]}async function _e(e,t,n){t&&n&&await Promise.all(n.filters.map(t=>x(e,t.where)))}const ve=new Set([`oid`,`global-id`,`guid`]),ye=new Set([`oid`,`global-id`]),be=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^shape$/i,/^shape_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/objectid/i,/^perimeter_/i,/_perimeter$/i,/_i$/i];function O(e){let t=new Set;A(e).forEach(e=>t.add(e)),D(e).forEach(e=>t.add(e.toLowerCase()));let n=e&&`infoFor3D`in e?e.infoFor3D:void 0;return n&&(Object.values(n.assetMapFieldRoles).forEach(e=>t.add(e.toLowerCase())),Object.values(n.transformFieldRoles).forEach(e=>t.add(e.toLowerCase()))),Array.from(t)}function k(e){if(!e)return[];let t=`editFieldsInfo`in e&&e.editFieldsInfo;if(!t)return[];let{creationDateField:n,creatorField:r,editDateField:i,editorField:a}=t;return[n,r,i,a].filter(Boolean)}function A(e){return k(e).map(e=>e.toLowerCase())}function j(e){return!!e.type}function xe(e,t){return!!e.editable&&j(e)&&!ve.has(e.type)&&!A(t).includes(e.name?.toLowerCase()??``)}function Se(e,t){let n=e.name?.toLowerCase()??``;return(t?.objectIdField==null||n!==t.objectIdField.toLowerCase())&&(t?.globalIdField==null||n!==t.globalIdField.toLowerCase())&&!O(t).includes(n)&&!ye.has(e.type)&&!be.some(e=>e.test(n))}async function Ce(e){if(!e)return[];let t=new Set;return await M(new d(t,e.fieldsIndex),e),Array.from(t).sort()}async function M(e,t){let{labelingInfo:n}=t;n?.length&&await Promise.all(n.map(t=>N(e,t)))}async function N(e,t){t&&await Promise.all([P(e,t.getLabelExpression()),x(e,t.where)])}async function P(e,t){if(t.type===`arcade`)await b(e,null,t.expression);else{let n=t.expression.match(/{[^}]*}/g);n&&n.forEach(t=>{e.collect(t.slice(1,-1))})}}function we(e){let t=e.defaultValue;if(t!==void 0&&I(e,t))return t;if(e.nullable)return null}function Te(e){let t=typeof e==`string`?{type:e}:e;if(U(t))return 255;if(t.type===`esriFieldTypeDate`||t.type===`date`)return 8}function F(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function Ee(e){return e===null||F(e)}function De(e){return e===null||Number.isInteger(e)}function Oe(){return!0}function I(e,t){let n;switch(e.type){case`date`:case`integer`:case`long`:case`small-integer`:case`big-integer`:case`esriFieldTypeDate`:case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`esriFieldTypeSmallInteger`:case`esriFieldTypeBigInteger`:n=e.nullable?De:Number.isInteger;break;case`double`:case`single`:case`esriFieldTypeSingle`:case`esriFieldTypeDouble`:n=e.nullable?Ee:F;break;case`string`:case`esriFieldTypeString`:n=e.nullable?o:s;break;default:n=Oe}return arguments.length===1?n:n(t)}const L=[`integer`,`small-integer`,`big-integer`,`long`],R=[`single`,`double`],ke=[...L,...R],z=[`esriFieldTypeInteger`,`esriFieldTypeSmallInteger`,`esriFieldTypeLong`,`esriFieldTypeBigInteger`],B=[`esriFieldTypeSingle`,`esriFieldTypeDouble`],V=new Set([...L,...z]),Ae=new Set([...R,...B]),je=r(V,Ae);function Me(e){return e!=null&&V.has(e.type)}function H(e){return e!=null&&je.has(e.type)}function U(e){return e!=null&&(e.type===`string`||e.type===`esriFieldTypeString`)}function W(e){return e!=null&&(e.type===`date`||e.type===`esriFieldTypeDate`)}function Ne(e){return e!=null&&(e.type===`date-only`||e.type===`esriFieldTypeDateOnly`)}function Pe(e){return e!=null&&(e.type===`guid`||e.type===`esriFieldTypeGUID`)}function Fe(e){return e!=null&&(e.type===`timestamp-offset`||e.type===`esriFieldTypeTimestampOffset`)}function Ie(e){return e!=null&&(e.type===`time-only`||e.type===`esriFieldTypeTimeOnly`)}function Le(e){return e!=null&&(e.type===`date`||e.type===`date-only`||e.type===`time-only`||e.type===`timestamp-offset`)}function Re(e){return e!=null&&(e.type===`oid`||e.type===`esriFieldTypeOID`)}function ze(e){return e!=null&&(e.type===`global-id`||e.type===`esriFieldTypeGlobalID`)}function Be(e,t){return Ue(e,t)===null}const G={OUT_OF_RANGE:`numeric-range-validation-error::out-of-range`},K={INVALID_TYPE:`type-validation-error::invalid-type`};function Ve(e){return e==null||typeof e==`number`&&isNaN(e)?null:e}function He(e){return parseFloat(e.replaceAll(`_`,``))}function Ue(e,t){return e==null||e.nullable&&t===null?null:I(e,t)?H(e)&&!We(e.type,Number(t))?G.OUT_OF_RANGE:null:K.INVALID_TYPE}function We(e,t){let n=typeof e==`string`?q(e):e;if(!n)return!1;let r=n.min,i=n.max;return n.isInteger?Number.isInteger(t)&&t>=r&&t<=i:t>=r&&t<=i}function Ge(e,t){let n=u(e,t);if(n)return n;if(H(e))return q(e.type)}function q(e){switch(e){case`esriFieldTypeSmallInteger`:case`small-integer`:return J;case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`integer`:case`long`:return Y;case`esriFieldTypeBigInteger`:case`big-integer`:return X;case`esriFieldTypeSingle`:case`single`:return Q;case`esriFieldTypeDouble`:case`double`:return Ye}}function Ke(e){if(!F(e))return null;if(Number.isInteger(e)){if(e>=J.min&&e<=J.max)return`esriFieldTypeSmallInteger`;if(e>=Y.min&&e<=Y.max)return`esriFieldTypeInteger`;if(e>=X.min&&e<=X.max)return`esriFieldTypeBigInteger`}return e>=Q.min&&e<=Q.max?`esriFieldTypeSingle`:`esriFieldTypeDouble`}const J={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},qe=-0x80000000,Je=2**31-1,Y={min:qe,max:Je,isInteger:!0,rawMin:qe,rawMax:Je},X={min:-(2**53-1),max:2**53-1,isInteger:!0,rawMin:-(2**53-1),rawMax:2**53-1},Z=(2-2**-23)*2**127,Q={min:-Z,max:Z,isInteger:!1,rawMin:-Z,rawMax:Z},Ye={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function Xe(e,t,n){switch(e){case l.INVALID_CODED_VALUE:return`Value ${n} is not in the coded domain - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case l.VALUE_OUT_OF_RANGE:return`Value ${n} is out of the range of valid values - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case K.INVALID_TYPE:return`Value ${n} is not a valid value for the field type - field: ${t.name}, type: ${t.type}, nullable: ${t.nullable}`;case G.OUT_OF_RANGE:{let{min:e,max:r}=q(t.type);return`Value ${n} is out of range for the number type - field: ${t.name}, type: ${t.type}, value range is ${e} to ${r}`}}}function Ze(e,t){return!$(e,t,null)}function $(e,t,n){if(!e?.attributes||!t){if(n!=null)for(let e of t??[])n.add(e);return!0}let r=new Set(Object.keys(e.attributes)),i=!1;for(let e of t)if(!r.has(e)){if(i=!0,n!=null)n.add(e);else break}return i}async function Qe(e,t){let n=new Set,r=new d(n,e.fieldsIndex);for(let e of t)await b(r,null,e);return Array.from(n).sort()}function $e(e){return e?[`raster.itempixelvalue`,`raster.servicepixelvalue`].some(t=>e.toLowerCase().startsWith(t)):!1}async function et(e,t){let n=new Set;return e?.collectRequiredFields&&await e.collectRequiredFields(new d(n,t)),Array.from(n).sort()}function tt(e){let t=e?.match(/{[^}]+}/g);return t?t.map(e=>e.slice(1,-1).split(`:`,1)[0].trim()):[]}function nt(e,t){let{statisticType:n,onStatisticField:r,onStatisticExpression:i}=e,a=t.get(r),o=H(a),s=i?.returnType;switch(n){case`avg`:case`avg_angle`:return a?o||W(a)?`double`:null:s&&s===`number`?`double`:null;case`count`:return`integer`;case`min`:case`max`:return a?o||Le(a)?a?.type??null:null:s&&s===`number`?`double`:null;case`sum`:return a?o?a?.type??null:null:s&&s===`number`?`double`:null;case`mode`:return a?a?.type??null:s?s===`number`?`double`:`string`:null;default:return null}}function rt(e){let{fieldName:t,fieldsMap:n,normalizedFieldsMap:r}=e;if(!t)return;let i=n.get(t);return i||(i=n.get(it(t))??r.get(at(t)),i&&n.set(t,i),i)}function it(e){return e.trim().toLowerCase()}function at(e){return m(e)?.toLowerCase()??``}export{G as NumericRangeValidationError,K as TypeValidationError,it as applyLowerCaseFieldName,X as bigIntegerRange,b as collectArcadeFieldNames,_e as collectDisplayFilterFields,ce as collectElevationFields,le as collectFeatureReductionFields,pe as collectFilterFields,M as collectLabelingFields,me as collectOrderByInfos,T as collectPopupTemplateFields,x as collectSQLFieldNames,fe as collectTrackInfoFields,Ye as doubleRange,tt as extractSubstitutionTemplatesFromString,Ze as featureHasFields,y as fixFields,te as fixRendererFields,ne as fixTimeInfoFields,B as floatJSONTypes,R as floatTypes,nt as getAggregateFieldType,ae as getDisplayFieldName,S as getDisplayFieldNameFromFields,k as getEditTrackingFields,se as getElevationFields,Qe as getExpressionFields,ge as getFeatureEditFields,D as getFeatureGeometryFields,Te as getFieldDefaultLength,we as getFieldDefaultValue,rt as getFieldFromIndex,Ge as getFieldRange,de as getFieldUsage,Ce as getLabelingFields,O as getLowerCaseDefaultHiddenFields,A as getLowerCaseEditTrackingFields,Ke as getNumericTypeForValue,et as getRendererFields,he as getTimeFields,z as integerJSONTypes,Y as integerRange,L as integerTypes,W as isDateField,Ne as isDateOnlyField,xe as isFieldEditable,Se as isFieldVisibleByDefault,j as isFieldWithType,ze as isGlobalIDField,Pe as isGuidField,Me as isIntegerField,We as isNumberInRange,H as isNumericField,Re as isObjectIDField,$e as isRasterPixelValueField,U as isStringField,Ie as isTimeOnlyField,Fe as isTimestampOffsetField,Be as isValidFieldValue,I as isValueMatchingFieldType,at as lowerCaseNormalizedFieldName,m as normalizeFieldName,ke as numericTypes,ie as packFields,$ as populateMissingFields,h as rendererFields,Ve as sanitizeNullFieldValue,He as sanitizedParseFloat,Q as singleRange,J as smallIntegerRange,re as unpackFieldNames,Ue as validateFieldValue,Xe as validationErrorToString,g as visualVariableFields};
|
|
2
|
+
import e from"../../core/Error.js";import{getDeepValue as t,setDeepValue as n}from"../../core/object.js";import{union as r}from"../../core/SetUtils.js";import{parseWhereClause as i}from"../../core/sql.js";import{getFieldNameFromSimpleExpression as a}from"../../support/arcadeExpressionUtils.js";import{isStringOrNull as o,isString as s}from"../../support/guards.js";import{loadArcade as c}from"../../support/loadArcade.js";import{DomainValidationError as l,getDomainRange as u}from"./domainUtils.js";import{RequiredFieldsCollector as d,ReferencedFieldsCollector as ee}from"./FieldCollector.js";const f=/^([0-9_])/,p=/[^a-z0-9_\u0080-\uffff]+/gi;function m(e){return e==null?null:e.trim().replaceAll(p,`_`).replace(f,`F$1`)||null}const h=[`field`,`field2`,`field3`,`normalizationField`,`rotationInfo.field`,`proportionalSymbolInfo.field`,`proportionalSymbolInfo.normalizationField`,`colorInfo.field`,`colorInfo.normalizationField`],te=[`field`,`normalizationField`];function ne(e,t){if(e!=null&&t!=null){for(let n of Array.isArray(e)?e:[e])if(g(h,n,t),`visualVariables`in n&&n.visualVariables)for(let e of n.visualVariables)g(te,e,t)}}function g(e,r,i){if(e)for(let a of e){let e=t(a,r),o=e&&typeof e!=`function`&&i.get(e);o&&n(a,o.name,r)}}function re(e,t){if(e!=null&&t?.fields?.length){if(`startField`in e){let n=t.get(e.startField),r=t.get(e.endField);e.startField=n?.name??null,e.endField=r?.name??null}else{let n=t.get(e.startTimeField),r=t.get(e.endTimeField);e.startTimeField=n?.name??null,e.endTimeField=r?.name??null}e.trackIdField=t.get(e.trackIdField)?.name??null}}const _=new Set;function v(e,t){return!e||!t?[]:(_.clear(),new d(_,e).collectAll(t),Array.from(_).sort())}function ie(e,t){return t==null||e==null?[]:t.includes(`*`)?(e.fields??[]).map(e=>e.name):t}function ae(e,t,n=1){if(!t||!e)return[];if(t.includes(`*`))return[`*`];let r=v(e,t);return r.length/e.fields.length>=n?[`*`]:r}async function y(e,t,n){let{fieldsIndex:r}=e;if(!n)return;let i=t?void 0:a(n);if(i)e.collect(i);else{let{arcadeUtils:i}=await c(),a=i.extractFieldNames(n,t?.partitions??r?.fields?.map(e=>e.name)),o=t?.index?e.withFieldsIndex(t.index):e;for(let e of a)o.collect(e)}}async function b(t,n){let{fieldsIndex:r}=t;if(n&&n!==`1=1`){let a=await i(n,r&&`getTimeZone`in r?r:null);if(!a.isStandardized)throw new e(`fieldUtils:collectFilterFields`,`Where clause is not standardized`,{where:n});t.collectAll(a.fieldNames)}}function oe({displayField:e,fields:t}){return e||(t?.length?x(t):null)}function x(e){return S(e,`name-or-title`)||S(e,`unique-identifier`)||S(e,`type-or-category`)||se(e)}function se(e){for(let t of e){if(!t?.name)continue;let e=t.name.toLowerCase();if(e.includes(`name`)||e.includes(`title`))return t.name}return null}function S(e,t){for(let n of e)if(n?.valueType&&n.valueType===t)return n.name;return null}async function ce(e){if(!e)return[];let t=new Set;return await le(new d(t,e.fieldsIndex),e),Array.from(t).sort()}async function le(e,t){if(!t)return;let n=t.elevationInfo?.featureExpressionInfo;if(n)return n.collectRequiredFields(e)}async function C(e,t){t.onStatisticExpression?await y(e,null,t.onStatisticExpression.expression):e.collect(t.onStatisticField)}async function ue(e,t,n){if(!t||!n||!(`fields`in n))return;let r=[],i=n.popupTemplate;r.push(w(e,i)),n.fields&&r.push(...n.fields.map(async t=>C(e,t))),await Promise.all(r)}async function de(e,t,n){let r=[];for(let i of n){let n=t.get(i);n&&r.push(C(e,n))}await Promise.all(r)}async function fe(e){await e.load();let{fieldsIndex:t,featureEffect:n,formTemplate:r}=e,{timeInfo:i}=e,a=[],o=[];if(e.definitionExpression){let t=e.definitionExpression;o.push(m({type:`definitionExpression`,value:t,owner:e},e=>b(e,t)))}n&&o.push(m({type:`featureEffect`,value:n,owner:e},e=>me(e,{timeInfo:i},n.filter)));for(let t of e.displayFilterInfo?.filters??[])if(t.where){let e=t.where;o.push(m({type:`displayFilterInfo`,value:e,owner:t},t=>b(t,e)))}for(let t of e.orderBy??[])o.push(m({type:`orderBy`,value:t,owner:e},e=>T(e,t)));let{renderer:s,popupTemplate:c,featureReduction:l}=e;if(s&&o.push(m({type:`renderer`,value:s,owner:e},e=>s.collectRequiredFields?.(e))),c&&o.push(m({type:`popupTemplate`,value:c,owner:e},e=>c.collectRequiredFields(e))),r&&o.push(m({type:`formTemplate`,value:r,owner:e},async t=>{await r.collectRequiredFields(t,e.relationships??void 0)})),h(e.labelingInfo),l&&`fieldsIndex`in l){let e=l.fieldsIndex;for(let t of e.fields)o.push(m({type:`featureReduction.fields`,value:t,owner:l},e=>C(e,t)));let{renderer:n,popupTemplate:r}=l;if(n&&o.push(m({type:`featureReduction.renderer`,value:n,owner:l},e=>n.collectRequiredFields?.(e),e)),r){let n={type:`featureReduction.popupTemplate`,value:r,owner:l};o.push(m(n,t=>r.collectRequiredFields(t,{partitions:new Map([[`$feature`,e.fields.map(e=>e.name)]])}),e),m(n,e=>w(e,r,{partitions:new Map([[`$aggregatedFeatures`,t.fields.map(e=>e.name)]])})))}h(l.labelingInfo,e)}if(i&&o.push(m({type:`timeInfo`,value:i,owner:e},e=>e.collectAll([i.startField,i.endField,i.trackIdField]))),e.trackIdField){let t=e.trackIdField;o.push(m({type:`trackIdField`,value:t,owner:e},e=>e.collect(t)))}await Promise.all(o);let u=new Map,f=[];for(let{location:e,fieldNames:n,unknownNames:r}of a){for(let t of Array.from(r).sort())f.some(n=>n.fieldName===t&&p(n,e))||f.push({...e,fieldName:t});let i=v(t,Array.from(n));for(let n of i){let r=t.get(n);if(!r)continue;let i=u.get(r);i||(i=[],u.set(r,i)),i.some(t=>p(t,e))||i.push(e)}}for(let e of u.values())e.sort((e,t)=>e.type.localeCompare(t.type));return f.sort((e,t)=>e.type.localeCompare(t.type)),{unknownFields:f,getLocations(e){let n=t.get(e);return(n&&u.get(n))??[]}};function p(e,t){return e.type===t.type&&e.owner===t.owner&&e.value===t.value}async function m(e,n,r){let i=new Set,o=new Set;a.push({location:e,fieldNames:i,unknownNames:o});let s=r?new Set:i,c=r??t;await n(new ee(s,c));for(let e of s)e&&e!==`*`&&!c.has(e)&&o.add(e);r&&await de(new d(i,t),r,s)}function h(e,t){let n=t?`featureReduction.labeling.expression`:`labeling.expression`,r=t?`featureReduction.labeling.where`:`labeling.where`;for(let i of e??[]){let e=i.getLabelExpression(),a=i.labelExpressionInfo?.expression??i.labelExpression??e.expression;if(o.push(m({type:n,value:a,owner:i},t=>N(t,e),t)),i.where){let e=i.where;o.push(m({type:r,value:e,owner:i},t=>b(t,e),t))}}}}async function pe(e,t){let{fieldsIndex:n,trackInfo:r}=t;if(!t||!r||!n)return;let i=[r.latestObservations.renderer?.collectRequiredFields(e),r.previousObservations.renderer?.collectRequiredFields(e),r.trackLines.renderer?.collectRequiredFields(e)];r.popupTemplate&&i.push(w(e,r.popupTemplate));for(let t of[r.latestObservations.labelingInfo,r.previousObservations.labelingInfo,r.trackLines.labelingInfo])if(t)for(let n of t)i.push(M(e,n));await Promise.all(i)}async function w(e,t,n){let r=[];t?.expressionInfos&&r.push(...t.expressionInfos.map(t=>y(e,n,t.expression)));let i=t?.content;if(Array.isArray(i))for(let t of i)t.type===`expression`&&t.expressionInfo&&r.push(y(e,n,t.expressionInfo.expression));await Promise.all(r)}async function me(e,t,n){t&&(t.timeInfo&&n?.timeExtent&&e.collectAll([t.timeInfo.startField,t.timeInfo.endField]),t.floorInfo&&e.collectAll([t.floorInfo.floorField]),n?.where!=null&&await b(e,n.where))}async function he(e,t,n){t&&n&&await Promise.all(n.map(t=>T(e,t)))}async function T(e,t){t&&(t.valueExpression?await y(e,null,t.valueExpression):t.field&&e.collect(t.field))}async function ge(e){if(!e)return[];let t=`timeInfo`in e&&e.timeInfo;return t?v(e.fieldsIndex,[e.trackIdField,t.startField,t.endField]):[]}function _e(e){return e?v(e.fieldsIndex,O(e)):[]}function E(e){if(!e)return[];let t=e.geometryFieldsInfo;return t?v(e.fieldsIndex,[t.shapeAreaField,t.shapeLengthField]):[]}async function ve(e,t,n){t&&n&&await Promise.all(n.filters.map(t=>b(e,t.where)))}const ye=new Set([`oid`,`global-id`,`guid`]),be=new Set([`oid`,`global-id`]),xe=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^shape$/i,/^shape_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/objectid/i,/^perimeter_/i,/_perimeter$/i,/_i$/i];function D(e){let t=new Set;k(e).forEach(e=>t.add(e)),E(e).forEach(e=>t.add(e.toLowerCase()));let n=e&&`infoFor3D`in e?e.infoFor3D:void 0;return n&&(Object.values(n.assetMapFieldRoles).forEach(e=>t.add(e.toLowerCase())),Object.values(n.transformFieldRoles).forEach(e=>t.add(e.toLowerCase()))),Array.from(t)}function O(e){if(!e)return[];let t=`editFieldsInfo`in e&&e.editFieldsInfo;if(!t)return[];let{creationDateField:n,creatorField:r,editDateField:i,editorField:a}=t;return[n,r,i,a].filter(Boolean)}function k(e){return O(e).map(e=>e.toLowerCase())}function A(e){return!!e.type}function Se(e,t){return!!e.editable&&A(e)&&!ye.has(e.type)&&!k(t).includes(e.name?.toLowerCase()??``)}function Ce(e,t){let n=e.name?.toLowerCase()??``;return(t?.objectIdField==null||n!==t.objectIdField.toLowerCase())&&(t?.globalIdField==null||n!==t.globalIdField.toLowerCase())&&!D(t).includes(n)&&!be.has(e.type)&&!xe.some(e=>e.test(n))}async function we(e){if(!e)return[];let t=new Set;return await j(new d(t,e.fieldsIndex),e),Array.from(t).sort()}async function j(e,t){let{labelingInfo:n}=t;n?.length&&await Promise.all(n.map(t=>M(e,t)))}async function M(e,t){t&&await Promise.all([N(e,t.getLabelExpression()),b(e,t.where)])}async function N(e,t){if(t.type===`arcade`)await y(e,null,t.expression);else{let n=t.expression.match(/{[^}]*}/g);n&&n.forEach(t=>{e.collect(t.slice(1,-1))})}}function Te(e){let t=e.defaultValue;if(t!==void 0&&F(e,t))return t;if(e.nullable)return null}function Ee(e){let t=typeof e==`string`?{type:e}:e;if(H(t))return 255;if(t.type===`esriFieldTypeDate`||t.type===`date`)return 8}function P(e){return typeof e==`number`&&!isNaN(e)&&isFinite(e)}function De(e){return e===null||P(e)}function Oe(e){return e===null||Number.isInteger(e)}function ke(){return!0}function F(e,t){let n;switch(e.type){case`date`:case`integer`:case`long`:case`small-integer`:case`big-integer`:case`esriFieldTypeDate`:case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`esriFieldTypeSmallInteger`:case`esriFieldTypeBigInteger`:n=e.nullable?Oe:Number.isInteger;break;case`double`:case`single`:case`esriFieldTypeSingle`:case`esriFieldTypeDouble`:n=e.nullable?De:P;break;case`string`:case`esriFieldTypeString`:n=e.nullable?o:s;break;default:n=ke}return arguments.length===1?n:n(t)}const I=[`integer`,`small-integer`,`big-integer`,`long`],L=[`single`,`double`],Ae=[...I,...L],R=[`esriFieldTypeInteger`,`esriFieldTypeSmallInteger`,`esriFieldTypeLong`,`esriFieldTypeBigInteger`],z=[`esriFieldTypeSingle`,`esriFieldTypeDouble`],B=new Set([...I,...R]),je=new Set([...L,...z]),Me=r(B,je);function Ne(e){return e!=null&&B.has(e.type)}function V(e){return e!=null&&Me.has(e.type)}function H(e){return e!=null&&(e.type===`string`||e.type===`esriFieldTypeString`)}function U(e){return e!=null&&(e.type===`date`||e.type===`esriFieldTypeDate`)}function Pe(e){return e!=null&&(e.type===`date-only`||e.type===`esriFieldTypeDateOnly`)}function Fe(e){return e!=null&&(e.type===`guid`||e.type===`esriFieldTypeGUID`)}function Ie(e){return e!=null&&(e.type===`timestamp-offset`||e.type===`esriFieldTypeTimestampOffset`)}function Le(e){return e!=null&&(e.type===`time-only`||e.type===`esriFieldTypeTimeOnly`)}function Re(e){return e!=null&&(e.type===`date`||e.type===`date-only`||e.type===`time-only`||e.type===`timestamp-offset`)}function ze(e){return e!=null&&(e.type===`oid`||e.type===`esriFieldTypeOID`)}function Be(e){return e!=null&&(e.type===`global-id`||e.type===`esriFieldTypeGlobalID`)}function Ve(e,t){return We(e,t)===null}const W={OUT_OF_RANGE:`numeric-range-validation-error::out-of-range`},G={INVALID_TYPE:`type-validation-error::invalid-type`};function He(e){return e==null||typeof e==`number`&&isNaN(e)?null:e}function Ue(e){return parseFloat(e.replaceAll(`_`,``))}function We(e,t){return e==null||e.nullable&&t===null?null:F(e,t)?V(e)&&!Ge(e.type,Number(t))?W.OUT_OF_RANGE:null:G.INVALID_TYPE}function Ge(e,t){let n=typeof e==`string`?K(e):e;if(!n)return!1;let r=n.min,i=n.max;return n.isInteger?Number.isInteger(t)&&t>=r&&t<=i:t>=r&&t<=i}function Ke(e,t){let n=u(e,t);if(n)return n;if(V(e))return K(e.type)}function K(e){switch(e){case`esriFieldTypeSmallInteger`:case`small-integer`:return q;case`esriFieldTypeInteger`:case`esriFieldTypeLong`:case`integer`:case`long`:return J;case`esriFieldTypeBigInteger`:case`big-integer`:return Y;case`esriFieldTypeSingle`:case`single`:return Z;case`esriFieldTypeDouble`:case`double`:return Xe}}function qe(e){if(!P(e))return null;if(Number.isInteger(e)){if(e>=q.min&&e<=q.max)return`esriFieldTypeSmallInteger`;if(e>=J.min&&e<=J.max)return`esriFieldTypeInteger`;if(e>=Y.min&&e<=Y.max)return`esriFieldTypeBigInteger`}return e>=Z.min&&e<=Z.max?`esriFieldTypeSingle`:`esriFieldTypeDouble`}const q={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},Je=-0x80000000,Ye=2**31-1,J={min:Je,max:Ye,isInteger:!0,rawMin:Je,rawMax:Ye},Y={min:-(2**53-1),max:2**53-1,isInteger:!0,rawMin:-(2**53-1),rawMax:2**53-1},X=(2-2**-23)*2**127,Z={min:-X,max:X,isInteger:!1,rawMin:-X,rawMax:X},Xe={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function Ze(e,t,n){switch(e){case l.INVALID_CODED_VALUE:return`Value ${n} is not in the coded domain - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case l.VALUE_OUT_OF_RANGE:return`Value ${n} is out of the range of valid values - field: ${t.name}, domain: ${JSON.stringify(t.domain)}`;case G.INVALID_TYPE:return`Value ${n} is not a valid value for the field type - field: ${t.name}, type: ${t.type}, nullable: ${t.nullable}`;case W.OUT_OF_RANGE:{let{min:e,max:r}=K(t.type);return`Value ${n} is out of range for the number type - field: ${t.name}, type: ${t.type}, value range is ${e} to ${r}`}}}function Qe(e,t){return!Q(e,t,null)}function Q(e,t,n){if(!e?.attributes||!t){if(n!=null)for(let e of t??[])n.add(e);return!0}let r=new Set(Object.keys(e.attributes)),i=!1;for(let e of t)if(!r.has(e)){if(i=!0,n!=null)n.add(e);else break}return i}async function $e(e,t){let n=new Set,r=new d(n,e.fieldsIndex);for(let e of t)await y(r,null,e);return Array.from(n).sort()}function et(e){return e?[`raster.itempixelvalue`,`raster.servicepixelvalue`].some(t=>e.toLowerCase().startsWith(t)):!1}async function tt(e,t){let n=new Set;return e?.collectRequiredFields&&await e.collectRequiredFields(new d(n,t)),Array.from(n).sort()}function nt(e){let t=e?.match(/{[^}]+}/g);return t?t.map(e=>e.slice(1,-1).split(`:`,1)[0].trim()):[]}function rt(e,t){let{statisticType:n,onStatisticField:r,onStatisticExpression:i}=e,a=t.get(r),o=V(a),s=i?.returnType;switch(n){case`avg`:case`avg_angle`:return a?o||U(a)?`double`:null:s&&s===`number`?`double`:null;case`count`:return`integer`;case`min`:case`max`:return a?o||Re(a)?a?.type??null:null:s&&s===`number`?`double`:null;case`sum`:return a?o?a?.type??null:null:s&&s===`number`?`double`:null;case`mode`:return a?a?.type??null:s?s===`number`?`double`:`string`:null;default:return null}}function it(e){let{fieldName:t,fieldsMap:n,normalizedFieldsMap:r}=e;if(!t)return;let i=n.get(t);return i||(i=n.get(at(t))??r.get($(t)),i&&n.set(t,i),i)}function at(e){return e.trim().toLowerCase()}function $(e){return m(e)?.toLowerCase()??``}export{W as NumericRangeValidationError,G as TypeValidationError,at as applyLowerCaseFieldName,Y as bigIntegerRange,y as collectArcadeFieldNames,ve as collectDisplayFilterFields,le as collectElevationFields,ue as collectFeatureReductionFields,me as collectFilterFields,j as collectLabelingFields,he as collectOrderByInfos,w as collectPopupTemplateFields,b as collectSQLFieldNames,pe as collectTrackInfoFields,Xe as doubleRange,nt as extractSubstitutionTemplatesFromString,Qe as featureHasFields,v as fixFields,ne as fixRendererFields,re as fixTimeInfoFields,z as floatJSONTypes,L as floatTypes,rt as getAggregateFieldType,oe as getDisplayFieldName,x as getDisplayFieldNameFromFields,O as getEditTrackingFields,ce as getElevationFields,$e as getExpressionFields,_e as getFeatureEditFields,E as getFeatureGeometryFields,Ee as getFieldDefaultLength,Te as getFieldDefaultValue,it as getFieldFromIndex,Ke as getFieldRange,we as getLabelingFields,fe as getLayerFieldUsage,D as getLowerCaseDefaultHiddenFields,k as getLowerCaseEditTrackingFields,qe as getNumericTypeForValue,tt as getRendererFields,ge as getTimeFields,R as integerJSONTypes,J as integerRange,I as integerTypes,U as isDateField,Pe as isDateOnlyField,Se as isFieldEditable,Ce as isFieldVisibleByDefault,A as isFieldWithType,Be as isGlobalIDField,Fe as isGuidField,Ne as isIntegerField,Ge as isNumberInRange,V as isNumericField,ze as isObjectIDField,et as isRasterPixelValueField,H as isStringField,Le as isTimeOnlyField,Ie as isTimestampOffsetField,Ve as isValidFieldValue,F as isValueMatchingFieldType,$ as lowerCaseNormalizedFieldName,m as normalizeFieldName,Ae as numericTypes,ae as packFields,Q as populateMissingFields,h as rendererFields,He as sanitizeNullFieldValue,Ue as sanitizedParseFloat,Z as singleRange,q as smallIntegerRange,ie as unpackFieldNames,We as validateFieldValue,Ze as validationErrorToString,te as visualVariableFields};
|
package/networks/Network.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../core/accessorSupport/decorators.js";import r from"../core/Error.js";import{Loadable as i}from"../core/Loadable.js";import a from"../core/Logger.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{isAbortError as s}from"../core/promiseUtils.js";import{urlToObject as c}from"../core/urlUtils.js";import{generateUUID as l}from"../core/uuid.js";import u from"../geometry/Extent.js";import d from"../geometry/SpatialReference.js";import{fromJSON as f}from"../geometry/support/jsonUtils.js";import p from"../Graphic.js";import{versionMatches as m,onApplyEditsEvent as h,onUpdateMomentEvent as g,emitApplyEditsEvent as _}from"../layers/mixins/EditBusLayer.js";import{parse as v}from"../layers/support/arcgisLayerUrl.js";import y from"../request.js";import{isVersionInEditSession as b,currentSessionId as x,isSafeToEditVersion as S}from"../versionManagement/support/versionManagementUtils.js";import C from"./support/TopologyValidationJobInfo.js";import{networkFromPortalItem as w}from"./support/utils.js";let T=class extends o(i){static fromPortalItem(e){return w(e)}constructor(e){super(e),this.id=l(),this.title=null,this.layerUrl=null,this.dataElement=null,this.fullExtent=null,this.spatialReference=null,this.type=null,this.sourceJSON=null,this._historicMoment=null,this._gdbVersion=null,this._sourceIdByLayerId=new Map,this._layerIdBySourceId=new Map,this._applyEditsHandler=e=>{let{serviceUrl:t,gdbVersion:n,result:r}=e,i=t===this.featureServiceUrl,a=m(t,n,this.gdbVersion);i&&a&&r.then(e=>{b(t,n)&&(this.historicMoment=e.historicMoment)})},this._updateMomentHandler=e=>{let{serviceUrl:t,gdbVersion:n,moment:r}=e,i=t===this.featureServiceUrl,a=m(t,n,this.gdbVersion);i&&a&&(this.historicMoment=r)},this.when().then(()=>{this.addHandles([h(this._applyEditsHandler),g(this._updateMomentHandler)])},()=>{})}initialize(){this.when().catch(e=>{s(e)||a.getLogger(this).error(`#load()`,`Failed to load layer (title: '${this.title??`no title`}', id: '${this.id??`no id`}')`,{error:e})})}get loaded(){return super.loaded}get datasetName(){return this.dataElement?.name??null}get owner(){return this.dataElement?.userIdentity??null}get schemaGeneration(){return this.dataElement?.schemaGeneration??null}get parsedUrl(){return c(this.layerUrl)}get featureServiceUrl(){return v(this.parsedUrl.path).url.path}get networkServiceUrl(){return this.featureServiceUrl.replace(/\/FeatureServer/i,`/UtilityNetworkServer`)}get layerId(){return v(this.parsedUrl.path).sublayer}get networkSystemLayers(){return null}get gdbVersion(){return this._gdbVersion}set gdbVersion(e){this._gdbVersion=e}get historicMoment(){return this._historicMoment}set historicMoment(e){this._historicMoment=e}async load(e){return this.addResolvingPromise(this._load(e)),this}async _load(e){await Promise.all([this._fetchDataElement(this.featureServiceUrl,this.layerId.toString(),e),this._fetchLayerMetaData(this.layerUrl,e)])}getLayerIdBySourceId(e){if(!this.dataElement)return null;let t=this._layerIdBySourceId.get(e);if(t!=null)return t;let n=this.dataElement.domainNetworks,r=this._traverseNetworkSources(n,this._layerIdBySourceId,`sourceId`,`layerId`,e);return r>=0?r:null}getSourceIdByLayerId(e){if(!this.dataElement)return null;let t=this._sourceIdByLayerId.get(e);if(t!=null)return t;let n=this.dataElement.domainNetworks,r=this._traverseNetworkSources(n,this._sourceIdByLayerId,`layerId`,`sourceId`,e);return r>=0?r:null}getObjectIdsFromElements(e){let t=[],n=new Map;for(let t of e){let e=this.getLayerIdBySourceId(t.networkSourceId);if(e==null)continue;let r=n.get(e);r===void 0&&(r=[]),r.push(t.objectId),n.set(e,r)}let r=this.featureServiceUrl;return n.forEach((e,n)=>t.push({layerUrl:`${r}/${n}`,objectIds:e})),t}async queryNamedTraceConfigurations(e,t){let[{queryNamedTraceConfigurations:n},{default:r}]=await Promise.all([import(`../rest/networks/queryNamedTraceConfigurations.js`),import(`../rest/networks/support/QueryNamedTraceConfigurationsParameters.js`)]);return(await n(this.networkServiceUrl,r.from(e),{...t}))?.namedTraceConfigurations}async validateTopology(e,t){if(!e.validateArea)throw new r(`network:undefined-validateArea`,`the network must have validateArea defined in the validate network topology parameters.`);let[{validateNetworkTopology:n},{default:i}]=await Promise.all([import(`../rest/networks/validateNetworkTopology.js`),import(`../rest/networks/support/ValidateNetworkTopologyParameters.js`)]),a=i.from(e);b(this.featureServiceUrl,this.gdbVersion||null)?(a.sessionID=x,await S(this.featureServiceUrl,this.gdbVersion,!0)):a.sessionID=null,a.gdbVersion=this.gdbVersion;let o=this.networkServiceUrl,s=this.featureServiceUrl,c=_(s,null,this.gdbVersion,!0),l=await n(o,a,{...t});if(l?.serviceEdits){let e=[];for(let t of l.serviceEdits){let{editedFeatures:n}=t,r=n?.spatialReference?new d(n.spatialReference):null;e.push({layerId:t.layerId,editedFeatures:{adds:n?.adds?.map(e=>E(e,r))||[],updates:n?.updates?.map(e=>({original:E(e[0],r),current:E(e[1],r)}))||[],deletes:n?.deletes?.map(e=>E(e,r))||[],spatialReference:r}})}c.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],editedFeatures:e,exceededTransferLimit:!1,historicMoment:l.moment})}return l}async submitTopologyValidationJob(e,t){let n=null;if(!e.validateArea)throw new r(`network:undefined-validateArea`,`the network must have validateArea defined in the validate network topology parameters.`);if(!this.gdbVersion){let e=this.layerUrl.replace(/\/FeatureServer/i,`/VersionManagementServer`).replace(/\/\d*$/,``);n=(await y(e,{responseType:`json`,query:{f:`json`}})).data.defaultVersionName}let[{submitValidateNetworkTopologyJob:i},{default:a}]=await Promise.all([import(`../rest/networks/validateNetworkTopology.js`),import(`../rest/networks/support/ValidateNetworkTopologyParameters.js`)]),o=a.from(e);b(this.featureServiceUrl,this.gdbVersion||null)?(o.sessionID=x,await S(this.featureServiceUrl,this.gdbVersion,!0)):o.sessionID=null,o.gdbVersion=this.gdbVersion||n;let s=this.networkServiceUrl,c=this.featureServiceUrl?_(this.featureServiceUrl,null,this.gdbVersion,!0):void 0,l=await i(s,o,{...t});return new C({statusUrl:l,editsResolver:c})}getSourceTypeById(e){if(!this.dataElement)return null;for(let t of this.dataElement.domainNetworks)for(let n of[t.edgeSources??[],t.junctionSources??[]])for(let r of n)if(r.sourceId===e)return n===t.edgeSources?`edge`:`junction`;return null}_traverseNetworkSources(e,t,n,r,i){for(let a of e)for(let e of[a.edgeSources??[],a.junctionSources??[]])for(let a of e)if(a[n]===i)return t.set(i,a[r]),a[r];return-1}async _fetchLayerMetaData(e,t){let{data:n}=await y(e,{responseType:`json`,query:{f:`json`},...t});this.sourceJSON=n,this.read(n,{origin:`service`})}async _fetchDataElement(e,t,n){if(this.dataElement)return;let i=(await y(`${e}/queryDataElements`,{responseType:`json`,query:{layers:JSON.stringify([t]),f:`json`},...n})).data.layerDataElements?.[0];if(!(i&&typeof i==`object`&&`dataElement`in i&&i.dataElement&&typeof i.dataElement==`object`))throw new r(`network:invalid-data-element`,`No data element was found for layer ${t}.`);this.read(i,{origin:`service`})}};e([t({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}}},read:!1}})],T.prototype,`id`,void 0),e([t({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}},service:{read:{source:`name`}}},read:!1}})],T.prototype,`title`,void 0),e([t({type:String,nonNullable:!0,json:{origins:{"web-map":{read:{source:`url`},write:{target:`url`,isRequired:!0}}},read:!1}})],T.prototype,`layerUrl`,void 0),e([t({type:Object,json:{origins:{service:{read:!0}},read:!1}})],T.prototype,`dataElement`,void 0),e([t({type:u,json:{origins:{service:{read:{source:`extent`}}},read:!1}})],T.prototype,`fullExtent`,void 0),e([t({type:d,json:{origins:{service:{read:{source:`extent.spatialReference`}}},read:!1}})],T.prototype,`spatialReference`,void 0),e([t({type:[`utility`,`trace`],readOnly:!0,json:{read:!1,write:!1}})],T.prototype,`type`,void 0),e([t({readOnly:!0})],T.prototype,`datasetName`,null),e([t({readOnly:!0})],T.prototype,`owner`,null),e([t({readOnly:!0})],T.prototype,`schemaGeneration`,null),e([t({readOnly:!0})],T.prototype,`parsedUrl`,null),e([t({readOnly:!0})],T.prototype,`featureServiceUrl`,null),e([t({readOnly:!0})],T.prototype,`networkServiceUrl`,null),e([t({readOnly:!0})],T.prototype,`layerId`,null),e([t()],T.prototype,`sourceJSON`,void 0),e([t({readOnly:!0})],T.prototype,`networkSystemLayers`,null),e([t({type:String})],T.prototype,`gdbVersion`,null),e([t({type:Date})],T.prototype,`historicMoment`,null),e([t()],T.prototype,`_historicMoment`,void 0),e([t()],T.prototype,`_gdbVersion`,void 0),T=e([n(`esri.networks.Network`)],T);function E(e,t){return new p({attributes:e.attributes,geometry:f({...e.geometry,spatialReference:t})})}export{T as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../core/accessorSupport/decorators.js";import r from"../core/Error.js";import{Loadable as i}from"../core/Loadable.js";import a from"../core/Logger.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{isAbortError as s}from"../core/promiseUtils.js";import{urlToObject as c}from"../core/urlUtils.js";import{generateUUID as l}from"../core/uuid.js";import u from"../geometry/Extent.js";import d from"../geometry/SpatialReference.js";import{fromJSON as f}from"../geometry/support/jsonUtils.js";import p from"../Graphic.js";import{versionMatches as m,onApplyEditsEvent as h,onUpdateMomentEvent as g,emitApplyEditsEvent as _}from"../layers/mixins/EditBusLayer.js";import{parse as v}from"../layers/support/arcgisLayerUrl.js";import y from"../request.js";import{isVersionInEditSession as b,currentSessionId as x,isSafeToEditVersion as S}from"../versionManagement/support/versionManagementUtils.js";import C from"./support/TopologyValidationJobInfo.js";import{networkFromPortalItem as w}from"./support/utils.js";let T=class extends o(i){static fromPortalItem(e){return w(e)}constructor(e){super(e),this.id=l(),this.title=null,this.layerUrl=null,this.dataElement=null,this.fullExtent=null,this.spatialReference=null,this.type=null,this.sourceJSON=null,this._historicMoment=null,this._gdbVersion=null,this._sourceIdByLayerId=new Map,this._layerIdBySourceId=new Map,this._applyEditsHandler=e=>{let{serviceUrl:t,gdbVersion:n,result:r}=e,i=t===this.featureServiceUrl,a=m(t,n,this.gdbVersion);i&&a&&r.then(e=>{b(t,n)&&(this.historicMoment=e.historicMoment)},()=>{})},this._updateMomentHandler=e=>{let{serviceUrl:t,gdbVersion:n,moment:r}=e,i=t===this.featureServiceUrl,a=m(t,n,this.gdbVersion);i&&a&&(this.historicMoment=r)},this.when().then(()=>{this.addHandles([h(this._applyEditsHandler),g(this._updateMomentHandler)])},()=>{})}initialize(){this.when().catch(e=>{s(e)||a.getLogger(this).error(`#load()`,`Failed to load layer (title: '${this.title??`no title`}', id: '${this.id??`no id`}')`,{error:e})})}get loaded(){return super.loaded}get datasetName(){return this.dataElement?.name??null}get owner(){return this.dataElement?.userIdentity??null}get schemaGeneration(){return this.dataElement?.schemaGeneration??null}get parsedUrl(){return c(this.layerUrl)}get featureServiceUrl(){return v(this.parsedUrl.path).url.path}get networkServiceUrl(){return this.featureServiceUrl.replace(/\/FeatureServer/i,`/UtilityNetworkServer`)}get layerId(){return v(this.parsedUrl.path).sublayer}get networkSystemLayers(){return null}get gdbVersion(){return this._gdbVersion}set gdbVersion(e){this._gdbVersion=e}get historicMoment(){return this._historicMoment}set historicMoment(e){this._historicMoment=e}async load(e){return this.addResolvingPromise(this._load(e)),this}async _load(e){await Promise.all([this._fetchDataElement(this.featureServiceUrl,this.layerId.toString(),e),this._fetchLayerMetaData(this.layerUrl,e)])}getLayerIdBySourceId(e){if(!this.dataElement)return null;let t=this._layerIdBySourceId.get(e);if(t!=null)return t;let n=this.dataElement.domainNetworks,r=this._traverseNetworkSources(n,this._layerIdBySourceId,`sourceId`,`layerId`,e);return r>=0?r:null}getSourceIdByLayerId(e){if(!this.dataElement)return null;let t=this._sourceIdByLayerId.get(e);if(t!=null)return t;let n=this.dataElement.domainNetworks,r=this._traverseNetworkSources(n,this._sourceIdByLayerId,`layerId`,`sourceId`,e);return r>=0?r:null}getObjectIdsFromElements(e){let t=[],n=new Map;for(let t of e){let e=this.getLayerIdBySourceId(t.networkSourceId);if(e==null)continue;let r=n.get(e);r===void 0&&(r=[]),r.push(t.objectId),n.set(e,r)}let r=this.featureServiceUrl;return n.forEach((e,n)=>t.push({layerUrl:`${r}/${n}`,objectIds:e})),t}async queryNamedTraceConfigurations(e,t){let[{queryNamedTraceConfigurations:n},{default:r}]=await Promise.all([import(`../rest/networks/queryNamedTraceConfigurations.js`),import(`../rest/networks/support/QueryNamedTraceConfigurationsParameters.js`)]);return(await n(this.networkServiceUrl,r.from(e),{...t}))?.namedTraceConfigurations}async validateTopology(e,t){if(!e.validateArea)throw new r(`network:undefined-validateArea`,`the network must have validateArea defined in the validate network topology parameters.`);let[{validateNetworkTopology:n},{default:i}]=await Promise.all([import(`../rest/networks/validateNetworkTopology.js`),import(`../rest/networks/support/ValidateNetworkTopologyParameters.js`)]),a=i.from(e);b(this.featureServiceUrl,this.gdbVersion||null)?(a.sessionID=x,await S(this.featureServiceUrl,this.gdbVersion,!0)):a.sessionID=null,a.gdbVersion=this.gdbVersion;let o=this.networkServiceUrl,s=this.featureServiceUrl,c=_(s,null,this.gdbVersion,!0),l=await n(o,a,{...t});if(l?.serviceEdits){let e=[];for(let t of l.serviceEdits){let{editedFeatures:n}=t,r=n?.spatialReference?new d(n.spatialReference):null;e.push({layerId:t.layerId,editedFeatures:{adds:n?.adds?.map(e=>E(e,r))||[],updates:n?.updates?.map(e=>({original:E(e[0],r),current:E(e[1],r)}))||[],deletes:n?.deletes?.map(e=>E(e,r))||[],spatialReference:r}})}c.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],editedFeatures:e,exceededTransferLimit:!1,historicMoment:l.moment})}return l}async submitTopologyValidationJob(e,t){let n=null;if(!e.validateArea)throw new r(`network:undefined-validateArea`,`the network must have validateArea defined in the validate network topology parameters.`);if(!this.gdbVersion){let e=this.layerUrl.replace(/\/FeatureServer/i,`/VersionManagementServer`).replace(/\/\d*$/,``);n=(await y(e,{responseType:`json`,query:{f:`json`}})).data.defaultVersionName}let[{submitValidateNetworkTopologyJob:i},{default:a}]=await Promise.all([import(`../rest/networks/validateNetworkTopology.js`),import(`../rest/networks/support/ValidateNetworkTopologyParameters.js`)]),o=a.from(e);b(this.featureServiceUrl,this.gdbVersion||null)?(o.sessionID=x,await S(this.featureServiceUrl,this.gdbVersion,!0)):o.sessionID=null,o.gdbVersion=this.gdbVersion||n;let s=this.networkServiceUrl,c=this.featureServiceUrl?_(this.featureServiceUrl,null,this.gdbVersion,!0):void 0,l=await i(s,o,{...t});return new C({statusUrl:l,editsResolver:c})}getSourceTypeById(e){if(!this.dataElement)return null;for(let t of this.dataElement.domainNetworks)for(let n of[t.edgeSources??[],t.junctionSources??[]])for(let r of n)if(r.sourceId===e)return n===t.edgeSources?`edge`:`junction`;return null}_traverseNetworkSources(e,t,n,r,i){for(let a of e)for(let e of[a.edgeSources??[],a.junctionSources??[]])for(let a of e)if(a[n]===i)return t.set(i,a[r]),a[r];return-1}async _fetchLayerMetaData(e,t){let{data:n}=await y(e,{responseType:`json`,query:{f:`json`},...t});this.sourceJSON=n,this.read(n,{origin:`service`})}async _fetchDataElement(e,t,n){if(this.dataElement)return;let i=(await y(`${e}/queryDataElements`,{responseType:`json`,query:{layers:JSON.stringify([t]),f:`json`},...n})).data.layerDataElements?.[0];if(!(i&&typeof i==`object`&&`dataElement`in i&&i.dataElement&&typeof i.dataElement==`object`))throw new r(`network:invalid-data-element`,`No data element was found for layer ${t}.`);this.read(i,{origin:`service`})}};e([t({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}}},read:!1}})],T.prototype,`id`,void 0),e([t({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}},service:{read:{source:`name`}}},read:!1}})],T.prototype,`title`,void 0),e([t({type:String,nonNullable:!0,json:{origins:{"web-map":{read:{source:`url`},write:{target:`url`,isRequired:!0}}},read:!1}})],T.prototype,`layerUrl`,void 0),e([t({type:Object,json:{origins:{service:{read:!0}},read:!1}})],T.prototype,`dataElement`,void 0),e([t({type:u,json:{origins:{service:{read:{source:`extent`}}},read:!1}})],T.prototype,`fullExtent`,void 0),e([t({type:d,json:{origins:{service:{read:{source:`extent.spatialReference`}}},read:!1}})],T.prototype,`spatialReference`,void 0),e([t({type:[`utility`,`trace`],readOnly:!0,json:{read:!1,write:!1}})],T.prototype,`type`,void 0),e([t({readOnly:!0})],T.prototype,`datasetName`,null),e([t({readOnly:!0})],T.prototype,`owner`,null),e([t({readOnly:!0})],T.prototype,`schemaGeneration`,null),e([t({readOnly:!0})],T.prototype,`parsedUrl`,null),e([t({readOnly:!0})],T.prototype,`featureServiceUrl`,null),e([t({readOnly:!0})],T.prototype,`networkServiceUrl`,null),e([t({readOnly:!0})],T.prototype,`layerId`,null),e([t()],T.prototype,`sourceJSON`,void 0),e([t({readOnly:!0})],T.prototype,`networkSystemLayers`,null),e([t({type:String})],T.prototype,`gdbVersion`,null),e([t({type:Date})],T.prototype,`historicMoment`,null),e([t()],T.prototype,`_historicMoment`,void 0),e([t()],T.prototype,`_gdbVersion`,void 0),T=e([n(`esri.networks.Network`)],T);function E(e,t){return new p({attributes:e.attributes,geometry:f({...e.geometry,spatialReference:t})})}export{T as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import{strict as r}from"../../core/jsonMap.js";import{createAbortError as i}from"../../core/promiseUtils.js";import a from"../../request.js";import o from"../../rest/networks/support/ValidateNetworkTopologyResult.js";import{enumeration as s}from"../../core/accessorSupport/decorators/enumeration.js";const c=r()({Pending:`job-waiting`,InProgress:`job-executing`,Completed:`job-succeeded`});let l=class extends o{constructor(e){super(e),this.statusUrl=null,this.status=null,this.submissionTime=null,this.lastUpdatedTime=null,this._timer=void 0}destroy(){clearInterval(this._timer)}async checkJobStatus(e){let t={...e,query:{f:`json`}},{data:n}=await a(this.statusUrl,t);return this.read(n),this.editsResolver&&this.editsResolver.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:!0,historicMoment:null}),this}async waitForJobCompletion(e={}){let{interval:t=1e3,statusCallback:n}=e;return new Promise((e,r)=>{this._clearTimer();let a=setInterval(()=>{this._timer||r(i()),this.checkJobStatus().then(t=>{let{status:r}=t;switch(this.status=r,r){case`job-succeeded`:this._clearTimer(),e(this);break;case`job-waiting`:case`job-executing`:n&&n(this)}},e=>{this._clearTimer(),r(e)})},t);this._timer=a})}_clearTimer(){clearInterval(this._timer),this._timer=void 0}};e([t()],l.prototype,`editsResolver`,void 0),e([t({type:String,json:{write:!0}})],l.prototype,`statusUrl`,void 0),e([s(c)],l.prototype,`status`,void 0),e([t({type:Date,json:{type:Number,write:{writer:(e,t)=>{t.submissionTime=e?e.getTime():null}}}})],l.prototype,`submissionTime`,void 0),e([t({type:Date,json:{type:Number,write:{writer:(e,t)=>{t.lastUpdatedTime=e?e.getTime():null}}}})],l.prototype,`lastUpdatedTime`,void 0),l=e([n(`esri.networks.support.TopologyValidationJobInfo`)],l);export{l as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import{strict as r}from"../../core/jsonMap.js";import{createAbortError as i}from"../../core/promiseUtils.js";import a from"../../request.js";import o from"../../rest/networks/support/ValidateNetworkTopologyResult.js";import{enumeration as s}from"../../core/accessorSupport/decorators/enumeration.js";const c=r()({Pending:`job-waiting`,InProgress:`job-executing`,Completed:`job-succeeded`});let l=class extends o{constructor(e){super(e),this.statusUrl=null,this.status=null,this.submissionTime=null,this.lastUpdatedTime=null,this._timer=void 0}destroy(){clearInterval(this._timer)}async checkJobStatus(e){let t={...e,query:{f:`json`}},{data:n}=await a(this.statusUrl,t).catch(e=>{throw typeof e?.details?.raw?.extendedCode==`number`&&this.editsResolver?.reject(e),e});return this.read(n),this.editsResolver&&this.status===`job-succeeded`&&this.editsResolver.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:!0,historicMoment:null}),this}async waitForJobCompletion(e={}){let{interval:t=1e3,statusCallback:n}=e;return new Promise((e,r)=>{this._clearTimer();let a=setInterval(()=>{this._timer||r(i()),this.checkJobStatus().then(t=>{let{status:r}=t;switch(this.status=r,r){case`job-succeeded`:this._clearTimer(),e(this);break;case`job-waiting`:case`job-executing`:n&&n(this)}},e=>{this._clearTimer(),r(e)})},t);this._timer=a})}_clearTimer(){clearInterval(this._timer),this._timer=void 0}};e([t()],l.prototype,`editsResolver`,void 0),e([t({type:String,json:{write:!0}})],l.prototype,`statusUrl`,void 0),e([s(c)],l.prototype,`status`,void 0),e([t({type:Date,json:{type:Number,write:{writer:(e,t)=>{t.submissionTime=e?e.getTime():null}}}})],l.prototype,`submissionTime`,void 0),e([t({type:Date,json:{type:Number,write:{writer:(e,t)=>{t.lastUpdatedTime=e?e.getTime():null}}}})],l.prototype,`lastUpdatedTime`,void 0),l=e([n(`esri.networks.support.TopologyValidationJobInfo`)],l);export{l as default};
|