@arcgis/core 5.0.0-next.30 → 5.0.0-next.31
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/Basemap.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{406d270ae2b3cf9e1f1b.js → 05e55118dc0023d500fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{93fe46be3c7fe34b5361.js → 1432e789aa4cba627337.js} +1 -1
- package/assets/esri/core/workers/chunks/{6e9d731cb20307b83ab0.js → 1e55f152b60145f33b61.js} +1 -1
- package/assets/esri/core/workers/chunks/444026d1938c1078ca97.js +1 -0
- package/assets/esri/core/workers/chunks/{a425ffec91d07bbfeb80.js → 565358ea8d1bdc4d1ebc.js} +1 -1
- package/assets/esri/core/workers/chunks/{d769c1b18e2710e0388b.js → a6324f5f560ffadc6e5d.js} +1 -1
- package/assets/esri/core/workers/chunks/{a091623bbfb3d771c8d8.js → d8db2c51b2fb42f37b2a.js} +1 -1
- package/assets/esri/core/workers/chunks/{984bb0943d07c86b7e77.js → ded3ef385d5a3a2ec8ca.js} +1 -1
- package/config.js +1 -1
- package/core/Message.js +1 -1
- package/geometry/Circle.js +1 -1
- package/geometry/Extent.js +1 -1
- package/geometry/geodesicUtils.js +5 -0
- package/geometry/support/geodesicUtils.js +1 -1
- package/interfaces.d.ts +427 -187
- package/kernel.js +1 -1
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/knowledgeGraph/SessionMemoryStorage.js +1 -1
- package/layers/support/BuildingFilterBlock.js +1 -1
- package/package.json +2 -2
- package/rest/support/QueryMixin.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementController.js +1 -1
- package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementController.js +1 -1
- package/views/2d/grid/gridUtils.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/OGCFeatureLayerView2D.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/environment/SceneViewEnvironment.js +1 -1
- package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
- package/views/3d/layers/DimensionLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImageryLayerView3D.js +1 -1
- package/views/3d/layers/LineOfSightLayerView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/OGCFeatureLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/ViewshedLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DElevationAlignment.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/views/interactive/sketch/constraintUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/layers/DimensionLayerView.js +1 -1
- package/views/layers/DimensionLayerViewMixin.js +5 -0
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/FeatureLayerViewMixin.d.ts +2 -2
- package/views/layers/FeatureLayerViewMixin.js +5 -0
- package/views/layers/ImageryLayerView.js +1 -1
- package/views/layers/ImageryLayerViewMixin.js +5 -0
- package/views/layers/LineOfSightLayerView.js +1 -1
- package/views/layers/LineOfSightLayerViewMixin.js +5 -0
- package/views/layers/MediaLayerView.js +1 -1
- package/views/layers/MediaLayerViewMixin.js +5 -0
- package/views/layers/OGCFeatureLayerView.js +1 -1
- package/views/layers/PointCloudLayerView.js +1 -1
- package/views/layers/StreamLayerView.js +1 -1
- package/views/layers/ViewshedLayerView.js +1 -1
- package/views/layers/ViewshedLayerViewMixin.js +5 -0
- package/views/support/LayerLayerViewInfo.js +1 -1
- package/views/support/PromiseQueue.js +1 -1
- package/views/support/angularMeasurementUtils.js +1 -1
- package/views/support/drapedUtils.js +1 -1
- package/views/support/geodesicAreaMeasurementUtils.js +1 -1
- package/views/support/geodesicLengthMeasurementUtils.js +1 -1
- package/views/support/geodesicMeasurementUtils.js +1 -1
- package/webscene/Environment.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/Attribution.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
- package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
- package/widgets/support/forms/expressions/FormExpressionArcadeExecutor.js +1 -1
- package/assets/esri/core/workers/chunks/b66e41d626a7d1b81d48.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,syncAndInitial as h,on as m}from"../../../core/reactiveUtils.js";import{property as c,subclass as p}from"../../../core/accessorSupport/decorators.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{LayerView3D as _}from"./LayerView3D.js";import{MediaLayerInteraction as f}from"./support/MediaLayerInteraction.js";import{drapedZ as v}from"../terrain/OverlayRenderer.js";import{Attribute as w}from"../webgl-engine/lib/Attribute.js";import{Geometry as E}from"../webgl-engine/lib/Geometry.js";import{ManagedTexture as D}from"../webgl-engine/lib/ManagedTexture.js";import{Object3DHighlightStateID as R}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as b}from"../webgl-engine/lib/RenderGeometry.js";import{ImageMaterial as j}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,syncAndInitial as h,on as m}from"../../../core/reactiveUtils.js";import{property as c,subclass as p}from"../../../core/accessorSupport/decorators.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{LayerView3D as _}from"./LayerView3D.js";import{MediaLayerInteraction as f}from"./support/MediaLayerInteraction.js";import{drapedZ as v}from"../terrain/OverlayRenderer.js";import{Attribute as w}from"../webgl-engine/lib/Attribute.js";import{Geometry as E}from"../webgl-engine/lib/Geometry.js";import{ManagedTexture as D}from"../webgl-engine/lib/ManagedTexture.js";import{Object3DHighlightStateID as R}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as b}from"../webgl-engine/lib/RenderGeometry.js";import{ImageMaterial as j}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import{MediaLayerViewMixin as M}from"../../layers/MediaLayerViewMixin.js";import{getHighlightName as A}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as H}from"../../support/layerViewUtils.js";let G=class extends(_(M(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return H(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=1,this.updatePolicy=1,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o(async(e,t,i)=>{const r=await this._collectMediaElements(e,t,i);this._synchronizeRenderElements(r)},0);const{view:t,layer:i}=e;this._interaction=new f({view:t,layer:i}),this.addHandles(l(()=>this.interactionOptions,e=>this._interaction.options=e,h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.overlayManager.registerGeometryDrapeSource(this);const r=()=>this._updateWithLastDrapingExtent();this.addHandles([i(()=>e.overlayManager.unregisterDrapeSource(this)),m(()=>t.effectiveSource,"change",r),m(()=>t.effectiveSource,"refresh",r)]),this._updatingHandles.add(()=>this.suspended,r)}destroy(){this._synchronizeRenderElements(new Set)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const r=A(t),n=new R(r),a=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(n,a);for(const i of a){const e=this._highlightedElements.get(i);e?e.add(n):this._highlightedElements.set(i,new Set([n]));const t=this._renderElements.get(i)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(n),this._renderer.modifyGeometries([t.renderGeometry],8))}return i(()=>{const e=this._elementsInHighlightedId.get(n);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(n);const i=this._renderElements.get(t)?.getRenderData();i&&(i.renderGeometry.geometry.removeHighlight(n),this._renderer.modifyGeometries([i.renderGeometry],8)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(n)}})}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch(()=>{}))}async _collectMediaElements(e,t,i){const r=this.layer.effectiveSource;return null==r?new Set:new Set((await Promise.all(e.map(e=>r.queryElements(u(e.extent,t),{signal:i})))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach((t,i)=>{e.has(i)||(this._removeElement(i,t),this.emit("element-render-changed",{element:i}))})}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),i=new I(r([this._updatingHandles.add(()=>e.opacity,e=>i.getRenderData()?.material.setParameters({opacity:e})),this._updatingHandles.add(()=>t.coords,()=>{i.data?this._updateGeometry(t,i):this._initializeRenderData(t,i)}),this._updatingHandles.add(()=>e.content,()=>this._initializeRenderData(t,i)),n(t)]));this._renderElements.set(e,i),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch(()=>{})),this._initializeRenderData(t,i)}_initializeRenderData(e,t){const{coords:i,element:r}=e,{contentWidth:n,contentHeight:s}=r;if(null==i||null==r.content)return void this._destroyRenderData(r,t);if(t.data)return;const a=this._createTexture(r.content),o=a.load(this.view.stage.renderView.renderingContext),l=()=>{if(!a.loaded)return;this.view.stage.addTexture(a);const e=new j({draped:!0,managedTexture:a,opacity:r.opacity,perspectiveInterpolation:!0}),o=this._getPositionAttributeArray(i),d=[0,0,1,0,1,1,0,1],l=this._getPerspectiveDivideAttributeArray(o,n,s),h=[0,1,2,0,2,3],m=new E(e,[["position",new w(o,h,3,!0)],["uv0",new w(d,h,2,!0)],["perspectiveDivide",new w(l,h,1,!0)]]),c=new b(m,{layerViewUid:this.uid,graphicUid:r.uid}),p=this._highlightedElements.get(r);p?.forEach(e=>c.geometry.addHighlight(e)),this._renderer.addGeometries([c],0),t.data=new z(c,a,e),this.emit("element-render-changed",{element:r})};d(o)?(t.data=a,this._updatingHandles.addPromise(o),o.then(l).catch(()=>a.dispose())):l()}_updateGeometry(e,t){const{coords:i,element:r}=e;if(null==i||null==r.content)return void this._destroyRenderData(r,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(i);n.renderGeometry.geometry.setAttributeData("position",s);const a=this._getPerspectiveDivideAttributeArray(s,r.contentWidth,r.contentHeight);n.renderGeometry.geometry.setAttributeData("perspectiveDivide",a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],2),this.emit("element-render-changed",{element:r})}_getPositionAttributeArray(e){const[t,i,r,n]=e.rings[0];return[t[0],t[1],v,n[0],n[1],v,r[0],r[1],v,i[0],i[1],v]}_getPerspectiveDivideAttributeArray(e,t,i){a(S,[0,0,t,0,t,i,0,i],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const r=S[6]/S[8]*t,n=S[7]/S[8]*i;return[1,1+r,1+r+n,1+n]}_destroyRenderData(e,t){const i=t.data;if(null==i)return;if(t.data=null,"dispose"in i)return void i.dispose();const r=i.texture;r.unload(),this.view.stage.removeTexture(r),this._renderer.removeGeometries([i.renderGeometry],2),this.emit("element-render-changed",{element:e})}_createTexture(e){const i=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new D(e,{wrap:{s:33071,t:33071},preMultiplyAlpha:!0,width:i,height:r,mipmap:!0,updateCallback:()=>this.view.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],G.prototype,"type",void 0),e([c()],G.prototype,"layer",void 0),e([c()],G.prototype,"interactive",null),e([c()],G.prototype,"selectedElement",null),e([c({readOnly:!0})],G.prototype,"visibleAtCurrentScale",null),G=e([p("esri.views.3d.layers.MediaLayerView3D")],G);const S=g();class I{constructor(e){this.handle=e}getRenderData(){return this.data&&"type"in this.data&&"RenderData"===this.data.type?this.data:null}}class z{constructor(e,t,i){this.renderGeometry=e,this.texture=t,this.material=i,this.type="RenderData"}}const T=G;export{T 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import r from"../../../core/Error.js";import{property as i,subclass as t}from"../../../core/accessorSupport/decorators.js";import a from"./FeatureLayerViewBase3D.js";import{
|
|
5
|
+
import{__decorate as e}from"tslib";import r from"../../../core/Error.js";import{property as i,subclass as t}from"../../../core/accessorSupport/decorators.js";import a from"./FeatureLayerViewBase3D.js";import{OGCFeatureLayerViewMixin as s}from"../../layers/OGCFeatureLayerView.js";let o=class extends(s(a)){constructor(){super(...arguments),this.type="ogc-feature-3d"}get graphicOrigin(){return this.layer.graphicOrigin}initialize(){this.layer.serviceSupportsSpatialReference(this.view.spatialReference)||this.addResolvingPromise(Promise.reject(new r("layerview:spatial-reference-incompatible","The spatial references supported by this OGC layer are incompatible with the spatial reference of the view",{layer:this.layer})))}};e([i()],o.prototype,"layer",void 0),e([i()],o.prototype,"graphicOrigin",null),o=e([t("esri.views.3d.layers.OGCFeatureLayerView3D")],o);const p=o;export{p 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../request.js";import{isSome as r}from"../../../core/arrayUtils.js";import{result as s,forEach as o}from"../../../core/asyncUtils.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{estimateNumberArrayMemory as l,baseObjectMemory as u,estimateNumberMemory as h,estimateFixedArrayMemory as p,baseArrayMemory as c}from"../../../core/memoryEstimations.js";import{isAbortError as _,allSettledValues as m,throwIfAborted as g}from"../../../core/promiseUtils.js";import{initial as f,watch as y,sync as b,syncAndInitial as w}from"../../../core/reactiveUtils.js";import{pt2px as P}from"../../../core/screenUtils.js";import{isArrayBuffer as N}from"../../../core/typedArrayUtil.js";import{property as v,subclass as x}from"../../../core/accessorSupport/decorators.js";import{b as C,i as S,g as I,d as A}from"../../../chunks/vec32.js";import{clone as j}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import k from"../../../geometry/Extent.js";import V from"../../../geometry/Point.js";import{projectBoundingSphere as Q}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as E,fromMinMax as O}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as D,create as L}from"../../../geometry/support/plane.js";import{Sphere as U}from"../../../geometry/support/sphere.js";import W from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as G}from"../../../layers/graphics/data/QueryEngine.js";import{CodedValue as M}from"../../../layers/support/CodedValue.js";import q from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as z}from"../../../layers/support/fieldUtils.js";import{queueAutoPriority as H}from"../../../request/queue.js";import T from"../../../rest/support/FeatureSet.js";import B from"../../../rest/support/Query.js";import{getElevationOffset as $}from"../../../support/elevationInfoUtils.js";import{LayerView3D as J}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as K,QueuePerformanceInfo as Z}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as Y}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as X}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as ee,checkPointCloudLayerCompatibleWithView as te}from"./i3s/I3SUtil.js";import{nodeDiff as ie,sortFrontToBack as re,splitWorkEntries as se}from"./i3s/LoDUtil.js";import{PagedNodeIndex as oe}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as ne}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as ae}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as de,PointCloudRendererNode as le}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as ue,getFixedSizeAlgorithm as he,getRendererInfo as pe,getFilterInfo as ce,rendererUsesFixedSizes as _e,getAttributeInfo as me}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as ge,readGeometry as fe,elevationFromPositions as ye}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as be,emptyHighlightHandle as we}from"./support/highlightUtils.js";import{PopupSceneLayerView as Pe}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as Ne}from"../support/extentUtils.js";import{computeMapPointFromVec3d as ve}from"../support/hitTest.js";import{Obb as xe}from"../support/orientedBoundingBox.js";import{updatingProgress as Ce}from"../support/updatingProperties.js";import Se from"../../layers/LayerView.js";import{PointCloudLayerView as Ie}from"../../layers/PointCloudLayerView.js";import{getHighlightName as Ae}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as je}from"../../support/layerViewUtils.js";import{PromiseQueue as Re}from"../../support/PromiseQueue.js";import{TaskPriority as ke}from"../../support/Scheduler.js";const Ve=8,Qe=L();let Fe=class extends(Ie(Pe(J(Se)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Re,this._loadingPages=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=ue(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=he(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=he(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=pe(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=ce(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of z(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=E(),t=this.view.renderSpatialReference;return Ne(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return"absolute-height"===e?.mode?$(e,this.layer.spatialReference):0}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){const e=this.view.resourceController,t=Ue(e);this._worker=new Y(t),this.addResolvingPromise(this._worker.promise),this.addResolvingPromise(this.layer.rootPagePromise),ee(this.layer),te(this.layer,this.view),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),f),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),f),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([y(()=>this.view.quality,()=>this._setUpdateViewNeeded(),b)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(ke.POINT_CLOUD_LAYER,this),y(()=>2===this.view.state.mode,()=>this._setUpdateViewNeeded(),w),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},f)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._queryFeaturesCache=a(this._queryFeaturesCache),this._queryEngine=a(this._queryEngine),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ae({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,f),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),f),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,f),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,f),this._updatingHandles.add(()=>this.pointSize,e=>{const t=P(e);this._renderer.size=e,this._renderer.sizePx=t},f),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,f),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloudLoDFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},f)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:ve(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new ne({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=_e(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=ie([...this._renderedNodes],e,this._index),re(this._workQueue,this.view.state.contentCamera.viewForward,this._index),se(this._workQueue,Ve,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){[...this._loadingNodes.values()].forEach(e=>e.abort()),this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array;this._loadingNodes.forEach((i,r)=>{e.has(r)||(this._loadingNodes.delete(r),t.push(i))}),t.forEach(e=>e.abort()),this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._loadingPages.forEach(e=>e.abort()),this._loadingPages.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}get readyToRun(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.readyToRun}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&!e.done;)this._processIndexQueue(),e.madeProgress();this._processWorkQueue(e),this._idleQueue.runTask(e)}}async _processIndexQueue(){const e=this._indexQueue.shift(),t=new AbortController;this._loadingPages.set(e,t);try{const i=await this._loadNodePage(e,t.signal);this._index.addPage(e,i,this._elevationOffset),this._setUpdateViewNeeded(),this._loadingPages.delete(e)}catch(i){this._loadingPages.get(e)===t&&this._loadingPages.delete(e)}}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}async _processWorkEntry(e){if(0===e.load.length){for(const t of e.remove)this._removeFromRenderer(t);return}const t=e.load.map(e=>{const t=new AbortController;return this._loadingNodes.set(e,t),t});this._updateLoading();try{const i=await Promise.all(e.load.map((e,i)=>this._memCache.pop(`${e}`)??this._loadNode(e,t[i].signal)));for(let t=0;t<e.load.length;t++)if(i[t]){const r=this._setupRendererData(e.load[t],i[t]);this._addToRenderer(r)}for(const t of e.remove)this._removeFromRenderer(t);for(const t of e.load)this._loadingNodes.delete(t)}catch(i){e.load.forEach((e,i)=>{this._loadingNodes.get(e)===t[i]&&this._loadingNodes.delete(e)})}this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",r=this.layer.fieldsIndex.get(i);if(!r||r.domain)return;if(!e.includes(r.name))return;const o=await s(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(r.domain=new q({name:"CLASS_CODE",codedValues:n.map(e=>new M({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const i=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,n=t.map(e=>me(s,e)).filter(r),a=async(e,t)=>{const i=this._index.getNode(t);await o(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return i.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof ne&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?ge({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=fe(t,await this._loadGeometry(e,null));return ye(i,i.length/3)}highlight(e,i){const r=be(e);if(0===r.length)return we;if(!(r[0]instanceof t))return we;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),Ae(i))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._loadingPages.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return je(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=T.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i.layer=this.layer,i.sourceLayer=this.layer,i.origin=this._graphicOrigin,i}const s=e.geometry?V.fromJSON(e.geometry):void 0;return s&&(s.spatialReference=o.spatialReference??n),this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new B(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:k.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new B({outSpatialReference:this.view.spatialReference}).toJSON():B.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new G({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new X({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{this._renderer.forEachNode(i=>{if(t){const e=i.obb,r=new U(e.center,C(e.halfSize));Q(r,this.view.renderSpatialReference,r,this.view.spatialReference);if(1===t(r))return}let r=this._queryFeaturesCache.get(`${i.id}`);r||(r=this._createQueryPointFeatures(i),this._queryFeaturesCache.put(`${i.id}`,r)),r.features.forEach(e)})},getFeatureExtent:({point:e},t)=>O(e,e,t),featureAdapter:{cloneWithGeometry:(e,t)=>new Oe(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=R(t[s+0],t[s+1],t[s+2]);S(o,o,e.origin),F(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Oe(e,r,o);i.push(n)}return new De(i)}async _initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;this._index=new oe(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock;const i=await this.layer.rootPagePromise;this._loadingInitNodePage=!1,i?(this._index.addPage(0,this._processJSONNodes(i,0),this._elevationOffset),this._setUpdateViewNeeded()):n.getLogger(this).error("Point cloud layer root page not loaded")}_loadNodePage(e,t){const i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return this._requestNodePage(i,t).then(t=>this._processJSONNodes(t,e))}_processJSONNodes(e,t){const i=t*this._index.pageSize;return e.nodes.map((e,t)=>({resourceId:e.resourceId??i+t,obb:xe.fromJSON(e.obb),obbInRenderSR:new xe,firstChild:e.firstChild,childCount:e.childCount,vertexCount:e.vertexCount??e.pointCount,lodThreshold:e.lodThreshold??e.effectiveArea}))}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=I(s,t.eye),n=D(s,-o,Qe),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw _(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const s=this.layer.outFields;if(!s)return[];const o=z(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const r of o){if(n.has(r))continue;const e=me(a,r);e&&d.push(t(e))}const l=await m(d);return g(i),l.filter(r)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=pe(this.layer),s=ce(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,m,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);g(t);const w={geometryBuffer:_,primaryAttributeData:m,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}async _requestNodePage(e,t){const r={f:"json",...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"json",signal:t};return(await i(e,s)).data}async _requestData(e,t){const r={...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"array-buffer",signal:t};return(await i(e,s)).data}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(`${t.id}`,t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(de(t))return t.splatSize=r,t.obb=s,A(t.origin,t.obb.center),t;const o=xe.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0===--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new le(e,r,j(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=Le,e+=l(t.coordinates);for(const i of t.attributes){const t=i.values;N(t.buffer)&&(e+=l(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Le)/t)+i*Le}get performanceInfo(){return new K(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new Z(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([v()],Fe.prototype,"layer",void 0),e([v()],Fe.prototype,"baseUrl",null),e([v()],Fe.prototype,"pointScale",null),e([v()],Fe.prototype,"useRealWorldSymbolSizes",null),e([v()],Fe.prototype,"pointSize",null),e([v()],Fe.prototype,"inverseDensity",null),e([v()],Fe.prototype,"maximumPointCount",void 0),e([v({readOnly:!0})],Fe.prototype,"availableFields",null),e([v({readOnly:!0})],Fe.prototype,"_clippingBox",null),e([v({readOnly:!0})],Fe.prototype,"_elevationOffset",null),e([v({type:Boolean})],Fe.prototype,"slicePlaneEnabled",void 0),e([v()],Fe.prototype,"_graphicOrigin",null),e([v()],Fe.prototype,"updating",void 0),e([v(Ce)],Fe.prototype,"updatingProgress",void 0),e([v({readOnly:!0})],Fe.prototype,"updatingProgressValue",null),e([v({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),Fe=e([x("esri.views.3d.layers.PointCloudLayerView3D")],Fe);const Ee=Fe;class Oe{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new W([],Array.from(this.point),!0,!1)}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return u+u+h+p(this.point,h)}}class De{constructor(e){this.features=e}get usedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,u+c)}}const Le=160;function Ue(e){return t=>e.immediate.schedule(t)}export{Ee as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../request.js";import{isSome as r}from"../../../core/arrayUtils.js";import{result as s,forEach as o}from"../../../core/asyncUtils.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{estimateNumberArrayMemory as l,baseObjectMemory as u,estimateNumberMemory as h,estimateFixedArrayMemory as p,baseArrayMemory as c}from"../../../core/memoryEstimations.js";import{isAbortError as _,allSettledValues as m,throwIfAborted as g}from"../../../core/promiseUtils.js";import{initial as f,watch as y,sync as b,syncAndInitial as w}from"../../../core/reactiveUtils.js";import{pt2px as P}from"../../../core/screenUtils.js";import{isArrayBuffer as N}from"../../../core/typedArrayUtil.js";import{property as v,subclass as x}from"../../../core/accessorSupport/decorators.js";import{b as C,i as S,g as I,d as A}from"../../../chunks/vec32.js";import{clone as j}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import k from"../../../geometry/Extent.js";import V from"../../../geometry/Point.js";import{projectBoundingSphere as Q}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as E,fromMinMax as O}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as D,create as L}from"../../../geometry/support/plane.js";import{Sphere as U}from"../../../geometry/support/sphere.js";import W from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as G}from"../../../layers/graphics/data/QueryEngine.js";import{CodedValue as M}from"../../../layers/support/CodedValue.js";import q from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as z}from"../../../layers/support/fieldUtils.js";import{queueAutoPriority as H}from"../../../request/queue.js";import T from"../../../rest/support/FeatureSet.js";import B from"../../../rest/support/Query.js";import{getElevationOffset as $}from"../../../support/elevationInfoUtils.js";import{LayerView3D as J}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as K,QueuePerformanceInfo as Z}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as Y}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as X}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as ee,checkPointCloudLayerCompatibleWithView as te}from"./i3s/I3SUtil.js";import{nodeDiff as ie,sortFrontToBack as re,splitWorkEntries as se}from"./i3s/LoDUtil.js";import{PagedNodeIndex as oe}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as ne}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as ae}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as de,PointCloudRendererNode as le}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as ue,getFixedSizeAlgorithm as he,getRendererInfo as pe,getFilterInfo as ce,rendererUsesFixedSizes as _e,getAttributeInfo as me}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as ge,readGeometry as fe,elevationFromPositions as ye}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as be,emptyHighlightHandle as we}from"./support/highlightUtils.js";import{PopupSceneLayerView as Pe}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as Ne}from"../support/extentUtils.js";import{computeMapPointFromVec3d as ve}from"../support/hitTest.js";import{Obb as xe}from"../support/orientedBoundingBox.js";import{updatingProgress as Ce}from"../support/updatingProperties.js";import Se from"../../layers/LayerView.js";import{PointCloudLayerViewMixin as Ie}from"../../layers/PointCloudLayerView.js";import{getHighlightName as Ae}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as je}from"../../support/layerViewUtils.js";import{PromiseQueue as Re}from"../../support/PromiseQueue.js";import{TaskPriority as ke}from"../../support/Scheduler.js";const Ve=8,Qe=L();let Fe=class extends(Ie(Pe(J(Se)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Re,this._loadingPages=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=ue(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=he(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=he(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=pe(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=ce(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of z(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=E(),t=this.view.renderSpatialReference;return Ne(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return"absolute-height"===e?.mode?$(e,this.layer.spatialReference):0}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){const e=this.view.resourceController,t=Ue(e);this._worker=new Y(t),this.addResolvingPromise(this._worker.promise),this.addResolvingPromise(this.layer.rootPagePromise),ee(this.layer),te(this.layer,this.view),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),f),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),f),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([y(()=>this.view.quality,()=>this._setUpdateViewNeeded(),b)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(ke.POINT_CLOUD_LAYER,this),y(()=>2===this.view.state.mode,()=>this._setUpdateViewNeeded(),w),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},f)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._queryFeaturesCache=a(this._queryFeaturesCache),this._queryEngine=a(this._queryEngine),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ae({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,f),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),f),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,f),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,f),this._updatingHandles.add(()=>this.pointSize,e=>{const t=P(e);this._renderer.size=e,this._renderer.sizePx=t},f),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,f),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloudLoDFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},f)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:ve(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new ne({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=_e(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=ie([...this._renderedNodes],e,this._index),re(this._workQueue,this.view.state.contentCamera.viewForward,this._index),se(this._workQueue,Ve,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){[...this._loadingNodes.values()].forEach(e=>e.abort()),this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array;this._loadingNodes.forEach((i,r)=>{e.has(r)||(this._loadingNodes.delete(r),t.push(i))}),t.forEach(e=>e.abort()),this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._loadingPages.forEach(e=>e.abort()),this._loadingPages.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}get readyToRun(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.readyToRun}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&!e.done;)this._processIndexQueue(),e.madeProgress();this._processWorkQueue(e),this._idleQueue.runTask(e)}}async _processIndexQueue(){const e=this._indexQueue.shift(),t=new AbortController;this._loadingPages.set(e,t);try{const i=await this._loadNodePage(e,t.signal);this._index.addPage(e,i,this._elevationOffset),this._setUpdateViewNeeded(),this._loadingPages.delete(e)}catch(i){this._loadingPages.get(e)===t&&this._loadingPages.delete(e)}}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}async _processWorkEntry(e){if(0===e.load.length){for(const t of e.remove)this._removeFromRenderer(t);return}const t=e.load.map(e=>{const t=new AbortController;return this._loadingNodes.set(e,t),t});this._updateLoading();try{const i=await Promise.all(e.load.map((e,i)=>this._memCache.pop(`${e}`)??this._loadNode(e,t[i].signal)));for(let t=0;t<e.load.length;t++)if(i[t]){const r=this._setupRendererData(e.load[t],i[t]);this._addToRenderer(r)}for(const t of e.remove)this._removeFromRenderer(t);for(const t of e.load)this._loadingNodes.delete(t)}catch(i){e.load.forEach((e,i)=>{this._loadingNodes.get(e)===t[i]&&this._loadingNodes.delete(e)})}this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",r=this.layer.fieldsIndex.get(i);if(!r||r.domain)return;if(!e.includes(r.name))return;const o=await s(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(r.domain=new q({name:"CLASS_CODE",codedValues:n.map(e=>new M({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const i=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,n=t.map(e=>me(s,e)).filter(r),a=async(e,t)=>{const i=this._index.getNode(t);await o(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return i.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof ne&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?ge({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=fe(t,await this._loadGeometry(e,null));return ye(i,i.length/3)}highlight(e,i){const r=be(e);if(0===r.length)return we;if(!(r[0]instanceof t))return we;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),Ae(i))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._loadingPages.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return je(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=T.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i.layer=this.layer,i.sourceLayer=this.layer,i.origin=this._graphicOrigin,i}const s=e.geometry?V.fromJSON(e.geometry):void 0;return s&&(s.spatialReference=o.spatialReference??n),this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new B(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:k.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new B({outSpatialReference:this.view.spatialReference}).toJSON():B.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new G({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new X({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{this._renderer.forEachNode(i=>{if(t){const e=i.obb,r=new U(e.center,C(e.halfSize));Q(r,this.view.renderSpatialReference,r,this.view.spatialReference);if(1===t(r))return}let r=this._queryFeaturesCache.get(`${i.id}`);r||(r=this._createQueryPointFeatures(i),this._queryFeaturesCache.put(`${i.id}`,r)),r.features.forEach(e)})},getFeatureExtent:({point:e},t)=>O(e,e,t),featureAdapter:{cloneWithGeometry:(e,t)=>new Oe(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=R(t[s+0],t[s+1],t[s+2]);S(o,o,e.origin),F(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Oe(e,r,o);i.push(n)}return new De(i)}async _initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;this._index=new oe(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock;const i=await this.layer.rootPagePromise;this._loadingInitNodePage=!1,i?(this._index.addPage(0,this._processJSONNodes(i,0),this._elevationOffset),this._setUpdateViewNeeded()):n.getLogger(this).error("Point cloud layer root page not loaded")}_loadNodePage(e,t){const i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return this._requestNodePage(i,t).then(t=>this._processJSONNodes(t,e))}_processJSONNodes(e,t){const i=t*this._index.pageSize;return e.nodes.map((e,t)=>({resourceId:e.resourceId??i+t,obb:xe.fromJSON(e.obb),obbInRenderSR:new xe,firstChild:e.firstChild,childCount:e.childCount,vertexCount:e.vertexCount??e.pointCount,lodThreshold:e.lodThreshold??e.effectiveArea}))}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=I(s,t.eye),n=D(s,-o,Qe),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw _(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const s=this.layer.outFields;if(!s)return[];const o=z(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const r of o){if(n.has(r))continue;const e=me(a,r);e&&d.push(t(e))}const l=await m(d);return g(i),l.filter(r)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=pe(this.layer),s=ce(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,m,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);g(t);const w={geometryBuffer:_,primaryAttributeData:m,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}async _requestNodePage(e,t){const r={f:"json",...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"json",signal:t};return(await i(e,s)).data}async _requestData(e,t){const r={...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"array-buffer",signal:t};return(await i(e,s)).data}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(`${t.id}`,t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(de(t))return t.splatSize=r,t.obb=s,A(t.origin,t.obb.center),t;const o=xe.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0===--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new le(e,r,j(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=Le,e+=l(t.coordinates);for(const i of t.attributes){const t=i.values;N(t.buffer)&&(e+=l(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Le)/t)+i*Le}get performanceInfo(){return new K(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new Z(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([v()],Fe.prototype,"layer",void 0),e([v()],Fe.prototype,"baseUrl",null),e([v()],Fe.prototype,"pointScale",null),e([v()],Fe.prototype,"useRealWorldSymbolSizes",null),e([v()],Fe.prototype,"pointSize",null),e([v()],Fe.prototype,"inverseDensity",null),e([v()],Fe.prototype,"maximumPointCount",void 0),e([v({readOnly:!0})],Fe.prototype,"availableFields",null),e([v({readOnly:!0})],Fe.prototype,"_clippingBox",null),e([v({readOnly:!0})],Fe.prototype,"_elevationOffset",null),e([v({type:Boolean})],Fe.prototype,"slicePlaneEnabled",void 0),e([v()],Fe.prototype,"_graphicOrigin",null),e([v()],Fe.prototype,"updating",void 0),e([v(Ce)],Fe.prototype,"updatingProgress",void 0),e([v({readOnly:!0})],Fe.prototype,"updatingProgressValue",null),e([v({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),Fe=e([x("esri.views.3d.layers.PointCloudLayerView3D")],Fe);const Ee=Fe;class Oe{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new W([],Array.from(this.point),!0,!1)}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return u+u+h+p(this.point,h)}}class De{constructor(e){this.features=e}get usedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,u+c)}}const Le=160;function Ue(e){return t=>e.immediate.schedule(t)}export{Ee as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import r from"../../../core/Error.js";import{watch as t}from"../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../core/accessorSupport/decorators.js";import o from"../../../rest/support/Query.js";import{isNumber as n}from"../../../support/guards.js";import{FeatureLikeLayerView3D as a}from"./FeatureLikeLayerView3D.js";import{LayerView3D as p}from"./LayerView3D.js";import{StreamController as c}from"./graphics/StreamController.js";import{StreamGraphics3DGraphicsPipeline as l}from"./graphics/StreamGraphics3DGraphicsPipeline.js";import u from"../../layers/LayerView.js";import{
|
|
5
|
+
import{__decorate as e}from"tslib";import r from"../../../core/Error.js";import{watch as t}from"../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../core/accessorSupport/decorators.js";import o from"../../../rest/support/Query.js";import{isNumber as n}from"../../../support/guards.js";import{FeatureLikeLayerView3D as a}from"./FeatureLikeLayerView3D.js";import{LayerView3D as p}from"./LayerView3D.js";import{StreamController as c}from"./graphics/StreamController.js";import{StreamGraphics3DGraphicsPipeline as l}from"./graphics/StreamGraphics3DGraphicsPipeline.js";import u from"../../layers/LayerView.js";import{StreamLayerViewMixin as h}from"../../layers/StreamLayerView.js";let y=class extends(h(a(p(u)))){constructor(){super(...arguments),this.type="stream-3d",this.updatePolicy=0,this.hasZ=!0,this.hasM=!1,this.featureEffect=null}initialize(){this.addHandles(t(()=>this.suspended,e=>{this.graphicsPipeline&&this._onSuspendedChange(e)}))}get connectionError(){const e=this.graphicsPipeline?.connection?.errorString;return e?new r("stream-controller",e):null}get graphicOrigin(){return this.layer.graphicOrigin}createQuery(){return new o({outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference})}queryLatestObservations(e,r){return this.graphicsPipeline.graphicsQuery.executeQueryForLatestObservations(this._ensureQuery(e),r?.signal)}async queryObjectIds(e,r){return(await super.queryObjectIds(e,r)).filter(n)}get _streamConnectionStatus(){return this.graphicsPipeline?.connection?.connectionStatus??"disconnected"}async createGraphicsPipeline(){return new l({layerView:this})}createController(){return new c({layer:this.layer,layerView:this})}beforeSetController(){}_doPause(){this.graphicsPipeline?.pause()}_doResume(){this.graphicsPipeline?.resume()}_doDisconnect(){this.graphicsPipeline?.disconnect(),this._doPause()}_doConnect(){this.graphicsPipeline?.connect(),this.resume()}_doClear(){this.graphicsPipeline?.clear()}};e([i({readOnly:!0})],y.prototype,"updatePolicy",void 0),e([i({readOnly:!0})],y.prototype,"connectionError",null),e([i()],y.prototype,"graphicsPipeline",void 0),e([i({readOnly:!0})],y.prototype,"hasZ",void 0),e([i({readOnly:!0})],y.prototype,"hasM",void 0),e([i()],y.prototype,"featureEffect",void 0),e([i()],y.prototype,"graphicOrigin",null),e([i({readOnly:!0})],y.prototype,"_streamConnectionStatus",null),y=e([s("esri.views.3d.layers.StreamLayerView3D")],y);const d=y;export{d 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as s}from"tslib";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerView3D as a}from"./LayerView3D.js";import{LayerViewAnalysisViewManager as r}from"./support/LayerViewAnalysisViewManager.js";import t from"../../layers/LayerView.js";import o
|
|
5
|
+
import{__decorate as s}from"tslib";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerView3D as a}from"./LayerView3D.js";import{LayerViewAnalysisViewManager as r}from"./support/LayerViewAnalysisViewManager.js";import t from"../../layers/LayerView.js";import{ViewshedLayerViewMixin as o}from"../../layers/ViewshedLayerViewMixin.js";var n;let l=class extends(a(o(t))){static{n=this}constructor(s){super(s),this.type="viewshed-3d",this._analysisViewManager=null}initialize(){this._analysisViewManager=new r({getAnalysis:()=>this.layer.source,loadAnalysisViewModule:n.loadAnalysisViewModule,parent:this}),this.addResolvingPromise(this._analysisViewManager.whenAnalysisView())}destroy(){this._analysisViewManager.destroy()}get analysisView(){return this._analysisViewManager.analysisView}whenAnalysisView(){return this._analysisViewManager.whenAnalysisView()}isUpdating(){return this._analysisViewManager.updating}static{this.loadAnalysisViewModule=()=>import("../analysis/ViewshedAnalysisView3D.js")}};s([e()],l.prototype,"type",void 0),s([e()],l.prototype,"_analysisViewManager",void 0),s([e({readOnly:!0})],l.prototype,"analysisView",null),l=n=s([i("esri.views.3d.layers.ViewshedLayerView3D")],l);const y=l;export{y 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{EventEmitter as i}from"../../../../core/Evented.js";import{watch as r}from"../../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{ExtentSet as n}from"./ExtentSet.js";import{TaskPriority as o}from"../../../support/Scheduler.js";let h=class extends e{constructor(t){super(t),this._dirtyExtents=new n,this._globalDirty=!1,this._averageExtentUpdateSize=0,this._dirtyGraphicsSet=new Set,this._updateElevation=!1,this.graphicsCoreOwner=null,this.graphicsCore=null,this.events=new i}initialize(){const t=this.elevationProvider,e=this.graphicsCoreOwner.view.resourceController.scheduler;this._task=e.registerTask(p(this.graphicsCore.layer.elevationInfo?.mode),this),this.addHandles([t.on("elevation-change",t=>this._elevationChanged(t)),r(()=>this.graphicsCoreOwner.suspended,()=>this._suspendedChange()),this._task,r(()=>p(this.graphicsCore.layer.elevationInfo?.mode),t=>this._task.priority=t)])}destroy(){this._dirtyGraphicsSet.clear(),this.graphicsCoreOwner=null,this.graphicsCore=null,this.queryGraphicUIDsInExtent=null,this.elevationProvider=null,this._dirtyExtents.destroy()}clear(){this._dirtyGraphicsSet.clear(),this.notifyChange("updating")}_suspendedChange(){!0===this.graphicsCoreOwner.suspended?this._updateElevation=!1:!1===this.graphicsCoreOwner.suspended&&this._updateElevation&&(this._globalDirty=!0,this.notifyChange("updating"))}elevationInfoChange(){this._globalDirty=!0,this.notifyChange("updating")}get updating(){return this.readyToRun}get readyToRun(){return this._dirtyGraphicsSet.size>0||this._dirtyExtents&&!this._dirtyExtents.empty||this._globalDirty}get updatingRemaining(){return this._dirtyGraphicsSet.size+this._dirtyExtents.size*this._averageExtentUpdateSize}runTask(t){for(this._globalDirty&&(this._markAllGraphicsElevationDirty(),this._globalDirty=!1,t.madeProgress()),t.run(()=>this._dirtyExtents.merge(t));this.readyToRun&&!t.done;)this._updateDirtyGraphics(t),this._updateDirtyExtents(t);this.notifyChange("updating")}_updateDirtyGraphics(t){const e=this.graphicsCoreOwner.view.renderCoordsHelper,i=0===this.graphicsCore.effectiveUpdatePolicy;for(const r of this._dirtyGraphicsSet.keys()){const s=this.graphicsCore.getGraphics3DGraphicById(r);if(this._dirtyGraphicsSet.delete(r),null!=s&&(s.alignWithElevation(this.elevationProvider,e,i),this.graphicsCore.deconflictor?.setDirty(),t.madeProgress()),t.done)return}}_updateDirtyExtents(t){for(;!this._dirtyExtents.empty&&!t.done;){const e=this._dirtyExtents.pop(),i=this.elevationProvider
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{EventEmitter as i}from"../../../../core/Evented.js";import{watch as r}from"../../../../core/reactiveUtils.js";import{property as s,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{ExtentSet as n}from"./ExtentSet.js";import{TaskPriority as o}from"../../../support/Scheduler.js";let h=class extends e{constructor(t){super(t),this._dirtyExtents=new n,this._globalDirty=!1,this._averageExtentUpdateSize=0,this._dirtyGraphicsSet=new Set,this._updateElevation=!1,this.graphicsCoreOwner=null,this.graphicsCore=null,this.events=new i}initialize(){const t=this.elevationProvider,e=this.graphicsCoreOwner.view.resourceController.scheduler;this._task=e.registerTask(p(this.graphicsCore.layer.elevationInfo?.mode),this),this.addHandles([t.on("elevation-change",t=>this._elevationChanged(t)),r(()=>this.graphicsCoreOwner.suspended,()=>this._suspendedChange()),this._task,r(()=>p(this.graphicsCore.layer.elevationInfo?.mode),t=>this._task.priority=t)])}destroy(){this._dirtyGraphicsSet.clear(),this.graphicsCoreOwner=null,this.graphicsCore=null,this.queryGraphicUIDsInExtent=null,this.elevationProvider=null,this._dirtyExtents.destroy()}clear(){this._dirtyGraphicsSet.clear(),this.notifyChange("updating")}_suspendedChange(){!0===this.graphicsCoreOwner.suspended?this._updateElevation=!1:!1===this.graphicsCoreOwner.suspended&&this._updateElevation&&(this._globalDirty=!0,this.notifyChange("updating"))}elevationInfoChange(){this._globalDirty=!0,this.notifyChange("updating")}get updating(){return this.readyToRun}get readyToRun(){return this._dirtyGraphicsSet.size>0||this._dirtyExtents&&!this._dirtyExtents.empty||this._globalDirty}get updatingRemaining(){return this._dirtyGraphicsSet.size+this._dirtyExtents.size*this._averageExtentUpdateSize}runTask(t){for(this._globalDirty&&(this._markAllGraphicsElevationDirty(),this._globalDirty=!1,t.madeProgress()),t.run(()=>this._dirtyExtents.merge(t));this.readyToRun&&!t.done;)this._updateDirtyGraphics(t),this._updateDirtyExtents(t);this.notifyChange("updating")}_updateDirtyGraphics(t){const e=this.graphicsCoreOwner.view.renderCoordsHelper,i=0===this.graphicsCore.effectiveUpdatePolicy;for(const r of this._dirtyGraphicsSet.keys()){const s=this.graphicsCore.getGraphics3DGraphicById(r);if(this._dirtyGraphicsSet.delete(r),null!=s&&(s.alignWithElevation(this.elevationProvider,e,i),this.graphicsCore.deconflictor?.setDirty(),t.madeProgress()),t.done)return}}_updateDirtyExtents(t){for(;!this._dirtyExtents.empty&&!t.done;){const e=this._dirtyExtents.pop(),{spatialReference:i}=this.elevationProvider;this.events.emit("invalidate-elevation",{extent:e,spatialReference:i});const r=this._dirtyGraphicsSet.size;this.queryGraphicUIDsInExtent(e,i,t=>{const e=this.graphicsCore.getGraphics3DGraphicById(t);null!=e&&e.needsElevationUpdates()&&this._dirtyGraphicsSet.add(t)}),this._averageExtentUpdateSize=.1*(this._dirtyGraphicsSet.size-r)+.9*this._averageExtentUpdateSize,t.madeProgress()}}_markAllGraphicsElevationDirty(){this._dirtyExtents.clear(),this._dirtyGraphicsSet.clear(),this.graphicsCore.graphics3DGraphics.forEach((t,e)=>this._dirtyGraphicsSet.add(e))}_elevationChanged(t){if("scene"===t.context&&(!this.graphicsCore.layer.elevationInfo||"relative-to-scene"!==this.graphicsCore.layer.elevationInfo.mode))return;const e=t.extent;if(this.graphicsCoreOwner.suspended){if(!this._updateElevation){const t=this.graphicsCore.computedExtent;t&&e[2]>t.xmin&&e[0]<t.xmax&&e[3]>t.ymin&&e[1]<t.ymax&&(this._updateElevation=!0)}this.events.emit("invalidate-elevation",t)}else e[0]===-1/0?this._globalDirty=!0:this._dirtyExtents.add(e),this.notifyChange("updating")}};function p(t){return null==t?o.ELEVATION_ALIGNMENT:"relative-to-scene"===t?o.ELEVATION_ALIGNMENT_SCENE:o.ELEVATION_ALIGNMENT}t([s()],h.prototype,"graphicsCoreOwner",void 0),t([s()],h.prototype,"graphicsCore",void 0),t([s()],h.prototype,"queryGraphicUIDsInExtent",void 0),t([s()],h.prototype,"elevationProvider",void 0),t([s({readOnly:!0})],h.prototype,"updating",null),t([s({readOnly:!0})],h.prototype,"updatingRemaining",null),h=t([a("esri.views.3d.layers.graphics.Graphics3DElevationAlignment")],h);export{h as Graphics3DElevationAlignment};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../request.js";import r from"../../../../core/Accessor.js";import{splitIntoChunks as s}from"../../../../core/arrayUtils.js";import{createTask as i,resultOrAbort as n,result as o}from"../../../../core/asyncUtils.js";import a from"../../../../core/Collection.js";import{makeHandle as d}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import c from"../../../../core/Logger.js";import{abortMaybe as h,destroyMaybe as l}from"../../../../core/maybe.js";import{estimateStringMemory as u,estimateNumberMemory as m}from"../../../../core/memoryEstimations.js";import{whenOrAbort as g,createResolver as p}from"../../../../core/promiseUtils.js";import y from"../../../../core/ReactiveSet.js";import{watch as f,sync as _}from"../../../../core/reactiveUtils.js";import{property as b,subclass as v}from"../../../../core/accessorSupport/decorators.js";import{equals as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as j}from"../../../../intl/number.js";import{getMaximumQuerySize as C,queryAllJSON as w}from"../../../../layers/support/featureQueryAll.js";let I=class extends r{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=L,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new a,this.geometryOverrides=new a,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new y,this._geometryChangedObjectIds=new y,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=new A(this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`)),this.addHandles(f(()=>this.layer.definitionExpression,async()=>{this._definitionExpressionDirty=!0,this._pendingFetchChangedObjectIds||(this._applyGeometryOverridesTask=h(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=i(e=>this._queryAndAddGeometryOverrides(e)),await this._applyGeometryOverridesTask.promise)},_)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally(()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})}destroy(){this._set("layer",null),this._memCache=l(this._memCache),this._pendingFetchAbortController=h(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return null!=this._associatedLayer?.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort((e,t)=>e-t):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return!!this.is3DOFL&&!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished)}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=this._interactiveEditingSessions,r=new F(e,()=>{t.remove(r)});return t.unshift(r),r}async applyAttributeOverrides(e,t,r,s=[]){if(this._pendingFetchChangedObjectIds&&await g(this._pendingFetchChangedObjectIds,r),null==t)return;const{attributeData:i,loadedAttributes:n}=t;if(null==n||null==i||0===this._attributeChangedObjectIds.size)return;const o=new Set;for(const d of n)o.add(d.index);for(const d of s)o.has(d.index)||(n.push(d),i[d.name]=new Array(e.length));const a=await this._lockFeatureIds(e);try{const t={attributeData:i,loadedAttributes:n},s=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds),{objectIds:o,fieldNames:a}=s;if(0===o.length||0===a.length)return;const d=await this._queryAttributeOverridesFromAssociatedLayer(o,a,r);if(null==d)return;this._processOverridesFromAssociatedLayer(e,d,a,t)}finally{a.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const r=this._clientGeometryCache.get(e);if(null!=r&&(this.geometryOverrides.remove(r),this._clientGeometryCache.delete(e)),null!=t){const r={oid:e,mesh:t};this.geometryOverrides.add(r),this._clientGeometryCache.set(e,r)}}updateAttributeValue(e,t,r){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,r)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,r){this._memCache.put(e,t,r)}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:r},s){const i=new Array;for(const a of t)i[a.index]=r[a.name];const n=new Set,o=new Set;for(let a=0;a<e.length;a++){const r=e[a];if(s.has(r))for(const e of t){const t=this._attributeFromCache(r,e.index);void 0===t?(n.add(r),o.add(e.name)):i[e.index][a]=t}}return{objectIds:Array.from(n),fieldNames:Array.from(o)}}_attributeFromCache(e,t){const r=this._fromInteractiveEditingSession(e,t);return void 0!==r?r:this._memCache.get(e,t)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const r of this._interactiveEditingSessions){if(r.objectId!==e)continue;const s=r.getAttribute(t);if(void 0!==s)return s}}async _queryAttributeOverridesFromAssociatedLayer(e,t,r){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:s}=this.layer;if(null==s)return null;const i=s.createQuery(),{objectIdField:n}=s,o=[n,...t];i.where=this.layer.definitionExpression||"1=1",i.returnGeometry=!1,i.outFields=o,i.cacheHint=!0;const a=await this._executeBatchQuery(s,e,i,r),d=[];for(const c of a)if(c.ok)for(const e of c.value.features)d.push(e);return d}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL)return null;const r=this.layer.associatedLayer,s=r.infoFor3D,{spatialReference:i}=r,{state:{viewingMode:n},spatialReference:o}=this.view,a=1===n,d=i.isGeographic;if(a&&!d)return c.getLogger(this).warn("unsupported-pcs-edits-in-global-view",this.layer.title,E(i,o,this.view.viewingMode,0)),null;if(!a&&d)return c.getLogger(this).warn("unsupported-gcs-edits-in-local-view",this.layer.title,E(i,o,this.view.viewingMode,0)),null;if(!(O(i,o)||a&&o.isWebMercator&&i.isWGS84))return c.getLogger(this).warn("unsupported-mismatched-spatial-reference-edits",this.layer.title,E(i,o,this.view.viewingMode,1)),null;this._logWarningIfMaximumObjectsExceeded();const{objectIdField:h,globalIdField:l}=r,u=[h,...null!=l?[l]:[]],m=r.createQuery();m.where=this.layer.definitionExpression||"1=1",m.returnGeometry=!0,m.outFields=u,m.cacheHint=!0,m.returnZ=r.hasZ,m.returnM=r.hasM;const{assetMapFromAssetMapsJSON:g,extractMesh:p}=await import("../../../../rest/support/meshFeatureSet.js"),y=await this._executeBatchQuery(r,e,m,t),f=[];for(const c of y){if(!c.ok)continue;const e=c.value,{assetMaps:t,features:r,globalIdFieldName:n}=e;if(null==t)continue;const o=g(s,t);for(const a of r){const e=p(a,n,i,s,o),t=a;null!=e?(t.geometry=e,f.push(t)):t.geometry=null}}return f}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${j(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;e+=t?.loaded?` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:` (${this.layer.parsedUrl.path})`,c.getLogger(this).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,r,i){if(0===t.length)return[];const o=C(e);t=[...t].sort((e,t)=>e-t);const a=s(t,o).map(t=>{const s=r.clone();return s.objectIds=t,n(w(e,s,{signal:i}))});return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,r,{loadedAttributes:s,attributeData:i}){const n=this._associatedLayer;if(null==n)return;const o=n.objectIdField,a=r.map(t=>(t in i||(i[t]=new Array(e.length)),i[t])),d=new Map(s.map(e=>[e.name,e.index])),c=r.map(e=>d.get(e)),h=new Map(Array.from(e,(e,t)=>[e,t]));for(const l of t){const e=l.attributes[o];for(let t=0;t<r.length;t++){const s=c[t],i=h.get(e),n=l.attributes[r[t]];a[t][i]=n,this._cacheAttributeValue(e,s,n)}}}async _fetchChangedObjectIds(e){const r=this.layer;await r.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:s}=r;if(null==s||!s.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(null==i)return;const n=s.layerId,a=this.is3DOFL,d={...s.customParameters,f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:i}])};if(null!=s.apiKey&&(d.token=s.apiKey),a){const e=s.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const h=await o(t(`${s.url}/extractChanges`,{method:"post",query:d,timeout:G,signal:e}));if(!h.ok){const e=this.layer.title;c.getLogger(this).warn("extractChanges:timeout",e,": could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.")}if(h.ok&&1===h.value.data?.edits?.length){const t=h.value.data.edits[0],r=t?.objectIds,s=t?.fieldUpdates,i=r?.adds??[],n=r?.updates??[],o=r?.deletes??[],d=[...i,...n,...o],c=a?[...i,...s??n,...o]:[],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort((e,t)=>e-t);for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of c)this._geometryChangedObjectIds.add(e);for(;this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;const t=this.layer,{associatedLayer:r}=t;if(null!=r&&r.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp?.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t?.serverGens?.minServerGen?t.serverGens.minServerGen:null}async _lockFeatureIds(e){const t=this._featureIdLocks;let r=!0;for(;r;){const s=new Array;for(const r of e){const e=t.get(r);e&&s.push(e)}0===s.length?r=!1:await Promise.all(s)}const s=p(),i=s.promise;for(const n of e)t.set(n,i);return d(()=>{for(const r of e)t.delete(r);s.resolve()})}get test(){}};e([b({constructOnly:!0})],I.prototype,"view",void 0),e([b({constructOnly:!0})],I.prototype,"layer",void 0),e([b({readOnly:!0})],I.prototype,"is3DOFL",null),e([b()],I.prototype,"_interactiveEditingSessions",void 0),e([b({readOnly:!0})],I.prototype,"sortedGeometryChangedObjectIds",null),e([b({readOnly:!0})],I.prototype,"geometryOverrides",void 0),e([b()],I.prototype,"_clientGeometryCache",void 0),e([b()],I.prototype,"_associatedLayer",null),e([b({constructOnly:!0})],I.prototype,"memoryController",void 0),e([b()],I.prototype,"_attributeChangedObjectIds",void 0),e([b()],I.prototype,"_geometryChangedObjectIds",void 0),e([b()],I.prototype,"hasGeometryChanges",null),e([b()],I.prototype,"_pendingFetchChangedObjectIds",void 0),e([b()],I.prototype,"_pendingFetchAbortController",void 0),e([b()],I.prototype,"_applyGeometryOverridesTask",void 0),e([b()],I.prototype,"updating",null),e([b()],I.prototype,"isEmpty",null),I=e([v("esri.views.3d.layers.i3s.I3SOverrides")],I);class F{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}class A{constructor(e){this._cache=e}destroy(){this._cache.destroy()}put(e,t,r){this._cache.put(this._getKey(e,t),new x(r))}get(e,t){return this._cache.get(this._getKey(e,t))?.value}_getKey(e,t){return`${e}-${t}`}}class x{constructor(e){this.value=e,this.usedMemory="string"==typeof e?u(e):m}}const G=1e4,L=5e4;function E(e,t,r,s){return`Displaying the edits of a SceneLayer with a${0===s?e.isGeographic?" geographic ":" projected ":" "}spatial reference (wkid:${e.wkid}) in ${r} viewing mode${1===s?` with spatial reference (wkid:${t.wkid}) `:" "}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${0===s?"viewing mode":"view spatial reference"} to display edits.`}export{I as I3SOverrides};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../request.js";import r from"../../../../core/Accessor.js";import{splitIntoChunks as s}from"../../../../core/arrayUtils.js";import{createTask as i,resultOrAbort as n,result as o}from"../../../../core/asyncUtils.js";import a from"../../../../core/Collection.js";import{makeHandle as d}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import c from"../../../../core/Logger.js";import{abortMaybe as h,destroyMaybe as l}from"../../../../core/maybe.js";import{estimateStringMemory as u,estimateNumberMemory as m}from"../../../../core/memoryEstimations.js";import{whenOrAbort as g,createResolver as p}from"../../../../core/promiseUtils.js";import y from"../../../../core/ReactiveSet.js";import{watch as f,sync as _}from"../../../../core/reactiveUtils.js";import{property as b,subclass as v}from"../../../../core/accessorSupport/decorators.js";import{equals as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as j}from"../../../../intl/number.js";import{getMaximumQuerySize as C,queryAllJSON as w}from"../../../../layers/support/featureQueryAll.js";let I=class extends r{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=L,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new a,this.geometryOverrides=new a,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new y,this._geometryChangedObjectIds=new y,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=new A(this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`)),this.addHandles(f(()=>this.layer.definitionExpression,async()=>{this._definitionExpressionDirty=!0,this._pendingFetchChangedObjectIds||(this._applyGeometryOverridesTask=h(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=i(e=>this._queryAndAddGeometryOverrides(e)),await this._applyGeometryOverridesTask.promise)},_)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally(()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})}destroy(){this._set("layer",null),this._memCache=l(this._memCache),this._pendingFetchAbortController=h(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return null!=this._associatedLayer?.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort((e,t)=>e-t):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return!!this.is3DOFL&&!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished)}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=this._interactiveEditingSessions,r=new F(e,()=>{t.remove(r)});return t.unshift(r),r}async applyAttributeOverrides(e,t,r,s=[]){if(this._pendingFetchChangedObjectIds&&await g(this._pendingFetchChangedObjectIds,r),null==t)return;const{attributeData:i,loadedAttributes:n}=t;if(null==n||null==i||0===this._attributeChangedObjectIds.size)return;const o=new Set;for(const d of n)o.add(d.index);for(const d of s)o.has(d.index)||(n.push(d),i[d.name]=new Array(e.length));const a=await this._lockFeatureIds(e);try{const t={attributeData:i,loadedAttributes:n},s=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds),{objectIds:o,fieldNames:a}=s;if(0===o.length||0===a.length)return;const d=await this._queryAttributeOverridesFromAssociatedLayer(o,a,r);if(null==d)return;this._processOverridesFromAssociatedLayer(e,d,a,t)}finally{a.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const r=this._clientGeometryCache.get(e);if(null!=r&&(this.geometryOverrides.remove(r),this._clientGeometryCache.delete(e)),null!=t){const r={oid:e,mesh:t};this.geometryOverrides.add(r),this._clientGeometryCache.set(e,r)}}updateAttributeValue(e,t,r){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,r)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,r){this._memCache.put(e,t,r)}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:r},s){const i=new Array;for(const a of t)i[a.index]=r[a.name];const n=new Set,o=new Set;for(let a=0;a<e.length;a++){const r=e[a];if(s.has(r))for(const e of t){const t=this._attributeFromCache(r,e.index);void 0===t?(n.add(r),o.add(e.name)):i[e.index][a]=t}}return{objectIds:Array.from(n),fieldNames:Array.from(o)}}_attributeFromCache(e,t){const r=this._fromInteractiveEditingSession(e,t);return void 0!==r?r:this._memCache.get(e,t)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const r of this._interactiveEditingSessions){if(r.objectId!==e)continue;const s=r.getAttribute(t);if(void 0!==s)return s}}async _queryAttributeOverridesFromAssociatedLayer(e,t,r){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:s}=this.layer;if(null==s)return null;const i=s.createQuery(),{objectIdField:n}=s,o=[n,...t];i.where=this.layer.definitionExpression||"1=1",i.returnGeometry=!1,i.outFields=o,i.cacheHint=!0;const a=await this._executeBatchQuery(s,e,i,r),d=[];for(const c of a)if(c.ok)for(const e of c.value.features)d.push(e);return d}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL)return null;const r=this.layer.associatedLayer,s=r.infoFor3D,{spatialReference:i}=r,{state:{viewingMode:n},spatialReference:o}=this.view,a=1===n,d=i.isGeographic;if(a&&!d)return c.getLogger(this).warn("unsupported-pcs-edits-in-global-view",this.layer.title,E(i,o,this.view.viewingMode,0)),null;if(!a&&d)return c.getLogger(this).warn("unsupported-gcs-edits-in-local-view",this.layer.title,E(i,o,this.view.viewingMode,0)),null;if(!(O(i,o)||a&&o.isWebMercator&&i.isWGS84))return c.getLogger(this).warn("unsupported-mismatched-spatial-reference-edits",this.layer.title,E(i,o,this.view.viewingMode,1)),null;this._logWarningIfMaximumObjectsExceeded();const{objectIdField:h,globalIdField:l}=r,u=[h,...null!=l?[l]:[]],m=r.createQuery();m.where=this.layer.definitionExpression||"1=1",m.returnGeometry=!0,m.outFields=u,m.cacheHint=!0,m.returnZ=r.hasZ,m.returnM=r.hasM;const{assetMapFromAssetMapsJSON:g,extractMesh:p}=await import("../../../../rest/support/meshFeatureSet.js"),y=await this._executeBatchQuery(r,e,m,t),f=[];for(const c of y){if(!c.ok)continue;const e=c.value,{assetMaps:t,features:r,globalIdFieldName:n}=e;if(null==t)continue;const o=g(s,t);for(const a of r){const e=p(a,n,i,s,o),t=a;null!=e?(t.geometry=e,f.push(t)):t.geometry=null}}return f}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${j(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;e+=t?.loaded?` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:` (${this.layer.parsedUrl.path})`,c.getLogger(this).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,r,i){if(0===t.length)return[];const o=C(e);t=[...t].sort((e,t)=>e-t);const a=s(t,o).map(t=>{const s=r.clone();return s.objectIds=t,n(w(e,s,{signal:i}))});return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,r,{loadedAttributes:s,attributeData:i}){const n=this._associatedLayer;if(null==n)return;const o=n.objectIdField,a=r.map(t=>(t in i||(i[t]=new Array(e.length)),i[t])),d=new Map(s.map(e=>[e.name,e.index])),c=r.map(e=>d.get(e)),h=new Map(Array.from(e,(e,t)=>[e,t]));for(const l of t){const e=l.attributes[o];for(let t=0;t<r.length;t++){const s=c[t],i=h.get(e),n=l.attributes[r[t]];a[t][i]=n,this._cacheAttributeValue(e,s,n)}}}async _fetchChangedObjectIds(e){const r=this.layer;await r.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:s}=r;if(null==s||!s.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(null==i)return;const n=s.layerId,a=this.is3DOFL,d={...s.customParameters,f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:i}])};if(null!=s.apiKey&&(d.token=s.apiKey),a){const e=s.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const h=await o(t(`${s.url}/extractChanges`,{method:"post",query:d,timeout:G,signal:e}));if(!h.ok){const e=this.layer.title;c.getLogger(this).warn("extractChanges:unavailable",e,": could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.")}if(h.ok&&1===h.value.data?.edits?.length){const t=h.value.data.edits[0],r=t?.objectIds,s=t?.fieldUpdates,i=r?.adds??[],n=r?.updates??[],o=r?.deletes??[],d=[...i,...n,...o],c=a?[...i,...s??n,...o]:[],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort((e,t)=>e-t);for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of c)this._geometryChangedObjectIds.add(e);for(;this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;const t=this.layer,{associatedLayer:r}=t;if(null!=r&&r.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp?.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t?.serverGens?.minServerGen?t.serverGens.minServerGen:null}async _lockFeatureIds(e){const t=this._featureIdLocks;let r=!0;for(;r;){const s=new Array;for(const r of e){const e=t.get(r);e&&s.push(e)}0===s.length?r=!1:await Promise.all(s)}const s=p(),i=s.promise;for(const n of e)t.set(n,i);return d(()=>{for(const r of e)t.delete(r);s.resolve()})}get test(){}};e([b({constructOnly:!0})],I.prototype,"view",void 0),e([b({constructOnly:!0})],I.prototype,"layer",void 0),e([b({readOnly:!0})],I.prototype,"is3DOFL",null),e([b()],I.prototype,"_interactiveEditingSessions",void 0),e([b({readOnly:!0})],I.prototype,"sortedGeometryChangedObjectIds",null),e([b({readOnly:!0})],I.prototype,"geometryOverrides",void 0),e([b()],I.prototype,"_clientGeometryCache",void 0),e([b()],I.prototype,"_associatedLayer",null),e([b({constructOnly:!0})],I.prototype,"memoryController",void 0),e([b()],I.prototype,"_attributeChangedObjectIds",void 0),e([b()],I.prototype,"_geometryChangedObjectIds",void 0),e([b()],I.prototype,"hasGeometryChanges",null),e([b()],I.prototype,"_pendingFetchChangedObjectIds",void 0),e([b()],I.prototype,"_pendingFetchAbortController",void 0),e([b()],I.prototype,"_applyGeometryOverridesTask",void 0),e([b()],I.prototype,"updating",null),e([b()],I.prototype,"isEmpty",null),I=e([v("esri.views.3d.layers.i3s.I3SOverrides")],I);class F{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}class A{constructor(e){this._cache=e}destroy(){this._cache.destroy()}put(e,t,r){this._cache.put(this._getKey(e,t),new x(r))}get(e,t){return this._cache.get(this._getKey(e,t))?.value}_getKey(e,t){return`${e}-${t}`}}class x{constructor(e){this.value=e,this.usedMemory="string"==typeof e?u(e):m}}const G=1e4,L=5e4;function E(e,t,r,s){return`Displaying the edits of a SceneLayer with a${0===s?e.isGeographic?" geographic ":" projected ":" "}spatial reference (wkid:${e.wkid}) in ${r} viewing mode${1===s?` with spatial reference (wkid:${t.wkid}) `:" "}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${0===s?"viewing mode":"view spatial reference"} to display edits.`}export{I as I3SOverrides};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{n as e,a as t,g as i,c as s,F as n,e as r,d as o,H as a,v as c,j as u,G as h,s as l,C as d,b as m,E as _,i as p}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as g}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as R}from"../../../../geometry/projection/projectors.js";import{create as S,fromMatrix as M,createPoints as x,intersectsSphere as C}from"../../../../geometry/support/frustum.js";import{getNormal as I,signedDistance as P}from"../../../../geometry/support/plane.js";import{isPlateCarree as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as E}from"../../../../geometry/support/sphere.js";import{makeDehydratedPoint as O}from"../../../../layers/graphics/dehydratedPoint.js";import{evaluateElevationAlignmentAtPoint as F}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as A}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as B,extractExpressionInfo as V}from"../graphics/featureExpressionInfoUtils.js";import{isValidMbs as y,intersectBoundingRectWithMbs as j}from"./I3SUtil.js";import{Obb as L,computeOffsetObb as w}from"../../support/orientedBoundingBox.js";const q=1e5;class G{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=S(),this._frustumMbs=new E,this._viewDirection=f(),this._useFrustumCulling=!1,this._poi=f(),this._cameraPOIDirection=f(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new L,this._tmp1=f(),this._tmp2=f(),this._tmp3=f(),this._tmp0=f(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=g(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=O(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||D(u)),this._indexSREllipsoidRadius=v(this._indexSR).radius,this._indexSRSphericalPCPF=g(e),this._projectorIndexSRToIndexSRSphericalPCPF=R(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=A.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(B(V(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,e(this._viewDirection,n.viewForward),r){M(n.viewMatrix,n.projectionMatrix,this._frustum,z);{const e=n.eye,r=N;t(r,z[4],e);const o=.5*i(r,r)/i(this._viewDirection,r),a=this._frustumMbs,c=a.center;s(c,e,this._viewDirection,o);const u=1+o;a.radius=u}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this._updateCameraPOIDirection(),this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const[r,o,a]=s.center,c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const u=t?null:this._elevationProvider.getRootElevationBounds?.();u&&i.expandElevationRange(u)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(y(t))return t;const{serviceMbsInIndexSR:i}=e;i&&t.copy(i);const s=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(s)){let i=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":i=this._elevationContext.geometryZWithOffset(t.center[2],this._renderCoordsHelper)+s-t.center[2],n=r-s;break;case"on-the-ground":i=s-t.center[2],n=r-s}t.center[2]+=i+.5*n,t.radius+=.5*n}else this._elevationContext&&t.radius<q&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],t.center[2]=F(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return b(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new L,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i.radius;let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<q){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=F(e,this._elevationProvider,u,c)-a}const h=o>0,l=h?this._tmpObb:t;return s.transform(l,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),h&&w(l,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(Z,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),Z):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){n(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(r(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,c=-1;if(s){const t=X;s.getCenter(t),e(t,t),r=t,s.getCorners(Y);for(const s of Y){e(s,s);const r=i(s,t);if(r<=0)return void n.invalidate();const o=Math.sqrt(1-r*r);c=Math.max(c,o)}}else{const i=t.serviceMbsInRenderSR;if(!y(i))return void n.invalidate();{const t=o(X,i.center),s=i.radius,u=a(t);if(u<s)return void n.invalidate();c=s/u,e(t,t),r=t}}const u=.001;n.set(r,c+u)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(X);e[2]=0;let s=0;const n=J;i.getCorners(Y);for(const t of Y){t[2]=0;const e=c(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(y(i)){const e=o(X,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):C(this._frustum,t)}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n.radius;if(-1===r||r>.9)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=n.getAxis(ee),h=i(c,a),l=this._frustumMbsRadius,d=h-l,m=h+l;if(d<=0)return!0;const _=u(k,c,d),p=u(H,c,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=I(v),r=e(W,n),o=i(r,c);if(Math.abs(1-o)<.01)continue;const a=K;u(a,c,o),t(a,a,r),e(a,a);const h=Q;s(h,_,a,d*f);if(P(v,h)<=0)continue;s(h,p,a,m*f);if(P(v,h)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=a(n);if(r<=s)return!0;const o=e.getAxis(ee),c=i(o,n);{const e=u(T,o,c);if(h(e,n)<s)return!0}const l=c/r;if(c<=0){return-l<s}const d=Math.sqrt(1-l*l);if(d<t)return!0;const m=s/r;return d*Math.sqrt(1-m*m)-m*l<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=Y;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(ee),a=i(t,n),c=a-s,h=a+s;if(c<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=$;if(u(o,n,c/r),P(e,o)<=0){s=!1;break}const a=$;if(u(a,n,h/r),P(e,a)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=I(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=o(T,t);s[2]=0;const n=e.radius,r=e.getAxis(ee);return h(s,r)<=n+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==j(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(l(i.center,this._camPos)),n=s-i.radius;return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e).radius}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=d(t.center,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t.radius,s=(Math.abs(t.center[0]*(t.center[0]-this._camPos[0])+t.center[1]*(t.center[1]-this._camPos[1])+t.center[2]*(t.center[2]-this._camPos[2]))/m(t.center)+i)/d(t.center,this._camPos);return Math.min(1,s)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=m(t.center),n=m(e)-s;u(this._tmp0,e,i(e,t.center)/_(e));const o=l(t.center,this._tmp0),a=t.radius;if(o<=a*a)return Math.abs(n);{const o=u(this._tmp0,t.center,1/s),c=s,h=a*a/2/c,l=u(this._tmp1,o,c-h),_=e,f=r(this._tmp2,_,l),v=r(this._tmp2,f,u(this._tmp3,o,i(o,f))),g=p(this._tmp2,l,u(this._tmp2,v,a/m(v)));let b=d(_,g);if(n>=2e5){const e=r(this._tmp1,_,g);let t=i(e,o)/m(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):U(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 2:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i.radius;return this._updateMinMaxDistance(r),e.maxError*t<=n}case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.getServiceMbsInRenderSR(e),s=t.center,n=i(s,this._cameraPOIDirection),r=n*n,o=_(s)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return d(this._camPos,this._poi)}}function U(e,t){const i=e[0]-t.center[0],s=e[1]-t.center[1],n=e[2]-t.center[2],r=i*i+s*s,o=t.radius;if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const z=x(),N=f(),T=f(),k=f(),H=f(),W=f(),Z=new L,X=f(),Y=[f(),f(),f(),f(),f(),f(),f(),f()],J=f(),K=f(),Q=f(),$=f(),ee=f();export{G as default};
|
|
5
|
+
import{n as e,a as t,g as i,c as s,F as n,e as r,d as o,H as a,v as c,j as u,G as h,s as l,C as d,b as m,E as _,i as p}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as g}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as R}from"../../../../geometry/projection/projectors.js";import{create as S,fromMatrix as M,createPoints as x,intersectsSphere as C}from"../../../../geometry/support/frustum.js";import{getNormal as I,signedDistance as P}from"../../../../geometry/support/plane.js";import{isPlateCarree as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as E}from"../../../../geometry/support/sphere.js";import{makeDehydratedPoint as O}from"../../../../layers/graphics/dehydratedPoint.js";import{evaluateElevationAlignmentAtPoint as F}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as A}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as B,extractExpressionInfo as V}from"../graphics/featureExpressionInfoUtils.js";import{isValidMbs as y,intersectBoundingRectWithMbs as j}from"./I3SUtil.js";import{Obb as L,computeOffsetObb as w}from"../../support/orientedBoundingBox.js";const q=1e5;class G{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=S(),this._frustumMbs=new E,this._viewDirection=f(),this._useFrustumCulling=!1,this._poi=f(),this._cameraPOIDirection=f(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new L,this._tmp1=f(),this._tmp2=f(),this._tmp3=f(),this._tmp0=f(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=g(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=O(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||D(u)),this._indexSREllipsoidRadius=v(this._indexSR).radius,this._indexSRSphericalPCPF=g(e),this._projectorIndexSRToIndexSRSphericalPCPF=R(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=A.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(B(V(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,e(this._viewDirection,n.viewForward),r){M(n.viewMatrix,n.projectionMatrix,this._frustum,z);{const e=n.eye,r=N;t(r,z[4],e);const o=.5*i(r,r)/i(this._viewDirection,r),a=this._frustumMbs,c=a.center;s(c,e,this._viewDirection,o);const u=1+o;a.radius=u}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this._updateCameraPOIDirection(),this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground",r=this._elevationProvider;if(r.getSphereElevationBounds){const e=r.getSphereElevationBounds(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const[o,a,c]=s.center,u=r.getElevation(o,a,c,this._indexSR,n);u&&i.expandElevationRangeValues(u,u);const h=t?null:r.getRootElevationBounds?.();h&&i.expandElevationRange(h)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(y(t))return t;const{serviceMbsInIndexSR:i}=e;i&&t.copy(i);const s=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(s)){let i=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":i=this._elevationContext.geometryZWithOffset(t.center[2],this._renderCoordsHelper)+s-t.center[2],n=r-s;break;case"on-the-ground":i=s-t.center[2],n=r-s}t.center[2]+=i+.5*n,t.radius+=.5*n}else this._elevationContext&&t.radius<q&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],t.center[2]=F(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return b(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new L,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i.radius;let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<q){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=F(e,this._elevationProvider,u,c)-a}const h=o>0,l=h?this._tmpObb:t;return s.transform(l,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),h&&w(l,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(Z,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),Z):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){n(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(r(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,c=-1;if(s){const t=X;s.getCenter(t),e(t,t),r=t,s.getCorners(Y);for(const s of Y){e(s,s);const r=i(s,t);if(r<=0)return void n.invalidate();const o=Math.sqrt(1-r*r);c=Math.max(c,o)}}else{const i=t.serviceMbsInRenderSR;if(!y(i))return void n.invalidate();{const t=o(X,i.center),s=i.radius,u=a(t);if(u<s)return void n.invalidate();c=s/u,e(t,t),r=t}}const u=.001;n.set(r,c+u)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(X);e[2]=0;let s=0;const n=J;i.getCorners(Y);for(const t of Y){t[2]=0;const e=c(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(y(i)){const e=o(X,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):C(this._frustum,t)}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n.radius;if(-1===r||r>.9)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=n.getAxis(ee),h=i(c,a),l=this._frustumMbsRadius,d=h-l,m=h+l;if(d<=0)return!0;const _=u(k,c,d),p=u(H,c,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=I(v),r=e(W,n),o=i(r,c);if(Math.abs(1-o)<.01)continue;const a=K;u(a,c,o),t(a,a,r),e(a,a);const h=Q;s(h,_,a,d*f);if(P(v,h)<=0)continue;s(h,p,a,m*f);if(P(v,h)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=a(n);if(r<=s)return!0;const o=e.getAxis(ee),c=i(o,n);{const e=u(T,o,c);if(h(e,n)<s)return!0}const l=c/r;if(c<=0){return-l<s}const d=Math.sqrt(1-l*l);if(d<t)return!0;const m=s/r;return d*Math.sqrt(1-m*m)-m*l<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=Y;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(ee),a=i(t,n),c=a-s,h=a+s;if(c<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=$;if(u(o,n,c/r),P(e,o)<=0){s=!1;break}const a=$;if(u(a,n,h/r),P(e,a)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=I(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=o(T,t);s[2]=0;const n=e.radius,r=e.getAxis(ee);return h(s,r)<=n+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==j(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(l(i.center,this._camPos)),n=s-i.radius;return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e).radius}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=d(t.center,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t.radius,s=(Math.abs(t.center[0]*(t.center[0]-this._camPos[0])+t.center[1]*(t.center[1]-this._camPos[1])+t.center[2]*(t.center[2]-this._camPos[2]))/m(t.center)+i)/d(t.center,this._camPos);return Math.min(1,s)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=m(t.center),n=m(e)-s;u(this._tmp0,e,i(e,t.center)/_(e));const o=l(t.center,this._tmp0),a=t.radius;if(o<=a*a)return Math.abs(n);{const o=u(this._tmp0,t.center,1/s),c=s,h=a*a/2/c,l=u(this._tmp1,o,c-h),_=e,f=r(this._tmp2,_,l),v=r(this._tmp2,f,u(this._tmp3,o,i(o,f))),g=p(this._tmp2,l,u(this._tmp2,v,a/m(v)));let b=d(_,g);if(n>=2e5){const e=r(this._tmp1,_,g);let t=i(e,o)/m(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):U(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 2:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i.radius;return this._updateMinMaxDistance(r),e.maxError*t<=n}case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.getServiceMbsInRenderSR(e),s=t.center,n=i(s,this._cameraPOIDirection),r=n*n,o=_(s)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return d(this._camPos,this._poi)}}function U(e,t){const i=e[0]-t.center[0],s=e[1]-t.center[1],n=e[2]-t.center[2],r=i*i+s*s,o=t.radius;if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const z=x(),N=f(),T=f(),k=f(),H=f(),W=f(),Z=new L,X=f(),Y=[f(),f(),f(),f(),f(),f(),f(),f()],J=f(),K=f(),Q=f(),$=f(),ee=f();export{G 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import r from"../../../../core/Logger.js";import{property as n,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{fromQuat as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as a,p as l}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as p}from"../../../../geometry/projection/projectBoundingSphere.js";import{empty as m,expand as u}from"../../../../geometry/support/aaBoundingRect.js";import{Sphere as h}from"../../../../geometry/support/sphere.js";import{ElevationRange as v}from"../../support/ElevationRange.js";import{ElevationUpdateEventImplementation as f}from"../../terrain/ElevationUpdateEvent.js";import{Intersector as d}from"../../webgl-engine/lib/Intersector.js";let
|
|
5
|
+
import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import r from"../../../../core/Logger.js";import{property as n,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{fromQuat as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as a,p as l}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as p}from"../../../../geometry/projection/projectBoundingSphere.js";import{empty as m,expand as u}from"../../../../geometry/support/aaBoundingRect.js";import{Sphere as h}from"../../../../geometry/support/sphere.js";import{ElevationRange as v}from"../../support/ElevationRange.js";import{ElevationUpdateEventImplementation as f}from"../../terrain/ElevationUpdateEvent.js";import{Intersector as d}from"../../webgl-engine/lib/Intersector.js";let g=class extends t{constructor(e){super(e),this._tmpEvent=new f,this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource}initialize(){this._intersector=new d(this.view.state.viewingMode),this._intersector.options.store=0,this._intersector.options.normalRequired=!1,this._tmpEvent.context=this.intersectionHandler.isGround?"ground":"scene"}get spatialReference(){return this.view?.elevationProvider?.spatialReference}getElevation(e,t,n,i){const o=this._renderCoordsHelper,s=a(x,e,t,n);if(!o.toRenderCoords(s,i,s))return r.getLogger(this).error("could not project point to compute elevation"),null;const{layerElevationSource:l,_intersector:c,intersectionHandler:p}=this,m=l.fullExtent,u=null!=m&&Number.isFinite(m.xmin)&&Number.isFinite(m.xmax)&&Number.isFinite(m.ymin)&&Number.isFinite(m.ymax)&&Number.isFinite(m.zmin)&&Number.isFinite(m.zmax)?new v(m.zmin,m.zmax):l.elevationRange;if(null==u)return null;const h=l.elevationOffset,f=u.elevationRangeMin+h,d=u.elevationRangeMax+h,g=o.setAltitude(R,d,s),E=o.setAltitude(y,f,s);return c.reset(g,E,this.view.state.camera),p.intersect(c,null,g,E,null,!0),c.results.min.getIntersectionPoint(s)?o.getAltitude(s):null}getElevations(e,t,r){const{groundSpatialReference:n}=this.view;for(let i=0;i<t;++i){const t=3*i,o=e[t],s=e[t+1];r(i,this.getElevation(o,s,0,n))}}getSphereElevationBounds(e,t){return p(e,t,_,this._renderSR),this._layerElevationSource.getElevationRange(_)}getRootElevationBounds(){const e=this.layerElevationSource.fullExtent;return e?.hasZ?new v(e.zmin,e.zmax):null}notifyObjectsChanged(e){this.spatialReference&&(this._computeLayerExtent(t=>{for(const r of e)t(r)},this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}notifyObjectsChangedFunctional(e){this.spatialReference&&(this._computeLayerExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}notifyObjectChanged(e){this.spatialReference&&(this._computeObjectExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}_computeObjectExtent(e,t){m(t),this._expandExtent(e,t)}_computeLayerExtent(e,t){m(t),e(e=>{this._expandExtent(e,t)})}_expandExtent(e,t){const r=this.spatialReference;if(null==r)return;if(null==e)return;o(E,e.quaternion),E[12]=e.center[0],E[13]=e.center[1],E[14]=e.center[2];const n=e.halfSize;for(let i=0;i<8;++i)x[0]=1&i?n[0]:-n[0],x[1]=2&i?n[1]:-n[1],x[2]=4&i?n[2]:-n[2],l(x,x,E),this._renderCoordsHelper.fromRenderCoords(x,x,r),u(t,x,t)}};e([n({constructOnly:!0})],g.prototype,"layerElevationSource",void 0),e([n({constructOnly:!0})],g.prototype,"intersectionHandler",void 0),e([n({constructOnly:!0})],g.prototype,"view",void 0),e([n()],g.prototype,"spatialReference",null),g=e([i("esri.views.3d.layers.i3s.LayerElevationProvider")],g);const E=s(),_=new h,x=c(),R=c(),y=c();export{g as LayerElevationProvider};
|