@arcgis/core 4.33.0-next.20250325 → 4.33.0-next.20250326

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 (170) hide show
  1. package/arcade/arcadeAsyncRuntime.js +1 -1
  2. package/arcade/arcadeCompiler.js +1 -1
  3. package/arcade/arcadeRuntime.js +1 -1
  4. package/arcade/containerUtils.js +1 -1
  5. package/arcade/functions/date.js +1 -1
  6. package/arcade/functions/feature.js +1 -1
  7. package/arcade/functions/featuresetbase.js +1 -1
  8. package/arcade/functions/featuresetgeom.js +1 -1
  9. package/arcade/functions/featuresetstats.js +1 -1
  10. package/arcade/functions/featuresetstring.js +1 -1
  11. package/arcade/functions/fieldStats.js +1 -1
  12. package/arcade/functions/geomasync.js +1 -1
  13. package/arcade/functions/geometry.js +1 -1
  14. package/arcade/functions/geomsync.js +1 -1
  15. package/arcade/functions/knowledgegraph.js +1 -1
  16. package/arcade/functions/maths.js +1 -1
  17. package/arcade/functions/stats.js +1 -1
  18. package/arcade/functions/string.js +1 -1
  19. package/arcade/geometry/functions.js +1 -1
  20. package/arcade/languageUtils.js +1 -1
  21. package/assets/esri/core/workers/RemoteClient.js +1 -1
  22. package/assets/esri/core/workers/chunks/0059295780fa4a090f30.js +319 -0
  23. package/assets/esri/core/workers/chunks/{8f4bcca8b0525e19374f.js → 042771b4e56355924140.js} +1 -1
  24. package/assets/esri/core/workers/chunks/1dd6d68d23ba07587ae4.js +1 -0
  25. package/assets/esri/core/workers/chunks/{fef46b841e8369b30227.js → 2873cb727c59328074db.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{bea2f317b73a86e2a997.js → 4dc1e7d7ac2a4b0144c4.js} +96 -96
  27. package/assets/esri/core/workers/chunks/705c1ebb327f680f8519.js +1 -0
  28. package/assets/esri/core/workers/chunks/{bd2dcc55ac3418421ee5.js → 726e3f413824f02fe689.js} +1 -1
  29. package/assets/esri/core/workers/chunks/afe94e351b4a50d7bc53.js +1 -0
  30. package/assets/esri/core/workers/chunks/{cbbbaccc0d3683e1c0fe.js → b8a4352f83502449ff95.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{605eddec7aac891ed141.js → ba47e43ef039fe4b8c5c.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{a2377969f76640f1d6fe.js → d5d2a4e8e19898d86c6d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{5f8028928ae8e5d27dda.js → e088edb9ffbaa1ed12eb.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ed831e51c2a03ee95879.js +1 -0
  35. package/assets/esri/core/workers/chunks/{3e9cd82325c473ddbf1f.js → edcc0fefd57323d2cb67.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{065ae931b5891847a06f.js → f28eaf1d3a7f12788bcf.js} +1 -1
  37. package/assets/esri/core/workers/chunks/f9396af9cbfd165e72e2.js +1 -0
  38. package/assets/esri/core/workers/chunks/{f86736a60856ef7fdacb.js → fa3eeb40e2d732c184d8.js} +1 -1
  39. package/chunks/BloomBlur.glsl.js +1 -1
  40. package/chunks/BloomComposition.glsl.js +2 -2
  41. package/chunks/ComponentShader.glsl.js +24 -25
  42. package/chunks/HighlightApply.glsl.js +1 -1
  43. package/chunks/HighlightDownsample.glsl.js +1 -1
  44. package/chunks/HighlightToSingle.glsl.js +1 -1
  45. package/chunks/ShadowHighlight.glsl.js +1 -1
  46. package/chunks/WaterSurface.glsl.js +1 -1
  47. package/chunks/aiServices.js +1 -1
  48. package/chunks/array.js +1 -1
  49. package/chunks/languageUtils.js +1 -1
  50. package/geometry/operators/projectOperator.js +1 -1
  51. package/geometry/operators/shapePreservingProjectOperator.js +1 -1
  52. package/interfaces.d.ts +17 -17
  53. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  54. package/package.json +1 -1
  55. package/rest/support/RasterData.js +1 -1
  56. package/support/revision.js +1 -1
  57. package/views/2d/LabelManager.js +1 -1
  58. package/views/2d/engine/vectorTiles/Placement.js +1 -1
  59. package/views/2d/engine/vectorTiles/SourceLayerData.js +1 -1
  60. package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
  61. package/views/2d/engine/vectorTiles/TileManager.js +1 -1
  62. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  63. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  64. package/views/2d/engine/vectorTiles/VectorTileFeatureIndex.js +1 -1
  65. package/views/2d/engine/vectorTiles/VectorTileRendererHelper3D.js +1 -1
  66. package/views/2d/engine/vectorTiles/buckets/BaseBucket.js +1 -1
  67. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  68. package/views/2d/engine/vectorTiles/constants.js +5 -0
  69. package/views/2d/engine/vectorTiles/decluttering/CollisionJob.js +5 -0
  70. package/views/2d/engine/vectorTiles/decluttering/SymbolDeclutterer.js +1 -1
  71. package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
  72. package/views/2d/engine/vectorTiles/decluttering/SymbolRepository.js +1 -1
  73. package/views/2d/engine/vectorTiles/decluttering/core.js +1 -1
  74. package/views/2d/engine/vectorTiles/decluttering/jobsUtil.js +1 -1
  75. package/views/2d/engine/vectorTiles/decluttering/util.js +1 -1
  76. package/views/2d/engine/vectorTiles/style/StyleLayer.js +1 -1
  77. package/views/2d/engine/vectorTiles/style/StyleRepository.js +1 -1
  78. package/views/2d/engine/webgl/AFeatureTile.js +1 -1
  79. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  80. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  81. package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
  82. package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
  83. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  84. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  85. package/views/2d/engine/webgl/mesh/MultiTileMeshData.js +1 -1
  86. package/views/2d/engine/webgl/mesh/meshDebugUtils.js +1 -1
  87. package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
  88. package/views/2d/engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/techniques/GraphicInstanceStore.js +1 -1
  90. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  91. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  92. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/AlignedVertexSpec.js +1 -1
  93. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  94. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  95. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  96. package/views/2d/layers/MediaLayerView2D.js +1 -1
  97. package/views/2d/layers/TileLayerView2D.js +1 -1
  98. package/views/2d/layers/features/FeatureContainer.js +1 -1
  99. package/views/2d/layers/features/RenderState.js +1 -1
  100. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  101. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  102. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  103. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  104. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  105. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  106. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  107. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  108. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  109. package/views/2d/layers/features/schema/processor/LabelMatcherSchema.js +1 -1
  110. package/views/2d/layers/features/schema/processor/SimpleProcessorSchema.js +1 -1
  111. package/views/2d/layers/features/schema/processor/SubtypeProcessorSchema.js +1 -1
  112. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  113. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  114. package/views/2d/layers/support/vectorTileDebugUtils.js +1 -1
  115. package/views/2d/tiling/FeatureTileSubscriptionManager.js +1 -1
  116. package/views/3d/layers/graphics/Labeler.js +1 -1
  117. package/views/3d/support/QualitySettings.js +1 -1
  118. package/views/3d/terrain/OverlayRenderer.js +1 -1
  119. package/views/3d/terrain/TerrainRenderer.js +1 -1
  120. package/views/3d/terrain/TileCompositor.js +1 -1
  121. package/views/3d/webgl-engine/core/shaderLibrary/HighlightCellGridScreenSpacePass.glsl.js +1 -1
  122. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoubleConfiguration.js +1 -1
  123. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +4 -4
  124. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +9 -9
  125. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +2 -2
  126. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +2 -2
  127. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +3 -3
  128. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js +6 -6
  129. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +1 -1
  130. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +1 -1
  131. package/views/3d/webgl-engine/core/shaderModules/{UintTexture2DBindUniform.js → Texture2DUintBindUniform.js} +1 -1
  132. package/views/3d/webgl-engine/core/shaderModules/{UintTexture2DPassUniform.js → Texture2DUintPassUniform.js} +1 -1
  133. package/views/3d/webgl-engine/effects/bloom/BloomBlur.glsl.js +1 -1
  134. package/views/3d/webgl-engine/effects/bloom/BloomBlurTechnique.js +1 -1
  135. package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +1 -1
  136. package/views/3d/webgl-engine/effects/bloom/BloomCompositionTechnique.js +1 -1
  137. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  138. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  139. package/views/3d/webgl-engine/lib/Program.js +1 -1
  140. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  141. package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
  142. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  143. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  144. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  145. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  146. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  147. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  148. package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
  149. package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +1 -1
  150. package/views/3d/webgl-engine/shaders/HighlightToSingle.glsl.js +1 -1
  151. package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
  152. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  153. package/views/VideoView.js +1 -1
  154. package/views/webgl/ShaderBuilder.js +1 -1
  155. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  156. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  157. package/assets/esri/core/workers/chunks/0e164b19e4ea3aa73843.js +0 -1
  158. package/assets/esri/core/workers/chunks/ac6b582ca180210e596c.js +0 -1
  159. package/assets/esri/core/workers/chunks/accd0661a6dd297fab6b.js +0 -1
  160. package/assets/esri/core/workers/chunks/b5f44cf03c4e5cc07bc4.js +0 -1
  161. package/assets/esri/core/workers/chunks/bfbb118ae3b4a4ce1c74.js +0 -319
  162. package/assets/esri/core/workers/chunks/fa7ddf3c89cdb8052b26.js +0 -1
  163. package/chunks/BloomDepthAdjust.glsl.js +0 -14
  164. package/views/2d/engine/vectorTiles/decluttering/jobs.js +0 -5
  165. package/views/2d/engine/webgl/collisions/CollisionEngine.js +0 -5
  166. package/views/2d/engine/webgl/collisions/CollisionGrid.js +0 -5
  167. package/views/3d/webgl-engine/core/shaderModules/TextureCubeBindUniform.js +0 -5
  168. package/views/3d/webgl-engine/core/shaderModules/UintTexture2DDrawUniform.js +0 -5
  169. package/views/3d/webgl-engine/effects/bloom/BloomDepthAdjust.glsl.js +0 -5
  170. package/views/3d/webgl-engine/effects/bloom/BloomDepthAdjustTechnique.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{create as e}from"../../../../geometry/support/aaBoundingRect.js";import t from"../../../../layers/support/TileInfo.js";import{SymbolFader as s}from"./decluttering/SymbolFader.js";import{Visibility as r,StyleLayerType as i}from"./style/StyleDefinition.js";import{WGLDrawPhase as l}from"../webgl/enums.js";import{RenderableTile as o}from"../webgl/RenderableTile.js";import n from"../webgl/TileContainer.js";import a from"../../tiling/TileCoverage.js";import d from"../../tiling/TileKey.js";import{StencilOperation as h,CompareFunction as c,FramebufferBit as u,BlendFactor as y}from"../../../webgl/enums.js";const p=1e-6;function m(e,t){if(e){const s=e.getLayoutProperty("visibility");if(!s||s.getValue()!==r.NONE&&(void 0===e.minzoom||e.minzoom<t+p)&&(void 0===e.maxzoom||e.maxzoom>=t-p))return!0}return!1}class f extends n{constructor(e){super(e),this._backgroundTiles=[],this._computeDisplayInfoView(e)}destroy(){this.removeAllChildren(),this._spriteMosaic?.dispose(),this._spriteMosaic=null,this._glyphMosaic?.dispose(),this._glyphMosaic=null,null!=this._symbolFader&&(this._symbolFader.clear(),this._symbolFader=null),this._styleRepository=null,this._backgroundTiles=[]}get fading(){return this._symbolFader?.fading??!1}get symbolFader(){return this._symbolFader}get symbolRepository(){return this._symbolFader?.symbolRepository}setStyleResources(e,t,r,i){this._spriteMosaic=e,this._glyphMosaic=t,this._styleRepository=r,this.tileInfoView=i,this._computeDisplayInfoView(i),null==this._symbolFader&&(this._symbolFader=new s(this._styleRepository,this.children)),this._symbolFader.styleRepository=r}setSpriteMosaic(e){this._spriteMosaic?.dispose(),this._spriteMosaic=e}deleteStyleLayers(e){null!=this._symbolFader&&this._symbolFader.deleteStyleLayers(e)}createRenderParams(e){return{...super.createRenderParams(e),renderPass:null,styleLayer:null,styleLayerUID:-1,glyphMosaic:this._glyphMosaic,spriteMosaic:this._spriteMosaic,hasClipping:!!this._clippingInfos}}doRender(e){!this.visible||e.drawPhase!==l.MAP&&e.drawPhase!==l.DEBUG||void 0===this._spriteMosaic||super.doRender(e)}addChild(e){return super.addChild(e),null!=this._symbolFader?this._symbolFader.addTile(e):e.decluttered=!0,this.requestRender(),e}removeChild(e){return null!=this._symbolFader&&this._symbolFader.removeTile(e),this.requestRender(),super.removeChild(e)}renderChildren(e){const{drawPhase:t}=e;t!==l.DEBUG?this._doRender(e):super.renderChildren(e)}removeAllChildren(){for(let e=0;e<this.children.length;e++){const t=this.children[e];null!=this._symbolFader&&this._symbolFader.removeTile(t),t.dispose()}super.removeAllChildren()}getStencilTarget(){return this.children.filter((e=>e.neededForCoverage&&e.hasData()))}restartDeclutter(){null!=this._symbolFader&&this._symbolFader.restartDeclutter()}_doRender(e){const{context:t,state:s}=e,r=this._styleRepository;if(!r)return;const i=r.layers,o=this._displayInfo.scaleToZoom(s.scale);r.backgroundBucketIds.length>0&&(e.renderPass="background",this._renderBackgroundLayers(e,r.backgroundBucketIds,o)),super.renderChildren(e),e.drawPhase===l.MAP&&this._fade(o,s);const n=this.children.filter((e=>e.visible&&e.hasData()));if(!n||0===n.length)return t.bindVAO(),t.setStencilTestEnabled(!0),void t.setBlendingEnabled(!0);for(const l of n)l.triangleCount=0;t.setStencilWriteMask(0),t.setColorMask(!0,!0,!0,!0),t.setStencilOp(h.KEEP,h.KEEP,h.REPLACE),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!1),t.setDepthTestEnabled(!0),t.setDepthWriteEnabled(!0),t.setDepthFunction(c.LEQUAL),t.setClearDepth(1),t.clear(u.DEPTH),e.renderPass="opaque";for(let l=i.length-1;l>=0;l--)this._renderStyleLayer(i[l],e,n);t.setDepthWriteEnabled(!1),t.setBlendingEnabled(!0),t.setBlendFunctionSeparate(y.ONE,y.ONE_MINUS_SRC_ALPHA,y.ONE,y.ONE_MINUS_SRC_ALPHA),e.renderPass="translucent";for(let l=0;l<i.length;l++)this._renderStyleLayer(i[l],e,n);t.bindVAO(),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!0);for(const l of n)l.debugInfo.display.triangleCount=l.triangleCount}_fade(e,t){null!=this._symbolFader&&(this._symbolFader.update(e,t)||this.requestRender())}_renderStyleLayer(e,t,s){const{displayLevel:l,painter:o,renderPass:n}=t;if(void 0===e)return;const a=e.getLayoutProperty("visibility");if(a&&a.getValue()===r.NONE)return;let d;switch(e.type){case i.BACKGROUND:return;case i.FILL:if("opaque"!==n&&"translucent"!==t.renderPass)return;d="vtlFill";break;case i.LINE:if("translucent"!==n)return;d="vtlLine";break;case i.CIRCLE:if("translucent"!==n)return;d="vtlCircle";break;case i.SYMBOL:if("translucent"!==n)return;d="vtlSymbol"}if(s=e.type===i.SYMBOL?s.filter((e=>e.decluttered)):s.filter((e=>e.neededForCoverage)),"vtlSymbol"!==d&&(0===s.length||void 0!==e.minzoom&&e.minzoom>=l+p||void 0!==e.maxzoom&&e.maxzoom<l-p))return;const h=e.uid;t.styleLayerUID=h,t.styleLayer=e;for(const r of s)if(r.layerData.has(h)){o.renderObjects(t,s,d);break}}_renderBackgroundLayers(t,s,r){const{context:l,painter:n,state:u}=t,y=this._styleRepository;let p=!1;for(const e of s){if(y.getLayerById(e).type===i.BACKGROUND&&m(y.getLayerById(e),r)){p=!0;break}}if(!p)return;const f=this.tileInfoView,g=f.getTileCoverage(t.state,0,!0,"smallest"),{spans:b,lodInfo:_}=g,{level:C}=_,E=e(),L=[];if(this._renderPasses){const e=this._renderPasses[0];null!=this._clippingInfos&&(e.brushes[0].prepareState(t),e.brushes[0].drawMany(t,this._clippingInfos))}const F=this._backgroundTiles;let R,v=0;for(const{row:i,colFrom:a,colTo:h}of b)for(let t=a;t<=h;t++){if(v<F.length)R=F[v],R.key.set(C,i,_.normalizeCol(t),_.getWorldForColumn(t)),f.getTileBounds(E,R.key,!1),R.x=E[0],R.y=E[3],R.resolution=f.getTileResolution(C);else{const s=new d(C,i,_.normalizeCol(t),_.getWorldForColumn(t)),r=f.getTileBounds(e(),s),l=f.getTileResolution(C);R=new o(s,l,r[0],r[3],512,512,4096,4096),F.push(R)}R.setTransform(u),L.push(R),v++}l.setStencilWriteMask(0),l.setColorMask(!0,!0,!0,!0),l.setStencilOp(h.KEEP,h.KEEP,h.REPLACE),l.setStencilFunction(c.EQUAL,0,255),l.setStencilTestEnabled(!0);for(const e of s){const s=y.getLayerById(e);s.type===i.BACKGROUND&&m(s,r)&&(t.styleLayerUID=s.uid,t.styleLayer=s,n.renderObjects(t,L,"vtlBackground"))}a.pool.release(g)}_computeDisplayInfoView(e){let s=e.tileInfo.lods[0].scale;const r=Math.max(25,e.tileInfo.lods.length),i=[];for(let t=0;t<=r;t++)i.push(s),s/=2;this._displayInfo=t.create({scales:i,size:512,spatialReference:e.spatialReference,numLODs:r})}}export{f as VectorTileContainer};
5
+ import{create as e}from"../../../../geometry/support/aaBoundingRect.js";import t from"../../../../layers/support/TileInfo.js";import{tileCoordSize as s,tilePixelSize as r}from"./constants.js";import{SymbolFader as i}from"./decluttering/SymbolFader.js";import{writeOpacityToBuffers as l}from"./decluttering/util.js";import{Visibility as o,StyleLayerType as n}from"./style/StyleDefinition.js";import{WGLDrawPhase as a}from"../webgl/enums.js";import{RenderableTile as d}from"../webgl/RenderableTile.js";import c from"../webgl/TileContainer.js";import h from"../../tiling/TileCoverage.js";import u from"../../tiling/TileKey.js";import{StencilOperation as y,CompareFunction as p,FramebufferBit as m,BlendFactor as f}from"../../../webgl/enums.js";const g=1e-6;function b(e,t){if(e){const s=e.getLayoutProperty("visibility");if(!s||s.getValue()!==o.NONE&&(void 0===e.minzoom||e.minzoom<t+g)&&(void 0===e.maxzoom||e.maxzoom>=t-g))return!0}return!1}class _ extends c{constructor(e){super(e),this._backgroundTiles=[],this._computeDisplayInfoView(e)}destroy(){this.removeAllChildren(),this._spriteMosaic?.dispose(),this._spriteMosaic=null,this._glyphMosaic?.dispose(),this._glyphMosaic=null,null!=this._symbolFader&&(this._symbolFader.clear(),this._symbolFader=null),this._styleRepository=null,this._backgroundTiles=[]}get fading(){return this._symbolFader?.fading??!1}get symbolFader(){return this._symbolFader}get symbolRepository(){return this._symbolFader?.symbolRepository}setStyleResources(e,t,r,o){if(this._spriteMosaic=e,this._glyphMosaic=t,this._styleRepository=r,this.tileInfoView=o,this._computeDisplayInfoView(o),null==this._symbolFader){const e=(e,t)=>{e.allSymbolsFadingOut=!0,e.lastOpacityUpdate=t,l(e,t,!0),e.decluttered=!0,e.requestRender()};this._symbolFader=new i("vector-tile",this._styleRepository,e,this.children,s)}this._symbolFader.styleRepository=r}setSpriteMosaic(e){this._spriteMosaic?.dispose(),this._spriteMosaic=e}deleteStyleLayers(e){null!=this._symbolFader&&this._symbolFader.deleteStyleLayers(e)}createRenderParams(e){return{...super.createRenderParams(e),renderPass:null,styleLayer:null,styleLayerUID:-1,glyphMosaic:this._glyphMosaic,spriteMosaic:this._spriteMosaic,hasClipping:!!this._clippingInfos}}doRender(e){!this.visible||e.drawPhase!==a.MAP&&e.drawPhase!==a.DEBUG||void 0===this._spriteMosaic||super.doRender(e)}addChild(e){return super.addChild(e),null!=this._symbolFader?this._symbolFader.addTile(e):e.decluttered=!0,this.requestRender(),e}removeChild(e){return null!=this._symbolFader&&this._symbolFader.removeTile(e),this.requestRender(),super.removeChild(e)}renderChildren(e){const{drawPhase:t}=e;t!==a.DEBUG?this._doRender(e):super.renderChildren(e)}removeAllChildren(){for(let e=0;e<this.children.length;e++){const t=this.children[e];null!=this._symbolFader&&this._symbolFader.removeTile(t),t.dispose()}super.removeAllChildren()}getStencilTarget(){return this.children.filter((e=>e.neededForCoverage&&e.hasData()))}restartDeclutter(){null!=this._symbolFader&&this._symbolFader.restartDeclutter()}_doRender(e){const{context:t,state:s}=e,r=this._styleRepository;if(!r)return;const i=r.layers,l=this._displayInfo.scaleToZoom(s.scale);r.backgroundBucketIds.length>0&&(e.renderPass="background",this._renderBackgroundLayers(e,r.backgroundBucketIds,l)),super.renderChildren(e),e.drawPhase===a.MAP&&this._fade(l,s);const o=this.children.filter((e=>e.visible&&e.hasData()));if(!o||0===o.length)return t.bindVAO(),t.setStencilTestEnabled(!0),void t.setBlendingEnabled(!0);for(const n of o)n.triangleCount=0;t.setStencilWriteMask(0),t.setColorMask(!0,!0,!0,!0),t.setStencilOp(y.KEEP,y.KEEP,y.REPLACE),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!1),t.setDepthTestEnabled(!0),t.setDepthWriteEnabled(!0),t.setDepthFunction(p.LEQUAL),t.setClearDepth(1),t.clear(m.DEPTH),e.renderPass="opaque";for(let n=i.length-1;n>=0;n--)this._renderStyleLayer(i[n],e,o);t.setDepthWriteEnabled(!1),t.setBlendingEnabled(!0),t.setBlendFunctionSeparate(f.ONE,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA),e.renderPass="translucent";for(let n=0;n<i.length;n++)this._renderStyleLayer(i[n],e,o);t.bindVAO(),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!0);for(const n of o)n.debugInfo.display.triangleCount=n.triangleCount}_fade(e,t){null!=this._symbolFader&&(this._symbolFader.update(e,t)||this.requestRender())}_renderStyleLayer(e,t,s){const{displayLevel:r,painter:i,renderPass:l}=t;if(void 0===e)return;const a=e.getLayoutProperty("visibility");if(a&&a.getValue()===o.NONE)return;let d;switch(e.type){case n.BACKGROUND:return;case n.FILL:if("opaque"!==l&&"translucent"!==t.renderPass)return;d="vtlFill";break;case n.LINE:if("translucent"!==l)return;d="vtlLine";break;case n.CIRCLE:if("translucent"!==l)return;d="vtlCircle";break;case n.SYMBOL:if("translucent"!==l)return;d="vtlSymbol"}if(s=e.type===n.SYMBOL?s.filter((e=>e.decluttered)):s.filter((e=>e.neededForCoverage)),"vtlSymbol"!==d&&(0===s.length||void 0!==e.minzoom&&e.minzoom>=r+g||void 0!==e.maxzoom&&e.maxzoom<r-g))return;const c=e.uid;t.styleLayerUID=c,t.styleLayer=e;for(const o of s)if(o.layerData.has(c)){i.renderObjects(t,s,d);break}}_renderBackgroundLayers(t,i,l){const{context:o,painter:a,state:c}=t,m=this._styleRepository;let f=!1;for(const e of i){if(m.getLayerById(e).type===n.BACKGROUND&&b(m.getLayerById(e),l)){f=!0;break}}if(!f)return;const g=this.tileInfoView,_=g.getTileCoverage(t.state,0,!0,"smallest"),{spans:C,lodInfo:E}=_,{level:F}=E,L=e(),R=[];if(this._renderPasses){const e=this._renderPasses[0];null!=this._clippingInfos&&(e.brushes[0].prepareState(t),e.brushes[0].drawMany(t,this._clippingInfos))}const v=this._backgroundTiles;let S,I=0;for(const{row:n,colFrom:h,colTo:y}of C)for(let t=h;t<=y;t++){if(I<v.length)S=v[I],S.key.set(F,n,E.normalizeCol(t),E.getWorldForColumn(t)),g.getTileBounds(L,S.key,!1),S.x=L[0],S.y=L[3],S.resolution=g.getTileResolution(F);else{const i=new u(F,n,E.normalizeCol(t),E.getWorldForColumn(t)),l=g.getTileBounds(e(),i),o=g.getTileResolution(F);S=new d(i,o,l[0],l[3],r,r,s,s),v.push(S)}S.setTransform(c),R.push(S),I++}o.setStencilWriteMask(0),o.setColorMask(!0,!0,!0,!0),o.setStencilOp(y.KEEP,y.KEEP,y.REPLACE),o.setStencilFunction(p.EQUAL,0,255),o.setStencilTestEnabled(!0);for(const e of i){const s=m.getLayerById(e);s.type===n.BACKGROUND&&b(s,l)&&(t.styleLayerUID=s.uid,t.styleLayer=s,a.renderObjects(t,R,"vtlBackground"))}h.pool.release(_)}_computeDisplayInfoView(e){let s=e.tileInfo.lods[0].scale;const i=Math.max(25,e.tileInfo.lods.length),l=[];for(let t=0;t<=i;t++)l.push(s),s/=2;this._displayInfo=t.create({scales:l,size:r,spatialReference:e.spatialReference,numLODs:i})}}export{_ as VectorTileContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Graphic.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import s from"../../../../core/pbf.js";import{PooledRBush as r}from"../../../../core/libs/rbush/PooledRBush.js";import{BucketType as i}from"./enums.js";import o from"./Feature.js";import{getTileMargins as l}from"./GeometryUtils.js";import a from"./SourceLayerData.js";import{IndexItem as n}from"./style/StyleLayer.js";const y=8,c=512,u=4096,h=(e,t)=>{const s=e.vtlSymbol.sourceTile,r=t.vtlSymbol.sourceTile;return s.level!==r.level?s.level-r.level:s.row!==r.row?s.row-r.row:s.col!==r.col?s.col-r.col:e.styleLayerUID-t.styleLayerUID};class d{constructor(e,t,s,r,i){this.tileKey=e,this._tileLayerData=t,this._styleRepository=s,this._tileHandler=r,this._parentLayer=i,this._index=null,this._tileKeyToPBF=new Map}static create(e,t,s,r,i){return new d(e,t,s,r,i)}clear(){this._index?.clear(),this._tileKeyToPBF.clear()}async queryAttributes(e,t,s,i,o){if(0===this._tileLayerData.size||!this._styleRepository||!this._tileHandler)return[];null===this._index&&(this._index=new r(100,m),await this._indexLayers());const l=[];return this._queryIndex(l,e,t,s,this.tileKey.level,i),o&&o?.length>0&&await this._getSymbolsAttributes(l,o),l}async _indexLayers(){const e=this.tileKey,t=this._styleRepository.layers,s=await this._getTilePayload(e);for(const[r,o]of this._tileLayerData){const l=t[r],a=s.find((e=>e.sourceName===l.source));if(!a)continue;const{protobuff:n,key:y}=a;if(o.type!==i.SYMBOL){const t=1<<e.level-y.level,s=e.row-y.row*t,r=e.col-y.col*t;this._indexLayer(l,n,e.level,t,s,r)}}}_indexLayer(e,t,r,i,y,h){const d=e.sourceLayer,m=e.getFeatureFilter(),f=r,_=r+1,p=l(f),g=new s(new Uint8Array(t),new DataView(t));for(;g.next();)switch(g.tag()){case 3:{const t=g.getMessage(),s=new a(t);if(t.release(),s.name!==d)continue;const l=s.getData(),w=s.extent/i,x=w*h-p,b=w*y-p,I=x+w+2*p,L=b+w+2*p,v=w/c,D=u/w,T=w*h,S=w*y;for(;l.nextTag(2);){const t=l.getMessage(),i=new o(t,s);if(t.release(),m&&!m.filter(i,r))continue;const a=i.values||{},y=a._minzoom,c=a._maxzoom;if(y&&y>=10*_||c&&c<=10*f)continue;const u=e.getFeatureInflatedBounds(i,f,s.extent,v);null==u||u[0]>I||u[1]>L||u[2]<x||u[3]<b||(u[0]=(u[0]-T)*D,u[1]=(u[1]-S)*D,u[2]=(u[2]-T)*D,u[3]=(u[3]-S)*D,this._index.insert(new n(e,i,u,D,T,S)))}break}default:g.skip()}}async _getSymbolsAttributes(e,t){if(!t||0===t.length)return e;const s=[];t.sort(h);let r=t[0].styleLayerUID,i=0;for(let l=0;l<t.length;l++)r!==t[l].styleLayerUID&&(s.push({from:i,to:l,styleLayerUID:r,sourceTileKey:t[l].vtlSymbol.sourceTile}),i=l,r=t[l].styleLayerUID);s.push({from:i,to:t.length,styleLayerUID:r,sourceTileKey:t[t.length-1].vtlSymbol.sourceTile});const o=this._styleRepository.layers;for(const l of s){const s=await this._getTilePayload(l.sourceTileKey),i=o[l.styleLayerUID],a=!!i&&s.find((e=>e.sourceName===i.source));a&&this._addSymbolsAttributes(e,t.slice(l.from,l.to).map((e=>e.vtlSymbol)),r,a)}return e}_addSymbolsAttributes(t,s,r,i){const o=this._styleRepository.layers,l=i.key,a=this.tileKey,n=1<<a.level-l.level,y=a.row-l.row*n,c=a.col-l.col*n;this._getSymbolAttributes(i.protobuff,s,r,n,y,c).forEach((s=>{const{attributes:i,tilePoint:l}=s;t.push({layerId:o[r].id,layerIndex:r,graphic:new e({attributes:i,origin:{type:"vector-tile",layerId:o[r].id,layerIndex:r,layer:this._parentLayer}}),tilePoint:l})}))}_getSymbolAttributes(e,t,r,i,l,n){const y=[],c=this._styleRepository.layers;let h=0;t.sort(((e,t)=>e.featureIndex-t.featureIndex));const d=new s(new Uint8Array(e),new DataView(e));for(;d.next();)switch(d.tag()){case 3:{const e=d.getMessage(),s=new a(e);if(e.release(),s.name!==c[r].sourceLayer)continue;const m=s.getData(),f=s.extent/i,_=u/f,p=f*n,g=f*l;let w=0;for(;m.nextTag(2);){const e=m.getMessage();if(w++===t[h].featureIndex){const t=new o(e,s),r=t.values,i=t.getGeometry(),l=null!=i?[_*(i[0][0].x-p),_*(i[0][0].y-g)]:null;y.push({attributes:r,tilePoint:l}),h++}if(e.release(),h===t.length)return y}break}default:d.skip()}return y}_queryIndex(t,s,r,i,o,l){const a=y*i*(window.devicePixelRatio||1);return this._index?.search({minX:s-a,minY:r-a,maxX:s+a,maxY:r+a},(a=>{const{layer:n,feature:y}=a;n.isIntersectingFeature(s,r,i,y,o,l,a)&&t.push({layerId:n.id,layerIndex:n.uid,tilePoint:null,graphic:new e({attributes:y.values,origin:{type:"vector-tile",layerId:a.layer.id,layerIndex:a.layer.uid,layer:this._parentLayer}})})})),t}async _getTilePayload(e){return t(this._tileKeyToPBF,e.id,(()=>this._tileHandler.fetchTilePBFs(e))).then((e=>e))}}const m=e=>({minX:e.bounds[0],minY:e.bounds[1],maxX:e.bounds[2],maxY:e.bounds[3]});export{d as default};
5
+ import e from"../../../../Graphic.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import s from"../../../../core/pbf.js";import{PooledRBush as r}from"../../../../core/libs/rbush/PooledRBush.js";import{tilePixelSize as i,tileCoordSize as o,tilePixelRatio as l}from"./constants.js";import{BucketType as n}from"./enums.js";import a from"./Feature.js";import{getTileMargins as y}from"./GeometryUtils.js";import c from"./SourceLayerData.js";import{IndexItem as u}from"./style/StyleLayer.js";const h=(e,t)=>{const s=e.vtlSymbol.sourceTile,r=t.vtlSymbol.sourceTile;return s.level!==r.level?s.level-r.level:s.row!==r.row?s.row-r.row:s.col!==r.col?s.col-r.col:e.styleLayerUID-t.styleLayerUID};class d{constructor(e,t,s,r,i){this.tileKey=e,this._tileLayerData=t,this._styleRepository=s,this._tileHandler=r,this._parentLayer=i,this._index=null,this._tileKeyToPBF=new Map}static create(e,t,s,r,i){return new d(e,t,s,r,i)}clear(){this._index?.clear(),this._tileKeyToPBF.clear()}async queryAttributes(e,t,s,i,o){if(0===this._tileLayerData.size||!this._styleRepository||!this._tileHandler)return[];null===this._index&&(this._index=new r(100,m),await this._indexLayers());const l=[];return this._queryIndex(l,e,t,s,this.tileKey.level,i),o&&o?.length>0&&await this._getSymbolsAttributes(l,o),l}async _indexLayers(){const e=this.tileKey,t=this._styleRepository.layers,s=await this._getTilePayload(e);for(const[r,i]of this._tileLayerData){const o=t[r],l=s.find((e=>e.sourceName===o.source));if(!l)continue;const{protobuff:a,key:y}=l;if(i.type!==n.SYMBOL){const t=1<<e.level-y.level,s=e.row-y.row*t,r=e.col-y.col*t;this._indexLayer(o,a,e.level,t,s,r)}}}_indexLayer(e,t,r,l,n,h){const d=e.sourceLayer,m=e.getFeatureFilter(),f=r,_=r+1,p=y(f),g=new s(new Uint8Array(t),new DataView(t));for(;g.next();)switch(g.tag()){case 3:{const t=g.getMessage(),s=new c(t);if(t.release(),s.name!==d)continue;const y=s.getData(),w=s.extent/l,x=w*h-p,b=w*n-p,I=x+w+2*p,L=b+w+2*p,v=w/i,D=o/w,T=w*h,S=w*n;for(;y.nextTag(2);){const t=y.getMessage(),i=new a(t,s);if(t.release(),m&&!m.filter(i,r))continue;const o=i.values||{},l=o._minzoom,n=o._maxzoom;if(l&&l>=10*_||n&&n<=10*f)continue;const c=e.getFeatureInflatedBounds(i,f,s.extent,v);null==c||c[0]>I||c[1]>L||c[2]<x||c[3]<b||(c[0]=(c[0]-T)*D,c[1]=(c[1]-S)*D,c[2]=(c[2]-T)*D,c[3]=(c[3]-S)*D,this._index.insert(new u(e,i,c,D,T,S)))}break}default:g.skip()}}async _getSymbolsAttributes(e,t){if(!t||0===t.length)return e;const s=[];t.sort(h);let r=t[0].styleLayerUID,i=0;for(let l=0;l<t.length;l++)r!==t[l].styleLayerUID&&(s.push({from:i,to:l,styleLayerUID:r,sourceTileKey:t[l].vtlSymbol.sourceTile}),i=l,r=t[l].styleLayerUID);s.push({from:i,to:t.length,styleLayerUID:r,sourceTileKey:t[t.length-1].vtlSymbol.sourceTile});const o=this._styleRepository.layers;for(const l of s){const s=await this._getTilePayload(l.sourceTileKey),i=o[l.styleLayerUID],n=!!i&&s.find((e=>e.sourceName===i.source));n&&this._addSymbolsAttributes(e,t.slice(l.from,l.to).map((e=>e.vtlSymbol)),r,n)}return e}_addSymbolsAttributes(t,s,r,i){const o=this._styleRepository.layers,l=i.key,n=this.tileKey,a=1<<n.level-l.level,y=n.row-l.row*a,c=n.col-l.col*a;this._getSymbolAttributes(i.protobuff,s,r,a,y,c).forEach((s=>{const{attributes:i,tilePoint:l}=s;t.push({layerId:o[r].id,layerIndex:r,graphic:new e({attributes:i,origin:{type:"vector-tile",layerId:o[r].id,layerIndex:r,layer:this._parentLayer}}),tilePoint:l})}))}_getSymbolAttributes(e,t,r,i,l,n){const y=[],u=this._styleRepository.layers;let h=0;t.sort(((e,t)=>e.featureIndex-t.featureIndex));const d=new s(new Uint8Array(e),new DataView(e));for(;d.next();)switch(d.tag()){case 3:{const e=d.getMessage(),s=new c(e);if(e.release(),s.name!==u[r].sourceLayer)continue;const m=s.getData(),f=s.extent/i,_=o/f,p=f*n,g=f*l;let w=0;for(;m.nextTag(2);){const e=m.getMessage();if(w++===t[h].featureIndex){const t=new a(e,s),r=t.values,i=t.getGeometry(),o=null!=i?[_*(i[0][0].x-p),_*(i[0][0].y-g)]:null;y.push({attributes:r,tilePoint:o}),h++}if(e.release(),h===t.length)return y}break}default:d.skip()}return y}_queryIndex(t,s,r,i,o,n){const a=l*i*(window.devicePixelRatio||1);return this._index?.search({minX:s-a,minY:r-a,maxX:s+a,maxY:r+a},(l=>{const{layer:a,feature:y}=l;a.isIntersectingFeature(s,r,i,y,o,n,l)&&t.push({layerId:a.id,layerIndex:a.uid,tilePoint:null,graphic:new e({attributes:y.values,origin:{type:"vector-tile",layerId:l.layer.id,layerIndex:l.layer.uid,layer:this._parentLayer}})})})),t}async _getTilePayload(e){return t(this._tileKeyToPBF,e.id,(()=>this._tileHandler.fetchTilePBFs(e))).then((e=>e))}}const m=e=>({minX:e.bounds[0],minY:e.bounds[1],maxX:e.bounds[2],maxY:e.bounds[3]});export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{set as e,identity as t,translate as i,rotate as s,multiply as l}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toRadian as r}from"../../../../core/libs/gl-matrix-2/math/common.js";import"../../tiling/TileInfoView.js";import a from"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{declutterSingleTile as o}from"./decluttering/jobsUtil.js";import{StyleLayerType as d}from"./style/StyleDefinition.js";import{RenderableTile as c}from"../webgl/RenderableTile.js";import{TileReshuffleManager as h}from"../webgl/TileReshuffleManager.js";import{CompareFunction as u,StencilOperation as m}from"../../../webgl/enums.js";const p=.125;class g{constructor(){this._renderParams={reshuffleManager:new h,context:null,drawPhase:1,state:new f,stationary:!0,pixelRatio:1,displayLevel:-1,requiredLevel:-1,globalOpacity:1,renderPass:"background",styleLayer:null,styleLayerUID:-1,painter:null,glyphMosaic:null,spriteMosaic:null,profiler:null,renderingOptions:null,requestRender:null,allowDelayedRender:!1,deltaTime:-1,timeline:null,time:0,hasClipping:!1,blendMode:null,dataUploadCounter:0,effects:null,inFadeTransition:!1,requireFBO:!1,highlightGradient:null,stencilSymbols:!0,is3D:!0,backgroundColor:null},this._backgroundTile=new c(new a(0,0,0,0),0,0,0,512,512,4096,4096),this._heading=0,this._declutteredForHeading=new WeakMap}dispose(){this._renderParams=null}renderBackground(e,t,i,s,l,n,r,a,o,d){const c=this._backgroundTile;this._updateRenderParameters(e,t,c,i,l,n,r,a,o,d),this._renderParams.stencilSymbols=!1,i.drawBackground(this._renderParams,c,s)}renderContent(e,t,i,s,l,n,r,a,o,d,c,h){this._declutter(i),s.forAll((({sourceLayerInfo:{data:e}})=>this._declutter(e)));const m=s.length>0;m&&this._stencilSymbols(e,t,i,s,l,n,r,a,o,d,c,h);let p=1;i.stencilRef=m?p:0,e.setStencilFunction(u.EQUAL,i.stencilRef,255),this._render(e,t,i,l,n,r,a,o,d,c,h),s.forAll((({sourceLod:t,offset:i,sourceLayerInfo:{data:s}})=>{s.stencilRef=++p,this._renderSymbols(e,t,s,l,n,r,a,i,d,c,h)}))}_stencilSymbols(e,t,i,s,l,n,r,a,o,d,c,h){let p=1;i.stencilRef=p,e.setDepthTestEnabled(!1),e.setDepthWriteEnabled(!1),e.setStencilTestEnabled(!0),e.setBlendingEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setStencilOp(m.KEEP,m.KEEP,m.REPLACE),e.setStencilWriteMask(255),e.setStencilFunction(u.ALWAYS,i.stencilRef,255),this._stencilTileSymbols(e,t,i,l,n,r,a,o,d,c,h),s.forAll((({sourceLod:t,offset:i,sourceLayerInfo:{data:s}})=>{s.stencilRef=++p,e.setStencilFunction(u.ALWAYS,s.stencilRef,255),this._stencilTileSymbols(e,t,s,l,n,r,a,i,d,c,h)})),e.setStencilWriteMask(0),e.setBlendingEnabled(!0),e.setDepthTestEnabled(!0),e.setColorMask(!0,!0,!0,!0)}_renderSymbols(e,t,i,s,l,n,r,a,o,c,h){e.setStencilFunction(u.EQUAL,i.stencilRef,255),this._render(e,t,i,s,l,n,r,a,o,c,h,d.SYMBOL)}_render(e,t,i,s,l,n,r,a,o,d,c,h){this._updateRenderParameters(e,t,i,s,n,r,a,o,d,c),this._renderParams.stencilSymbols=!1,s.drawTile(this._renderParams,i,l,h)}_stencilTileSymbols(e,t,i,s,l,n,r,a,o,d,c){this._updateRenderParameters(e,t,i,s,n,r,a,o,d,c),this._renderParams.stencilSymbols=!0,i.triangleCount=0,s.drawSymbols(this._renderParams,i,l)}_updateRenderParameters(n,a,o,d,c,h,u,m,g,f){"type"in o&&"vector-tile"===o.type&&!o.stage&&o.attachWithContext(n);const y=a[0]-c.getLevelShift(a[0]),_=this._renderParams;_.context=n,_.painter=d,_.glyphMosaic=d.glyphMosaic,_.spriteMosaic=d.spriteMosaic,_.pixelRatio=g*f,_.displayLevel=y,_.requiredLevel=y;const b=c.getScale(a[0]),[S,M]=c.getOffset(a,h*b),w=p*h*b/m,R=o.transforms.displayViewScreenMat3;R[0]=w,R[4]=-w,R[6]=-1-S-u[0]*h*2,R[7]=1+M+(1-u[1])*h*2-2;const T=_.state,L=m/f;T.size[0]=L,T.size[1]=L,T.pixelRatio=f,T.rotation=(360-this._heading)%360;const P=2/L;e(T.displayViewMat3,P,0,0,0,-P,0,-1,1,1);const E=t(T.displayMat3),j=r(this._heading);i(E,E,[L/2,L/2]),s(E,E,j),i(E,E,[-L/2,-L/2]),l(E,T.displayViewMat3,E)}updateHeading(e){this._heading=e}_declutter(e){this._declutteredForHeading.get(e)!==this._heading&&(o(e,(360-this._heading)%360),this._declutteredForHeading.set(e,this._heading))}}class f{constructor(){this.size=[0,0],this.pixelRatio=1,this.rotation=0,this.displayMat3=n(),this.displayViewMat3=n(),this.transform=null,this.inverseTransform=null,this.viewMat2d=null,this.viewMat3=null,this.id=0,this.extent=null,this.center=null,this.scale=1,this.resolution=0,this.worldScreenWidth=0,this.spatialReference=null,this.viewpoint=null,this.getScreenTransform=null,this.toMap=null,this.toScreen=null,this.clone=null,this.copy=null,this.toJSON=null}}export{g as VectorTileRendererHelper3D};
5
+ import{set as e,identity as t,translate as i,rotate as s,multiply as l}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toRadian as r}from"../../../../core/libs/gl-matrix-2/math/common.js";import"../../tiling/TileInfoView.js";import a from"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{tilePixelSize as o,tileCoordSize as d,tileCoordinateScale as c}from"./constants.js";import{declutterSingleTile as h}from"./decluttering/jobsUtil.js";import{StyleLayerType as u}from"./style/StyleDefinition.js";import{RenderableTile as m}from"../webgl/RenderableTile.js";import{TileReshuffleManager as p}from"../webgl/TileReshuffleManager.js";import{CompareFunction as g,StencilOperation as f}from"../../../webgl/enums.js";class y{constructor(){this._renderParams={reshuffleManager:new p,context:null,drawPhase:1,state:new _,stationary:!0,pixelRatio:1,displayLevel:-1,requiredLevel:-1,globalOpacity:1,renderPass:"background",styleLayer:null,styleLayerUID:-1,painter:null,glyphMosaic:null,spriteMosaic:null,profiler:null,renderingOptions:null,requestRender:null,allowDelayedRender:!1,deltaTime:-1,timeline:null,time:0,hasClipping:!1,blendMode:null,dataUploadCounter:0,effects:null,inFadeTransition:!1,requireFBO:!1,highlightGradient:null,stencilSymbols:!0,is3D:!0,backgroundColor:null},this._backgroundTile=new m(new a(0,0,0,0),0,0,0,o,o,d,d),this._heading=0,this._declutteredForHeading=new WeakMap}dispose(){this._renderParams=null}renderBackground(e,t,i,s,l,n,r,a,o,d){const c=this._backgroundTile;this._updateRenderParameters(e,t,c,i,l,n,r,a,o,d),this._renderParams.stencilSymbols=!1,i.drawBackground(this._renderParams,c,s)}renderContent(e,t,i,s,l,n,r,a,o,d,c,h){this._declutter(i),s.forAll((({sourceLayerInfo:{data:e}})=>this._declutter(e)));const u=s.length>0;u&&this._stencilSymbols(e,t,i,s,l,n,r,a,o,d,c,h);let m=1;i.stencilRef=u?m:0,e.setStencilFunction(g.EQUAL,i.stencilRef,255),this._render(e,t,i,l,n,r,a,o,d,c,h),s.forAll((({sourceLod:t,offset:i,sourceLayerInfo:{data:s}})=>{s.stencilRef=++m,this._renderSymbols(e,t,s,l,n,r,a,i,d,c,h)}))}_stencilSymbols(e,t,i,s,l,n,r,a,o,d,c,h){let u=1;i.stencilRef=u,e.setDepthTestEnabled(!1),e.setDepthWriteEnabled(!1),e.setStencilTestEnabled(!0),e.setBlendingEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setStencilOp(f.KEEP,f.KEEP,f.REPLACE),e.setStencilWriteMask(255),e.setStencilFunction(g.ALWAYS,i.stencilRef,255),this._stencilTileSymbols(e,t,i,l,n,r,a,o,d,c,h),s.forAll((({sourceLod:t,offset:i,sourceLayerInfo:{data:s}})=>{s.stencilRef=++u,e.setStencilFunction(g.ALWAYS,s.stencilRef,255),this._stencilTileSymbols(e,t,s,l,n,r,a,i,d,c,h)})),e.setStencilWriteMask(0),e.setBlendingEnabled(!0),e.setDepthTestEnabled(!0),e.setColorMask(!0,!0,!0,!0)}_renderSymbols(e,t,i,s,l,n,r,a,o,d,c){e.setStencilFunction(g.EQUAL,i.stencilRef,255),this._render(e,t,i,s,l,n,r,a,o,d,c,u.SYMBOL)}_render(e,t,i,s,l,n,r,a,o,d,c,h){this._updateRenderParameters(e,t,i,s,n,r,a,o,d,c),this._renderParams.stencilSymbols=!1,s.drawTile(this._renderParams,i,l,h)}_stencilTileSymbols(e,t,i,s,l,n,r,a,o,d,c){this._updateRenderParameters(e,t,i,s,n,r,a,o,d,c),this._renderParams.stencilSymbols=!0,i.triangleCount=0,s.drawSymbols(this._renderParams,i,l)}_updateRenderParameters(n,a,o,d,h,u,m,p,g,f){"type"in o&&"vector-tile"===o.type&&!o.stage&&o.attachWithContext(n);const y=a[0]-h.getLevelShift(a[0]),_=this._renderParams;_.context=n,_.painter=d,_.glyphMosaic=d.glyphMosaic,_.spriteMosaic=d.spriteMosaic,_.pixelRatio=g*f,_.displayLevel=y,_.requiredLevel=y;const b=h.getScale(a[0]),[S,M]=h.getOffset(a,u*b),w=c*u*b/p,R=o.transforms.displayViewScreenMat3;R[0]=w,R[4]=-w,R[6]=-1-S-m[0]*u*2,R[7]=1+M+(1-m[1])*u*2-2;const T=_.state,L=p/f;T.size[0]=L,T.size[1]=L,T.pixelRatio=f,T.rotation=(360-this._heading)%360;const P=2/L;e(T.displayViewMat3,P,0,0,0,-P,0,-1,1,1);const j=t(T.displayMat3),E=r(this._heading);i(j,j,[L/2,L/2]),s(j,j,E),i(j,j,[-L/2,-L/2]),l(j,T.displayViewMat3,j)}updateHeading(e){this._heading=e}_declutter(e){this._declutteredForHeading.get(e)!==this._heading&&(h(e,(360-this._heading)%360),this._declutteredForHeading.set(e,this._heading))}}class _{constructor(){this.size=[0,0],this.pixelRatio=1,this.rotation=0,this.displayMat3=n(),this.displayViewMat3=n(),this.transform=null,this.inverseTransform=null,this.viewMat2d=null,this.viewMat3=null,this.id=0,this.extent=null,this.center=null,this.scale=1,this.resolution=0,this.worldScreenWidth=0,this.spatialReference=null,this.viewpoint=null,this.getScreenTransform=null,this.toMap=null,this.toScreen=null,this.clone=null,this.copy=null,this.toJSON=null}}export{y as VectorTileRendererHelper3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t,e,s){this.layerExtent=4096,this._features=[],this.layer=t,this.zoom=e,this._spriteInfo=s,this._filter=t.getFeatureFilter()}pushFeature(t){this._filter&&!this._filter.filter(t,this.zoom)||this._features.push(t)}hasFeatures(){return this._features.length>0}getResources(t,e,s){}}export{t as default};
5
+ import{tileCoordSize as t}from"../constants.js";class e{constructor(e,s,r){this.layerExtent=t,this._features=[],this.layer=e,this.zoom=s,this._spriteInfo=r,this._filter=e.getFeatureFilter()}pushFeature(t){this._filter&&!this._filter.filter(t,this.zoom)||this._features.push(t)}hasFeatures(){return this._features.length>0}getResources(t,e,s){}}export{e 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.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/BidiEngine.js";import{assertIsSome as t}from"../../../../../core/maybe.js";import{numericHash as n}from"../../../../../core/string.js";import{GeometryType as i,Point as s}from"../../../../../geometry/support/TileClipper.js";import{BucketType as a}from"../enums.js";import{cDegToRad as o,log2 as r,interpolate as l}from"../GeometryUtils.js";import{tilePixelRatio as h,Anchor as x,tileCoordSize as c}from"../Placement.js";import{sdfGlyphSize as d,TextShaping as f}from"../TextShaping.js";import g from"./BaseBucket.js";import{TextTransform as y,SymbolPlacement as m,RotationAlignment as u,TextWritingMode as p,SymbolAnchor as _,TextJustification as M}from"../style/StyleDefinition.js";import{IconLayout as P,TextLayout as I}from"../style/StyleLayer.js";const b=10;function A(e,t){return e.iconMosaicItem&&t.iconMosaicItem?e.iconMosaicItem.page===t.iconMosaicItem.page?0:e.iconMosaicItem.page-t.iconMosaicItem.page:e.iconMosaicItem&&!t.iconMosaicItem?1:!e.iconMosaicItem&&t.iconMosaicItem?-1:0}class L extends g{constructor(e,t,n,i,s,o,r,l,h){super(t,n,h.getSpriteItems()),this.type=a.SYMBOL,this._markerMap=new Map,this._glyphMap=new Map,this._glyphBufferDataStorage=new Map,this._isIconSDF=!1,this._sourceTileKey=e,this._iconVertexBuffer=i,this._iconIndexBuffer=s,this._textVertexBuffer=o,this._textIndexBuffer=r,this._placementEngine=l,this._workerTileHandler=h}get markerPageMap(){return this._markerMap}get glyphsPageMap(){return this._glyphMap}get symbolInstances(){return this._symbolInstances}static{this._bidiEngine=new e}getResources(e,t,i){const s=this.layer,a=this.zoom;e&&e.setExtent(this.layerExtent);const o=s.getLayoutProperty("icon-image"),r=s.getLayoutProperty("text-field");let l=s.getLayoutProperty("text-transform"),h=s.getLayoutProperty("text-font");const x=[];let c,d,f,g;o&&!o.isDataDriven&&(c=o.getValue(a)),r&&!r.isDataDriven&&(d=r.getValue(a)),l&&l.isDataDriven||(f=s.getLayoutValue("text-transform",a),l=null),h&&h.isDataDriven||(g=s.getLayoutValue("text-font",a),h=null);for(const m of this._features){const u=m.getGeometry(e);if(!u||0===u.length)continue;let p,_;o&&(p=o.isDataDriven?o.getValue(a,m):this._replaceKeys(c,m.values),p&&t(p));let M=!1;if(r&&(_=r.isDataDriven?r.getValue(a,m):this._replaceKeys(d,m.values),_)){switch(_=_.replaceAll("\\n","\n"),l&&(f=l.getValue(a,m)),f){case y.LOWERCASE:_=_.toLowerCase();break;case y.UPPERCASE:_=_.toUpperCase()}if(L._bidiEngine.hasBidiChar(_)){let e;e="rtl"===L._bidiEngine.checkContextual(_)?"IDNNN":"ICNNN",_=L._bidiEngine.bidiTransform(_,e,"VLYSN"),M=!0}if(_.length>0){h&&(g=h.getValue(a,m));for(const e of g){let t=i[e];t||(t=i[e]=new Set);for(const e of _){const n=e.codePointAt(0);null!=n&&t.add(n)}}}}if(!p&&!_)continue;const P=s.getLayoutValue("symbol-sort-key",a,m),I={feature:m,sprite:p,label:_,rtl:M,geometry:u,hash:(_?n(_):0)^(p?n(p):0),priority:P,textFont:g};x.push(I)}this._symbolFeatures=x}processFeatures(e){e&&e.setExtent(this.layerExtent);const n=this.layer,s=this.zoom,a=n.getLayoutValue("symbol-placement",s),r=a!==m.POINT,l=n.getLayoutValue("symbol-spacing",s)*h,g=n.getLayoutProperty("icon-image"),y=n.getLayoutProperty("text-field"),b=g?new P(n,s,r):null,T=y?new I(n,s,r):null,V=this._workerTileHandler;let w;g&&(w=V.getSpriteItems()),this._iconIndexStart=3*this._iconIndexBuffer.index,this._textIndexStart=3*this._textIndexBuffer.index,this._iconIndexCount=0,this._textIndexCount=0,this._markerMap.clear(),this._glyphMap.clear();const B=[];let C=1;T?.size&&(C=T.size/d);const R=T?T.maxAngle*o:0,D=T?T.size*h:0;for(const o of this._symbolFeatures){let e;b&&w&&o.sprite&&(e=w[o.sprite],e&&e.sdf&&(this._isIconSDF=!0));let n;!!e&&b.update(s,o.feature);let g=0;const y=o.label;if(y){t(T),T.update(s,o.feature);const e=r&&T.rotationAlignment===u.MAP?T.keepUpright:T.writingMode&&T.writingMode.includes(p.VERTICAL);let i=.5;switch(T.anchor){case _.TOP_LEFT:case _.LEFT:case _.BOTTOM_LEFT:i=0;break;case _.TOP_RIGHT:case _.RIGHT:case _.BOTTOM_RIGHT:i=1}let a=.5;switch(T.anchor){case _.TOP_LEFT:case _.TOP:case _.TOP_RIGHT:a=0;break;case _.BOTTOM_LEFT:case _.BOTTOM:case _.BOTTOM_RIGHT:a=1}let l=.5;switch(T.justify){case M.AUTO:l=i;break;case M.LEFT:l=0;break;case M.RIGHT:l=1}const x=T.letterSpacing*d,c=r?0:T.maxWidth*d,m=T.lineHeight*d,P=o.textFont.map((e=>V.getGlyphItems(e)));if(n=new f(P,c,m,x,i,a,l).getShaping(y,o.rtl,e),n&&n.length>0){let e=1e30,t=-1e30;for(const i of n)e=Math.min(e,i.x),t=Math.max(t,i.x);g=(t-e+2*d)*C*h}}for(let t of o.geometry){const s=[];if(a===m.LINE){if(n?.length&&T?.size){const e=T.size*h*(2+Math.min(2,4*Math.abs(T.offset[1])));t=L._smoothVertices(t,e)}L._pushAnchors(s,t,l,g)}else a===m.LINE_CENTER?L._pushCenterAnchor(s,t):o.feature.type===i.Polygon?L._pushCentroid(s,t):s.push(new x(t[0].x,t[0].y));for(const i of s){if(i.x<0||i.x>c||i.y<0||i.y>c)continue;if(r&&g>0&&T?.rotationAlignment===u.MAP&&!L._honorsTextMaxAngle(t,i,g,R,D))continue;const s={shaping:n,line:t,iconMosaicItem:e,anchor:i,symbolFeature:o,textColliders:[],iconColliders:[],textVertexRanges:[],iconVertexRanges:[]};B.push(s),this._processFeature(s,b,T)}}}B.sort(A),this._addPlacedGlyphs(),this._symbolInstances=B}serialize(){let e=14;e+=this.layerUIDs.length,e+=3*this.markerPageMap.size,e+=3*this.glyphsPageMap.size,e+=L._symbolsSerializationLength(this._symbolInstances),e+=this._iconVertexBuffer.array.length,e+=this._iconIndexBuffer.array.length,e+=this._textVertexBuffer.array.length,e+=this._textIndexBuffer.array.length;const t=new Uint32Array(e),n=new Int32Array(t.buffer),i=new Float32Array(t.buffer),[s,a,o]=this._sourceTileKey.split("/");let r=0;t[r++]=this.type,t[r++]=this.layerUIDs.length;for(let l=0;l<this.layerUIDs.length;l++)t[r++]=this.layerUIDs[l];t[r++]=this._isIconSDF?1:0,t[r++]=parseFloat(s),t[r++]=parseFloat(a),t[r++]=parseFloat(o),t[r++]=this.markerPageMap.size;for(const[l,[h,x]]of this.markerPageMap)t[r++]=l,t[r++]=h,t[r++]=x;t[r++]=this.glyphsPageMap.size;for(const[l,[h,x]]of this.glyphsPageMap)t[r++]=l,t[r++]=h,t[r++]=x;t[r++]=this._iconVertexBuffer.index/4,t[r++]=this._textVertexBuffer.index/4,r=L.serializeSymbols(t,n,i,r,this._symbolInstances),t[r++]=this._iconVertexBuffer.array.length;for(let l=0;l<this._iconVertexBuffer.array.length;l++)n[r++]=this._iconVertexBuffer.array[l];t[r++]=this._iconIndexBuffer.array.length;for(let l=0;l<this._iconIndexBuffer.array.length;l++)t[r++]=this._iconIndexBuffer.array[l];t[r++]=this._textVertexBuffer.array.length;for(let l=0;l<this._textVertexBuffer.array.length;l++)n[r++]=this._textVertexBuffer.array[l];t[r++]=this._textIndexBuffer.array.length;for(let l=0;l<this._textIndexBuffer.array.length;l++)t[r++]=this._textIndexBuffer.array[l];return t.buffer}static _symbolsSerializationLength(e){let t=0;t+=1;for(const n of e||[]){t+=5,t+=1;for(const e of n.textColliders)t+=b;for(const e of n.iconColliders)t+=b;t+=1,t+=2*n.textVertexRanges.length,t+=1,t+=2*n.iconVertexRanges.length}return t}static serializeSymbols(e,t,n,i,s){s=s||[],t[i++]=s.length;for(const a of s){t[i++]=a.anchor.x,t[i++]=a.anchor.y,t[i++]=a.symbolFeature.hash,t[i++]=a.symbolFeature.priority,t[i++]=a.symbolFeature.feature.featureIndex,t[i++]=a.textColliders.length+a.iconColliders.length;for(const e of a.textColliders)t[i++]=e.xTile,t[i++]=e.yTile,t[i++]=e.dxPixels,t[i++]=e.dyPixels,t[i++]=e.hard?1:0,t[i++]=e.partIndex,n[i++]=e.minLod,n[i++]=e.maxLod,t[i++]=e.width,t[i++]=e.height;for(const e of a.iconColliders)t[i++]=e.xTile,t[i++]=e.yTile,t[i++]=e.dxPixels,t[i++]=e.dyPixels,t[i++]=e.hard?1:0,t[i++]=e.partIndex,n[i++]=e.minLod,n[i++]=e.maxLod,t[i++]=e.width,t[i++]=e.height;t[i++]=a.textVertexRanges.length;for(const[e,n]of a.textVertexRanges)t[i++]=e,t[i++]=n;t[i++]=a.iconVertexRanges.length;for(const[e,n]of a.iconVertexRanges)t[i++]=e,t[i++]=n}return i}_replaceKeys(e,t){return e.replaceAll(/{([^{}]+)}/g,((e,n)=>n in t?t[n]:""))}_processFeature(e,t,n){const{line:i,iconMosaicItem:s,shaping:a,anchor:o}=e,l=this.zoom,h=this.layer,x=!!s;let c=!0;x&&(c=t?.optional||!s);const d=a&&a.length>0,f=!d||n?.optional;let g,y;if(x&&(g=this._placementEngine.getIconPlacement(o,s,t)),(g||c)&&(d&&(y=this._placementEngine.getTextPlacement(o,a,i,n)),y||f)){if(g&&y||(f||c?f||y?c||g||(y=null):g=null:(g=null,y=null)),y){const t=h.hasDataDrivenText?h.textMaterial.encodeAttributes(e.symbolFeature.feature,l,h):null;if(this._storePlacedGlyphs(e,y.shapes,l,n.rotationAlignment,t),y.textColliders){e.textColliders=y.textColliders;for(const e of y.textColliders){e.minLod=Math.max(l+r(e.minLod),0),e.maxLod=Math.min(l+r(e.maxLod),25);const t=e.angle;if(t){const n=Math.cos(t),i=Math.sin(t),s=e.dxPixels*n-e.dyPixels*i,a=e.dxPixels*i+e.dyPixels*n,o=(e.dxPixels+e.width)*n-e.dyPixels*i,r=(e.dxPixels+e.width)*i+e.dyPixels*n,l=e.dxPixels*n-(e.dyPixels+e.height)*i,h=e.dxPixels*i+(e.dyPixels+e.height)*n,x=(e.dxPixels+e.width)*n-(e.dyPixels+e.height)*i,c=(e.dxPixels+e.width)*i+(e.dyPixels+e.height)*n,d=Math.min(s,o,l,x),f=Math.max(s,o,l,x),g=Math.min(a,r,h,c),y=Math.max(a,r,h,c);e.dxPixels=d,e.dyPixels=g,e.width=f-d,e.height=y-g}}}}if(g){const n=h.hasDataDrivenIcon?h.iconMaterial.encodeAttributes(e.symbolFeature.feature,l,h):null;if(this._addPlacedIcons(e,g.shapes,l,s.page,t.rotationAlignment===u.VIEWPORT,n),g.iconColliders){e.iconColliders=g.iconColliders;for(const e of g.iconColliders){e.minLod=Math.max(l+r(e.minLod),0),e.maxLod=Math.min(l+r(e.maxLod),25);const t=e.angle;if(t){const n=Math.cos(t),i=Math.sin(t),s=e.dxPixels*n-e.dyPixels*i,a=e.dxPixels*i+e.dyPixels*n,o=(e.dxPixels+e.width)*n-e.dyPixels*i,r=(e.dxPixels+e.width)*i+e.dyPixels*n,l=e.dxPixels*n-(e.dyPixels+e.height)*i,h=e.dxPixels*i+(e.dyPixels+e.height)*n,x=(e.dxPixels+e.width)*n-(e.dyPixels+e.height)*i,c=(e.dxPixels+e.width)*i+(e.dyPixels+e.height)*n,d=Math.min(s,o,l,x),f=Math.max(s,o,l,x),g=Math.min(a,r,h,c),y=Math.max(a,r,h,c);e.dxPixels=d,e.dyPixels=g,e.width=f-d,e.height=y-g}}}}}}_addPlacedIcons(e,t,n,i,s,a){const o=Math.max(n-1,0),l=this._iconVertexBuffer,h=this._iconIndexBuffer,x=this._markerMap;for(const c of t){const t=s?0:Math.max(n+r(c.minzoom),o),d=s?25:Math.min(n+r(c.maxzoom),25);if(d<=t)continue;const f=c.tl,g=c.tr,y=c.bl,m=c.br,u=c.mosaicRect,p=c.labelAngle,_=c.minAngle,M=c.maxAngle,P=c.anchor,I=l.index,b=u.x,A=u.y,L=b+u.width,T=A+u.height,V=l.index;l.add(P.x,P.y,f.x,f.y,b,A,p,_,M,t,d,a),l.add(P.x,P.y,g.x,g.y,L,A,p,_,M,t,d,a),l.add(P.x,P.y,y.x,y.y,b,T,p,_,M,t,d,a),l.add(P.x,P.y,m.x,m.y,L,T,p,_,M,t,d,a),e.iconVertexRanges.length>0&&e.iconVertexRanges[0][0]+e.iconVertexRanges[0][1]===V?e.iconVertexRanges[0][1]+=4:e.iconVertexRanges.push([V,4]),h.add(I,I+1,I+2),h.add(I+1,I+2,I+3),x.has(i)?x.get(i)[1]+=6:x.set(i,[this._iconIndexStart+this._iconIndexCount,6]),this._iconIndexCount+=6}}_addPlacedGlyphs(){const e=this._textVertexBuffer,t=this._textIndexBuffer,n=this._glyphMap;for(const[i,s]of this._glyphBufferDataStorage)for(const a of s){const s=e.index,o=a.symbolInstance,r=a.ddAttributes,l=e.index;e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.tl[0],a.tl[1],a.xmin,a.ymin,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.tr[0],a.tr[1],a.xmax,a.ymin,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.bl[0],a.bl[1],a.xmin,a.ymax,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.br[0],a.br[1],a.xmax,a.ymax,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),o.textVertexRanges.length>0&&o.textVertexRanges[0][0]+o.textVertexRanges[0][1]===l?o.textVertexRanges[0][1]+=4:o.textVertexRanges.push([l,4]),t.add(s,s+1,s+2),t.add(s+1,s+2,s+3),n.has(i)?n.get(i)[1]+=6:n.set(i,[this._textIndexStart+this._textIndexCount,6]),this._textIndexCount+=6}this._glyphBufferDataStorage.clear()}_storePlacedGlyphs(e,t,n,i,s){const a=Math.max(n-1,0),o=i===u.VIEWPORT;let l,h,x,c,d,f,g,y,m,p,_;for(const u of t){if(l=o?0:Math.max(n+r(u.minzoom),a),h=o?25:Math.min(n+r(u.maxzoom),25),h<=l)continue;x=u.tl,c=u.tr,d=u.bl,f=u.br,g=u.labelAngle,y=u.minAngle,m=u.maxAngle,p=u.anchor,_=u.mosaicRect,this._glyphBufferDataStorage.has(u.page)||this._glyphBufferDataStorage.set(u.page,[]);this._glyphBufferDataStorage.get(u.page).push({glyphAnchor:[p.x,p.y],tl:[x.x,x.y],tr:[c.x,c.y],bl:[d.x,d.y],br:[f.x,f.y],xmin:_.x,ymin:_.y,xmax:_.x+_.width,ymax:_.y+_.height,labelAngle:g,minAngle:y,maxAngle:m,minLod:l,maxLod:h,placementLod:a,symbolInstance:e,ddAttributes:s})}}static _pushAnchors(e,t,n,i){n+=i;let a=0;const o=t.length-1;for(let l=0;l<o;l++)a+=s.distance(t[l],t[l+1]);let r=i||n;if(r*=.5,a<=r)return;const h=r/a;let c=0,d=-(n=a/Math.max(Math.round(a/n),1))/2;const f=t.length-1;for(let s=0;s<f;s++){const i=t[s],a=t[s+1],o=a.x-i.x,r=a.y-i.y,f=Math.sqrt(o*o+r*r);let g;for(;d+n<c+f;){d+=n;const t=(d-c)/f,y=l(i.x,a.x,t),m=l(i.y,a.y,t);void 0===g&&(g=Math.atan2(r,o)),e.push(new x(y,m,g,s,h))}c+=f}}static _pushCenterAnchor(e,t){let n=0;const i=t.length-1;for(let l=0;l<i;l++)n+=s.distance(t[l],t[l+1]);const a=n/2;let o=0;const r=t.length-1;for(let s=0;s<r;s++){const n=t[s],i=t[s+1],r=i.x-n.x,h=i.y-n.y,c=Math.sqrt(r*r+h*h);if(a<o+c){const t=(a-o)/c,d=l(n.x,i.x,t),f=l(n.y,i.y,t),g=Math.atan2(h,r);return void e.push(new x(d,f,g,s,0))}o+=c}}static _deviation(e,t,n){const i=(t.x-e.x)*(n.x-t.x)+(t.y-e.y)*(n.y-t.y),s=(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x);return Math.atan2(s,i)}static _honorsTextMaxAngle(e,t,n,i,a){let o=0;const r=n/2;let l=new s(t.x,t.y),h=t.segment+1;for(;o>-r;){if(--h,h<0)return!1;o-=s.distance(e[h],l),l=e[h]}o+=s.distance(e[h],e[h+1]);const x=[];let c=0;const d=e.length;for(;o<r;){const t=e[h];let n,r=h;do{if(++r,r===d)return!1;n=e[r]}while(n.isEqual(t));let l,f=r;do{if(++f,f===d)return!1;l=e[f]}while(l.isEqual(n));const g=this._deviation(t,n,l);for(x.push({deviation:g,distToAnchor:o}),c+=g;o-x[0].distToAnchor>a;)c-=x.shift().deviation;if(Math.abs(c)>i)return!1;o+=s.distance(n,l),h=r}return!0}static _smoothVertices(e,t){if(t<=0)return e;let n=e.length;if(n<3)return e;const i=[];let a=0,o=0;i.push(0);for(let y=1;y<n;y++){const t=s.distance(e[y],e[y-1]);t>0&&(a+=t,i.push(a),o++,o!==y&&(e[o]=e[y]))}if(n=o+1,n<3)return e;t=Math.min(t,.2*a);const r=e[0].x,l=e[0].y,h=e[n-1].x,x=e[n-1].y,c=s.sub(e[0],e[1]);c.normalize(),e[0].x+=t*c.x,e[0].y+=t*c.y,c.assignSub(e[n-1],e[n-2]),c.normalize(),e[n-1].x+=t*c.x,e[n-1].y+=t*c.y,i[0]-=t,i[n-1]+=t;const d=[];d.push(new s(r,l));const f=1e-6,g=.5*t;for(let y=1;y<n-1;y++){let a=0,o=0,r=0;for(let n=y-1;n>=0;n--){const s=g+i[n+1]-i[y];if(s<0)break;const l=i[n+1]-i[n],h=i[y]-i[n]<g?1:s/l;if(h<f)break;const x=h*h,c=h*s-.5*x*l,d=h*l/t,m=e[n+1],u=e[n].x-m.x,p=e[n].y-m.y;a+=d/c*(m.x*h*s+.5*x*(s*u-l*m.x)-x*h*l*u/3),o+=d/c*(m.y*h*s+.5*x*(s*p-l*m.y)-x*h*l*p/3),r+=d}for(let s=y+1;s<n;s++){const n=g-i[s-1]+i[y];if(n<0)break;const l=i[s]-i[s-1],h=i[s]-i[y]<g?1:n/l;if(h<f)break;const x=h*h,c=h*n-.5*x*l,d=h*l/t,m=e[s-1],u=e[s].x-m.x,p=e[s].y-m.y;a+=d/c*(m.x*h*n+.5*x*(n*u-l*m.x)-x*h*l*u/3),o+=d/c*(m.y*h*n+.5*x*(n*p-l*m.y)-x*h*l*p/3),r+=d}d.push(new s(a/r,o/r))}return d.push(new s(h,x)),e[0].x=r,e[0].y=l,e[n-1].x=h,e[n-1].y=x,d}static _pushCentroid(e,t){const n=0,i=0,s=4096,a=4096,o=t.length-1;let r=0,l=0,h=0,c=t[0].x,d=t[0].y;c>s&&(c=s),c<n&&(c=n),d>a&&(d=a),d<i&&(d=i);for(let x=1;x<o;x++){let e=t[x].x,o=t[x].y,f=t[x+1].x,g=t[x+1].y;e>s&&(e=s),e<n&&(e=n),o>a&&(o=a),o<i&&(o=i),f>s&&(f=s),f<n&&(f=n),g>a&&(g=a),g<i&&(g=i);const y=(e-c)*(g-d)-(f-c)*(o-d);r+=y*(c+e+f),l+=y*(d+o+g),h+=y}r/=3*h,l/=3*h,isNaN(r)||isNaN(l)||e.push(new x(r,l))}}export{L as default};
5
+ import e from"../../../../../core/BidiEngine.js";import{assertIsSome as t}from"../../../../../core/maybe.js";import{numericHash as n}from"../../../../../core/string.js";import{GeometryType as i,Point as s}from"../../../../../geometry/support/TileClipper.js";import{tilePixelRatio as a,tileCoordSize as o}from"../constants.js";import{BucketType as r}from"../enums.js";import{cDegToRad as l,log2 as h,interpolate as x}from"../GeometryUtils.js";import{Anchor as c}from"../Placement.js";import{sdfGlyphSize as d,TextShaping as f}from"../TextShaping.js";import g from"./BaseBucket.js";import{TextTransform as y,SymbolPlacement as m,RotationAlignment as u,TextWritingMode as p,SymbolAnchor as _,TextJustification as M}from"../style/StyleDefinition.js";import{IconLayout as P,TextLayout as I}from"../style/StyleLayer.js";const b=10;function A(e,t){return e.iconMosaicItem&&t.iconMosaicItem?e.iconMosaicItem.page===t.iconMosaicItem.page?0:e.iconMosaicItem.page-t.iconMosaicItem.page:e.iconMosaicItem&&!t.iconMosaicItem?1:!e.iconMosaicItem&&t.iconMosaicItem?-1:0}class L extends g{constructor(e,t,n,i,s,a,o,l,h){super(t,n,h.getSpriteItems()),this.type=r.SYMBOL,this._markerMap=new Map,this._glyphMap=new Map,this._glyphBufferDataStorage=new Map,this._isIconSDF=!1,this._sourceTileKey=e,this._iconVertexBuffer=i,this._iconIndexBuffer=s,this._textVertexBuffer=a,this._textIndexBuffer=o,this._placementEngine=l,this._workerTileHandler=h}get markerPageMap(){return this._markerMap}get glyphsPageMap(){return this._glyphMap}get symbolInstances(){return this._symbolInstances}static{this._bidiEngine=new e}getResources(e,t,i){const s=this.layer,a=this.zoom;e&&e.setExtent(this.layerExtent);const o=s.getLayoutProperty("icon-image"),r=s.getLayoutProperty("text-field");let l=s.getLayoutProperty("text-transform"),h=s.getLayoutProperty("text-font");const x=[];let c,d,f,g;o&&!o.isDataDriven&&(c=o.getValue(a)),r&&!r.isDataDriven&&(d=r.getValue(a)),l&&l.isDataDriven||(f=s.getLayoutValue("text-transform",a),l=null),h&&h.isDataDriven||(g=s.getLayoutValue("text-font",a),h=null);for(const m of this._features){const u=m.getGeometry(e);if(!u||0===u.length)continue;let p,_;o&&(p=o.isDataDriven?o.getValue(a,m):this._replaceKeys(c,m.values),p&&t(p));let M=!1;if(r&&(_=r.isDataDriven?r.getValue(a,m):this._replaceKeys(d,m.values),_)){switch(_=_.replaceAll("\\n","\n"),l&&(f=l.getValue(a,m)),f){case y.LOWERCASE:_=_.toLowerCase();break;case y.UPPERCASE:_=_.toUpperCase()}if(L._bidiEngine.hasBidiChar(_)){let e;e="rtl"===L._bidiEngine.checkContextual(_)?"IDNNN":"ICNNN",_=L._bidiEngine.bidiTransform(_,e,"VLYSN"),M=!0}if(_.length>0){h&&(g=h.getValue(a,m));for(const e of g){let t=i[e];t||(t=i[e]=new Set);for(const e of _){const n=e.codePointAt(0);null!=n&&t.add(n)}}}}if(!p&&!_)continue;const P=s.getLayoutValue("symbol-sort-key",a,m),I={feature:m,sprite:p,label:_,rtl:M,geometry:u,hash:(_?n(_):0)^(p?n(p):0),priority:P,textFont:g};x.push(I)}this._symbolFeatures=x}processFeatures(e){e&&e.setExtent(this.layerExtent);const n=this.layer,s=this.zoom,r=n.getLayoutValue("symbol-placement",s),h=r!==m.POINT,x=n.getLayoutValue("symbol-spacing",s)*a,g=n.getLayoutProperty("icon-image"),y=n.getLayoutProperty("text-field"),b=g?new P(n,s,h):null,T=y?new I(n,s,h):null,V=this._workerTileHandler;let w;g&&(w=V.getSpriteItems()),this._iconIndexStart=3*this._iconIndexBuffer.index,this._textIndexStart=3*this._textIndexBuffer.index,this._iconIndexCount=0,this._textIndexCount=0,this._markerMap.clear(),this._glyphMap.clear();const B=[];let C=1;T?.size&&(C=T.size/d);const R=T?T.maxAngle*l:0,D=T?T.size*a:0;for(const l of this._symbolFeatures){let e;b&&w&&l.sprite&&(e=w[l.sprite],e&&e.sdf&&(this._isIconSDF=!0));let n;!!e&&b.update(s,l.feature);let g=0;const y=l.label;if(y){t(T),T.update(s,l.feature);const e=h&&T.rotationAlignment===u.MAP?T.keepUpright:T.writingMode&&T.writingMode.includes(p.VERTICAL);let i=.5;switch(T.anchor){case _.TOP_LEFT:case _.LEFT:case _.BOTTOM_LEFT:i=0;break;case _.TOP_RIGHT:case _.RIGHT:case _.BOTTOM_RIGHT:i=1}let o=.5;switch(T.anchor){case _.TOP_LEFT:case _.TOP:case _.TOP_RIGHT:o=0;break;case _.BOTTOM_LEFT:case _.BOTTOM:case _.BOTTOM_RIGHT:o=1}let r=.5;switch(T.justify){case M.AUTO:r=i;break;case M.LEFT:r=0;break;case M.RIGHT:r=1}const x=T.letterSpacing*d,c=h?0:T.maxWidth*d,m=T.lineHeight*d,P=l.textFont.map((e=>V.getGlyphItems(e)));if(n=new f(P,c,m,x,i,o,r).getShaping(y,l.rtl,e),n&&n.length>0){let e=1e30,t=-1e30;for(const i of n)e=Math.min(e,i.x),t=Math.max(t,i.x);g=(t-e+2*d)*C*a}}for(let t of l.geometry){const s=[];if(r===m.LINE){if(n?.length&&T?.size){const e=T.size*a*(2+Math.min(2,4*Math.abs(T.offset[1])));t=L._smoothVertices(t,e)}L._pushAnchors(s,t,x,g)}else r===m.LINE_CENTER?L._pushCenterAnchor(s,t):l.feature.type===i.Polygon?L._pushCentroid(s,t):s.push(new c(t[0].x,t[0].y));for(const i of s){if(i.x<0||i.x>o||i.y<0||i.y>o)continue;if(h&&g>0&&T?.rotationAlignment===u.MAP&&!L._honorsTextMaxAngle(t,i,g,R,D))continue;const s={shaping:n,line:t,iconMosaicItem:e,anchor:i,symbolFeature:l,textColliders:[],iconColliders:[],textVertexRanges:[],iconVertexRanges:[]};B.push(s),this._processFeature(s,b,T)}}}B.sort(A),this._addPlacedGlyphs(),this._symbolInstances=B}serialize(){let e=14;e+=this.layerUIDs.length,e+=3*this.markerPageMap.size,e+=3*this.glyphsPageMap.size,e+=L._symbolsSerializationLength(this._symbolInstances),e+=this._iconVertexBuffer.array.length,e+=this._iconIndexBuffer.array.length,e+=this._textVertexBuffer.array.length,e+=this._textIndexBuffer.array.length;const t=new Uint32Array(e),n=new Int32Array(t.buffer),i=new Float32Array(t.buffer),[s,a,o]=this._sourceTileKey.split("/");let r=0;t[r++]=this.type,t[r++]=this.layerUIDs.length;for(let l=0;l<this.layerUIDs.length;l++)t[r++]=this.layerUIDs[l];t[r++]=this._isIconSDF?1:0,t[r++]=parseFloat(s),t[r++]=parseFloat(a),t[r++]=parseFloat(o),t[r++]=this.markerPageMap.size;for(const[l,[h,x]]of this.markerPageMap)t[r++]=l,t[r++]=h,t[r++]=x;t[r++]=this.glyphsPageMap.size;for(const[l,[h,x]]of this.glyphsPageMap)t[r++]=l,t[r++]=h,t[r++]=x;t[r++]=this._iconVertexBuffer.index/4,t[r++]=this._textVertexBuffer.index/4,r=L.serializeSymbols(t,n,i,r,this._symbolInstances),t[r++]=this._iconVertexBuffer.array.length;for(let l=0;l<this._iconVertexBuffer.array.length;l++)n[r++]=this._iconVertexBuffer.array[l];t[r++]=this._iconIndexBuffer.array.length;for(let l=0;l<this._iconIndexBuffer.array.length;l++)t[r++]=this._iconIndexBuffer.array[l];t[r++]=this._textVertexBuffer.array.length;for(let l=0;l<this._textVertexBuffer.array.length;l++)n[r++]=this._textVertexBuffer.array[l];t[r++]=this._textIndexBuffer.array.length;for(let l=0;l<this._textIndexBuffer.array.length;l++)t[r++]=this._textIndexBuffer.array[l];return t.buffer}static _symbolsSerializationLength(e){let t=0;t+=1;for(const n of e||[]){t+=5,t+=1;for(const e of n.textColliders)t+=b;for(const e of n.iconColliders)t+=b;t+=1,t+=2*n.textVertexRanges.length,t+=1,t+=2*n.iconVertexRanges.length}return t}static serializeSymbols(e,t,n,i,s){s=s||[],t[i++]=s.length;for(const a of s){t[i++]=a.anchor.x,t[i++]=a.anchor.y,t[i++]=a.symbolFeature.hash,t[i++]=a.symbolFeature.priority,t[i++]=a.symbolFeature.feature.featureIndex,t[i++]=a.textColliders.length+a.iconColliders.length;for(const e of a.textColliders)t[i++]=e.xTile,t[i++]=e.yTile,t[i++]=e.dxPixels,t[i++]=e.dyPixels,t[i++]=e.hard?1:0,t[i++]=e.partIndex,n[i++]=e.minLod,n[i++]=e.maxLod,t[i++]=e.width,t[i++]=e.height;for(const e of a.iconColliders)t[i++]=e.xTile,t[i++]=e.yTile,t[i++]=e.dxPixels,t[i++]=e.dyPixels,t[i++]=e.hard?1:0,t[i++]=e.partIndex,n[i++]=e.minLod,n[i++]=e.maxLod,t[i++]=e.width,t[i++]=e.height;t[i++]=a.textVertexRanges.length;for(const[e,n]of a.textVertexRanges)t[i++]=e,t[i++]=n;t[i++]=a.iconVertexRanges.length;for(const[e,n]of a.iconVertexRanges)t[i++]=e,t[i++]=n}return i}_replaceKeys(e,t){return e.replaceAll(/{([^{}]+)}/g,((e,n)=>n in t?t[n]:""))}_processFeature(e,t,n){const{line:i,iconMosaicItem:s,shaping:a,anchor:o}=e,r=this.zoom,l=this.layer,x=!!s;let c=!0;x&&(c=t?.optional||!s);const d=a&&a.length>0,f=!d||n?.optional;let g,y;if(x&&(g=this._placementEngine.getIconPlacement(o,s,t)),(g||c)&&(d&&(y=this._placementEngine.getTextPlacement(o,a,i,n)),y||f)){if(g&&y||(f||c?f||y?c||g||(y=null):g=null:(g=null,y=null)),y){const t=l.hasDataDrivenText?l.textMaterial.encodeAttributes(e.symbolFeature.feature,r,l):null;if(this._storePlacedGlyphs(e,y.shapes,r,n.rotationAlignment,t),y.textColliders){e.textColliders=y.textColliders;for(const e of y.textColliders){e.minLod=Math.max(r+h(e.minLod),0),e.maxLod=Math.min(r+h(e.maxLod),25);const t=e.angle;if(t){const n=Math.cos(t),i=Math.sin(t),s=e.dxPixels*n-e.dyPixels*i,a=e.dxPixels*i+e.dyPixels*n,o=(e.dxPixels+e.width)*n-e.dyPixels*i,r=(e.dxPixels+e.width)*i+e.dyPixels*n,l=e.dxPixels*n-(e.dyPixels+e.height)*i,h=e.dxPixels*i+(e.dyPixels+e.height)*n,x=(e.dxPixels+e.width)*n-(e.dyPixels+e.height)*i,c=(e.dxPixels+e.width)*i+(e.dyPixels+e.height)*n,d=Math.min(s,o,l,x),f=Math.max(s,o,l,x),g=Math.min(a,r,h,c),y=Math.max(a,r,h,c);e.dxPixels=d,e.dyPixels=g,e.width=f-d,e.height=y-g}}}}if(g){const n=l.hasDataDrivenIcon?l.iconMaterial.encodeAttributes(e.symbolFeature.feature,r,l):null;if(this._addPlacedIcons(e,g.shapes,r,s.page,t.rotationAlignment===u.VIEWPORT,n),g.iconColliders){e.iconColliders=g.iconColliders;for(const e of g.iconColliders){e.minLod=Math.max(r+h(e.minLod),0),e.maxLod=Math.min(r+h(e.maxLod),25);const t=e.angle;if(t){const n=Math.cos(t),i=Math.sin(t),s=e.dxPixels*n-e.dyPixels*i,a=e.dxPixels*i+e.dyPixels*n,o=(e.dxPixels+e.width)*n-e.dyPixels*i,r=(e.dxPixels+e.width)*i+e.dyPixels*n,l=e.dxPixels*n-(e.dyPixels+e.height)*i,h=e.dxPixels*i+(e.dyPixels+e.height)*n,x=(e.dxPixels+e.width)*n-(e.dyPixels+e.height)*i,c=(e.dxPixels+e.width)*i+(e.dyPixels+e.height)*n,d=Math.min(s,o,l,x),f=Math.max(s,o,l,x),g=Math.min(a,r,h,c),y=Math.max(a,r,h,c);e.dxPixels=d,e.dyPixels=g,e.width=f-d,e.height=y-g}}}}}}_addPlacedIcons(e,t,n,i,s,a){const o=Math.max(n-1,0),r=this._iconVertexBuffer,l=this._iconIndexBuffer,x=this._markerMap;for(const c of t){const t=s?0:Math.max(n+h(c.minzoom),o),d=s?25:Math.min(n+h(c.maxzoom),25);if(d<=t)continue;const f=c.tl,g=c.tr,y=c.bl,m=c.br,u=c.mosaicRect,p=c.labelAngle,_=c.minAngle,M=c.maxAngle,P=c.anchor,I=r.index,b=u.x,A=u.y,L=b+u.width,T=A+u.height,V=r.index;r.add(P.x,P.y,f.x,f.y,b,A,p,_,M,t,d,a),r.add(P.x,P.y,g.x,g.y,L,A,p,_,M,t,d,a),r.add(P.x,P.y,y.x,y.y,b,T,p,_,M,t,d,a),r.add(P.x,P.y,m.x,m.y,L,T,p,_,M,t,d,a),e.iconVertexRanges.length>0&&e.iconVertexRanges[0][0]+e.iconVertexRanges[0][1]===V?e.iconVertexRanges[0][1]+=4:e.iconVertexRanges.push([V,4]),l.add(I,I+1,I+2),l.add(I+1,I+2,I+3),x.has(i)?x.get(i)[1]+=6:x.set(i,[this._iconIndexStart+this._iconIndexCount,6]),this._iconIndexCount+=6}}_addPlacedGlyphs(){const e=this._textVertexBuffer,t=this._textIndexBuffer,n=this._glyphMap;for(const[i,s]of this._glyphBufferDataStorage)for(const a of s){const s=e.index,o=a.symbolInstance,r=a.ddAttributes,l=e.index;e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.tl[0],a.tl[1],a.xmin,a.ymin,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.tr[0],a.tr[1],a.xmax,a.ymin,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.bl[0],a.bl[1],a.xmin,a.ymax,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),e.add(a.glyphAnchor[0],a.glyphAnchor[1],a.br[0],a.br[1],a.xmax,a.ymax,a.labelAngle,a.minAngle,a.maxAngle,a.minLod,a.maxLod,r),o.textVertexRanges.length>0&&o.textVertexRanges[0][0]+o.textVertexRanges[0][1]===l?o.textVertexRanges[0][1]+=4:o.textVertexRanges.push([l,4]),t.add(s,s+1,s+2),t.add(s+1,s+2,s+3),n.has(i)?n.get(i)[1]+=6:n.set(i,[this._textIndexStart+this._textIndexCount,6]),this._textIndexCount+=6}this._glyphBufferDataStorage.clear()}_storePlacedGlyphs(e,t,n,i,s){const a=Math.max(n-1,0),o=i===u.VIEWPORT;let r,l,x,c,d,f,g,y,m,p,_;for(const u of t){if(r=o?0:Math.max(n+h(u.minzoom),a),l=o?25:Math.min(n+h(u.maxzoom),25),l<=r)continue;x=u.tl,c=u.tr,d=u.bl,f=u.br,g=u.labelAngle,y=u.minAngle,m=u.maxAngle,p=u.anchor,_=u.mosaicRect,this._glyphBufferDataStorage.has(u.page)||this._glyphBufferDataStorage.set(u.page,[]);this._glyphBufferDataStorage.get(u.page).push({glyphAnchor:[p.x,p.y],tl:[x.x,x.y],tr:[c.x,c.y],bl:[d.x,d.y],br:[f.x,f.y],xmin:_.x,ymin:_.y,xmax:_.x+_.width,ymax:_.y+_.height,labelAngle:g,minAngle:y,maxAngle:m,minLod:r,maxLod:l,placementLod:a,symbolInstance:e,ddAttributes:s})}}static _pushAnchors(e,t,n,i){n+=i;let a=0;const o=t.length-1;for(let x=0;x<o;x++)a+=s.distance(t[x],t[x+1]);let r=i||n;if(r*=.5,a<=r)return;const l=r/a;let h=0,d=-(n=a/Math.max(Math.round(a/n),1))/2;const f=t.length-1;for(let s=0;s<f;s++){const i=t[s],a=t[s+1],o=a.x-i.x,r=a.y-i.y,f=Math.sqrt(o*o+r*r);let g;for(;d+n<h+f;){d+=n;const t=(d-h)/f,y=x(i.x,a.x,t),m=x(i.y,a.y,t);void 0===g&&(g=Math.atan2(r,o)),e.push(new c(y,m,g,s,l))}h+=f}}static _pushCenterAnchor(e,t){let n=0;const i=t.length-1;for(let l=0;l<i;l++)n+=s.distance(t[l],t[l+1]);const a=n/2;let o=0;const r=t.length-1;for(let s=0;s<r;s++){const n=t[s],i=t[s+1],r=i.x-n.x,l=i.y-n.y,h=Math.sqrt(r*r+l*l);if(a<o+h){const t=(a-o)/h,d=x(n.x,i.x,t),f=x(n.y,i.y,t),g=Math.atan2(l,r);return void e.push(new c(d,f,g,s,0))}o+=h}}static _deviation(e,t,n){const i=(t.x-e.x)*(n.x-t.x)+(t.y-e.y)*(n.y-t.y),s=(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x);return Math.atan2(s,i)}static _honorsTextMaxAngle(e,t,n,i,a){let o=0;const r=n/2;let l=new s(t.x,t.y),h=t.segment+1;for(;o>-r;){if(--h,h<0)return!1;o-=s.distance(e[h],l),l=e[h]}o+=s.distance(e[h],e[h+1]);const x=[];let c=0;const d=e.length;for(;o<r;){const t=e[h];let n,r=h;do{if(++r,r===d)return!1;n=e[r]}while(n.isEqual(t));let l,f=r;do{if(++f,f===d)return!1;l=e[f]}while(l.isEqual(n));const g=this._deviation(t,n,l);for(x.push({deviation:g,distToAnchor:o}),c+=g;o-x[0].distToAnchor>a;)c-=x.shift().deviation;if(Math.abs(c)>i)return!1;o+=s.distance(n,l),h=r}return!0}static _smoothVertices(e,t){if(t<=0)return e;let n=e.length;if(n<3)return e;const i=[];let a=0,o=0;i.push(0);for(let y=1;y<n;y++){const t=s.distance(e[y],e[y-1]);t>0&&(a+=t,i.push(a),o++,o!==y&&(e[o]=e[y]))}if(n=o+1,n<3)return e;t=Math.min(t,.2*a);const r=e[0].x,l=e[0].y,h=e[n-1].x,x=e[n-1].y,c=s.sub(e[0],e[1]);c.normalize(),e[0].x+=t*c.x,e[0].y+=t*c.y,c.assignSub(e[n-1],e[n-2]),c.normalize(),e[n-1].x+=t*c.x,e[n-1].y+=t*c.y,i[0]-=t,i[n-1]+=t;const d=[];d.push(new s(r,l));const f=1e-6,g=.5*t;for(let y=1;y<n-1;y++){let a=0,o=0,r=0;for(let n=y-1;n>=0;n--){const s=g+i[n+1]-i[y];if(s<0)break;const l=i[n+1]-i[n],h=i[y]-i[n]<g?1:s/l;if(h<f)break;const x=h*h,c=h*s-.5*x*l,d=h*l/t,m=e[n+1],u=e[n].x-m.x,p=e[n].y-m.y;a+=d/c*(m.x*h*s+.5*x*(s*u-l*m.x)-x*h*l*u/3),o+=d/c*(m.y*h*s+.5*x*(s*p-l*m.y)-x*h*l*p/3),r+=d}for(let s=y+1;s<n;s++){const n=g-i[s-1]+i[y];if(n<0)break;const l=i[s]-i[s-1],h=i[s]-i[y]<g?1:n/l;if(h<f)break;const x=h*h,c=h*n-.5*x*l,d=h*l/t,m=e[s-1],u=e[s].x-m.x,p=e[s].y-m.y;a+=d/c*(m.x*h*n+.5*x*(n*u-l*m.x)-x*h*l*u/3),o+=d/c*(m.y*h*n+.5*x*(n*p-l*m.y)-x*h*l*p/3),r+=d}d.push(new s(a/r,o/r))}return d.push(new s(h,x)),e[0].x=r,e[0].y=l,e[n-1].x=h,e[n-1].y=x,d}static _pushCentroid(e,t){const n=0,i=0,s=o,a=o,r=t.length-1;let l=0,h=0,x=0,d=t[0].x,f=t[0].y;d>s&&(d=s),d<n&&(d=n),f>a&&(f=a),f<i&&(f=i);for(let o=1;o<r;o++){let e=t[o].x,r=t[o].y,c=t[o+1].x,g=t[o+1].y;e>s&&(e=s),e<n&&(e=n),r>a&&(r=a),r<i&&(r=i),c>s&&(c=s),c<n&&(c=n),g>a&&(g=a),g<i&&(g=i);const y=(e-d)*(g-f)-(c-d)*(r-f);l+=y*(d+e+c),h+=y*(f+r+g),x+=y}l/=3*x,h/=3*x,isNaN(l)||isNaN(h)||e.push(new c(l,h))}}export{L as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ const o=512,t=4096,c=8,e=.125;export{t as tileCoordSize,e as tileCoordinateScale,c as tilePixelRatio,o as tilePixelSize};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{clone as e}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{collisionGridCellSize as t}from"./config.js";import{GridIndex as s}from"./util.js";import{TranslateAnchor as o,RotationAlignment as r}from"../style/StyleDefinition.js";class i{constructor(o,r,i,n,l,c,h=!0){this._symbols=o,this._styleRepository=n,this._zoom=l,this._useCollisionGroups=h,this._currentLayerCursor=0,this._currentSymbolCursor=0,this._styleProps=new Map,this._allNeededMatrices=new Map,this._symbolGroups=[],this._gridIndex=new s(r,i,t),this._si=Math.sin(Math.PI*c/180),this._co=Math.cos(Math.PI*c/180),n.cachedStyles&&(this._styleProps=n.cachedStyles);for(const t of o)for(const s of t.symbols)this._allNeededMatrices.has(s.tile)||this._allNeededMatrices.set(s.tile,e(s.tile.transforms.tileUnitsToPixels));this._useCollisionGroups&&this._buildSymbolGroups()}work(e){const t=performance.now();if(this._useCollisionGroups)return this._collideByGroups(t,e);for(;this._currentLayerCursor<this._symbols.length;this._currentLayerCursor++,this._currentSymbolCursor=0){const s=this._symbols[this._currentLayerCursor],o=this._getProperties(s.styleLayerUID),r=this._styleRepository.layerContexts?.get(s.styleLayerUID);for(;this._currentSymbolCursor<s.symbols.length;this._currentSymbolCursor++){if(this._currentSymbolCursor%100==99&&performance.now()-t>e)return!1;const i=s.symbols[this._currentSymbolCursor];if(!i.uniqueSymbol?.show)continue;const n=this._computeCoordinates(i,o,r),l=i.uniqueSymbol;if(!l.show)continue;const{iconAllowOverlap:c,textAllowOverlap:h}=o;for(const e of n){if(!e.enabled)continue;const t=l.parts[e.partIndex];if(!t.show)continue;!(e.partIndex?h:c)&&this._doesCollide(e)&&(e.hard?l.show=!1:t.show=!1)}l.show&&this._insertColliders(l.parts,n,o)}}return!0}_buildSymbolGroups(){const e=new Map;for(const t of this._symbols){const s=this._getProperties(t.styleLayerUID),o=this._styleRepository.layerContexts?.get(t.styleLayerUID);if("esriGeometryPoint"===s.geometryType)for(const r of t.symbols){const t=this._computeCoordinates(r,s,o);if(r.featureID){let o=e.get(r.featureID);o||(o=[],e.set(r.featureID,o)),o.push({symbol:r,colliders:t,styleProps:s})}}else for(const e of t.symbols){const t=[{symbol:e,colliders:this._computeCoordinates(e,s,o),styleProps:s}];this._symbolGroups.push(t)}}for(const t of e.values())this._symbolGroups.push(t)}_collideByGroups(e,t){for(;this._currentSymbolCursor<this._symbolGroups.length;this._currentSymbolCursor++){if(this._currentSymbolCursor%100==99&&performance.now()-e>t)return!1;let s=!1;const o=this._symbolGroups[this._currentSymbolCursor];for(const{symbol:e,colliders:t,styleProps:r}of o){if(!e.uniqueSymbol?.show)continue;const o=e.uniqueSymbol;if(!o.show)continue;const{iconAllowOverlap:i,textAllowOverlap:n}=r;for(const e of t){if(!e.enabled)continue;const t=o.parts[e.partIndex];if(!t.show)continue;!(e.partIndex?n:i)&&this._doesCollide(e)&&(e.hard?(s=!0,o.show=!1):(s=!0,t.show=!1))}}if(s)for(const{symbol:e}of o)e.uniqueSymbol.show=!1;else for(const{symbol:e,colliders:t,styleProps:r}of o)this._insertColliders(e.uniqueSymbol.parts,t,r)}return!0}_insertColliders(e,t,s){const{iconIgnorePlacement:o,textIgnorePlacement:r}=s;for(const i of t){if(!i.enabled)continue;if(i.partIndex?r:o)continue;if(!e[i.partIndex].show)continue;const t=i.xScreen+i.dxScreen,s=i.yScreen+i.dyScreen,n=t+i.width,l=s+i.height,[c,h,y,u]=this._gridIndex.getCellSpan(t,s,n,l);for(let e=h;e<=u;e++)for(let t=c;t<=y;t++){this._gridIndex.cells[e][t].push(i)}}}_computeCoordinates(e,t,s){const{iconRotationAlignment:i,textRotationAlignment:n,iconTranslate:l,iconTranslateAnchor:c,textTranslate:h,textTranslateAnchor:y}=t,u=this._si,a=this._co,d=this._zoom,f=this._allNeededMatrices.get(e.tile),m=e.uniqueSymbol,p=e.colliders(s);let _=0;for(const x of p){const[e,t]=0===x.partIndex?l:h,s=0===x.partIndex?c:y,m=x.minLod<=d&&d<=x.maxLod;_+=m?0:1,x.enabled=m,x.xScreen=x.xTile*f[0]+x.yTile*f[3]+f[6],x.yScreen=x.xTile*f[1]+x.yTile*f[4]+f[7],s===o.MAP?(x.xScreen+=a*e-u*t,x.yScreen+=u*e+a*t):(x.xScreen+=e,x.yScreen+=t),r.VIEWPORT===(0===x.partIndex?i:n)?(x.dxScreen=x.dxPixels,x.dyScreen=x.dyPixels):(x.dxScreen=a*(x.dxPixels+x.width/2)-u*(x.dyPixels+x.height/2)-x.width/2,x.dyScreen=u*(x.dxPixels+x.width/2)+a*(x.dyPixels+x.height/2)-x.height/2)}return p.length>0&&_===p.length&&m&&(m.show=!1),p}_getProperties(e){const t=this._styleProps.get(e);if(t)return t;const s=this._styleRepository.getLayerStyleProperties?.(e,this._zoom);return this._styleProps.set(e,s),s}_doesCollide(e){const t=e.xScreen+e.dxScreen,s=e.yScreen+e.dyScreen,o=t+e.width,r=s+e.height,[i,n,l,c]=this._gridIndex.getCellSpan(t,s,o,r);for(let h=n;h<=c;h++)for(let e=i;e<=l;e++){const i=this._gridIndex.cells[h][e];for(const e of i){const i=e.xScreen+e.dxScreen,n=e.yScreen+e.dyScreen,l=i+e.width,c=n+e.height;if(!(o<i||t>l||r<n||s>c))return!0}}return!1}}export{i as CollisionJob};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{fadeDuration as o}from"./config.js";function e(o,e){if(o.priority-e.priority)return o.priority-e.priority;const t=o.tile.key,i=e.tile.key;return t.world-i.world?t.world-i.world:t.level-i.level?t.level-i.level:t.row-i.row?t.row-i.row:t.col-i.col?t.col-i.col:o.xTile-e.xTile?o.xTile-e.xTile:o.yTile-e.yTile}class t{get running(){return this._running}constructor(o,e,t,i,s,n){this._visibleTiles=o,this._symbolRepository=e,this._createCollisionJob=t,this._assignTileSymbolsOpacity=i,this._symbolLayerSorter=s,this._isLayerVisible=n,this._selectionJob=null,this._selectionJobCompleted=!1,this._collisionJob=null,this._collisionJobCompleted=!1,this._opacityJob=null,this._opacityJobCompleted=!1,this._running=!0}setScreenSize(o,e){this._screenWidth===o&&this._screenHeight===e||this.restart(),this._screenWidth=o,this._screenHeight=e}restart(){this._selectionJob=null,this._selectionJobCompleted=!1,this._collisionJob=null,this._collisionJobCompleted=!1,this._opacityJob=null,this._opacityJobCompleted=!1,this._running=!0}continue(o){if(this._selectionJob||(this._selectionJob=this._createSelectionJob()),!this._selectionJobCompleted){const e=performance.now();if(!this._selectionJob.work(o))return!1;if(this._selectionJobCompleted=!0,0===(o=Math.max(0,o-(performance.now()-e))))return!1}if(this._collisionJob||(this._collisionJob=this._createCollisionJob(this._selectionJob.sortedSymbols,this._screenWidth,this._screenHeight)),!this._collisionJobCompleted){const e=performance.now();if(!this._collisionJob.work(o))return!1;if(this._collisionJobCompleted=!0,0===(o=Math.max(0,o-(performance.now()-e))))return!1}if(this._opacityJob||(this._opacityJob=this._createOpacityJob()),!this._opacityJobCompleted){const e=performance.now();if(!this._opacityJob.work(o))return!1;if(this._opacityJobCompleted=!0,0===(o=Math.max(0,o-(performance.now()-e))))return!1}return this._running=!1,!0}_createSelectionJob(){const o=this._symbolRepository.uniqueSymbols;for(let e=0;e<o.length;e++){const t=o[e];for(let o=0;o<t.uniqueSymbols.length;o++){const e=t.uniqueSymbols[o];for(const o of e.tileSymbols)o.selectedForRendering=!1}}const t=[];let i=0,s=0;const n=this._isLayerVisible;function r(r){let l;const c=performance.now();for(;s<o.length;s++,i=0){const e=o[s],h=e.styleLayerUID;if(!n(h)){t[s]||(t[s]={styleLayerUID:h,symbols:[]});continue}t[s]=t[s]||{styleLayerUID:h,symbols:[]};const a=t[s];for(;i<e.uniqueSymbols.length;i++){if(l=e.uniqueSymbols[i],i%100==99&&performance.now()-c>r)return!1;let o=null,t=!1,s=!1;for(const e of l.tileSymbols)if(!s||!t){const i=e.tile;(!o||i.isCoverage||i.neededForCoverage&&!t)&&(o=e,(i.neededForCoverage||i.isCoverage)&&(s=!0),i.isCoverage&&(t=!0))}if(o.selectedForRendering=!0,s){a.symbols.push(o),l.show=!0;for(const o of l.parts)o.show=!0}else l.show=!1}}for(const o of t)o.symbols.sort(e);return!0}const l=this._symbolLayerSorter;return{work:r,get sortedSymbols(){return t.sort(l)}}}_createOpacityJob(){const o=this._assignTileSymbolsOpacity,e=this._visibleTiles;let t=0;function s(e,t){for(const o of e.symbols.values())i(o,t);o(e,t);for(const o of e.childrenTiles)s(o,t)}return{work(o){const i=performance.now();for(;t<e.length;t++){if(performance.now()-i>o)return!1;const n=e[t];if(null!=n.parentTile)continue;s(n,performance.now())}return!0}}}}function i(e,t){for(const i of e){const e=i.unique;for(const i of e.parts){const s=i.targetOpacity>.5?1:-1;i.startOpacity+=s*((t-i.startTime)/o),i.startOpacity=Math.min(Math.max(i.startOpacity,0),1),i.startTime=t,i.targetOpacity=e.show&&i.show?1:0}}}export{t as SymbolDeclutterer};
5
+ import{VectorTile as e}from"../VectorTile.js";import{fadeDuration as t}from"./config.js";import{effectFlag0 as o,filterFlag0 as i}from"../../webgl/definitions.js";function s(e){return(e.uniqueSymbol?.show&&e.uniqueSymbol?.lastShow)??!1}function r(e,t){if(e.priority-t.priority)return e.priority-t.priority;if(s(e)&&!s(t))return-1;if(s(t)&&!s(e))return 1;const o=e.tile.key,i=t.tile.key;return o.world-i.world?o.world-i.world:o.level-i.level?o.level-i.level:o.row-i.row?o.row-i.row:o.col-i.col?o.col-i.col:e.xTile-t.xTile?e.xTile-t.xTile:e.yTile-t.yTile}class n{get running(){return this._running}constructor(e,t,o,i,s,r,n,l){this.selectionMode=e,this._visibleTiles=t,this._symbolRepository=o,this._styleRepository=i,this._createCollisionJob=s,this._assignTileSymbolsOpacity=r,this._symbolLayerSorter=n,this._isLayerVisible=l,this._selectionJob=null,this._selectionJobCompleted=!1,this._collisionJob=null,this._collisionJobCompleted=!1,this._opacityJob=null,this._opacityJobCompleted=!1,this._running=!0}setScreenSize(e,t){this._screenWidth===e&&this._screenHeight===t||this.restart(),this._screenWidth=e,this._screenHeight=t}restart(){this._selectionJob=null,this._selectionJobCompleted=!1,this._collisionJob=null,this._collisionJobCompleted=!1,this._opacityJob=null,this._opacityJobCompleted=!1,this._running=!0}continue(e){if(this._selectionJob||(this._selectionJob=this._createSelectionJob()),!this._selectionJobCompleted){const t=performance.now();if(!this._selectionJob.work(e))return!1;if(this._selectionJobCompleted=!0,0===(e=Math.max(0,e-(performance.now()-t))))return!1}if(this._collisionJob||(this._collisionJob=this._createCollisionJob(this._selectionJob.sortedSymbols,this._screenWidth,this._screenHeight,!0)),!this._collisionJobCompleted){const t=performance.now();if(!this._collisionJob.work(e))return!1;if(this._collisionJobCompleted=!0,0===(e=Math.max(0,e-(performance.now()-t))))return!1}if(this._opacityJob||(this._opacityJob=this._createOpacityJob()),!this._opacityJobCompleted){const t=performance.now();if(!this._opacityJob.work(e))return!1;if(this._opacityJobCompleted=!0,0===(e=Math.max(0,e-(performance.now()-t))))return!1}return this._running=!1,!0}_isFeatureFiltered(e,t,s){const r=t.getFilterFlags(e),n=r&i,l=null==s.featureEffect||s.featureEffect.excludedLabelsVisible||r&o;return!(n&&l)}_getFiltered(){let e;if(this._styleRepository?.layerContexts)for(const t of this._symbolRepository.uniqueSymbols){const o=this._styleRepository.layerContexts?.get(t.styleLayerUID);if(o?.attributeView)for(const i of t.uniqueSymbols){e??=new Set;const t=o.attributeView,s=o.layerView;this._isFeatureFiltered(i.featureID,t,s)&&e.add(i.featureID)}}return e}_resetSelection(){for(let e=0;e<this._symbolRepository.uniqueSymbols.length;e++){const t=this._symbolRepository.uniqueSymbols[e];for(let e=0;e<t.uniqueSymbols.length;e++){const o=t.uniqueSymbols[e];for(const e of o.tileSymbols)e.selectedForRendering=!1}}}_createSelectionJob(){const e="feature-tile"===this.selectionMode?c:a,t=this._symbolRepository.uniqueSymbols;this._resetSelection();const o=[];let i=0,s=0;const n=this._isLayerVisible,l=this._getFiltered(),h=this._styleRepository?.layerContexts;function y(c){let a;const y=performance.now();for(;s<t.length;s++,i=0){const r=t[s],u=r.styleLayerUID;let f=0;if(h){const e=h.get(u).layerView;f=e.view.allLayerViews.items.indexOf(e)}if(!n(u)){o[s]||(o[s]={styleLayerUID:u,layerOrder:f,symbols:[]});continue}o[s]||={styleLayerUID:u,symbols:[],layerOrder:f};const b=o[s];for(;i<r.uniqueSymbols.length;i++){if(a=r.uniqueSymbols[i],i%100==99&&performance.now()-y>c)return!1;if(a.lastShow=a.show,a.featureID&&l?.has(a.featureID)){a.show=!1,a.parts[0].show=!1,a.parts[1].show=!1;continue}const t=e(a);if(t){t.selectedForRendering=!0,b.symbols.push(t),a.show=!0;for(const e of a.parts)e.show=!0}else a.show=!1}}for(const e of o)e.symbols.sort(r);return o.sort(((e,t)=>t.layerOrder-e.layerOrder)),!0}const u=this._symbolLayerSorter;return{work:y,get sortedSymbols(){return o.sort(u)}}}_createOpacityJob(){const t=this._assignTileSymbolsOpacity,o=this._visibleTiles;let i=0;function s(e,o){for(const t of e.symbols.values())l(t,o);t(e,o);for(const t of e.childrenTiles)s(t,o)}return{work(r){const n=performance.now();for(;i<o.length;i++){if(performance.now()-n>r)return!1;const l=o[i];if(null!=l.parentTile)continue;const c=performance.now();l instanceof e?s(l,c):t(l,c)}return!0}}}}function l(e,o){for(const i of e){const e=i.uniqueSymbol;for(const i of e.parts){const s=i.targetOpacity>.5?1:-1;i.startOpacity+=s*((o-i.startTime)/t),i.startOpacity=Math.min(Math.max(i.startOpacity,0),1),i.startTime=o,i.targetOpacity=e.show&&i.show?1:0}}}function c(e){let t=null,o=null,i=null;for(const s of e.tileSymbols){const e=s.tile;e.isReady&&e.isCoverage?t=s:e.isReady?o=s:e.rendering&&(i=s)}return t??o??i}function a(e){let t=null,o=!1,i=!1;for(const s of e.tileSymbols)if(!i||!o){const e=s.tile;(!t||e.isCoverage||e.neededForCoverage&&!o)&&(t=s,(e.neededForCoverage||e.isCoverage)&&(i=!0),e.isCoverage&&(o=!0))}return i?t:null}export{n as SymbolDeclutterer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{signal as t}from"../../../../../core/signal.js";import{declutterBudget as e,fadeDuration as i}from"./config.js";import{VTLUniqueSymbol as s}from"./core.js";import{CollisionJob as o}from"./jobs.js";import{SymbolDeclutterer as r}from"./SymbolDeclutterer.js";import{SymbolRepository as l}from"./SymbolRepository.js";import{writeOpacityToBuffers as a}from"./util.js";import{Visibility as n}from"../style/StyleDefinition.js";const c=.5,h=1e-6;class _{constructor(e,i){this.styleRepository=e,this._tileToHandle=new Map,this._viewState={scale:0,rotation:0,center:[0,0],size:[0,0]},this._declutterViewState={scale:0,rotation:0,center:[0,0],size:[0,0]},this._offsetFromScreenCenter=[0,0],this._completed=!1,this._fading=t(!1),this._symbolRepository=new l(4096,i,(()=>new s)),this._symbolDeclutterer=new r(i,this._symbolRepository,((t,e,i)=>this._createCollisionJob(t,e,i)),((t,e)=>{t.allSymbolsFadingOut=!0,t.lastOpacityUpdate=e,a(t,e,!0),t.decluttered=!0,t.requestRender()}),((t,e)=>this.styleRepository.getStyleLayerByUID(t.styleLayerUID).z-this.styleRepository.getStyleLayerByUID(e.styleLayerUID).z),(t=>{const e=this.styleRepository.getStyleLayerByUID(t);if(this._zoom+h<e.minzoom||this._zoom-h>=e.maxzoom)return!1;const i=e.getLayoutProperty("visibility");return!i||i.getValue()!==n.NONE}))}get symbolRepository(){return this._symbolRepository}_createCollisionJob(t,e,i){return this.updateDecluttererViewState(),new o(t,e,i,this.styleRepository,this._zoom,this._viewState.rotation)}get fading(){return this._fading.value}get decluttererOffset(){return this._offsetFromScreenCenter}addTile(t){t.decluttered=!1,this._tileToHandle.set(t,t.on("symbols-changed",(()=>{this._symbolRepository.add(t),this.restartDeclutter()}))),this._symbolRepository.add(t),this.restartDeclutter()}removeTile(t){const e=this._tileToHandle.get(t);e&&(this._symbolRepository.removeTile(t),this.restartDeclutter(),e.remove(),this._tileToHandle.delete(t))}update(t,e){this._zoom=t,this._viewState={scale:e.scale,rotation:e.rotation,center:[e.center[0],e.center[1]],size:[e.size[0],e.size[1]]};const i=[0,0];e.toScreen(i,e.center);const s=[0,0];return e.toScreen(s,this._declutterViewState.center),this._offsetFromScreenCenter[0]=i[0]-s[0],this._offsetFromScreenCenter[1]=i[1]-s[1],this._continueDeclutter(),this._completed}restartDeclutter(){this._completed=!1,this._symbolDeclutterer.restart(),this._notifyUnstable()}clear(){this._completed=!1,this._symbolRepository=null,this._symbolDeclutterer.restart(),this._tileToHandle.forEach((t=>t.remove())),this._tileToHandle.clear()}get stale(){return this._zoom!==this._declutterZoom||this._viewState.size[0]!==this._declutterViewState.size[0]||this._viewState.size[1]!==this._declutterViewState.size[1]||this._viewState.scale!==this._declutterViewState.scale||this._viewState.rotation!==this._declutterViewState.rotation}deleteStyleLayers(t){this._symbolRepository.deleteStyleLayers(t)}_continueDeclutter(){this._completed&&!this.stale||(this._symbolDeclutterer.running||(this.updateDecluttererViewState(),this._symbolDeclutterer.restart()),this._symbolDeclutterer.setScreenSize(this._viewState.size[0],this._viewState.size[1]),this._completed=this._symbolDeclutterer.continue(e),this._completed&&this._scheduleNotifyStable())}_scheduleNotifyStable(){null!=this._stableNotificationHandle&&clearTimeout(this._stableNotificationHandle),this._stableNotificationHandle=setTimeout((()=>{this._stableNotificationHandle=null,this._fading.value=!1}),(1+c)*i)}_notifyUnstable(){null!=this._stableNotificationHandle&&(clearTimeout(this._stableNotificationHandle),this._stableNotificationHandle=null),this._fading.value=!0}updateDecluttererViewState(){this._declutterZoom=this._zoom,this._declutterViewState.center[0]=this._viewState.center[0],this._declutterViewState.center[1]=this._viewState.center[1],this._declutterViewState.rotation=this._viewState.rotation,this._declutterViewState.scale=this._viewState.scale,this._declutterViewState.size[0]=this._viewState.size[0],this._declutterViewState.size[1]=this._viewState.size[1],this._offsetFromScreenCenter[0]=0,this._offsetFromScreenCenter[1]=0}}export{_ as SymbolFader};
5
+ import{signal as t}from"../../../../../core/signal.js";import{CollisionJob as e}from"./CollisionJob.js";import{declutterBudget as i,fadeDuration as s}from"./config.js";import{SymbolDeclutterer as r}from"./SymbolDeclutterer.js";import{SymbolRepository as o}from"./SymbolRepository.js";import{Visibility as l}from"../style/StyleDefinition.js";const a=.5,n=1e-6;class c{constructor(e,s,a,c,h,y=i){this.styleRepository=s,this._declutterBudget=y,this._tileToHandle=new Map,this._viewState={scale:0,rotation:0,center:[0,0],size:[0,0]},this._declutterViewState={scale:0,rotation:0,center:[0,0],size:[0,0]},this._offsetFromScreenCenter=[0,0],this._completed=!1,this._fading=t(!1);const _=(t,e,i,s)=>this._createCollisionJob(t,e,i,s),u=t=>{const e=this.styleRepository.getStyleLayerByUID?.(t);if(e){if(this._zoom+n<e.minzoom||this._zoom-n>=e.maxzoom)return!1;const t=e.getLayoutProperty?.("visibility");if(t&&t.getValue()===l.NONE)return!1}return!0},m=(t,e)=>(this.styleRepository.getStyleLayerByUID?.(t.styleLayerUID)?.z??0)-(this.styleRepository.getStyleLayerByUID?.(e.styleLayerUID)?.z??0);this._symbolRepository=new o(h,c),this._symbolDeclutterer=new r(e,c,this._symbolRepository,this.styleRepository,_,a,m,u)}get symbolRepository(){return this._symbolRepository}_createCollisionJob(t,i,s,r){return this.updateDecluttererViewState(),new e(t,i,s,this.styleRepository,this._zoom,this._viewState.rotation,r)}get fading(){return this._fading.value}get decluttererOffset(){return this._offsetFromScreenCenter}registerFeatureTile(t){this.symbolRepository?(this.symbolRepository.registerFeatureTile(t),this.restartDeclutter()):console.error("InternalError: Symbol repository not yet initialized")}unregisterFeatureTile(t){this.symbolRepository?(this._symbolRepository.unregisterFeatureTile(t),this.restartDeclutter()):console.error("InternalError: Symbol repository not yet initialized")}insertFeatureTileMetrics(t,e){this.symbolRepository?(this.symbolRepository.insertFeatureTileMetrics(t,e),this.restartDeclutter()):console.error("InternalError: Symbol repository not yet initialized")}removeFeatureTileMetrics(t,e){this.symbolRepository?(this.symbolRepository.removeFeatureTileMetrics(t,e),this.restartDeclutter()):console.error("InternalError: Symbol repository not yet initialized")}addTile(t){t.decluttered=!1,this._tileToHandle.set(t,t.on("symbols-changed",(()=>{this._symbolRepository.registerVectorTile(t),this.restartDeclutter()}))),this._symbolRepository.registerVectorTile(t),this.restartDeclutter()}removeTile(t){const e=this._tileToHandle.get(t);e&&(this._symbolRepository.unregisterVectorTile(t),this.restartDeclutter(),e.remove(),this._tileToHandle.delete(t))}update(t,e){this._zoom=t,this._viewState={scale:e.scale,rotation:e.rotation,center:[e.center[0],e.center[1]],size:[e.size[0],e.size[1]]};const i=[0,0];e.toScreen(i,e.center);const s=[0,0];return e.toScreen(s,this._declutterViewState.center),this._offsetFromScreenCenter[0]=i[0]-s[0],this._offsetFromScreenCenter[1]=i[1]-s[1],this._continueDeclutter(),this._completed}restartDeclutter(){this._completed=!1,this._symbolDeclutterer.restart(),this._notifyUnstable()}clear(){this._completed=!1,this._symbolRepository=null,this._symbolDeclutterer.restart(),this._tileToHandle.forEach((t=>t.remove())),this._tileToHandle.clear()}get stale(){return this._zoom!==this._declutterZoom||this._viewState.size[0]!==this._declutterViewState.size[0]||this._viewState.size[1]!==this._declutterViewState.size[1]||this._viewState.scale!==this._declutterViewState.scale||this._viewState.rotation!==this._declutterViewState.rotation}deleteStyleLayers(t){this._symbolRepository.deleteStyleLayers(t)}_continueDeclutter(){this._completed&&!this.stale||(this._symbolDeclutterer.running||(this.updateDecluttererViewState(),this._symbolDeclutterer.restart()),this._symbolDeclutterer.setScreenSize(this._viewState.size[0],this._viewState.size[1]),this._completed=this._symbolDeclutterer.continue(this._declutterBudget),this._completed&&this._scheduleNotifyStable())}_scheduleNotifyStable(){null!=this._stableNotificationHandle&&clearTimeout(this._stableNotificationHandle),this._stableNotificationHandle=setTimeout((()=>{this._stableNotificationHandle=null,this._fading.value=!1}),(1+a)*s)}_notifyUnstable(){null!=this._stableNotificationHandle&&(clearTimeout(this._stableNotificationHandle),this._stableNotificationHandle=null),this._fading.value=!0}updateDecluttererViewState(){this._declutterZoom=this._zoom,this._declutterViewState.center[0]=this._viewState.center[0],this._declutterViewState.center[1]=this._viewState.center[1],this._declutterViewState.rotation=this._viewState.rotation,this._declutterViewState.scale=this._viewState.scale,this._declutterViewState.size[0]=this._viewState.size[0],this._declutterViewState.size[1]=this._viewState.size[1],this._offsetFromScreenCenter[0]=0,this._offsetFromScreenCenter[1]=0}}export{c as SymbolFader};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{GridIndex as e,isSearchCircleOverlapingSymbol as s,tileCoordChange as l}from"./util.js";const o=32,t=8,i=64,n=20;class r{constructor(e,s,l){this.tileCoordRange=e,this._visibleTiles=s,this._createUnique=l,this._tiles=new Map,this._uniqueSymbolsReferences=new Map}get uniqueSymbols(){return null==this._uniqueSymbolLayerArray&&(this._uniqueSymbolLayerArray=this._createUniqueSymbolLayerArray()),this._uniqueSymbolLayerArray}get uniqueSymbolsReferences(){return this._uniqueSymbolsReferences}add(s,l){this._uniqueSymbolLayerArray=null;let n=this._tiles.get(s.id);n||(n={symbols:new Map},this._tiles.set(s.id,n));const r=new Map;if(l)for(const e of l)n.symbols.has(e)&&(r.set(e,n.symbols.get(e)),n.symbols.delete(e));else for(const[e,o]of s.layerData)n.symbols.has(e)&&(r.set(e,n.symbols.get(e)),n.symbols.delete(e));this._removeSymbols(r);const y=s.symbols,a=new Map;for(const[f,u]of y){let s=u.length;if(s>=o){let l=this.tileCoordRange;do{l/=2,s/=4}while(s>t&&l>i);const o=new e(this.tileCoordRange,this.tileCoordRange,l);a.set(f,{flat:u,index:o}),n.symbols.set(f,{flat:u,index:o});for(const e of u)o.getCell(e.xTile,e.yTile).push(e)}else a.set(f,{flat:u}),n.symbols.set(f,{flat:u})}this._addSymbols(s.key,y)}deleteStyleLayers(e){this._uniqueSymbolLayerArray=null;for(const[s,l]of this._tiles){const o=new Map;for(const s of e)l.symbols.has(s)&&(o.set(s,l.symbols.get(s)),l.symbols.delete(s));this._removeSymbols(o),0===l.symbols.size&&this._tiles.delete(s)}}removeTile(e){this._uniqueSymbolLayerArray=null;const s=this._tiles.get(e.id);if(!s)return;const l=new Map;for(const[o,t]of e.symbols)s.symbols.has(o)&&(l.set(o,s.symbols.get(o)),s.symbols.delete(o));this._removeSymbols(l),0===s.symbols.size&&this._tiles.delete(e.id)}querySymbols(e,l,o,t){const i=[],n=this.uniqueSymbols;for(const r of n){const t=r.styleLayerUID,n=r.uniqueSymbols;for(const r of n){const n=r.tileSymbols.find((e=>e.selectedForRendering));n&&s(n,e,l*(window.devicePixelRatio||1),o)&&i.push({vtlSymbol:n,styleLayerUID:t,tileKey:n.tile.key})}}return i}_removeSymbols(e){for(const[s,{flat:l}]of e)for(const e of l){const l=e.unique,o=l.tileSymbols,t=o.length-1;for(let s=0;s<t;s++)if(o[s]===e){o[s]=o[t];break}if(o.length=t,0===t){const e=this._uniqueSymbolsReferences.get(s);e.delete(l),0===e.size&&this._uniqueSymbolsReferences.delete(s)}e.unique=null}}_addSymbols(e,s){if(0===s.size)return;const l=this._visibleTiles;for(const o of l)o.parentTile||o.key.world!==e.world||o.key.level===e.level&&!o.key.equals(e)||this._matchSymbols(o,e,s);for(const[o,t]of s)for(const e of t)if(null==e.unique){const s=this._createUnique();e.unique=s,s.tileSymbols.push(e);let l=this._uniqueSymbolsReferences.get(o);l||(l=new Set,this._uniqueSymbolsReferences.set(o,l)),l.add(s)}}_matchSymbols(e,s,o){if(e.key.level>s.level){const l=e.key.level-s.level;if(e.key.row>>l!==s.row||e.key.col>>l!==s.col)return}if(s.level>e.key.level){const l=s.level-e.key.level;if(s.row>>l!==e.key.row||s.col>>l!==e.key.col)return}if(s.equals(e.key)){for(const l of e.childrenTiles)this._matchSymbols(l,s,o);return}const t=new Map;for(const[i,r]of o){const o=[];for(const t of r){const i=l(this.tileCoordRange,t.xTile,s.level,s.col,e.key.level,e.key.col),n=l(this.tileCoordRange,t.yTile,s.level,s.row,e.key.level,e.key.row);i>=0&&i<this.tileCoordRange&&n>=0&&n<this.tileCoordRange&&o.push({symbol:t,xTransformed:i,yTransformed:n})}const y=[],a=(e.key.level<s.level?1:1<<e.key.level-s.level)+n,f=this._tiles.get(e.id).symbols.get(i);if(f){const e=f.flat;for(const s of o){let l,o=!1;const t=s.xTransformed,i=s.yTransformed;l=null!=f.index?f.index.getCell(t,i):e;const n=s.symbol,r=n.hash;for(const e of l)if(r===e.hash&&Math.abs(t-e.xTile)<=a&&Math.abs(i-e.yTile)<=a){const s=e.unique;n.unique=s,s.tileSymbols.push(n),o=!0;break}o||y.push(n)}}y.length>0&&t.set(i,y)}for(const l of e.childrenTiles)this._matchSymbols(l,s,t)}_createUniqueSymbolLayerArray(){const e=this._uniqueSymbolsReferences,s=new Array(e.size);let l,o=0;for(const[t,i]of e){const e=new Array(i.size);l=0;for(const s of i)e[l++]=s;s[o]={styleLayerUID:t,uniqueSymbols:e},o++}return s}}export{r as SymbolRepository};
5
+ import{UniqueSymbol as e}from"./core.js";import{isSearchCircleOverlapingSymbol as t,tileCoordChangeX as s,tileCoordChangeY as i,GridIndex as l}from"./util.js";class o{static fromSymbols(e,t){let s=e.length;if(s>=n){let i=t;do{i/=2,s/=4}while(s>r&&i>y);const n=new l(t,t,i);for(const t of e)n.getCell(t.xTile,t.yTile).push(t);return new o(t,e,n)}return new o(t,e,null)}constructor(e,t,s){this.tileCoordRange=e,this._symbols=t,this._index=s}addSymbols(e){for(const t of e)this._symbols.push(t);if(this._index)for(const t of e)this._index.getCell(t.xTile,t.yTile).push(t)}removeSymbols(e){const t=new Set(e);if(this._symbols=this._symbols.filter((e=>!t.has(e))),this._index)for(const s of this._index.cells)for(let e=0;e<s.length;e++)s[e]=s[e].filter((e=>!t.has(e)))}getSymbols(){return this._symbols}getCandidate(e,t,s,i){if(!this._index){for(const l of this._symbols)if(s===l.hash&&Math.abs(e-l.xTile)<=i&&Math.abs(t-l.yTile)<=i)return l;return null}const l=this._index.getCellSpan(e-i,t-i,e+i,t+i),[o,n,r,y]=l;for(let a=n;a<=y;a++)for(let l=o;l<=r;l++){const o=this._index.cells[a][l];for(const l of o)if(s===l.hash&&Math.abs(e-l.xTile)<=i&&Math.abs(t-l.yTile)<=i)return l}return null}}const n=32,r=8,y=64,a=20;class u{constructor(e,t){this.tileCoordRange=e,this._visibleTiles=t,this._indexMapByTile=new Map,this._uniqueSymbolsByStyleLayerId=new Map}get uniqueSymbols(){return null==this._uniqueSymbolLayerArray&&(this._uniqueSymbolLayerArray=this._createUniqueSymbolLayerArray()),this._uniqueSymbolLayerArray}registerVectorTile(e,t){const s=this._ensureIndexMap(e),i=t?.values()??s.keys();for(const l of i){const e=s.get(l);e&&(this._removeSymbols(l,e.getSymbols()),s.delete(l))}this._addSymbols(e.key,s,e.symbols),this._invalidate()}unregisterVectorTile(e){this._removeTile(e),this._invalidate()}registerFeatureTile(e){this._ensureIndexMap(e),this._invalidate()}unregisterFeatureTile(e){this._removeTile(e),this._invalidate()}insertFeatureTileMetrics(e,t){const s=this._indexMapByTile.get(e);if(!s)throw new Error(`tile ${e.id} not registered!`);this._addSymbols(e.key,s,h(t)),this._invalidate()}removeFeatureTileMetrics(e,t){const s=this._indexMapByTile.get(e);if(!s)return;const i=h(t);for(const[l,o]of s.entries()){const e=i.get(l);e&&(o.removeSymbols(e),this._removeSymbols(l,e))}this._invalidate()}deleteStyleLayers(e){for(const t of this._indexMapByTile.values())for(const s of e){const e=t.get(s);e&&(this._removeSymbols(s,e.getSymbols()),t.delete(s))}this._invalidate()}querySymbols(e,s,i,l){const o=[];for(const[n,r]of this._uniqueSymbolsByStyleLayerId.entries())for(const l of r){const r=l.tileSymbols.find((e=>e.selectedForRendering));r&&t(r,e,s*(window.devicePixelRatio||1),i)&&o.push({vtlSymbol:r,styleLayerUID:n,tileKey:r.tile.key})}return o}_ensureIndexMap(e){let t=this._indexMapByTile.get(e);return t||(t=new Map,this._indexMapByTile.set(e,t)),t}_invalidate(){this._uniqueSymbolLayerArray=null}_addSymbols(e,t,s){for(const[i,l]of s){let e=t.get(i);e?e.addSymbols(l):(e=o.fromSymbols(l,this.tileCoordRange),t.set(i,e))}this._updateUniqueSymbols(e,s)}_removeTile(e){const t=this._indexMapByTile.get(e);if(t){for(const[e,s]of t.entries())this._removeSymbols(e,s.getSymbols());this._indexMapByTile.delete(e),this._invalidate()}}_removeSymbols(e,t){for(const s of t){const t=s.uniqueSymbol;if(t){if(t.tileSymbols=t.tileSymbols.filter((e=>e!==s)),0===t.tileSymbols.length){const s=this._uniqueSymbolsByStyleLayerId.get(e);s.delete(t),0===s.size&&this._uniqueSymbolsByStyleLayerId.delete(e)}s.uniqueSymbol=null}}}_updateUniqueSymbols(t,s){if(0!==s.size){for(const e of this._visibleTiles)e.parentTile||e.key.world!==t.world||e.key.level===t.level&&!e.key.equals(t)||this._matchSymbols(e,t,s);for(const[t,i]of s)for(const s of i)if(!s.uniqueSymbol){s.uniqueSymbol=new e(s);let i=this._uniqueSymbolsByStyleLayerId.get(t);i||(i=new Set,this._uniqueSymbolsByStyleLayerId.set(t,i)),i.add(s.uniqueSymbol)}}}_matchSymbols(e,t,l){if(e.key.level>t.level){const s=e.key.level-t.level;if(e.key.row>>s!==t.row||e.key.col>>s!==t.col)return}if(t.level>e.key.level){const s=t.level-e.key.level;if(t.row>>s!==e.key.row||t.col>>s!==e.key.col)return}const o=new Map;for(const[n,r]of l){const l=[],y=(e.key.level<t.level?1:1<<e.key.level-t.level)+a,u=this._indexMapByTile.get(e),h=u?.get(n);if(h)for(const o of r){if(o.uniqueSymbol)continue;const n=s(this.tileCoordRange,o.xTile,t,e.key),r=i(this.tileCoordRange,o.yTile,t,e.key),u=-20,c=this.tileCoordRange+a;if(!(n>=u&&n<c&&r>=u&&r<c)){l.push(o);continue}const f=h.getCandidate(n,r,o.hash,y),m=f?.uniqueSymbol;m?(o.uniqueSymbol=m,m.tileSymbols.push(o)):l.push(o)}l.length>0&&o.set(n,l)}for(const s of e.childrenTiles||[])this._matchSymbols(s,t,o)}_createUniqueSymbolLayerArray(){const e=this._uniqueSymbolsByStyleLayerId,t=new Array(e.size);let s,i=0;for(const[l,o]of e){const e=new Array(o.size);s=0;for(const t of o)e[s++]=t;t[i]={styleLayerUID:l,uniqueSymbols:e},i++}return t}}function h(e){const t=new Map;for(const s of e){const e=s.labelClassId;let i=t.get(e);i||(i=[],t.set(e,i)),i.push(s)}return t}export{u as SymbolRepository};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t,s){this.sourceTile=s,this.xTile=0,this.yTile=0,this.hash=0,this.priority=1,this.featureIndex=0,this.colliders=[],this.textVertexRanges=[],this.iconVertexRanges=[],this.tile=t}}class s{constructor(){this.tileSymbols=[],this.parts=[{startTime:0,startOpacity:0,targetOpacity:0,show:!1},{startTime:0,startOpacity:0,targetOpacity:0,show:!1}],this.show=!1}}export{t as VTLSymbol,s as VTLUniqueSymbol};
5
+ class t{constructor(t,s){this.sourceTile=s,this.xTile=0,this.yTile=0,this.hash=0,this.priority=1,this.featureIndex=0,this.uniqueSymbol=null,this._colliders=[],this.textVertexRanges=[],this.iconVertexRanges=[],this.tile=t}colliders(){return this._colliders}}class s{constructor(t){this.parts=[{startTime:0,startOpacity:0,targetOpacity:0,show:!1},{startTime:0,startOpacity:0,targetOpacity:0,show:!1}],this.show=!1,this.lastShow=!1,this.tileSymbols=[t],this.featureID=t.featureID}}export{s as UniqueSymbol,t as VTLSymbol};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{identity as t,translate as o,rotate as e,scale as r}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{toRadian as i}from"../../../../../core/libs/gl-matrix-2/math/common.js";import{VTLUniqueSymbol as m}from"./core.js";import{CollisionJob as l}from"./jobs.js";import{SymbolDeclutterer as n}from"./SymbolDeclutterer.js";import{SymbolRepository as a}from"./SymbolRepository.js";import{writeOpacityToBuffers as c}from"./util.js";import{Visibility as f}from"../style/StyleDefinition.js";function y(s,y){const j=s.transforms.tileUnitsToPixels,b=i(y),h=Math.cos(b),u=Math.sin(b),x=Math.ceil(512*(Math.abs(u)+Math.abs(h)));t(p),o(p,p,[x/2,x/2]),e(p,p,b),o(p,p,[-256,-256]),r(p,p,[1/8,1/8,1]),s.transforms.tileUnitsToPixels=p;const g=[],S=new a(4096,g,(()=>new m)),M=new n(g,S,((t,o,e)=>new l(t,o,e,s.styleRepository,s.key.level,y)),((t,o)=>{c(t,o,!1)}),(()=>0),(t=>{const o=s.styleRepository.getStyleLayerByUID(t).getLayoutProperty("visibility");return!o||o.getValue()!==f.NONE}));g.push(s),S.add(s),M.setScreenSize(x,x),M.continue(1/0),S.removeTile(s),s.transforms.tileUnitsToPixels=j}const p=s();export{y as declutterSingleTile};
5
+ import{identity as t,translate as o,rotate as e,scale as r}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{toRadian as s}from"../../../../../core/libs/gl-matrix-2/math/common.js";import{tileCoordSize as l}from"../constants.js";import{CollisionJob as m}from"./CollisionJob.js";import{SymbolDeclutterer as n}from"./SymbolDeclutterer.js";import{SymbolRepository as a}from"./SymbolRepository.js";import{writeOpacityToBuffers as c}from"./util.js";import{Visibility as f}from"../style/StyleDefinition.js";function y(i,y){const u=i.transforms.tileUnitsToPixels,b=s(y),j=Math.cos(b),g=Math.sin(b),h=Math.ceil(512*(Math.abs(g)+Math.abs(j)));t(p),o(p,p,[h/2,h/2]),e(p,p,b),o(p,p,[-256,-256]),r(p,p,[1/8,1/8,1]),i.transforms.tileUnitsToPixels=p;const x=[],S=new a(l,x),M=new n("vector-tile",x,S,null,((t,o,e)=>new m(t,o,e,i.styleRepository,i.key.level,y)),((t,o)=>{c(t,o,!1)}),(()=>0),(t=>{const o=i.styleRepository.getStyleLayerByUID(t).getLayoutProperty("visibility");return!o||o.getValue()!==f.NONE}));x.push(i),S.registerVectorTile(i),M.setScreenSize(h,h),M.continue(1/0),S.unregisterVectorTile(i),i.transforms.tileUnitsToPixels=u}const p=i();export{y as declutterSingleTile};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{BucketType as t}from"../enums.js";import{isCircleOverlapingRect as e}from"../GeometryUtils.js";import{VTLSymbol as s}from"./core.js";function o(t,e,s,o,i,l){const r=s-i;if(r>=0)return(e>>r)+(o-(l<<r))*(t>>r);const n=-r;return e-(l-(o<<n))*(t>>n)<<n}class i{constructor(t,e,s){this._rows=Math.ceil(e/s),this._columns=Math.ceil(t/s),this._cellSize=s,this.cells=new Array(this._rows);for(let o=0;o<this._rows;o++){this.cells[o]=new Array(this._columns);for(let t=0;t<this._columns;t++)this.cells[o][t]=[]}}getCell(t,e){const s=Math.min(Math.max(Math.floor(e/this._cellSize),0),this._rows-1),o=Math.min(Math.max(Math.floor(t/this._cellSize),0),this._columns-1);return this.cells[s]&&this.cells[s][o]||null}getCellSpan(t,e,s,o){return[Math.min(Math.max(Math.floor(t/this._cellSize),0),this.columns-1),Math.min(Math.max(Math.floor(e/this._cellSize),0),this.rows-1),Math.min(Math.max(Math.floor(s/this._cellSize),0),this.columns-1),Math.min(Math.max(Math.floor(o/this._cellSize),0),this.rows-1)]}get cellSize(){return this._cellSize}get columns(){return this._columns}get rows(){return this._rows}}function l(t,e,o,i,l,r,n){const c=e[i++];for(let a=0;a<c;a++){const c=new s(r,n);c.xTile=e[i++],c.yTile=e[i++],c.hash=e[i++],c.priority=e[i++],c.featureIndex=e[i++];const a=e[i++];for(let t=0;t<a;t++){const t=e[i++],s=e[i++],l=e[i++],r=e[i++],n=!!e[i++],a=e[i++],h=o[i++],u=o[i++],f=e[i++],m=e[i++];c.colliders.push({xTile:t,yTile:s,dxPixels:l,dyPixels:r,hard:n,partIndex:a,width:f,height:m,minLod:h,maxLod:u})}const h=t[i++];for(let e=0;e<h;e++)c.textVertexRanges.push([t[i++],t[i++]]);const u=t[i++];for(let e=0;e<u;e++)c.iconVertexRanges.push([t[i++],t[i++]]);l.push(c)}return i}function r(t,e,s){for(const[o,i]of t.symbols)n(t,e,s,i,o)}function n(e,s,o,i,l){const r=e.layerData.get(l);if(r.type===t.SYMBOL){for(const t of i){const s=t.unique;let i;if(t.selectedForRendering){const t=s.parts[0],l=t.startOpacity,r=t.targetOpacity;e.allSymbolsFadingOut=e.allSymbolsFadingOut&&0===r;const n=o?Math.floor(127*l)|r<<7:r?255:0;i=n<<24|n<<16|n<<8|n}else i=0;for(const[e,o]of t.iconVertexRanges)for(let t=e;t<e+o;t+=4)r.iconOpacity[t/4]=i;if(t.selectedForRendering){const t=s.parts[1],l=t.startOpacity,r=t.targetOpacity;e.allSymbolsFadingOut=e.allSymbolsFadingOut&&0===r;const n=o?Math.floor(127*l)|r<<7:r?255:0;i=n<<24|n<<16|n<<8|n}else i=0;for(const[e,o]of t.textVertexRanges)for(let t=e;t<e+o;t+=4)r.textOpacity[t/4]=i}r.lastOpacityUpdate=s,r.opacityChanged=!0}}function c(t,s,o,i){const l=t.colliders;let r,n,c,a;for(const h of l){if(t.unique.show&&t.unique.parts[h.partIndex].show&&(r=h.xScreen-i[0]+h.dxScreen,n=h.yScreen-i[1]+h.dyScreen,c=r+h.width,a=n+h.height,e(o,s.x,s.y,r,n,c,a)))return!0}return!1}export{i as GridIndex,l as deserializeSymbols,c as isSearchCircleOverlapingSymbol,o as tileCoordChange,r as writeOpacityToBuffers};
5
+ import{BucketType as t}from"../enums.js";import{isCircleOverlapingRect as e}from"../GeometryUtils.js";import{VTLSymbol as o}from"./core.js";function s(t,e,o,s){return r(t,e,o.level,o.col,s.key.level,s.key.col)}function l(t,e,o,s){return r(t,e,o.level,o.row,s.level,s.row)}function r(t,e,o,s,l,r){const i=o-l;if(i>=0)return(e>>i)+(s-(r<<i))*(t>>i);const n=-i;return e-(r-(s<<n))*(t>>n)<<n}class i{constructor(t,e,o){this._rows=Math.ceil(e/o),this._columns=Math.ceil(t/o),this._cellSize=o,this.cells=new Array(this._rows);for(let s=0;s<this._rows;s++){this.cells[s]=new Array(this._columns);for(let t=0;t<this._columns;t++)this.cells[s][t]=[]}}getCell(t,e){const o=Math.min(Math.max(Math.floor(e/this._cellSize),0),this._rows-1),s=Math.min(Math.max(Math.floor(t/this._cellSize),0),this._columns-1);return this.cells[o]&&this.cells[o][s]||null}getCellSpan(t,e,o,s){return[Math.min(Math.max(Math.floor(t/this._cellSize),0),this.columns-1),Math.min(Math.max(Math.floor(e/this._cellSize),0),this.rows-1),Math.min(Math.max(Math.floor(o/this._cellSize),0),this.columns-1),Math.min(Math.max(Math.floor(s/this._cellSize),0),this.rows-1)]}get cellSize(){return this._cellSize}get columns(){return this._columns}get rows(){return this._rows}}function n(t,e,s,l,r,i,n){const c=e[l++];for(let a=0;a<c;a++){const c=new o(i,n);c.xTile=e[l++],c.yTile=e[l++],c.hash=e[l++],c.priority=e[l++],c.featureIndex=e[l++];const a=e[l++],h=c.colliders();for(let t=0;t<a;t++){const t=e[l++],o=e[l++],r=e[l++],i=e[l++],n=!!e[l++],c=e[l++],a=s[l++],u=s[l++],f=e[l++],m=e[l++];h.push({xTile:t,yTile:o,dxPixels:r,dyPixels:i,hard:n,partIndex:c,width:f,height:m,minLod:a,maxLod:u})}const u=t[l++];for(let e=0;e<u;e++)c.textVertexRanges.push([t[l++],t[l++]]);const f=t[l++];for(let e=0;e<f;e++)c.iconVertexRanges.push([t[l++],t[l++]]);r.push(c)}return l}function c(t,e,o){for(const[s,l]of t.symbols)a(t,e,o,l,s)}function a(e,o,s,l,r){const i=e.layerData.get(r);if(i.type===t.SYMBOL){for(const t of l){const o=t.uniqueSymbol;let l;if(t.selectedForRendering){const t=o.parts[0],r=t.startOpacity,i=t.targetOpacity;e.allSymbolsFadingOut=e.allSymbolsFadingOut&&0===i;const n=s?Math.floor(127*r)|i<<7:i?255:0;l=n<<24|n<<16|n<<8|n}else l=0;for(const[e,s]of t.iconVertexRanges)for(let t=e;t<e+s;t+=4)i.iconOpacity[t/4]=l;if(t.selectedForRendering){const t=o.parts[1],r=t.startOpacity,i=t.targetOpacity;e.allSymbolsFadingOut=e.allSymbolsFadingOut&&0===i;const n=s?Math.floor(127*r)|i<<7:i?255:0;l=n<<24|n<<16|n<<8|n}else l=0;for(const[e,s]of t.textVertexRanges)for(let t=e;t<e+s;t+=4)i.textOpacity[t/4]=l}i.lastOpacityUpdate=o,i.opacityChanged=!0}}function h(t,o,s,l){const r=t.colliders();let i,n,c,a;for(const h of r){if(t.uniqueSymbol?.show&&t.uniqueSymbol.parts[h.partIndex].show&&(i=h.xScreen-l[0]+h.dxScreen,n=h.yScreen-l[1]+h.dyScreen,c=i+h.width,a=n+h.height,e(s,o.x,o.y,i,n,c,a)))return!0}return!1}export{i as GridIndex,n as deserializeSymbols,h as isSearchCircleOverlapingSymbol,s as tileCoordChangeX,l as tileCoordChangeY,c as writeOpacityToBuffers};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{fromValues as t}from"../../../../../geometry/support/aaBoundingRect.js";import{ShaderProgramType as i}from"../enums.js";import{translateAnchor as e,pointInPolygon as a,distanceFromToPolylineWithinThreshold as o,offsetLine as r}from"../GeometryUtils.js";import{VTLBackgroundMaterial as n}from"../shaders/VTLBackgroundMaterial.js";import{VTLCircleMaterial as s}from"../shaders/VTLCircleMaterial.js";import{VTLFillMaterial as l,VTLOutlineMaterial as h}from"../shaders/VTLFillMaterial.js";import{VTLLineMaterial as u}from"../shaders/VTLLineMaterial.js";import{VTLIconMaterial as p,VTLTextMaterial as g}from"../shaders/VTLSymbolMaterial.js";import c from"./Filter.js";import{StyleLayerType as y,StyleDefinition as P,RotationAlignment as f}from"./StyleDefinition.js";import D from"./StyleProperty.js";import{thinLineHalfWidthThreshold as m}from"../../webgl/definitions.js";const d=8;var _;!function(t){t[t.BUTT=0]="BUTT",t[t.ROUND=1]="ROUND",t[t.SQUARE=2]="SQUARE",t[t.UNKNOWN=4]="UNKNOWN"}(_||(_={}));class L{constructor(t,i,e,a,o,r){this.layer=t,this.feature=i,this.bounds=e,this.normalizationRatio=a,this.normalizationOffsetX=o,this.normalizationOffsetY=r}}class T{constructor(t,i,e,a){switch(this.type=t,this.typeName=i.type,this.id=i.id,this.source=i.source,this.sourceLayer=i["source-layer"],this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,this.filter=i.filter,this.layout=i.layout,this.paint=i.paint,this.z=e,this.uid=a,t){case y.BACKGROUND:this._layoutDefinition=P.backgroundLayoutDefinition,this._paintDefinition=P.backgroundPaintDefinition;break;case y.FILL:this._layoutDefinition=P.fillLayoutDefinition,this._paintDefinition=P.fillPaintDefinition;break;case y.LINE:this._layoutDefinition=P.lineLayoutDefinition,this._paintDefinition=P.linePaintDefinition;break;case y.SYMBOL:this._layoutDefinition=P.symbolLayoutDefinition,this._paintDefinition=P.symbolPaintDefinition;break;case y.CIRCLE:this._layoutDefinition=P.circleLayoutDefinition,this._paintDefinition=P.circlePaintDefinition}this._layoutProperties=this._parseLayout(this.layout),this._paintProperties=this._parsePaint(this.paint)}getFeatureFilter(){return void 0!==this._featureFilter?this._featureFilter:this._featureFilter=c.createFilter(this.filter)}getLayoutProperty(t){return this._layoutProperties[t]}getPaintProperty(t){return this._paintProperties[t]}getLayoutValue(t,i,e){let a;const o=this._layoutProperties[t];return o&&(a=o.getValue(i,e)),void 0===a&&(a=this._layoutDefinition[t].default),a}getPaintValue(t,i,e){let a;const o=this._paintProperties[t];return o&&(a=o.getValue(i,e)),void 0===a&&(a=this._paintDefinition[t].default),a}isPainterDataDriven(){const t=this._paintProperties;if(t)for(const i in t)if(t[i].isDataDriven)return!0;return!1}isIntersectingFeature(t,i,e,a,o,r,n){return!1}getFeatureInflatedBounds(t,i,e,a){return null}_parseLayout(t){const i={};for(const e in t){const a=this._layoutDefinition[e];a&&(i[e]=new D(a,t[e]))}return i}_parsePaint(t){const i={};for(const e in t){const a=this._paintDefinition[e];a&&(i[e]=new D(a,t[e]))}return i}computeAttributesKey(t,i,e,a){let o=0,r=0;for(const n of i){let t=3;if(!n||n!==a){const i=e[n],{isLayout:a,isOptional:o}=i,r=a?this.getLayoutProperty(n):this.getPaintProperty(n);t=r?.interpolator?2:r?.isDataDriven?1:o&&!r?3:0}r|=t<<o,o+=2}return r<<3|t}}class V extends T{constructor(t,e,a,o){super(t,e,a,o),this.backgroundMaterial=new n(this.computeAttributesKey(i.BACKGROUND,n.ATTRIBUTES,n.ATTRIBUTES_INFO))}}class v extends T{constructor(t,e,a,o){super(t,e,a,o);const r=this.getPaintProperty("fill-color"),n=this.getPaintProperty("fill-opacity"),s=this.getPaintProperty("fill-pattern");this.hasDataDrivenColor=r?.isDataDriven,this.hasDataDrivenOpacity=n?.isDataDriven,this.hasDataDrivenFill=this.hasDataDrivenColor||this.hasDataDrivenOpacity||s?.isDataDriven;const u=this.getPaintProperty("fill-outline-color");this.outlineUsesFillColor=!u,this.hasDataDrivenOutlineColor=u?.isDataDriven,this.hasDataDrivenOutline=u?u.isDataDriven:!!r&&r.isDataDriven,this.hasDataDrivenOutline=(u?this.hasDataDrivenOutlineColor:this.hasDataDrivenColor)||this.hasDataDrivenOpacity,this.fillMaterial=new l(this.computeAttributesKey(i.FILL,l.ATTRIBUTES,l.ATTRIBUTES_INFO)),this.outlineMaterial=new h(this.computeAttributesKey(i.OUTLINE,this.outlineUsesFillColor?h.ATTRIBUTES_FILL:h.ATTRIBUTES_OUTLINE,this.outlineUsesFillColor?h.ATTRIBUTES_INFO_FILL:h.ATTRIBUTES_INFO_OUTLINE),this.outlineUsesFillColor)}getFeatureInflatedBounds(t,i,e,a){const o=R(t);if(!o)return null;const r=this.getPaintValue("fill-translate",i,t),n=a*Math.max(r[0],r[1]);return o[0]-=n,o[2]-=n,o[1]+=n,o[3]+=n,o}isIntersectingFeature(t,i,r,n,s,l,h){const u=n.getGeometry();if(!u)return!1;const p=d/h.normalizationRatio;t=t/h.normalizationRatio+h.normalizationOffsetX,i=i/h.normalizationRatio+h.normalizationOffsetY;const g=e(this.getPaintValue("fill-translate",s,n),this.getPaintValue("fill-translate-anchor",s,n),l,d);t-=p*g.x,i-=p*g.y;return!!a(t,i,u)||o(t,i,u,p*r)}}class x extends T{constructor(t,e,a,o){super(t,e,a,o);const r=this.getPaintProperty("line-pattern");if(this.lineMaterial=new u(this.computeAttributesKey(i.LINE,u.ATTRIBUTES,u.ATTRIBUTES_INFO,r?"line-dasharray":"")),this.hasDataDrivenLine=this.getPaintProperty("line-blur")?.isDataDriven||this.getPaintProperty("line-color")?.isDataDriven||this.getPaintProperty("line-gap-width")?.isDataDriven||this.getPaintProperty("line-offset")?.isDataDriven||this.getPaintProperty("line-opacity")?.isDataDriven||this.getPaintProperty("line-pattern")?.isDataDriven||this.getPaintProperty("line-dasharray")?.isDataDriven||this.getLayoutProperty("line-cap")?.isDataDriven||this.getPaintProperty("line-width")?.isDataDriven,this.canUseThinTessellation=!1,!this.hasDataDrivenLine){const t=this.getPaintProperty("line-width");if(!t||"number"==typeof t&&.5*t<m){const t=this.getPaintProperty("line-offset");(!t||"number"==typeof t&&0===t)&&(this.canUseThinTessellation=!0)}}}getDashKey(t,i){let e;switch(i){case _.BUTT:e="Butt";break;case _.ROUND:e="Round";break;case _.SQUARE:e="Square";break;default:e="Butt"}return`dasharray-[${t.toString()}]-${e}`}getFeatureInflatedBounds(t,i,e,a){const o=R(t);if(!o)return null;const r=this.getPaintValue("line-translate",i,t),n=a*Math.max(r[0],r[1]);o[0]-=n,o[2]-=n,o[1]+=n,o[3]+=n;const s=a*Math.abs(this.getPaintValue("line-offset",i,t)||0),l=a*(this.getPaintValue("line-width",i,t)/2);return o[0]-=s+l,o[1]-=s+l,o[2]+=s+l,o[3]+=s+l,o}isIntersectingFeature(t,i,a,n,s,l,h){let u=n.getGeometry();if(!u)return!1;const p=d/h.normalizationRatio;t=t/h.normalizationRatio+h.normalizationOffsetX,i=i/h.normalizationRatio+h.normalizationOffsetY;const g=e(this.getPaintValue("line-translate",s,n),this.getPaintValue("line-translate-anchor",s,n),l,d);t-=p*g.x,i-=p*g.y;const c=p*this.getPaintValue("line-offset",s,n)||0;0!==c&&(u=r(u,-c));const y=this.getPaintValue("line-width",s,n);return o(t,i,u,p*(a+y/2))}}class I extends T{constructor(t,e,a,o){super(t,e,a,o),this.iconMaterial=new p(this.computeAttributesKey(i.ICON,p.ATTRIBUTES,p.ATTRIBUTES_INFO)),this.textMaterial=new g(this.computeAttributesKey(i.TEXT,g.ATTRIBUTES,g.ATTRIBUTES_INFO)),this.hasDataDrivenIcon=this.getPaintProperty("icon-color")?.isDataDriven||this.getPaintProperty("icon-halo-blur")?.isDataDriven||this.getPaintProperty("icon-halo-color")?.isDataDriven||this.getPaintProperty("icon-halo-width")?.isDataDriven||this.getPaintProperty("icon-opacity")?.isDataDriven||this.getLayoutProperty("icon-size")?.isDataDriven,this.hasDataDrivenText=this.getPaintProperty("text-color")?.isDataDriven||this.getPaintProperty("text-halo-blur")?.isDataDriven||this.getPaintProperty("text-halo-color")?.isDataDriven||this.getPaintProperty("text-halo-width")?.isDataDriven||this.getPaintProperty("text-opacity")?.isDataDriven||this.getLayoutProperty("text-size")?.isDataDriven}}class A extends T{constructor(t,e,a,o){super(t,e,a,o),this.circleMaterial=new s(this.computeAttributesKey(i.CIRCLE,s.ATTRIBUTES,s.ATTRIBUTES_INFO))}getFeatureInflatedBounds(t,i,e,a){const o=R(t);if(!o)return null;const r=this.getPaintValue("circle-translate",i,t),n=Math.max(r[0],r[1]);o[0]-=n,o[2]-=n,o[1]+=n,o[3]+=n;const s=a*(d*(this.getPaintValue("circle-radius",i,t)+this.getPaintValue("circle-stroke-width",i,t))/2);return o[0]-=s,o[1]-=s,o[2]+=s,o[3]+=s,o}isIntersectingFeature(t,i,a,o,r,n,s){const l=o.getGeometry();if(!l)return!1;const h=d/s.normalizationRatio;t=t/s.normalizationRatio+s.normalizationOffsetX,i=i/s.normalizationRatio+s.normalizationOffsetY,a*=h;const u=e(this.getPaintValue("circle-translate",r,o),this.getPaintValue("circle-translate-anchor",r,o),n,h),p=h*(this.getPaintValue("circle-radius",r,o)+this.getPaintValue("circle-stroke-width",r,o));let g,c;for(const e of l)if(e)for(const o of e){g=o.x+u.x,c=o.y+u.y;if(Math.sqrt((t-g)*(t-g)+(i-c)*(i-c))-a<=p)return!0}return!1}}class U{constructor(t,i,e){let a;this.allowOverlap=t.getLayoutValue("icon-allow-overlap",i),this.ignorePlacement=t.getLayoutValue("icon-ignore-placement",i),this.keepUpright=t.getLayoutValue("icon-keep-upright",i),this.optional=t.getLayoutValue("icon-optional",i),this.rotationAlignment=t.getLayoutValue("icon-rotation-alignment",i),this.rotationAlignment===f.AUTO&&(this.rotationAlignment=e?f.MAP:f.VIEWPORT),a=t.getLayoutProperty("icon-anchor"),a?.isDataDriven?this._anchorProp=a:this.anchor=t.getLayoutValue("icon-anchor",i),a=t.getLayoutProperty("icon-offset"),a?.isDataDriven?this._offsetProp=a:this.offset=t.getLayoutValue("icon-offset",i),a=t.getLayoutProperty("icon-padding"),a?.isDataDriven?this._paddingProp=a:this.padding=t.getLayoutValue("icon-padding",i),a=t.getLayoutProperty("icon-rotate"),a?.isDataDriven?this._rotateProp=a:this.rotate=t.getLayoutValue("icon-rotate",i),a=t.getLayoutProperty("icon-size"),a?.isDataDriven?this._sizeProp=a:this.size=t.getLayoutValue("icon-size",i)}update(t,i){this._anchorProp&&(this.anchor=this._anchorProp.getValue(t,i)),this._offsetProp&&(this.offset=this._offsetProp.getValue(t,i)),this._paddingProp&&(this.padding=this._paddingProp.getValue(t,i)),this._rotateProp&&(this.rotate=this._rotateProp.getValue(t,i)),this._sizeProp&&(this.size=this._sizeProp.getValue(t,i))}}class O{constructor(t,i,e){let a;this.allowOverlap=t.getLayoutValue("text-allow-overlap",i),this.ignorePlacement=t.getLayoutValue("text-ignore-placement",i),this.keepUpright=t.getLayoutValue("text-keep-upright",i),this.optional=t.getLayoutValue("text-optional",i),this.rotationAlignment=t.getLayoutValue("text-rotation-alignment",i),this.rotationAlignment===f.AUTO&&(this.rotationAlignment=e?f.MAP:f.VIEWPORT),a=t.getLayoutProperty("text-anchor"),a?.isDataDriven?this._anchorProp=a:this.anchor=t.getLayoutValue("text-anchor",i),a=t.getLayoutProperty("text-justify"),a?.isDataDriven?this._justifyProp=a:this.justify=t.getLayoutValue("text-justify",i),a=t.getLayoutProperty("text-letter-spacing"),a?.isDataDriven?this._letterSpacingProp=a:this.letterSpacing=t.getLayoutValue("text-letter-spacing",i),a=t.getLayoutProperty("text-line-height"),a?.isDataDriven?this._lineHeightProp=a:this.lineHeight=t.getLayoutValue("text-line-height",i),a=t.getLayoutProperty("text-max-angle"),a?.isDataDriven?this._maxAngleProp=a:this.maxAngle=t.getLayoutValue("text-max-angle",i),a=t.getLayoutProperty("text-max-width"),a?.isDataDriven?this._maxWidthProp=a:this.maxWidth=t.getLayoutValue("text-max-width",i),a=t.getLayoutProperty("text-offset"),a?.isDataDriven?this._offsetProp=a:this.offset=t.getLayoutValue("text-offset",i),a=t.getLayoutProperty("text-padding"),a?.isDataDriven?this._paddingProp=a:this.padding=t.getLayoutValue("text-padding",i),a=t.getLayoutProperty("text-rotate"),a?.isDataDriven?this._rotateProp=a:this.rotate=t.getLayoutValue("text-rotate",i),a=t.getLayoutProperty("text-size"),a?.isDataDriven?this._sizeProp=a:this.size=t.getLayoutValue("text-size",i),a=t.getLayoutProperty("text-writing-mode"),a?.isDataDriven?this._writingModeProp=a:this.writingMode=t.getLayoutValue("text-writing-mode",i)}update(t,i){this._anchorProp&&(this.anchor=this._anchorProp.getValue(t,i)),this._justifyProp&&(this.justify=this._justifyProp.getValue(t,i)),this._letterSpacingProp&&(this.letterSpacing=this._letterSpacingProp.getValue(t,i)),this._lineHeightProp&&(this.lineHeight=this._lineHeightProp.getValue(t,i)),this._maxAngleProp&&(this.maxAngle=this._maxAngleProp.getValue(t,i)),this._maxWidthProp&&(this.maxWidth=this._maxWidthProp.getValue(t,i)),this._offsetProp&&(this.offset=this._offsetProp.getValue(t,i)),this._paddingProp&&(this.padding=this._paddingProp.getValue(t,i)),this._rotateProp&&(this.rotate=this._rotateProp.getValue(t,i)),this._sizeProp&&(this.size=this._sizeProp.getValue(t,i)),this._writingModeProp&&(this.writingMode=this._writingModeProp.getValue(t,i))}}function R(i){const e=i?.getGeometry();if(null==e)return null;let a=1/0,o=1/0,r=-1/0,n=-1/0;for(const t of e)if(t)for(const i of t)a=Math.min(a,i.x),o=Math.min(o,i.y),r=Math.max(r,i.x),n=Math.max(n,i.y);return t(a,o,r,n)}export{V as BackgroundStyleLayer,_ as CapType,A as CircleStyleLayer,v as FillStyleLayer,U as IconLayout,L as IndexItem,x as LineStyleLayer,T as StyleLayer,I as SymbolStyleLayer,O as TextLayout};
5
+ import{fromValues as t}from"../../../../../geometry/support/aaBoundingRect.js";import{tilePixelRatio as i}from"../constants.js";import{ShaderProgramType as e}from"../enums.js";import{translateAnchor as a,pointInPolygon as o,distanceFromToPolylineWithinThreshold as r,offsetLine as n}from"../GeometryUtils.js";import{VTLBackgroundMaterial as s}from"../shaders/VTLBackgroundMaterial.js";import{VTLCircleMaterial as l}from"../shaders/VTLCircleMaterial.js";import{VTLFillMaterial as h,VTLOutlineMaterial as u}from"../shaders/VTLFillMaterial.js";import{VTLLineMaterial as p}from"../shaders/VTLLineMaterial.js";import{VTLIconMaterial as g,VTLTextMaterial as c}from"../shaders/VTLSymbolMaterial.js";import y from"./Filter.js";import{StyleLayerType as P,StyleDefinition as f,RotationAlignment as D}from"./StyleDefinition.js";import m from"./StyleProperty.js";import{thinLineHalfWidthThreshold as d}from"../../webgl/definitions.js";var _;!function(t){t[t.BUTT=0]="BUTT",t[t.ROUND=1]="ROUND",t[t.SQUARE=2]="SQUARE",t[t.UNKNOWN=4]="UNKNOWN"}(_||(_={}));class L{constructor(t,i,e,a,o,r){this.layer=t,this.feature=i,this.bounds=e,this.normalizationRatio=a,this.normalizationOffsetX=o,this.normalizationOffsetY=r}}class T{constructor(t,i,e,a){switch(this.type=t,this.typeName=i.type,this.id=i.id,this.source=i.source,this.sourceLayer=i["source-layer"],this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,this.filter=i.filter,this.layout=i.layout,this.paint=i.paint,this.z=e,this.uid=a,t){case P.BACKGROUND:this._layoutDefinition=f.backgroundLayoutDefinition,this._paintDefinition=f.backgroundPaintDefinition;break;case P.FILL:this._layoutDefinition=f.fillLayoutDefinition,this._paintDefinition=f.fillPaintDefinition;break;case P.LINE:this._layoutDefinition=f.lineLayoutDefinition,this._paintDefinition=f.linePaintDefinition;break;case P.SYMBOL:this._layoutDefinition=f.symbolLayoutDefinition,this._paintDefinition=f.symbolPaintDefinition;break;case P.CIRCLE:this._layoutDefinition=f.circleLayoutDefinition,this._paintDefinition=f.circlePaintDefinition}this._layoutProperties=this._parseLayout(this.layout),this._paintProperties=this._parsePaint(this.paint)}getFeatureFilter(){return void 0!==this._featureFilter?this._featureFilter:this._featureFilter=y.createFilter(this.filter)}getLayoutProperty(t){return this._layoutProperties[t]}getPaintProperty(t){return this._paintProperties[t]}getLayoutValue(t,i,e){let a;const o=this._layoutProperties[t];return o&&(a=o.getValue(i,e)),void 0===a&&(a=this._layoutDefinition[t].default),a}getPaintValue(t,i,e){let a;const o=this._paintProperties[t];return o&&(a=o.getValue(i,e)),void 0===a&&(a=this._paintDefinition[t].default),a}isPainterDataDriven(){const t=this._paintProperties;if(t)for(const i in t)if(t[i].isDataDriven)return!0;return!1}isIntersectingFeature(t,i,e,a,o,r,n){return!1}getFeatureInflatedBounds(t,i,e,a){return null}_parseLayout(t){const i={};for(const e in t){const a=this._layoutDefinition[e];a&&(i[e]=new m(a,t[e]))}return i}_parsePaint(t){const i={};for(const e in t){const a=this._paintDefinition[e];a&&(i[e]=new m(a,t[e]))}return i}computeAttributesKey(t,i,e,a){let o=0,r=0;for(const n of i){let t=3;if(!n||n!==a){const i=e[n],{isLayout:a,isOptional:o}=i,r=a?this.getLayoutProperty(n):this.getPaintProperty(n);t=r?.interpolator?2:r?.isDataDriven?1:o&&!r?3:0}r|=t<<o,o+=2}return r<<3|t}}class V extends T{constructor(t,i,a,o){super(t,i,a,o),this.backgroundMaterial=new s(this.computeAttributesKey(e.BACKGROUND,s.ATTRIBUTES,s.ATTRIBUTES_INFO))}}class v extends T{constructor(t,i,a,o){super(t,i,a,o);const r=this.getPaintProperty("fill-color"),n=this.getPaintProperty("fill-opacity"),s=this.getPaintProperty("fill-pattern");this.hasDataDrivenColor=r?.isDataDriven,this.hasDataDrivenOpacity=n?.isDataDriven,this.hasDataDrivenFill=this.hasDataDrivenColor||this.hasDataDrivenOpacity||s?.isDataDriven;const l=this.getPaintProperty("fill-outline-color");this.outlineUsesFillColor=!l,this.hasDataDrivenOutlineColor=l?.isDataDriven,this.hasDataDrivenOutline=l?l.isDataDriven:!!r&&r.isDataDriven,this.hasDataDrivenOutline=(l?this.hasDataDrivenOutlineColor:this.hasDataDrivenColor)||this.hasDataDrivenOpacity,this.fillMaterial=new h(this.computeAttributesKey(e.FILL,h.ATTRIBUTES,h.ATTRIBUTES_INFO)),this.outlineMaterial=new u(this.computeAttributesKey(e.OUTLINE,this.outlineUsesFillColor?u.ATTRIBUTES_FILL:u.ATTRIBUTES_OUTLINE,this.outlineUsesFillColor?u.ATTRIBUTES_INFO_FILL:u.ATTRIBUTES_INFO_OUTLINE),this.outlineUsesFillColor)}getFeatureInflatedBounds(t,i,e,a){const o=R(t);if(!o)return null;const r=this.getPaintValue("fill-translate",i,t),n=a*Math.max(r[0],r[1]);return o[0]-=n,o[2]-=n,o[1]+=n,o[3]+=n,o}isIntersectingFeature(t,e,n,s,l,h,u){const p=s.getGeometry();if(!p)return!1;const g=i/u.normalizationRatio;t=t/u.normalizationRatio+u.normalizationOffsetX,e=e/u.normalizationRatio+u.normalizationOffsetY;const c=a(this.getPaintValue("fill-translate",l,s),this.getPaintValue("fill-translate-anchor",l,s),h,i);t-=g*c.x,e-=g*c.y;return!!o(t,e,p)||r(t,e,p,g*n)}}class x extends T{constructor(t,i,a,o){super(t,i,a,o);const r=this.getPaintProperty("line-pattern");if(this.lineMaterial=new p(this.computeAttributesKey(e.LINE,p.ATTRIBUTES,p.ATTRIBUTES_INFO,r?"line-dasharray":"")),this.hasDataDrivenLine=this.getPaintProperty("line-blur")?.isDataDriven||this.getPaintProperty("line-color")?.isDataDriven||this.getPaintProperty("line-gap-width")?.isDataDriven||this.getPaintProperty("line-offset")?.isDataDriven||this.getPaintProperty("line-opacity")?.isDataDriven||this.getPaintProperty("line-pattern")?.isDataDriven||this.getPaintProperty("line-dasharray")?.isDataDriven||this.getLayoutProperty("line-cap")?.isDataDriven||this.getPaintProperty("line-width")?.isDataDriven,this.canUseThinTessellation=!1,!this.hasDataDrivenLine){const t=this.getPaintProperty("line-width");if(!t||"number"==typeof t&&.5*t<d){const t=this.getPaintProperty("line-offset");(!t||"number"==typeof t&&0===t)&&(this.canUseThinTessellation=!0)}}}getDashKey(t,i){let e;switch(i){case _.BUTT:e="Butt";break;case _.ROUND:e="Round";break;case _.SQUARE:e="Square";break;default:e="Butt"}return`dasharray-[${t.toString()}]-${e}`}getFeatureInflatedBounds(t,i,e,a){const o=R(t);if(!o)return null;const r=this.getPaintValue("line-translate",i,t),n=a*Math.max(r[0],r[1]);o[0]-=n,o[2]-=n,o[1]+=n,o[3]+=n;const s=a*Math.abs(this.getPaintValue("line-offset",i,t)||0),l=a*(this.getPaintValue("line-width",i,t)/2);return o[0]-=s+l,o[1]-=s+l,o[2]+=s+l,o[3]+=s+l,o}isIntersectingFeature(t,e,o,s,l,h,u){let p=s.getGeometry();if(!p)return!1;const g=i/u.normalizationRatio;t=t/u.normalizationRatio+u.normalizationOffsetX,e=e/u.normalizationRatio+u.normalizationOffsetY;const c=a(this.getPaintValue("line-translate",l,s),this.getPaintValue("line-translate-anchor",l,s),h,i);t-=g*c.x,e-=g*c.y;const y=g*this.getPaintValue("line-offset",l,s)||0;0!==y&&(p=n(p,-y));const P=this.getPaintValue("line-width",l,s);return r(t,e,p,g*(o+P/2))}}class I extends T{constructor(t,i,a,o){super(t,i,a,o),this.iconMaterial=new g(this.computeAttributesKey(e.ICON,g.ATTRIBUTES,g.ATTRIBUTES_INFO)),this.textMaterial=new c(this.computeAttributesKey(e.TEXT,c.ATTRIBUTES,c.ATTRIBUTES_INFO)),this.hasDataDrivenIcon=this.getPaintProperty("icon-color")?.isDataDriven||this.getPaintProperty("icon-halo-blur")?.isDataDriven||this.getPaintProperty("icon-halo-color")?.isDataDriven||this.getPaintProperty("icon-halo-width")?.isDataDriven||this.getPaintProperty("icon-opacity")?.isDataDriven||this.getLayoutProperty("icon-size")?.isDataDriven,this.hasDataDrivenText=this.getPaintProperty("text-color")?.isDataDriven||this.getPaintProperty("text-halo-blur")?.isDataDriven||this.getPaintProperty("text-halo-color")?.isDataDriven||this.getPaintProperty("text-halo-width")?.isDataDriven||this.getPaintProperty("text-opacity")?.isDataDriven||this.getLayoutProperty("text-size")?.isDataDriven}}class A extends T{constructor(t,i,a,o){super(t,i,a,o),this.circleMaterial=new l(this.computeAttributesKey(e.CIRCLE,l.ATTRIBUTES,l.ATTRIBUTES_INFO))}getFeatureInflatedBounds(t,e,a,o){const r=R(t);if(!r)return null;const n=this.getPaintValue("circle-translate",e,t),s=Math.max(n[0],n[1]);r[0]-=s,r[2]-=s,r[1]+=s,r[3]+=s;const l=o*(i*(this.getPaintValue("circle-radius",e,t)+this.getPaintValue("circle-stroke-width",e,t))/2);return r[0]-=l,r[1]-=l,r[2]+=l,r[3]+=l,r}isIntersectingFeature(t,e,o,r,n,s,l){const h=r.getGeometry();if(!h)return!1;const u=i/l.normalizationRatio;t=t/l.normalizationRatio+l.normalizationOffsetX,e=e/l.normalizationRatio+l.normalizationOffsetY,o*=u;const p=a(this.getPaintValue("circle-translate",n,r),this.getPaintValue("circle-translate-anchor",n,r),s,u),g=u*(this.getPaintValue("circle-radius",n,r)+this.getPaintValue("circle-stroke-width",n,r));let c,y;for(const i of h)if(i)for(const a of i){c=a.x+p.x,y=a.y+p.y;if(Math.sqrt((t-c)*(t-c)+(e-y)*(e-y))-o<=g)return!0}return!1}}class U{constructor(t,i,e){let a;this.allowOverlap=t.getLayoutValue("icon-allow-overlap",i),this.ignorePlacement=t.getLayoutValue("icon-ignore-placement",i),this.keepUpright=t.getLayoutValue("icon-keep-upright",i),this.optional=t.getLayoutValue("icon-optional",i),this.rotationAlignment=t.getLayoutValue("icon-rotation-alignment",i),this.rotationAlignment===D.AUTO&&(this.rotationAlignment=e?D.MAP:D.VIEWPORT),a=t.getLayoutProperty("icon-anchor"),a?.isDataDriven?this._anchorProp=a:this.anchor=t.getLayoutValue("icon-anchor",i),a=t.getLayoutProperty("icon-offset"),a?.isDataDriven?this._offsetProp=a:this.offset=t.getLayoutValue("icon-offset",i),a=t.getLayoutProperty("icon-padding"),a?.isDataDriven?this._paddingProp=a:this.padding=t.getLayoutValue("icon-padding",i),a=t.getLayoutProperty("icon-rotate"),a?.isDataDriven?this._rotateProp=a:this.rotate=t.getLayoutValue("icon-rotate",i),a=t.getLayoutProperty("icon-size"),a?.isDataDriven?this._sizeProp=a:this.size=t.getLayoutValue("icon-size",i)}update(t,i){this._anchorProp&&(this.anchor=this._anchorProp.getValue(t,i)),this._offsetProp&&(this.offset=this._offsetProp.getValue(t,i)),this._paddingProp&&(this.padding=this._paddingProp.getValue(t,i)),this._rotateProp&&(this.rotate=this._rotateProp.getValue(t,i)),this._sizeProp&&(this.size=this._sizeProp.getValue(t,i))}}class O{constructor(t,i,e){let a;this.allowOverlap=t.getLayoutValue("text-allow-overlap",i),this.ignorePlacement=t.getLayoutValue("text-ignore-placement",i),this.keepUpright=t.getLayoutValue("text-keep-upright",i),this.optional=t.getLayoutValue("text-optional",i),this.rotationAlignment=t.getLayoutValue("text-rotation-alignment",i),this.rotationAlignment===D.AUTO&&(this.rotationAlignment=e?D.MAP:D.VIEWPORT),a=t.getLayoutProperty("text-anchor"),a?.isDataDriven?this._anchorProp=a:this.anchor=t.getLayoutValue("text-anchor",i),a=t.getLayoutProperty("text-justify"),a?.isDataDriven?this._justifyProp=a:this.justify=t.getLayoutValue("text-justify",i),a=t.getLayoutProperty("text-letter-spacing"),a?.isDataDriven?this._letterSpacingProp=a:this.letterSpacing=t.getLayoutValue("text-letter-spacing",i),a=t.getLayoutProperty("text-line-height"),a?.isDataDriven?this._lineHeightProp=a:this.lineHeight=t.getLayoutValue("text-line-height",i),a=t.getLayoutProperty("text-max-angle"),a?.isDataDriven?this._maxAngleProp=a:this.maxAngle=t.getLayoutValue("text-max-angle",i),a=t.getLayoutProperty("text-max-width"),a?.isDataDriven?this._maxWidthProp=a:this.maxWidth=t.getLayoutValue("text-max-width",i),a=t.getLayoutProperty("text-offset"),a?.isDataDriven?this._offsetProp=a:this.offset=t.getLayoutValue("text-offset",i),a=t.getLayoutProperty("text-padding"),a?.isDataDriven?this._paddingProp=a:this.padding=t.getLayoutValue("text-padding",i),a=t.getLayoutProperty("text-rotate"),a?.isDataDriven?this._rotateProp=a:this.rotate=t.getLayoutValue("text-rotate",i),a=t.getLayoutProperty("text-size"),a?.isDataDriven?this._sizeProp=a:this.size=t.getLayoutValue("text-size",i),a=t.getLayoutProperty("text-writing-mode"),a?.isDataDriven?this._writingModeProp=a:this.writingMode=t.getLayoutValue("text-writing-mode",i)}update(t,i){this._anchorProp&&(this.anchor=this._anchorProp.getValue(t,i)),this._justifyProp&&(this.justify=this._justifyProp.getValue(t,i)),this._letterSpacingProp&&(this.letterSpacing=this._letterSpacingProp.getValue(t,i)),this._lineHeightProp&&(this.lineHeight=this._lineHeightProp.getValue(t,i)),this._maxAngleProp&&(this.maxAngle=this._maxAngleProp.getValue(t,i)),this._maxWidthProp&&(this.maxWidth=this._maxWidthProp.getValue(t,i)),this._offsetProp&&(this.offset=this._offsetProp.getValue(t,i)),this._paddingProp&&(this.padding=this._paddingProp.getValue(t,i)),this._rotateProp&&(this.rotate=this._rotateProp.getValue(t,i)),this._sizeProp&&(this.size=this._sizeProp.getValue(t,i)),this._writingModeProp&&(this.writingMode=this._writingModeProp.getValue(t,i))}}function R(i){const e=i?.getGeometry();if(null==e)return null;let a=1/0,o=1/0,r=-1/0,n=-1/0;for(const t of e)if(t)for(const i of t)a=Math.min(a,i.x),o=Math.min(o,i.y),r=Math.max(r,i.x),n=Math.max(n,i.y);return t(a,o,r,n)}export{V as BackgroundStyleLayer,_ as CapType,A as CircleStyleLayer,v as FillStyleLayer,U as IconLayout,L as IndexItem,x as LineStyleLayer,T as StyleLayer,I as SymbolStyleLayer,O as TextLayout};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{StyleLayerType as e}from"./StyleDefinition.js";import{CircleStyleLayer as t,SymbolStyleLayer as r,LineStyleLayer as s,FillStyleLayer as i,BackgroundStyleLayer as a}from"./StyleLayer.js";class l{constructor(t){if(this._style=t,this.backgroundBucketIds=[],this._uidToLayer=new Map,this._layerByName={},this._runningId=0,t.layers||(t.layers=[]),this.version=parseFloat(t.version),this.layers=t.layers.map(((e,t,r)=>this._create(e,t,r))).filter((e=>!!e)),this.layers)for(let r=0;r<this.layers.length;r++){const t=this.layers[r];this._layerByName[t.id]=t,this._uidToLayer.set(t.uid,t),t.type===e.BACKGROUND&&this.backgroundBucketIds.push(t.id)}this._identifyRefLayers()}isPainterDataDriven(e){const t=this._layerByName[e];return!!t&&t.isPainterDataDriven()}getStyleLayerId(e){return e>=this.layers.length?null:this.layers[e].id}getStyleLayerByUID(e){return this._uidToLayer.get(e)??null}getStyleLayerIndex(e){const t=this._layerByName[e];return t?this.layers.indexOf(t):-1}setStyleLayer(e,t){if(!e?.id)return;const r=this._style;null!=t&&t>=this.layers.length&&(t=this.layers.length-1);let s,i=!0;const a=this._layerByName[e.id];if(a){const y=this.layers.indexOf(a);t||(t=y),t===y?(i=!1,s=l._recreateLayer(e,a),this.layers[t]=s,r.layers[t]=e):(this.layers.splice(y,1),r.layers.splice(y,1),s=this._create(e,t,this.layers),this.layers.splice(t,0,s),r.layers.splice(t,0,e))}else s=this._create(e,t,this.layers),!t||t>=this.layers.length?(this.layers.push(s),r.layers.push(e)):(this.layers.splice(t,0,s),r.layers.splice(t,0,e));this._layerByName[e.id]=s,this._uidToLayer.set(s.uid,s),i&&this._recomputeZValues(),this._identifyRefLayers()}getStyleLayer(e){const t=this._layerByName[e];return t?{type:t.typeName,id:t.id,source:t.source,"source-layer":t.sourceLayer,minzoom:t.minzoom,maxzoom:t.maxzoom,filter:t.filter,layout:t.layout,paint:t.paint}:null}deleteStyleLayer(e){const t=this._layerByName[e];if(t){delete this._layerByName[e],this._uidToLayer.delete(t.uid);const r=this.layers.indexOf(t);this.layers.splice(r,1),this._style.layers.splice(r,1),this._recomputeZValues(),this._identifyRefLayers()}}getLayerById(e){return this._layerByName[e]}getLayoutProperties(e){const t=this._layerByName[e];return t?t.layout:null}getPaintProperties(e){const t=this._layerByName[e];return t?t.paint:null}setPaintProperties(e,t){const r=this._layerByName[e];if(!r)return;const s={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:r.layout,paint:t},i=l._recreateLayer(s,r),a=this.layers.indexOf(r);this.layers[a]=i,this._style.layers[a].paint=t,this._layerByName[r.id]=i,this._uidToLayer.set(r.uid,i)}setLayoutProperties(e,t){const r=this._layerByName[e];if(!r)return;const s={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:t,paint:r.paint},i=l._recreateLayer(s,r),a=this.layers.indexOf(r);this.layers[a]=i,this._style.layers[a].layout=t,this._layerByName[r.id]=i,this._uidToLayer.set(r.uid,i)}setStyleLayerVisibility(e,t){const r=this._layerByName[e];if(!r)return;const s=r.layout||{};s.visibility=t;const i={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:s,paint:r.paint},a=l._recreateLayer(i,r),y=this.layers.indexOf(r);this.layers[y]=a,this._style.layers[y].layout=s,this._layerByName[r.id]=a,this._uidToLayer.set(r.uid,a)}getStyleLayerVisibility(e){const t=this._layerByName[e];if(!t)return"none";const r=t.layout;return r?.visibility??"visible"}_recomputeZValues(){const e=this.layers,t=1/(e.length+1);for(let r=0;r<e.length;r++)e[r].z=1-(1+r)*t}_identifyRefLayers(){const t=[],r=[];let s=0;for(const i of this.layers){const a=i.layout;if(i.type===e.FILL){const e=i;let r=i.source+"|"+i.sourceLayer;r+="|"+(a?.visibility??""),r+="|"+i.minzoom,r+="|"+i.maxzoom,r+="|"+JSON.stringify(i.filter),(e.hasDataDrivenFill||e.hasDataDrivenOutline)&&(r+="|"+s),t.push({key:r,layer:i})}else if(i.type===e.LINE){const e=i,t=i.paint,l=null!=t&&(null!=t["line-pattern"]||null!=t["line-dasharray"]);let y=i.source+"|"+i.sourceLayer;y+="|"+(a?.visibility??""),y+="|"+i.minzoom,y+="|"+i.maxzoom,y+="|"+JSON.stringify(i.filter),y+="|"+(void 0!==a?a["line-cap"]:""),y+="|"+(void 0!==a?a["line-join"]:""),(e.hasDataDrivenLine||l)&&(y+="|"+s),r.push({key:y,layer:i})}++s}this._assignRefLayers(t),this._assignRefLayers(r)}_assignRefLayers(t){let r,s;t.sort(((e,t)=>e.key<t.key?-1:e.key>t.key?1:0));const i=t.length;for(let a=0;a<i;a++){const l=t[a];if(l.key===r)l.layer.refLayerId=s;else if(r=l.key,s=l.layer.id,l.layer.type===e.FILL){if(!l.layer.getPaintProperty("fill-outline-color"))for(let e=a+1;e<i;e++){const i=t[e];if(i.key!==r)break;if(i.layer.getPaintProperty("fill-outline-color")){t[a]=i,t[e]=l,s=i.layer.id;break}}}else if(l.layer.type===e.LINE){let e=l.layer;for(let y=a+1;y<i;y++){const i=t[y];if(i.key!==r)break;const n=i.layer;(e.canUseThinTessellation&&!n.canUseThinTessellation||!e.canUseThinTessellation&&(n.getPaintProperty("line-pattern")||n.getPaintProperty("line-dasharray")))&&(e=n,t[a]=i,t[y]=l,s=i.layer.id)}}}}_create(l,y,n){const o=1-(1+y)*(1/(n.length+1)),u=this._runningId++;switch(l.type){case"background":return new a(e.BACKGROUND,l,o,u);case"fill":return new i(e.FILL,l,o,u);case"line":return new s(e.LINE,l,o,u);case"symbol":return new r(e.SYMBOL,l,o,u);case"raster":return console.warn(`Unsupported vector tile raster layer ${l.id}`),null;case"circle":return new t(e.CIRCLE,l,o,u)}return null}static _recreateLayer(l,y){switch(l.type){case"background":return new a(e.BACKGROUND,l,y.z,y.uid);case"fill":return new i(e.FILL,l,y.z,y.uid);case"line":return new s(e.LINE,l,y.z,y.uid);case"symbol":return new r(e.SYMBOL,l,y.z,y.uid);case"raster":return console.warn(`Unsupported vector tile raster layer ${l.id}`),null;case"circle":return new t(e.CIRCLE,l,y.z,y.uid)}return null}}export{l as default};
5
+ import{StyleLayerType as e,SymbolPlacement as t,RotationAlignment as r}from"./StyleDefinition.js";import{CircleStyleLayer as a,SymbolStyleLayer as i,LineStyleLayer as s,FillStyleLayer as l,BackgroundStyleLayer as n}from"./StyleLayer.js";class y{constructor(t){if(this._style=t,this.backgroundBucketIds=[],this._uidToLayer=new Map,this._layerByName={},this._runningId=0,t.layers||(t.layers=[]),this.version=parseFloat(t.version),this.layers=t.layers.map(((e,t,r)=>this._create(e,t,r))).filter((e=>!!e)),this.layers)for(let r=0;r<this.layers.length;r++){const t=this.layers[r];this._layerByName[t.id]=t,this._uidToLayer.set(t.uid,t),t.type===e.BACKGROUND&&this.backgroundBucketIds.push(t.id)}this._identifyRefLayers()}getLayerStyleProperties(e,a){const i=this.getStyleLayerByUID(e),s=i?.getLayoutValue("symbol-placement",a)!==t.POINT;let l=i?.getLayoutValue("icon-rotation-alignment",a);l===r.AUTO&&(l=s?r.MAP:r.VIEWPORT);let n=i?.getLayoutValue("text-rotation-alignment",a);n===r.AUTO&&(n=s?r.MAP:r.VIEWPORT);const y=i?.getPaintValue("icon-translate",a),o=i?.getPaintValue("icon-translate-anchor",a),u=i?.getPaintValue("text-translate",a),c=i?.getPaintValue("text-translate-anchor",a);return{geometryType:null,iconAllowOverlap:i?.getLayoutValue("icon-allow-overlap",a),iconIgnorePlacement:i?.getLayoutValue("icon-ignore-placement",a),textAllowOverlap:i?.getLayoutValue("text-allow-overlap",a),textIgnorePlacement:i?.getLayoutValue("text-ignore-placement",a),iconRotationAlignment:l,textRotationAlignment:n,iconTranslateAnchor:o,iconTranslate:y,textTranslateAnchor:c,textTranslate:u}}isPainterDataDriven(e){const t=this._layerByName[e];return!!t&&t.isPainterDataDriven()}getStyleLayerId(e){return e>=this.layers.length?null:this.layers[e].id}getStyleLayerByUID(e){return this._uidToLayer.get(e)??null}getStyleLayerIndex(e){const t=this._layerByName[e];return t?this.layers.indexOf(t):-1}setStyleLayer(e,t){if(!e?.id)return;const r=this._style;null!=t&&t>=this.layers.length&&(t=this.layers.length-1);let a,i=!0;const s=this._layerByName[e.id];if(s){const l=this.layers.indexOf(s);t||(t=l),t===l?(i=!1,a=y._recreateLayer(e,s),this.layers[t]=a,r.layers[t]=e):(this.layers.splice(l,1),r.layers.splice(l,1),a=this._create(e,t,this.layers),this.layers.splice(t,0,a),r.layers.splice(t,0,e))}else a=this._create(e,t,this.layers),!t||t>=this.layers.length?(this.layers.push(a),r.layers.push(e)):(this.layers.splice(t,0,a),r.layers.splice(t,0,e));this._layerByName[e.id]=a,this._uidToLayer.set(a.uid,a),i&&this._recomputeZValues(),this._identifyRefLayers()}getStyleLayer(e){const t=this._layerByName[e];return t?{type:t.typeName,id:t.id,source:t.source,"source-layer":t.sourceLayer,minzoom:t.minzoom,maxzoom:t.maxzoom,filter:t.filter,layout:t.layout,paint:t.paint}:null}deleteStyleLayer(e){const t=this._layerByName[e];if(t){delete this._layerByName[e],this._uidToLayer.delete(t.uid);const r=this.layers.indexOf(t);this.layers.splice(r,1),this._style.layers.splice(r,1),this._recomputeZValues(),this._identifyRefLayers()}}getLayerById(e){return this._layerByName[e]}getLayoutProperties(e){const t=this._layerByName[e];return t?t.layout:null}getPaintProperties(e){const t=this._layerByName[e];return t?t.paint:null}setPaintProperties(e,t){const r=this._layerByName[e];if(!r)return;const a={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:r.layout,paint:t},i=y._recreateLayer(a,r),s=this.layers.indexOf(r);this.layers[s]=i,this._style.layers[s].paint=t,this._layerByName[r.id]=i,this._uidToLayer.set(r.uid,i)}setLayoutProperties(e,t){const r=this._layerByName[e];if(!r)return;const a={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:t,paint:r.paint},i=y._recreateLayer(a,r),s=this.layers.indexOf(r);this.layers[s]=i,this._style.layers[s].layout=t,this._layerByName[r.id]=i,this._uidToLayer.set(r.uid,i)}setStyleLayerVisibility(e,t){const r=this._layerByName[e];if(!r)return;const a=r.layout||{};a.visibility=t;const i={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:a,paint:r.paint},s=y._recreateLayer(i,r),l=this.layers.indexOf(r);this.layers[l]=s,this._style.layers[l].layout=a,this._layerByName[r.id]=s,this._uidToLayer.set(r.uid,s)}getStyleLayerVisibility(e){const t=this._layerByName[e];if(!t)return"none";const r=t.layout;return r?.visibility??"visible"}_recomputeZValues(){const e=this.layers,t=1/(e.length+1);for(let r=0;r<e.length;r++)e[r].z=1-(1+r)*t}_identifyRefLayers(){const t=[],r=[];let a=0;for(const i of this.layers){const s=i.layout;if(i.type===e.FILL){const e=i;let r=i.source+"|"+i.sourceLayer;r+="|"+(s?.visibility??""),r+="|"+i.minzoom,r+="|"+i.maxzoom,r+="|"+JSON.stringify(i.filter),(e.hasDataDrivenFill||e.hasDataDrivenOutline)&&(r+="|"+a),t.push({key:r,layer:i})}else if(i.type===e.LINE){const e=i,t=i.paint,l=null!=t&&(null!=t["line-pattern"]||null!=t["line-dasharray"]);let n=i.source+"|"+i.sourceLayer;n+="|"+(s?.visibility??""),n+="|"+i.minzoom,n+="|"+i.maxzoom,n+="|"+JSON.stringify(i.filter),n+="|"+(void 0!==s?s["line-cap"]:""),n+="|"+(void 0!==s?s["line-join"]:""),(e.hasDataDrivenLine||l)&&(n+="|"+a),r.push({key:n,layer:i})}++a}this._assignRefLayers(t),this._assignRefLayers(r)}_assignRefLayers(t){let r,a;t.sort(((e,t)=>e.key<t.key?-1:e.key>t.key?1:0));const i=t.length;for(let s=0;s<i;s++){const l=t[s];if(l.key===r)l.layer.refLayerId=a;else if(r=l.key,a=l.layer.id,l.layer.type===e.FILL){if(!l.layer.getPaintProperty("fill-outline-color"))for(let e=s+1;e<i;e++){const i=t[e];if(i.key!==r)break;if(i.layer.getPaintProperty("fill-outline-color")){t[s]=i,t[e]=l,a=i.layer.id;break}}}else if(l.layer.type===e.LINE){let e=l.layer;for(let n=s+1;n<i;n++){const i=t[n];if(i.key!==r)break;const y=i.layer;(e.canUseThinTessellation&&!y.canUseThinTessellation||!e.canUseThinTessellation&&(y.getPaintProperty("line-pattern")||y.getPaintProperty("line-dasharray")))&&(e=y,t[s]=i,t[n]=l,a=i.layer.id)}}}}_create(t,r,y){const o=1-(1+r)*(1/(y.length+1)),u=this._runningId++;switch(t.type){case"background":return new n(e.BACKGROUND,t,o,u);case"fill":return new l(e.FILL,t,o,u);case"line":return new s(e.LINE,t,o,u);case"symbol":return new i(e.SYMBOL,t,o,u);case"raster":return console.warn(`Unsupported vector tile raster layer ${t.id}`),null;case"circle":return new a(e.CIRCLE,t,o,u)}return null}static _recreateLayer(t,r){switch(t.type){case"background":return new n(e.BACKGROUND,t,r.z,r.uid);case"fill":return new l(e.FILL,t,r.z,r.uid);case"line":return new s(e.LINE,t,r.z,r.uid);case"symbol":return new i(e.SYMBOL,t,r.z,r.uid);case"raster":return console.warn(`Unsupported vector tile raster layer ${t.id}`),null;case"circle":return new a(e.CIRCLE,t,r.z,r.uid)}return null}}export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{set as t,multiply as s}from"../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{set as i,multiply as e,invert as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{i as m,q as n}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{tileSize as c}from"./definitions.js";import{TiledDisplayObject as h}from"./TiledDisplayObject.js";const f=a(),p=l();class d extends h{constructor(t,s,r,i){super(t,s,r,i,c,c)}destroy(){super.destroy()}setTransform(o){const a=this.resolution/o.resolution,m=this.transforms.tileMat3,[n,l]=o.toScreenNoRotation([0,0],[this.x,this.y]),c=this.width/this.rangeX*a,h=this.height/this.rangeY*a;i(m,c,0,0,0,h,0,n,l,1),e(this.transforms.displayViewScreenMat3,o.displayViewMat3,m);const f=t(r(),c,0,0,h,n,l);s(this.transforms.labelMat2d,o.viewMat2d,f)}_createTransforms(){return{labelMat2d:r(),tileMat3:a(),displayViewScreenMat3:a()}}containsScreenPoint(t,s,r){const i=e(f,t.viewMat3,this.transforms.tileMat3),a=o(f,i);if(null==a)return!0;m(p,...s,1);const l=n(p,p,a),c=r*(this.resolution/t.resolution);return l[0]>=-c&&l[0]<this.width+c&&l[1]>=-c&&l[1]<this.height+c}}export{d as AFeatureTile};
5
+ import{set as t,multiply as s}from"../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{set as r,multiply as e,identity as o,translate as a,rotate as n,scale as l,invert as m}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{i as h,q as f}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{tileSize as d}from"./definitions.js";import{TiledDisplayObject as u}from"./TiledDisplayObject.js";const x=c(),M=p();class g extends u{constructor(t,s,i,r){super(t,s,i,r,d,d)}destroy(){super.destroy()}setTransform(m){const c=this.resolution/m.resolution,h=this.transforms.tileMat3,[f,p]=m.toScreenNoRotation([0,0],[this.x,this.y]),d=this.width/this.rangeX*c,u=this.height/this.rangeY*c;r(h,d,0,0,0,u,0,f,p,1),e(this.transforms.displayViewScreenMat3,m.displayViewMat3,h);const x=t(i(),d,0,0,u,f,p);s(this.transforms.labelMat2d,m.viewMat2d,x);const M=[0,0];m.toScreen(M,[this.x,this.y]);const g=this.transforms.tileUnitsToPixels;o(g),a(g,g,M),n(g,g,Math.PI*m.rotation/180),l(g,g,[d,u,1])}_createTransforms(){return{labelMat2d:i(),tileMat3:c(),displayViewScreenMat3:c(),tileUnitsToPixels:c()}}containsScreenPoint(t,s,i){const r=e(x,t.viewMat3,this.transforms.tileMat3),o=m(x,r);if(null==o)return!0;h(M,...s,1);const a=f(M,M,o),n=i*(this.resolution/t.resolution);return a[0]>=-n&&a[0]<this.width+n&&a[1]>=-n&&a[1]<this.height+n}}export{g as AFeatureTile};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../core/Error.js";import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{AttributeDataType as i,filterFlagsUnit as s,animationUnit as r,gpgpuUnit as a,localTimeOriginUnit as n,visualVariableUnit as u,dataDrivenUnit0 as h,dataDrivenUnit1 as o,dataDrivenUnit2 as l}from"./definitions.js";import{getDisplayIdTexel as d}from"./DisplayId.js";import{getPixelArrayCtor as g,getPixelBytes as _}from"./Utils.js";import{TextureWrapMode as p,TextureSamplingMode as c}from"../../../webgl/enums.js";import{FramebufferObject as x}from"../../../webgl/FramebufferObject.js";import{Texture as f}from"../../../webgl/Texture.js";import{TextureDescriptor as b}from"../../../webgl/TextureDescriptor.js";const T=()=>e.getLogger("esri.views.2d.engine.webgl.AttributeStoreView");class m{constructor(t,e,i){this._texture=null,this._lastTexture=null,this._fbos={},this.texelSize=4;const{buffer:s,pixelType:r,textureOnly:a}=t,n=g(r);this.blockIndex=i,this.pixelType=r,this.size=e,this.textureOnly=a,a||(this.data=new n(s)),this._resetRange()}destroy(){this._texture?.dispose();for(const t in this._fbos){const e=this._fbos[t];e&&("0"===t&&e.detachColorTexture(),e.dispose()),this._fbos[t]=null}this._texture=null}get _textureDesc(){const t=new b;return t.wrapMode=p.CLAMP_TO_EDGE,t.samplingMode=c.NEAREST,t.dataType=this.pixelType,t.width=this.size,t.height=this.size,t}setData(t,e,i){const s=d(t),r=this.data,a=s*this.texelSize+e;!r||a>=r.length||(r[a]=i,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s))}getData(t,e){if(null==this.data)return null;const i=d(t)*this.texelSize+e;return!this.data||i>=this.data.length?null:this.data[i]}getTexture(t){return this._texture??this._initTexture(t)}getFBO(t,e=0){if(!this._fbos[e]){const i=0===e?this.getTexture(t):this._textureDesc;this._fbos[e]=new x(t,i)}return this._fbos[e]}get hasDirty(){const t=this.dirtyStart;return this.dirtyEnd>=t}updateTexture(e,i){try{const s=this.dirtyStart,r=this.dirtyEnd;if(!this.hasDirty)return;has("esri-2d-update-debug")&&console.debug(`Version[${i}] AttributeStoreView.updateTexture`,{start:s,end:r,firstBytes:new Uint8Array(this.data.buffer.slice(0,16)),block:this}),this._resetRange();const a=this.data.buffer,n=this.getTexture(e),u=4,h=(s-s%this.size)/this.size,o=(r-r%this.size)/this.size,l=h,d=this.size,_=o,p=h*this.size*u,c=(d+_*this.size)*u-p,x=g(this.pixelType),f=new x(a,p*x.BYTES_PER_ELEMENT,c),b=this.size,m=_-l+1;if(m>this.size)return void T().error(new t("mapview-webgl","Out-of-bounds index when updating AttributeData"));n.updateData(0,0,l,b,m,f)}catch(s){}}update(t){const{data:e,start:i,end:s}=t;if(null!=e&&null!=this.data){const s=this.data,r=i*this.texelSize;for(let i=0;i<e.length;i++){const a=1<<i%this.texelSize;t.layout&a&&(s[r+i]=e[i])}}this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,s)}resize(t,e){const i=this.size;if(this.size=e,this.textureOnly)return void(i!==this.size&&(this._lastTexture=this._texture,this._texture=null));const s=g(this.pixelType);this.destroy(),this.data=new s(t.buffer)}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}_initTexture(t){const e=new f(t,this._textureDesc,this.data??void 0);if(null!=this._lastTexture&&this._fbos[0]){const i=this._lastTexture.descriptor.width,s=this._lastTexture.descriptor.height,r=this._lastTexture.descriptor.dataType,a=this._lastTexture.descriptor.pixelFormat,n=this.getFBO(t),u=_(r),h=new(g(r))(new ArrayBuffer(i*s*u*this.texelSize)),o=t.getBoundFramebufferObject(),{x:l,y:d,width:p,height:c}=t.getViewport();t.bindFramebuffer(n),n.readPixels(0,0,i,s,a,r,h),e.updateData(0,0,0,2*i,s/2,h),t.setViewport(l,d,p,c),t.bindFramebuffer(o)}return this.destroy(),this._texture=e,this._texture}}class y{constructor(){this.size=0,this._pendingAttributeUpdates=[],this._version=0,this._epoch=0,this._locked=!1}get locked(){return this._locked}_initialize(t){if(!t)throw new Error("InternalError: initArgs must be defined");const e=t.blockDescriptors;if(this.size=t.blockSize,has("esri-2d-update-debug")&&console.debug("AttributeStoreView.initialize",{message:t}),null==this._data)this._data=e.map(((t,e)=>null!=t?new m(t,this.size,e):null));else for(let i=0;i<this._data.length;i++){const t=this._data[i],s=e[i];null!=s&&(null==t?this._data[i]=new m(s,this.size,i):t.resize(s,this.size))}}destroy(){for(const t of this._data??[])t?.destroy();this._defaultTexture?.dispose(),this._defaultTexture=null,this._pendingAttributeUpdates=[]}isEmpty(){return null==this._data}getBlock(t){if(null==this._data)return null;return this._data[t]}setLabelMinZoom(t,e){this.setData(t,i.FilterFlags,1,e)}setLocalTimeOrigin(t,e){this.setData(t,i.LocalTimeOrigin,0,e)}getLabelMinZoom(t){return this.getData(t,i.FilterFlags,1,255)}getFilterFlags(t){return this.getData(t,i.FilterFlags,0,0)}getVisualVariableData(t,e){return this.getData(t,i.VV,e,0)}getData(t,e,i,s){if(!this._data)return 0;const r=this._data[e];if(null==r)return 0;const a=r.getData(t,i);return null!=a?a:s}setData(t,e,i,s){this._data[e].setData(t,i,s)}lockTextureUploads(){this._locked=!0}unlockTextureUploads(){this._locked=!1,this.update()}requestUpdate(t){this._version=t.version,this._pendingAttributeUpdates.push(t),has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] AttributeStoreView.requestUpdate`,{message:t})}get currentEpoch(){return this._epoch}update(){if(this._locked)return;const t=this._pendingAttributeUpdates;this._pendingAttributeUpdates=[];for(const e of t){const{blockData:t,initArgs:i,sendUpdateEpoch:s,version:r}=e;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] Epoch[${s}] AttributeStoreView.applyUpdate`),this._version=r,this._epoch=s,null!=i&&this._initialize(i);const a=this._data;for(let e=0;e<t.length;e++){const i=t[e],s=a[e];null!=s&&null!=i&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] CpuBlock[${e}] AttributeStoreView.update`,{block:i}),s.update(i))}}}getUniforms(t){return{filterFlags:{texture:this._getTexture(t,i.FilterFlags),unit:s},animation:{texture:this._getTexture(t,i.Animation),unit:r},gpgpu:{texture:this._getTexture(t,i.GPGPU),unit:a},localTimeOrigin:{texture:this._getTexture(t,i.LocalTimeOrigin),unit:n},visualVariableData:{texture:this._getTexture(t,i.VV),unit:u},dataDriven0:{texture:this._getTexture(t,i.DD0),unit:h},dataDriven1:{texture:this._getTexture(t,i.DD1),unit:o},dataDriven2:{texture:this._getTexture(t,i.DD2),unit:l},size:this.size}}_getTexture(t,e){const i=this._data?.[e];return i?(i.updateTexture(t,this._version),i.getTexture(t)):this._getDefaultTexture(t)}_getDefaultTexture(t){if(null==this._defaultTexture){const e=new b;e.wrapMode=p.CLAMP_TO_EDGE,e.samplingMode=c.NEAREST,e.width=1,e.height=1,this._defaultTexture=new f(t,e,new Uint8Array(4))}return this._defaultTexture}}export{y as AttributeStoreView};
5
+ import t from"../../../../core/Error.js";import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{AttributeDataType as i,filterFlagsUnit as s,animationUnit as r,gpgpuUnit as a,localTimeOriginUnit as n,visualVariableUnit as u,dataDrivenUnit0 as h,dataDrivenUnit1 as o,dataDrivenUnit2 as l}from"./definitions.js";import{getDisplayIdTexel as d}from"./DisplayId.js";import{getPixelArrayCtor as g,getPixelBytes as p}from"./Utils.js";import{TextureWrapMode as _,TextureSamplingMode as c}from"../../../webgl/enums.js";import{FramebufferObject as x}from"../../../webgl/FramebufferObject.js";import{Texture as f}from"../../../webgl/Texture.js";import{TextureDescriptor as b}from"../../../webgl/TextureDescriptor.js";const T=()=>e.getLogger("esri.views.2d.engine.webgl.AttributeStoreView");class m{constructor(t,e,i){this._texture=null,this._lastTexture=null,this._fbos={},this.texelSize=4;const{buffer:s,pixelType:r,textureOnly:a}=t,n=g(r);this.blockIndex=i,this.pixelType=r,this.size=e,this.textureOnly=a,a||(this.data=new n(s)),this._resetRange()}destroy(){this._texture?.dispose();for(const t in this._fbos){const e=this._fbos[t];e&&("0"===t&&e.detachColorTexture(),e.dispose()),this._fbos[t]=null}this._texture=null}get _textureDesc(){const t=new b;return t.wrapMode=_.CLAMP_TO_EDGE,t.samplingMode=c.NEAREST,t.dataType=this.pixelType,t.width=this.size,t.height=this.size,t}setData(t,e,i){const s=d(t),r=this.data,a=s*this.texelSize+e;!r||a>=r.length||(r[a]=i,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s))}getData(t,e){if(null==this.data)return null;const i=d(t)*this.texelSize+e;return!this.data||i>=this.data.length?null:this.data[i]}getTexture(t){return this._texture??this._initTexture(t)}getFBO(t,e=0){if(!this._fbos[e]){const i=0===e?this.getTexture(t):this._textureDesc;this._fbos[e]=new x(t,i)}return this._fbos[e]}get hasDirty(){const t=this.dirtyStart;return this.dirtyEnd>=t}updateTexture(e,i){try{const s=this.dirtyStart,r=this.dirtyEnd;if(!this.hasDirty)return;has("esri-2d-update-debug")&&console.debug(`Version[${i}] AttributeStoreView.updateTexture`,{start:s,end:r,firstBytes:new Uint8Array(this.data.buffer.slice(0,16)),block:this}),this._resetRange();const a=this.data.buffer,n=this.getTexture(e),u=4,h=(s-s%this.size)/this.size,o=(r-r%this.size)/this.size,l=h,d=this.size,p=o,_=h*this.size*u,c=(d+p*this.size)*u-_,x=g(this.pixelType),f=new x(a,_*x.BYTES_PER_ELEMENT,c),b=this.size,m=p-l+1;if(m>this.size)return void T().error(new t("mapview-webgl","Out-of-bounds index when updating AttributeData"));n.updateData(0,0,l,b,m,f)}catch(s){}}update(t){const{data:e,start:i,end:s}=t;if(null!=e&&null!=this.data){const s=this.data,r=i*this.texelSize;for(let i=0;i<e.length;i++){const a=1<<i%this.texelSize;t.layout&a&&(s[r+i]=e[i])}}this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,s)}resize(t,e){const i=this.size;if(this.size=e,this.textureOnly)return void(i!==this.size&&(this._lastTexture=this._texture,this._texture=null));const s=g(this.pixelType);this.destroy(),this.data=new s(t.buffer)}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}_initTexture(t){const e=new f(t,this._textureDesc,this.data??void 0);if(null!=this._lastTexture&&this._fbos[0]){const i=this._lastTexture.descriptor.width,s=this._lastTexture.descriptor.height,r=this._lastTexture.descriptor.dataType,a=this._lastTexture.descriptor.pixelFormat,n=this.getFBO(t),u=p(r),h=new(g(r))(new ArrayBuffer(i*s*u*this.texelSize)),o=t.getBoundFramebufferObject(),{x:l,y:d,width:_,height:c}=t.getViewport();t.bindFramebuffer(n),n.readPixels(0,0,i,s,a,r,h),e.updateData(0,0,0,2*i,s/2,h),t.setViewport(l,d,_,c),t.bindFramebuffer(o)}return this.destroy(),this._texture=e,this._texture}}class y{constructor(){this.size=0,this._pendingAttributeUpdates=[],this._version=0,this._epoch=0,this._locked=!1}get locked(){return this._locked}_initialize(t){if(!t)throw new Error("InternalError: initArgs must be defined");const e=t.blockDescriptors;if(this.size=t.blockSize,has("esri-2d-update-debug")&&console.debug("AttributeStoreView.initialize",{message:t}),null==this._data)this._data=e.map(((t,e)=>null!=t?new m(t,this.size,e):null));else for(let i=0;i<this._data.length;i++){const t=this._data[i],s=e[i];null!=s&&(null==t?this._data[i]=new m(s,this.size,i):t.resize(s,this.size))}}destroy(){for(const t of this._data??[])t?.destroy();this._defaultTexture?.dispose(),this._defaultTexture=null,this._pendingAttributeUpdates=[]}isEmpty(){return null==this._data}getBlock(t){if(null==this._data)return null;return this._data[t]}setLabelMinZoom(t,e){this.setData(t,i.FilterFlags,1,e)}setLocalTimeOrigin(t,e){this.setData(t,i.LocalTimeOrigin,0,e)}getLabelMinZoom(t){return this.getData(t,i.FilterFlags,1,255)}getFilterFlags(t){return this.getData(t,i.FilterFlags,0,0)}getVisualVariableData(t,e){return this.getData(t,i.VV,e,0)}getData(t,e,i,s){if(!this._data)return 0;const r=this._data[e];if(null==r)return 0;const a=r.getData(t,i);return null!=a?a:s}setData(t,e,i,s){this._data[e].setData(t,i,s)}lockTextureUploads(){this._locked=!0}unlockTextureUploads(){this._locked=!1,this.update()}requestUpdate(t){this._version=t.version,this._pendingAttributeUpdates.push(t),has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] AttributeStoreView.requestUpdate`,{message:t})}get currentEpoch(){return this._epoch}get hasPendingUpdates(){return this._pendingAttributeUpdates.length>0}update(){if(this._locked)return;const t=this._pendingAttributeUpdates;this._pendingAttributeUpdates=[];for(const e of t){const{blockData:t,initArgs:i,sendUpdateEpoch:s,version:r}=e;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] Epoch[${s}] AttributeStoreView.applyUpdate`),this._version=r,this._epoch=s,null!=i&&this._initialize(i);const a=this._data;for(let e=0;e<t.length;e++){const i=t[e],s=a[e];null!=s&&null!=i&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] CpuBlock[${e}] AttributeStoreView.update`,{block:i}),s.update(i))}}}getUniforms(t){return{filterFlags:{texture:this._getTexture(t,i.FilterFlags),unit:s},animation:{texture:this._getTexture(t,i.Animation),unit:r},gpgpu:{texture:this._getTexture(t,i.GPGPU),unit:a},localTimeOrigin:{texture:this._getTexture(t,i.LocalTimeOrigin),unit:n},visualVariableData:{texture:this._getTexture(t,i.VV),unit:u},dataDriven0:{texture:this._getTexture(t,i.DD0),unit:h},dataDriven1:{texture:this._getTexture(t,i.DD1),unit:o},dataDriven2:{texture:this._getTexture(t,i.DD2),unit:l},size:this.size}}_getTexture(t,e){const i=this._data?.[e];return i?(i.updateTexture(t,this._version),i.getTexture(t)):this._getDefaultTexture(t)}_getDefaultTexture(t){if(null==this._defaultTexture){const e=new b;e.wrapMode=_.CLAMP_TO_EDGE,e.samplingMode=c.NEAREST,e.width=1,e.height=1,this._defaultTexture=new f(t,e,new Uint8Array(4))}return this._defaultTexture}}export{y as AttributeStoreView};