@arcgis/core 4.29.6 → 4.29.8

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.
Files changed (89) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{4984e2b79d862114d6a6.js → 1a8d56e01ddfec2257c3.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{3afb525a131b6841276b.js → 1e4d779a884f13762601.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{2447a4d5886aeb0ff72a.js → 205597cd91cb7ff3d2b4.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{6c50daccd84ba5545bfe.js → 22ebdec0867e44d8d58c.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{da4616b02dd0c3dd3d5d.js → 321547d796a2ecd72ab4.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{6c3ae96ec90e9ed7dd50.js → 32be478638e9e643ea32.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{a61f337802ae963d7f65.js → 59f03847a9eb96e5f65c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{7a98d2e026f63a581b1e.js → 5b08309b184f5d8345a0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/631bda7b99a27f4453c1.js +1 -0
  11. package/assets/esri/core/workers/chunks/{c527692694688a5b3b07.js → 658a8ee9a4f24bc03f7f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/99ac2a6a5be0604ee4c2.js +1 -0
  13. package/assets/esri/core/workers/chunks/{48db6e0bbb1a9c043193.js → b7a78246d25dc07f173d.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{60ab18c6a04d4b2f1d4c.js → bb05528d2ca12c57a031.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{5227f9eea6988aadad7f.js → cf0dc0ccbeaf9458de6e.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{f59b5ea05caca8a1a398.js → d40408be9bbcb0021d18.js} +1 -1
  17. package/assets/esri/core/workers/chunks/df6fbabbc74a408575fc.js +1 -0
  18. package/chunks/Laserlines.glsl.js +1 -1
  19. package/chunks/sphere.js +1 -1
  20. package/chunks/vec32.js +1 -1
  21. package/chunks/vec42.js +1 -1
  22. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  23. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  24. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  25. package/geometry/support/sphere.js +1 -1
  26. package/interfaces.d.ts +8 -2
  27. package/kernel.js +1 -1
  28. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  29. package/layers/mixins/FeatureLayerBase.js +1 -1
  30. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  31. package/layers/support/SubtypeSublayer.js +1 -1
  32. package/layers/voxel/VoxelVolume.js +1 -1
  33. package/networks/UtilityNetwork.js +1 -1
  34. package/package.json +1 -1
  35. package/support/revision.js +1 -1
  36. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  37. package/views/2d/engine/webgl/mesh/MultiTileMeshData.js +1 -1
  38. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  39. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  40. package/views/2d/layers/features/FeatureContainer.js +1 -1
  41. package/views/2d/layers/features/Processor.js +1 -1
  42. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  43. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  44. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  45. package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
  46. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  47. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  48. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  49. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  50. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  51. package/views/3d/camera/constraintUtils/distance.js +1 -1
  52. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  53. package/views/3d/layers/I3SMeshView3D.js +1 -1
  54. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  55. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  56. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  57. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  58. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  59. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  60. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  61. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  62. package/views/3d/layers/support/makeScheduleFunction.js +5 -0
  63. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  64. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  65. package/views/3d/state/controllers/global/ZoomController.js +1 -1
  66. package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
  67. package/views/3d/state/controllers/momentum/ZoomSphericalMomentumController.js +1 -1
  68. package/views/3d/state/utils/navigationUtils.js +1 -1
  69. package/views/3d/support/geometryUtils/sphere.js +1 -1
  70. package/views/3d/terrain/OverlayManager.js +1 -1
  71. package/views/3d/terrain/PatchRenderData.js +1 -1
  72. package/views/3d/terrain/SphericalPatch.js +1 -1
  73. package/views/3d/terrain/TerrainSurface.js +1 -1
  74. package/views/3d/terrain/Tile.js +1 -1
  75. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  76. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  77. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  78. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  79. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  80. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  81. package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
  82. package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
  83. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  84. package/views/interactive/sketch/constraints.js +1 -1
  85. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  86. package/views/support/geometry3dUtils.js +1 -1
  87. package/assets/esri/core/workers/chunks/a068f0c8c1c632e8b2cb.js +0 -1
  88. package/assets/esri/core/workers/chunks/a28b7d868346e13468bb.js +0 -1
  89. package/assets/esri/core/workers/chunks/ccd53b81c2688dd11584.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/4.29/esri/copyright.txt for details.
4
4
  */
5
- import"../../../tiling/TileInfoView.js";import e from"../../../tiling/TileKey.js";import"../../../tiling/TileQueue.js";import"../../../tiling/TileStrategy.js";import{tileSize as s}from"../definitions.js";import{MeshData as t}from"./MeshData.js";import{getPow2NeighborKey as r}from"../../../layers/features/support/tileUtils.js";const i=1,n=2,h=4,o=8,c=16,a=32,l=64,m=128;function u(e){switch(e){case i:case o:case a:return-1;case n:case l:return 0;case h:case c:case m:return 1}}function f(e){switch(e){case i:case n:case h:return-1;case o:case c:return 0;case a:case l:case m:return 1}}const _=i|o|a,d=h|c|m,p=i|n|h,g=a|l|m;class y{constructor(e,s,r=0){this.tileKey=e,this._bufferingEnabled=s,this._sizeHint=r,this._meshes={self:new t(this.id,this._sizeHint),neighbors:new Array},this._currentRecordOverlaps=0,this._currentEntityOverlaps=0}get id(){return this.tileKey}vertexCount(){return this._meshes.self.vertexCount()}indexCount(){return this._meshes.self.indexCount()}indexEnsureSize(e){this._meshes.self.indexEnsureSize(e)}entityStart(e,s=e){this._currentEntityOverlaps=0,this._meshes.self.entityStart(e,s)}entityRecordCount(){return this._meshes.self.entityRecordCount()}entityEnd(){if(this._meshes.self.entityEnd(),this._bufferingEnabled)for(let e=0;e<8;e++){const s=1<<e;!!(this._currentEntityOverlaps&s)&&this._meshes.neighbors[e].entityEnd()}}recordStart(e,s,t){this._currentRecordOverlaps=0,this._meshes.self.recordStart(e,s,t)}recordEnd(e=0){const s=this._meshes.self.recordEnd(this._currentRecordOverlaps);return s&&0!==this._currentRecordOverlaps?(this._copyIntoNeighbors(),this._currentEntityOverlaps|=this._currentRecordOverlaps,!0):s}recordBounds(e,s,t,r){this._bufferingEnabled&&this._addOverlap(e,s,t,r)}recordCount(){return this._meshes.self.recordCount()}metricStart(e){this._meshes.self.metricStart(e)}metricBoxWrite(e){this._meshes.self.metricBoxWrite(e)}metricEnd(){this._meshes.self.metricEnd()}vertexWrite(e){this._meshes.self.vertexWrite(e)}vertexWriteF32(e){this._meshes.self.vertexWriteF32(e)}vertexWriteRegion(e){this._meshes.self.vertexWriteRegion(e)}indexWrite(e){this._meshes.self.indexWrite(e)}serialize(s){const t={message:[],transferList:[]},i=this._meshes.self.serialize();return t.message.push({tileId:this.tileKey,...i.message}),t.transferList.push(...i.transferList),this._meshes.neighbors.forEach(((i,n)=>{const h=i.serialize(),o=1<<n,c=u(o),a=f(o),l=r(new e(this.tileKey),c,a,s);t.message.push({tileId:l.id,...h.message}),t.transferList.push(...h.transferList)})),t}_addOverlap(e,t,r,i){const n=Math.min(s/2,r),h=Math.min(s/2,i),o=255^((e<0+n?d:e>=s-n?_:d|_)|(t<0+h?g:t>=s-h?p:g|p));this._currentRecordOverlaps|=o}_copyIntoNeighbors(){for(let e=0;e<8;e++){const r=1<<e;if(!!(this._currentRecordOverlaps&r)){if(!this._meshes.neighbors[e]){const s=Math.floor(this._sizeHint/16);this._meshes.neighbors[e]=new t(r,s)}const i=this._meshes.neighbors[e],n=-u(r)*s,h=-f(r)*s;i.copyLastFrom(this._meshes.self,n,h)}}}}export{y as MultiTileMeshData};
5
+ import"../../../tiling/TileInfoView.js";import e from"../../../tiling/TileKey.js";import"../../../tiling/TileQueue.js";import"../../../tiling/TileStrategy.js";import{tileSize as s}from"../definitions.js";import{MeshData as t}from"./MeshData.js";import{getPow2NeighborKey as r}from"../../../layers/features/support/tileUtils.js";const i=1,n=2,h=4,o=8,c=16,a=32,l=64,f=128;function u(e){switch(e){case i:case o:case a:return-1;case n:case l:return 0;case h:case c:case f:return 1}}function m(e){switch(e){case i:case n:case h:return-1;case o:case c:return 0;case a:case l:case f:return 1}}const _=i|o|a,d=h|c|f,p=i|n|h,y=a|l|f;class g{constructor(e,s,r,i=0){this.tileKey=e,this._bufferingEnabled=s,this._sizeHint=i,this._meshes={self:new t(this.id,this._sizeHint),neighbors:new Array},this._currentRecordOverlaps=0,this._currentEntityOverlaps=0,this._copyBufferedDataIntoSelf=r&&this._bufferingEnabled&&0===e.level}get id(){return this.tileKey.id}vertexCount(){return this._meshes.self.vertexCount()}indexCount(){return this._meshes.self.indexCount()}indexEnsureSize(e){this._meshes.self.indexEnsureSize(e)}entityStart(e,s=e){this._currentEntityOverlaps=0,this._meshes.self.entityStart(e,s)}entityRecordCount(){return this._meshes.self.entityRecordCount()}entityEnd(){if(this._meshes.self.entityEnd(),this._bufferingEnabled){if(this._copyBufferedDataIntoSelf)return;for(let e=0;e<8;e++){const s=1<<e;!!(this._currentEntityOverlaps&s)&&this._meshes.neighbors[e].entityEnd()}}}recordStart(e,s,t){this._currentRecordOverlaps=0,this._meshes.self.recordStart(e,s,t)}recordEnd(e=0){const s=this._meshes.self.recordEnd(this._currentRecordOverlaps);return s&&0!==this._currentRecordOverlaps?(this._copyIntoNeighbors(),this._currentEntityOverlaps|=this._currentRecordOverlaps,!0):s}recordBounds(e,s,t,r){this._bufferingEnabled&&this._addOverlap(e,s,t,r)}recordCount(){return this._meshes.self.recordCount()}metricStart(e){this._meshes.self.metricStart(e)}metricBoxWrite(e){this._meshes.self.metricBoxWrite(e)}metricEnd(){this._meshes.self.metricEnd()}vertexWrite(e){this._meshes.self.vertexWrite(e)}vertexWriteF32(e){this._meshes.self.vertexWriteF32(e)}vertexWriteRegion(e){this._meshes.self.vertexWriteRegion(e)}indexWrite(e){this._meshes.self.indexWrite(e)}serialize(s){const t={message:[],transferList:[]},i=this._meshes.self.serialize();return t.message.push({tileId:this.tileKey.id,...i.message}),t.transferList.push(...i.transferList),this._meshes.neighbors.forEach(((i,n)=>{const h=i.serialize(),o=1<<n,c=u(o),a=m(o),l=r(new e(this.tileKey),c,a,s);t.message.push({tileId:l.id,...h.message}),t.transferList.push(...h.transferList)})),t}_addOverlap(e,t,r,i){const n=Math.min(s/2,r),h=Math.min(s/2,i),o=255^((e<0+n?d:e>=s-n?_:d|_)|(t<0+h?y:t>=s-h?p:y|p));this._currentRecordOverlaps|=o}_copyIntoNeighbors(){for(let e=0;e<8;e++){const r=1<<e;if(!!(this._currentRecordOverlaps&r)){if(this._copyBufferedDataIntoSelf){const e=-u(r)*s,t=-m(r)*s;this._meshes.self.copyLast(e,t);continue}if(!this._meshes.neighbors[e]){const s=Math.floor(this._sizeHint/16);this._meshes.neighbors[e]=new t(r,s)}const i=this._meshes.neighbors[e],n=-u(r)*s,h=-m(r)*s;i.copyLastFrom(this._meshes.self,n,h)}}}}export{g as MultiTileMeshData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{memoize as e}from"../../../../../../../core/MapUtils.js";import{fromRotation as t}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as i}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{getXAnchorDirection as s,getYAnchorDirection as a}from"../../../alignmentUtils.js";import{getDisplayIdTexel as n}from"../../../DisplayId.js";import{LabelMetric as r}from"../../../collisions/LabelMetric.js";import{smoothPaths as o,pathDivide as l}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as h,processColorInput as c}from"../fill/meshWriterUtils.js";import{TextMeshWriter as m,maxLabelZoom as d}from"../text/TextMeshWriter.js";const u=1,g=0,p=128,f=e((e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t}));class x extends m{constructor(){super(...arguments),this._zoomLevel=0}_write(e,t,i,s){if(this._zoomLevel=s||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),s=t.readYForDisplay();return this._writePoint(e,i,s,t)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const i=t.readCentroidForDisplay();if(!i)return;const[s,a]=i.coords;return this._writePoint(e,s,a,t)}case"esriGeometryPolyline":{const i=t.readLegacyGeometryForDisplay();this._writeLines(e,t,i)}}}_writePoint(e,t,i,o){const l=this._getShaping();if(!l)return;let h=this._getPointReferenceBounds();h||(h={offsetX:0,offsetY:0,size:0});const c=l.boundsT,m=s(this.evaluatedMeshParams.horizontalAlignment),d=a(this.evaluatedMeshParams.verticalAlignment),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,g=this.evaluatedMeshParams.scaleInfo?.minScale??0,p=n(o.getDisplayId());e.metricStart(new r(p,t,i,m,d,u,g,h)),e.metricBoxWrite(c),this._writeGlyphs(e,o.getDisplayId(),t,i,l,0,h),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t,i){const{repeatLabel:s,scaleInfo:a}=this.evaluatedMeshParams,n=this.evaluatedMeshParams.repeatLabelDistance||128,r=this._getShaping();if(!r)return;this._current={out:e,id:t.getDisplayId(),shaping:r,zoomRange:h(a,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0}};const c=o(i.paths,r.bounds.width),m=this._placeSubdivGlyphs.bind(this),d=(r.bounds.width+n)/(1<<u);for(const o of c)l(o,d,m,!!s)}_placeSubdivGlyphs(e,t,i,s){const{allowOverrun:a,labelPosition:n,repeatLabelDistance:r}=this.evaluatedMeshParams,o=this._current.zoomRange[0],l=f(t),h=this._current.shaping.bounds.width/(1<<u),c=Math.sqrt(r||p)/(1<<u),m=Math.min(i,s-i),g=this._current.shaping.isMultiline?d:Math.log2(m/(c+h/2)),x=0===t?g:Math.min(l,g),_=Math.max(o,this._zoomLevel+u-x),M=this._zoomLevel-_,y=this._current.shaping.bounds.width/2*2**M;this._current.shaping.isMultiline?0===t&&this._placeStraight(e,_):a&&M<0?this._placeStraightAlong(e,o):"parallel"===n?this._placeStraightAlong(e,_):"curved"===n&&this._placeCurved(e,_,y)}_placeStraight(e,s){const{out:a,id:o,shaping:l,zoomRange:h,referenceBounds:c}=this._current,{x:m,y:u}=e,g=e.angle*(180/Math.PI)%360,p=(e.angle*(180/Math.PI)+180)%360;if(l.textBox){const n=Math.max(s,h[0],0),r=Math.min(d,h[1]),m=t(i(),-e.angle),[u,f]=l.shapeBackground(m),x={minZoom:n,maxZoom:r,clipAngle:g,mapAligned:!0,isLineLabel:!0};a.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding),this._writeTextBox(a,o,e.x,e.y,f,c,x),a.recordEnd(),x.clipAngle=p,a.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding),this._writeTextBox(a,o,e.x,e.y,f,c,x),a.recordEnd()}const f=n(o),x=this.evaluatedMeshParams.scaleInfo?.maxScale??0,_=this.evaluatedMeshParams.scaleInfo?.minScale??0;a.metricStart(new r(f,e.x,e.y,0,0,x,_,null)),a.metricBoxWrite(l.bounds);for(const t of l.glyphs)t.minZoom=s,t.maxZoom=h[1],t.angle=e.angle,this._writeLineGlyph(a,o,m,u,l.bounds,t,g,c,!0),t.angle=e.angle+Math.PI,this._writeLineGlyph(a,o,m,u,l.bounds,t,p,c,!0);a.metricEnd()}_placeCurved(e,t,i){const{out:s,id:a}=this._current,o=e.clone(),l=e.angle*(180/Math.PI)%360,h=(e.angle*(180/Math.PI)+180)%360,c=n(a),m=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new r(c,e.x,e.y,0,0,m,d,null)),this._placeFirst(o,t,1,l),this._placeBack(e,o,t,i,1,l),this._placeForward(e,o,t,i,1,l),this._placeFirst(o,t,0,h),this._placeBack(e,o,t,i,0,h),this._placeForward(e,o,t,i,0,h),s.metricEnd()}_placeStraightAlong(e,s){const{out:a,id:o,shaping:l,zoomRange:h,referenceBounds:c}=this._current,{boxBorderLineColor:m,boxBackgroundColor:u}=this.evaluatedMeshParams,g=e.clone(),p=e.angle*(180/Math.PI)%360,f=(e.angle*(180/Math.PI)+180)%360;if(l.glyphs.length>0&&(m||u)){const n=Math.max(s,h[0],0),r=Math.min(d,h[1]),m=t(i(),-e.angle),[u,g]=l.shapeBackground(m),x={minZoom:n,maxZoom:r,clipAngle:p,mapAligned:!0,isLineLabel:!0};a.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding),this._writeTextBox(a,o,e.x,e.y,g,c,x),a.recordEnd(),x.clipAngle=f,a.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding),this._writeTextBox(a,o,e.x,e.y,g,c,x),a.recordEnd()}const x=n(o),_=this.evaluatedMeshParams.scaleInfo?.maxScale??0,M=this.evaluatedMeshParams.scaleInfo?.minScale??0;a.metricStart(new r(x,e.x,e.y,0,0,_,M,null)),this._placeFirst(g,s,1,p,!0),this._placeFirst(g,s,0,f,!0),a.metricEnd()}_placeBack(e,t,i,s,a,n){const r=e.clone();let o=e.backwardLength+g;for(;r.prev()&&!(o>=s);)this._placeOnSegment(r,t,o,i,-1,a,n),o+=r.length+g}_placeForward(e,t,i,s,a,n){const r=e.clone();let o=e.remainingLength+g;for(;r.next()&&!(o>=s);)this._placeOnSegment(r,t,o,i,1,a,n),o+=r.length+g}_placeFirst(e,t,i,s,a=!1){const n=e,{out:r,id:o,shaping:l,zoomRange:h,referenceBounds:c}=this._current,m=l.glyphs;for(const u of m){const m=u.x>l.bounds.x?i:1-i,p=m*e.remainingLength+(1-m)*e.backwardLength,f=Math.abs(u.x+u.width/2-l.bounds.x),x=Math.max(0,this._zoomLevel+Math.log2(f/(p+g))),_=Math.max(t,a?0:x);u.maxZoom=Math.min(h[1],d),u.angle=e.angle+(1-i)*Math.PI,u.minZoom=Math.max(h[0],_),r.metricBoxWrite(u.bounds),this._writeLineGlyph(r,o,n.x,n.y,l.bounds,u,s,c,!0)}}_placeOnSegment(e,t,i,s,a,n,r){const{out:o,id:l,shaping:h,referenceBounds:c}=this._current,m=h.glyphs,d=e.dx/e.length,u=e.dy/e.length,p={x:e.x+i*-a*d,y:e.y+i*-a*u};for(const f of m){const t=f.x>h.bounds.x?n:1-n;if(!(t&&1===a||!t&&-1===a))continue;const m=Math.abs(f.x+f.width/2-h.bounds.x),d=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),u=Math.max(s,this._zoomLevel+Math.log2(m/(i+e.length+g)));0!==d&&(f.angle=e.angle+(1-n)*Math.PI,f.minZoom=u,f.maxZoom=d,this._writeLineGlyph(o,l,p.x,p.y,h.bounds,f,r,c,!0))}}_writeLineGlyph(e,t,i,s,a,n,r,o,l){const h=i+a.x,m=s+a.y,d=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),u=Math.max(a.width,a.height)*d;e.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),e.recordBounds(h,m,u,u);const{texcoords:g,offsets:p}=n,f=this._textMeshTransformProps.fontSize;this._writeQuad(e,t,i,s,{texcoords:g,offsets:p,fontSize:f,color:c(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:o,minZoom:Math.max(this._current.zoomRange[0],n.minZoom),maxZoom:Math.min(this._current.zoomRange[1],n.maxZoom),clipAngle:r,mapAligned:l,isLineLabel:!0}),e.recordEnd()}}export{x as LabelMeshWriter};
5
+ import{memoize as e}from"../../../../../../../core/MapUtils.js";import{fromRotation as t}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as i}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{getXAnchorDirection as s,getYAnchorDirection as a}from"../../../alignmentUtils.js";import{getDisplayIdTexel as o}from"../../../DisplayId.js";import n from"../../../collisions/BoundingBox.js";import{LabelMetric as r}from"../../../collisions/LabelMetric.js";import{smoothPaths as l,pathDivide as h}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as c,processColorInput as m}from"../fill/meshWriterUtils.js";import{TextMeshWriter as d,maxLabelZoom as u}from"../text/TextMeshWriter.js";const g=1,p=0,f=128,_=e((e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t}));class x extends d{constructor(){super(...arguments),this._zoomLevel=0}_write(e,t,i,s){if(this._zoomLevel=s||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),s=t.readYForDisplay();return this._writePoint(e,i,s,t)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const i=t.readCentroidForDisplay();if(!i)return;const[s,a]=i.coords;return this._writePoint(e,s,a,t)}case"esriGeometryPolyline":{const i=t.readLegacyGeometryForDisplay();this._writeLines(e,t,i)}}}_writePoint(e,t,i,n){const l=this._getShaping();if(!l)return;let h=this._getPointReferenceBounds();h||(h={offsetX:0,offsetY:0,size:0});const c=l.boundsT,m=s(this.evaluatedMeshParams.horizontalAlignment),d=a(this.evaluatedMeshParams.verticalAlignment),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,g=this.evaluatedMeshParams.scaleInfo?.minScale??0,p=o(n.getDisplayId());e.metricStart(new r(p,t,i,m,d,u,g,h)),e.metricBoxWrite(c),this._writeGlyphs(e,n.getDisplayId(),t,i,l,0,h),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t,i){const{repeatLabel:s,scaleInfo:a}=this.evaluatedMeshParams,o=this.evaluatedMeshParams.repeatLabelDistance||128,n=this._getShaping();if(!n)return;this._current={out:e,id:t.getDisplayId(),shaping:n,zoomRange:c(a,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0}};const r=l(i.paths,n.bounds.width),m=this._placeSubdivGlyphs.bind(this),d=(n.bounds.width+o)/(1<<g);for(const l of r)h(l,d,m,!!s)}_placeSubdivGlyphs(e,t,i,s){const{allowOverrun:a,labelPosition:o,repeatLabelDistance:n}=this.evaluatedMeshParams,r=this._current.zoomRange[0],l=_(t),h=this._current.shaping.bounds.width/(1<<g),c=Math.sqrt(n||f)/(1<<g),m=Math.min(i,s-i),d=this._current.shaping.isMultiline?u:Math.log2(m/(c+h/2)),p=0===t?d:Math.min(l,d),x=Math.max(r,this._zoomLevel+g-p),M=this._zoomLevel-x,y=this._current.shaping.bounds.width/2*2**M;this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x):a&&M<0?this._placeStraightAlong(e,r):"parallel"===o?this._placeStraightAlong(e,x):"curved"===o&&this._placeCurved(e,x,y)}_placeStraight(e,t){const{out:i,id:s,shaping:a,referenceBounds:n}=this._current,{x:l,y:h}=e,c=o(s),m=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0;i.metricStart(new r(c,e.x,e.y,0,0,m,d,null)),i.metricBoxWrite(a.boundsT);const u=e.angle*(180/Math.PI)%360,g=(e.angle*(180/Math.PI)+180)%360;this._writeGlyphs(i,s,l,h,a,0,n,{clipAngle:u,mapAligned:!0,isLineLabel:!0,minZoom:t}),this._writeGlyphs(i,s,l,h,a,0,n,{clipAngle:g,mapAligned:!0,isLineLabel:!0,minZoom:t}),i.metricEnd()}_placeCurved(e,t,i){const{out:s,id:a}=this._current,n=e.clone(),l=e.angle*(180/Math.PI)%360,h=(e.angle*(180/Math.PI)+180)%360,c=o(a),m=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new r(c,e.x,e.y,0,0,m,d,null)),this._placeFirst(n,t,1,l),this._placeBack(e,n,t,i,1,l),this._placeForward(e,n,t,i,1,l),this._placeFirst(n,t,0,h),this._placeBack(e,n,t,i,0,h),this._placeForward(e,n,t,i,0,h),s.metricEnd()}_placeStraightAlong(e,s){const{out:a,id:n,shaping:l,zoomRange:h,referenceBounds:c}=this._current,{boxBorderLineColor:m,boxBackgroundColor:d}=this.evaluatedMeshParams,g=e.clone(),p=e.angle*(180/Math.PI)%360,f=(e.angle*(180/Math.PI)+180)%360;if(l.glyphs.length>0&&(m||d)){const o=Math.max(s,h[0],0),r=Math.min(u,h[1]),m=t(i(),-e.angle),[d,g]=l.shapeBackground(m),_={minZoom:o,maxZoom:r,clipAngle:p,mapAligned:!0,isLineLabel:!0};a.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding),this._writeTextBox(a,n,e.x,e.y,g,c,_),a.recordEnd(),_.clipAngle=f,a.recordStart(this.instanceId,this.attributeLayout,l.glyphs[0].textureBinding),this._writeTextBox(a,n,e.x,e.y,g,c,_),a.recordEnd()}const _=o(n),x=this.evaluatedMeshParams.scaleInfo?.maxScale??0,M=this.evaluatedMeshParams.scaleInfo?.minScale??0;a.metricStart(new r(_,e.x,e.y,0,0,x,M,null)),this._placeFirst(g,s,1,p,!0),this._placeFirst(g,s,0,f,!0),a.metricEnd()}_placeBack(e,t,i,s,a,o){const n=e.clone();let r=e.backwardLength+p;for(;n.prev()&&!(r>=s);)this._placeOnSegment(n,t,r,i,-1,a,o),r+=n.length+p}_placeForward(e,t,i,s,a,o){const n=e.clone();let r=e.remainingLength+p;for(;n.next()&&!(r>=s);)this._placeOnSegment(n,t,r,i,1,a,o),r+=n.length+p}_placeFirst(e,t,i,s,a=!1){const o=e,{out:n,id:r,shaping:l,zoomRange:h,referenceBounds:c}=this._current,m=l.glyphs;for(const d of m){const m=d.x>l.bounds.x?i:1-i,g=m*e.remainingLength+(1-m)*e.backwardLength,f=Math.abs(d.x+d.width/2-l.bounds.x),_=Math.max(0,this._zoomLevel+Math.log2(f/(g+p))),x=Math.max(t,a?0:_);d.maxZoom=Math.min(h[1],u),d.angle=e.angle+(1-i)*Math.PI,d.minZoom=Math.max(h[0],x),this._writeLineGlyph(n,r,o.x,o.y,l.bounds,d,s,c,!0),i&&this._isVisible(d.minZoom,d.maxZoom)&&n.metricBoxWrite(d.bounds)}}_placeOnSegment(e,t,i,s,a,o,r){const{out:l,id:h,shaping:c,referenceBounds:m}=this._current,d=c.glyphs,u=e.dx/e.length,g=e.dy/e.length,f={x:e.x+i*-a*u,y:e.y+i*-a*g};for(const _ of d){const d=_.x>c.bounds.x?o:1-o;if(!(d&&1===a||!d&&-1===a))continue;const u=Math.abs(_.x+_.width/2-c.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(u/i)-.1),x=Math.max(s,this._zoomLevel+Math.log2(u/(i+e.length+p)));if(0!==g&&(_.angle=e.angle+(1-o)*Math.PI,_.minZoom=x,_.maxZoom=g,this._writeLineGlyph(l,h,f.x,f.y,c.bounds,_,r,m,!0),o&&this._isVisible(_.minZoom,_.maxZoom))){const i=_.bounds,s=e.x-t.x,a=e.y-t.y,o=new n(i.center[0]+s,i.center[1]+a,i.width,i.height);l.metricBoxWrite(o)}}}_writeLineGlyph(e,t,i,s,a,o,n,r,l){const h=i+a.x,c=s+a.y,d=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),u=Math.max(a.width,a.height)*d;e.recordStart(this.instanceId,this.attributeLayout,o.textureBinding),e.recordBounds(h,c,u,u);const{texcoords:g,offsets:p}=o,f=this._textMeshTransformProps.fontSize;this._writeQuad(e,t,i,s,{texcoords:g,offsets:p,fontSize:f,color:m(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:r,minZoom:Math.max(this._current.zoomRange[0],o.minZoom),maxZoom:Math.min(this._current.zoomRange[1],o.maxZoom),clipAngle:n,mapAligned:l,isLineLabel:!0}),e.recordEnd()}_isVisible(e,t){const i=this._zoomLevel;return e<=i&&i<=t}}export{x as LabelMeshWriter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{CIMMarkerPlacementHelper as r}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as i,getYDirection as s}from"../../../alignmentUtils.js";import{minMaxZoomPrecisionFactor as n,magicLabelLineHeight as a,glyphSize as c}from"../../../definitions.js";import{shapeGlyphs as l}from"../../../mesh/templates/shapingUtils.js";import{packBitset as h,processColorInput as p}from"../fill/meshWriterUtils.js";import{getGeometryEngine as f}from"../mesh/loadGeometryEngine.js";import{MeshWriter as m}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as d,bitsetTextIsMapAligned as u}from"../shaders/constants.js";import{TextMeshTransformProps as g}from"./TextParams.js";import{DataType as x}from"../../../../../../webgl/enums.js";const y=28,_=[4,4],P=[16,4],S={topLeft:P,topRight:P,bottomLeft:P,bottomRight:P},k=[4,2],b=[4,6],T={topLeft:k,topRight:k,bottomLeft:b,bottomRight:b},B={topLeft:k,topRight:b,bottomLeft:k,bottomRight:b},R={topLeft:b,topRight:b,bottomLeft:_,bottomRight:_},w={topLeft:_,topRight:_,bottomLeft:b,bottomRight:b},M={topLeft:b,topRight:_,bottomLeft:b,bottomRight:_},z={topLeft:_,topRight:b,bottomLeft:_,bottomRight:b},L={createComputedParams:t=>t,attributes:{pos:{type:x.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:x.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:x.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>h([[d,t],[u,!!e]])},zoomRange:{type:x.UNSIGNED_SHORT,count:2,packPrecisionFactor:n,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||y]},offset:{type:x.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:r,topRight:i}=t;return[r,i,e,o]}}},textureUV:{type:x.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:r,topRight:i}=t;return[r,i,e,o]}}},color:{type:x.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:x.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>e(t)},referenceSize:{type:x.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:o})=>e(o??t)},haloColor:{type:x.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>p(t)},haloFontSize:{type:x.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,pack:({haloFontSize:t})=>e(t)},clipAngle:{type:x.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>G(t||0)},referenceSymbol:{type:x.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,o)=>{if(!t.referenceBounds)return[0,0,0,0];const r=i(o.horizontalAlignment),n=s(o.verticalAlignment),{offsetX:a,offsetY:c,size:l}=t.referenceBounds;return[e(a),-e(c),e(l),r+1<<2|n+1]}}}};class E extends m{constructor(){super(...arguments),this.vertexSpec=L,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new g(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,o){const r=this._getShaping();if(!r)return;const i=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,r,o);if(o&&o.nextPath())return o.nextPoint(),this._writeGlyphs(t,i,o.x,o.y,r,0);if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[s,n]=o.coords;return this._writeGlyphs(t,i,s,n,r,0)}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex(((e,o)=>this._writeGlyphs(t,i,e,o,r,0)))}const s=e.readXForDisplay(),n=e.readYForDisplay();return this._writeGlyphs(t,i,s,n,r,0)}_writePlacedTextMarkers(t,i,s,n){const a=n??o.fromFeatureSetReaderCIM(i);if(!a)return;const c=-1,l=r.getPlacement(a,c,this.evaluatedMeshParams.placement,e(1),t.id,f());if(!l)return;const h=i.getDisplayId();let p=l.next();for(;null!=p;){const e=p.tx,o=-p.ty,r=-p.getAngle();this._writeGlyphs(t,h,e,o,s,r),p=l.next()}}_getShaping(){const o=this._textMeshTransformProps,r=this.evaluatedMeshParams;if(!r.glyphs?.glyphs.length)return null;const i=Math.round(e(o.fontSize)),s=e(o.offsetX),n=e(o.offsetY),h=t(e(r.lineWidth),32,512),p=a*t(r.lineHeightRatio,.25,4);return l(r.glyphs,{scale:i/c,angle:o.postAngle,xOffset:s,yOffset:n,horizontalAlignment:r.horizontalAlignment,verticalAlignment:r.verticalAlignment,maxLineWidth:h,lineHeight:p,decoration:r.decoration,borderLineSizePx:e(r.boxBorderLineSize),hasBackground:!!r.boxBackgroundColor,useCIMAngleBehavior:r.useCIMAngleBehavior})}_writeGlyphs(t,o,r,i,s,n,a){const c=this.evaluatedMeshParams,l=this._textMeshTransformProps,h=l.fontSize,f=e(l.offsetX),m=e(l.offsetY);0!==n&&s.setRotation(n);const d=s.bounds,u=r+d.x+f,g=i+d.y-m,x=2*(c.minPixelBuffer?c.minPixelBuffer/h:1),y=Math.max(d.width,d.height)*x;s.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,s.glyphs[0].textureBinding),t.recordBounds(u,g,y,y),this._writeTextBox(t,o,r,i,s.textBox,a),t.recordEnd());for(const e of s.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),t.recordBounds(u,g,y,y);const{texcoords:s,offsets:n}=e;this._writeQuad(t,o,r,i,{texcoords:s,offsets:n,fontSize:h,color:p(c.color),isBackground:!1,referenceBounds:a}),t.recordEnd()}0!==n&&s.setRotation(-n)}_writeTextBox(t,e,o,r,i,s,n){const a=this.evaluatedMeshParams,{fontSize:c}=this._textMeshTransformProps,{boxBackgroundColor:l,boxBorderLineColor:h}=a,f={isBackground:!0,fontSize:c,referenceBounds:s,...n};l&&(this._writeQuad(t,e,o,r,{texcoords:S,offsets:i.main,color:p(l),...f}),h||(this._writeQuad(t,e,o,r,{texcoords:R,offsets:i.top,color:p(l),...f}),this._writeQuad(t,e,o,r,{texcoords:w,offsets:i.bot,color:p(l),...f}),this._writeQuad(t,e,o,r,{texcoords:M,offsets:i.left,color:p(l),...f}),this._writeQuad(t,e,o,r,{texcoords:z,offsets:i.right,color:p(l),...f}))),h&&(this._writeQuad(t,e,o,r,{texcoords:T,offsets:i.top,color:p(h),...f}),this._writeQuad(t,e,o,r,{texcoords:T,offsets:i.bot,color:p(h),...f}),this._writeQuad(t,e,o,r,{texcoords:B,offsets:i.left,color:p(h),...f}),this._writeQuad(t,e,o,r,{texcoords:B,offsets:i.right,color:p(h),...f}))}_writeQuad(t,e,o,r,i){const s=t.vertexCount();this._writeVertex(t,e,o,r,i),t.indexWrite(s+0),t.indexWrite(s+1),t.indexWrite(s+2),t.indexWrite(s+1),t.indexWrite(s+3),t.indexWrite(s+2)}}const G=t=>Math.round(t*(254/360));export{E as TextMeshWriter,L as TextVertexSpec,y as maxLabelZoom};
5
+ import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{CIMMarkerPlacementHelper as r}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as i,getYDirection as s}from"../../../alignmentUtils.js";import{minMaxZoomPrecisionFactor as n,magicLabelLineHeight as a,glyphSize as c}from"../../../definitions.js";import{shapeGlyphs as l}from"../../../mesh/templates/shapingUtils.js";import{packBitset as f,processColorInput as h,getMinMaxZoom as p}from"../fill/meshWriterUtils.js";import{getGeometryEngine as m}from"../mesh/loadGeometryEngine.js";import{MeshWriter as d}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as u,bitsetTextIsMapAligned as g}from"../shaders/constants.js";import{TextMeshTransformProps as x}from"./TextParams.js";import{DataType as y}from"../../../../../../webgl/enums.js";const _=28,P=[4,4],S=[16,4],k={topLeft:S,topRight:S,bottomLeft:S,bottomRight:S},T=[4,2],b=[4,6],B={topLeft:T,topRight:T,bottomLeft:b,bottomRight:b},R={topLeft:T,topRight:b,bottomLeft:T,bottomRight:b},w={topLeft:b,topRight:b,bottomLeft:P,bottomRight:P},M={topLeft:P,topRight:P,bottomLeft:b,bottomRight:b},z={topLeft:b,topRight:P,bottomLeft:b,bottomRight:P},L={topLeft:P,topRight:b,bottomLeft:P,bottomRight:b},I={createComputedParams:t=>t,attributes:{pos:{type:y.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:y.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>f([[u,t],[g,!!e]])},zoomRange:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:n,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||_]},offset:{type:y.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:r,topRight:i}=t;return[r,i,e,o]}}},textureUV:{type:y.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:r,topRight:i}=t;return[r,i,e,o]}}},color:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:y.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>e(t)},referenceSize:{type:y.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:o})=>e(o??t)},haloColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>h(t)},haloFontSize:{type:y.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,pack:({haloFontSize:t})=>e(t)},clipAngle:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>G(t||0)},referenceSymbol:{type:y.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,o)=>{if(!t.referenceBounds)return[0,0,0,0];const r=i(o.horizontalAlignment),n=s(o.verticalAlignment),{offsetX:a,offsetY:c,size:l}=t.referenceBounds;return[e(a),-e(c),e(l),r+1<<2|n+1]}}}};class E extends d{constructor(){super(...arguments),this.vertexSpec=I,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new x(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,o){const r=this._getShaping();if(!r)return;const i=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,r,o);if(o&&o.nextPath())return o.nextPoint(),this._writeGlyphs(t,i,o.x,o.y,r,0);if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[s,n]=o.coords;return this._writeGlyphs(t,i,s,n,r,0)}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex(((e,o)=>this._writeGlyphs(t,i,e,o,r,0)))}const s=e.readXForDisplay(),n=e.readYForDisplay();return this._writeGlyphs(t,i,s,n,r,0)}_writePlacedTextMarkers(t,i,s,n){const a=n??o.fromFeatureSetReaderCIM(i);if(!a)return;const c=-1,l=r.getPlacement(a,c,this.evaluatedMeshParams.placement,e(1),t.id,m());if(!l)return;const f=i.getDisplayId();let h=l.next();for(;null!=h;){const e=h.tx,o=-h.ty,r=-h.getAngle();this._writeGlyphs(t,f,e,o,s,r),h=l.next()}}_getShaping(){const o=this._textMeshTransformProps,r=this.evaluatedMeshParams;if(!r.glyphs?.glyphs.length)return null;const i=Math.round(e(o.fontSize)),s=e(o.offsetX),n=e(o.offsetY),f=t(e(r.lineWidth),32,512),h=a*t(r.lineHeightRatio,.25,4);return l(r.glyphs,{scale:i/c,angle:o.postAngle,xOffset:s,yOffset:n,horizontalAlignment:r.horizontalAlignment,verticalAlignment:r.verticalAlignment,maxLineWidth:f,lineHeight:h,decoration:r.decoration,borderLineSizePx:e(r.boxBorderLineSize),hasBackground:!!r.boxBackgroundColor,useCIMAngleBehavior:r.useCIMAngleBehavior})}_writeGlyphs(t,o,r,i,s,n,a,c){const l=this.evaluatedMeshParams,f=this._textMeshTransformProps,m=f.fontSize,d=e(f.offsetX),u=e(f.offsetY),[g,x]=p(l.scaleInfo,this.getTileInfo());0!==n&&s.setRotation(n);const y=s.bounds,_=r+y.x+d,P=i+y.y-u,S=2*(l.minPixelBuffer?l.minPixelBuffer/m:1),k=Math.max(y.width,y.height)*S;s.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,s.glyphs[0].textureBinding),t.recordBounds(_,P,k,k),this._writeTextBox(t,o,r,i,s.textBox,a,c),t.recordEnd());for(const e of s.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),t.recordBounds(_,P,k,k);const{texcoords:s,offsets:n}=e;this._writeQuad(t,o,r,i,{texcoords:s,offsets:n,fontSize:m,color:h(l.color),isBackground:!1,referenceBounds:a,minZoom:g,maxZoom:x,...c}),t.recordEnd()}0!==n&&s.setRotation(-n)}_writeTextBox(t,e,o,r,i,s,n){const a=this.evaluatedMeshParams,{fontSize:c}=this._textMeshTransformProps,{boxBackgroundColor:l,boxBorderLineColor:f}=a,p={isBackground:!0,fontSize:c,referenceBounds:s,...n};l&&(this._writeQuad(t,e,o,r,{texcoords:k,offsets:i.main,color:h(l),...p}),f||(this._writeQuad(t,e,o,r,{texcoords:w,offsets:i.top,color:h(l),...p}),this._writeQuad(t,e,o,r,{texcoords:M,offsets:i.bot,color:h(l),...p}),this._writeQuad(t,e,o,r,{texcoords:z,offsets:i.left,color:h(l),...p}),this._writeQuad(t,e,o,r,{texcoords:L,offsets:i.right,color:h(l),...p}))),f&&(this._writeQuad(t,e,o,r,{texcoords:B,offsets:i.top,color:h(f),...p}),this._writeQuad(t,e,o,r,{texcoords:B,offsets:i.bot,color:h(f),...p}),this._writeQuad(t,e,o,r,{texcoords:R,offsets:i.left,color:h(f),...p}),this._writeQuad(t,e,o,r,{texcoords:R,offsets:i.right,color:h(f),...p}))}_writeQuad(t,e,o,r,i){const s=t.vertexCount();this._writeVertex(t,e,o,r,i),t.indexWrite(s+0),t.indexWrite(s+1),t.indexWrite(s+2),t.indexWrite(s+1),t.indexWrite(s+3),t.indexWrite(s+2)}}const G=t=>Math.round(t*(254/360));export{E as TextMeshWriter,I as TextVertexSpec,_ as maxLabelZoom};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import"../../../../core/Logger.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as r,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/InstanceStore.js";import{RenderState as h}from"./RenderState.js";import{renderHighlight as d}from"../support/util.js";class l{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class u extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._layerView=e}renderChildren(e){if(this.attributeView.update(),this._renderState){const e=Array.from(this._renderState.tiles()).filter((e=>e.needsUpload));if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this.requestRender())}for(const t of this.children)t.setTransform(e.state);if(super.renderChildren(e),this.hasAnimation){e.painter.effects.integrate.draw(e,e.attributeView)}switch(e.drawPhase){case r.MAP:return this._renderMapPhase(e);case r.HIGHLIGHT:return this._renderHighlightPhase(e);case r.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight()}get _layer(){return this._layerView.layer}_getExclusivePostprocessingInstance({drawPhase:e}){if(null==this._instanceStore)return null;let t=0,s=null;for(const i of this._instanceStore.values())i.techniqueRef.drawPhase&e&&(t++,i.techniqueRef.postProcessingEnabled&&(s=i));return t>1?null:s}_getOverrideStencilRef({drawPhase:e}){if(null==this._instanceStore)return null;let t=null;for(const s of this._instanceStore.values()){if(!(s.techniqueRef.drawPhase&e))continue;const{overrideStencilRef:i}=s.techniqueRef;if(null==t)t=i;else if(t!==i){t=null;break}}return t}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter((e=>this._visibleTiles.has(e.key.id))):[]}async updateAttributeView(e){this.requestRender(),await this.updatingHandles.addPromise(this.attributeView.requestUpdate(e)),this.hasLabels&&this._layerView.view.labelManager.requestUpdate()}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe)if(this._subscriptions.has(t))this._subscriptions.get(t).version=s;else{const e=new l(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise)}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new h((()=>this._stage),e,this._tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const i of t)s.set(i.fieldName,{minValue:i.minValue,maxValue:i.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this.requestRender()}swapRenderState(){if(this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState)for(const e of this._renderState.tiles())e.upload();this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){if(e(s),!this._subscriptions.has(t.id))return;const i=this._subscriptions.get(t.id);if(i.version!==t.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${t.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${t.id}] FeatureContainer - Dropping message, outdated version]`,t)}return}const r=this._renderStateNext??this._renderState;if(!r)throw new Error("InternalError: No renderState defined");if(r.version!==t.version&&console.error(`InternalError: Version mismatch. [renderState: ${r.version}, message: ${t.version}]`),r.updateTile(t),t.end){this._subscriptions.get(t.id).end()}this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find((({x:t,y:s})=>t===e.x&&s===e.y));const i=t();return s?s.resolvers.push(i):(s={x:e.x,y:e.y,resolvers:[i]},this._hitTestsRequests.push(s)),this.requestRender(),i.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const i of this.children)if(i.getSortKeys(t).forEach(((e,t)=>s.set(t,e))),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}updateTransitionProperties(e,t){super.updateTransitionProperties(e,t),this._layerView.featureEffectView.transitionStep(e,t),this._layerView.featureEffectView.transitioning&&this.requestRender()}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,i=e.state.scale;i<=(t||1/0)&&i>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){const t=this._getOverrideStencilRef(e);if(null==t)super.setStencilReference(e);else for(const s of this.children)s.stencilRef=t(s)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&d(e,!1,(e=>{this._renderFeatures(e,n.Highlight)}))}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,i=t.getBoundFramebufferObject(),r=t.getViewport(),a=e.passOptions;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),this._renderFeatures(e,n.All),s.draw(e),s.unbind(),t.bindFramebuffer(i),t.restoreViewport(r),e.passOptions=a}_renderFeatures(e,t){for(const i of this.children){if(!i.visible)continue;const s=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,r=i.getDisplayList(e.drawPhase,this._instanceStore,s);e.selection=t,r?.render(e)}const s=this._getExclusivePostprocessingInstance(e);null!=s&&s.techniqueRef.postProcess(e,s)}}export{u as FeatureContainer};
5
+ import has from"../../../../core/has.js";import"../../../../core/Logger.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as r,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/InstanceStore.js";import{RenderState as h}from"./RenderState.js";import{renderHighlight as d}from"../support/util.js";class l{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class u extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._layerView=e}renderChildren(e){if(this.attributeView.update(),this._renderState){const e=Array.from(this._renderState.tiles()).filter((e=>e.needsUpload));if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this.requestRender())}for(const t of this.children)t.setTransform(e.state);if(this.hasAnimation){e.painter.effects.integrate.draw(e,e.attributeView)}switch(super.renderChildren(e),e.drawPhase){case r.MAP:return this._renderMapPhase(e);case r.HIGHLIGHT:return this._renderHighlightPhase(e);case r.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight()}get _layer(){return this._layerView.layer}_getExclusivePostprocessingInstance({drawPhase:e}){if(null==this._instanceStore)return null;let t=0,s=null;for(const i of this._instanceStore.values())i.techniqueRef.drawPhase&e&&(t++,i.techniqueRef.postProcessingEnabled&&(s=i));return t>1?null:s}_getOverrideStencilRef({drawPhase:e}){if(null==this._instanceStore)return null;let t=null;for(const s of this._instanceStore.values()){if(!(s.techniqueRef.drawPhase&e))continue;const{overrideStencilRef:i}=s.techniqueRef;if(null==t)t=i;else if(t!==i){t=null;break}}return t}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter((e=>this._visibleTiles.has(e.key.id))):[]}async updateAttributeView(e){this.requestRender(),await this.updatingHandles.addPromise(this.attributeView.requestUpdate(e)),this.hasLabels&&this._layerView.view.labelManager.requestUpdate()}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe)if(this._subscriptions.has(t))this._subscriptions.get(t).version=s;else{const e=new l(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise)}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new h((()=>this._stage),e,this._tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const i of t)s.set(i.fieldName,{minValue:i.minValue,maxValue:i.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this.requestRender()}swapRenderState(){if(this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState)for(const e of this._renderState.tiles())e.upload();this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){if(e(s),!this._subscriptions.has(t.id))return;const i=this._subscriptions.get(t.id);if(i.version!==t.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${t.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${t.id}] FeatureContainer - Dropping message, outdated version]`,t)}return}const r=this._renderStateNext??this._renderState;if(!r)throw new Error("InternalError: No renderState defined");if(r.version!==t.version&&console.error(`InternalError: Version mismatch. [renderState: ${r.version}, message: ${t.version}]`),r.updateTile(t),t.end){this._subscriptions.get(t.id).end()}this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find((({x:t,y:s})=>t===e.x&&s===e.y));const i=t();return s?s.resolvers.push(i):(s={x:e.x,y:e.y,resolvers:[i]},this._hitTestsRequests.push(s)),this.requestRender(),i.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const i of this.children)if(i.getSortKeys(t).forEach(((e,t)=>s.set(t,e))),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}updateTransitionProperties(e,t){super.updateTransitionProperties(e,t),this._layerView.featureEffectView.transitionStep(e,t),this._layerView.featureEffectView.transitioning&&this.requestRender()}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,i=e.state.scale;i<=(t||1/0)&&i>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){const t=this._getOverrideStencilRef(e);if(null==t)super.setStencilReference(e);else for(const s of this.children)s.stencilRef=t(s)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&d(e,!1,(e=>{this._renderFeatures(e,n.Highlight)}))}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,i=t.getBoundFramebufferObject(),r=t.getViewport(),a=e.passOptions;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),this._renderFeatures(e,n.All),s.draw(e),s.unbind(),t.bindFramebuffer(i),t.restoreViewport(r),e.passOptions=a}_renderFeatures(e,t){for(const i of this.children){if(!i.visible)continue;const s=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,r=i.getDisplayList(e.drawPhase,this._instanceStore,s);e.selection=t,r?.render(e)}const s=this._getExclusivePostprocessingInstance(e);null!=s&&s.techniqueRef.postProcess(e,s)}}export{u as FeatureContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{destroyMaybe as t}from"../../../../core/maybe.js";import{ignoreAbortErrors as e,throwIfNotAbortError as s,throwIfAborted as r}from"../../../../core/promiseUtils.js";import{diff as i,hasDiff as a}from"../../../../core/accessorSupport/diffUtils.js";import o from"../../../../geometry/SpatialReference.js";import{MultiTileMeshData as n}from"../../engine/webgl/mesh/MultiTileMeshData.js";import{FeatureMeshFactory as c}from"../../engine/webgl/mesh/factories/FeatureMeshFactory.js";import{ResourceProxy as h}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{ProcessorTileMessageQueue as u}from"./ProcessorTileMessageQueue.js";import{BinningStrategy as g}from"./processor/BinningStrategy.js";import{ClusterStrategy as d}from"./processor/ClusterStrategy.js";import{FeatureUpdateStrategy as y}from"./processor/FeatureUpdateStrategy.js";import{AttributeStore as _}from"./support/AttributeStore.js";import{ComputedAttributeStorage as p}from"./support/ComputedAttributeStorage.js";class l{constructor(t,s){this._connection=t,this._source=s,this._version=1,this._proxy=new h({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new _({isLocal:!1,update:t=>e(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destory(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,e,s,r,n){const h=t.processor,u=i(this._schema,h);if(!u&&!r)return;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:u,schema:h}),this._schema=h;const g=o.fromJSON(t.source.mutable.dataFilter.outSpatialReference),d=new p({fields:this._source.metadata.fieldsIndex,spatialReference:g});return await this._attributeStore.update(h.storage,d,this._source.metadata,g,e),this._strategy?.invalidateAttributeData(),r||a(u,"mesh")?(a(u,"mesh.strategy")&&await this._updateStrategy(h.mesh.strategy,g,n,h.mesh.timeZone),this._updateSortKey(d,"sortKey"in h.mesh?h.mesh.sortKey:null),(a(u,"mesh.factory")||"dictionary"===h.mesh.factory.symbology.type)&&(this._factory=await c.create(d,this._proxy,h.mesh.factory,s)),this._invalidate(),this._version=e,this._connection.container.updateRenderState(this._version)):void 0}async applyOverride(t){if(!this._strategy)return;const e=this._strategy.applyOverride(t);for await(const r of e)try{await this._process(r)}catch(s){}this._source.applyOverride(t)}async updateChunks(){await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],r=new Map;for await(const a of t){let t=r.get(a.id);null==t&&(t=new u({concurrency:16,process:t=>this._process(t)}),r.set(a.id,t));const i=t.push(a).catch((t=>s(t)));e.push(i)}try{await Promise.all(e)}catch(i){}has("esri-2d-update-debug")&&console.log("SendUpdates"),await this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,r){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new y(this._source,this._attributeStore,r);break;case"binning":this._strategy=await g.create(t,e,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await d.create(this._connection,t,e,this._source,this._attributeStore,r)}for(const i of s)this._strategy.onSubscribe(i)}async _updateSortKey(e,s){if(this._sortInfo=t(this._sortInfo?.computed),null!=s){const t=s.byRenderer?null:await e.createComputedField(s);this._sortInfo={...s,computed:t}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if(has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),r(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone)),i=e.tile.tileInfoView.tileInfo.isWrappable,{message:a,transferList:o}=s.serialize(i),n=t.createMessage(a,this._version,this._attributeStore.epoch);if(r(e.signal),this._connection.container.onMessage(n,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,r=t.reader?.getCursor(),i=r?.getSize()??0,a=new n(s.key.id,this._strategy.enablePixelBuffering,i);if(!r)return a;const o=s.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;r.next();){const t=this._getSortKeyValue(r,e);a.entityStart(r.getDisplayId(),t),this._factory.write(a,this._proxy,r,o,s.level),a.entityEnd()}return a}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,a=i?this._factory.getSortKey(t,e):s?.read(t,e);return null==a||isNaN(a)?0:a*("asc"===r?-1:1)}}export{l as default};
5
+ import has from"../../../../core/has.js";import{destroyMaybe as t}from"../../../../core/maybe.js";import{ignoreAbortErrors as e,throwIfNotAbortError as s,throwIfAborted as r}from"../../../../core/promiseUtils.js";import{diff as i,hasDiff as a}from"../../../../core/accessorSupport/diffUtils.js";import o from"../../../../geometry/SpatialReference.js";import{MultiTileMeshData as n}from"../../engine/webgl/mesh/MultiTileMeshData.js";import{FeatureMeshFactory as c}from"../../engine/webgl/mesh/factories/FeatureMeshFactory.js";import{ResourceProxy as h}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{ProcessorTileMessageQueue as u}from"./ProcessorTileMessageQueue.js";import{BinningStrategy as g}from"./processor/BinningStrategy.js";import{ClusterStrategy as d}from"./processor/ClusterStrategy.js";import{FeatureUpdateStrategy as y}from"./processor/FeatureUpdateStrategy.js";import{AttributeStore as p}from"./support/AttributeStore.js";import{ComputedAttributeStorage as _}from"./support/ComputedAttributeStorage.js";class l{constructor(t,s){this._connection=t,this._source=s,this._version=1,this._proxy=new h({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new p({isLocal:!1,update:t=>e(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destory(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,e,s,r,n){const h=t.processor,u=i(this._schema,h);if(!u&&!r)return;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:u,schema:h}),this._schema=h;const g=o.fromJSON(t.source.mutable.dataFilter.outSpatialReference),d=new _({fields:this._source.metadata.fieldsIndex,spatialReference:g});return await this._attributeStore.update(h.storage,d,this._source.metadata,g,e),this._strategy?.invalidateAttributeData(),r||a(u,"mesh")?(a(u,"mesh.strategy")&&await this._updateStrategy(h.mesh.strategy,g,n,h.mesh.timeZone),this._updateSortKey(d,"sortKey"in h.mesh?h.mesh.sortKey:null),(a(u,"mesh.factory")||"dictionary"===h.mesh.factory.symbology.type)&&(this._factory=await c.create(d,this._proxy,h.mesh.factory,s)),this._invalidate(),this._version=e,this._connection.container.updateRenderState(this._version)):void 0}async applyOverride(t){if(!this._strategy)return;const e=this._strategy.applyOverride(t);for await(const r of e)try{await this._process(r)}catch(s){}this._source.applyOverride(t)}async updateChunks(){await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],r=new Map;for await(const a of t){let t=r.get(a.id);null==t&&(t=new u({concurrency:16,process:t=>this._process(t)}),r.set(a.id,t));const i=t.push(a).catch((t=>s(t)));e.push(i)}try{await Promise.all(e)}catch(i){}has("esri-2d-update-debug")&&console.log("SendUpdates"),await this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,r){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new y(this._source,this._attributeStore,r);break;case"binning":this._strategy=await g.create(t,e,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await d.create(this._connection,t,e,this._source,this._attributeStore,r)}for(const i of s)this._strategy.onSubscribe(i)}async _updateSortKey(e,s){if(this._sortInfo=t(this._sortInfo?.computed),null!=s){const t=s.byRenderer?null:await e.createComputedField(s);this._sortInfo={...s,computed:t}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if(has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),r(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone)),i=e.tile.tileInfoView.tileInfo.isWrappable,{message:a,transferList:o}=s.serialize(i),n=t.createMessage(a,this._version,this._attributeStore.epoch);if(r(e.signal),this._connection.container.onMessage(n,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,r=t.reader?.getCursor(),i=r?.getSize()??0,a=s.tileInfoView.tileInfo.isWrappable,o=new n(s.key,this._strategy.enablePixelBuffering,a,i);if(!r)return o;const c=s.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;r.next();){const t=this._getSortKeyValue(r,e);o.entityStart(r.getDisplayId(),t),this._factory.write(o,this._proxy,r,c,s.level),o.entityEnd()}return o}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,a=i?this._factory.getSortKey(t,e):s?.read(t,e);return null==a||isNaN(a)?0:a*("asc"===r?-1:1)}}export{l as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../geometry.js";import{getGeohashBounds as e}from"../../../../../geohash/geohashUtils.js";import{unquantizeOptimizedGeometry as t,convertToFeature as s}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as r}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as o}from"../../../../../layers/graphics/data/projectionSupport.js";import{ComputedAggregateField as a}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as i}from"./AAggregateStrategy.js";import{ASendState as n}from"./AProcessorStrategy.js";import{FeatureTileUpdateMessage as l}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as d}from"../support/ComputedAttributeStorage.js";import c from"../support/FeatureFilter.js";import{FeatureMetadata as u}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as p}from"../support/FeatureSetReaderJSON.js";import f from"../../../tiling/TileKey.js";import h from"../../../../../geometry/SpatialReference.js";class m extends n{constructor(e,t){super(e),this.bins=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.bins.clear(),this.done=!1,this.handledChunks.clear()}destroy(){const e=this.subscription.tile.key.level;for(const t of this.bins.values()){const s=t.cachedFeature?.objectId;null!=s&&this._store.releaseDisplayIdForObjectId(`${s}.${e}`)}}*featuresWorldSpace(){for(const e of this.bins.values()){const s=e.cachedFeature;if(s){const e=s.clone();t(e.geometry,e.geometry,!1,!1,this.subscription.tile.transform),yield e}}}getGeohashBounds(t,s){const r=this.subscription.tile;return e(r.extent,r.resolution,s,t)}}class g extends i{static async create(e,t,s,r,i){const n=new d({spatialReference:t}),l=e.fixedBinLevel,u=await Promise.all(e.fields.map((async e=>a.create(n,e)))),p=e.featureFilter?await c.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return await o(t,h.WGS84),new g({fields:u,geohashLevel:l,spatialReference:t,featureFilter:p,timeZone:i},e.fields,s,r)}constructor(e,t,s,r){super(s,r,e.spatialReference,e.fields),this._indexOptions=e,this._metadata=new u({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:t,globalIdField:null,spatialReference:s.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new m(e,this._attributeStore)}async*applyOverride(e){for(const t of this._sendStates.values())t.reset()}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),o=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace()){const{objectId:t,displayId:a}=e,i=r.get(t);if(null!=i){const e=s(a,i,t);o.push(e),r.delete(t)}}return o}getDisplayFeatures(e){const t=new Set(e),r=new Set,o=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace())t.has(e.displayId)&&!r.has(e.objectId)&&(e.geometry&&o.push({...s(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),r.add(e.objectId));return{features:[],aggregates:o}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.objectIds);return[]}async*updateChunks(){if(this._source.chunks().length)for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){for(const t of this._sendStates.values())for(const s of t.featuresWorldSpace())e(s)}async*_update(e,t){const{handledChunks:s,subscription:o,bins:a}=e,{spatialReference:i,geohashLevel:n}=this._indexOptions,d=o.tile;if(e.done)return;for(const r of t.chunks()){if(s.has(r.chunkId))continue;s.add(r.chunkId);const t=r.queryInfo;if("tileId"in t){const e=new f(t.tileId);if(e.level!==d.level||e.world!==d.key.world)continue}const o=r.getGeohashIndex(this._indexOptions),l=e.getGeohashBounds(i,n);null!=l&&o.putBins(a,l)}const c=[],u=o.tile.transform,h=o.tile.key.level;for(const l of a.values()){if(l.cachedFeature)l.cachedFeature.attributes=l.getAttributes();else{const e=l.getGeometry(this.spatialReference,u),t=new r(e,l.getAttributes(),null);e||(t.centroid=l.getGeometryCentroid(this.spatialReference,u)),t.objectId=l.id,t.displayId=this._attributeStore.createDisplayIdForObjectId(`${t.objectId}.${h}`),l.cachedFeature=t}c.push(l.cachedFeature)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const m=p.fromOptimizedFeatures(c,this._metadata,u),g=m.getCursor(),y=e.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;g.next();)this._attributeStore.setAttributeData(g.getDisplayId(),g,y);const b=new l(e.subscription,m,[],e.done,{});yield b}}export{m as BinningState,g as BinningStrategy};
5
+ import"../../../../../geometry.js";import{getGeohashBounds as e}from"../../../../../geohash/geohashUtils.js";import{unquantizeOptimizedGeometry as t,convertToFeature as s}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as r}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as o}from"../../../../../layers/graphics/data/projectionSupport.js";import{ComputedAggregateField as a}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as i}from"./AAggregateStrategy.js";import{ASendState as n}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as l,FeatureTileUpdateMessage as d}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as c}from"../support/ComputedAttributeStorage.js";import u from"../support/FeatureFilter.js";import{FeatureMetadata as p}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as f}from"../support/FeatureSetReaderJSON.js";import h from"../../../tiling/TileKey.js";import m from"../../../../../geometry/SpatialReference.js";class g extends n{constructor(e,t){super(e),this.bins=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.bins.clear(),this.done=!1,this.handledChunks.clear()}destroy(){const e=this.subscription.tile.key.level;for(const t of this.bins.values()){const s=t.cachedFeature?.objectId;null!=s&&this._store.releaseDisplayIdForObjectId(`${s}.${e}`)}}*featuresWorldSpace(){for(const e of this.bins.values()){const s=e.cachedFeature;if(s){const e=s.clone();e.geometry&&t(e.geometry,e.geometry,!1,!1,this.subscription.tile.transform),yield e}}}getGeohashBounds(t,s){const r=this.subscription.tile;return e(r.extent,r.resolution,s,t)}}class y extends i{static async create(e,t,s,r,i){const n=new c({spatialReference:t}),l=e.fixedBinLevel,d=await Promise.all(e.fields.map((async e=>a.create(n,e)))),p=e.featureFilter?await u.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return await o(t,m.WGS84),new y({fields:d,geohashLevel:l,spatialReference:t,featureFilter:p,timeZone:i},e.fields,s,r)}constructor(e,t,s,r){super(s,r,e.spatialReference,e.fields),this._indexOptions=e,this._metadata=new p({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:t,globalIdField:null,spatialReference:s.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new g(e,this._attributeStore)}async*applyOverride(e){for(const t of this._sendStates.values()){t.reset();const e=new l(t.subscription,f.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),o=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace()){const{objectId:t,displayId:a}=e,i=r.get(t);if(null!=i){const e=s(a,i,t);o.push(e),r.delete(t)}}return o}getDisplayFeatures(e){const t=new Set(e),r=new Set,o=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace())t.has(e.displayId)&&!r.has(e.objectId)&&(e.geometry&&o.push({...s(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),r.add(e.objectId));return{features:[],aggregates:o}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.objectIds);return[]}async*updateChunks(){if(this._source.chunks().length)for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){for(const t of this._sendStates.values())for(const s of t.featuresWorldSpace())e(s)}async*_update(e,t){const{handledChunks:s,subscription:o,bins:a}=e,{spatialReference:i,geohashLevel:n}=this._indexOptions,l=o.tile;if(e.done)return;for(const r of t.chunks()){if(s.has(r.chunkId))continue;s.add(r.chunkId);const t=r.queryInfo;if("tileId"in t){const e=new h(t.tileId);if(e.level!==l.level||e.world!==l.key.world)continue}const o=r.getGeohashIndex(this._indexOptions),d=e.getGeohashBounds(i,n);null!=d&&o.putBins(a,d)}const c=[],u=o.tile.transform,p=o.tile.key.level;for(const d of a.values()){if(d.cachedFeature)d.cachedFeature.attributes=d.getAttributes();else{const e=d.getGeometry(this.spatialReference,u),t=new r(e,d.getAttributes(),null);e||(t.centroid=d.getGeometryCentroid(this.spatialReference,u)),t.objectId=d.id,t.displayId=this._attributeStore.createDisplayIdForObjectId(`${t.objectId}.${p}`),d.cachedFeature=t}c.push(d.cachedFeature)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const m=f.fromOptimizedFeatures(c,this._metadata,u),g=m.getCursor(),y=e.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;g.next();)this._attributeStore.setAttributeData(g.getDisplayId(),g,y);const b=new d(e.subscription,m,[],e.done,{});yield b}}export{g as BinningState,y as BinningStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{ASendState as e,AProcessorStrategy as t}from"./AProcessorStrategy.js";import{FeatureTileUpdateMessage as s,FeatureTileAppendMessage as r}from"../sources/FeatureSourceMessage.js";import{OverrideChunk as o}from"../sources/strategies/chunks/OverrideChunk.js";class n extends e{}class a extends t{constructor(e,t,s){super(e,t),this._timeZone=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const e of this._source.chunks())this._cleanupChunkIds(e)}invalidateAttributeData(){this.handledChunksForAttributeData.clear()}onSubscribe(e){super.onSubscribe(e),this._evalOptions=e.tile.createArcadeEvaluationOptions(this._timeZone)}createState(e){return new n(e)}get aggregateQueryEngine(){return null}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),o=[];for(const n of this._source.chunks()){const e=n.reader.getCursor();for(;e.next();){const t=e.getObjectId(),n=e.getDisplayId(),a=r.get(t);if(null!=a){const e=s(n,a,t);o.push(e),r.delete(t)}}}return o}getDisplayFeatures(e){const t=new Set(e),s=new Set,r=[];for(const o of this._source.chunks()){const e=o.reader.getCursor();for(;e.next();){const o=e.getObjectId(),n=e.getDisplayId();t.has(n)&&!s.has(o)&&(r.push({...e.readLegacyFeatureWorldSpace(),displayId:n}),s.add(o))}}return{features:r,aggregates:[]}}async*applyOverride(e){const t=[],r=e.reader.getCursor();for(;r.next();){const e=r.getObjectId();t.push(e);const s=this._attributeStore.createDisplayIdForObjectId(e);r.setDisplayId(s),this._attributeStore.setAttributeData(s,r,this._evalOptions)}const n=this.getDisplayIds(t),a=this.getDisplayIds(e.removed),i=new o;i.applyOverrides(e);for(const o of this._sendStates.values())yield new s(o.subscription,null,n,!1,i.queryInfo);for(const o of this._sendStates.values()){const e=i.getTileReader(o.subscription.tile);yield new s(o.subscription,e,a,!1,i.queryInfo)}for(const s of e.removed)this._attributeStore.releaseDisplayIdForObjectId(s)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const e of this._sendStates.values())yield*this._update(e)}}removeChunks(e){for(const t of e)this.handledChunks.delete(t.chunkId),this.handledChunksForAttributeData.delete(t.chunkId),this._cleanupChunkIds(t)}afterUpdateChunks(){for(const e of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(e);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(e){if(this.handledChunksForIdCreation.has(e.chunkId)){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(e):this._attributeStore.releaseDisplayIdForObjectId(e)}this.handledChunksForIdCreation.delete(e.chunkId)}}async _updateAttributeData(){for(const e of this._source.chunks()){const{chunkId:t,reader:s}=e;if(!this.handledChunksForIdCreation.has(t)){this.handledChunksForIdCreation.add(t);const e=s.getCursor();for(;e.next();){const t=this._attributeStore.createDisplayIdForObjectId(e.getObjectId());e.setDisplayId(t)}}}for(const e of this._source.chunks())if(!this.handledChunksForAttributeData.has(e.chunkId)){this.handledChunksForAttributeData.add(e.chunkId);const t=e.reader.getCursor();for(;t.next();){const e=t.getDisplayId();this._attributeStore.setAttributeData(e,t,this._evalOptions)}}}*_update(e){const{subscription:t,handledChunks:s}=e;for(const o of this._source.chunks()){const{chunkId:n}=o;if(s.has(n))continue;s.add(n);const a=o.getTileReader(t.tile);a&&(yield new r(e.subscription,a,!1,o.end,o.queryInfo))}}}export{n as DefaultSendState,a as FeatureUpdateStrategy};
5
+ import{ASendState as e,AProcessorStrategy as t}from"./AProcessorStrategy.js";import{FeatureTileUpdateMessage as s,FeatureTileAppendMessage as r}from"../sources/FeatureSourceMessage.js";import{OverrideChunk as n}from"../sources/strategies/chunks/OverrideChunk.js";class a extends e{}class o extends t{constructor(e,t,s){super(e,t),this._timeZone=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const e of this._source.chunks())this._cleanupChunkIds(e)}invalidateAttributeData(){this.handledChunksForAttributeData.clear()}onSubscribe(e){super.onSubscribe(e),this._evalOptions=e.tile.createArcadeEvaluationOptions(this._timeZone)}createState(e){return new a(e)}get aggregateQueryEngine(){return null}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),n=[];for(const a of this._source.chunks()){const e=a.reader.getCursor();for(;e.next();){const t=e.getObjectId(),a=e.getDisplayId(),o=r.get(t);if(null!=o){const e=s(a,o,t);n.push(e),r.delete(t)}}}return n}getDisplayFeatures(e){const t=new Set(e),s=new Set,r=[];for(const n of this._source.chunks()){const e=n.reader.getCursor();for(;e.next();){const n=e.getObjectId(),a=e.getDisplayId();t.has(a)&&!s.has(n)&&(r.push({...e.readLegacyFeatureWorldSpace(),displayId:a}),s.add(n))}}return{features:r,aggregates:[]}}async*applyOverride(e){const t=[],r=e.reader.getCursor();for(;r.next();){const e=r.getObjectId();t.push(e);const s=this._attributeStore.createDisplayIdForObjectId(e);r.setDisplayId(s),this._attributeStore.setAttributeData(s,r,this._evalOptions)}const a=this.getDisplayIds(t),o=this.getDisplayIds(e.removed),d=new n(this._source.metadata);d.applyOverrides(e),this.handledChunks.add(d.chunkId),this.handledChunksForAttributeData.add(d.chunkId),this.handledChunksForIdCreation.add(d.chunkId);for(const n of this._sendStates.values())n.handledChunks.add(d.chunkId),yield new s(n.subscription,null,a,!1,d.queryInfo);for(const n of this._sendStates.values()){const e=d.getTileReader(n.subscription.tile);yield new s(n.subscription,e,o,!1,d.queryInfo)}for(const s of e.removed)this._attributeStore.releaseDisplayIdForObjectId(s)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const e of this._sendStates.values())yield*this._update(e)}}removeChunks(e){for(const t of e)this.handledChunks.delete(t.chunkId),this.handledChunksForAttributeData.delete(t.chunkId),this._cleanupChunkIds(t)}afterUpdateChunks(){for(const e of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(e);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(e){if(this.handledChunksForIdCreation.has(e.chunkId)){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(e):this._attributeStore.releaseDisplayIdForObjectId(e)}this.handledChunksForIdCreation.delete(e.chunkId)}}async _updateAttributeData(){for(const e of this._source.chunks()){const{chunkId:t,reader:s}=e;if(!this.handledChunksForIdCreation.has(t)){this.handledChunksForIdCreation.add(t);const e=s.getCursor();for(;e.next();){const t=this._attributeStore.createDisplayIdForObjectId(e.getObjectId());e.setDisplayId(t)}}}for(const e of this._source.chunks())if(!this.handledChunksForAttributeData.has(e.chunkId)){this.handledChunksForAttributeData.add(e.chunkId);const t=e.reader.getCursor();for(;t.next();){const e=t.getDisplayId();this._attributeStore.setAttributeData(e,t,this._evalOptions)}}}*_update(e){const{subscription:t,handledChunks:s}=e;for(const n of this._source.chunks()){const{chunkId:a}=n;if(s.has(a))continue;s.add(a);const o=n.getTileReader(t.tile);o&&(yield new r(e.subscription,o,!1,n.end,n.queryInfo))}}}export{a as DefaultSendState,o as FeatureUpdateStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{QueryEngine as n}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as o}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as u}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as d}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as c}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as g}from"./strategies/PagedTileLoadStrategy.js";import{SnapshotLoadStrategy as m}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as _}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as l}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as p}from"../support/FeatureMetadata.js";import{UpdateTracking2D as y}from"../../support/UpdateTracking2D.js";class f{constructor(e,t,s,r){this._aggregateAdapter=e,this._subscriptions=t,this._onChange=s,this._connection=r,this._updateTracking=new y({debugName:"FeatureSource"}),this._store=new l(this._onChange)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy()}get _eventLog(){return this._connection.eventLog}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get service(){return this._schema.service}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new n({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:e.outSpatialReference,cacheSpatialQueries:!0,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._eventLog.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._eventLog.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}getOverride(e){return this._updateTracking.addPromise(this._doGetOverride(e))}applyOverride(e){this._store.applyOverrides(e)}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._metadata=new p(this._schema.service.metadata),this._queryEngine?.destroy(),this._queryEngine=null,"feature"===this._schema.type&&null!=this._schema.service.queryMetadata.lastEditDate&&(this._lastEditDate=this._schema.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&a(n,"availableFields")){if(await this._queryLastEditDateChanged())await this._updateStrategy(t);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(o){this._eventLog.onEvent({type:"updateFieldsError",error:o})}}return!1}return!(!i(n,"dataFilter")&&!i(n,"sourceRefreshVersion"))&&(await this._updateStrategy(t),!0)}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new d(this._connection))}async _doGetOverride(e){return this._strategy.queryOverride(e)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this._schema.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e=this.service,t="isSourceHosted"in e&&e.isSourceHosted,s=Array.isArray(e.source),r=e.source&&"collection"in e.source,a=t||s||r;if("stream"===this._schema.type){const e=new _(this._schema.service,this._schema.mutable.dataFilter,this._store,{outSR:this._schema.mutable.dataFilter.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}const i=u.fromSchema(this._schema,this._metadata),n=await this._supportSnapshotMode(this._schema,i);return n?new m(this._schema.service,i,this._store,n.featureCount,this.metadata,this._eventLog):a?new g(this._schema.service,i,this._store,this.metadata,this._eventLog):new c(this._schema.service,i,this._store,this.metadata,this._eventLog)}async _updateStrategy(e){const t=await this._createStrategy();this._eventLog.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((e=>this._strategy.load(e).then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(n){s(n)}this._eventLog.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e.service,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=e.service.source,i=t.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const n=(await o(a,i.inner,{query:i.customParameters})).data.count,{min:h,max:u}=r.snapshotCountThresholds;return n<=h||r.supportsSnapshotMaxThreshold&&n<u?{featureCount:n}:null}}export{f as FeatureSource};
5
+ import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{QueryEngine as n}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as o}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as d}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as u}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as c}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as _}from"./strategies/PagedTileLoadStrategy.js";import{SnapshotLoadStrategy as g}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as m}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as l}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as p}from"../support/FeatureMetadata.js";import{UpdateTracking2D as y}from"../../support/UpdateTracking2D.js";class v{constructor(e,t,s,r){this._aggregateAdapter=e,this._subscriptions=t,this._onChange=s,this._connection=r,this._updateTracking=new y({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._store=new l(this._onChange)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy()}get _eventLog(){return this._connection.eventLog}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get service(){return this._schema.service}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new n({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:e.outSpatialReference,cacheSpatialQueries:!0,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._eventLog.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._eventLog.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}getOverride(e){return this._updateTracking.addPromise(this._doGetOverride(e))}applyOverride(e){this._didInvalidateData=!0,this._store.applyOverrides(e,this.metadata)}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._metadata=new p(this._schema.service.metadata),this._queryEngine?.destroy(),this._queryEngine=null,"feature"===this._schema.type&&null!=this._schema.service.queryMetadata.lastEditDate&&(this._lastEditDate=this._schema.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&a(n,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(t);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(o){this._eventLog.onEvent({type:"updateFieldsError",error:o})}}return!1}return!(!i(n,"dataFilter")&&!i(n,"sourceRefreshVersion"))&&(await this._updateStrategy(t),!0)}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new u(this._connection))}async _doGetOverride(e){return this._strategy.queryOverride(e)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this._schema.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e=this.service,t="isSourceHosted"in e&&e.isSourceHosted,s=Array.isArray(e.source),r=e.source&&"collection"in e.source,a=t||s||r;if("stream"===this._schema.type){const e=new m(this._schema.service,this._schema.mutable.dataFilter,this._store,{outSR:this._schema.mutable.dataFilter.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}const i=d.fromSchema(this._schema,this._metadata),n=await this._supportSnapshotMode(this._schema,i);return n?new g(this._schema.service,i,this._store,n.featureCount,this.metadata,this._eventLog):a?new _(this._schema.service,i,this._store,this.metadata,this._eventLog):new c(this._schema.service,i,this._store,this.metadata,this._eventLog)}async _updateStrategy(e){const t=await this._createStrategy();this._eventLog.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((e=>this._strategy.load(e).then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(n){s(n)}this._eventLog.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e.service,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=e.service.source,i=t.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const n=(await o(a,i.inner,{query:i.customParameters})).data.count,{min:h,max:d}=r.snapshotCountThresholds;return n<=h||r.supportsSnapshotMaxThreshold&&n<d?{featureCount:n}:null}}export{v as FeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as r}from"../../../support/FeatureSetReaderJSON.js";class t extends e{constructor(){super(...arguments),this.chunkId="override",this.normalizedChunkId="override",this.removed=new Set,this.overridenIds=new Set,this._features=[]}get reader(){return r.fromOptimizedFeatures(this._features,this._layerSchema??{fields:[]})}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(e){super.invalidate(),this._layerSchema||(this._layerSchema=e.reader.fullSchema());const{reader:r,removed:t}=e,s=[],d=new Set,o=r.getCursor(),i=new Set(t);for(this.overridenIds.clear();o.next();){const e=o.readOptimizedFeatureWorldSpace(),r=e.objectId;s.push(e),d.add(r),this.overridenIds.add(r),this.removed.delete(r)}for(const a of this._features){const e=a.objectId;i.has(e)||d.has(e)||(s.push(a),this.overridenIds.add(e))}this._features=s;for(const a of d.values())this.removed.delete(a);for(const a of t)this.removed.add(a),this.overridenIds.add(a)}getTileReader(e){if(!this._features.length)return null;const r=this.queryFeaturesInBounds(e.bounds);return r.setTransformForDisplay(e.transform),r}}export{t as OverrideChunk};
5
+ import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as r}from"../../../support/FeatureSetReaderJSON.js";class t extends e{constructor(e){super(),this.metadata=e,this.chunkId="override",this.normalizedChunkId="override",this.removed=new Set,this.overridenIds=new Set,this._features=[]}get reader(){return r.fromOptimizedFeatures(this._features,this.metadata)}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(e){super.invalidate();const{reader:r,removed:t}=e,s=[],d=new Set,o=r.getCursor(),i=new Set(t);for(this.overridenIds.clear();o.next();){const e=o.readOptimizedFeatureWorldSpace(),r=e.objectId;s.push(e),d.add(r),this.overridenIds.add(r),this.removed.delete(r)}for(const n of this._features){const e=n.objectId;i.has(e)||d.has(e)||(s.push(n),this.overridenIds.add(e))}this._features=s;for(const n of d.values())this.removed.delete(n);for(const n of t)this.removed.add(n),this.overridenIds.add(n)}getTileReader(e){if(!this._features.length)return null;const r=this.queryFeaturesInBounds(e.bounds);return r.setTransformForDisplay(e.transform),r}}export{t as OverrideChunk};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as o}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as r}from"./OverrideChunk.js";class t{constructor(s){this._onChange=s,this._chunks=new Map,this._overrideChunk=new r,this._chunksToRemove=[],this.events=new e,this.featureAdapter=new o}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),this._overrideChunk&&this._chunksToRemove.push(this._overrideChunk),this._overrideChunk=new r}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrideChunk.overridenIds.size&&e.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}cleanupRemovedChunks(){const e=this._chunksToRemove;return this._chunksToRemove=[],e}applyOverrides(e){this._overrideChunk.applyOverrides(e);for(const s of this._chunks.values())s.reader.removeIds(this._overrideChunk.overridenIds),s.invalidate()}forEach(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r.copy()),s.add(o))}}}forEachUnsafe(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r),s.add(o))}}}forEachInBounds(e,s){const o=new Set;for(const r of this.chunks()){const t=r.queryFeaturesInBounds(e);for(;t.next();){const e=t.getObjectId();o.has(e)||(s(t.copy()),o.add(e))}}}forEachBounds(e,o){const r=s();for(const s of e){s.getBounds(r)&&o(r)}}}export{t as FeatureSourceChunkStore};
5
+ import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as o}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as r}from"./OverrideChunk.js";class n{constructor(s){this._onChange=s,this._chunks=new Map,this._chunksToRemove=[],this.events=new e,this.featureAdapter=new o}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),null!=this._overrideChunk&&this._chunksToRemove.push(this._overrideChunk),this._overrideChunk=null}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrideChunk?.overridenIds.size&&e.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}cleanupRemovedChunks(){const e=this._chunksToRemove;return this._chunksToRemove=[],e}applyOverrides(e,s){null==this._overrideChunk&&(this._overrideChunk=new r(s)),this._overrideChunk.applyOverrides(e);for(const o of this._chunks.values())o.reader.removeIds(this._overrideChunk.overridenIds),o.invalidate()}forEach(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r.copy()),s.add(o))}}}forEachUnsafe(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r),s.add(o))}}}forEachInBounds(e,s){const o=new Set;for(const r of this.chunks()){const n=r.queryFeaturesInBounds(e);for(;n.next();){const e=n.getObjectId();o.has(e)||(s(n.copy()),o.add(e))}}}forEachBounds(e,o){const r=s();for(const s of e){s.getBounds(r)&&o(r)}}}export{n as FeatureSourceChunkStore};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../geometry.js";import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{assertIsSome as t}from"../../../../../core/maybe.js";import{DateOnly as r}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as s}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as i}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as a}from"../../../../../geometry/support/aaBoundingBox.js";import{getLabelPoint as o}from"../../../../../geometry/support/labelPoint.js";import{convertToGeometry as n,unquantizeOptimizedGeometry as d}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as u}from"../../../../../layers/graphics/OptimizedFeature.js";import h from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as c,unknown as l}from"../../../../../time/timeZoneUtils.js";import{FeatureSetCache as m}from"./FeatureSetCache.js";import{StaticBitSet as f}from"./StaticBitSet.js";import{fromJSON as y}from"../../../../../geometry/support/jsonUtils.js";const p=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],g=p[0],_=p[1],b=p[2],x=p[3],T=has("featurelayer-simplify-payload-size-factors")??[1,2,4],I=T[0],A=T[1],D=T[2],F=has("featurelayer-simplify-mobile-factor")??2,S=has("esri-mobile"),j=4294967295;function B(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class C{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(e,t){let r=1;const s=S?F:1;t>4e6?r=D*s:t>1e6?r=A*s:t>5e5?r=I*s:t>1e5&&(r=s);let i=0;return e>4e3?i=x*r:e>2e3?i=b*r:e>100?i=_:e>15&&(i=g),i}parseTimestampOffset(e){return e}getBounds(e){if(B(this._boundsBuffer,4*this.getIndex()+4,0),this.getBoundsXMin()===j)return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(!t)return this.setBoundsXMin(j),!1;let r=1/0,s=1/0,i=-1/0,o=-1/0;return t.forEachVertex(((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),i=Math.max(i,e),o=Math.max(o,t)})),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(i),this.setBoundsYMax(o),a(e,r,s,i,o),!0}const t=this.getBoundsXMin(),r=this.getBoundsYMin(),s=this.getBoundsXMax(),i=this.getBoundsYMax();return a(e,t,r,s,i),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}removeIds(e){if(null==this._objectIdToIndex){const e=new Map,r=this.getCursor();for(;r.next();){const s=r.getObjectId();t(s),e.set(s,r.getIndex())}this._objectIdToIndex=e}const r=this._objectIdToIndex;for(const t of e.values())r.has(t)&&this._removeAtIndex(r.get(t))}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace(),s=new u(e,t,r);return s.objectId=this.getObjectId(),s.displayId=this.getDisplayId(),s}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return n(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryWorldSpace(){let e=this._readGeometry();if(e||(e=this._createGeometryFromServerCentroid()),!e)return null;const t=e.clone(),r=this.getInTransform();return null!=r&&d(t,t,this.hasZ,this.hasM,r),t}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();if(!t)return null;const r=t.clone(),s=this.getInTransform();return null!=s&&d(r,r,this.hasZ,this.hasM,s),r}setCache(e){let t=this._caches.get(e);null==t&&(t=new m(this.getSize()),this._caches.set(e,t)),this._activeCache=t}setCachedValue(e){this._activeCache.set(this.getIndex(),e)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);return"esriGeometryPoint"!==this.geometryType&&t&&this.getInTransform()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some((t=>t.hasField(e)))}geometry(){const e=this.readGeometryWorldSpace(),t=n(e,this.geometryType,this.hasZ,this.hasM),r=y(t);if(r){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.spatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??c):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===l}field(t){let i=this.fields.get(t);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const a of this._joined)if(a.setIndex(this.getIndex()),i=a.fields.get(t),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(a._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(a._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(a._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,a._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((e=>e.name))}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes??{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}_getExists(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(e){const t=i.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=o(t);return r?(r[1]*=-1,new h([],r)):null}copyInto(e){e._joined=this._joined,e._deleted=this._deleted,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer,e._activeCache=this._activeCache,e._caches=this._caches}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return n(e,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createQuantizedExtrudedGeometry(t,r)}_createQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(e,t):this._createQuantizedExtrudedQuad(e,t)}_createQuantizedExtrudedQuad(e,t){return new h([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(e,t){return new h([2],[e-1,t+1,1,-1])}_removeAtIndex(e){null==this._deleted&&(this._deleted=f.create(this.getSize())),this._deleted.set(e)}}export{C as FeatureSetReader};
5
+ import"../../../../../geometry.js";import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{assertIsSome as t}from"../../../../../core/maybe.js";import{DateOnly as r}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as s}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as i}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as o}from"../../../../../geometry/support/aaBoundingBox.js";import{getLabelPoint as a}from"../../../../../geometry/support/labelPoint.js";import{convertToGeometry as n,unquantizeOptimizedGeometry as d}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as u}from"../../../../../layers/graphics/OptimizedFeature.js";import h from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as c,unknown as l}from"../../../../../time/timeZoneUtils.js";import{FeatureSetCache as m}from"./FeatureSetCache.js";import{StaticBitSet as f}from"./StaticBitSet.js";import{fromJSON as y}from"../../../../../geometry/support/jsonUtils.js";const p=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],g=p[0],_=p[1],x=p[2],b=p[3],T=has("featurelayer-simplify-payload-size-factors")??[1,2,4],I=T[0],A=T[1],D=T[2],F=has("featurelayer-simplify-mobile-factor")??2,S=has("esri-mobile"),j=4294967295;function B(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class C{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(e,t){let r=1;const s=S?F:1;t>4e6?r=D*s:t>1e6?r=A*s:t>5e5?r=I*s:t>1e5&&(r=s);let i=0;return e>4e3?i=b*r:e>2e3?i=x*r:e>100?i=_:e>15&&(i=g),i}parseTimestampOffset(e){return e}getBounds(e){if(B(this._boundsBuffer,4*this.getIndex()+4,0),this.getBoundsXMin()===j)return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(!t)return this.setBoundsXMin(j),!1;let r=1/0,s=1/0,i=-1/0,a=-1/0;return t.forEachVertex(((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),i=Math.max(i,e),a=Math.max(a,t)})),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(i),this.setBoundsYMax(a),o(e,r,s,i,a),!0}const t=this.getBoundsXMin(),r=this.getBoundsYMin(),s=this.getBoundsXMax(),i=this.getBoundsYMax();return o(e,t,r,s,i),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}removeIds(e){if(null==this._objectIdToIndex){const e=new Map,r=this.getCursor();for(;r.next();){const s=r.getObjectId();t(s),e.set(s,r.getIndex())}this._objectIdToIndex=e}const r=this._objectIdToIndex;for(const t of e.values())r.has(t)&&this._removeAtIndex(r.get(t))}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace(),s=new u(e,t,r);return s.objectId=this.getObjectId(),s.displayId=this.getDisplayId(),s}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return n(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryWorldSpace(){let e=this._readGeometry();if(e||(e=this._createGeometryFromServerCentroid()),!e)return null;const t=e.clone(),r=this.getInTransform();return null!=r&&d(t,t,this.hasZ,this.hasM,r),t}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();if(!t)return null;const r=t.clone(),s=this.getInTransform();return null!=s&&d(r,r,this.hasZ,this.hasM,s),r}setCache(e){let t=this._caches.get(e);null==t&&(t=new m(this.getSize()),this._caches.set(e,t)),this._activeCache=t}setCachedValue(e){this._activeCache.set(this.getIndex(),e)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);return"esriGeometryPoint"!==this.geometryType&&t&&this.getInTransform()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some((t=>t.hasField(e)))}geometry(){const e=this.readGeometryWorldSpace(),t=n(e,this.geometryType,this.hasZ,this.hasM),r=y(t);if(r){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.spatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??c):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===l}field(t){let i=this.fields.get(t);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const o of this._joined)if(o.setIndex(this.getIndex()),i=o.fields.get(t),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(o._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(o._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(o._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,o._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((e=>e.name))}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes??{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}_getExists(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(e){const t=i.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=a(t);return r?(r[1]*=-1,new h([],r)):null}copyInto(e){e._joined=this._joined,e._deleted=this._deleted,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer,e._activeCache=this._activeCache,e._caches=this._caches,e._contextTimeZone=this._contextTimeZone}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return n(e,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createQuantizedExtrudedGeometry(t,r)}_createQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(e,t):this._createQuantizedExtrudedQuad(e,t)}_createQuantizedExtrudedQuad(e,t){return new h([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(e,t){return new h([2],[e-1,t+1,1,-1])}_removeAtIndex(e){null==this._deleted&&(this._deleted=f.create(this.getSize())),this._deleted.set(e)}}export{C as FeatureSetReader};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{quantizeOptimizedGeometry as e}from"../../../../../layers/graphics/featureConversionUtils.js";import r from"../../../../../layers/graphics/OptimizedGeometry.js";import{FeatureSetReader as t}from"./FeatureSetReader.js";class s extends t{static from(e,r){return new s(e.copy(),r)}constructor(e,r){super(e.metadata),this._currentIndex=-1,this._displayTranslationX=0,this._displayTranslationY=0,this._displayScaleX=1,this._displayScaleY=1,this._reader=e,this._indices=r,this._isPoint="esriGeometryPoint"===e.geometryType}setTransformForDisplay(e){const r=this._reader.getInTransform();if(null==r){const[r,t]=e.scale,[s,a]=e.translate;return this._displayTranslationX=-s/r,this._displayScaleX=1/r,this._displayTranslationY=a/t,this._displayScaleY=1/-t,void(this._displayTransform=e)}const[t,s]=r.scale,[a,i]=r.translate,[d,n]=e.scale,[o,l]=e.translate;if(this._displayScaleX=t/d,this._displayTranslationX=(a-o)/d,this._displayScaleY=s/n,this._displayTranslationY=(-i+l)/n,!this._isPoint&&r)throw new Error("InternalError: Relative transformations not supported for non-point features");this._displayTransform=e}getInTransform(){return this._reader.getInTransform()}get fields(){return this._reader.fields}get hasNext(){return this._currentIndex+1<this._indices.length}getSize(){return this._indices.length}getCursor(){return this.copy()}copy(){const e=new s(this._reader.copy(),this._indices);return e._currentIndex=this._currentIndex,e._displayTransform=this._displayTransform,e._displayTranslationX=this._displayTranslationX,e._displayTranslationY=this._displayTranslationY,e._displayScaleX=this._displayScaleX,e._displayScaleY=this._displayScaleY,e}_nextIndex(){return++this._currentIndex<this._indices.length&&(this._reader.setIndex(this._indices[this._currentIndex]),!0)}next(){for(;this._nextIndex()&&!this._reader._getExists(););return this._currentIndex<this._indices.length}readXForDisplay(){return this._reader.readXForDisplay()*this._displayScaleX+this._displayTranslationX}readYForDisplay(){return this._reader.readYForDisplay()*this._displayScaleY+this._displayTranslationY}readGeometryForDisplay(){const t=this._reader.readGeometryForDisplay();if(!this._displayTransform)return t;const s=new r;return e(s,t,this.hasZ,this.hasM,this.geometryType,this._displayTransform),s.deltaDecode()}readCentroidForDisplay(){const e=this._reader.readCentroidForDisplay()?.clone();if(e){const[r,t]=e.coords;e.coords[0]=r*this._displayScaleX+this._displayTranslationX,e.coords[1]=t*this._displayScaleY+this._displayTranslationY}return e}get geometryType(){return this._reader.geometryType}get hasFeatures(){return this._reader.hasFeatures}get exceededTransferLimit(){return this._reader.exceededTransferLimit}get hasZ(){return this._reader.hasZ}get hasM(){return this._reader.hasM}readAttribute(e,r=!1){return this._reader.readAttribute(e,r)}readAttributes(){return this._reader.readAttributes()}joinAttributes(e){return this._reader.joinAttributes(e)}getBounds(e){return this._reader.getBounds(e)}getAttributeHash(){return this._reader.getAttributeHash()}getObjectId(){return this._reader.getObjectId()}getDisplayId(){return this._reader.getDisplayId()}setDisplayId(e){return this._reader.setDisplayId(e)}setIndex(e){return this._reader.setIndex(e)}getIndex(){return this._reader.getIndex()}readXWorldSpace(){return this._reader.readXWorldSpace()}readYWorldSpace(){return this._reader.readYWorldSpace()}_readX(){return this._reader.readXForDisplay()}_readY(){return this._reader.readYForDisplay()}_readServerCentroid(){return this._reader._readServerCentroid()}readLegacyFeatureForDisplay(){return this._reader.readLegacyFeatureForDisplay()}readLegacyGeometryForDisplay(){return this._reader.readLegacyGeometryForDisplay()}readGeometryArea(){return this._reader.readGeometryArea()}readGeometryWorldSpace(){return this._reader.readGeometryWorldSpace()}_readGeometry(){return this._reader._readGeometry()}_readAttribute(e,r){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}_readAttributes(){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}readArcadeFeature(){return this._reader.readArcadeFeature()}geometry(){return this._reader.geometry()}field(e){return this.readAttribute(e,!0)}hasField(e){return this._reader.hasField(e)}setField(e,r){return this._reader.setField(e,r)}keys(){return this._reader.keys()}castToText(e=!1){return this._reader.castToText(e)}}export{s as FeatureSetReaderIndirect};
5
+ import{quantizeOptimizedGeometry as e,convertToGeometry as r}from"../../../../../layers/graphics/featureConversionUtils.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{FeatureSetReader as s}from"./FeatureSetReader.js";class a extends s{static from(e,r){return new a(e.copy(),r)}constructor(e,r){super(e.metadata),this._currentIndex=-1,this._displayTranslationX=0,this._displayTranslationY=0,this._displayScaleX=1,this._displayScaleY=1,this._reader=e,this._indices=r,this._isPoint="esriGeometryPoint"===e.geometryType}setTransformForDisplay(e){const r=this._reader.getInTransform();if(null==r){const[r,t]=e.scale,[s,a]=e.translate;return this._displayTranslationX=-s/r,this._displayScaleX=1/r,this._displayTranslationY=a/t,this._displayScaleY=1/-t,void(this._displayTransform=e)}const[t,s]=r.scale,[a,i]=r.translate,[d,n]=e.scale,[o,l]=e.translate;if(this._displayScaleX=t/d,this._displayTranslationX=(a-o)/d,this._displayScaleY=s/n,this._displayTranslationY=(-i+l)/n,!this._isPoint&&r)throw new Error("InternalError: Relative transformations not supported for non-point features");this._displayTransform=e}getInTransform(){return this._reader.getInTransform()}get fields(){return this._reader.fields}get hasNext(){return this._currentIndex+1<this._indices.length}getSize(){return this._indices.length}getCursor(){return this.copy()}copy(){const e=new a(this._reader.copy(),this._indices);return e._currentIndex=this._currentIndex,e._displayTransform=this._displayTransform,e._displayTranslationX=this._displayTranslationX,e._displayTranslationY=this._displayTranslationY,e._displayScaleX=this._displayScaleX,e._displayScaleY=this._displayScaleY,e}get contextTimeZone(){return this._reader.contextTimeZone}set contextTimeZone(e){this._reader.contextTimeZone=e}_nextIndex(){return++this._currentIndex<this._indices.length&&(this._reader.setIndex(this._indices[this._currentIndex]),!0)}next(){for(;this._nextIndex()&&!this._reader._getExists(););return this._currentIndex<this._indices.length}readXForDisplay(){return this._reader.readXForDisplay()*this._displayScaleX+this._displayTranslationX}readYForDisplay(){return this._reader.readYForDisplay()*this._displayScaleY+this._displayTranslationY}readGeometryForDisplay(){const r=this._reader.readGeometryForDisplay();if(!this._displayTransform)return r;const s=new t;return e(s,r,this.hasZ,this.hasM,this.geometryType,this._displayTransform),s.deltaDecode()}readCentroidForDisplay(){const e=this._reader.readCentroidForDisplay()?.clone();if(e){const[r,t]=e.coords;e.coords[0]=r*this._displayScaleX+this._displayTranslationX,e.coords[1]=t*this._displayScaleY+this._displayTranslationY}return e}get geometryType(){return this._reader.geometryType}get hasFeatures(){return this._reader.hasFeatures}get exceededTransferLimit(){return this._reader.exceededTransferLimit}get hasZ(){return this._reader.hasZ}get hasM(){return this._reader.hasM}readAttribute(e,r=!1){return this._reader.readAttribute(e,r)}readAttributes(){return this._reader.readAttributes()}joinAttributes(e){return this._reader.joinAttributes(e)}getBounds(e){return this._reader.getBounds(e)}getAttributeHash(){return this._reader.getAttributeHash()}getObjectId(){return this._reader.getObjectId()}getDisplayId(){return this._reader.getDisplayId()}setDisplayId(e){return this._reader.setDisplayId(e)}setIndex(e){return this._reader.setIndex(e)}getIndex(){return this._reader.getIndex()}readXWorldSpace(){return this._reader.readXWorldSpace()}readYWorldSpace(){return this._reader.readYWorldSpace()}_readX(){return this._reader.readXForDisplay()}_readY(){return this._reader.readYForDisplay()}_readServerCentroid(){return this._reader._readServerCentroid()}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return r(e,this.geometryType,!1,!1)}readGeometryArea(){return this._reader.readGeometryArea()}readGeometryWorldSpace(){return this._reader.readGeometryWorldSpace()}_readGeometry(){return this._reader._readGeometry()}_readAttribute(e,r){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}_readAttributes(){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}readArcadeFeature(){return this._reader.readArcadeFeature()}geometry(){return this._reader.geometry()}field(e){return this.readAttribute(e,!0)}hasField(e){return this._reader.hasField(e)}setField(e,r){return this._reader.setField(e,r)}keys(){return this._reader.keys()}castToText(e=!1){return this._reader.castToText(e)}}export{a as FeatureSetReaderIndirect};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{ringsCentroid as t,polygonCentroid as e}from"../../../../../geometry/support/centroid.js";import{getJsonType as r}from"../../../../../geometry/support/jsonUtils.js";import{convertFromGeometry as s,quantizeOptimizedGeometry as i}from"../../../../../layers/graphics/featureConversionUtils.js";import o from"../../../../../layers/graphics/OptimizedGeometry.js";import{tileSize as n}from"../../../engine/webgl/definitions.js";import{FeatureSetReader as h}from"./FeatureSetReader.js";class c extends h{static from(t,e,r){return new c(t,e,r)}constructor(t,e,r){super(r),this._items=t,this._tile=e,this._index=-1,this._cachedGeometry=null;const s=e.lod;s.wrap&&(this._wrappingInfo={worldSizeX:s.worldSize[0]})}get _current(){return this._items[this._index]}getItem(){return this._current}getZOrder(){return this._current.zOrder}getMeshWriters(){return this._current.symbolResource?.symbolInfo.meshWriters??[]}hasField(t){return null!=this._current.attributes[t]}field(t){return this.readAttribute(t)}get geometryType(){const t=r(this._current.geometry);return"esriGeometryPoint"===t?"esriGeometryMultipoint":t}getCursor(){return this.copy()}copy(){const t=new c(this._items,this._tile,this.metadata);return this.copyInto(t),t}copyInto(t){super.copyInto(t),t._cachedGeometry=this._cachedGeometry,t._index=this._index}get fields(){throw new Error("Fields reading not supported to graphics.")}get hasFeatures(){return!!this._items.length}get hasNext(){return this._index+1<this._items.length}get exceededTransferLimit(){throw new Error("InternalError: exceededTransferLimit not implemented for graphics.")}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return this._tile.transform}getSize(){return this._items.length}getAttributeHash(){let t="";for(const e in this._current.attributes)t+=this._current.attributes[e];return t}getObjectId(){return this._items[this._index].objectId}getDisplayId(){return this._current.displayId}setDisplayId(t){throw new Error("InternalError: Setting displayId not supported for graphics.")}setIndex(t){this._index=t}getIndex(){return this._index}next(){for(this._cachedGeometry=null;++this._index<this._items.length&&!this._getExists(););return this._index<this._items.length}readGeometryArea(){throw new Error("InternalError: readGeometryArea not supported for graphics.")}_readGeometry(){if(!this._cachedGeometry){const t=s(this._current.projectedGeometry,this.hasZ,this.hasM);if(this._cachedGeometry=i(new o,t,this.hasZ,this.hasM,this.geometryType,this._tile.transform),!this._cachedGeometry)return null;this._wrapGeometry(this._cachedGeometry)}return this._cachedGeometry}_wrapGeometry(t){if(!this._wrappingInfo)return;const{worldSizeX:e}=this._wrappingInfo;if(t.isPoint)return 1===e?(t.coords.push(n,0),t.coords.push(2*-n,0),void t.lengths.push(3)):2===e?(t.coords.push(2*n,0),t.coords.push(4*-n,0),void t.lengths.push(3)):void this._wrapVertex(t.coords,0,2,e);if("esriGeometryMultipoint"!==this.geometryType);else{if(1===e){const e=t.coords.slice();e[0]-=512;const r=t.coords.slice();r[0]+=512,t.coords.push(...e,...r);const s=t.lengths[0];return void t.lengths.push(s,s)}this._wrapVertex(t.coords,0,2,e)}}_wrapVertex(t,e,r,s){const i=e*r,o=t[i];o<-n*(s-2)?t[i]=o+n*s:o>n*(s-1)&&(t[i]=o-n*s)}_readX(){const t=this._readGeometry();return null!=t?t.coords[0]:0}_readY(){const t=this._readGeometry();return null!=t?t.coords[1]:0}_readServerCentroid(){switch(this.geometryType){case"esriGeometryPolygon":{const t=e(this._current.projectedGeometry),r=new o([],t);return i(new o,r,this.hasZ,this.hasM,this.geometryType,this._tile.transform)}case"esriGeometryPolyline":{const e=this._current.projectedGeometry,r=t(e.paths,this.hasZ),s=new o([],r);return i(new o,s,this.hasZ,this.hasM,this.geometryType,this._tile.transform)}}return null}_readAttribute(t,e){const r=this._current.attributes[t];if(void 0!==r)return r;const s=t.toLowerCase();for(const i in this._current.attributes)if(i.toLowerCase()===s)return this._current.attributes[i]}_readAttributes(){return this._current.attributes}}export{c as GraphicsReader};
5
+ import{ringsCentroid as t,polygonCentroid as e}from"../../../../../geometry/support/centroid.js";import{getJsonType as r}from"../../../../../geometry/support/jsonUtils.js";import{convertFromGeometry as s,generalizeOptimizedGeometry as i,quantizeOptimizedGeometry as o}from"../../../../../layers/graphics/featureConversionUtils.js";import n from"../../../../../layers/graphics/OptimizedGeometry.js";import{tileSize as h}from"../../../engine/webgl/definitions.js";import{FeatureSetReader as a}from"./FeatureSetReader.js";class c extends a{static from(t,e,r){return new c(t,e,r)}constructor(t,e,r){super(r),this._items=t,this._tile=e,this._index=-1,this._cachedGeometry=null;const s=e.lod;s.wrap&&(this._wrappingInfo={worldSizeX:s.worldSize[0]})}get _current(){return this._items[this._index]}getItem(){return this._current}getZOrder(){return this._current.zOrder}getMeshWriters(){return this._current.symbolResource?.symbolInfo.meshWriters??[]}hasField(t){return null!=this._current.attributes[t]}field(t){return this.readAttribute(t)}get geometryType(){const t=r(this._current.geometry);return"esriGeometryPoint"===t?"esriGeometryMultipoint":t}getCursor(){return this.copy()}copy(){const t=new c(this._items,this._tile,this.metadata);return this.copyInto(t),t}copyInto(t){super.copyInto(t),t._cachedGeometry=this._cachedGeometry,t._index=this._index}get fields(){throw new Error("Fields reading not supported to graphics.")}get hasFeatures(){return!!this._items.length}get hasNext(){return this._index+1<this._items.length}get exceededTransferLimit(){throw new Error("InternalError: exceededTransferLimit not implemented for graphics.")}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return this._tile.transform}getSize(){return this._items.length}getAttributeHash(){let t="";for(const e in this._current.attributes)t+=this._current.attributes[e];return t}getObjectId(){return this._items[this._index].objectId}getDisplayId(){return this._current.displayId}setDisplayId(t){throw new Error("InternalError: Setting displayId not supported for graphics.")}setIndex(t){this._index=t}getIndex(){return this._index}next(){for(this._cachedGeometry=null;++this._index<this._items.length&&!this._getExists(););return this._index<this._items.length}readGeometryArea(){throw new Error("InternalError: readGeometryArea not supported for graphics.")}_readGeometry(){if(!this._cachedGeometry){let t=s(this._current.projectedGeometry,this.hasZ,this.hasM);if("esriGeometryPolyline"===this.geometryType&&(t=i(new n,t,this.hasZ,this.hasM,this.geometryType,this._tile.transform.scale[0])),this._cachedGeometry=o(new n,t,this.hasZ,this.hasM,this.geometryType,this._tile.transform),!this._cachedGeometry)return null;this._wrapGeometry(this._cachedGeometry)}return this._cachedGeometry}_wrapGeometry(t){if(!this._wrappingInfo)return;const{worldSizeX:e}=this._wrappingInfo;if(t.isPoint)return 1===e?(t.coords.push(h,0),t.coords.push(2*-h,0),void t.lengths.push(3)):2===e?(t.coords.push(2*h,0),t.coords.push(4*-h,0),void t.lengths.push(3)):void this._wrapVertex(t.coords,0,2,e);if("esriGeometryMultipoint"!==this.geometryType);else{if(1===e){const e=t.coords.slice();e[0]-=512;const r=t.coords.slice();r[0]+=512,t.coords.push(...e,...r);const s=t.lengths[0];return void t.lengths.push(s,s)}this._wrapVertex(t.coords,0,2,e)}}_wrapVertex(t,e,r,s){const i=e*r,o=t[i];o<-h*(s-2)?t[i]=o+h*s:o>h*(s-1)&&(t[i]=o-h*s)}_readX(){const t=this._readGeometry();return null!=t?t.coords[0]:0}_readY(){const t=this._readGeometry();return null!=t?t.coords[1]:0}_readServerCentroid(){switch(this.geometryType){case"esriGeometryPolygon":{const t=e(this._current.projectedGeometry),r=new n([],t);return o(new n,r,this.hasZ,this.hasM,this.geometryType,this._tile.transform)}case"esriGeometryPolyline":{const e=this._current.projectedGeometry,r=t(e.paths,this.hasZ),s=new n([],r);return o(new n,s,this.hasZ,this.hasM,this.geometryType,this._tile.transform)}}return null}_readAttribute(t,e){const r=this._current.attributes[t];if(void 0!==r)return r;const s=t.toLowerCase();for(const i in this._current.attributes)if(i.toLowerCase()===s)return this._current.attributes[i]}_readAttributes(){return this._current.attributes}}export{c as GraphicsReader};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{deg2rad as e}from"../../../../../core/mathUtils.js";import{createLength as t,createArea as s}from"../../../../../core/quantityUtils.js";import{set as i,distance as o}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{q as n,c as h,b as a,F as d,f as l,k as g,h as p,g as c,n as m}from"../../../../../chunks/vec32.js";import{create as u}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as f}from"../../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C,canProjectToWGS84ComparableLonLat as S}from"../../../../../geometry/projection.js";import L from"../../../../../geometry/SpatialReference.js";import{getSphericalPCPF as P}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectDirection as j}from"../../../../../geometry/projection/projectDirection.js";import{projectPointToVector as R}from"../../../../../geometry/projection/projectPointToVector.js";import{projectPointToWGS84ComparableLonLat as M}from"../../../../../geometry/projection/projectPointToWGS84ComparableLonLat.js";import{projectVectorToVector as A}from"../../../../../geometry/projection/projectVectorToVector.js";import{Axis as v}from"../../../../../geometry/support/Axis.js";import{compactIndices as V}from"../../../../../geometry/support/Indices.js";import{segmentIntersects as W}from"../../../../../geometry/support/intersectsBase.js";import{d as I}from"../../../../../chunks/sphere.js";import{areaPoints2d as z}from"../../../../../geometry/support/triangle.js";import{MeasurementMode as w}from"../../interfaces.js";import{segmentLengthGeodesicVector as U,bestFitPlane as G,fitHemisphere as y,triangleAreaGeodesic as T,planePointDistance as x,boundingSphere as b,segmentLengthGeodesic as F,segmentLengthEuclidean as q}from"../../support/measurementUtils.js";import{getElevationAtPoint as E}from"../../../support/ElevationProvider.js";import{midpoint3d as N,makeOrthonormal as D,tangentFrame as k}from"../../../support/mathUtils.js";import{triangulate as B}from"../../../../support/euclideanAreaMeasurementUtils.js";class H{get numVertices(){return this._length}get hasStagedVertex(){return this._hasCursorPoint}constructor(e,t){this.validMeasurement=!1,this.positionsWorldCoords=[],this.positionsRenderCoords=[],this.positionsProjectedWorldCoords=[],this.positionsFittedRenderCoords=[],this.positionsGeographic=[],this.positionsSpherical=[],this.positionsStereographic=[],this.pathSegmentLengths=[],this.geodesicPathSegmentLengths=[],this.perimeterSegmentLengths=[],this.intersectingSegments=new Set,this.geodesicIntersectingSegments=new Set,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.areaCentroidWorldCoords=u(),this.areaCentroidRenderCoords=u(),this.geodesicAreaCentroidRenderCoords=u(),this.area=null,this.geodesicArea=null,this.pathLength=null,this.geodesicPathLength=null,this.perimeterLength=null,this._length=0,this._centroidRenderCoords=u(),this._planeWorldCoords=_(),this._worldUp=u(),this._worldTangent=u(),this._frame=[u(),u(),u()],this._pathVersion=-1,this._hasCursorPoint=!1,this._mode=null,this._tempU=u(),this._tempV=u(),this._tempVec3=u(),this._tempSphere=I(),this._sceneView=e,this.unitNormalizer=t}update(e,t,s,i,o,r){const n=null!=t,h=this._pathVersion===e.version,a=this._hasCursorPoint===n,d=this._mode===o;return!(h&&!r&&a&&d&&e.isValidPolygon)&&(this._pathVersion=e.version,this._hasCursorPoint=n,this._updateCursorSegmentLength(e,t),this._update(e,t,s,i,o),!0)}_update(e,s,i,o,r){const n=this.unitNormalizer,h=this._sceneView.renderSpatialReference,a=this.unitNormalizer.spatialReference;let d=e.numVertices;const l=!(null==s||s.equals(e.lastPoint)||d>2&&s.equals(e.firstPoint));l&&(d+=1);const g=!e.polygonIsClosed&&d>2,p=e.polygonIsClosed||g;this._resize(d);const c=P(i.spatialReference),u=C(i.spatialReference,c)&&S(i.spatialReference),{positionsGeographic:_,positionsWorldCoords:f,positionsRenderCoords:L,positionsSpherical:j}=this,A=(e,t)=>{X(i.elevationProvider,e),R(e,f[t],a),R(e,L[t],h),u&&(M(e,_[t]),R(e,j[t],c),m(j[t],j[t]))};e.forEachVertexPosition(((e,t)=>A(e,t))),l&&A(s,d-1);const v=this._updatePathLengths(p);if(this.pathLength=this._length>1?t(n.normalizeDistance(v),"meters"):null,u){const e=this._updateGeodesicPathLengths(p,a);this.geodesicPathLength=this._length>1?t(e,"meters"):null}else this.geodesicPathLength=null;if(this._updateMode(r),!p)return this.area=null,this.geodesicArea=null,this.perimeterLength=null,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.intersectingSegments.clear(),this.geodesicIntersectingSegments.clear(),void(this.validMeasurement=!1);this._updateAreaAndPerimeterLength(i,n,h,a,o),u&&this._updateGeodesicArea(i),this.validMeasurement=!0}getData(){return{validMeasurement:this.validMeasurement,numVertices:this.numVertices,hasStagedVertex:this.hasStagedVertex,positionsWorldCoords:this.positionsWorldCoords,positionsRenderCoords:this.positionsRenderCoords,positionsProjectedWorldCoords:this.positionsProjectedWorldCoords,positionsFittedRenderCoords:this.positionsFittedRenderCoords,positionsGeographic:this.positionsGeographic,positionsSpherical:this.positionsSpherical,positionsStereographic:this.positionsStereographic,pathSegmentLengths:this.pathSegmentLengths,geodesicPathSegmentLengths:this.geodesicPathSegmentLengths,perimeterSegmentLengths:this.perimeterSegmentLengths,intersectingSegments:this.intersectingSegments,geodesicIntersectingSegments:this.geodesicIntersectingSegments,triangleIndices:this.triangleIndices,geodesicTriangleIndices:this.geodesicTriangleIndices,areaCentroidWorldCoords:this.areaCentroidWorldCoords,areaCentroidRenderCoords:this.areaCentroidRenderCoords,geodesicAreaCentroidRenderCoords:this.geodesicAreaCentroidRenderCoords,fittingMode:this.fittingMode,area:this.area,geodesicArea:this.geodesicArea,pathLength:this.pathLength,geodesicPathLength:this.geodesicPathLength,perimeterLength:this.perimeterLength,unitNormalizer:this.unitNormalizer,actualMeasurementMode:this.actualMeasurementMode}}_resize(e){for(e<this._length&&(this.positionsWorldCoords.length=e,this.positionsRenderCoords.length=e,this.positionsProjectedWorldCoords.length=e,this.positionsFittedRenderCoords.length=e,this.positionsGeographic.length=e,this.positionsSpherical.length=e,this.positionsStereographic.length=e,this.pathSegmentLengths.length=e,this.geodesicPathSegmentLengths.length=e,this.perimeterSegmentLengths.length=e,this._length=e);this._length<e;)this.positionsWorldCoords.push(u()),this.positionsRenderCoords.push(u()),this.positionsProjectedWorldCoords.push(r()),this.positionsFittedRenderCoords.push(u()),this.positionsGeographic.push(u()),this.positionsSpherical.push(u()),this.positionsStereographic.push(r()),this.pathSegmentLengths.push(0),this.geodesicPathSegmentLengths.push(0),this.perimeterSegmentLengths.push(0),++this._length}_updatePathLengths(e){const t=this.positionsWorldCoords,s=this.pathSegmentLengths;let i=0;for(let o=0;o<this._length;++o){const r=s[o]=n(t[o],t[(o+1)%this._length]);(o<this._length-1||e)&&(i+=r)}return i}_updateGeodesicPathLengths(e,t){const s=this.positionsGeographic,i=this.geodesicPathSegmentLengths;let o=0;for(let r=0;r<this._length;++r){const n=i[r]=U(s[r],s[(r+1)%this._length],t??void 0);(r<this._length-1||e)&&(o+=n)}return o}_updateAreaAndPerimeterLength(e,o,r,n,m){const u=e.renderCoordsHelper,_=this.positionsWorldCoords,f=this.positionsRenderCoords,C=this.positionsProjectedWorldCoords,S=this.positionsFittedRenderCoords,L=this._planeWorldCoords,P=this._centroidRenderCoords;N(f,P),u.worldUpAtPosition(P,this._worldUp),u.worldBasisAtPosition(P,v.X,this._worldTangent),j(P,this._worldUp,r,this._worldUp,n),j(P,this._worldTangent,r,this._worldTangent,n),_.length>2&&G(_,L),this.fittingMode=this._selectFittingMode(L,_,this._worldUp,m);let R=0;if("horizontal"===this.fittingMode){let e=-1/0;f.forEach(((t,s)=>{const i=u.getAltitude(f[s]);i>e&&(e=i,R=s)}))}const M=_[R];let V=L,W=this._worldTangent;"horizontal"===this.fittingMode?V=this._worldUp:"vertical"===this.fittingMode&&(V=this._tempVec3,W=this._worldUp,D(L,this._worldUp,V)),h(this._frame[2],V),D(W,V,this._frame[0]),a(this._frame[1],this._frame[0],this._frame[2]),d(this._frame[1],this._frame[1]);const I=this._tempVec3,z=this._tempU,w=this._tempV;for(let t=0;t<this._length;++t){const e=C[t],s=S[t];l(I,_[t],M),i(e,g(this._frame[0],I),g(this._frame[1],I)),p(z,this._frame[0],e[0]),p(w,this._frame[1],e[1]),c(I,z,w),c(I,I,M),A(I,n,s,r)}this.perimeterLength=this._length>0?t(o.normalizeDistance(this._updatePerimeterLengths()),"meters"):null,N(S,this.areaCentroidRenderCoords),A(this.areaCentroidRenderCoords,r,this.areaCentroidWorldCoords,n),this._updateIntersectingSegments(),this.area=0===this.intersectingSegments.size?s(o.normalizeArea(this._computeArea()),"square-meters"):null}_updateGeodesicArea(e){const{renderCoordsHelper:t,spatialReference:o}=e,{positionsSpherical:r,positionsStereographic:n}=this,h=this._tempVec3,a=y(r,h);if(!a)return void(this.geodesicArea=null);const d=this._tempU,l=this._tempV;k(h,d,l);for(let s=0;s<this._length;++s){const e=g(r[s],d),t=g(r[s],l),o=g(r[s],h);i(n[s],e/o,t/o)}p(h,h,f(o).radius),t.toRenderCoords(h,P(o),this.geodesicAreaCentroidRenderCoords),this._updateGeodesicIntersectingSegments(),this.geodesicArea=a&&0===this.geodesicIntersectingSegments.size?s(this._computeGeodesicArea(),"square-meters"):null}_updatePerimeterLengths(){const e=this.positionsProjectedWorldCoords,t=this.perimeterSegmentLengths;let s=0;for(let i=0;i<this._length;++i){s+=t[i]=o(e[i],e[(i+1)%this._length])}return s}_updateIntersectingSegments(){const e=this.positionsProjectedWorldCoords,t=this.intersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeArea(){const e=this.positionsProjectedWorldCoords,t=this.triangleIndices=V(B(e));let s=0;for(let i=0;i<t.length;i+=3)s+=z(e[t[i]],e[t[i+1]],e[t[i+2]]);return s}_updateGeodesicIntersectingSegments(){const e=this.positionsStereographic,t=this.geodesicIntersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeGeodesicArea(){const e=this.positionsGeographic,t=this.positionsStereographic,s=this.geodesicTriangleIndices=V(B(t));let i=0;for(let o=0;o<s.length;o+=3)i+=T(e[s[o]],e[s[o+1]],e[s[o+2]],L.WGS84);return i}_selectFittingMode(t,s,i,o){const r=s.map((e=>Math.abs(x(t,e)))).reduce(((e,t)=>Math.max(e,t)),0);b(s,this._tempSphere);const n=r/(2*this._tempSphere[3]),h=n<o.maxRelativeErrorCoplanar,a=n<o.maxRelativeErrorAlmostCoplanar;let d="horizontal";if(h)d="oblique";else if(a){d=Math.abs(g(i,t))>Math.cos(e(o.verticalAngleThreshold))?"horizontal":"vertical"}return d}_updateCursorSegmentLength(e,s){const i=e.lastPoint;e.isValidPolygon||null==i||null==s?(this.geodesicStagedSegmentLength=null,this.stagedSegmentLength=null):(this.geodesicStagedSegmentLength=t(F(i,s),"meters"),this.stagedSegmentLength=t(this.unitNormalizer.normalizeDistance(q(i,s,this.unitNormalizer.spatialReference)),"meters"))}_updateMode(e){if(e===w.Auto){this.actualMeasurementMode="euclidean";let e=0;null!=this.geodesicPathLength&&(e+=this.geodesicPathLength.value),e>Z&&(this.actualMeasurementMode="geodesic")}else this.actualMeasurementMode=e===w.Euclidean?"euclidean":"geodesic";null==this.geodesicPathLength&&(this.actualMeasurementMode="euclidean"),this._mode=e}}function X(e,t){t.hasZ||(t.z=E(e,t,"ground")??0)}const Z=1e5;export{H as MeasurementDataManager};
5
+ import{deg2rad as e}from"../../../../../core/mathUtils.js";import{createLength as t,createArea as s}from"../../../../../core/quantityUtils.js";import{set as i,distance as o}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{q as n,c as h,b as a,F as d,f as l,k as g,h as p,g as c,n as m}from"../../../../../chunks/vec32.js";import{create as u}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as f}from"../../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C,canProjectToWGS84ComparableLonLat as S}from"../../../../../geometry/projection.js";import L from"../../../../../geometry/SpatialReference.js";import{getSphericalPCPF as P}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectDirection as j}from"../../../../../geometry/projection/projectDirection.js";import{projectPointToVector as R}from"../../../../../geometry/projection/projectPointToVector.js";import{projectPointToWGS84ComparableLonLat as M}from"../../../../../geometry/projection/projectPointToWGS84ComparableLonLat.js";import{projectVectorToVector as A}from"../../../../../geometry/projection/projectVectorToVector.js";import{Axis as v}from"../../../../../geometry/support/Axis.js";import{compactIndices as V}from"../../../../../geometry/support/Indices.js";import{segmentIntersects as W}from"../../../../../geometry/support/intersectsBase.js";import{c as I}from"../../../../../chunks/sphere.js";import{areaPoints2d as z}from"../../../../../geometry/support/triangle.js";import{MeasurementMode as w}from"../../interfaces.js";import{segmentLengthGeodesicVector as U,bestFitPlane as G,fitHemisphere as y,triangleAreaGeodesic as T,planePointDistance as x,boundingSphere as b,segmentLengthGeodesic as F,segmentLengthEuclidean as q}from"../../support/measurementUtils.js";import{getElevationAtPoint as E}from"../../../support/ElevationProvider.js";import{midpoint3d as N,makeOrthonormal as D,tangentFrame as k}from"../../../support/mathUtils.js";import{triangulate as B}from"../../../../support/euclideanAreaMeasurementUtils.js";class H{get numVertices(){return this._length}get hasStagedVertex(){return this._hasCursorPoint}constructor(e,t){this.validMeasurement=!1,this.positionsWorldCoords=[],this.positionsRenderCoords=[],this.positionsProjectedWorldCoords=[],this.positionsFittedRenderCoords=[],this.positionsGeographic=[],this.positionsSpherical=[],this.positionsStereographic=[],this.pathSegmentLengths=[],this.geodesicPathSegmentLengths=[],this.perimeterSegmentLengths=[],this.intersectingSegments=new Set,this.geodesicIntersectingSegments=new Set,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.areaCentroidWorldCoords=u(),this.areaCentroidRenderCoords=u(),this.geodesicAreaCentroidRenderCoords=u(),this.area=null,this.geodesicArea=null,this.pathLength=null,this.geodesicPathLength=null,this.perimeterLength=null,this._length=0,this._centroidRenderCoords=u(),this._planeWorldCoords=_(),this._worldUp=u(),this._worldTangent=u(),this._frame=[u(),u(),u()],this._pathVersion=-1,this._hasCursorPoint=!1,this._mode=null,this._tempU=u(),this._tempV=u(),this._tempVec3=u(),this._tempSphere=I(),this._sceneView=e,this.unitNormalizer=t}update(e,t,s,i,o,r){const n=null!=t,h=this._pathVersion===e.version,a=this._hasCursorPoint===n,d=this._mode===o;return!(h&&!r&&a&&d&&e.isValidPolygon)&&(this._pathVersion=e.version,this._hasCursorPoint=n,this._updateCursorSegmentLength(e,t),this._update(e,t,s,i,o),!0)}_update(e,s,i,o,r){const n=this.unitNormalizer,h=this._sceneView.renderSpatialReference,a=this.unitNormalizer.spatialReference;let d=e.numVertices;const l=!(null==s||s.equals(e.lastPoint)||d>2&&s.equals(e.firstPoint));l&&(d+=1);const g=!e.polygonIsClosed&&d>2,p=e.polygonIsClosed||g;this._resize(d);const c=P(i.spatialReference),u=C(i.spatialReference,c)&&S(i.spatialReference),{positionsGeographic:_,positionsWorldCoords:f,positionsRenderCoords:L,positionsSpherical:j}=this,A=(e,t)=>{X(i.elevationProvider,e),R(e,f[t],a),R(e,L[t],h),u&&(M(e,_[t]),R(e,j[t],c),m(j[t],j[t]))};e.forEachVertexPosition(((e,t)=>A(e,t))),l&&A(s,d-1);const v=this._updatePathLengths(p);if(this.pathLength=this._length>1?t(n.normalizeDistance(v),"meters"):null,u){const e=this._updateGeodesicPathLengths(p,a);this.geodesicPathLength=this._length>1?t(e,"meters"):null}else this.geodesicPathLength=null;if(this._updateMode(r),!p)return this.area=null,this.geodesicArea=null,this.perimeterLength=null,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.intersectingSegments.clear(),this.geodesicIntersectingSegments.clear(),void(this.validMeasurement=!1);this._updateAreaAndPerimeterLength(i,n,h,a,o),u&&this._updateGeodesicArea(i),this.validMeasurement=!0}getData(){return{validMeasurement:this.validMeasurement,numVertices:this.numVertices,hasStagedVertex:this.hasStagedVertex,positionsWorldCoords:this.positionsWorldCoords,positionsRenderCoords:this.positionsRenderCoords,positionsProjectedWorldCoords:this.positionsProjectedWorldCoords,positionsFittedRenderCoords:this.positionsFittedRenderCoords,positionsGeographic:this.positionsGeographic,positionsSpherical:this.positionsSpherical,positionsStereographic:this.positionsStereographic,pathSegmentLengths:this.pathSegmentLengths,geodesicPathSegmentLengths:this.geodesicPathSegmentLengths,perimeterSegmentLengths:this.perimeterSegmentLengths,intersectingSegments:this.intersectingSegments,geodesicIntersectingSegments:this.geodesicIntersectingSegments,triangleIndices:this.triangleIndices,geodesicTriangleIndices:this.geodesicTriangleIndices,areaCentroidWorldCoords:this.areaCentroidWorldCoords,areaCentroidRenderCoords:this.areaCentroidRenderCoords,geodesicAreaCentroidRenderCoords:this.geodesicAreaCentroidRenderCoords,fittingMode:this.fittingMode,area:this.area,geodesicArea:this.geodesicArea,pathLength:this.pathLength,geodesicPathLength:this.geodesicPathLength,perimeterLength:this.perimeterLength,unitNormalizer:this.unitNormalizer,actualMeasurementMode:this.actualMeasurementMode}}_resize(e){for(e<this._length&&(this.positionsWorldCoords.length=e,this.positionsRenderCoords.length=e,this.positionsProjectedWorldCoords.length=e,this.positionsFittedRenderCoords.length=e,this.positionsGeographic.length=e,this.positionsSpherical.length=e,this.positionsStereographic.length=e,this.pathSegmentLengths.length=e,this.geodesicPathSegmentLengths.length=e,this.perimeterSegmentLengths.length=e,this._length=e);this._length<e;)this.positionsWorldCoords.push(u()),this.positionsRenderCoords.push(u()),this.positionsProjectedWorldCoords.push(r()),this.positionsFittedRenderCoords.push(u()),this.positionsGeographic.push(u()),this.positionsSpherical.push(u()),this.positionsStereographic.push(r()),this.pathSegmentLengths.push(0),this.geodesicPathSegmentLengths.push(0),this.perimeterSegmentLengths.push(0),++this._length}_updatePathLengths(e){const t=this.positionsWorldCoords,s=this.pathSegmentLengths;let i=0;for(let o=0;o<this._length;++o){const r=s[o]=n(t[o],t[(o+1)%this._length]);(o<this._length-1||e)&&(i+=r)}return i}_updateGeodesicPathLengths(e,t){const s=this.positionsGeographic,i=this.geodesicPathSegmentLengths;let o=0;for(let r=0;r<this._length;++r){const n=i[r]=U(s[r],s[(r+1)%this._length],t??void 0);(r<this._length-1||e)&&(o+=n)}return o}_updateAreaAndPerimeterLength(e,o,r,n,m){const u=e.renderCoordsHelper,_=this.positionsWorldCoords,f=this.positionsRenderCoords,C=this.positionsProjectedWorldCoords,S=this.positionsFittedRenderCoords,L=this._planeWorldCoords,P=this._centroidRenderCoords;N(f,P),u.worldUpAtPosition(P,this._worldUp),u.worldBasisAtPosition(P,v.X,this._worldTangent),j(P,this._worldUp,r,this._worldUp,n),j(P,this._worldTangent,r,this._worldTangent,n),_.length>2&&G(_,L),this.fittingMode=this._selectFittingMode(L,_,this._worldUp,m);let R=0;if("horizontal"===this.fittingMode){let e=-1/0;f.forEach(((t,s)=>{const i=u.getAltitude(f[s]);i>e&&(e=i,R=s)}))}const M=_[R];let V=L,W=this._worldTangent;"horizontal"===this.fittingMode?V=this._worldUp:"vertical"===this.fittingMode&&(V=this._tempVec3,W=this._worldUp,D(L,this._worldUp,V)),h(this._frame[2],V),D(W,V,this._frame[0]),a(this._frame[1],this._frame[0],this._frame[2]),d(this._frame[1],this._frame[1]);const I=this._tempVec3,z=this._tempU,w=this._tempV;for(let t=0;t<this._length;++t){const e=C[t],s=S[t];l(I,_[t],M),i(e,g(this._frame[0],I),g(this._frame[1],I)),p(z,this._frame[0],e[0]),p(w,this._frame[1],e[1]),c(I,z,w),c(I,I,M),A(I,n,s,r)}this.perimeterLength=this._length>0?t(o.normalizeDistance(this._updatePerimeterLengths()),"meters"):null,N(S,this.areaCentroidRenderCoords),A(this.areaCentroidRenderCoords,r,this.areaCentroidWorldCoords,n),this._updateIntersectingSegments(),this.area=0===this.intersectingSegments.size?s(o.normalizeArea(this._computeArea()),"square-meters"):null}_updateGeodesicArea(e){const{renderCoordsHelper:t,spatialReference:o}=e,{positionsSpherical:r,positionsStereographic:n}=this,h=this._tempVec3,a=y(r,h);if(!a)return void(this.geodesicArea=null);const d=this._tempU,l=this._tempV;k(h,d,l);for(let s=0;s<this._length;++s){const e=g(r[s],d),t=g(r[s],l),o=g(r[s],h);i(n[s],e/o,t/o)}p(h,h,f(o).radius),t.toRenderCoords(h,P(o),this.geodesicAreaCentroidRenderCoords),this._updateGeodesicIntersectingSegments(),this.geodesicArea=a&&0===this.geodesicIntersectingSegments.size?s(this._computeGeodesicArea(),"square-meters"):null}_updatePerimeterLengths(){const e=this.positionsProjectedWorldCoords,t=this.perimeterSegmentLengths;let s=0;for(let i=0;i<this._length;++i){s+=t[i]=o(e[i],e[(i+1)%this._length])}return s}_updateIntersectingSegments(){const e=this.positionsProjectedWorldCoords,t=this.intersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeArea(){const e=this.positionsProjectedWorldCoords,t=this.triangleIndices=V(B(e));let s=0;for(let i=0;i<t.length;i+=3)s+=z(e[t[i]],e[t[i+1]],e[t[i+2]]);return s}_updateGeodesicIntersectingSegments(){const e=this.positionsStereographic,t=this.geodesicIntersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeGeodesicArea(){const e=this.positionsGeographic,t=this.positionsStereographic,s=this.geodesicTriangleIndices=V(B(t));let i=0;for(let o=0;o<s.length;o+=3)i+=T(e[s[o]],e[s[o+1]],e[s[o+2]],L.WGS84);return i}_selectFittingMode(t,s,i,o){const r=s.map((e=>Math.abs(x(t,e)))).reduce(((e,t)=>Math.max(e,t)),0);b(s,this._tempSphere);const n=r/(2*this._tempSphere[3]),h=n<o.maxRelativeErrorCoplanar,a=n<o.maxRelativeErrorAlmostCoplanar;let d="horizontal";if(h)d="oblique";else if(a){d=Math.abs(g(i,t))>Math.cos(e(o.verticalAngleThreshold))?"horizontal":"vertical"}return d}_updateCursorSegmentLength(e,s){const i=e.lastPoint;e.isValidPolygon||null==i||null==s?(this.geodesicStagedSegmentLength=null,this.stagedSegmentLength=null):(this.geodesicStagedSegmentLength=t(F(i,s),"meters"),this.stagedSegmentLength=t(this.unitNormalizer.normalizeDistance(q(i,s,this.unitNormalizer.spatialReference)),"meters"))}_updateMode(e){if(e===w.Auto){this.actualMeasurementMode="euclidean";let e=0;null!=this.geodesicPathLength&&(e+=this.geodesicPathLength.value),e>Z&&(this.actualMeasurementMode="geodesic")}else this.actualMeasurementMode=e===w.Euclidean?"euclidean":"geodesic";null==this.geodesicPathLength&&(this.actualMeasurementMode="euclidean"),this._mode=e}}function X(e,t){t.hasZ||(t.z=E(e,t,"ground")??0)}const Z=1e5;export{H as MeasurementDataManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{c as e,f as r,g as n,q as t,E as o}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrap as c}from"../../../../geometry/support/ray.js";import{h as s,b as a}from"../../../../chunks/sphere.js";import{defaultConstraintOptions as f,interactionDirectionTowardsConstraintMinimization as m,adjustRangeForInteraction as u}from"./common.js";import{InteractionType as p}from"./InteractionType.js";function d(e,r,n=f){if(!e.state.isLocal)return 0;const t=e.state.constraints.distance;if(!e.pointsOfInterest.surfaceOrigin.renderLocation||t===1/0)return 0;x.min=0,x.max=t,l(e,n,x);const o=O(e,r),i=x.max-o;return i>=-1e-6?0:i}function y(t,o,i=f){const u=d(t,o,i);if(0===u)return!1;const p=t.pointsOfInterest.surfaceOrigin;if(!p.renderLocation)return!1;const y=O(t,o)+u,l=e(L,o.eye),x=m(o,i.interactionDirection,g(o,p.renderLocation,h),I);if(!s(a(p.renderLocation,y),c(o.eye,x),C))return!1;o.eye=C;const N=r(j,o.eye,l);o.center=n(C,o.center,N);const b=t.renderCoordsHelper.getAltitude(o.center),k=t.renderCoordsHelper.intersectInfiniteManifold(o.ray,b,C);return null!=k&&(o.center=k),!0}function l(e,r,n){const t=r.interactionType;if(t===p.NONE)return;const{min:o,max:i}=n,{interactionStartCamera:c,interactionFactor:s}=r;if(!c)return;const a=t===p.ZOOM||t===p.PAN,f=d(e,c),m=0===f?0:O(e,c);n.min=o,n.max=i;u(f,m,a,s,.05*m,n)}function O(e,r){const n=e.pointsOfInterest.surfaceOrigin;return n.renderLocation?t(r.eye,n.renderLocation):0}function g(e,r,n){return o(n,e.eye,r)}const x={min:0,max:0},L=i(),j=i(),I=i(),h=i(),C=i();export{y as applyDistanceConstraint,d as getDistanceConstraintError};
5
+ import{c as e,f as r,g as n,q as t,E as o}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrap as c}from"../../../../geometry/support/ray.js";import{i as s,k as a}from"../../../../chunks/sphere.js";import{defaultConstraintOptions as f,interactionDirectionTowardsConstraintMinimization as m,adjustRangeForInteraction as u}from"./common.js";import{InteractionType as p}from"./InteractionType.js";function d(e,r,n=f){if(!e.state.isLocal)return 0;const t=e.state.constraints.distance;if(!e.pointsOfInterest.surfaceOrigin.renderLocation||t===1/0)return 0;x.min=0,x.max=t,l(e,n,x);const o=O(e,r),i=x.max-o;return i>=-1e-6?0:i}function y(t,o,i=f){const u=d(t,o,i);if(0===u)return!1;const p=t.pointsOfInterest.surfaceOrigin;if(!p.renderLocation)return!1;const y=O(t,o)+u,l=e(L,o.eye),x=m(o,i.interactionDirection,g(o,p.renderLocation,h),I);if(!s(a(p.renderLocation,y),c(o.eye,x),k))return!1;o.eye=k;const C=r(j,o.eye,l);o.center=n(k,o.center,C);const N=t.renderCoordsHelper.getAltitude(o.center),v=t.renderCoordsHelper.intersectInfiniteManifold(o.ray,N,k);return null!=v&&(o.center=v),!0}function l(e,r,n){const t=r.interactionType;if(t===p.NONE)return;const{min:o,max:i}=n,{interactionStartCamera:c,interactionFactor:s}=r;if(!c)return;const a=t===p.ZOOM||t===p.PAN,f=d(e,c),m=0===f?0:O(e,c);n.min=o,n.max=i;u(f,m,a,s,.05*m,n)}function O(e,r){const n=e.pointsOfInterest.surfaceOrigin;return n.renderLocation?t(r.eye,n.renderLocation):0}function g(e,r,n){return o(n,e.eye,r)}const x={min:0,max:0},L=i(),j=i(),I=i(),h=i(),k=i();export{y as applyDistanceConstraint,d as getDistanceConstraintError};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as e}from"../../../../core/compilerUtils.js";import{clamp as t,acosClamped as r,asinClamped as n,deg2rad as i}from"../../../../core/mathUtils.js";import{fromRotation as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as o,e as c,h as u,g as l,q as m,k as f,n as d,l as p,p as y}from"../../../../chunks/vec32.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../../geometry/ellipsoidUtils.js";import{j as C,k as T,t as I}from"../../../../chunks/sphere.js";import{hasConstraintType as O,defaultConstraintOptions as A,adjustRangeForInteraction as D}from"./common.js";import{ConstraintTypes as S}from"./ConstraintTypes.js";import{InteractionType as x}from"./InteractionType.js";import{TiltMode as R}from"./TiltMode.js";import{viewAngle as j}from"../../state/utils/viewUtils.js";function w(t,r,n,i=!0){V.eyeCenterDistance=0,V.requiresTwoSteps=!1;const a=U(t,r,n,A,V);if(0===a)return!1;switch(s(_,-a,r.viewRight),n.tiltMode){case R.LOOK_AROUND:c(K,r.viewForward,_),u(K,K,V.eyeCenterDistance),r.center=l(z,r.eye,K);break;case R.TUMBLE:o(K,r.center,r.eye),c(K,K,_),r.eye=o(z,r.center,K);break;default:e(n.tiltMode)}return r.up=c(z,r.up,_),!V.requiresTwoSteps||!i||w(t,r,n,!1)}function U(e,t,r,n=A,i){if(!e.state.constraints.tilt)return 0;const s=t.distance,a=e.state.constraints.tilt(s,J);return N(e,r,a),n.interactionType===x.TUMBLE&&O(n.selection,S.ALTITUDE)&&B(e,n.interactionStartCamera,a),r.tiltMode===R.LOOK_AROUND||n.tiltMode===R.LOOK_AROUND?L(e,t,a,i):P(e,t,a)}function P(e,r,n){const i=j(e.renderCoordsHelper,r.center,r.eye),s=i-t(i,n.min,n.max);return v(s)?s:0}function L(e,t,r,n){switch(n&&(n.requiresTwoSteps=!1),e.viewingMode){case"global":return q(e,t,r,n);case"local":return g(e,t,r,n)}}function g(e,r,n,i){const s=j(e.renderCoordsHelper,r.center,r.eye),a=t(s,n.min,n.max),o=s-a;if(!v(o))return 0;if(i){const t=e.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,n=e.renderCoordsHelper.getAltitude(r.eye)-t,s=Math.cos(a);Math.abs(s)>1e-4?i.eyeCenterDistance=n/s:i.eyeCenterDistance=r.distance}return o}function q(e,r,n,i){const s=b(e,r,Q),a=t(s.tiltAtCenter,n.min,n.max);if(!v(s.tiltAtCenter-a))return 0;let o,c;return s.centerIsOnSurface?(o=H(s),c=E(s,o)):(o=s.constraints.clampTilt(s.eyeCenterDistance,s.tiltAtCenter),i&&o<Math.PI/2&&(i.requiresTwoSteps=!0,o=Math.PI/2-1e-5),c=F(s,o)),i&&(i.eyeCenterDistance=k(s,o)),c}function b(e,t,n){const i=e.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,s=i+h(e.spatialReference).radius,a=e.renderCoordsHelper.intersectManifold(t.ray,i,z);return n.eyeCenterDistance=t.distance,n.centerIsOnSurface=!1,null!=a?(n.eyeCenterDistance=m(t.eye,a),n.tiltAtCenter=j(e.renderCoordsHelper,a,t.eye),n.centerIsOnSurface=!0):e.state.isLocal?n.tiltAtCenter=j(e.renderCoordsHelper,t.center,t.eye):(C(T(I,s),t.ray,z),n.eyeCenterDistance=m(t.eye,z),n.tiltAtCenter=r(-f(t.viewForward,d(z,z)))),n.radius=s,n.eyeRadius=p(t.eye),n.constraints=e.state.constraints,n}function v(e){return Math.abs(e)>1e-9}function H(e){const{constraints:t,eyeCenterDistance:r,tiltAtCenter:n}=e;let i=n,s=t.clampTilt(r,n);const a=k(e,s);if(t.clampTilt(a,n)===s)return s;let o=0;for(;o<10&&v(s-i);){const r=(i+s)/2,n=k(e,r);v(t.clampTilt(n,r)-r)?i=r:s=r,o++}return s}function k(e,r){if(!e.centerIsOnSurface)return e.eyeCenterDistance;const i=Math.PI-t(r,0,Math.PI),s=n(e.radius/e.eyeRadius*Math.sin(i)),a=Math.PI-i-s,o=Math.sin(a)/Math.sin(i);if(e.eyeRadius<e.radius&&o>1){const t=Math.PI-s,r=Math.PI-i-t;return Math.sin(r)/Math.sin(i)*e.eyeRadius}return o*e.eyeRadius}function E(e,t){const r=n(e.radius/e.eyeRadius*Math.sin(e.tiltAtCenter)),i=n(e.radius/e.eyeRadius*Math.sin(t));return e.eyeRadius>e.radius?r-i:i-r}function F(e,t){return e.tiltAtCenter-Math.PI/2-(t-Math.PI/2)}function N(e,t,r){if(t.interactionType===x.NONE)return;const{interactionStartCamera:n,interactionFactor:i}=t;if(!n)return;const{min:s,max:a}=r,o=U(e,n,A,t),c=0===o?0:j(e.renderCoordsHelper,n.center,n.eye);r.min=s,r.max=a,t.interactionType===x.TUMBLE?(O(t.selection,S.ALTITUDE)&&B(e,n,r),D(o,c,!0,i,G,r)):D(o,c,!1,i,G,r)}function B(e,t,n){const i=e.state.constraints;if(e.state.isLocal||!i.altitude||!t)return;const s=y(t.center),a=Math.sqrt(s),o=t.distance,c=h(e.spatialReference).radius,u=i.altitude.min+c,l=i.altitude.max+c,m=(u*u-o*o-s)/(-2*a*o),f=(l*l-o*o-s)/(-2*a*o);n.min=Math.max(n.min,Math.min(Math.PI-r(f),n.max)),n.max=Math.min(n.max,Math.PI-r(m))}const K=M(),_=a(),z=M(),G=i(5),J={min:0,max:0},Q={constraints:null,radius:0,eyeRadius:0,centerIsOnSurface:!0,eyeCenterDistance:0,tiltAtCenter:0},V={eyeCenterDistance:0,requiresTwoSteps:!1};export{w as applyTiltConstraint,U as getTiltConstraintError};
5
+ import{neverReached as e}from"../../../../core/compilerUtils.js";import{clamp as t,acosClamped as r,asinClamped as n,deg2rad as i}from"../../../../core/mathUtils.js";import{fromRotation as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as o,e as c,h as u,g as l,q as m,k as f,n as d,l as p,p as y}from"../../../../chunks/vec32.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as M}from"../../../../geometry/ellipsoidUtils.js";import{e as C,h as T,t as I}from"../../../../chunks/sphere.js";import{hasConstraintType as O,defaultConstraintOptions as A,adjustRangeForInteraction as D}from"./common.js";import{ConstraintTypes as S}from"./ConstraintTypes.js";import{InteractionType as x}from"./InteractionType.js";import{TiltMode as R}from"./TiltMode.js";import{viewAngle as w}from"../../state/utils/viewUtils.js";function j(t,r,n,i=!0){V.eyeCenterDistance=0,V.requiresTwoSteps=!1;const a=U(t,r,n,A,V);if(0===a)return!1;switch(s(_,-a,r.viewRight),n.tiltMode){case R.LOOK_AROUND:c(K,r.viewForward,_),u(K,K,V.eyeCenterDistance),r.center=l(z,r.eye,K);break;case R.TUMBLE:o(K,r.center,r.eye),c(K,K,_),r.eye=o(z,r.center,K);break;default:e(n.tiltMode)}return r.up=c(z,r.up,_),!V.requiresTwoSteps||!i||j(t,r,n,!1)}function U(e,t,r,n=A,i){if(!e.state.constraints.tilt)return 0;const s=t.distance,a=e.state.constraints.tilt(s,J);return N(e,r,a),n.interactionType===x.TUMBLE&&O(n.selection,S.ALTITUDE)&&B(e,n.interactionStartCamera,a),r.tiltMode===R.LOOK_AROUND||n.tiltMode===R.LOOK_AROUND?L(e,t,a,i):P(e,t,a)}function P(e,r,n){const i=w(e.renderCoordsHelper,r.center,r.eye),s=i-t(i,n.min,n.max);return v(s)?s:0}function L(e,t,r,n){switch(n&&(n.requiresTwoSteps=!1),e.viewingMode){case"global":return q(e,t,r,n);case"local":return g(e,t,r,n)}}function g(e,r,n,i){const s=w(e.renderCoordsHelper,r.center,r.eye),a=t(s,n.min,n.max),o=s-a;if(!v(o))return 0;if(i){const t=e.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,n=e.renderCoordsHelper.getAltitude(r.eye)-t,s=Math.cos(a);Math.abs(s)>1e-4?i.eyeCenterDistance=n/s:i.eyeCenterDistance=r.distance}return o}function q(e,r,n,i){const s=b(e,r,Q),a=t(s.tiltAtCenter,n.min,n.max);if(!v(s.tiltAtCenter-a))return 0;let o,c;return s.centerIsOnSurface?(o=H(s),c=k(s,o)):(o=s.constraints.clampTilt(s.eyeCenterDistance,s.tiltAtCenter),i&&o<Math.PI/2&&(i.requiresTwoSteps=!0,o=Math.PI/2-1e-5),c=F(s,o)),i&&(i.eyeCenterDistance=E(s,o)),c}function b(e,t,n){const i=e.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,s=i+M(e.spatialReference).radius,a=e.renderCoordsHelper.intersectManifold(t.ray,i,z);return n.eyeCenterDistance=t.distance,n.centerIsOnSurface=!1,null!=a?(n.eyeCenterDistance=m(t.eye,a),n.tiltAtCenter=w(e.renderCoordsHelper,a,t.eye),n.centerIsOnSurface=!0):e.state.isLocal?n.tiltAtCenter=w(e.renderCoordsHelper,t.center,t.eye):(C(T(I,s),t.ray,z),n.eyeCenterDistance=m(t.eye,z),n.tiltAtCenter=r(-f(t.viewForward,d(z,z)))),n.radius=s,n.eyeRadius=p(t.eye),n.constraints=e.state.constraints,n}function v(e){return Math.abs(e)>1e-9}function H(e){const{constraints:t,eyeCenterDistance:r,tiltAtCenter:n}=e;let i=n,s=t.clampTilt(r,n);const a=E(e,s);if(t.clampTilt(a,n)===s)return s;let o=0;for(;o<10&&v(s-i);){const r=(i+s)/2,n=E(e,r);v(t.clampTilt(n,r)-r)?i=r:s=r,o++}return s}function E(e,r){if(!e.centerIsOnSurface)return e.eyeCenterDistance;const i=Math.PI-t(r,0,Math.PI),s=n(e.radius/e.eyeRadius*Math.sin(i)),a=Math.PI-i-s,o=Math.sin(a)/Math.sin(i);if(e.eyeRadius<e.radius&&o>1){const t=Math.PI-s,r=Math.PI-i-t;return Math.sin(r)/Math.sin(i)*e.eyeRadius}return o*e.eyeRadius}function k(e,t){const r=n(e.radius/e.eyeRadius*Math.sin(e.tiltAtCenter)),i=n(e.radius/e.eyeRadius*Math.sin(t));return e.eyeRadius>e.radius?r-i:i-r}function F(e,t){return e.tiltAtCenter-Math.PI/2-(t-Math.PI/2)}function N(e,t,r){if(t.interactionType===x.NONE)return;const{interactionStartCamera:n,interactionFactor:i}=t;if(!n)return;const{min:s,max:a}=r,o=U(e,n,A,t),c=0===o?0:w(e.renderCoordsHelper,n.center,n.eye);r.min=s,r.max=a,t.interactionType===x.TUMBLE?(O(t.selection,S.ALTITUDE)&&B(e,n,r),D(o,c,!0,i,G,r)):D(o,c,!1,i,G,r)}function B(e,t,n){const i=e.state.constraints;if(e.state.isLocal||!i.altitude||!t)return;const s=y(t.center),a=Math.sqrt(s),o=t.distance,c=M(e.spatialReference).radius,u=i.altitude.min+c,l=i.altitude.max+c,m=(u*u-o*o-s)/(-2*a*o),f=(l*l-o*o-s)/(-2*a*o);n.min=Math.max(n.min,Math.min(Math.PI-r(f),n.max)),n.max=Math.min(n.max,Math.PI-r(m))}const K=h(),_=a(),z=h(),G=i(5),J={min:0,max:0},Q={constraints:null,radius:0,eyeRadius:0,centerIsOnSurface:!0,eyeCenterDistance:0,tiltAtCenter:0},V={eyeCenterDistance:0,requiresTwoSteps:!1};export{j as applyTiltConstraint,U as getTiltConstraintError};