@arcgis/core 4.24.1 → 4.24.4
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/{1872276fb7f434c41c09.js → 1d6f79eae87228ba21c9.js} +1 -1
- package/assets/esri/core/workers/chunks/{dd51b8f77fd9472c2e54.js → 48576ac3dd2efaa25141.js} +1 -1
- package/assets/esri/core/workers/chunks/{b780228a520e1a0b100b.js → 8706454ab4002d4b60f6.js} +1 -1
- package/assets/esri/core/workers/chunks/{de5c5c216a804becdaf6.js → a68428fde8bc960da276.js} +1 -1
- package/assets/esri/core/workers/chunks/{ed1bb19480397d388fe9.js → d1bc85b78d6f217b022a.js} +1 -1
- package/assets/esri/themes/base/widgets/_Editor.scss +6 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/BlendLayers.glsl.js +4 -4
- package/config.js +1 -1
- package/interfaces.d.ts +68 -2
- package/layers/support/FeatureReductionBinning.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/previewSymbol2D.js +1 -1
- package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/tileUtils.js +1 -1
- package/views/webgl/context-util.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/InputField.js +1 -1
- package/widgets/FeatureForm/InputFieldGroup.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import o from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as L}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as b}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as x}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as P}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as C}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as R,projectPointToVector as j}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as I,intersection as V,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as N,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as q}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as F}from"../../../layers/support/LercDecoder.js";import{printAllocations as H}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Q,scaleToZoom as X}from"../support/cameraUtils.js";import z from"../support/debugFlags.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{ClientType as $}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{sampleElevation as Z,ElevationData as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{LODSnapping as ie,TextureUpdate as re}from"./interfaces.js";import{LayerClass as se,LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{MAX_ROOT_TILES as de,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as pe,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ue,MAX_MEMORY_LOD_BIAS as ce,ELEVATION_NODATA_VALUE as _e}from"./TerrainConst.js";import ge from"./TerrainRenderer.js";import me from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as fe,internalAssert as Te,isSurfaceLayerView as ye,isMapTileLayerView as ve,isBlendableLayerView as we,isGroupLayer as Le,isElevationLayerView as Se,isVectorTileLayerView as Ee,useFetchTileForLayer as be,isImageryTileLayerView as De,isTileLayerView as xe,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as Pe}from"./terrainUtils.js";import{SplitLimits as Ce,Tile as Re}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Me}from"./TileUpdate.js";import{IteratorPreorder as Ae,IteratorPostorder as Ie,hasLoadableSiblings as Ve,sortTilesByPOI as Oe,sortTiles as Ne}from"./tileUtils.js";import{TilingSchemeLogic as ke}from"./TilingSchemeLogic.js";import{UpsampleInfo as Be}from"./UpsampleInfo.js";import{isCompositeBlendMode as qe,blendModeFromString as Ge}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as We}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Fe,TaskPriority as He,noBudget as Qe}from"../../support/Scheduler.js";const Xe=o.getLogger("esri.views.3d.terrain.TerrainSurface"),ze=.25;let Ye=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new J,this._iteratorPool=new c(Ae,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ie,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=null,this._performanceInfo=new me,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Ce,this._snapLevel=1/0,this._frustum=N(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new C,this._frameTask=Fe,this._allTiles=new _,this._upsampleInfoPool=new c(Be),this._rootTilesExtent=A(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=F(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(he);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._set("overlayManager",new ne({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new ge({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:M(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>z.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&z.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=te(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new ke({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester($.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester($.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(He.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this.lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Re.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),H(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=Q(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=X(this.view,e)-r;Math.abs(this._snapLevel-s)>ze&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ie.ON:ie.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=A(),r=Y(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,A()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,et);return p(s)?null:Z(et[0],et[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=et){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[se.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!R(s,r,s,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(et)){for(;!e.isLeaf&&!e.rendered;){let t=0;et[0]>e.children[0].extent[2]&&(t+=1),et[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(et[0]=e,et[1]=t,et[2]=i,et[3]=r,!R(et,s,et,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},l=this.rootTiles;if(u(l))for(const h of l)o(h);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;et[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this.lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?re.UNFADED:re.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(fe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return it[0]=e,it[1]=t,it[2]=i,s.init(it,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=tt;let s=t.rootTilesInExtent(e,i,5*de);if(u(this.rootTiles)){if(s.length>de)return void Xe.warn(pe);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ke(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>de&&(Xe.warn(ue),s=t.rootTilesInExtent(e,i,de)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=A(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&t.setPendingUpdate(Me.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Ve(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.extent,a=this._viewProjectionMatrix;this.setTileTreeDirty();const n=this._iteratorPool.acquire();for(n.reset(e);!n.done;){const e=n.next();e.updateClippingStatus(s)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Me.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(a),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))}n.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this.lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=N()),k(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,k(this._frustum,e.frustum),b(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),x(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Je(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):Ze(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Me.TEXTURE_FADING)?Me.TEXTURE_FADING:!!e.resetPendingUpdate(Me.TEXTURE_NOFADING)&&Me.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){st.spatialReference=this.spatialReference,st.tile=e,st.extent=e.extent,this.emit("elevation-change",st)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==Me.SPLIT){if(e.resetPendingUpdate(Me.SPLIT)&&e.updateAgentSuspension(),i===Me.VSPLITMERGE&&e.updateAgents(se.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Me.MERGE),e.resetPendingUpdate(Me.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(Me.MERGE),e.isLeaf&&(e.setPendingUpdate(Me.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Oe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){Te(0===this.neighborTilesToUpdate.size),this.deferTileNeighborUpdate=!0}_batchUpdateUpdatedTileNeighbors(){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;if(r.resetPendingUpdate(Me.MERGE)){if(!t)return r.setPendingUpdate(Me.MERGE),e.done;this._mergeTile(r),s=!0,e.madeProgress()}else r.resetPendingUpdate(Me.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&r.resetPendingUpdate(Me.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Me.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(We.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this.lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){fe(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Me.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){at.spatialReference=this.spatialReference,at.extent=e.extent,at.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",at)}_createTile(e,t,i,r){fe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&s.setPendingUpdate(Me.SPLIT),s}_mergeTile(e){fe(!e.hasPendingUpdate(Me.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(fe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Pe&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),fe(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e))}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Me.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,se.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Qe){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),ye(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ve(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(we(e)){const t=Le(e.layer.parent)?"normal":e.layer.blendMode;if(qe(Ge[t]))return!0}return!1}_layerClassFromLayerView(e){return Se(e)?se.ELEVATION:se.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(re.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),we(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(re.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!ye(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===se.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),o=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const l=e.indexOf(i[t]);n[t]=l,t!==l&&(a=!0),l>-1&&(o[l]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(o,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===se.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(se.MAP),e===re.IMMEDIATE?this.renderer.updateTileTexture(t,Me.TEXTURE_NOFADING):t.updateRenderData(se.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=We.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Ee(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===se.ELEVATION?Se(i)?this._requestElevationTileData(e,i,r):Promise.reject():ve(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[se.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):Xe.warn("TerrainSurface: received data from unknown layer %d %s",se.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,se.ELEVATION,t,i),this.requestUpdate())};if(be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:_e,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:_e},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,se.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Ee(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(De(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(xe(t)&&be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);q(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const l=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,l,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(se.MAP,t.uid);u(r)?e.dataArrived(r,se.MAP,i):(Ue(i),Xe.warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):Xe.warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return fe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){rt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&rt.push(e)}));const t=rt.toArray();return Ne(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Pe)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&B(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}};e([S()],Ye.prototype,"_renderer",void 0),e([S()],Ye.prototype,"_hasPendingUpdates",void 0),e([S()],Ye.prototype,"_asyncWorkItems",void 0),e([S()],Ye.prototype,"_allTilesDirty",void 0),e([S()],Ye.prototype,"_allTilesSorted",void 0),e([S()],Ye.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],Ye.prototype,"_watchUpdatingTracking",void 0),e([S()],Ye.prototype,"_frameTask",void 0),e([S({readOnly:!0})],Ye.prototype,"snapLevel",null),e([S({readOnly:!0})],Ye.prototype,"lodSnapping",null),e([S({constructOnly:!0})],Ye.prototype,"view",void 0),e([S()],Ye.prototype,"_userClippingExtent",null),e([S()],Ye.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],Ye.prototype,"extent",null),e([S({readOnly:!0})],Ye.prototype,"groundExtent",null),e([S({readOnly:!0})],Ye.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],Ye.prototype,"updating",null),e([S(K)],Ye.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],Ye.prototype,"updatingProgressValue",null),e([S()],Ye.prototype,"_maxNumUpdating",void 0),e([S({aliasOf:"view.map.ground.opacity"})],Ye.prototype,"baseOpacity",void 0),e([S()],Ye.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],Ye.prototype,"overlayManager",void 0),e([S({readOnly:!0})],Ye.prototype,"viewingMode",null),e([S()],Ye.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],Ye.prototype,"ready",null),e([S({value:le.FRONT_TO_BACK})],Ye.prototype,"renderOrder",null),e([S({readOnly:!0})],Ye.prototype,"rootTiles",void 0),e([S({readOnly:!0})],Ye.prototype,"spatialReference",null),e([S({type:t,aliasOf:"view.map.ground.surfaceColor"})],Ye.prototype,"backgroundColor",void 0),e([S({value:!1})],Ye.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],Ye.prototype,"tilingScheme",void 0),e([S({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Ye.prototype,"tilingSchemeLocked",void 0),e([S({readOnly:!0})],Ye.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],Ye.prototype,"velvetOverground",null),e([L("_renderer.wireframe")],Ye.prototype,"wireframe",void 0),e([S({value:!1})],Ye.prototype,"suspended",null),e([S({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Ye.prototype,"textureFadeDuration",void 0),e([S()],Ye.prototype,"_layerViewsDirty",void 0),e([L("_renderer.renderPatchBorders")],Ye.prototype,"renderPatchBorders",void 0),e([L("_renderer.renderingDisabled")],Ye.prototype,"renderingDisabled",void 0),Ye=e([E("esri.views.3d.terrain.TerrainSurface")],Ye);const $e=Ye;function Ke(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Je(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Je(e))))}function Ze(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const et=P(),tt=A(),it=[0,0,0],rt=new _,st={spatialReference:null,tile:null,extent:null,context:"ground"},at={spatialReference:null,extent:null,scale:0};export{$e as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import o from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as L}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import{m as E}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as x}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as C}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as P}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as R,projectPointToVector as j}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as I,intersection as V,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as N,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as q}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as F}from"../../../layers/support/LercDecoder.js";import{printAllocations as H}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Q,scaleToZoom as X}from"../support/cameraUtils.js";import z from"../support/debugFlags.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{ClientType as $}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{sampleElevation as Z,ElevationData as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{LODSnapping as ie,TextureUpdate as re}from"./interfaces.js";import{LayerClass as se,LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{MAX_ROOT_TILES as de,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as pe,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ue,MAX_MEMORY_LOD_BIAS as ce,ELEVATION_NODATA_VALUE as _e}from"./TerrainConst.js";import ge from"./TerrainRenderer.js";import me from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as fe,internalAssert as Te,isSurfaceLayerView as ye,isMapTileLayerView as ve,isBlendableLayerView as we,isGroupLayer as Le,isElevationLayerView as Se,isVectorTileLayerView as be,useFetchTileForLayer as Ee,isImageryTileLayerView as De,isTileLayerView as xe,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as Ce}from"./terrainUtils.js";import{SplitLimits as Pe,Tile as Re}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Me}from"./TileUpdate.js";import{IteratorPreorder as Ae,IteratorPostorder as Ie,hasLoadableSiblings as Ve,sortTilesByPOI as Oe,sortTiles as Ne}from"./tileUtils.js";import{TilingSchemeLogic as ke}from"./TilingSchemeLogic.js";import{UpsampleInfo as Be}from"./UpsampleInfo.js";import{isCompositeBlendMode as qe,blendModeFromString as Ge}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as We}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Fe,TaskPriority as He,noBudget as Qe}from"../../support/Scheduler.js";const Xe=o.getLogger("esri.views.3d.terrain.TerrainSurface"),ze=.25;let Ye=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new J,this._iteratorPool=new c(Ae,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ie,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=null,this._performanceInfo=new me,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Pe,this._snapLevel=1/0,this._frustum=N(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new P,this._frameTask=Fe,this._allTiles=new _,this._upsampleInfoPool=new c(Be),this._rootTilesExtent=A(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=F(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(he);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._set("overlayManager",new ne({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new ge({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:M(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>z.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&z.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=te(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new ke({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester($.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester($.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(He.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this.lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Re.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),H(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=Q(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=X(this.view,e)-r;Math.abs(this._snapLevel-s)>ze&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ie.ON:ie.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=A(),r=Y(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,A()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,et);return p(s)?null:Z(et[0],et[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=et){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[se.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!R(s,r,s,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(et)){for(;!e.isLeaf&&!e.rendered;){let t=0;et[0]>e.children[0].extent[2]&&(t+=1),et[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(et[0]=e,et[1]=t,et[2]=i,et[3]=r,!R(et,s,et,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},l=this.rootTiles;if(u(l))for(const h of l)o(h);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;et[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this.lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?re.UNFADED:re.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(fe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return it[0]=e,it[1]=t,it[2]=i,s.init(it,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=tt;let s=t.rootTilesInExtent(e,i,5*de);if(u(this.rootTiles)){if(s.length>de)return void Xe.warn(pe);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ke(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>de&&(Xe.warn(ue),s=t.rootTilesInExtent(e,i,de)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=A(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&t.setPendingUpdate(Me.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Ve(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.view.state.fixedContentCamera,a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const o=this._iteratorPool.acquire();for(o.reset(e);!o.done;){const e=o.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Me.RENDERDATA);const t=e.computeVisibility();s||t?(e.updateScreenDepth(n),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))):o.skipSubtree()}o.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this.lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=N()),k(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,k(this._frustum,e.frustum),E(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),x(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Je(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):Ze(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Me.TEXTURE_FADING)?Me.TEXTURE_FADING:!!e.resetPendingUpdate(Me.TEXTURE_NOFADING)&&Me.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){st.spatialReference=this.spatialReference,st.tile=e,st.extent=e.extent,this.emit("elevation-change",st)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next();if(e.loadable){const i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i===Me.SPLIT){e.resetPendingUpdate(Me.MERGE),e.isLeaf&&(e.setPendingUpdate(Me.SPLIT),t.skipSubtree());continue}e.resetPendingUpdate(Me.SPLIT)&&e.updateAgentSuspension(),i===Me.VSPLITMERGE&&e.updateAgents(se.ELEVATION)}if(t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Me.MERGE),e.resetPendingUpdate(Me.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.loadable&&e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Oe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){Te(0===this.neighborTilesToUpdate.size),this.deferTileNeighborUpdate=!0}_batchUpdateUpdatedTileNeighbors(){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1;for(;!e.done;){i=!0;let r=!1;const s=!this._allTiles.some((i=>{if(i.resetPendingUpdate(Me.MERGE)){if(!t)return i.setPendingUpdate(Me.MERGE),e.done;this._mergeTile(i),r=!0,e.madeProgress()}else i.resetPendingUpdate(Me.SPLIT)&&(this._splitTile(i),r=!0,e.madeProgress());return!e.done&&i.resetPendingUpdate(Me.RENDERDATA)&&(this._updateRenderData(i),e.madeProgress()),e.done}));if(r&&(this._allTilesSorted=!1,this._allTilesDirty=!0),s){if(!r)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}i||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Me.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(We.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this.lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){fe(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Me.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){at.spatialReference=this.spatialReference,at.extent=e.extent,at.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",at)}_createTile(e,t,i,r){fe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.loadable&&(s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&s.setPendingUpdate(Me.SPLIT)),s}_mergeTile(e){fe(!e.hasPendingUpdate(Me.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(fe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Ce&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),fe(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e))}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Me.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,se.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Qe){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),ye(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ve(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(we(e)){const t=Le(e.layer.parent)?"normal":e.layer.blendMode;if(qe(Ge[t]))return!0}return!1}_layerClassFromLayerView(e){return Se(e)?se.ELEVATION:se.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(re.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),we(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(re.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!ye(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===se.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),o=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const l=e.indexOf(i[t]);n[t]=l,t!==l&&(a=!0),l>-1&&(o[l]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(o,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===se.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(se.MAP),e===re.IMMEDIATE?this.renderer.updateTileTexture(t,Me.TEXTURE_NOFADING):t.updateRenderData(se.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=We.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||be(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===se.ELEVATION?Se(i)?this._requestElevationTileData(e,i,r):Promise.reject():ve(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[se.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):Xe.warn("TerrainSurface: received data from unknown layer %d %s",se.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,se.ELEVATION,t,i),this.requestUpdate())};if(Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:_e,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:_e},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,se.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(be(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(De(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(xe(t)&&Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);q(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const l=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,l,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(se.MAP,t.uid);u(r)?e.dataArrived(r,se.MAP,i):(Ue(i),Xe.warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):Xe.warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return fe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){rt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&rt.push(e)}));const t=rt.toArray();return Ne(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Ce)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&B(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}};e([S()],Ye.prototype,"_renderer",void 0),e([S()],Ye.prototype,"_hasPendingUpdates",void 0),e([S()],Ye.prototype,"_asyncWorkItems",void 0),e([S()],Ye.prototype,"_allTilesDirty",void 0),e([S()],Ye.prototype,"_allTilesSorted",void 0),e([S()],Ye.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],Ye.prototype,"_watchUpdatingTracking",void 0),e([S()],Ye.prototype,"_frameTask",void 0),e([S({readOnly:!0})],Ye.prototype,"snapLevel",null),e([S({readOnly:!0})],Ye.prototype,"lodSnapping",null),e([S({constructOnly:!0})],Ye.prototype,"view",void 0),e([S()],Ye.prototype,"_userClippingExtent",null),e([S()],Ye.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],Ye.prototype,"extent",null),e([S({readOnly:!0})],Ye.prototype,"groundExtent",null),e([S({readOnly:!0})],Ye.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],Ye.prototype,"updating",null),e([S(K)],Ye.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],Ye.prototype,"updatingProgressValue",null),e([S()],Ye.prototype,"_maxNumUpdating",void 0),e([S({aliasOf:"view.map.ground.opacity"})],Ye.prototype,"baseOpacity",void 0),e([S()],Ye.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],Ye.prototype,"overlayManager",void 0),e([S({readOnly:!0})],Ye.prototype,"viewingMode",null),e([S()],Ye.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],Ye.prototype,"ready",null),e([S({value:le.FRONT_TO_BACK})],Ye.prototype,"renderOrder",null),e([S({readOnly:!0})],Ye.prototype,"rootTiles",void 0),e([S({readOnly:!0})],Ye.prototype,"spatialReference",null),e([S({type:t,aliasOf:"view.map.ground.surfaceColor"})],Ye.prototype,"backgroundColor",void 0),e([S({value:!1})],Ye.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],Ye.prototype,"tilingScheme",void 0),e([S({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Ye.prototype,"tilingSchemeLocked",void 0),e([S({readOnly:!0})],Ye.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],Ye.prototype,"velvetOverground",null),e([L("_renderer.wireframe")],Ye.prototype,"wireframe",void 0),e([S({value:!1})],Ye.prototype,"suspended",null),e([S({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Ye.prototype,"textureFadeDuration",void 0),e([S()],Ye.prototype,"_layerViewsDirty",void 0),e([L("_renderer.renderPatchBorders")],Ye.prototype,"renderPatchBorders",void 0),e([L("_renderer.renderingDisabled")],Ye.prototype,"renderingDisabled",void 0),Ye=e([b("esri.views.3d.terrain.TerrainSurface")],Ye);const $e=Ye;function Ke(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Je(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Je(e))))}function Ze(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const et=C(),tt=A(),it=[0,0,0],rt=new _,st={spatialReference:null,tile:null,extent:null,context:"ground"},at={spatialReference:null,extent:null,scale:0};export{$e as default};
|
package/views/3d/terrain/Tile.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../core/mathUtils.js";import{isNone as t,isSome as i,abortMaybe as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as h,p as l,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{E as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as y}from"../../../geometry/support/aaBoundingRect.js";import{c as E}from"../../../chunks/sphere.js";import{VectorTile as v}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as T}from"../support/StreamDataLoader.js";import{ElevationBounds as L}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{LODSnapping as I,TextureUpdate as D,NeighborIndex as N}from"./interfaces.js";import{LayerClass as b,LayerClasses as S}from"./LayerClass.js";import{MapTileAgent as x}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as O,getElevationDesiredResolutionLevel as U}from"./TerrainConst.js";import{weakAssert as C,getLayerWithExtentRange as R,isBlendableLayerView as P,oppositeCorner as B,neighborCornerIndices as G,neighborEdgeIndices as V,oppositeEdge as W,internalAssert as w,isNorth as q,isSouth as H,isWest as F,isEast as k,ENABLE_WATERPROOFNESS_TESTS as X,isWestCorner as z,isNorthCorner as J}from"./terrainUtils.js";import{TILE_AGENT_DONE as Y}from"./TileAgent.js";import{TilePerLayerInfo as $}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";import{getGpuMemoryUsage as ee}from"../../webgl/Util.js";const te=f(),ie=f(),se=f(),ne=.1;class re{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class ae{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=A(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=A(),this.centerAtSeaLevel=f(),this._center=[f(),E(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemory=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){le.prune(0),de.prune(0),$.prune()}get usedMemory(){return t(this._usedMemory)&&this._updateMemoryUsed(),i(this._usedMemory)?this._usedMemory:0+(this.isCached?0:this.mapTileMemory)}get cachedMemory(){return this.isCached?this.mapTileMemory:0}get mapTileMemory(){t(this._usedMemory)&&this._updateMemoryUsed();let e=this._mapTileMemory;for(const{data:t}of this.layerInfo[b.MAP])t instanceof v&&(e+=t.memoryUsage);return e}get isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ce.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setNeedsRender(),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setNeedsRender()),e}get shouldLoad(){if(this._surface.lodSnapping===I.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ce.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of S){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=$.acquire(this._surface.upsampleInfoPool),s===b.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,O)}release(){C(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of S){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this._usedMemory=null}refMapData(){++this._mapDataRefCount,this.isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this.isCached){const e=this.cachedMemory;e>0&&(this._surface.upsampleMapCache.put(this.key,this,e),this.setMemoryDirty())}}setMemoryDirty(){this._usedMemory=null}get cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_updateMemoryUsed(){this._usedMemory=0,this._mapTileMemory=0;const e=this.layerInfo[b.MAP];for(let i=0;i<e.length;i++)this._mapTileMemory+=this.getUsedMemoryForLayer(b.MAP,i);const t=this.cpuImageMemorySize;for(const i of this.layerInfo[b.ELEVATION])this._usedMemory+=i.data?t:0;this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemory+=ee(this.renderData.textureDescriptor)),this.isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this.cachedMemory)}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];if(!i||!i.data)return 0;if(e!==b.MAP||this.isCached){if(e===b.ELEVATION)return this.cpuImageMemorySize}else{const e=i.data;if(e instanceof Q)return ee(e.texture);if(e instanceof HTMLImageElement||e instanceof T)return this.cpuImageMemorySize;if(e instanceof v||e instanceof j)return e.memoryUsage}return 0}updateScreenDepth(e){const t=this._center[ce.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,s){if(i(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return K.NONE;const n=this.level;h(te,this._center[ce.MIDDLE],t);let r=l(te),a=ce.MIDDLE;h(ie,this._center[ce.TOP],t);const o=l(ie);o<r&&(r=o,a=ce.TOP),h(ie,this._center[ce.BOTTOM],t);const f=l(ie);if(f<r&&(r=f,a=ce.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return K.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,A=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,K.VSPLITMERGE):K.NONE_HIT_MAXLOD};if(s===I.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?A():K.SPLIT}const y=d(this.up,te),E=this._elevationBounds[1]-this._elevationBounds[0],v=E/this.edgeLen;if(e.aboveGround&&y>0&&v<.001){if(y/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-v>0)return K.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,K.VSPLITMERGE):K.NONE;if(n>=e.maxLod)return A();if(n>6){h(ie,this._center[a],t),u(se,this.up,y),h(se,se,ie);const i=l(se);if(i>this.radius*this.radius){u(se,se,this.radius/Math.sqrt(i)),c(se,se,this._center[a]),h(se,t,se);const s=Math.min(1,(Math.abs(d(se,this.up))+.5*E+this._curvatureHeight)/g(se)),n=ne/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return K.NONE}}return K.SPLIT}setChildren(e,t,i,s){C(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}prepareToLoad(e){this.refMapData();for(const t of S)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of S){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[b.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(y(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,s=this._isWithinClippingArea;i(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of S){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Y&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==b.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,i){const n=this.layerInfo[t][e];if(n.waitingAgents.has(i))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),i.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(i),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),i.tile.lij.toString(),t,e),i.dataArrived(this),!0;if(n.requestPromise)return!0;s(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return l(h(se,this._center[ce.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);C(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this._updateMemoryUsed())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this._updateMemoryUsed()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this._updateMemoryUsed()}updateRenderData(e,t){switch(e){case b.MAP:return this._updateTexture(t);case b.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===D.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===D.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[b.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const t=this.layerInfo[b.ELEVATION];let s=!0;for(const n of t)i(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(se,this.up,t),c(this._center[ce.MIDDLE],this.centerAtSeaLevel,se),u(se,this.up,e[0]),c(this._center[ce.TOP],this.centerAtSeaLevel,se),u(se,this.up,e[1]),c(this._center[ce.BOTTOM],this.centerAtSeaLevel,se)}findElevationBoundsForLayer(e,s){const n=this.layerInfo[b.ELEVATION][e];if(i(n.elevationBounds)&&n.elevationBounds.level>=s)return;const r=this._surface.layerViewByIndex(e,b.ELEVATION),a=R(r);if(!Z(this,a,!1))return;const o=ue;let h=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,h=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<U(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[b.ELEVATION][e].data,!(!i&&t&&s>=U(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,h=!0))}h&&(t(n.elevationBounds)&&(n.elevationBounds=new L),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Y&&(he(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:$.acquire(this._surface.upsampleInfoPool)}this._updateMemoryUsed()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,D.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Y&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of S){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Y&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Y&&this.updateRenderData(e,D.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Y&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,i){const s=this.layerInfo[i][e];s.loadingAgent=Y,!s.data&&t(s.upsampleInfo)&&this._createOrUpdateAgents(e+1,i)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=(()=>{for(let s=e;s<i.length;++s){const e=this._surface.layerViewByIndex(s,t);if(P(e)&&"normal"!==e.layer.blendMode)return!0}return!1})(),n=this._isSuspended(t);for(let r=e;r<i.length;++r){const e=i[r];let a=!1;const o=this._surface.layerViewByIndex(r,t),h=R(o);if(e.loadingAgent?Z(this,h,!1)?(e.loadingAgent!==Y&&e.loadingAgent.setSuspension(n),e.loadingAgent!==Y&&(a=e.loadingAgent.update())):e.dispose():Z(this,h,!1)&&(e.loadingAgent=oe(this,r,t,n),a=e.loadingAgent.startLoading(),a?e.loadingAgent===Y&&this.setPendingUpdate(K.GEOMETRY):(he(e.loadingAgent),e.loadingAgent=Y)),e.loadingAgent===Y&&this.updateRenderData(t,D.FADING),!s&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,U(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this.cachedMemory}}_findLIJ(e,t){if(!e)return null;const s=this.surface.rootTiles;if(i(s))for(const i of s)if(ge(i,e)){let s=i,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!t(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return t(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?fe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===N.NORTH_EAST?1:e===N.NORTH_WEST?0:e===N.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)}forAllSubtreeOnSide(e,t){const i=e===N.NORTH?[0,1]:e===N.NORTH_EAST?[1]:e===N.EAST?[1,3]:e===N.SOUTH_EAST?[3]:e===N.SOUTH?[2,3]:e===N.SOUTH_WEST?[2]:e===N.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){G.forEach((t=>this.findNeighborCornerTileExact(t,e))),V.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(W(t),e)))}getNeighborEdgeStartVertexIndex(e,t){const i=t??this.findNeighborTile(V[e],(e=>e.isLoaded));if(!i||!this.isLoaded||!i.isLoaded)return 0;const s=this.level-i.level;if(0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,h=this.lij[a+1]-o;return r?n-1-h:h}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=V[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){w(!i.isLeaf);const s=(e+2)%4,n=W(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(w(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this.forEachLoadedNeighbor((e=>this._updateNeighbor(e))),V.forEach((t=>{this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e))?.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach(((t,s)=>{const n=this.findNeighborTile(t,i);null!=n&&n!==this&&n.forAllSubtreeOnSide(W(t),(t=>!!t.isLoaded&&(e(t),!0)));const r=this.renderData?.geometryState?.neighborData;r&&(r.modifiedEdgeResolutions[s]=!1)})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));w(!s||_e(this,s,t)),s?.isLoaded&&e(s)}))}_updateNeighbor(e){e?.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=q(t)?-1:H(t)?1:0,s=F(t)?-1:k(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){X&&(w(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(q(e)&&t[3]+s>=i[3])return!1;if(H(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&k(e)&&t[2]+s>=i[2])}}function oe(e,t,i,s){const n=i===b.ELEVATION?de.acquire():le.acquire();return n.init(e,t,i,s),n}function he(e){e.dispose(),e instanceof M?de.release(e):e instanceof x&&le.release(e)}const le=new n(x),de=new n(M),ue=new L;var ce;function ge(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function fe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function pe(e,t,i){return Math.abs(e-t)<=i}function me(e,i,s){if(t(e)||t(i))return!1;if(0===e.level&&0===i.level){if(e.isEastEnd&&i.isWestEnd&&s===N.EAST)return!0;if(e.isWestEnd&&i.isEastEnd&&s===N.WEST)return!0}const n=1e-6*(e.extent[2]-e.extent[0]);switch(s){case N.NORTH:return pe(e.extent[3],i.extent[1],n);case N.SOUTH:return pe(e.extent[1],i.extent[3],n);case N.EAST:return pe(e.extent[2],i.extent[0],n)||pe(e.extent[2],-i.extent[0],n);case N.WEST:return pe(e.extent[0],i.extent[2],n)||pe(e.extent[0],-i.extent[2],n)}}function _e(e,i,s){return!t(e)&&!t(i)&&i!==e&&(e.level>=i.level?Ae(e,i,s):Ae(i,e,B(s)))}function Ae(e,t,i){w(e.level>=t.level);const s=z(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],h=[s?a[2]:a[0],n?a[1]:a[3]],l=1e-5*(r[2]-r[0]),d=pe(o[0],h[0],l)||e.surface.isGlobal&&pe(o[0],-h[0],l),u=pe(o[1],h[1],l);if(d&&u)return!0;if(e.level===t.level)return!1;if(!d&&!u)return!1;return d?ye(a[1],a[3],r[1],r[3],l):ye(a[0],a[2],r[0],r[2],l)}function ye(e,t,i,s,n=m){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ce||(ce={}));export{ce as CenterPosition,re as SplitLimits,ae as Tile,pe as almostEquals,_e as isCornerNeighbor,me as isEdgeNeighbor};
|
|
5
|
+
import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as h,p as l,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{E as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as y,equals as A}from"../../../geometry/support/aaBoundingRect.js";import{c as E}from"../../../chunks/sphere.js";import{VectorTile as T}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as L}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{LODSnapping as D,TextureUpdate as I,NeighborIndex as N}from"./interfaces.js";import{LayerClasses as b,LayerClass as S}from"./LayerClass.js";import{MapTileAgent as x}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as O,getElevationDesiredResolutionLevel as C}from"./TerrainConst.js";import{weakAssert as U,getLayerWithExtentRange as R,isBlendableLayerView as P,oppositeCorner as B,neighborCornerIndices as G,neighborEdgeIndices as V,oppositeEdge as W,internalAssert as w,isNorth as q,isSouth as H,isWest as F,isEast as k,ENABLE_WATERPROOFNESS_TESTS as X,isWestCorner as z,isNorthCorner as J}from"./terrainUtils.js";import{TILE_AGENT_DONE as Y}from"./TileAgent.js";import{TilePerLayerInfo as $}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";import{getGpuMemoryUsage as ee}from"../../webgl/Util.js";const te=f(),ie=f(),se=f(),ne=.1;class re{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class ae{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=y(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=y(),this.centerAtSeaLevel=f(),this._center=[f(),E(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemory=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){le.prune(0),de.prune(0),$.prune()}get isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ce.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setNeedsRender(),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setNeedsRender()),e}get shouldLoad(){if(!this.loadable)return!1;if(this._surface.lodSnapping===D.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ce.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of b){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=$.acquire(this._surface.upsampleInfoPool),s===S.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,O)}release(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of b){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this.isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this.isCached){this.setMemoryDirty();const e=this.cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this.isCached?0:this._mapTileMemory)}get cachedMemory(){return this.isCached?this.mapTileMemory:0}get mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[S.MAP].reduce(((e,t)=>e+(t instanceof T?t.memoryUsage:0)),this._mapTileMemory)}get cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(t(this._usedMemory))return this._usedMemory;this._usedMemory=0,this._mapTileMemory=0;let e=0;for(const{data:t}of this.layerInfo[S.MAP])t instanceof T?e+=this._getTerrainDataMemory(t):this._mapTileMemory+=this._getTerrainDataMemory(t);const i=this.cpuImageMemorySize;for(const t of this.layerInfo[S.ELEVATION])this._usedMemory+=t.data?i:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemory+=ee(this.renderData.textureDescriptor)),this.isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemory+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===S.MAP?this.isCached?0:this._getTerrainDataMemory(i.data):e===S.ELEVATION?this.cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Q?ee(e.texture):e instanceof HTMLImageElement||e instanceof v?this.cpuImageMemorySize:e instanceof T||e instanceof j?e.memoryUsage:0}updateScreenDepth(e){const t=this._center[ce.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(t(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return K.NONE;const n=this.level;h(te,this._center[ce.MIDDLE],i);let r=l(te),a=ce.MIDDLE;h(ie,this._center[ce.TOP],i);const o=l(ie);o<r&&(r=o,a=ce.TOP),h(ie,this._center[ce.BOTTOM],i);const f=l(ie);if(f<r&&(r=f,a=ce.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return K.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,y=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,K.VSPLITMERGE):K.NONE_HIT_MAXLOD};if(s===D.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?y():K.SPLIT}const A=d(this.up,te),E=this._elevationBounds[1]-this._elevationBounds[0],T=E/this.edgeLen;if(e.aboveGround&&A>0&&T<.001){if(A/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-T>0)return K.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,K.VSPLITMERGE):K.NONE;if(n>=e.maxLod)return y();if(n>6){h(ie,this._center[a],i),u(se,this.up,A),h(se,se,ie);const t=l(se);if(t>this.radius*this.radius){u(se,se,this.radius/Math.sqrt(t)),c(se,se,this._center[a]),h(se,i,se);const s=Math.min(1,(Math.abs(d(se,this.up))+.5*E+this._curvatureHeight)/g(se)),n=ne/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return K.NONE}}return K.SPLIT}setChildren(e,t,i,s){U(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}prepareToLoad(e){this.refMapData();for(const t of b)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of b){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[S.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(A(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of b){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Y&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==S.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return l(h(se,this._center[ce.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t){switch(e){case S.MAP:return this._updateTexture(t);case S.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===I.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===I.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[S.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const i=this.layerInfo[S.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(se,this.up,t),c(this._center[ce.MIDDLE],this.centerAtSeaLevel,se),u(se,this.up,e[0]),c(this._center[ce.TOP],this.centerAtSeaLevel,se),u(se,this.up,e[1]),c(this._center[ce.BOTTOM],this.centerAtSeaLevel,se)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[S.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,S.ELEVATION),a=R(r);if(!Z(this,a,!1))return;const o=ue;let h=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,h=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<C(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[S.ELEVATION][e].data,!(!i&&t&&s>=C(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,h=!0))}h&&(s(n.elevationBounds)&&(n.elevationBounds=new L),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Y&&(he(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:$.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,I.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Y&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of b){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Y&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Y&&this.updateRenderData(e,I.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Y&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=Y,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=(()=>{for(let s=e;s<i.length;++s){const e=this._surface.layerViewByIndex(s,t);if(P(e)&&"normal"!==e.layer.blendMode)return!0}return!1})(),n=this._isSuspended(t);for(let r=e;r<i.length;++r){const e=i[r];let a=!1;const o=this._surface.layerViewByIndex(r,t),h=R(o);if(e.loadingAgent?Z(this,h,!1)?(e.loadingAgent!==Y&&e.loadingAgent.setSuspension(n),e.loadingAgent!==Y&&(a=e.loadingAgent.update())):e.dispose():Z(this,h,!1)&&(e.loadingAgent=oe(this,r,t,n),a=e.loadingAgent.startLoading(),a?e.loadingAgent===Y&&this.setPendingUpdate(K.GEOMETRY):(he(e.loadingAgent),e.loadingAgent=Y)),e.loadingAgent===Y&&this.updateRenderData(t,I.FADING),!s&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,C(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this.cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(ge(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?fe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===N.NORTH_EAST?1:e===N.NORTH_WEST?0:e===N.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)}forAllSubtreeOnSide(e,t){const i=e===N.NORTH?[0,1]:e===N.NORTH_EAST?[1]:e===N.EAST?[1,3]:e===N.SOUTH_EAST?[3]:e===N.SOUTH?[2,3]:e===N.SOUTH_WEST?[2]:e===N.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){G.forEach((t=>this.findNeighborCornerTileExact(t,e))),V.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(W(t),e)))}getNeighborEdgeStartVertexIndex(e,t){const i=t??this.findNeighborTile(V[e],(e=>e.isLoaded));if(!i||!this.isLoaded||!i.isLoaded)return 0;const s=this.level-i.level;if(0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,h=this.lij[a+1]-o;return r?n-1-h:h}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=V[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){w(!i.isLeaf);const s=(e+2)%4,n=W(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(w(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this.forEachLoadedNeighbor((e=>this._updateNeighbor(e))),V.forEach((t=>{this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e))?.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach(((t,s)=>{const n=this.findNeighborTile(t,i);null!=n&&n!==this&&n.forAllSubtreeOnSide(W(t),(t=>!!t.isLoaded&&(e(t),!0)));const r=this.renderData?.geometryState?.neighborData;r&&(r.modifiedEdgeResolutions[s]=!1)})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));w(!s||_e(this,s,t)),s?.isLoaded&&e(s)}))}_updateNeighbor(e){e?.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=q(t)?-1:H(t)?1:0,s=F(t)?-1:k(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){X&&(w(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(q(e)&&t[3]+s>=i[3])return!1;if(H(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&k(e)&&t[2]+s>=i[2])}}function oe(e,t,i,s){const n=i===S.ELEVATION?de.acquire():le.acquire();return n.init(e,t,i,s),n}function he(e){e.dispose(),e instanceof M?de.release(e):e instanceof x&&le.release(e)}const le=new n(x),de=new n(M),ue=new L;var ce;function ge(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function fe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function pe(e,t,i){return Math.abs(e-t)<=i}function me(e,t,i){if(s(e)||s(t))return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===N.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===N.WEST)return!0}const n=1e-6*(e.extent[2]-e.extent[0]);switch(i){case N.NORTH:return pe(e.extent[3],t.extent[1],n);case N.SOUTH:return pe(e.extent[1],t.extent[3],n);case N.EAST:return pe(e.extent[2],t.extent[0],n)||pe(e.extent[2],-t.extent[0],n);case N.WEST:return pe(e.extent[0],t.extent[2],n)||pe(e.extent[0],-t.extent[2],n)}}function _e(e,t,i){return!s(e)&&!s(t)&&t!==e&&(e.level>=t.level?ye(e,t,i):ye(t,e,B(i)))}function ye(e,t,i){w(e.level>=t.level);const s=z(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],h=[s?a[2]:a[0],n?a[1]:a[3]],l=1e-5*(r[2]-r[0]),d=pe(o[0],h[0],l)||e.surface.isGlobal&&pe(o[0],-h[0],l),u=pe(o[1],h[1],l);if(d&&u)return!0;if(e.level===t.level)return!1;if(!d&&!u)return!1;return d?Ae(a[1],a[3],r[1],r[3],l):Ae(a[0],a[2],r[0],r[2],l)}function Ae(e,t,i,s,n=m){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ce||(ce={}));export{ce as CenterPosition,re as SplitLimits,ae as Tile,pe as almostEquals,_e as isCornerNeighbor,me as isEdgeNeighbor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";class r{constructor(){this._queue=new n,this._last=null,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=null}reset(e=null){this._queue.clear(),t(e)&&this._queue.pushArray(e),this._last=null}skipSubtree(){this._last=null}next(){return this._last&&!this._last.isLeaf&&this._queue.pushArray(this._last.children),this._last=this._queue.pop(),this._last}}class i{constructor(){this.q=new n}get done(){return 0===this.q.length}reset(t){if(this.q.clear(),!e(t)){this.q.pushArray(t);for(let t=0;t<this.q.length;++t){const e=this.q.data[t];e.isLeaf||this.q.pushArray(e.children)}}}next(){return this.q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)l(t[n],e);else l(t,e)}function l(t,e){if(e(t),!t.isLeaf)for(const n of t.children)l(n,e)}function u(t,n,r){if(e(n)||e(n.fullExtent))return!1;const i=n.fullExtent,s=t.extent;if(r){if(s[0]<i.xmin||s[1]<i.ymin||s[2]>i.xmax||s[3]>i.ymax)return!1}else if(i.xmin>s[2]||i.ymin>s[3]||i.xmax<s[0]||i.ymax<s[1])return!1;const l=t.surface.tilingScheme.levels[t.level].scale;return!(n.minScale>0&&l>1.00000001*n.minScale)&&!(n.maxScale>0&&l<.99999999*n.maxScale)}function o(t,e){return t.lij[0]-e.lij[0]||t.lij[1]-e.lij[1]||t.lij[2]-e.lij[2]}function a(t,e){e.sort(((e,n)=>h(e,n,t)))}function h(t,e,n){const r=t.screenDepth,i=e.screenDepth;return r<i?-n:r>i?n:o(t,e)}function c(t,e){const n=new Map;t.forAll((t=>n.set(t.lij,t.distanceToSquared(e)))),t.sort(((t,e)=>n.get(t.lij)-n.get(e.lij)||o(t,e)))}function f(t,e,n){let r=1,i=0,s=0;for(;t!==e;)if(r*=.5,i*=.5,s*=.5,1&t.lij[2]&&(i+=.5),0==(1&t.lij[1])&&(s+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,i,s,r)}function m(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function p(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,i=n?e:t,s=1<<i[0]-r[0];return Math.floor(i[1]/s)===r[1]&&Math.floor(i[2]/s)===r[2]}export{i as IteratorPostorder,r as IteratorPreorder,h as compareTiles,f as computeUpsampleInfo,u as fallsWithinLayer,m as hasLoadableSiblings,a as sortTiles,c as sortTilesByPOI,p as tilesAreRelated,s as traverseTilesPreorder};
|
|
5
|
+
import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";class r{constructor(){this._queue=new n,this._last=null,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=null}reset(e=null){this._queue.clear(),t(e)&&this._queue.pushArray(e),this._last=null}skipSubtree(){this._last=null}next(){return this._last&&!this._last.isLeaf&&this._queue.pushArray(this._last.children),this._last=this._queue.pop(),this._last}}class i{constructor(){this.q=new n}get done(){return 0===this.q.length}reset(t){if(this.q.clear(),!e(t)){this.q.pushArray(t);for(let t=0;t<this.q.length;++t){const e=this.q.data[t];e.isLeaf||this.q.pushArray(e.children)}}}next(){return this.q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)l(t[n],e);else l(t,e)}function l(t,e){if(e(t),!t.isLeaf)for(const n of t.children)l(n,e)}function u(t,n,r){if(e(n)||e(n.fullExtent))return!1;const i=n.fullExtent,s=t.extent;if(r){if(s[0]<i.xmin||s[1]<i.ymin||s[2]>i.xmax||s[3]>i.ymax)return!1}else if(i.xmin>s[2]||i.ymin>s[3]||i.xmax<s[0]||i.ymax<s[1])return!1;const l=t.surface.tilingScheme.levels[t.level].scale;return!(n.minScale>0&&l>1.00000001*n.minScale)&&!(n.maxScale>0&&l<.99999999*n.maxScale)}function o(t,e){return t.lij[0]-e.lij[0]||t.lij[1]-e.lij[1]||t.lij[2]-e.lij[2]}function a(t,e){e.sort(((e,n)=>h(e,n,t)))}function h(t,e,n){const r=t.screenDepth,i=e.screenDepth;return r<i?-n:r>i?n:o(t,e)}function c(t,e){const n=new Map;t.forAll((t=>n.set(t.lij,t.distanceToSquared(e)))),t.sort(((t,e)=>n.get(t.lij)-n.get(e.lij)||o(t,e)))}function f(t,e,n){let r=1,i=0,s=0;for(;t!==e;)if(r*=.5,i*=.5,s*=.5,1&t.lij[2]&&(i+=.5),0==(1&t.lij[1])&&(s+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,i,s,r)}function m(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n&&e.loadable)return!0}}return!1}function p(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,i=n?e:t,s=1<<i[0]-r[0];return Math.floor(i[1]/s)===r[1]&&Math.floor(i[2]/s)===r[2]}export{i as IteratorPostorder,r as IteratorPreorder,h as compareTiles,f as computeUpsampleInfo,u as fallsWithinLayer,m as hasLoadableSiblings,a as sortTiles,c as sortTilesByPOI,p as tilesAreRelated,s as traverseTilesPreorder};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/has.js";import{isSome as t,isNone as r}from"../../core/maybe.js";var o;function n(e,r,o={}){const n=i(e);for(;n.length>1;){const e=l(r,n.shift(),o);if(t(e))return e}return c(r,n.shift(),o)}function i(t){const r=e("esri-force-webgl");if(r===o.WEBGL1||r===o.WEBGL2)return[r];switch(t){case"2d":return e("mac")?[o.WEBGL1,o.WEBGL2]:[o.WEBGL2,o.WEBGL1];case"3d":return[o.WEBGL2,o.WEBGL1]}}function c(e,t,o={}){if(!window.WebGLRenderingContext)return a(e,s),null;const n=l(e,t,o);return r(n)&&a(e,u),n}function l(e,t,r={}){const n=t===o.WEBGL1?["webgl","experimental-webgl","webkit-3d","moz-webgl"]:["webgl2"];let i=null;for(const o of n){try{i=e.getContext(o,r)}catch(c){}if(i)break}return i}function a(e,t){const r=e.parentNode;r&&(r.innerHTML='<table style="background-color: #8CE; width: 100%; height: 100%;"><tr><td align="center"><div style="display: table-cell; vertical-align: middle;"><div style="">'+t+"</div></div></td></tr></table>")}!function(e){e[e.WEBGL1=1]="WEBGL1",e[e.WEBGL2=2]="WEBGL2"}(o||(o={}));const s='This page requires a browser that supports WebGL.<br/><a href="http://get.webgl.org">Click here to upgrade your browser.</a>',u='It doesn\'t appear your computer can support WebGL.<br/><a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>';export{o as ContextType,l as createContext,n as createContextOrErrorHTML,i as getContextTypes};
|
|
5
|
+
import e from"../../core/has.js";import{isSome as t,isNone as r}from"../../core/maybe.js";var o;function n(e,r,o={}){const n=i(e);for(;n.length>1;){const e=l(r,n.shift(),o);if(t(e))return e}return c(r,n.shift(),o)}function i(t){const r=e("esri-force-webgl");if(r===o.WEBGL1||r===o.WEBGL2)return[r];switch(t){case"2d":return e("mac")&&e("chrome")?[o.WEBGL1,o.WEBGL2]:[o.WEBGL2,o.WEBGL1];case"3d":return[o.WEBGL2,o.WEBGL1]}}function c(e,t,o={}){if(!window.WebGLRenderingContext)return a(e,s),null;const n=l(e,t,o);return r(n)&&a(e,u),n}function l(e,t,r={}){const n=t===o.WEBGL1?["webgl","experimental-webgl","webkit-3d","moz-webgl"]:["webgl2"];let i=null;for(const o of n){try{i=e.getContext(o,r)}catch(c){}if(i)break}return i}function a(e,t){const r=e.parentNode;r&&(r.innerHTML='<table style="background-color: #8CE; width: 100%; height: 100%;"><tr><td align="center"><div style="display: table-cell; vertical-align: middle;"><div style="">'+t+"</div></div></td></tr></table>")}!function(e){e[e.WEBGL1=1]="WEBGL1",e[e.WEBGL2=2]="WEBGL2"}(o||(o={}));const s='This page requires a browser that supports WebGL.<br/><a href="http://get.webgl.org">Click here to upgrade your browser.</a>',u='It doesn\'t appear your computer can support WebGL.<br/><a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>';export{o as ContextType,l as createContext,n as createContextOrErrorHTML,i as getContextTypes};
|
package/widgets/Editor.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as a}from"../core/maybe.js";import{watch as i,on as n,when as o,initial as r}from"../core/reactiveUtils.js";import{aliasOf as l}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as h}from"../layers/support/fieldUtils.js";import m from"../views/interactive/sketch/SketchLabelOptions.js";import u from"../views/interactive/sketch/SketchTooltipOptions.js";import g from"../views/interactive/snapping/SnappingOptions.js";import v from"./Attachments.js";import w from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import f from"./Spinner.js";import k from"./Widget.js";import{workflowDeprecation as b}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as C}from"./FeatureTemplates/ItemList.js";import{Heading as M,incrementHeadingLevel as A}from"./support/Heading.js";import F from"./support/SnappingControls.js";import{accessibleHandler as W}from"./support/decorators/accessibleHandler.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as S}from"./support/decorators/vmEvent.js";import{tsx as E}from"./support/jsxFactory.js";import{classes as B}from"./support/widgetUtils.js";import{substitute as P}from"../intl/substitute.js";const j={base:"esri-editor esri-widget esri-widget--panel",message:"esri-editor__message",controls:"esri-editor__controls",controlButton:"esri-editor__control-button",progressBar:"esri-editor__progress-bar",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content__section",panelContentSectionGroup:"esri-editor__panel-content__section__group",panelContentMessage:"esri-editor__panel-content__message",scroller:"esri-editor__scroller",snappingControlsPopover:"esri-editor__snapping-controls-popover",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary"},L=B(j.scroller,j.panelContent),x={undoRedoButtons:!1};function U(e){e.focus()}const V="esri.widgets.Editor",D=s.getLogger(V);let I=class extends(t(k)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new w,this._stateStack=[],this._attachments=new v({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new f,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=j.widgetIcon,this.label=void 0,this.labelOptions=new m,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new g,this.tooltipOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...x},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new F({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([i((()=>this.headingLevel),(e=>{this._featureForm.headingLevel=A(e),this._featureTemplates.headingLevel=A(e)}),r),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),i((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null}),r),i((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})}),r),n((()=>this.viewModel?.sketchViewModel),"create",(()=>{this.scheduleRender()})),n((()=>this.viewModel?.activeWorkflow),"cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),i((()=>this.supportingWidgetDefaults),(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))}),r),i((()=>this._attachments?.error),(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),i((()=>this.viewModel?.failures),(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:a,cancel:i}]=e;this._prompt={title:t.errorWarningTitle,message:P(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{a(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(i(),this._prompt=null)}}}})),i((()=>this.viewModel?.state),(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),i((()=>[this._attachments?.selectedFile,this._attachments?.submitting]),(()=>this.scheduleRender())),o((()=>!this.viewModel?.activeWorkflow),(()=>this._featureTemplates.filterText="")),n((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.viewModel?.activeWorkflow&&this._handleBack()}))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js")])}castVisibleElements(e){return{...x,...e}}startCreateWorkflowAtFeatureTypeSelection(){return b(D,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return b(D,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return b(D,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return E("div",{class:j.base});const{state:i}=s,n=a(t)?E("calcite-scrim",null,this.renderPrompt(t)):null;return E("div",{class:j.base},s.syncing||e.submitting?this.renderProgressBar():null,E("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(i)),n)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return E("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_handleBack:n,_snappingControls:o,viewModel:{sketchViewModel:r}}=this;return E(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:n,heading:a.selectTemplate,headingLevel:s,messages:a,messagesCommon:i,sketchViewModel:r,snappingControls:o},E("div",{class:L},this._featureTemplates.render()))}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:a,messagesCommon:i,headingLevel:n,_handleBack:o,_snappingControls:r,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?a.editFeature:a.createFeatures,m="update"===t.type?i.update:i.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g="update"===t.type&&t.data.editableItem.supports.includes("delete"),v="update"===t.type&&t.data.editableItem.hasAttachments,w=[{label:"create-features"===t.type&&t.numPendingFeatures>1?P(a.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave,width:g?"half":"full"}];return g&&w.push({label:i.delete,type:"tertiary",clickHandler:this._handleDelete,appearance:"outline",width:"half"}),E(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:n,handleBack:o,messages:a,messagesCommon:i,sketchViewModel:d,snappingControls:r},E("div",{class:L},E("div",{class:j.panelContentSection},E("div",{class:j.panelContentSectionGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(P(a.clickToFinishTemplate,{button:m})),v?E("div",{key:"attachments"},E("div",null,a.attachments),this._attachments.render()):null),u?E("calcite-scrim",null):null)),this.renderFooterActions(w))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:n,messagesCommon:o,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd,width:"full"}];return E(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:n.addAttachment,headingLevel:i,handleBack:a,messages:n,messagesCommon:o,sketchViewModel:l,snappingControls:r},E("div",{class:L},t.render()),this.renderFooterActions(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:n,messagesCommon:o,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate,width:"half"},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete,width:"half",appearance:"outline"}];return E(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:n.editAttachment,headingLevel:i,handleBack:a,messages:n,messagesCommon:o,sketchViewModel:l,snappingControls:r},E("div",{class:L},t.render()),this.renderFooterActions(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:n,_snappingControls:o,viewModel:{sketchViewModel:r}}=this;return E(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:i.selectFeature,headingLevel:a,handleBack:s,messages:i,messagesCommon:n,sketchViewModel:r,snappingControls:o},E("div",{class:B(L,j.panelContentMessage)},this.renderMessage(i.selectFeatureToEdit)))}renderMessage(e){return E("div",{class:j.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:n,_snappingControls:o,viewModel:r}=this,{sketchViewModel:l}=r,d=r.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return E(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:i.placeFeature,headingLevel:a,handleBack:s,messages:i,messagesCommon:n,sketchViewModel:l,snappingControls:o},E("div",{class:B(L,j.panelContentMessage)},this.renderMessage(h)))}renderFooterActions(e){return e.map((({type:e,disabled:t,class:s,...a},i)=>this.renderButton({class:this.classes(j.controlButton,"secondary"===e?j.buttonSecondary:"tertiary"===e?j.buttonTertiary:null,t?j.buttonDisabled:null,s),disabled:t??!1,key:i,slot:"footer-actions",...a})))}renderPrompt({title:e,message:t,context:s,actions:a}){const i=!!a.secondary,n=E("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:i?"half":"full",onclick:a.primary.action,key:"prompt-primary-button",afterCreate:U},a.primary.label),o=i?E("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:a.secondary.action,key:"prompt-secondary-button"},a.secondary.label):null;return E("div",{class:`${j.promptContainer}--${s}`},E("div",{class:j.promptHeader},E("calcite-icon",{icon:"exclamation-mark-triangle"}),E(M,{class:j.promptHeading,level:this.headingLevel},e)),E("div",{class:j.promptMessage},t),E("div",{class:j.promptDivider}),E("div",{class:j.promptActions},o,n))}renderProgressBar(){return E("div",{class:this.classes(j.progressBar),key:"progress-bar"})}renderButton(e){const{disabled:t,class:s,key:a,clickHandler:i,label:n,...o}=e;return E("calcite-button",{class:s,disabled:t,key:a,onclick:i,type:"button",...o},n)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_snappingControls:n,viewModel:{sketchViewModel:o}}=this;return E(t,{active:this.isPanelActive(e),key:"landing-panel",heading:a.widgetLabel,headingLevel:s,showBackButton:!1,messages:a,messagesCommon:i,sketchViewModel:o,snappingControls:n},E("div",{class:L},E("div",{key:"edit-actions",class:j.panelContentSection},this.renderUpdateActions()),E("div",{key:"create-actions",class:j.panelContentSection},this.renderCreateActions())))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return E("div",null,E(M,{level:A(this.headingLevel)},e.editFeatures),E("div",{class:j.updateFeaturesActionButtons},E("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:j.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;if(0!==e.viewModel.numberOfFeatureTemplates)return E("div",null,E(M,{level:A(t)},s.createFeatures),E("div",{key:"templates",class:j.featureTemplatesContainer},e.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:n,messagesTemplates:o,_snappingControls:r,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=P(i.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,a=this._filterText.toLowerCase(),{title:i}=s.layer,n=this.viewModel.editableItems.find((e=>e.layer===s.layer));return n.supports.includes("update")&&(!a||t.toLowerCase().includes(a)||i.toLowerCase().includes(a))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return E(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:a,handleBack:s,messages:i,messagesCommon:n,sketchViewModel:d,snappingControls:r},E("div",{class:L},C({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e})))}EditorPanel(e,...t){const{active:s,handleBack:a,heading:i,headingLevel:n,key:o,messages:r,messagesCommon:l,showBackButton:d,sketchViewModel:c,snappingControls:p}=e;return E("calcite-panel",{bind:this,key:o,heading:i,headingLevel:n,showBackButton:d??!0,beforeBack:a??null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},E("div",{class:j.panelToolbar},E("calcite-popover",{autoClose:s,afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:r.snappingSettings,heading:r.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed",placement:"bottom"},E("div",{class:j.snappingControlsPopover},p.render())),E("calcite-button",{id:`${o}__snappingButton`,text:r.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:j.panelToolbarSnappingButton},r.snapping),this.visibleElements.undoRedoButtons?[E("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!c.canUndo(),onclick:c.undo.bind(c)}),E("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!c.canRedo(),onclick:c.redo.bind(c)})]:null),t)}_onSnappingPopoverPanelScroll(){this._snappingPopover?.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const a=t.geometry,i="polygon"===e?"rings":"paths",[n]=a[i];return"polygon"===e&&n<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:a}=e,i=h(t);return i&&a[i]&&`${a[i]}`||P(this.messages.untitledFeatureTemplate,{id:a[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified){const{type:a}=t,i="create"===a?e.cancelAddWarningMessage:e.cancelEditWarningMessage,n="create"===a?e.cancelAddTitle:e.cancelEditTitle,o="create"===a?e.continueAdding:e.continueEditing,r="create"===a?e.discardFeature:e.discardEdits;throw this._prompt={title:n,message:i,context:"danger",actions:{primary:{label:r,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([c()],I.prototype,"_attachments",void 0),e([l("viewModel.activeWorkflow")],I.prototype,"activeWorkflow",void 0),e([l("viewModel.allowedWorkflows")],I.prototype,"allowedWorkflows",void 0),e([c()],I.prototype,"useDeprecatedCreateWorkflow",void 0),e([c()],I.prototype,"headingLevel",void 0),e([c()],I.prototype,"iconClass",void 0),e([c({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],I.prototype,"label",void 0),e([l("viewModel.labelOptions")],I.prototype,"labelOptions",void 0),e([l("viewModel.layerInfos")],I.prototype,"layerInfos",void 0),e([c(),T("esri/widgets/Editor/t9n/Editor")],I.prototype,"messages",void 0),e([c(),T("esri/t9n/common")],I.prototype,"messagesCommon",void 0),e([c(),T("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],I.prototype,"messagesTemplates",void 0),e([l("viewModel.snappingOptions")],I.prototype,"snappingOptions",void 0),e([l("viewModel.tooltipOptions")],I.prototype,"tooltipOptions",void 0),e([c()],I.prototype,"supportingWidgetDefaults",void 0),e([l("viewModel.view")],I.prototype,"view",void 0),e([c(),S(["workflow-cancel","workflow-commit"])],I.prototype,"viewModel",void 0),e([c()],I.prototype,"visibleElements",void 0),e([d("visibleElements")],I.prototype,"castVisibleElements",null),e([W()],I.prototype,"_handleDelete",null),e([W()],I.prototype,"_handleAttachmentAdd",null),e([W()],I.prototype,"_handleAttachmentUpdate",null),e([W()],I.prototype,"_handleAttachmentDelete",null),e([W()],I.prototype,"_handleAdd",null),e([W()],I.prototype,"_handleEdit",null),e([W()],I.prototype,"_handleDone",null),I=e([p(V)],I);const O=I;export{O as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as a}from"../core/maybe.js";import{watch as i,on as o,when as n,initial as r}from"../core/reactiveUtils.js";import{aliasOf as l}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as h}from"../layers/support/fieldUtils.js";import m from"../views/interactive/sketch/SketchLabelOptions.js";import u from"../views/interactive/sketch/SketchTooltipOptions.js";import g from"../views/interactive/snapping/SnappingOptions.js";import v from"./Attachments.js";import w from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import f from"./Spinner.js";import k from"./Widget.js";import{workflowDeprecation as b}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as C}from"./FeatureTemplates/ItemList.js";import{Heading as M,incrementHeadingLevel as A}from"./support/Heading.js";import F from"./support/SnappingControls.js";import{accessibleHandler as W}from"./support/decorators/accessibleHandler.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as S}from"./support/decorators/vmEvent.js";import{tsx as E}from"./support/jsxFactory.js";import{classes as B}from"./support/widgetUtils.js";import{substitute as P}from"../intl/substitute.js";const j={base:"esri-editor esri-widget esri-widget--panel",message:"esri-editor__message",controls:"esri-editor__controls",controlButton:"esri-editor__control-button",progressBar:"esri-editor__progress-bar",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentMessage:"esri-editor__panel-content__message",panelContentSection:"esri-editor__panel-content__section",panelContentSectionGroup:"esri-editor__panel-content__section__group",scroller:"esri-editor__scroller",snappingControlsPopover:"esri-editor__snapping-controls-popover",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary"},L=B(j.scroller,j.panelContent),x={undoRedoButtons:!1};function U(e){e.focus()}const V="esri.widgets.Editor",D=s.getLogger(V);let I=class extends(t(k)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new w,this._stateStack=[],this._attachments=new v({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new f,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=j.widgetIcon,this.label=void 0,this.labelOptions=new m,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new g,this.tooltipOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...x},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new F({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([i((()=>this.headingLevel),(e=>{this._featureForm.headingLevel=A(e),this._featureTemplates.headingLevel=A(e)}),r),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),i((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null}),r),i((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})}),r),o((()=>this.viewModel?.sketchViewModel),"create",(()=>{this.scheduleRender()})),o((()=>this.viewModel?.activeWorkflow),"cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),i((()=>this.supportingWidgetDefaults),(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))}),r),i((()=>this._attachments?.error),(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),i((()=>this.viewModel?.failures),(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:a,cancel:i}]=e;this._prompt={title:t.errorWarningTitle,message:P(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{a(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(i(),this._prompt=null)}}}})),i((()=>this.viewModel?.state),(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),i((()=>[this._attachments?.selectedFile,this._attachments?.submitting]),(()=>this.scheduleRender())),n((()=>!this.viewModel?.activeWorkflow),(()=>this._featureTemplates.filterText="")),o((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.viewModel?.activeWorkflow&&this._handleBack()}))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js")])}castVisibleElements(e){return{...x,...e}}startCreateWorkflowAtFeatureTypeSelection(){return b(D,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return b(D,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return b(D,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return E("div",{class:j.base});const{state:i}=s,o=a(t)?E("calcite-scrim",null,this.renderPrompt(t)):null;return E("div",{class:j.base},s.syncing||e.submitting?this.renderProgressBar():null,E("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(i)),o)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return E("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_handleBack:o,_snappingControls:n,viewModel:{sketchViewModel:r}}=this;return E(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:o,heading:a.selectTemplate,headingLevel:s,messages:a,messagesCommon:i,sketchViewModel:r,snappingControls:n},E("div",{class:L},this._featureTemplates.render()))}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:a,messagesCommon:i,headingLevel:o,_handleBack:n,_snappingControls:r,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?a.editFeature:a.createFeatures,m="update"===t.type?i.update:i.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g="update"===t.type&&t.data.editableItem.supports.includes("delete"),v="update"===t.type&&t.data.editableItem.hasAttachments,w=[{label:"create-features"===t.type&&t.numPendingFeatures>1?P(a.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave,width:g?"half":"full"}];g&&w.push({label:i.delete,type:"tertiary",clickHandler:this._handleDelete,appearance:"outline",width:"half"});const _=c.inputFields.every((e=>!e.visible))?this.renderMessage(P(a.clickToFinishTemplate,{button:m})):E("div",{class:j.panelContentSection},E("div",{class:j.panelContentSectionGroup},this._featureForm.render(),v?E("div",{key:"attachments"},E("div",null,a.attachments),this._attachments.render()):null));return E(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:o,handleBack:n,messages:a,messagesCommon:i,sketchViewModel:d,snappingControls:r},E("div",{class:L},_,u?E("calcite-scrim",null):null),this.renderFooterActions(w))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:o,messagesCommon:n,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?n.cancel:n.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd,width:"full"}];return E(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:o.addAttachment,headingLevel:i,handleBack:a,messages:o,messagesCommon:n,sketchViewModel:l,snappingControls:r},E("div",{class:L},t.render()),this.renderFooterActions(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:a,headingLevel:i,messages:o,messagesCommon:n,_snappingControls:r,viewModel:{sketchViewModel:l}}=this,d=[{label:n.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate,width:"half"},{label:n.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete,width:"half",appearance:"outline"}];return E(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:o.editAttachment,headingLevel:i,handleBack:a,messages:o,messagesCommon:n,sketchViewModel:l,snappingControls:r},E("div",{class:L},t.render()),this.renderFooterActions(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:r}}=this;return E(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:i.selectFeature,headingLevel:a,handleBack:s,messages:i,messagesCommon:o,sketchViewModel:r,snappingControls:n},E("div",{class:L},this.renderMessage(i.selectFeatureToEdit)))}renderMessage(e){return E("div",{class:j.panelContentMessage},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:o,_snappingControls:n,viewModel:r}=this,{sketchViewModel:l}=r,d=r.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return E(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:i.placeFeature,headingLevel:a,handleBack:s,messages:i,messagesCommon:o,sketchViewModel:l,snappingControls:n},E("div",{class:L},this.renderMessage(h)))}renderFooterActions(e){return e.map((({type:e,disabled:t,class:s,...a},i)=>this.renderButton({class:this.classes(j.controlButton,"secondary"===e?j.buttonSecondary:"tertiary"===e?j.buttonTertiary:null,t?j.buttonDisabled:null,s),disabled:t??!1,key:i,slot:"footer-actions",...a})))}renderPrompt({title:e,message:t,context:s,actions:a}){const i=!!a.secondary,o=E("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:i?"half":"full",onclick:a.primary.action,key:"prompt-primary-button",afterCreate:U},a.primary.label),n=i?E("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:a.secondary.action,key:"prompt-secondary-button"},a.secondary.label):null;return E("div",{class:`${j.promptContainer}--${s}`},E("div",{class:j.promptHeader},E("calcite-icon",{icon:"exclamation-mark-triangle"}),E(M,{class:j.promptHeading,level:this.headingLevel},e)),E("div",{class:j.promptMessage},t),E("div",{class:j.promptDivider}),E("div",{class:j.promptActions},n,o))}renderProgressBar(){return E("div",{class:this.classes(j.progressBar),key:"progress-bar"})}renderButton(e){const{disabled:t,class:s,key:a,clickHandler:i,label:o,...n}=e;return E("calcite-button",{class:s,disabled:t,key:a,onclick:i,type:"button",...n},o)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:a,messagesCommon:i,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return E(t,{active:this.isPanelActive(e),key:"landing-panel",heading:a.widgetLabel,headingLevel:s,showBackButton:!1,messages:a,messagesCommon:i,sketchViewModel:n,snappingControls:o},E("div",{class:L},E("div",{key:"edit-actions",class:j.panelContentSection},this.renderUpdateActions()),E("div",{key:"create-actions",class:j.panelContentSection},this.renderCreateActions())))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return E("div",null,E(M,{level:A(this.headingLevel)},e.editFeatures),E("div",{class:j.updateFeaturesActionButtons},E("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:j.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;if(0!==e.viewModel.numberOfFeatureTemplates)return E("div",null,E(M,{level:A(t)},s.createFeatures),E("div",{key:"templates",class:j.featureTemplatesContainer},e.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:a,messages:i,messagesCommon:o,messagesTemplates:n,_snappingControls:r,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=P(i.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,a=this._filterText.toLowerCase(),{title:i}=s.layer,o=this.viewModel.editableItems.find((e=>e.layer===s.layer));return o.supports.includes("update")&&(!a||t.toLowerCase().includes(a)||i.toLowerCase().includes(a))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return E(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:a,handleBack:s,messages:i,messagesCommon:o,sketchViewModel:d,snappingControls:r},E("div",{class:L},C({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:n.filterPlaceholder,noItems:n.noItems,noMatches:n.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e})))}EditorPanel(e,...t){const{active:s,handleBack:a,heading:i,headingLevel:o,key:n,messages:r,messagesCommon:l,showBackButton:d,sketchViewModel:c,snappingControls:p}=e;return E("calcite-panel",{bind:this,key:n,heading:i,headingLevel:o,showBackButton:d??!0,beforeBack:a??null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},E("div",{class:j.panelToolbar},E("calcite-popover",{autoClose:s,afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:r.snappingSettings,heading:r.snappingSettings,"reference-element":`${n}__snappingButton`,"overlay-positioning":"fixed",placement:"bottom"},E("div",{class:j.snappingControlsPopover},p.render())),E("calcite-button",{id:`${n}__snappingButton`,text:r.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:j.panelToolbarSnappingButton},r.snapping),this.visibleElements.undoRedoButtons?[E("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!c.canUndo(),onclick:c.undo.bind(c)}),E("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!c.canRedo(),onclick:c.redo.bind(c)})]:null),t)}_onSnappingPopoverPanelScroll(){this._snappingPopover?.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const a=t.geometry,i="polygon"===e?"rings":"paths",[o]=a[i];return"polygon"===e&&o<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:a}=e,i=h(t);return i&&a[i]&&`${a[i]}`||P(this.messages.untitledFeatureTemplate,{id:a[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified){const{type:a}=t,i="create"===a?e.cancelAddWarningMessage:e.cancelEditWarningMessage,o="create"===a?e.cancelAddTitle:e.cancelEditTitle,n="create"===a?e.continueAdding:e.continueEditing,r="create"===a?e.discardFeature:e.discardEdits;throw this._prompt={title:o,message:i,context:"danger",actions:{primary:{label:r,action:()=>{s(),this._prompt=null}},secondary:{label:n,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([c()],I.prototype,"_attachments",void 0),e([l("viewModel.activeWorkflow")],I.prototype,"activeWorkflow",void 0),e([l("viewModel.allowedWorkflows")],I.prototype,"allowedWorkflows",void 0),e([c()],I.prototype,"useDeprecatedCreateWorkflow",void 0),e([c()],I.prototype,"headingLevel",void 0),e([c()],I.prototype,"iconClass",void 0),e([c({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],I.prototype,"label",void 0),e([l("viewModel.labelOptions")],I.prototype,"labelOptions",void 0),e([l("viewModel.layerInfos")],I.prototype,"layerInfos",void 0),e([c(),T("esri/widgets/Editor/t9n/Editor")],I.prototype,"messages",void 0),e([c(),T("esri/t9n/common")],I.prototype,"messagesCommon",void 0),e([c(),T("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],I.prototype,"messagesTemplates",void 0),e([l("viewModel.snappingOptions")],I.prototype,"snappingOptions",void 0),e([l("viewModel.tooltipOptions")],I.prototype,"tooltipOptions",void 0),e([c()],I.prototype,"supportingWidgetDefaults",void 0),e([l("viewModel.view")],I.prototype,"view",void 0),e([c(),S(["workflow-cancel","workflow-commit"])],I.prototype,"viewModel",void 0),e([c()],I.prototype,"visibleElements",void 0),e([d("visibleElements")],I.prototype,"castVisibleElements",null),e([W()],I.prototype,"_handleDelete",null),e([W()],I.prototype,"_handleAttachmentAdd",null),e([W()],I.prototype,"_handleAttachmentUpdate",null),e([W()],I.prototype,"_handleAttachmentDelete",null),e([W()],I.prototype,"_handleAdd",null),e([W()],I.prototype,"_handleEdit",null),e([W()],I.prototype,"_handleDone",null),I=e([p(V)],I);const O=I;export{O as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import{makeHandle as s}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{destroyMaybe as r,isNone as a,isSome as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as F}from"../../intl/locale.js";import{fetchMessageBundle as C}from"../../intl/messages.js";const v=new t({attributes:{}}),b="esri.widgets.FeatureForm.FeatureFormViewModel",E=o.getLogger(b),V=["editable","required","value","visibility"],x="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",w="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let I=class extends(n(u(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressionLookup=new Map,this._expressionLookup=new Map,this._expressionInvalidationCallbacks=new Set,this._contingentValuesCache=null,this._featureClone=v.clone(),this._initialFeature=v.clone(),this._arcadeGeometryOperationsEnabled=!1,this._inputFieldCache=[],this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await C("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=c((()=>this.layer),(e=>{"feature"===e?.type&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=c((()=>this.feature?.geometry),(e=>{this._featureClone.geometry=e;for(const t of this._expressionInvalidationCallbacks)t()}));this.handles.add([F(e),t,i])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get allInputFields(){return this.inputFields.reduce(((e,t)=>T(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():v.clone(),this._initialFeature=this._featureClone.clone(),this.contingencyConstraintViolations.clear(),this._clearInputFieldCache(),this._set("feature",e)}get fieldsWithContingentValues(){if(a(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){null!=e?this._override("formTemplate",e):this._clearOverride("formTemplate")}get inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,formTemplate:s,messages:o,layer:r,state:a,spatialReference:u}=this;if("ready"!==a)return[];const c={arcade:e,feature:t,initialFeature:i,layer:r,messages:o,expressionTrackingProvider:{registerExpression:this._registerExpression.bind(this)},spatialReference:u},p=l(s)&&s.elements.length>0?this._updateInputFieldsFromElements(n,s.elements,c):this._updateInputFieldsFromLayerFields(n,r?.fields,c);return this._inputFieldCache=p,p}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get spatialReference(){return this.layer?.spatialReference||null}set spatialReference(e){void 0===e?this._clearOverride("spatialReference"):this._override("spatialReference",e)}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:i}=this,n=!!i?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);t=""===t?null:t,s&&i.getAttribute(e)!==t&&(s.value=t,n&&!s.valid||this._afterValueChange(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,a(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),r=[...s,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)n.set(e,a);return r}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_updateInputFieldsFromElements(e,t,i){const n=new Map;for(const o of e)if(T(o)){A(n,o.groupElement,o);for(const e of o.inputFields)A(n,e.fieldElement,e)}else A(n,o.fieldElement,o);const s=this._updateInputFieldsRecursive(n,t.filter(this._isSupportedElement),i);for(const[o,r]of n.entries())n.delete(o),r.destroy();return s}_updateInputFieldsRecursive(e,t,i,n=null){const s=[];for(const o of t){const t=e.has(o),r=t?e.get(o):k(o)?this._makeInputFieldGroupFromGroupElement(o,i):this._makeInputFieldFromFieldElement(o,i,n);if(s.push(r),t)if(e.delete(o),T(r)){const{arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s}=i;r.set({arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s})}else r.set(i);if(k(o)){const t=o.elements.filter((e=>this._isSupportedElement(e)));r.inputFields=this._updateInputFieldsRecursive(e,t,i,r)}}return s}_updateInputFieldsFromLayerFields(e,t,i){if(!Array.isArray(t))return E.warn(b,"No attribute fields found."),[];const n=new Map;for(const c of e)if(T(c)){for(const e of c.inputFields)e.destroy();c.inputFields.length=0,c.destroy()}else n.set(c.field,c);const s=[],{feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u}=i;for(const c of t){const e=n.get(c)??new y({field:c,feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u,value:o.getAttribute(c.name)});e.set({fieldElement:null,requiredFunction:null,visibilityFunction:null,valueFunction:null,editableFunction:null}),s.push(e),n.delete(c)}for(const[c,p]of n.entries())n.delete(c),p.destroy();return s}_makeInputFieldFromFieldElement(e,t,i=null){const{arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d}=t,h=new y({fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),requiredFunction:this._getCompiledExpression(e.requiredExpression),visibilityFunction:this._getCompiledExpression(e.visibilityExpression),valueFunction:this._getCompiledExpression(e.valueExpression),editableFunction:this._getCompiledExpression(e.editableExpression),group:i,arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d,value:r.getAttribute(e.fieldName)}),f=`watch-expression-field-${h.id}`,m=c((()=>h.fieldElement),(e=>{this.handles.remove(f),l(e)&&this.handles.add(V.map((t=>c((()=>e[`${t}Expression`]),(async e=>{e&&""!==e&&(h[`${t}Function`]=await this._getOrMakeCompiledExpression(e),h.arcade=this._arcade)}),{initial:!0,sync:!0}))),f)}),{initial:!0,sync:!0}),g=s((()=>this.handles.remove(f))),_=c((()=>h.value),(()=>this._afterValueChange(h)));return h.own([m,g,_]),h}_makeInputFieldGroupFromGroupElement(e,t){const{arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o}=t,r=new _({groupElement:e,visibilityFunction:this._getCompiledExpression(e.visibilityExpression),inputFields:[],arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o});return r.own(c((()=>r.groupElement),(e=>l(e)&&e.own(c((()=>e.visibilityExpression),(async e=>{e&&""!==e&&(r.visibilityFunction=await this._getOrMakeCompiledExpression(e),r.arcade=this._arcade)}),{initial:!0}))),{initial:!0})),r}_clearInputFieldCache(){for(const e of this._inputFieldCache)e.destroy();this._inputFieldCache=[]}_afterValueChange(e){const{name:t,value:i}=e;if(this.get("layer.typeIdField")===t&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}this._featureClone.setAttribute(t,i);for(const n of this._expressionInvalidationCallbacks)n();this._emitChangeEvent(e)}_registerExpression(e){const{_expressionInvalidationCallbacks:t}=this;return t.add(e),s((()=>t.delete(e)))}_getCompiledExpression(e){return this._compiledExpressionLookup.get(this._expressionLookup.get(e))}async _getOrMakeCompiledExpression(e){{if(a(e)||""===e)return null;const t=this._expressionLookup.get(e)??this._addToExpressionLookup(e);if(this._compiledExpressionLookup.has(t))return this._compiledExpressionLookup.get(t);this._arcade||(this._arcade=await g());const i=this._arcade.arcadeUtils;return!this._arcadeGeometryOperationsEnabled&&i.hasGeometryOperations(t)&&(await i.enableGeometryOperations(),this._arcadeGeometryOperationsEnabled=!0),this._addToCompiledExpressionLookup(t)}}_addToCompiledExpressionLookup(e){const{_arcade:{arcadeUtils:t},_compiledExpressionLookup:i}=this,n=t.createFunction(e);return i.set(e,n),n}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:i}=this,n=(l(i)&&l(i.expressionInfos)?Object.values(i.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(E.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(a(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const s=t.get(e),o=l,r=[s.name,o.name].sort().join("|");if(n.has(r))continue;i.push([s,o]),n.add(r),t.set(e,o)}else t.set(e,l);const s=new Set(i.flat()),o=new Set(e);for(const l of s)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(i.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of i){const e=a.get(l),t=a.get(u);if(e===t)continue;const i=r.get(e),n=r.get(t);for(const s of n)i.add(s),a.set(s,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),r=new Map;for(const a of i.contingencies){const[e]=this._hashContingency(a,s.codedValueFields,!0);r.has(e)?r.get(e).push(a):r.set(e,[a])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(r,i):r.get(i);if(r.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,r.get(j),s.codedValueFields)),!a(o))for(const r of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,s.rangeFields):this._joinContingencies(r,t);if(a(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}r=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,r.get(j),s.codedValueFields)),!a(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:c,bothAreAny:p,leftIsRange:d,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(l||p)continue;if(r&&c||a&&u){n.values[s]=new f({objectType:"null"});continue}if(r&&h||a&&d)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{const n=t.values[i],s=e.values[i];return"any"===n.objectType||"any"===s.objectType||n.codedValue?.code===s.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,r=new Set,l=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(a(e))continue;switch(e.type){case"coded-value":r.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...r],rangeFields:[...l]}}_hashContingency(e,t,i=!1){if(t.length<1)return[x,!1];const n=[];let s=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${w}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),s]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([p({readOnly:!0})],I.prototype,"allInputFields",null),e([p()],I.prototype,"_layerFieldsByName",null),e([p()],I.prototype,"_inputFieldCache",void 0),e([p()],I.prototype,"contingencyConstraintViolations",void 0),e([p()],I.prototype,"feature",null),e([p()],I.prototype,"fieldsWithContingentValues",null),e([p({type:h})],I.prototype,"formTemplate",null),e([p({readOnly:!0})],I.prototype,"inputFields",null),e([p()],I.prototype,"joinedContingentValues",null),e([p()],I.prototype,"layer",null),e([p()],I.prototype,"messages",void 0),e([p()],I.prototype,"spatialReference",null),e([p()],I.prototype,"state",null),e([p()],I.prototype,"strict",void 0),e([p()],I.prototype,"submittable",null),e([p()],I.prototype,"valid",null),e([p()],I.prototype,"getValues",null),e([p()],I.prototype,"submit",null),I=e([d(b)],I);const T=e=>!!e.inputFields,k=e=>"group"===e.type,A=(e,t,i)=>{l(t)&&e.set(t,i)},M=I;export{M as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import{makeHandle as s}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{destroyMaybe as r,isNone as a,isSome as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as F}from"../../intl/locale.js";import{fetchMessageBundle as C}from"../../intl/messages.js";const v=new t({attributes:{}}),b="esri.widgets.FeatureForm.FeatureFormViewModel",E=o.getLogger(b),V=["editable","required","value","visibility"],x="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",w="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let I=class extends(n(u(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressionLookup=new Map,this._expressionLookup=new Map,this._expressionInvalidationCallbacks=new Set,this._contingentValuesCache=null,this._featureClone=v.clone(),this._initialFeature=v.clone(),this._arcadeGeometryOperationsEnabled=!1,this._inputFieldCache=[],this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await C("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=c((()=>this.layer),(e=>{"feature"===e?.type&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=c((()=>this.feature?.geometry),(e=>{this._featureClone.geometry=e;for(const t of this._expressionInvalidationCallbacks)t()}));this.handles.add([F(e),t,i])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get allInputFields(){return this.inputFields.reduce(((e,t)=>T(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():v.clone(),this._initialFeature=this._featureClone.clone(),this.contingencyConstraintViolations.clear(),this._clearInputFieldCache(),this._set("feature",e)}get fieldsWithContingentValues(){if(a(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){null!=e?this._override("formTemplate",e):this._clearOverride("formTemplate")}get inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,formTemplate:s,messages:o,layer:r,state:a,spatialReference:u}=this;if("ready"!==a)return[];const c={arcade:e,feature:t,initialFeature:i,layer:r,messages:o,expressionTrackingProvider:{registerExpression:this._registerExpression.bind(this)},spatialReference:u},p=l(s)&&s.elements.length>0?this._updateInputFieldsFromElements(n,s.elements,c):this._updateInputFieldsFromLayerFields(n,r?.fields,c);return this._inputFieldCache=p,p}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get spatialReference(){return this.layer?.spatialReference||null}set spatialReference(e){void 0===e?this._clearOverride("spatialReference"):this._override("spatialReference",e)}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:i}=this,n=!!i?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);t=""===t?null:t,s&&i.getAttribute(e)!==t&&(s.value=t,n&&!s.valid||this._afterValueChange(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,a(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),r=[...s,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)n.set(e,a);return r}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_updateInputFieldsFromElements(e,t,i){const n=new Map;for(const o of e)if(T(o)){A(n,o.groupElement,o);for(const e of o.inputFields)A(n,e.fieldElement,e)}else A(n,o.fieldElement,o);const s=this._updateInputFieldsRecursive(n,t.filter(this._isSupportedElement),i);for(const[o,r]of n.entries())n.delete(o),r.destroy();return s}_updateInputFieldsRecursive(e,t,i,n=null){const s=[];for(const o of t){const t=e.has(o),r=t?e.get(o):k(o)?this._makeInputFieldGroupFromGroupElement(o,i):this._makeInputFieldFromFieldElement(o,i,n);if(s.push(r),t)if(e.delete(o),T(r)){const{arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s}=i;r.set({arcade:e,feature:t,expressionTrackingProvider:n,spatialReference:s})}else r.set(i);if(k(o)){const t=o.elements.filter((e=>this._isSupportedElement(e)));r.inputFields=this._updateInputFieldsRecursive(e,t,i,r)}}return s}_updateInputFieldsFromLayerFields(e,t,i){if(!Array.isArray(t))return E.warn(b,"No attribute fields found."),[];const n=new Map;for(const c of e)if(T(c)){for(const e of c.inputFields)e.destroy();c.inputFields.length=0,c.destroy()}else n.set(c.field,c);const s=[],{feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u}=i;for(const c of t){const e=n.get(c)??new y({field:c,feature:o,initialFeature:r,layer:a,messages:l,spatialReference:u,value:o.getAttribute(c.name)});e.set({fieldElement:null,requiredFunction:null,visibilityFunction:null,valueFunction:null,editableFunction:null}),s.push(e),n.delete(c)}for(const[c,p]of n.entries())n.delete(c),p.destroy();return s}_makeInputFieldFromFieldElement(e,t,i=null){const{arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d}=t,h=new y({fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),requiredFunction:this._getCompiledExpression(e.requiredExpression),visibilityFunction:this._getCompiledExpression(e.visibilityExpression),valueFunction:this._getCompiledExpression(e.valueExpression),editableFunction:this._getCompiledExpression(e.editableExpression),group:i,arcade:n,expressionTrackingProvider:o,feature:r,initialFeature:a,layer:u,messages:p,spatialReference:d,value:r.getAttribute(e.fieldName)}),f=`watch-expression-field-${h.id}`,m=c((()=>h.fieldElement),(e=>{this.handles.remove(f),l(e)&&this.handles.add(V.map((t=>c((()=>e[`${t}Expression`]),(async e=>{e&&""!==e&&(h[`${t}Function`]=await this._getOrMakeCompiledExpression(e),h.arcade=this._arcade)}),{initial:!0,sync:!0}))),f)}),{initial:!0,sync:!0}),g=s((()=>this.handles.remove(f))),_=c((()=>h.value),(()=>this._afterValueChange(h)));return h.own([m,g,_]),h}_makeInputFieldGroupFromGroupElement(e,t){const{arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o}=t,r=new _({groupElement:e,visibilityFunction:this._getCompiledExpression(e.visibilityExpression),inputFields:[],arcade:i,feature:n,expressionTrackingProvider:s,spatialReference:o});return r.own(c((()=>r.groupElement),(e=>l(e)&&e.own(c((()=>e.visibilityExpression),(async e=>{e&&""!==e&&(r.visibilityFunction=await this._getOrMakeCompiledExpression(e),r.arcade=this._arcade)}),{initial:!0}))),{initial:!0})),r}_clearInputFieldCache(){for(const e of this._inputFieldCache){if(T(e))for(const t of e.inputFields)t.destroy();e.destroy()}this._inputFieldCache=[]}_afterValueChange(e){const{name:t,value:i}=e;if(this.get("layer.typeIdField")===t&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}this._featureClone.setAttribute(t,i);for(const n of this._expressionInvalidationCallbacks)n();this._emitChangeEvent(e)}_registerExpression(e){const{_expressionInvalidationCallbacks:t}=this;return t.add(e),s((()=>t.delete(e)))}_getCompiledExpression(e){return this._compiledExpressionLookup.get(this._expressionLookup.get(e))}async _getOrMakeCompiledExpression(e){{if(a(e)||""===e)return null;const t=this._expressionLookup.get(e)??this._addToExpressionLookup(e);if(this._compiledExpressionLookup.has(t))return this._compiledExpressionLookup.get(t);this._arcade||(this._arcade=await g());const i=this._arcade.arcadeUtils;return!this._arcadeGeometryOperationsEnabled&&i.hasGeometryOperations(t)&&(await i.enableGeometryOperations(),this._arcadeGeometryOperationsEnabled=!0),this._addToCompiledExpressionLookup(t)}}_addToCompiledExpressionLookup(e){const{_arcade:{arcadeUtils:t},_compiledExpressionLookup:i}=this,n=t.createFunction(e);return i.set(e,n),n}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:i}=this,n=(l(i)&&l(i.expressionInfos)?Object.values(i.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(E.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(a(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const s=t.get(e),o=l,r=[s.name,o.name].sort().join("|");if(n.has(r))continue;i.push([s,o]),n.add(r),t.set(e,o)}else t.set(e,l);const s=new Set(i.flat()),o=new Set(e);for(const l of s)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(i.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of i){const e=a.get(l),t=a.get(u);if(e===t)continue;const i=r.get(e),n=r.get(t);for(const s of n)i.add(s),a.set(s,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),r=new Map;for(const a of i.contingencies){const[e]=this._hashContingency(a,s.codedValueFields,!0);r.has(e)?r.get(e).push(a):r.set(e,[a])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(r,i):r.get(i);if(r.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,r.get(j),s.codedValueFields)),!a(o))for(const r of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,s.rangeFields):this._joinContingencies(r,t);if(a(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}r=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,r.get(j),s.codedValueFields)),!a(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:c,bothAreAny:p,leftIsRange:d,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(l||p)continue;if(r&&c||a&&u){n.values[s]=new f({objectType:"null"});continue}if(r&&h||a&&d)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{const n=t.values[i],s=e.values[i];return"any"===n.objectType||"any"===s.objectType||n.codedValue?.code===s.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,r=new Set,l=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(a(e))continue;switch(e.type){case"coded-value":r.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...r],rangeFields:[...l]}}_hashContingency(e,t,i=!1){if(t.length<1)return[x,!1];const n=[];let s=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${w}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),s]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([p({readOnly:!0})],I.prototype,"allInputFields",null),e([p()],I.prototype,"_layerFieldsByName",null),e([p()],I.prototype,"_inputFieldCache",void 0),e([p()],I.prototype,"contingencyConstraintViolations",void 0),e([p()],I.prototype,"feature",null),e([p()],I.prototype,"fieldsWithContingentValues",null),e([p({type:h})],I.prototype,"formTemplate",null),e([p({readOnly:!0})],I.prototype,"inputFields",null),e([p()],I.prototype,"joinedContingentValues",null),e([p()],I.prototype,"layer",null),e([p()],I.prototype,"messages",void 0),e([p()],I.prototype,"spatialReference",null),e([p()],I.prototype,"state",null),e([p()],I.prototype,"strict",void 0),e([p()],I.prototype,"submittable",null),e([p()],I.prototype,"valid",null),e([p()],I.prototype,"getValues",null),e([p()],I.prototype,"submit",null),I=e([d(b)],I);const T=e=>!!e.inputFields,k=e=>"group"===e.type,A=(e,t,i)=>{l(t)&&e.set(t,i)},M=I;export{M as default};
|