@arcgis/core 4.22.0-next.20211021 → 4.22.0-next.20211025

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 (440) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/00ac1ce56f9885a8be83.js +1 -0
  3. package/assets/esri/core/workers/chunks/01c9afe41ab4ccc597c9.js +1 -0
  4. package/assets/esri/core/workers/chunks/02a3d14adc504a51fa24.js +1 -0
  5. package/assets/esri/core/workers/chunks/035a9ab0202d5386b782.js +1 -0
  6. package/assets/esri/core/workers/chunks/062bace5505f13689c7d.js +1 -0
  7. package/assets/esri/core/workers/chunks/06c7745d813bcb540ce8.js +1 -0
  8. package/assets/esri/core/workers/chunks/0950b488a60b2abc21fc.js +1 -0
  9. package/assets/esri/core/workers/chunks/0af396f2e0de681113ef.js +1 -0
  10. package/assets/esri/core/workers/chunks/131838059f0f81d8eaee.js +1 -0
  11. package/assets/esri/core/workers/chunks/146cba0d172ec2f4eba2.js +1 -0
  12. package/assets/esri/core/workers/chunks/17e49c0dfa5a5a6213e2.js +1 -0
  13. package/assets/esri/core/workers/chunks/1a0b08190274725dc956.js +1 -0
  14. package/assets/esri/core/workers/chunks/1add7f0779accdf8d204.js +1 -0
  15. package/assets/esri/core/workers/chunks/20b81d11e6286d347bfc.js +1 -0
  16. package/assets/esri/core/workers/chunks/{e596bd3de960d1dc1c57.js → 2207580a78ee292ed9b8.js} +1 -1
  17. package/assets/esri/core/workers/chunks/2d3646a83465c75986f9.js +1 -0
  18. package/assets/esri/core/workers/chunks/2d38ee3ef3ebe32a1194.js +1 -0
  19. package/assets/esri/core/workers/chunks/3737dcc3c0dea3ca05d5.js +1 -0
  20. package/assets/esri/core/workers/chunks/3e2042e70647c1afa6aa.js +1 -0
  21. package/assets/esri/core/workers/chunks/3ebfaab2855a2236a95d.js +1 -0
  22. package/assets/esri/core/workers/chunks/{d6fe616192a8efbfbc3e.js → 440f8101402a4c0d7019.js} +1 -1
  23. package/assets/esri/core/workers/chunks/4587d770767966985e22.js +1 -0
  24. package/assets/esri/core/workers/chunks/487b8892fae85810a8c0.js +1 -0
  25. package/assets/esri/core/workers/chunks/4901a78f32c3ea6b823b.js +1 -0
  26. package/assets/esri/core/workers/chunks/496fe47fc4d28e1a716d.js +1 -0
  27. package/assets/esri/core/workers/chunks/{9f22f47d4b2e72d7bdcf.js → 4c010119c24510ea31bb.js} +2 -2
  28. package/assets/esri/core/workers/chunks/{9f22f47d4b2e72d7bdcf.js.LICENSE.txt → 4c010119c24510ea31bb.js.LICENSE.txt} +0 -0
  29. package/assets/esri/core/workers/chunks/4f5076e1f2b18ce8156d.js +1 -0
  30. package/assets/esri/core/workers/chunks/{f291ebc4b089bd1f0a3f.js → 50e86a6bb13042b1dbac.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{64d9a062c1f1ac08a3ac.js → 565020b1c02a8cb33c2b.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{d78c60a22f76df7c48c7.js → 59640d78295e2e363f18.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{a0356f320a1b2fbd03f0.js → 5ac2b2598245aa17cdbd.js} +1 -1
  34. package/assets/esri/core/workers/chunks/5b4a8cce5601cc92c8a3.js +1 -0
  35. package/assets/esri/core/workers/chunks/5b92d5d4049622531109.js +1 -0
  36. package/assets/esri/core/workers/chunks/{751c1a2838b54a74a9a6.js → 5f3caa0ddb215342c728.js} +2 -2
  37. package/assets/esri/core/workers/chunks/615e995d5ce8fa044b09.js +1 -0
  38. package/assets/esri/core/workers/chunks/62a2453699e0dd2393b9.js +1 -0
  39. package/assets/esri/core/workers/chunks/67013547be1a7ae1670a.js +1 -0
  40. package/assets/esri/core/workers/chunks/67eddf4808f8888faeb4.js +1 -0
  41. package/assets/esri/core/workers/chunks/695dbedff2340aa019ba.js +1 -0
  42. package/assets/esri/core/workers/chunks/6a7e388c94206d2f61ff.js +1 -0
  43. package/assets/esri/core/workers/chunks/6e22b69d55e791ab3d9a.js +1 -0
  44. package/assets/esri/core/workers/chunks/71e6c0c5ef0aa7eb1703.js +1 -0
  45. package/assets/esri/core/workers/chunks/7a74e230439c5111f852.js +1 -0
  46. package/assets/esri/core/workers/chunks/7e76a8e6fa67e607d09e.js +1 -0
  47. package/assets/esri/core/workers/chunks/7fe4985ca0cb3e6d35c6.js +1 -0
  48. package/assets/esri/core/workers/chunks/8027330714ff5ffb020e.js +1 -0
  49. package/assets/esri/core/workers/chunks/844b564d1a422a17f6ac.js +1 -0
  50. package/assets/esri/core/workers/chunks/856f9281a08cb032238e.js +1 -0
  51. package/assets/esri/core/workers/chunks/89b4983de872780e9aa1.js +1 -0
  52. package/assets/esri/core/workers/chunks/8f3bc0cd2c2b01ab80cd.js +1 -0
  53. package/assets/esri/core/workers/chunks/8fd912e325ccd48b98a9.js +1 -0
  54. package/assets/esri/core/workers/chunks/901907a5c01f0fd1478f.js +1 -0
  55. package/assets/esri/core/workers/chunks/92a0b88a14c92239df8a.js +1 -0
  56. package/assets/esri/core/workers/chunks/972e9aeb3c29c9bf441a.js +1 -0
  57. package/assets/esri/core/workers/chunks/9758c34ce61c3714515a.js +1 -0
  58. package/assets/esri/core/workers/chunks/{457ea4feaa006d60c6b1.js → 9a04d087a29f0f3937a3.js} +1 -1
  59. package/assets/esri/core/workers/chunks/9b0bb171224b35ce2031.js +1 -0
  60. package/assets/esri/core/workers/chunks/9cbe7afdaef8720dfc8d.js +1 -0
  61. package/assets/esri/core/workers/chunks/9ccde5b6562f0007fe45.js +1 -0
  62. package/assets/esri/core/workers/chunks/9d320bbeedeea15522ab.js +1 -0
  63. package/assets/esri/core/workers/chunks/a001b3b4527817548094.js +1 -0
  64. package/assets/esri/core/workers/chunks/{197b72bca45065e0eb4a.js → a0c580d4a1915ddd3fe4.js} +1 -1
  65. package/assets/esri/core/workers/chunks/a4a9c15929b43d83701f.js +1 -0
  66. package/assets/esri/core/workers/chunks/a54d11f44721f808b82f.js +1 -0
  67. package/assets/esri/core/workers/chunks/a646a11673d513c00e7a.js +1 -0
  68. package/assets/esri/core/workers/chunks/a792e2bc7cafdc29f05e.js +1 -0
  69. package/assets/esri/core/workers/chunks/acae1771697034f265b1.js +1 -0
  70. package/assets/esri/core/workers/chunks/af2ee804a9c63eea610c.js +1 -0
  71. package/assets/esri/core/workers/chunks/b28b487047da3aeef3fd.js +1 -0
  72. package/assets/esri/core/workers/chunks/b3e57824a5855cb37a96.js +1 -0
  73. package/assets/esri/core/workers/chunks/b89449ead32e4cd21edd.js +1 -0
  74. package/assets/esri/core/workers/chunks/b99891ed5a02cab02173.js +1 -0
  75. package/assets/esri/core/workers/chunks/bac84bc621be73a7a4bc.js +1 -0
  76. package/assets/esri/core/workers/chunks/{25037dcf8a0c72b7b647.js → bbe068388167e9dd0c11.js} +1 -1
  77. package/assets/esri/core/workers/chunks/c271a1857bcc4e9a36dd.js +1 -0
  78. package/assets/esri/core/workers/chunks/{eb3035e49a45ecc82575.js → c5030664720fcdc6d85e.js} +1 -1
  79. package/assets/esri/core/workers/chunks/c534ed122f8a1202d3a3.js +1 -0
  80. package/assets/esri/core/workers/chunks/c5ef2e28b0c539ddb6a7.js +1 -0
  81. package/assets/esri/core/workers/chunks/c65e5ccfae03d148d82b.js +1 -0
  82. package/assets/esri/core/workers/chunks/c91660f3982be4e03705.js +1 -0
  83. package/assets/esri/core/workers/chunks/ce93113b99bdbeddd07b.js +1 -0
  84. package/assets/esri/core/workers/chunks/cf2d408e669cfa2c65be.js +1 -0
  85. package/assets/esri/core/workers/chunks/d08f63ffeecefa02ad91.js +1 -0
  86. package/assets/esri/core/workers/chunks/{8d33644192c01e5416b4.js → d1a71b58ef62e71979c5.js} +1 -1
  87. package/assets/esri/core/workers/chunks/d30eade5afecd334f6cb.js +1 -0
  88. package/assets/esri/core/workers/chunks/d8782d0856b9d815cb6c.js +1 -0
  89. package/assets/esri/core/workers/chunks/db16c21b650001502e6c.js +1 -0
  90. package/assets/esri/core/workers/chunks/db18110c57253a31ac96.js +1 -0
  91. package/assets/esri/core/workers/chunks/dbaa5fb466d6c0214f24.js +1 -0
  92. package/assets/esri/core/workers/chunks/deae370788a7aacf4dd5.js +1 -0
  93. package/assets/esri/core/workers/chunks/e6ca132e1eeea3aa174e.js +1 -0
  94. package/assets/esri/core/workers/chunks/e878ccc431729ef3360f.js +1 -0
  95. package/assets/esri/core/workers/chunks/eb124f15ad4b9193f00a.js +1 -0
  96. package/assets/esri/core/workers/chunks/ebc71c06c1c22aaef54e.js +1 -0
  97. package/assets/esri/core/workers/chunks/f183da283af0836421ab.js +1 -0
  98. package/assets/esri/core/workers/chunks/f42bdc2a134833d33b4e.js +1 -0
  99. package/assets/esri/core/workers/chunks/{736d628cda4e02d40337.js → f8612c2fc5739e98be58.js} +1 -1
  100. package/assets/esri/core/workers/chunks/f965e3e5f6f4f9ba54ac.js +1 -0
  101. package/assets/esri/core/workers/chunks/fa4089640f480b69962e.js +1 -0
  102. package/assets/esri/core/workers/chunks/fb219563e5169ea67d68.js +1 -0
  103. package/assets/esri/libs/i3s/i3s.wasm +0 -0
  104. package/chunks/ChapmanAtmosphere.glsl.js +56 -77
  105. package/chunks/Clouds.glsl.js +1 -1
  106. package/chunks/Pattern.glsl.js +9 -11
  107. package/chunks/RibbonLine.glsl.js +60 -68
  108. package/chunks/i3s.js +1 -1
  109. package/chunks/mat4.js +1 -1
  110. package/chunks/vec3.js +1 -1
  111. package/core/Collection.js +1 -1
  112. package/core/Loadable.js +1 -1
  113. package/core/accessorSupport/ensureType.js +1 -1
  114. package/core/promiseUtils.js +1 -1
  115. package/core/support/OwningCollection.js +1 -1
  116. package/core/workers/RemoteClient.js +1 -1
  117. package/core/workers/WorkerOwner.js +1 -1
  118. package/core/workers/workers.js +2 -2
  119. package/geometry/projection.js +1 -1
  120. package/identity/IdentityManagerBase.js +1 -1
  121. package/interfaces.d.ts +205 -497
  122. package/layers/ElevationLayer.js +1 -1
  123. package/layers/GeoJSONLayer.js +1 -1
  124. package/layers/ImageryTileLayer.js +1 -1
  125. package/layers/VectorTileLayer.js +1 -1
  126. package/layers/VoxelWasmPerScene.js +1 -1
  127. package/layers/WCSLayer.js +1 -1
  128. package/layers/analyses/AreaMeasurement3D.js +1 -1
  129. package/layers/analyses/DirectLineMeasurement3D.js +1 -1
  130. package/layers/analyses/Slice.js +1 -1
  131. package/layers/effects/EffectList.js +1 -1
  132. package/layers/effects/effects.js +1 -1
  133. package/layers/effects/jsonUtils.js +1 -1
  134. package/layers/effects/parser.js +1 -1
  135. package/layers/effects/utils.js +5 -0
  136. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  137. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  138. package/layers/graphics/data/QueryEngine.js +1 -1
  139. package/layers/graphics/data/QueryEngineResult.js +1 -1
  140. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  141. package/layers/mixins/ImageryTileMixin.js +1 -1
  142. package/layers/support/RasterWorker.js +1 -1
  143. package/layers/support/TilemapCache.js +1 -1
  144. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  145. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  146. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  147. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  148. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  149. package/package.json +2 -2
  150. package/portal/support/portalLayers.js +1 -1
  151. package/request.js +1 -1
  152. package/smartMapping/renderers/support/utils.js +1 -1
  153. package/smartMapping/statistics/support/WorkerClient.js +1 -1
  154. package/smartMapping/statistics/support/statsWorker.js +1 -1
  155. package/smartMapping/statistics/support/utils.js +1 -1
  156. package/smartMapping/support/adapters/CSVLayerAdapter.js +1 -1
  157. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  158. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  159. package/smartMapping/support/adapters/support/utils.js +1 -1
  160. package/statistics/utils.js +1 -1
  161. package/support/GraphicsCollection.js +1 -1
  162. package/support/revision.js +1 -1
  163. package/symbols/FillSymbol3DLayer.js +1 -1
  164. package/symbols/IconSymbol3DLayer.js +1 -1
  165. package/symbols/LineSymbol3DLayer.js +1 -1
  166. package/symbols/patterns/LinePattern3D.js +5 -0
  167. package/symbols/patterns/LineStylePattern3D.d.ts +4 -0
  168. package/symbols/patterns/LineStylePattern3D.js +5 -0
  169. package/symbols/patterns/StylePattern3D.js +1 -1
  170. package/symbols/patterns/lineStyles.js +5 -0
  171. package/symbols/patterns/utils.js +1 -1
  172. package/symbols/support/Symbol3DFillMaterial.js +1 -1
  173. package/symbols/support/Symbol3DIconOutline.js +5 -0
  174. package/symbols/support/Symbol3DMaterial.js +1 -1
  175. package/symbols/support/Symbol3DOutline.js +1 -1
  176. package/symbols/support/defaults3D.js +1 -1
  177. package/symbols/support/previewSymbol3D.js +1 -1
  178. package/symbols/support/symbolLayerUtils3D.js +1 -1
  179. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  180. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  181. package/views/2d/engine/vectorTiles/style/StyleRepository.js +1 -1
  182. package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
  183. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  184. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  185. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  186. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  187. package/views/2d/layers/features/controllers/EditsQueue.js +1 -1
  188. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  189. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  190. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  191. package/views/2d/layers/support/FeatureLayerProxy.js +1 -1
  192. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  193. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  194. package/views/3d/environment/CloudsGenerator.js +1 -1
  195. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  196. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  197. package/views/3d/environment/SimpleAtmosphere.js +1 -1
  198. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  199. package/views/3d/externalRenderers.js +1 -1
  200. package/views/3d/interactive/Manipulator3D.js +1 -1
  201. package/views/3d/interactive/analysisTools/slice/SliceTool.js +1 -1
  202. package/views/3d/interactive/analysisTools/slice/images/Factory.js +5 -0
  203. package/views/3d/interactive/analysisTools/slice/sliceToolConfig.js +1 -1
  204. package/views/3d/interactive/analysisTools/slice/sliceToolUtils.js +1 -1
  205. package/views/3d/interactive/editingTools/settings.js +1 -1
  206. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  207. package/views/3d/interactive/graphics/Slice/SliceController.js +1 -1
  208. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  209. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  210. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  211. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  212. package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
  213. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  214. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  215. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  216. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  217. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  218. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  219. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  220. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  221. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  222. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  223. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  224. package/views/3d/layers/I3SMeshView3D.js +1 -1
  225. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  226. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  227. package/views/3d/layers/analyses/AreaMeasurement3D/AreaMeasurementView3D.js +1 -1
  228. package/views/3d/layers/analyses/AreaMeasurement3D/support/AreaMeasurementPathHelper.js +1 -1
  229. package/views/3d/layers/analyses/AreaMeasurement3D/support/AreaMeasurementVisualization.js +1 -1
  230. package/views/3d/layers/analyses/DirectLineMeasurement3D/DirectLineMeasurementView3D.js +1 -1
  231. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  232. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  233. package/views/3d/layers/graphics/ElevationQuery.js +1 -1
  234. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  235. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  236. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  237. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  238. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  239. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  240. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  241. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  242. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  243. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  244. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  245. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  246. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  247. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  248. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  249. package/views/3d/layers/graphics/Labeler.js +1 -1
  250. package/views/3d/layers/graphics/Loadable.js +1 -1
  251. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  252. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  253. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  254. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  255. package/views/3d/layers/graphics/pointUtils.js +1 -1
  256. package/views/3d/layers/i3s/I3SAttributeOverrides.js +1 -1
  257. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  258. package/views/3d/layers/i3s/I3SStreamDataController.js +1 -1
  259. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  260. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  261. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  262. package/views/3d/layers/support/patternUtils.js +1 -1
  263. package/views/3d/state/GoToOperation.js +1 -1
  264. package/views/3d/state/ViewStateManager.js +1 -1
  265. package/views/3d/support/LaserLineRenderer.js +1 -1
  266. package/views/3d/support/SharedSymbolResources.js +1 -1
  267. package/views/3d/support/StreamDataLoader.js +1 -1
  268. package/views/3d/support/StreamTextureCollection.js +5 -0
  269. package/views/3d/support/TextureCollection.js +1 -1
  270. package/views/3d/support/debugFlags.js +1 -1
  271. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  272. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  273. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  274. package/views/3d/terrain/OverlayManager.js +1 -1
  275. package/views/3d/terrain/OverlayRenderTarget.js +1 -1
  276. package/views/3d/terrain/OverlayRenderer.js +1 -1
  277. package/views/3d/terrain/Tile.js +1 -1
  278. package/views/3d/webgl-engine/Stage.js +1 -1
  279. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  280. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +13 -12
  281. package/views/3d/webgl-engine/core/shaderLibrary/shading/Reprojection.glsl.js +1 -1
  282. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +10 -3
  283. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js +1 -1
  284. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  285. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  286. package/views/3d/webgl-engine/lib/GLMaterialTexture.js +1 -1
  287. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  288. package/views/3d/webgl-engine/lib/Material.js +1 -1
  289. package/views/3d/webgl-engine/lib/ModelDirtySet.js +1 -1
  290. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  291. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  292. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  293. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  294. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  295. package/views/3d/webgl-engine/lib/TextTexture.js +1 -1
  296. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  297. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  298. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  299. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  300. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  301. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  302. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  303. package/views/3d/webgl-engine/lib/lodRendering/LodLevel.js +1 -1
  304. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  305. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  306. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  307. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  308. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  309. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  310. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  311. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  312. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  313. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  314. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  315. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  316. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  317. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  318. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  319. package/views/3d/webgl-engine/materials/WaterGLMaterial.js +1 -1
  320. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  321. package/views/3d/webgl-engine/materials/lineStippleUtils.js +1 -1
  322. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  323. package/views/3d/webgl-engine/parts/Model.js +1 -1
  324. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  325. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  326. package/views/LayerViewManager.js +1 -1
  327. package/views/SceneView.js +1 -1
  328. package/views/ToolViewManager.js +1 -1
  329. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  330. package/views/support/AllocationTracer.js +1 -1
  331. package/views/support/DefaultsFromMap.js +1 -1
  332. package/views/support/QueueProcessor.js +1 -1
  333. package/views/webgl/capabilities/load.js +1 -1
  334. package/webscene/Slide.js +1 -1
  335. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  336. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  337. package/widgets/BuildingExplorer/support/layerUtils.js +1 -1
  338. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  339. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  340. package/widgets/Editor/UpdateWorkflow.js +1 -1
  341. package/widgets/Feature/FeatureViewModel.js +1 -1
  342. package/widgets/Home/HomeViewModel.js +1 -1
  343. package/widgets/Locate/LocateViewModel.js +1 -1
  344. package/widgets/Popup/PopupViewModel.js +1 -1
  345. package/widgets/Search/SearchViewModel.js +1 -1
  346. package/widgets/Search.js +1 -1
  347. package/widgets/Sketch/SketchViewModel.js +1 -1
  348. package/widgets/Slice/SliceViewModel.js +1 -1
  349. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  350. package/assets/esri/core/workers/chunks/0283801d442984997abe.js +0 -1
  351. package/assets/esri/core/workers/chunks/0419e14a520b8fcf3e7a.js +0 -1
  352. package/assets/esri/core/workers/chunks/05318446b6a40caea361.js +0 -1
  353. package/assets/esri/core/workers/chunks/09e714d4381649348ac9.js +0 -1
  354. package/assets/esri/core/workers/chunks/0cecd668b9d5d3f83293.js +0 -1
  355. package/assets/esri/core/workers/chunks/13a73a88efd4f464173e.js +0 -1
  356. package/assets/esri/core/workers/chunks/1576727e8174d672555b.js +0 -1
  357. package/assets/esri/core/workers/chunks/1a3cbeb0a53d03a51dad.js +0 -1
  358. package/assets/esri/core/workers/chunks/1b8524b617bfc6fe422c.js +0 -1
  359. package/assets/esri/core/workers/chunks/1dc1d750046912ff6cef.js +0 -1
  360. package/assets/esri/core/workers/chunks/21fa174c114640be5e40.js +0 -1
  361. package/assets/esri/core/workers/chunks/2a3f6e56079620421a02.js +0 -1
  362. package/assets/esri/core/workers/chunks/2a5bcc73e55986ad93fe.js +0 -1
  363. package/assets/esri/core/workers/chunks/2a6f2e3d639aae491171.js +0 -1
  364. package/assets/esri/core/workers/chunks/2c17d1bad17bcee53f7d.js +0 -1
  365. package/assets/esri/core/workers/chunks/2cea27a0d07aa9a88ad4.js +0 -1
  366. package/assets/esri/core/workers/chunks/2e193d97d199b29b00c2.js +0 -1
  367. package/assets/esri/core/workers/chunks/2eb41fdf0d0a3b0c3232.js +0 -1
  368. package/assets/esri/core/workers/chunks/2f09ea639ca5d1d6ca7e.js +0 -1
  369. package/assets/esri/core/workers/chunks/2fb847ab1440bd1bdf15.js +0 -1
  370. package/assets/esri/core/workers/chunks/402d22ebbae608760b4f.js +0 -1
  371. package/assets/esri/core/workers/chunks/44daef7f0cbc6f6af09f.js +0 -1
  372. package/assets/esri/core/workers/chunks/46899156159e398c693f.js +0 -1
  373. package/assets/esri/core/workers/chunks/46bf8921db25845c63c0.js +0 -1
  374. package/assets/esri/core/workers/chunks/4eb23554e375350f73b5.js +0 -1
  375. package/assets/esri/core/workers/chunks/551917be63a513dfa4de.js +0 -1
  376. package/assets/esri/core/workers/chunks/564f6f5484bcb13ebb2b.js +0 -1
  377. package/assets/esri/core/workers/chunks/61df67ae47b7fb5875d9.js +0 -1
  378. package/assets/esri/core/workers/chunks/62642a8fc7bafe339984.js +0 -1
  379. package/assets/esri/core/workers/chunks/6304f4e53027df04eb8f.js +0 -1
  380. package/assets/esri/core/workers/chunks/6331987617ad166ea098.js +0 -1
  381. package/assets/esri/core/workers/chunks/6b13fcbc71c0088d317e.js +0 -1
  382. package/assets/esri/core/workers/chunks/6f7a6841e7269d2764ad.js +0 -1
  383. package/assets/esri/core/workers/chunks/70110efd2de23d9a5263.js +0 -1
  384. package/assets/esri/core/workers/chunks/7eae3f0588cde44fce39.js +0 -1
  385. package/assets/esri/core/workers/chunks/80d3c7a429c6412f1a8d.js +0 -1
  386. package/assets/esri/core/workers/chunks/80deebdf54bea04a0889.js +0 -1
  387. package/assets/esri/core/workers/chunks/81aa5fe7dcb4fdeb0974.js +0 -1
  388. package/assets/esri/core/workers/chunks/840d08b41913cad4df89.js +0 -1
  389. package/assets/esri/core/workers/chunks/85d154aeb511c5d70bb1.js +0 -1
  390. package/assets/esri/core/workers/chunks/8681e99e2bc9ece61c43.js +0 -1
  391. package/assets/esri/core/workers/chunks/8e5ef967f6518f4c93b1.js +0 -1
  392. package/assets/esri/core/workers/chunks/8edd7f70c8b95c34125c.js +0 -1
  393. package/assets/esri/core/workers/chunks/9044a7b90a53312b6392.js +0 -1
  394. package/assets/esri/core/workers/chunks/905b4dfc1ce57a225fa4.js +0 -1
  395. package/assets/esri/core/workers/chunks/945f90b31ebfae623ea0.js +0 -1
  396. package/assets/esri/core/workers/chunks/9943fd69b67cd1871d68.js +0 -1
  397. package/assets/esri/core/workers/chunks/9ad91c23480ffb656030.js +0 -1
  398. package/assets/esri/core/workers/chunks/9d103681372ab01a4147.js +0 -1
  399. package/assets/esri/core/workers/chunks/9d3230f59b4c4d1b2713.js +0 -1
  400. package/assets/esri/core/workers/chunks/9db75bc0980d16b730a1.js +0 -1
  401. package/assets/esri/core/workers/chunks/a0659b8bdc067da7badd.js +0 -1
  402. package/assets/esri/core/workers/chunks/a480ee9a994410177961.js +0 -1
  403. package/assets/esri/core/workers/chunks/a9b279975d7df0f295d7.js +0 -1
  404. package/assets/esri/core/workers/chunks/aa3abaa5ad4a5a3bcb84.js +0 -1
  405. package/assets/esri/core/workers/chunks/aa8e607f908297786675.js +0 -1
  406. package/assets/esri/core/workers/chunks/ab5a302b5f62d38293f9.js +0 -1
  407. package/assets/esri/core/workers/chunks/abd6a84396e0eb3f01ad.js +0 -1
  408. package/assets/esri/core/workers/chunks/abe9f8516b03a3fb0477.js +0 -1
  409. package/assets/esri/core/workers/chunks/aff6aa5c7f75f8e052d9.js +0 -1
  410. package/assets/esri/core/workers/chunks/b601cc5304b132536239.js +0 -1
  411. package/assets/esri/core/workers/chunks/b85f614ddbddd3c3007e.js +0 -1
  412. package/assets/esri/core/workers/chunks/b944f4ab25a691b3e611.js +0 -1
  413. package/assets/esri/core/workers/chunks/bbdacddb61e651ca0098.js +0 -1
  414. package/assets/esri/core/workers/chunks/c2fa728e805637a1783e.js +0 -1
  415. package/assets/esri/core/workers/chunks/c901f5f85d962254fc2c.js +0 -1
  416. package/assets/esri/core/workers/chunks/ca173b908d89a4e334f6.js +0 -1
  417. package/assets/esri/core/workers/chunks/cc2ef3bfa1f614d7452c.js +0 -1
  418. package/assets/esri/core/workers/chunks/cdb32a9ac9f5804c4212.js +0 -1
  419. package/assets/esri/core/workers/chunks/ce9a4997973da80141a5.js +0 -1
  420. package/assets/esri/core/workers/chunks/d0674b50a358d3bb9db2.js +0 -1
  421. package/assets/esri/core/workers/chunks/d18b7b4b3b9bea7204b0.js +0 -1
  422. package/assets/esri/core/workers/chunks/d2ce983f7babdf18a0ed.js +0 -1
  423. package/assets/esri/core/workers/chunks/d38a0d867dc6cecdc551.js +0 -1
  424. package/assets/esri/core/workers/chunks/e39ca33e9e463c1d6060.js +0 -1
  425. package/assets/esri/core/workers/chunks/e471d103205018a5cf7f.js +0 -1
  426. package/assets/esri/core/workers/chunks/e542fb044fc96f7e8af2.js +0 -1
  427. package/assets/esri/core/workers/chunks/e94e00a28591337b2def.js +0 -1
  428. package/assets/esri/core/workers/chunks/eb2709ccbc001f42ac1b.js +0 -1
  429. package/assets/esri/core/workers/chunks/f905511ca5f9b59fc17f.js +0 -1
  430. package/assets/esri/core/workers/chunks/f910e80dd87727af5184.js +0 -1
  431. package/assets/esri/core/workers/chunks/f9300a24305b0af1d227.js +0 -1
  432. package/assets/esri/core/workers/chunks/fa1e1ac5b3ef7bdf8a78.js +0 -1
  433. package/assets/esri/core/workers/chunks/fce76a84c7d25d8d47e8.js +0 -1
  434. package/assets/esri/core/workers/chunks/fef4f97fbe861a1b60e8.js +0 -1
  435. package/layers/AreaMeasurementLayer.d.ts +0 -4
  436. package/layers/DirectLineMeasurementLayer.d.ts +0 -4
  437. package/symbols/support/symbolPreview.d.ts +0 -4
  438. package/symbols/support/symbolPreview.js +0 -5
  439. package/views/3d/layers/AreaMeasurementLayerView3D.d.ts +0 -4
  440. package/views/3d/layers/DirectLineMeasurementLayerView3D.d.ts +0 -4
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{result as i}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import"../../../core/has.js";import s from"../../../core/Error.js";import a from"../../../core/Handles.js";import{clone as o}from"../../../core/lang.js";import n from"../../../core/Logger.js";import{isSome as l,destroyMaybe as h,removeMaybe as c,isNone as u}from"../../../core/maybe.js";import{EsriPromiseMixin as d}from"../../../core/Promise.js";import{createAbortController as m,isAbortError as p,eachAlways as f}from"../../../core/promiseUtils.js";import{whenOnce as y,init as g}from"../../../core/watchUtils.js";import{property as x}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as F}from"../../../core/accessorSupport/decorators/subclass.js";import{isHostedAgolService as v}from"../../support/arcgisLayerUrl.js";import{projectGeometry as T}from"../../../portal/support/geometryServiceUtils.js";import E from"../../../rest/support/StatisticDefinition.js";import{FeatureTileFetcher3D as w}from"../../../views/3d/layers/support/FeatureTileFetcher3D.js";import{FeatureTileFetcher3DDebugger as C}from"../../../views/3d/layers/support/FeatureTileFetcher3DDebugger.js";import D from"../../../views/3d/support/debugFlags.js";import{WatchUpdatingTracking as b}from"../../../views/support/WatchUpdatingTracking.js";const S=n.getLogger("esri.layers.graphics.controllers.FeatureTileController3D");let _=class extends(d(t)){constructor(e){super(e),this.type="feature-tile-3d",this.watchUpdatingTracking=new b,this.serviceDataExtent=null,this.serviceDataCount=A.NO_SERVICE_DATA_COUNT,this.vertexLimitExceeded=!1,this.displayFeatureLimit=null,this.suspended=!1,this.tileFetcher=null,this.handles=new a,this.fetchDataInfoPromise=null,this.fetchDataInfoAbortController=null,this.lifeCycleAbortController=m()}set extent(e){if(e&&!e.spatialReference.equals(this.layerView.view.spatialReference))return void S.error("#extent=","extent needs to be in the same spatial reference as the view");const t=this._get("extent");if(t===e)return;if(t&&e&&t.equals(e))return;const i=e?e.clone():null;this._set("extent",i)}get updating(){return!!(l(this.tileFetcher)&&this.tileFetcher.updating||null!=this.fetchDataInfoPromise||"tiles"===this.mode&&this.layerView.view.featureTiles&&this.layerView.view.featureTiles.updating||this.watchUpdatingTracking&&this.watchUpdatingTracking.updating)}get updatingTotal(){return this.updating&&l(this.tileFetcher)?this.tileFetcher.updatingTotal:0}get updatingRemaining(){return this.updating&&l(this.tileFetcher)?this.tileFetcher.updatingRemaining:0}get expectedFeatureDiff(){return this.updating&&l(this.tileFetcher)?this.tileFetcher.expectedFeatureDiff:0}get memoryForUnusedFeatures(){return l(this.tileFetcher)?this.tileFetcher.memoryForUnusedFeatures:0}get maximumNumberOfFeaturesExceeded(){return!(!l(this.tileFetcher)||!this.tileFetcher.maximumNumberOfFeaturesExceeded)}get maximumNumberOfFeatures(){return l(this.displayFeatureLimit)?this.displayFeatureLimit.maximumNumberOfFeatures:0}set maximumNumberOfFeatures(e){e!==this.maximumNumberOfFeatures&&(null==e?this._clearOverride("maximumNumberOfFeatures"):this._override("maximumNumberOfFeatures",e))}get hasMaximumNumberOfFeaturesOverride(){return this._isOverridden("maximumNumberOfFeatures")}get mode(){var e,t;const i=this.layerView.layer;if("feature"===i.type&&l(i.infoFor3D))return"snapshot";if(!1===(null==(e=this.layerView.view.qualitySettings)||null==(t=e.graphics3D)?void 0:t.snapshotAvailable)||this.serviceDataCount===A.NO_SERVICE_DATA_COUNT||this.vertexLimitExceeded)return"tiles";const r=this.layerView.view,s=r&&r.featureTiles,a=s&&s.tilingScheme;if(i&&i.minScale&&this.serviceDataExtent&&a){const e=this.approximateExtentSizeAtScale(i.minScale,a);if((this.serviceDataExtent.width/e+this.serviceDataExtent.height/e)/2>A.MAX_SNAPSHOT_MIN_SCALE_FACTOR)return"tiles"}return!this.maximumNumberOfFeatures||this.serviceDataCount<=this.maximumNumberOfFeatures?"snapshot":"tiles"}get maxTotalSnapshotVertices(){const e=this._get("maxTotalSnapshotVertices")||0,t="snapshot"===this.mode&&l(this.tileFetcher)&&this.tileFetcher.totalVertices||0;return Math.max(e,t)}approximateExtentSizeAtScale(e,t){const i=this.layerView.view,r=Math.ceil((i.width/t.pixelSize+i.height/t.pixelSize)/2),s=t.levels[0];return r*((s.tileSize[0]/(s.scale/e)+s.tileSize[1]/(s.scale/e))/2)}get tileDescriptors(){return"snapshot"===this.mode?new r([{id:"dummy-tile-full-extent",lij:[0,0,0]}]):this.layerView.view.featureTiles?this.layerView.view.featureTiles.tiles:new r}get test(){return{fetchDataInfoPromise:this.fetchDataInfoPromise,tileFetcher:this.tileFetcher}}initialize(){this.watchUpdatingTracking.add(this,"vertexLimitInfo",(()=>this.watchUpdatingTracking.addPromise(this.updateVertexLimitExceeded(null,this.lifeCycleAbortController.signal)))),this.watchUpdatingTracking.add(this,"mode",(()=>this.modeChanged()),2),this.addResolvingPromise(Promise.resolve().then((()=>this.verifyCapabilities())).then((()=>this.watchUpdatingTracking.addPromise(this.fetchServiceDataInfo()))).then((()=>this.initializeTileFetcher())))}verifyCapabilities(){const e=this.layerView.layer;if(!e.get("capabilities.operations.supportsQuery")&&"ogc-feature"!==e.type)throw new s("graphicscontroller:query-capability-required","Service requires query capabilities to be used as a feature layer",{layer:e})}destroy(){this.cancelFetchServiceDataInfo(),this.tileFetcher=h(this.tileFetcher),this.handles=h(this.handles),this.tilesHandle=c(this.tilesHandle),this.lifeCycleAbortController&&(this.lifeCycleAbortController.abort(),this.lifeCycleAbortController=null),this.watchUpdatingTracking.destroy(),this._set("watchUpdatingTracking",null)}suspend(){this.suspended||(this.suspended=!0,l(this.tileFetcher)&&this.tileFetcher.suspend())}resume(){this.suspended&&(this.suspended=!1,l(this.tileFetcher)&&this.tileFetcher.resume())}restart(){const e=()=>{l(this.tileFetcher)&&this.tileFetcher.restart()};this.watchUpdatingTracking.addPromise(this.fetchServiceDataInfo().then(e,e))}refetch(){const e=()=>{l(this.tileFetcher)&&this.tileFetcher.refetch()};this.watchUpdatingTracking.addPromise(this.fetchServiceDataInfo().then(e,e))}initializeTileFetcher(){const e=this.layerView.view;if(!e)return;const t=y(e.featureTiles,"tilingScheme",this.lifeCycleAbortController.signal);this.watchUpdatingTracking.addPromise(t),t.then((()=>{const{layerView:t,tileDescriptors:i}=this,r=t.layer,s=new w({context:this.context,filterExtent:this.extent,tileDescriptors:i,features:this.graphics});this.tileFetcher=s,this.suspended?this.tileFetcher.suspend():this.tileFetcher.resume();const a=this.layerView.view.resourceController;a&&(this.handles.add(a.memoryController.events.on("quality-changed",(e=>{s.memoryFactor=e}))),this.tileFetcher.memoryFactor=a.memoryController.memoryFactor);const o="polygon"===this.context.geometryType?"polygonLodFactor":"polyline"===this.context.geometryType?"polylineLodFactor":null;o&&this.handles.add(g(this.layerView.view,"qualitySettings.graphics3D."+o,(e=>{s.lodFactor=e||1})));const n=e=>{s.maximumNumberOfFeatures=e,s.useTileCount=this.serviceDataCount>e},l=e=>s.useTileCount=e>this.maximumNumberOfFeatures;this.watchUpdatingTracking.add(r,"createQueryVersion",(()=>this.dataFilterChanged())),this.watchUpdatingTracking.add(t,"availableFields",((e,t)=>this.availableFieldsChanged(t,e))),this.watchUpdatingTracking.add(t,"requiredFields",((e,t)=>this.requiredFieldsChanged(t,e))),this.handles.add([r.on("apply-edits",(e=>this.applyEdits(e))),this.watch("extent",(e=>s.filterExtent=e),!0),this.watch("tileDescriptors",(e=>s.tileDescriptors=e),!0),g(this,"maximumNumberOfFeatures",n,!0),g(this,"serviceDataCount",l,!0),g(D,"FEATURE_TILE_FETCH_SHOW_TILES",(t=>{t&&s&&!s.debugger?(s.debugger=new C(s,e.featureTiles.tilingScheme.toTileInfo(),e),s.debugger.update()):!t&&this.tileFetcher&&s.debugger&&(s.debugger.destroy(),s.debugger=null)}))]),this.supportsExceedsLimitQuery||this.watchUpdatingTracking.add(this,"maxTotalSnapshotVertices",(()=>this.watchUpdatingTracking.addPromise(this.updateVertexLimitExceeded(null,this.lifeCycleAbortController.signal))))})).catch((()=>{}))}modeChanged(){switch(this.mode){case"tiles":this.tilesHandle||(this.tilesHandle=this.layerView.view.featureTiles.addClient());break;default:S.warn("Unhandled feature layer mode "+this.mode);case"snapshot":l(this.tilesHandle)&&(this.tilesHandle.remove(),this.tilesHandle=null)}}dataFilterChanged(){this._set("maxTotalSnapshotVertices",0),this.notifyChange("maxTotalSnapshotVertices"),this.refetch()}applyEdits(e){u(this.tileFetcher)||this.tileFetcher.applyEdits(e).then((e=>{e&&(e.deletedFeatures.length||e.updatedFeatures.length||e.addedFeatures.length)&&this.watchUpdatingTracking.addPromise(this.updateServiceDataExtent(this.lifeCycleAbortController.signal))})).catch((e=>{if(!p(e))throw e}))}availableFieldsChanged(e,t){l(this.tileFetcher)&&N(this.tileFetcher.availableFields,t)&&this.refetch()}requiredFieldsChanged(e,t){l(this.tileFetcher)&&N(this.tileFetcher.availableFields,t)&&this.restart()}createVertexLimitExceededQuery(e){const t=this.layerView.layer,i=t.createQuery();return i.outStatistics=[new E({statisticType:"exceedslimit",maxVertexCount:e,outStatisticFieldName:"exceedslimit",maxPointCount:1e8,maxRecordCount:1e8})],t.capabilities.query.supportsCacheHint&&(i.cacheHint=!0),i}createDataInfoQuery(){const e=this.layerView.layer,t=e.createQuery();return t.outSpatialReference=this.layerView.view.spatialReference,e.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}fullExtentIsAccurate(){const e=this.layerView.layer;if(e.definitionExpression)return!1;switch(e.type){case"feature":return v(e.url);case"csv":case"geojson":case"ogc-feature":case"wfs":return!0;default:return}}async updateServiceDataExtent(e){try{await this.tryUpdateServiceDataExtent(e)}catch(t){p(t)||this._set("serviceDataExtent",o(this.layerView.fullExtentInLocalViewSpatialReference))}}async tryUpdateServiceDataExtent(e){const t=this.layerView,i=t.layer,r=i.capabilities.query.supportsExtent,s=o(t.fullExtentInLocalViewSpatialReference),a=i.fullExtent,n=this.fullExtentIsAccurate(),h=this.serviceDataCount;if(r&&h<=A.MAX_FEATURE_COUNT_FOR_EXTENT&&(!s||!n)&&"queryExtent"in i){const t=this.createDataInfoQuery(),r=await i.queryExtent(t,{timeout:A.QUERY_EXTENT_TIMEOUT,signal:e});this._set("serviceDataExtent",r.extent)}else if(s)this._set("serviceDataExtent",s);else if(l(a)){const r="portalItem"in i?i.portalItem:null,s=await T(a,t.view.spatialReference,r,e);this._set("serviceDataExtent",s)}else this._set("serviceDataExtent",null)}async updateServiceDataCount(e){const t=this.layerView.layer;if(!("queryFeatureCount"in t))return void this._set("serviceDataCount",A.NO_SERVICE_DATA_COUNT);const r=await i(t.queryFeatureCount(this.createDataInfoQuery(),{timeout:A.QUERY_STATISTICS_TIMEOUT,signal:e}));if(!0===r.ok)this._set("serviceDataCount",r.value);else{if(p(r.error))throw r.error;this._set("serviceDataCount",A.NO_SERVICE_DATA_COUNT)}}get vertexLimitInfo(){if(u(this.displayFeatureLimit)||u(this.displayFeatureLimit.averageSymbolComplexity))return null;const{averageSymbolComplexity:e,maximumTotalNumberOfPrimitives:t}=this.displayFeatureLimit,{primitivesPerCoordinate:i,primitivesPerFeature:r}=e,s=this._get("vertexLimitInfo");return u(s)||s.maximumTotalNumberOfPrimitives!==t||s.primitivesPerCoordinate!==i||s.primitivesPerFeature!==r?{primitivesPerCoordinate:i,primitivesPerFeature:r,maximumTotalNumberOfPrimitives:t}:s}get supportsExceedsLimitQuery(){const e=this.layerView.layer;return e.capabilities&&e.capabilities.operations&&e.capabilities.operations.supportsExceedsLimitStatistics}get minimumNumberOfVerticesForGeometry(){switch(this.layerView.layer.geometryType){case"point":case"multipoint":return 1;case"polygon":return 4;case"polyline":return 2;case"multipatch":case"mesh":return 3;default:return 0}}async updateVertexLimitExceeded(e,t){const r=this.vertexLimitInfo;if(u(r))return void this._set("vertexLimitExceeded",!1);const s=r.primitivesPerFeature<=0,a=this.minimumNumberOfVerticesForGeometry>1;if(!s&&!a)return void this._set("vertexLimitExceeded",!1);const{primitivesPerFeature:o,primitivesPerCoordinate:n,maximumTotalNumberOfPrimitives:h}=r;let c;0!==o&&l(e)&&await e;const d=this.serviceDataCount,m=d!==A.NO_SERVICE_DATA_COUNT;if(c=m?Math.ceil((h-d*o)/(n||1)):Math.ceil(h/(n||1)),a&&(c=Math.min(c,U)),m&&this.minimumNumberOfVerticesForGeometry*d>c)return void this._set("vertexLimitExceeded",!0);if(!this.supportsExceedsLimitQuery)return void this._set("vertexLimitExceeded",this.maxTotalSnapshotVertices>c);const f=await i(this.layerView.layer.queryFeatures(this.createVertexLimitExceededQuery(c),{timeout:A.QUERY_STATISTICS_TIMEOUT,signal:t}));if(!1===f.ok){if(p(f.error))throw f.error;return void this._set("vertexLimitExceeded",!1)}const y=f.value.features[0];y&&y.attributes?this._set("vertexLimitExceeded",!!y.attributes.exceedslimit):this._set("vertexLimitExceeded",!1)}async fetchServiceDataInfo(){this.cancelFetchServiceDataInfo();let e=m();const t=e.signal,i=this.updateServiceDataCount(t),r=f([i,this.updateVertexLimitExceeded(i,t)]),s=r.then((()=>this.updateServiceDataExtent(t))).catch((e=>{p(e)||S.error("#fetchServiceDataInfo()",e)})).then((()=>{s===this.fetchDataInfoPromise&&(this.fetchDataInfoPromise=null,this.fetchDataInfoAbortController=null),e=null}));return e&&(this.fetchDataInfoPromise=s),this.fetchDataInfoAbortController=e,r.then((()=>{}),(()=>{}))}cancelFetchServiceDataInfo(){const e=this.fetchDataInfoAbortController;e&&(this.fetchDataInfoAbortController=null,this.fetchDataInfoPromise=null,e.abort())}get debug(){return{storedFeatures:l(this.tileFetcher)?this.tileFetcher.storedFeatures:0,totalFeatures:l(this.tileFetcher)?this.tileFetcher.totalFeatures:0,totalVertices:l(this.tileFetcher)?this.tileFetcher.totalVertices:0}}};e([x({readOnly:!0})],_.prototype,"type",void 0),e([x({constructOnly:!0})],_.prototype,"graphics",void 0),e([x({constructOnly:!0})],_.prototype,"layerView",void 0),e([x({constructOnly:!0})],_.prototype,"context",void 0),e([x()],_.prototype,"extent",null),e([x()],_.prototype,"updating",null),e([x({readOnly:!0})],_.prototype,"watchUpdatingTracking",void 0),e([x()],_.prototype,"updatingTotal",null),e([x()],_.prototype,"updatingRemaining",null),e([x()],_.prototype,"expectedFeatureDiff",null),e([x()],_.prototype,"memoryForUnusedFeatures",null),e([x()],_.prototype,"maximumNumberOfFeaturesExceeded",null),e([x({readOnly:!0})],_.prototype,"serviceDataExtent",void 0),e([x({readOnly:!0})],_.prototype,"serviceDataCount",void 0),e([x({readOnly:!0})],_.prototype,"vertexLimitExceeded",void 0),e([x()],_.prototype,"displayFeatureLimit",void 0),e([x({type:Number})],_.prototype,"maximumNumberOfFeatures",null),e([x({readOnly:!0})],_.prototype,"mode",null),e([x({readOnly:!0})],_.prototype,"maxTotalSnapshotVertices",null),e([x({readOnly:!0,dependsOn:["mode"]})],_.prototype,"tileDescriptors",null),e([x()],_.prototype,"tileFetcher",void 0),e([x()],_.prototype,"fetchDataInfoPromise",void 0),e([x({readOnly:!0})],_.prototype,"vertexLimitInfo",null),_=e([F("esri.layers.graphics.controllers.FeatureTileController3D")],_);const O=1e4,I=12e3,V=1e4,U=5e6;function N(e,t){if(!t)return!1;for(const i of t)if(!e.has(i))return!0;return!1}var A;!function(e){function t(){e.MAX_FEATURE_COUNT_FOR_EXTENT=O,e.QUERY_STATISTICS_TIMEOUT=I,e.QUERY_EXTENT_TIMEOUT=V}e.NO_SERVICE_DATA_COUNT=1/0,e.MAX_SNAPSHOT_MIN_SCALE_FACTOR=5,e.reset=t}(A||(A={})),A.reset();export{_ as FeatureTileController3D,A as FeatureTileController3DConstants};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{result as i}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import"../../../core/has.js";import s from"../../../core/Error.js";import a from"../../../core/Handles.js";import{clone as o}from"../../../core/lang.js";import n from"../../../core/Logger.js";import{isSome as l,destroyMaybe as h,removeMaybe as c,isNone as u}from"../../../core/maybe.js";import{EsriPromiseMixin as d}from"../../../core/Promise.js";import{isAbortError as m,eachAlways as p}from"../../../core/promiseUtils.js";import{whenOnce as f,init as y}from"../../../core/watchUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as x}from"../../../core/accessorSupport/decorators/subclass.js";import{isHostedAgolService as F}from"../../support/arcgisLayerUrl.js";import{projectGeometry as v}from"../../../portal/support/geometryServiceUtils.js";import T from"../../../rest/support/StatisticDefinition.js";import{FeatureTileFetcher3D as w}from"../../../views/3d/layers/support/FeatureTileFetcher3D.js";import{FeatureTileFetcher3DDebugger as E}from"../../../views/3d/layers/support/FeatureTileFetcher3DDebugger.js";import C from"../../../views/3d/support/debugFlags.js";import{WatchUpdatingTracking as b}from"../../../views/support/WatchUpdatingTracking.js";const D=n.getLogger("esri.layers.graphics.controllers.FeatureTileController3D");let S=class extends(d(t)){constructor(e){super(e),this.type="feature-tile-3d",this.watchUpdatingTracking=new b,this.serviceDataExtent=null,this.serviceDataCount=A.NO_SERVICE_DATA_COUNT,this.vertexLimitExceeded=!1,this.displayFeatureLimit=null,this.suspended=!1,this.tileFetcher=null,this.handles=new a,this.fetchDataInfoPromise=null,this.fetchDataInfoAbortController=null,this.lifeCycleAbortController=new AbortController}set extent(e){if(e&&!e.spatialReference.equals(this.layerView.view.spatialReference))return void D.error("#extent=","extent needs to be in the same spatial reference as the view");const t=this._get("extent");if(t===e)return;if(t&&e&&t.equals(e))return;const i=e?e.clone():null;this._set("extent",i)}get updating(){return!!(l(this.tileFetcher)&&this.tileFetcher.updating||null!=this.fetchDataInfoPromise||"tiles"===this.mode&&this.layerView.view.featureTiles&&this.layerView.view.featureTiles.updating||this.watchUpdatingTracking&&this.watchUpdatingTracking.updating)}get updatingTotal(){return this.updating&&l(this.tileFetcher)?this.tileFetcher.updatingTotal:0}get updatingRemaining(){return this.updating&&l(this.tileFetcher)?this.tileFetcher.updatingRemaining:0}get expectedFeatureDiff(){return this.updating&&l(this.tileFetcher)?this.tileFetcher.expectedFeatureDiff:0}get memoryForUnusedFeatures(){return l(this.tileFetcher)?this.tileFetcher.memoryForUnusedFeatures:0}get maximumNumberOfFeaturesExceeded(){return!(!l(this.tileFetcher)||!this.tileFetcher.maximumNumberOfFeaturesExceeded)}get maximumNumberOfFeatures(){return l(this.displayFeatureLimit)?this.displayFeatureLimit.maximumNumberOfFeatures:0}set maximumNumberOfFeatures(e){e!==this.maximumNumberOfFeatures&&(null==e?this._clearOverride("maximumNumberOfFeatures"):this._override("maximumNumberOfFeatures",e))}get hasMaximumNumberOfFeaturesOverride(){return this._isOverridden("maximumNumberOfFeatures")}get mode(){var e,t;const i=this.layerView.layer;if("feature"===i.type&&l(i.infoFor3D))return"snapshot";if(!1===(null==(e=this.layerView.view.qualitySettings)||null==(t=e.graphics3D)?void 0:t.snapshotAvailable)||this.serviceDataCount===A.NO_SERVICE_DATA_COUNT||this.vertexLimitExceeded)return"tiles";const r=this.layerView.view,s=r&&r.featureTiles,a=s&&s.tilingScheme;if(i&&i.minScale&&this.serviceDataExtent&&a){const e=this.approximateExtentSizeAtScale(i.minScale,a);if((this.serviceDataExtent.width/e+this.serviceDataExtent.height/e)/2>A.MAX_SNAPSHOT_MIN_SCALE_FACTOR)return"tiles"}return!this.maximumNumberOfFeatures||this.serviceDataCount<=this.maximumNumberOfFeatures?"snapshot":"tiles"}get maxTotalSnapshotVertices(){const e=this._get("maxTotalSnapshotVertices")||0,t="snapshot"===this.mode&&l(this.tileFetcher)&&this.tileFetcher.totalVertices||0;return Math.max(e,t)}approximateExtentSizeAtScale(e,t){const i=this.layerView.view,r=Math.ceil((i.width/t.pixelSize+i.height/t.pixelSize)/2),s=t.levels[0];return r*((s.tileSize[0]/(s.scale/e)+s.tileSize[1]/(s.scale/e))/2)}get tileDescriptors(){return"snapshot"===this.mode?new r([{id:"dummy-tile-full-extent",lij:[0,0,0]}]):this.layerView.view.featureTiles?this.layerView.view.featureTiles.tiles:new r}get test(){return{fetchDataInfoPromise:this.fetchDataInfoPromise,tileFetcher:this.tileFetcher}}initialize(){this.watchUpdatingTracking.add(this,"vertexLimitInfo",(()=>this.watchUpdatingTracking.addPromise(this.updateVertexLimitExceeded(null,this.lifeCycleAbortController.signal)))),this.watchUpdatingTracking.add(this,"mode",(()=>this.modeChanged()),2),this.addResolvingPromise(Promise.resolve().then((()=>this.verifyCapabilities())).then((()=>this.watchUpdatingTracking.addPromise(this.fetchServiceDataInfo()))).then((()=>this.initializeTileFetcher())))}verifyCapabilities(){const e=this.layerView.layer;if(!e.get("capabilities.operations.supportsQuery")&&"ogc-feature"!==e.type)throw new s("graphicscontroller:query-capability-required","Service requires query capabilities to be used as a feature layer",{layer:e})}destroy(){this.cancelFetchServiceDataInfo(),this.tileFetcher=h(this.tileFetcher),this.handles=h(this.handles),this.tilesHandle=c(this.tilesHandle),this.lifeCycleAbortController&&(this.lifeCycleAbortController.abort(),this.lifeCycleAbortController=null),this.watchUpdatingTracking.destroy(),this._set("watchUpdatingTracking",null)}suspend(){this.suspended||(this.suspended=!0,l(this.tileFetcher)&&this.tileFetcher.suspend())}resume(){this.suspended&&(this.suspended=!1,l(this.tileFetcher)&&this.tileFetcher.resume())}restart(){const e=()=>{l(this.tileFetcher)&&this.tileFetcher.restart()};this.watchUpdatingTracking.addPromise(this.fetchServiceDataInfo().then(e,e))}refetch(){const e=()=>{l(this.tileFetcher)&&this.tileFetcher.refetch()};this.watchUpdatingTracking.addPromise(this.fetchServiceDataInfo().then(e,e))}initializeTileFetcher(){const e=this.layerView.view;if(!e)return;const t=f(e.featureTiles,"tilingScheme",this.lifeCycleAbortController.signal);this.watchUpdatingTracking.addPromise(t),t.then((()=>{const{layerView:t,tileDescriptors:i}=this,r=t.layer,s=new w({context:this.context,filterExtent:this.extent,tileDescriptors:i,features:this.graphics});this.tileFetcher=s,this.suspended?this.tileFetcher.suspend():this.tileFetcher.resume();const a=this.layerView.view.resourceController;a&&(this.handles.add(a.memoryController.events.on("quality-changed",(e=>{s.memoryFactor=e}))),this.tileFetcher.memoryFactor=a.memoryController.memoryFactor);const o="polygon"===this.context.geometryType?"polygonLodFactor":"polyline"===this.context.geometryType?"polylineLodFactor":null;o&&this.handles.add(y(this.layerView.view,"qualitySettings.graphics3D."+o,(e=>{s.lodFactor=e||1})));const n=e=>{s.maximumNumberOfFeatures=e,s.useTileCount=this.serviceDataCount>e},l=e=>s.useTileCount=e>this.maximumNumberOfFeatures;this.watchUpdatingTracking.add(r,"createQueryVersion",(()=>this.dataFilterChanged())),this.watchUpdatingTracking.add(t,"availableFields",((e,t)=>this.availableFieldsChanged(t,e))),this.watchUpdatingTracking.add(t,"requiredFields",((e,t)=>this.requiredFieldsChanged(t,e))),this.handles.add([r.on("apply-edits",(e=>this.applyEdits(e))),this.watch("extent",(e=>s.filterExtent=e),!0),this.watch("tileDescriptors",(e=>s.tileDescriptors=e),!0),y(this,"maximumNumberOfFeatures",n,!0),y(this,"serviceDataCount",l,!0),y(C,"FEATURE_TILE_FETCH_SHOW_TILES",(t=>{t&&s&&!s.debugger?(s.debugger=new E(s,e.featureTiles.tilingScheme.toTileInfo(),e),s.debugger.update()):!t&&this.tileFetcher&&s.debugger&&(s.debugger.destroy(),s.debugger=null)}))]),this.supportsExceedsLimitQuery||this.watchUpdatingTracking.add(this,"maxTotalSnapshotVertices",(()=>this.watchUpdatingTracking.addPromise(this.updateVertexLimitExceeded(null,this.lifeCycleAbortController.signal))))})).catch((()=>{}))}modeChanged(){switch(this.mode){case"tiles":this.tilesHandle||(this.tilesHandle=this.layerView.view.featureTiles.addClient());break;default:D.warn("Unhandled feature layer mode "+this.mode);case"snapshot":l(this.tilesHandle)&&(this.tilesHandle.remove(),this.tilesHandle=null)}}dataFilterChanged(){this._set("maxTotalSnapshotVertices",0),this.notifyChange("maxTotalSnapshotVertices"),this.refetch()}applyEdits(e){u(this.tileFetcher)||this.tileFetcher.applyEdits(e).then((e=>{e&&(e.deletedFeatures.length||e.updatedFeatures.length||e.addedFeatures.length)&&this.watchUpdatingTracking.addPromise(this.updateServiceDataExtent(this.lifeCycleAbortController.signal))})).catch((e=>{if(!m(e))throw e}))}availableFieldsChanged(e,t){l(this.tileFetcher)&&U(this.tileFetcher.availableFields,t)&&this.refetch()}requiredFieldsChanged(e,t){l(this.tileFetcher)&&U(this.tileFetcher.availableFields,t)&&this.restart()}createVertexLimitExceededQuery(e){const t=this.layerView.layer,i=t.createQuery();return i.outStatistics=[new T({statisticType:"exceedslimit",maxVertexCount:e,outStatisticFieldName:"exceedslimit",maxPointCount:1e8,maxRecordCount:1e8})],t.capabilities.query.supportsCacheHint&&(i.cacheHint=!0),i}createDataInfoQuery(){const e=this.layerView.layer,t=e.createQuery();return t.outSpatialReference=this.layerView.view.spatialReference,e.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}fullExtentIsAccurate(){const e=this.layerView.layer;if(e.definitionExpression)return!1;switch(e.type){case"feature":return F(e.url);case"csv":case"geojson":case"ogc-feature":case"wfs":return!0;default:return}}async updateServiceDataExtent(e){try{await this.tryUpdateServiceDataExtent(e)}catch(t){m(t)||this._set("serviceDataExtent",o(this.layerView.fullExtentInLocalViewSpatialReference))}}async tryUpdateServiceDataExtent(e){const t=this.layerView,i=t.layer,r=i.capabilities.query.supportsExtent,s=o(t.fullExtentInLocalViewSpatialReference),a=i.fullExtent,n=this.fullExtentIsAccurate(),h=this.serviceDataCount;if(r&&h<=A.MAX_FEATURE_COUNT_FOR_EXTENT&&(!s||!n)&&"queryExtent"in i){const t=this.createDataInfoQuery(),r=await i.queryExtent(t,{timeout:A.QUERY_EXTENT_TIMEOUT,signal:e});this._set("serviceDataExtent",r.extent)}else if(s)this._set("serviceDataExtent",s);else if(l(a)){const r="portalItem"in i?i.portalItem:null,s=await v(a,t.view.spatialReference,r,e);this._set("serviceDataExtent",s)}else this._set("serviceDataExtent",null)}async updateServiceDataCount(e){const t=this.layerView.layer;if(!("queryFeatureCount"in t))return void this._set("serviceDataCount",A.NO_SERVICE_DATA_COUNT);const r=await i(t.queryFeatureCount(this.createDataInfoQuery(),{timeout:A.QUERY_STATISTICS_TIMEOUT,signal:e}));if(!0===r.ok)this._set("serviceDataCount",r.value);else{if(m(r.error))throw r.error;this._set("serviceDataCount",A.NO_SERVICE_DATA_COUNT)}}get vertexLimitInfo(){if(u(this.displayFeatureLimit)||u(this.displayFeatureLimit.averageSymbolComplexity))return null;const{averageSymbolComplexity:e,maximumTotalNumberOfPrimitives:t}=this.displayFeatureLimit,{primitivesPerCoordinate:i,primitivesPerFeature:r}=e,s=this._get("vertexLimitInfo");return u(s)||s.maximumTotalNumberOfPrimitives!==t||s.primitivesPerCoordinate!==i||s.primitivesPerFeature!==r?{primitivesPerCoordinate:i,primitivesPerFeature:r,maximumTotalNumberOfPrimitives:t}:s}get supportsExceedsLimitQuery(){const e=this.layerView.layer;return e.capabilities&&e.capabilities.operations&&e.capabilities.operations.supportsExceedsLimitStatistics}get minimumNumberOfVerticesForGeometry(){switch(this.layerView.layer.geometryType){case"point":case"multipoint":return 1;case"polygon":return 4;case"polyline":return 2;case"multipatch":case"mesh":return 3;default:return 0}}async updateVertexLimitExceeded(e,t){const r=this.vertexLimitInfo;if(u(r))return void this._set("vertexLimitExceeded",!1);const s=r.primitivesPerFeature<=0,a=this.minimumNumberOfVerticesForGeometry>1;if(!s&&!a)return void this._set("vertexLimitExceeded",!1);const{primitivesPerFeature:o,primitivesPerCoordinate:n,maximumTotalNumberOfPrimitives:h}=r;let c;0!==o&&l(e)&&await e;const d=this.serviceDataCount,p=d!==A.NO_SERVICE_DATA_COUNT;if(c=p?Math.ceil((h-d*o)/(n||1)):Math.ceil(h/(n||1)),a&&(c=Math.min(c,V)),p&&this.minimumNumberOfVerticesForGeometry*d>c)return void this._set("vertexLimitExceeded",!0);if(!this.supportsExceedsLimitQuery)return void this._set("vertexLimitExceeded",this.maxTotalSnapshotVertices>c);const f=await i(this.layerView.layer.queryFeatures(this.createVertexLimitExceededQuery(c),{timeout:A.QUERY_STATISTICS_TIMEOUT,signal:t}));if(!1===f.ok){if(m(f.error))throw f.error;return void this._set("vertexLimitExceeded",!1)}const y=f.value.features[0];y&&y.attributes?this._set("vertexLimitExceeded",!!y.attributes.exceedslimit):this._set("vertexLimitExceeded",!1)}async fetchServiceDataInfo(){this.cancelFetchServiceDataInfo();let e=new AbortController;const t=e.signal,i=this.updateServiceDataCount(t),r=p([i,this.updateVertexLimitExceeded(i,t)]),s=r.then((()=>this.updateServiceDataExtent(t))).catch((e=>{m(e)||D.error("#fetchServiceDataInfo()",e)})).then((()=>{s===this.fetchDataInfoPromise&&(this.fetchDataInfoPromise=null,this.fetchDataInfoAbortController=null),e=null}));return e&&(this.fetchDataInfoPromise=s),this.fetchDataInfoAbortController=e,r.then((()=>{}),(()=>{}))}cancelFetchServiceDataInfo(){const e=this.fetchDataInfoAbortController;e&&(this.fetchDataInfoAbortController=null,this.fetchDataInfoPromise=null,e.abort())}get debug(){return{storedFeatures:l(this.tileFetcher)?this.tileFetcher.storedFeatures:0,totalFeatures:l(this.tileFetcher)?this.tileFetcher.totalFeatures:0,totalVertices:l(this.tileFetcher)?this.tileFetcher.totalVertices:0}}};e([g({readOnly:!0})],S.prototype,"type",void 0),e([g({constructOnly:!0})],S.prototype,"graphics",void 0),e([g({constructOnly:!0})],S.prototype,"layerView",void 0),e([g({constructOnly:!0})],S.prototype,"context",void 0),e([g()],S.prototype,"extent",null),e([g()],S.prototype,"updating",null),e([g({readOnly:!0})],S.prototype,"watchUpdatingTracking",void 0),e([g()],S.prototype,"updatingTotal",null),e([g()],S.prototype,"updatingRemaining",null),e([g()],S.prototype,"expectedFeatureDiff",null),e([g()],S.prototype,"memoryForUnusedFeatures",null),e([g()],S.prototype,"maximumNumberOfFeaturesExceeded",null),e([g({readOnly:!0})],S.prototype,"serviceDataExtent",void 0),e([g({readOnly:!0})],S.prototype,"serviceDataCount",void 0),e([g({readOnly:!0})],S.prototype,"vertexLimitExceeded",void 0),e([g()],S.prototype,"displayFeatureLimit",void 0),e([g({type:Number})],S.prototype,"maximumNumberOfFeatures",null),e([g({readOnly:!0})],S.prototype,"mode",null),e([g({readOnly:!0})],S.prototype,"maxTotalSnapshotVertices",null),e([g({readOnly:!0,dependsOn:["mode"]})],S.prototype,"tileDescriptors",null),e([g()],S.prototype,"tileFetcher",void 0),e([g()],S.prototype,"fetchDataInfoPromise",void 0),e([g({readOnly:!0})],S.prototype,"vertexLimitInfo",null),S=e([x("esri.layers.graphics.controllers.FeatureTileController3D")],S);const _=1e4,O=12e3,I=1e4,V=5e6;function U(e,t){if(!t)return!1;for(const i of t)if(!e.has(i))return!0;return!1}var A;!function(e){function t(){e.MAX_FEATURE_COUNT_FOR_EXTENT=_,e.QUERY_STATISTICS_TIMEOUT=O,e.QUERY_EXTENT_TIMEOUT=I}e.NO_SERVICE_DATA_COUNT=1/0,e.MAX_SNAPSHOT_MIN_SCALE_FACTOR=5,e.reset=t}(A||(A={})),A.reset();export{S as FeatureTileController3D,A as FeatureTileController3DConstants};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import i from"../../../core/Handles.js";import s from"../../../core/has.js";import a from"../../../core/Logger.js";import{isSome as r,isNone as d}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{createAbortController as h,isAbortError as l}from"../../../core/promiseUtils.js";import{init as u}from"../../../core/watchUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as p}from"../../../geometry/projection.js";import{create as g}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as m,create as y}from"../../../geometry/support/aaBoundingRect.js";import{makeDehydratedPoint as x}from"../dehydratedFeatures.js";import{PromiseQueue as f}from"../../support/PromiseQueue.js";import{addTask as b}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as w}from"../../../views/3d/layers/i3s/I3SIndex.js";import N from"../../../views/3d/layers/i3s/I3SLodHandling.js";import v from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as C}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as D,getIndexCrs as L,findIntersectingNodes as S}from"../../../views/3d/layers/i3s/I3SUtil.js";import V from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{projectToBoundingBox as I}from"../../../views/3d/support/extentUtils.js";import{maxDownloadSlots as A}from"../../../views/3d/support/index.js";import{extractSafeScaleBounds as F,scaleBoundsPredicate as P}from"../../../views/support/layerViewUtils.js";import{noBudget as U}from"../../../views/support/Scheduler.js";const O=a.getLogger("esri.layers.graphics.controllers.I3SOnDemandController"),M=100,q=2,G=1e4,j=1e-4,Q=1.2,T=500,B=1.5;let E=class extends(n(t)){constructor(e){super(e),this.screenSizeFactor=0,this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.scaleVisibilityEnabled=!0,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._newLoadingNodes=new o({deallocator:null}),this._loadedNodeScales=new Map,this._modificationsNodeFilteringArray=new o,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._handles=new i,this._idleQueue=new f,this._elevationUpdateNodes=new o({deallocator:null}),this._errorCount=0}get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store.lodType}get isGraphics3D(){return"points"===this.layer.profile}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(2);return new C(e,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(3);return new C(e,this.layer.apiKey)}get crsVertex(){return D(this.layer)}get crsIndex(){return L(this.layer)}get rootNodeVisible(){if(r(this._index)){const e=this._index.rootNode;if(r(e))return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}initialize(){this._disableMemCache=!this.layerView.loadCachedGPUData||!this.layerView.addCachedGPUData,this._lodHandling=new N(this.layerView);const e=this.layerView.i3slayer;this.layer=e,this._defaultGeometrySchema=e.store.defaultGeometrySchema,this.disableIDBCache=s("disable-feature:idb-cache"),"fields"in e&&(this._fields=e.fields,this._attributeStorageInfo=e.attributeStorageInfo),this.addResolvingPromise(Promise.all([this.layer.indexInfo,this.layer.when(),this.layerView.when()]).then((([t])=>{var i;if(this.destroyed||!this.layerView||this.layerView.destroyed)return;const s=this.layerView.view;this._setClippingArea(s.clippingArea);const a=this.layerView.view.resourceController;this._handles.add([u(s,"pointsOfInterest.focus.renderLocation",(e=>this._pointOfInterestChanged(e))),a.memoryController.events.on("quality-changed",(()=>this._setCameraDirty())),u(this.layerView,"suspended",(e=>{const t=e?()=>this._updateViewData():()=>this._updateIdleState(!0),i=e?()=>{}:()=>this._updateIdleState(!1);this._idleStateCallbacks?(e&&this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=a.scheduler.registerIdleStateCallbacks(t,i)})),b(this.layerView.view.resourceController.scheduler,{update:(e,t)=>this._frame(e,t),needsUpdate:()=>this.updating}),this.watch("uncompressedTextureDownsamplingEnabled",(()=>this.restartNodeLoading())),this.watch(["featureTarget","fixedFeatureTarget"],(()=>{this._setCameraDirty(),this._stableFeatureLOD=!1})),s.state.watch("contentCamera",(()=>this._setCameraDirty())),this.layer.watch("elevationInfo",(()=>this._elevationInfoChanged())),this.layer.watch(["minScale","maxScale"],(()=>this._scaleBoundsChanged())),this.layerView.watch("lodFactor",(()=>this._setCameraDirty())),this.layerView.watch("availableFields?",(()=>this._requiredFieldsChange())),this.layerView.watch("holeFilling",(e=>r(this._index)&&(this._index.holeFilling=e)))]),this._updateScaleHandles(),this._viewportQueries=new V(this.crsIndex,s.renderCoordsHelper,s.state.contentCamera,!s.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,s.elevationProvider,this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this.lod,angleDependentLoD:this.lod<.5}),this._index=new w(e,t,this.indexStreamController,this._viewportQueries,O,this.layerView.holeFilling,(e=>this.layerView.isNodeLoaded(e)),(e=>this.layerView.isNodeReloading(e)),(e=>this._shouldLoadNode(e)),(e=>this._enableFromGPUCache(e,1)),(e=>this._needsUpdate(e)),(()=>!this.indexStreamController.busy),(e=>this.layerView.computeVisibilityObb?this.layerView.computeVisibilityObb(e):null),null!=(i=this.layerView)&&i.computeNodeFiltering?e=>this.layerView.computeNodeFiltering(e):void 0);const d=r(this.layer.modifications)&&this.layer.modifications&&this.layer.modifications.length>0;this._index.imModificationsChanged(d),this._startNodeLoading()}))),this._tmpPoint=x(0,0,0,this.crsIndex)}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;r(t)&&i&&i.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll((e=>{const i=t.getNode(e);r(i)&&this._modificationsNodeFilteringArray.push(i)})),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._handles.destroy(),this._nodeLoader=null,H.prune(),r(k)&&(k.hide(),k=null)}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map((i=>{const s=z(e,i),a=z(t,i);return s>=0&&a>=0?{index:s,name:t[a].name,field:t[a],attributeStorageInfo:e[s]}:null})).filter((e=>null!=e&&e.name!==i))}_requiredFieldsChange(){const e=this._getRequiredAttributes();R(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=g();I(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){r(this._viewportQueries)&&(this._viewportQueries.setPointOfInterest(e),r(this._index)&&(this._index.progressiveLoadPenalty=K.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),r(this._viewportQueries)&&r(this._index)&&(this._viewportQueries.updateExtent(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this.notifyChange("rootNodeVisible"),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateElevationChanged(e,t){const i=this._index;if(d(i))return;const s=i.rootNode;if(d(s))return;const a=this._elevationUpdateNodes;a.clear(),S(e,t,s,this.crsIndex,i,(e=>a.push(e.index))),a.forAll((e=>{i.invalidateBoundingVolumeCache(e),e===s.index&&this.notifyChange("rootNodeVisible")})),a.length&&this.restartNodeLoading()}getParentIndex(e){return r(this._index)&&this._index.getParentIndex(e)}_elevationInfoChanged(){r(this._index)&&this._index.updateElevationInfo(this.layer.elevationInfo),this._setCameraDirty()}_updateScaleHandles(){const e="scale-bounds";this._handles.remove(e),this.areScaleBoundsActive&&this._handles.add(this.layerView.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),e)}_scaleBoundsChanged(){this.areScaleBoundsActive||this._loadedNodeScales.clear(),this._updateScaleHandles(),this._setCameraDirty()}_scaleUpdateHandler(e){this._updateScaleInBoundingRect(e.scale,e.extent,e.spatialReference),this._setCameraDirty()}_updateScaleInBoundingRect(e,t,i){const s=this._index;if(d(s))return;const a=s.rootNode;!d(a)&&p(t,i,$,this.crsIndex)&&this._loadedNodeScales.forEach(((t,i)=>{const a=s.getNode(i);r(a)&&m($,a.mbs)&&this._loadedNodeScales.set(i,e)}))}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get areScaleBoundsActive(){const{minScale:e,maxScale:t}=F(this.layer);return this.scaleVisibilityEnabled&&(e>0||t>0)}get unloadedMemoryEstimate(){return d(this._index)||this.layerView.suspended?0:this._index.getUnloadedMemoryEstimate()*this.lodDropFactor}get indexDepth(){return r(this._index)?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData||(this._disableMemCache=!0),this._disableMemCache=e}_frame(e,t){return this.layerView.suspended?(this._updateViewData(),this._evaluateUpdating(),-1/0):!this.layerView.visible||d(this._index)?-1/0:(this._processLogError(e,t),this._index.getPriority())}_processLogError(e,t){try{this._process(e,t)}catch(i){this._errorCount<50?O.error("Error during processing: "+i):50===this._errorCount&&O.error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){if(this._restartNodeLoading&&this._startNodeLoading(),null!=this._nodeLoader&&!d(this._index)){for(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this.isIntegratedMesh&&(e.enabled=!1),e.run((()=>this._processIndex(e))),this._updateFeatureLOD(),e.run((()=>this._processCache(e))),this.isIntegratedMesh&&(e.enabled=!0),e.run((()=>this._processNodes(e,t)));!e.done&&this._idleQueue.process();)e.madeProgress();e.run((()=>this._prefetchIndex())),t.numIndexLoading+=this._index.getIndexLoading(),t.numNodesLoading+=this._downloadingCount,e.run((()=>this._lodHandling.lodGlobalHandling(e))),this._evaluateUpdating()}}_processIndex(e){if(d(this._index))return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update([...this._loadingNodes.keys()],e,(e=>this.updateNodeModificationStatus(e))),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading()||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(d(this._index)||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.isGraphics3D||d(this._index)||d(this._viewportQueries))return;const e=!this._index.isLoading(),t=this.featureTarget*this.baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.getIndexMissing()>T){if(this._featureLOD<=j)return;this._featureLOD/=B,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=G||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this.lod,a=this._index.checkFeatureTarget(t,s);a!==s&&(this._featureLOD=a/this.baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*Q||e&&i.estimate>t))return;if(this._featureLOD<=j)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(G,Math.max(j,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this.lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(d(t))return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);r(s)&&(!this.layerView.isNodeLoaded(s.index)&&this._isNodeInScaleBounds(s));s=t.getParent(s.index))if(this._enableFromGPUCache(s,0)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(d(this._index))return!1;let i=(this._isIdle?M:q)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());r(t)&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const a=this._index.getNode(s.add.back());if(d(a)||2!==a.cacheState&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(a),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach((e=>e.abort())),this._loadingNodes.clear(),this._updatingNodes.forEach((e=>e.abort())),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=q)&&(this._downloadingCount<A&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView.suspended)e=this._cameraDirty,t=e?0:1;else{const i=(r(this._index)?this._index.getIndexMissing():0)+3*(r(this._index)?this._index.updates.add.length:0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.length>0||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}this.updating=e,this.updatingProgress=t}_updateViewData(){if(!this._cameraDirty||d(this._index)||d(this._viewportQueries))return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this.screenSizeFactor=1/(t.perScreenPixelRatio/2),this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this.lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=K.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.resourceController.memoryController.memoryFactor<1?1:this.layerView.progressiveLoadFactor}get lod(){return this._featureLOD*this.baseLOD}get baseLOD(){const e=this.layerView.lodFactor,t=this.layerView.view.resourceController.memoryController.memoryFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*t}get lodDropFactor(){if(this.fixedFeatureTarget)return 1;const e=this.layerView.view.resourceController.memoryController;return(Math.min(e.memoryFactor,.5)-e.minQuality)/(.5-e.minQuality)}isGeometryVisible(e){return r(this._index)&&this._index.isGeometryVisible(e.index)}updateVisibility(e){r(this._index)&&this._index.invalidateNodeVisibilityCache(e)}updateBoundingVolume(e){r(this._index)&&this._index.invalidateBoundingVolumeCache(e)}invalidateGeometryVisibility(e){r(this._index)&&this._index.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){r(this._index)&&this._index.invalidateVisibilityObbs()}modificationsChanged(){if(r(this._index)){const e=r(this.layer.modifications)&&this.layer.modifications&&this.layer.modifications.length>0;this._index.imModificationsChanged(e)}this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e)||!this._isNodeInScaleBounds(e))&&(!!r(this._index)&&this._index.isGeometryVisible(e.index))}_shouldDropNode(e){if(d(this._viewportQueries))return!1;const t=this.lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||d(e)||d(this._viewportQueries))return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,uncompressedTextureDownsamplingEnabled:this.layerView.uncompressedTextureDownsamplingEnabled,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:!this.isMeshPyramid};this._nodeLoader=new v(this.layer,this.dataStreamController,O,this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e=>this._isNodeInScaleBounds(e)),((e,t)=>this._removeNodes(e,t,1)),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(d(t)||d(this._viewportQueries))return!1;H.clear(),this.layerView.getLoadedNodeIndices(H);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return H.filterInPlace((e=>{const i=t.getNode(e);return d(i)||!t.isGeometryVisible(e)||s(i)||!this._isNodeInScaleBounds(i)})),H.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(H,e,0),!(i&&this.lodDropFactor<1)&&(0===H.length||(H.clear(),!1))}markNodeToRemove(e){H.push(e)}removeMarkedNodes(){this._removeNodes(H,U,0)}_removeNodes(e,t,i){const s=e.length;if(0!==s&&!t.done){for(r(this._index)&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),a=this._index;1===i&&this.layerView.nodeFadeoutEnabled&&r(a)&&a.isGeometryVisible(s)?this.layerView.fadeNode(s,1,!0):this.layerView.removeNode(s),t.madeProgress()}if(this._loadedNodeScales.size>0)for(let t=e.length;t<s;t++){const i=e.data[t];this._loadedNodeScales.delete(i)}}}_needsUpdate(e){if(!e.resources.hasFeatureData||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}_updateLoadedNode(e){const t=h();this._updatingNodes.set(e.index,t);(R(this.layerView.getLoadedAttributes(e.index),this._requiredAttributes)?Promise.resolve(this.layerView.getAttributeData(e.index)):this._nodeLoader.loadAttributes(e,this._requiredAttributes,t.signal)).then((i=>this.schedule((()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:i},t.signal)),t.signal))).catch((i=>{if(!l(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)})).catch((()=>{})).then((()=>{this._updatingNodes.delete(e.index),this._evaluateUpdating()})),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void O.error("already loading node "+e.index);const t=h();this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).catch((e=>{if(!l(e))throw e})).finally((()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()}))}_loadAndAddNode(e,t){return 1===e.cacheState?this._loadUncached(e,t):this._loadCached(e,t).then((t=>{t||(e.cacheState=1,r(this._index)&&this._index.updates.add.push(e.index))})).catch((t=>{if(!l(t))throw e.cacheState=1,t}))}_enableFromGPUCache(e,t){if(this._disableMemCache||d(this._index))return!1;if(0===t&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e);return r(t)&&r(t.attributeInfo)&&R(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){r(this._index)&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}_loadCached(e,t){if(this._enableFromGPUCache(e,1))return Promise.resolve(!0);const i=this.layerView;return!this.disableIDBCache&&i.loadCachedNodeData&&i.addCachedNodeData?this.schedule((()=>i.loadCachedNodeData(e,t,((t,i)=>this._nodeLoader.loadTextures(e,t,i)))),t).then((s=>{if(d(s))return!1;const a=this._requiredAttributes;return this.reschedule((()=>this._nodeLoader.loadAttributes(e,a,t)),t).then((r=>this.reschedule((()=>i.addCachedNodeData(e,s,{loadedAttributes:a,attributeData:r},t)),t))).then((()=>(this._nodeAdded(),!0)))})):Promise.resolve(!1)}_loadUncached(e,t){return this._downloadingCount++,this._nodeLoader.loadNodeData(e,t).catch((e=>{throw this._downloadingCount--,e})).then((i=>(this._downloadingCount--,this.schedule((()=>this.layerView.addNode(e,i,t)),t)))).then((()=>{this._nodeAdded(),e.cacheState=2})).catch((t=>{if(!l(t))throw O.error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,r(this._index)&&this._index.requestUpdate(),t}))}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&r(this._index)&&this._index.resetFailedNodes())}_getScale(e){if(this._loadedNodeScales.has(e.index))return this._loadedNodeScales.get(e.index);this._tmpPoint.x=e.mbs[0],this._tmpPoint.y=e.mbs[1],this._tmpPoint.z=e.mbs[2];const t=this.layerView.view.basemapTerrain.getScale(this._tmpPoint);return this.layerView.isNodeLoaded(e.index)&&this._loadedNodeScales.set(e.index,t),t}_isNodeInScaleBounds(e){if(!this.areScaleBoundsActive)return!0;const t=this._getScale(e),{minScale:i,maxScale:s}=F(this.layer);return P(t,i,s)}updateStats(e){e.index=r(this._index)?this._index.size:0,this.isGraphics3D&&(e.detail=this._featureLOD,e.target=this.featureTarget*this.baseLOD),r(this._index)&&this._index.updateStats(e)}get test(){const e=this;return{index:this._index,set disableUpdates(t){e._updatesDisabled=t,t?e.cancelNodeLoading():e.requestUpdate()},set disableIDBCache(t){e.disableIDBCache=t},set ignoreServiceObb(t){r(e._index)&&(e._index.ignoreServiceObb=t)},shouldLoadNode:t=>e._shouldLoadNode(t)}}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),r(this._index)&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;r(t)&&t.layerFilterChanged(e),this.requestUpdate()}};e([_({readOnly:!0})],E.prototype,"isMeshPyramid",null),e([_({readOnly:!0})],E.prototype,"isGraphics3D",null),e([_({readOnly:!0})],E.prototype,"indexStreamController",null),e([_({readOnly:!0})],E.prototype,"dataStreamController",null),e([_({readOnly:!0})],E.prototype,"crsVertex",null),e([_({readOnly:!0})],E.prototype,"crsIndex",null),e([_()],E.prototype,"screenSizeFactor",void 0),e([_()],E.prototype,"featureTarget",void 0),e([_()],E.prototype,"fixedFeatureTarget",void 0),e([_()],E.prototype,"layerView",void 0),e([_()],E.prototype,"layer",void 0),e([_({})],E.prototype,"updating",void 0),e([_({})],E.prototype,"updatingProgress",void 0),e([_({readOnly:!0})],E.prototype,"leavesReached",void 0),e([_({constructOnly:!0})],E.prototype,"scaleVisibilityEnabled",void 0),e([_({readOnly:!0,dependsOn:[]})],E.prototype,"rootNodeVisible",null),E=e([c("esri.layers.graphics.controllers.I3SOnDemandController")],E);const H=new o({deallocator:null});let k;function R(e,t){return r(e)&&e.length===t.length&&e.every((e=>z(t,e.name)>=0))}function z(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const K={factorIM:.2,factor3dObject:.05,distancePenalty:10},$=y(),J=E;export{J as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import i from"../../../core/Handles.js";import s from"../../../core/has.js";import a from"../../../core/Logger.js";import{isSome as r,isNone as d}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{isAbortError as h}from"../../../core/promiseUtils.js";import{init as l}from"../../../core/watchUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as c}from"../../../geometry/projection.js";import{create as p}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as g,create as m}from"../../../geometry/support/aaBoundingRect.js";import{makeDehydratedPoint as y}from"../dehydratedFeatures.js";import{PromiseQueue as x}from"../../support/PromiseQueue.js";import{addTask as f}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as b}from"../../../views/3d/layers/i3s/I3SIndex.js";import w from"../../../views/3d/layers/i3s/I3SLodHandling.js";import N from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as v}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as C,getIndexCrs as D,findIntersectingNodes as L}from"../../../views/3d/layers/i3s/I3SUtil.js";import S from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{projectToBoundingBox as V}from"../../../views/3d/support/extentUtils.js";import{maxDownloadSlots as I}from"../../../views/3d/support/index.js";import{extractSafeScaleBounds as A,scaleBoundsPredicate as F}from"../../../views/support/layerViewUtils.js";import{noBudget as P}from"../../../views/support/Scheduler.js";const U=a.getLogger("esri.layers.graphics.controllers.I3SOnDemandController"),O=100,M=2,q=1e4,G=1e-4,j=1.2,Q=500,T=1.5;let B=class extends(n(t)){constructor(e){super(e),this.screenSizeFactor=0,this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.scaleVisibilityEnabled=!0,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._newLoadingNodes=new o({deallocator:null}),this._loadedNodeScales=new Map,this._modificationsNodeFilteringArray=new o,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._handles=new i,this._idleQueue=new x,this._elevationUpdateNodes=new o({deallocator:null}),this._errorCount=0}get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store.lodType}get isGraphics3D(){return"points"===this.layer.profile}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(2);return new v(e,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(3);return new v(e,this.layer.apiKey)}get crsVertex(){return C(this.layer)}get crsIndex(){return D(this.layer)}get rootNodeVisible(){if(r(this._index)){const e=this._index.rootNode;if(r(e))return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}initialize(){this._disableMemCache=!this.layerView.loadCachedGPUData||!this.layerView.addCachedGPUData,this._lodHandling=new w(this.layerView);const e=this.layerView.i3slayer;this.layer=e,this._defaultGeometrySchema=e.store.defaultGeometrySchema,this.disableIDBCache=s("disable-feature:idb-cache"),"fields"in e&&(this._fields=e.fields,this._attributeStorageInfo=e.attributeStorageInfo),this.addResolvingPromise(Promise.all([this.layer.indexInfo,this.layer.when(),this.layerView.when()]).then((([t])=>{var i;if(this.destroyed||!this.layerView||this.layerView.destroyed)return;const s=this.layerView.view;this._setClippingArea(s.clippingArea);const a=this.layerView.view.resourceController;this._handles.add([l(s,"pointsOfInterest.focus.renderLocation",(e=>this._pointOfInterestChanged(e))),a.memoryController.events.on("quality-changed",(()=>this._setCameraDirty())),l(this.layerView,"suspended",(e=>{const t=e?()=>this._updateViewData():()=>this._updateIdleState(!0),i=e?()=>{}:()=>this._updateIdleState(!1);this._idleStateCallbacks?(e&&this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=a.scheduler.registerIdleStateCallbacks(t,i)})),f(this.layerView.view.resourceController.scheduler,{update:(e,t)=>this._frame(e,t),needsUpdate:()=>this.updating}),this.watch("uncompressedTextureDownsamplingEnabled",(()=>this.restartNodeLoading())),this.watch(["featureTarget","fixedFeatureTarget"],(()=>{this._setCameraDirty(),this._stableFeatureLOD=!1})),s.state.watch("contentCamera",(()=>this._setCameraDirty())),this.layer.watch("elevationInfo",(()=>this._elevationInfoChanged())),this.layer.watch(["minScale","maxScale"],(()=>this._scaleBoundsChanged())),this.layerView.watch("lodFactor",(()=>this._setCameraDirty())),this.layerView.watch("availableFields?",(()=>this._requiredFieldsChange())),this.layerView.watch("holeFilling",(e=>r(this._index)&&(this._index.holeFilling=e)))]),this._updateScaleHandles(),this._viewportQueries=new S(this.crsIndex,s.renderCoordsHelper,s.state.contentCamera,!s.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,s.elevationProvider,this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this.lod,angleDependentLoD:this.lod<.5}),this._index=new b(e,t,this.indexStreamController,this._viewportQueries,U,this.layerView.holeFilling,(e=>this.layerView.isNodeLoaded(e)),(e=>this.layerView.isNodeReloading(e)),(e=>this._shouldLoadNode(e)),(e=>this._enableFromGPUCache(e,1)),(e=>this._needsUpdate(e)),(()=>!this.indexStreamController.busy),(e=>this.layerView.computeVisibilityObb?this.layerView.computeVisibilityObb(e):null),null!=(i=this.layerView)&&i.computeNodeFiltering?e=>this.layerView.computeNodeFiltering(e):void 0);const d=r(this.layer.modifications)&&this.layer.modifications&&this.layer.modifications.length>0;this._index.imModificationsChanged(d),this._startNodeLoading()}))),this._tmpPoint=y(0,0,0,this.crsIndex)}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;r(t)&&i&&i.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll((e=>{const i=t.getNode(e);r(i)&&this._modificationsNodeFilteringArray.push(i)})),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._handles.destroy(),this._nodeLoader=null,E.prune(),r(H)&&(H.hide(),H=null)}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map((i=>{const s=R(e,i),a=R(t,i);return s>=0&&a>=0?{index:s,name:t[a].name,field:t[a],attributeStorageInfo:e[s]}:null})).filter((e=>null!=e&&e.name!==i))}_requiredFieldsChange(){const e=this._getRequiredAttributes();k(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=p();V(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){r(this._viewportQueries)&&(this._viewportQueries.setPointOfInterest(e),r(this._index)&&(this._index.progressiveLoadPenalty=z.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),r(this._viewportQueries)&&r(this._index)&&(this._viewportQueries.updateExtent(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this.notifyChange("rootNodeVisible"),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateElevationChanged(e,t){const i=this._index;if(d(i))return;const s=i.rootNode;if(d(s))return;const a=this._elevationUpdateNodes;a.clear(),L(e,t,s,this.crsIndex,i,(e=>a.push(e.index))),a.forAll((e=>{i.invalidateBoundingVolumeCache(e),e===s.index&&this.notifyChange("rootNodeVisible")})),a.length&&this.restartNodeLoading()}getParentIndex(e){return r(this._index)&&this._index.getParentIndex(e)}_elevationInfoChanged(){r(this._index)&&this._index.updateElevationInfo(this.layer.elevationInfo),this._setCameraDirty()}_updateScaleHandles(){const e="scale-bounds";this._handles.remove(e),this.areScaleBoundsActive&&this._handles.add(this.layerView.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),e)}_scaleBoundsChanged(){this.areScaleBoundsActive||this._loadedNodeScales.clear(),this._updateScaleHandles(),this._setCameraDirty()}_scaleUpdateHandler(e){this._updateScaleInBoundingRect(e.scale,e.extent,e.spatialReference),this._setCameraDirty()}_updateScaleInBoundingRect(e,t,i){const s=this._index;if(d(s))return;const a=s.rootNode;!d(a)&&c(t,i,K,this.crsIndex)&&this._loadedNodeScales.forEach(((t,i)=>{const a=s.getNode(i);r(a)&&g(K,a.mbs)&&this._loadedNodeScales.set(i,e)}))}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get areScaleBoundsActive(){const{minScale:e,maxScale:t}=A(this.layer);return this.scaleVisibilityEnabled&&(e>0||t>0)}get unloadedMemoryEstimate(){return d(this._index)||this.layerView.suspended?0:this._index.getUnloadedMemoryEstimate()*this.lodDropFactor}get indexDepth(){return r(this._index)?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData||(this._disableMemCache=!0),this._disableMemCache=e}_frame(e,t){return this.layerView.suspended?(this._updateViewData(),this._evaluateUpdating(),-1/0):!this.layerView.visible||d(this._index)?-1/0:(this._processLogError(e,t),this._index.getPriority())}_processLogError(e,t){try{this._process(e,t)}catch(i){this._errorCount<50?U.error("Error during processing: "+i):50===this._errorCount&&U.error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){if(this._restartNodeLoading&&this._startNodeLoading(),null!=this._nodeLoader&&!d(this._index)){for(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this.isIntegratedMesh&&(e.enabled=!1),e.run((()=>this._processIndex(e))),this._updateFeatureLOD(),e.run((()=>this._processCache(e))),this.isIntegratedMesh&&(e.enabled=!0),e.run((()=>this._processNodes(e,t)));!e.done&&this._idleQueue.process();)e.madeProgress();e.run((()=>this._prefetchIndex())),t.numIndexLoading+=this._index.getIndexLoading(),t.numNodesLoading+=this._downloadingCount,e.run((()=>this._lodHandling.lodGlobalHandling(e))),this._evaluateUpdating()}}_processIndex(e){if(d(this._index))return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update([...this._loadingNodes.keys()],e,(e=>this.updateNodeModificationStatus(e))),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading()||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(d(this._index)||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.isGraphics3D||d(this._index)||d(this._viewportQueries))return;const e=!this._index.isLoading(),t=this.featureTarget*this.baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.getIndexMissing()>Q){if(this._featureLOD<=G)return;this._featureLOD/=T,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=q||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this.lod,a=this._index.checkFeatureTarget(t,s);a!==s&&(this._featureLOD=a/this.baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*j||e&&i.estimate>t))return;if(this._featureLOD<=G)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(q,Math.max(G,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this.lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(d(t))return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);r(s)&&(!this.layerView.isNodeLoaded(s.index)&&this._isNodeInScaleBounds(s));s=t.getParent(s.index))if(this._enableFromGPUCache(s,0)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(d(this._index))return!1;let i=(this._isIdle?O:M)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());r(t)&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const a=this._index.getNode(s.add.back());if(d(a)||2!==a.cacheState&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(a),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach((e=>e.abort())),this._loadingNodes.clear(),this._updatingNodes.forEach((e=>e.abort())),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=M)&&(this._downloadingCount<I&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView.suspended)e=this._cameraDirty,t=e?0:1;else{const i=(r(this._index)?this._index.getIndexMissing():0)+3*(r(this._index)?this._index.updates.add.length:0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.length>0||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}this.updating=e,this.updatingProgress=t}_updateViewData(){if(!this._cameraDirty||d(this._index)||d(this._viewportQueries))return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this.screenSizeFactor=1/(t.perScreenPixelRatio/2),this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this.lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=z.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.resourceController.memoryController.memoryFactor<1?1:this.layerView.progressiveLoadFactor}get lod(){return this._featureLOD*this.baseLOD}get baseLOD(){const e=this.layerView.lodFactor,t=this.layerView.view.resourceController.memoryController.memoryFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*t}get lodDropFactor(){if(this.fixedFeatureTarget)return 1;const e=this.layerView.view.resourceController.memoryController;return(Math.min(e.memoryFactor,.5)-e.minQuality)/(.5-e.minQuality)}isGeometryVisible(e){return r(this._index)&&this._index.isGeometryVisible(e.index)}updateVisibility(e){r(this._index)&&this._index.invalidateNodeVisibilityCache(e)}updateBoundingVolume(e){r(this._index)&&this._index.invalidateBoundingVolumeCache(e)}invalidateGeometryVisibility(e){r(this._index)&&this._index.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){r(this._index)&&this._index.invalidateVisibilityObbs()}modificationsChanged(){if(r(this._index)){const e=r(this.layer.modifications)&&this.layer.modifications&&this.layer.modifications.length>0;this._index.imModificationsChanged(e)}this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e)||!this._isNodeInScaleBounds(e))&&(!!r(this._index)&&this._index.isGeometryVisible(e.index))}_shouldDropNode(e){if(d(this._viewportQueries))return!1;const t=this.lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||d(e)||d(this._viewportQueries))return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,uncompressedTextureDownsamplingEnabled:this.layerView.uncompressedTextureDownsamplingEnabled,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:!this.isMeshPyramid};this._nodeLoader=new N(this.layer,this.dataStreamController,U,this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e=>this._isNodeInScaleBounds(e)),((e,t)=>this._removeNodes(e,t,1)),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(d(t)||d(this._viewportQueries))return!1;E.clear(),this.layerView.getLoadedNodeIndices(E);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return E.filterInPlace((e=>{const i=t.getNode(e);return d(i)||!t.isGeometryVisible(e)||s(i)||!this._isNodeInScaleBounds(i)})),E.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(E,e,0),!(i&&this.lodDropFactor<1)&&(0===E.length||(E.clear(),!1))}markNodeToRemove(e){E.push(e)}removeMarkedNodes(){this._removeNodes(E,P,0)}_removeNodes(e,t,i){const s=e.length;if(0!==s&&!t.done){for(r(this._index)&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),a=this._index;1===i&&this.layerView.nodeFadeoutEnabled&&r(a)&&a.isGeometryVisible(s)?this.layerView.fadeNode(s,1,!0):this.layerView.removeNode(s),t.madeProgress()}if(this._loadedNodeScales.size>0)for(let t=e.length;t<s;t++){const i=e.data[t];this._loadedNodeScales.delete(i)}}}_needsUpdate(e){if(!e.resources.hasFeatureData||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}_updateLoadedNode(e){const t=new AbortController;this._updatingNodes.set(e.index,t);(k(this.layerView.getLoadedAttributes(e.index),this._requiredAttributes)?Promise.resolve(this.layerView.getAttributeData(e.index)):this._nodeLoader.loadAttributes(e,this._requiredAttributes,t.signal)).then((i=>this.schedule((()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:i},t.signal)),t.signal))).catch((i=>{if(!h(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)})).catch((()=>{})).then((()=>{this._updatingNodes.delete(e.index),this._evaluateUpdating()})),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void U.error("already loading node "+e.index);const t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).catch((e=>{if(!h(e))throw e})).finally((()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()}))}_loadAndAddNode(e,t){return 1===e.cacheState?this._loadUncached(e,t):this._loadCached(e,t).then((t=>{t||(e.cacheState=1,r(this._index)&&this._index.updates.add.push(e.index))})).catch((t=>{if(!h(t))throw e.cacheState=1,t}))}_enableFromGPUCache(e,t){if(this._disableMemCache||d(this._index))return!1;if(0===t&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e);return r(t)&&r(t.attributeInfo)&&k(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){r(this._index)&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}_loadCached(e,t){if(this._enableFromGPUCache(e,1))return Promise.resolve(!0);const i=this.layerView;return!this.disableIDBCache&&i.loadCachedNodeData&&i.addCachedNodeData?this.schedule((()=>i.loadCachedNodeData(e,t,((t,i)=>this._nodeLoader.loadTextures(e,t,i)))),t).then((s=>{if(d(s))return!1;const a=this._requiredAttributes;return this.reschedule((()=>this._nodeLoader.loadAttributes(e,a,t)),t).then((r=>this.reschedule((()=>i.addCachedNodeData(e,s,{loadedAttributes:a,attributeData:r},t)),t))).then((()=>(this._nodeAdded(),!0)))})):Promise.resolve(!1)}_loadUncached(e,t){return this._downloadingCount++,this._nodeLoader.loadNodeData(e,t).catch((e=>{throw this._downloadingCount--,e})).then((i=>(this._downloadingCount--,this.schedule((()=>this.layerView.addNode(e,i,t)),t)))).then((()=>{this._nodeAdded(),e.cacheState=2})).catch((t=>{if(!h(t))throw U.error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,r(this._index)&&this._index.requestUpdate(),t}))}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&r(this._index)&&this._index.resetFailedNodes())}_getScale(e){if(this._loadedNodeScales.has(e.index))return this._loadedNodeScales.get(e.index);this._tmpPoint.x=e.mbs[0],this._tmpPoint.y=e.mbs[1],this._tmpPoint.z=e.mbs[2];const t=this.layerView.view.basemapTerrain.getScale(this._tmpPoint);return this.layerView.isNodeLoaded(e.index)&&this._loadedNodeScales.set(e.index,t),t}_isNodeInScaleBounds(e){if(!this.areScaleBoundsActive)return!0;const t=this._getScale(e),{minScale:i,maxScale:s}=A(this.layer);return F(t,i,s)}updateStats(e){e.index=r(this._index)?this._index.size:0,this.isGraphics3D&&(e.detail=this._featureLOD,e.target=this.featureTarget*this.baseLOD),r(this._index)&&this._index.updateStats(e)}get test(){const e=this;return{index:this._index,set disableUpdates(t){e._updatesDisabled=t,t?e.cancelNodeLoading():e.requestUpdate()},set disableIDBCache(t){e.disableIDBCache=t},set ignoreServiceObb(t){r(e._index)&&(e._index.ignoreServiceObb=t)},shouldLoadNode:t=>e._shouldLoadNode(t)}}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),r(this._index)&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;r(t)&&t.layerFilterChanged(e),this.requestUpdate()}};e([u({readOnly:!0})],B.prototype,"isMeshPyramid",null),e([u({readOnly:!0})],B.prototype,"isGraphics3D",null),e([u({readOnly:!0})],B.prototype,"indexStreamController",null),e([u({readOnly:!0})],B.prototype,"dataStreamController",null),e([u({readOnly:!0})],B.prototype,"crsVertex",null),e([u({readOnly:!0})],B.prototype,"crsIndex",null),e([u()],B.prototype,"screenSizeFactor",void 0),e([u()],B.prototype,"featureTarget",void 0),e([u()],B.prototype,"fixedFeatureTarget",void 0),e([u()],B.prototype,"layerView",void 0),e([u()],B.prototype,"layer",void 0),e([u({})],B.prototype,"updating",void 0),e([u({})],B.prototype,"updatingProgress",void 0),e([u({readOnly:!0})],B.prototype,"leavesReached",void 0),e([u({constructOnly:!0})],B.prototype,"scaleVisibilityEnabled",void 0),e([u({readOnly:!0,dependsOn:[]})],B.prototype,"rootNodeVisible",null),B=e([_("esri.layers.graphics.controllers.I3SOnDemandController")],B);const E=new o({deallocator:null});let H;function k(e,t){return r(e)&&e.length===t.length&&e.every((e=>R(t,e.name)>=0))}function R(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const z={factorIM:.2,factor3dObject:.05,distancePenalty:10},K=m(),$=B;export{$ 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.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{clone as t}from"../../../core/lang.js";import{isNone as i,isUndefined as s}from"../../../core/maybe.js";import{MemCacheStorage as r,MemCache as a}from"../../../core/MemCache.js";import{getMetersPerUnitForSR as u}from"../../../core/unitUtils.js";import{create as n,set as c,NEGATIVE_INFINITY as h,expandWithAABB as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as l,create as d}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as m}from"../../../geometry/support/boundsUtils.js";import{fromJSON as p,isExtent as y,isPolygon as f}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as _}from"../../../geometry/support/normalizeUtils.js";import{equals as x,isValid as g}from"../../../geometry/support/spatialReferenceUtils.js";import{validateFields as w,validateWhere as S,validateHaving as Q,hasInvalidFieldType as R}from"./attributeSupport.js";import{project as I,checkProjectionSupport as F}from"./projectionSupport.js";import{queryCapabilities as b}from"./QueryEngineCapabilities.js";import j from"./QueryEngineResult.js";import{getSpatialQueryOperator as A,canQueryWithRBush as E,checkSpatialQuerySupport as k}from"./spatialQuerySupport.js";import{getTimeExtent as C}from"./timeSupport.js";import{cleanFromGeometryEngine as T,normalizeQuery as O,QUERY_ENGINE_EMPTY_RESULT as B}from"./utils.js";import z from"../../support/FieldsIndex.js";import{PromiseQueue as P}from"../../support/PromiseQueue.js";import{loadArcade as G}from"../../../support/arcadeOnDemand.js";function q(e){return e.every((e=>"exceedslimit"!==e.statisticType))}const v="feature-store:unsupported-query";class M{constructor(e,t=null,i,s,r){this.attributes=e,this.geometry=i,this.centroid=s,this.filterFlags=r,this.groupId=-1,this.displayId=t}}const U=new Set,N=new r(2e6);let Z=0;class D{constructor(e){this.capabilities={query:b},this.geometryType=e.geometryType,this.hasM=e.hasM,this.hasZ=e.hasZ,this.objectIdField=e.objectIdField,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._changeHandle=this.featureStore.events.on("changed",(()=>this.clearCache())),this.timeInfo=e.timeInfo,e.cacheSpatialQueries&&(this._geometryQueryCache=new a(Z+++"$$",N)),this.fieldsIndex=new z(e.fields),e.scheduler&&e.priority&&(this._frameQueue=new P,this._frameTask=e.scheduler.registerTask(e.priority,this))}destroy(){this._frameTask&&(this._frameTask.remove(),this._frameTask=null,this._frameQueue.cancelAll(),this._frameQueue=null),this.clearCache(),this._geometryQueryCache&&this._geometryQueryCache.destroy(),this._changeHandle&&(this._changeHandle.remove(),this._changeHandle=null),this.fieldsIndex.destroy()}get featureAdapter(){return this.featureStore.featureAdapter}get fullExtent(){const e=this.featureStore.fullBounds;return e?{xmin:e[0],ymin:e[1],xmax:e[2],ymax:e[3],spatialReference:T(this.spatialReference)}:null}get timeExtent(){return this.timeInfo?(this._timeExtent||(this._timeExtent=C(this.timeInfo,this.featureStore)),this._timeExtent):null}clearCache(){this._geometryQueryCache&&this._geometryQueryCache.clear(),this._allItems=null,this._timeExtent=null}async executeQuery(e={},i){let s,r=t(e);try{r=await this._schedule((()=>O(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i)}catch(a){if(a!==B)throw a;s=new j([],null,this)}return s.createQueryResponse(r)}async executeQueryForCount(e={},i){let s,r=t(e);r.returnGeometry=!1,r.returnCentroid=!1,r.outSR=null;try{r=await this._schedule((()=>O(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i)}catch(a){if(a!==B)throw a;return 0}return s.createQueryResponseForCount(r)}async executeQueryForExtent(e={},i){let s,r=t(e);const a=r.outSR;try{r=await this._schedule((()=>O(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),r.returnGeometry=!0,r.returnCentroid=!1,r.outSR=null,s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.size;if(!e)return{count:e,extent:null};c(J,h),this.featureStore.forEachBounds(s.items,(e=>o(J,e)),H);const t={xmin:J[0],ymin:J[1],xmax:J[3],ymax:J[4],spatialReference:T(this.spatialReference)};this.hasZ&&isFinite(J[2])&&isFinite(J[5])&&(t.zmin=J[2],t.zmax=J[5]);const n=I(t,s.spatialReference,a);if(n.spatialReference=T(a||this.spatialReference),n.xmax-n.xmin==0){const e=u(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin==0){const e=u(n.spatialReference);n.ymin-=e,n.ymax+=e}if(this.hasZ&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin==0){const e=u(n.spatialReference);n.zmin-=e,n.zmax+=e}return{count:e,extent:n}}catch(n){if(n===B)return{count:0,extent:null};throw n}}async executeQueryForIds(e={},t){return this.executeQueryForIdSet(e,t).then((e=>Array.from(e)))}async executeQueryForIdSet(e={},i){let s,r=t(e);r.returnGeometry=!1,r.returnCentroid=!1,r.outSR=null;try{r=await this._schedule((()=>O(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.items,t=new Set;return await this._reschedule((()=>{for(const i of e)t.add(s.featureAdapter.getObjectId(i))}),i),t}catch(a){if(a===B)return new Set;throw a}}async executeQueryForSnapping(e,t){const{point:s,distance:r,types:a}=e;if(0===a)return{candidates:[]};const u=await this._reschedule((()=>this._checkQuerySupport(e.query)),t),n=!x(s.spatialReference,this.spatialReference);n&&await F(s.spatialReference,this.spatialReference);const c="number"==typeof r?r:r.x,h="number"==typeof r?r:r.y,o={xmin:s.x-c,xmax:s.x+c,ymin:s.y-h,ymax:s.y+h,spatialReference:s.spatialReference},l=n?I(o,this.spatialReference):o;if(!l)return{candidates:[]};const d=(await _(p(s),null,{signal:t}))[0],m=(await _(p(l),null,{signal:t}))[0];if(i(d)||i(m))return{candidates:[]};let y=new j(this._searchFeatures(this._getQueryBBoxes(m.toJSON())),null,this);y=await this._reschedule((()=>y.executeObjectIdsQuery(u)),t),y=await this._reschedule((()=>y.executeTimeQuery(u)),t),y=await this._reschedule((()=>y.executeAttributesQuery(u)),t);const f=d.toJSON(),g=n?I(f,this.spatialReference):f,w=n?Math.max(l.xmax-l.xmin,l.ymax-l.ymin)/2:r;return y.createSnappingResponse({...e,point:g,distance:w},s.spatialReference)}async executeQueryForLatestObservations(i={},s){if(!this.timeInfo||!this.timeInfo.trackIdField)throw new e(v,"Missing timeInfo or timeInfo.trackIdField",{query:i,timeInfo:this.timeInfo});let r,a=t(i);try{a=await this._schedule((()=>O(a,this.definitionExpression,this.spatialReference)),s),a=await this._reschedule((()=>this._checkQuerySupport(a)),s),r=await this._reschedule((()=>this._executeGeometryQuery(a,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(a)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(a)),s),r=await this._reschedule((()=>r.executeTimeQuery(a)),s),r=await this._reschedule((()=>r.executeAttributesQuery(a)),s),r=await this._reschedule((()=>r.filterLatest()),s)}catch(u){if(u!==B)throw u;r=new j([],null,this)}return r.createQueryResponse(a)}async executeQueryForSummaryStatistics(e={},i,s){let r;e=t(e);try{e=await this._schedule((()=>O(e,this.definitionExpression,this.spatialReference)),s),e=await this._reschedule((()=>this._checkSummaryStatisticsSupport(e,i)),s),r=await this._reschedule((()=>this._executeGeometryQuery(e,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(e)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(e)),s),r=await this._reschedule((()=>r.executeTimeQuery(e)),s),r=await this._reschedule((()=>r.executeAttributesQuery(e)),s)}catch(a){if(a!==B)throw a;r=new j([],null,this)}return r.createSummaryStatisticsResponse(e,i)}async executeQueryForUniqueValues(e={},i,s){let r;e=t(e);try{e=await this._schedule((()=>O(e,this.definitionExpression,this.spatialReference)),s),e=await this._reschedule((()=>this._checkSummaryStatisticsSupport(e,i)),s),r=await this._reschedule((()=>this._executeGeometryQuery(e,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(e)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(e)),s),r=await this._reschedule((()=>r.executeTimeQuery(e)),s),r=await this._reschedule((()=>r.executeAttributesQuery(e)),s)}catch(a){if(a!==B)throw a;r=new j([],null,this)}return r.createUniqueValuesResponse(e,i)}async _schedule(e,t){return this._frameQueue?this._frameQueue.push(e,t):e()}async _reschedule(e,t){return this._frameQueue?this._frameQueue.unshift(e,t):e()}get running(){return this._frameQueue.length>0}runTask(e){for(this._budget=e;!e.done&&this._frameQueue&&this._frameQueue.process();)e.madeProgress();this._budget=null}_getAll(){if(!this._allItems){const e=[];this.featureStore.forEach((t=>e.push(t))),this._allItems=new j(e,null,this)}return this._allItems}async _executeGeometryQuery(e,t){const{geometry:i,outSR:r,spatialRel:a,returnGeometry:u,returnCentroid:n}=e,c=u||n,h=g(r)&&!x(this.spatialReference,r),o=this._geometryQueryCache?h&&c?JSON.stringify({geometry:i,spatialRelationship:a,outSpatialReference:r}):JSON.stringify({geometry:i,spatialRelationship:a}):null;if(o){const e=this._geometryQueryCache.get(o);if(!s(e))return e}const l=async e=>{if(h&&c){const t=await e.project(r);return o&&this._geometryQueryCache.put(o,t,t.size||1),t}return o&&this._geometryQueryCache.put(o,e,e.size||1),e};if(!i)return l(this._getAll());const d=this.featureAdapter;if("esriSpatialRelDisjoint"===a){const e=this._searchFeatures(this._getQueryBBoxes(i));if(!e.length)return l(this._getAll());let s,r;const u=new Set;for(const t of e)u.add(d.getObjectId(t));await this._reschedule((()=>{let e=0;s=new Array(u.size),this.featureStore.forEach((t=>s[e++]=t)),r=u}),t);const n=await this._reschedule((async()=>{const e=await A(a,i,this.geometryType,this.hasZ,this.hasM),u=t=>!r.has(d.getObjectId(t))||e(d.getGeometry(t));return new j(await this._runSpatialFilter(s,u,t),i,this)}),t);return l(n)}const m=this._searchFeatures(this._getQueryBBoxes(i));if(!m.length){const e=new j([],i,this);return o&&this._geometryQueryCache.put(o,e,e.size||1),e}if(this._canExecuteSoloPass(i,e))return l(new j(m,i,this));const p=await A(a,i,this.geometryType,this.hasZ,this.hasM),y=await this._runSpatialFilter(m,(e=>p(d.getGeometry(e))),t);return l(new j(y,i,this))}async _runSpatialFilter(e,t,i){if(!t)return e;if(!this._budget)return e.filter((e=>t(e)));let s=0;const r=new Array,a=async()=>{for(;s<e.length;){const u=e[s];t(u)&&r.push(u),this._budget.done&&await this._reschedule((()=>a()),i),++s}};return this._reschedule((()=>a()),i).then((()=>r))}_canExecuteSoloPass(e,t){const{geometryType:i}=this,{spatialRel:s}=t;return E(e)&&("esriSpatialRelEnvelopeIntersects"===s||"esriGeometryPoint"===i&&("esriSpatialRelIntersects"===s||"esriSpatialRelContains"===s||"esriSpatialRelWithin"===s))}_getQueryBBoxes(e){if(E(e)){if(y(e))return[l(e.xmin,e.ymin,e.xmax,e.ymax)];if(f(e))return e.rings.map((e=>l(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1]))))}return[m(d(),e)]}_searchFeatures(e){for(const s of e)this.featureStore.forEachInBounds(s,(e=>{U.add(e)}));const t=new Array(U.size);let i=0;return U.forEach((e=>t[i++]=e)),U.clear(),t}async _checkSummaryStatisticsSupport(t,i){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(v,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkSummaryStatisticsParamsSupport(i),k(t,this.geometryType,this.spatialReference),F(this.spatialReference,t.outSR)]).then((()=>t))}async _checkSummaryStatisticsParamsSupport(t){let i=[];if(t.valueExpression){const{arcadeUtils:e}=await G();i=e.extractFieldNames(t.valueExpression)}if(t.field&&i.push(t.field),t.normalizationField&&i.push(t.normalizationField),!i.length)throw new e(v,"params should have at least a field or valueExpression",{params:t});w(this.fieldsIndex,i,"params contains missing fields")}async _checkQuerySupport(t){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(v,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkStatisticsQuerySupport(t),k(t,this.geometryType,this.spatialReference),F(this.spatialReference,t.outSR)]).then((()=>t))}_checkAttributesQuerySupport(t){const{outFields:i,orderByFields:s,returnDistinctValues:r,outStatistics:a}=t,u=a?a.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())):[];if(s&&s.length>0){const e=" asc",t=" desc",i=s.map((i=>{const s=i.toLowerCase();return s.indexOf(e)>-1?s.split(e)[0]:s.indexOf(t)>-1?s.split(t)[0]:i})).filter((e=>-1===u.indexOf(e)));w(this.fieldsIndex,i,"orderByFields contains missing fields")}if(i&&i.length>0)w(this.fieldsIndex,i,"outFields contains missing fields");else if(r)throw new e(v,"outFields should be specified for returnDistinctValues",{query:t});S(this.fieldsIndex,t.where)}async _checkStatisticsQuerySupport(t){const{outStatistics:i,groupByFieldsForStatistics:s,having:r}=t,a=s&&s.length,u=i&&i.length;if(r){if(!a||!u)throw new e(v,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:t});Q(this.fieldsIndex,r,i)}if(u){if(!q(i))return;const r=i.map((e=>e.onStatisticField));w(this.fieldsIndex,r,"onStatisticFields contains missing fields"),a&&w(this.fieldsIndex,s,"groupByFieldsForStatistics contains missing fields");for(const s of i){const{onStatisticField:i,statisticType:r}=s;if(("percentile_disc"===r||"percentile_cont"===r)&&"statisticParameters"in s){const{statisticParameters:i}=s;if(!i)throw new e(v,"statisticParamters should be set for percentile type",{definition:s,query:t})}else if("count"!==r&&i&&R(i,this.fieldsIndex))throw new e(v,"outStatistics contains non-numeric fields",{definition:s,query:t})}}}}const H=n(),J=n();export{M as Feature,D as default};
5
+ import e from"../../../core/Error.js";import{clone as t}from"../../../core/lang.js";import{isNone as i,isUndefined as s}from"../../../core/maybe.js";import{MemCacheStorage as r,MemCache as a}from"../../../core/MemCache.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{create as u,set as o,NEGATIVE_INFINITY as c,expandWithAABB as h}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as l,create as p}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as d}from"../../../geometry/support/boundsUtils.js";import{fromJSON as m,isExtent as y,isPolygon as f}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as _}from"../../../geometry/support/normalizeUtils.js";import{equals as x,isValid as g}from"../../../geometry/support/spatialReferenceUtils.js";import{validateFields as w,validateWhere as Q,validateHaving as S,hasInvalidFieldType as R}from"./attributeSupport.js";import{project as F,checkProjectionSupport as I}from"./projectionSupport.js";import{queryCapabilities as E}from"./QueryEngineCapabilities.js";import b from"./QueryEngineResult.js";import{getSpatialQueryOperator as j,canQueryWithRBush as A,checkSpatialQuerySupport as k}from"./spatialQuerySupport.js";import{getTimeExtent as C}from"./timeSupport.js";import{cleanFromGeometryEngine as z,normalizeQuery as B,QUERY_ENGINE_EMPTY_RESULT as T}from"./utils.js";import O from"../../support/FieldsIndex.js";import{PromiseQueue as v}from"../../support/PromiseQueue.js";import{loadArcade as P}from"../../../support/arcadeOnDemand.js";function q(e){return e.every((e=>"exceedslimit"!==e.statisticType))}const G="feature-store:unsupported-query";class M{constructor(e,t=null,i,s,r){this.attributes=e,this.geometry=i,this.centroid=s,this.filterFlags=r,this.groupId=-1,this.displayId=t}}const U=new Set,N=new r(2e6);let Z=0;class D{constructor(e){this.capabilities={query:E},this.geometryType=e.geometryType,this.hasM=e.hasM,this.hasZ=e.hasZ,this.objectIdField=e.objectIdField,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._changeHandle=this.featureStore.events.on("changed",(()=>this.clearCache())),this.timeInfo=e.timeInfo,e.cacheSpatialQueries&&(this._geometryQueryCache=new a(Z+++"$$",N)),this.fieldsIndex=new O(e.fields),e.scheduler&&e.priority&&(this._frameQueue=new v,this._frameTask=e.scheduler.registerTask(e.priority,this))}destroy(){this._frameTask&&(this._frameTask.remove(),this._frameTask=null,this._frameQueue.cancelAll(),this._frameQueue=null),this.clearCache(),this._geometryQueryCache&&this._geometryQueryCache.destroy(),this._changeHandle&&(this._changeHandle.remove(),this._changeHandle=null),this.fieldsIndex.destroy()}get featureAdapter(){return this.featureStore.featureAdapter}get fullExtent(){const e=this.featureStore.fullBounds;return e?{xmin:e[0],ymin:e[1],xmax:e[2],ymax:e[3],spatialReference:z(this.spatialReference)}:null}get timeExtent(){return this.timeInfo?(this._timeExtent||(this._timeExtent=C(this.timeInfo,this.featureStore)),this._timeExtent):null}clearCache(){this._geometryQueryCache&&this._geometryQueryCache.clear(),this._allItems=null,this._timeExtent=null}async executeQuery(e={},i){let s,r=t(e);try{r=await this._schedule((()=>B(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i)}catch(a){if(a!==T)throw a;s=new b([],null,this)}return s.createQueryResponse(r)}async executeQueryForCount(e={},i){let s,r=t(e);r.returnGeometry=!1,r.returnCentroid=!1,r.outSR=null;try{r=await this._schedule((()=>B(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i)}catch(a){if(a!==T)throw a;return 0}return s.createQueryResponseForCount(r)}async executeQueryForExtent(e={},i){let s,r=t(e);const a=r.outSR;try{r=await this._schedule((()=>B(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),r.returnGeometry=!0,r.returnCentroid=!1,r.outSR=null,s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.size;if(!e)return{count:e,extent:null};o(J,c),this.featureStore.forEachBounds(s.items,(e=>h(J,e)),H);const t={xmin:J[0],ymin:J[1],xmax:J[3],ymax:J[4],spatialReference:z(this.spatialReference)};this.hasZ&&isFinite(J[2])&&isFinite(J[5])&&(t.zmin=J[2],t.zmax=J[5]);const u=F(t,s.spatialReference,a);if(u.spatialReference=z(a||this.spatialReference),u.xmax-u.xmin==0){const e=n(u.spatialReference);u.xmin-=e,u.xmax+=e}if(u.ymax-u.ymin==0){const e=n(u.spatialReference);u.ymin-=e,u.ymax+=e}if(this.hasZ&&null!=u.zmin&&null!=u.zmax&&u.zmax-u.zmin==0){const e=n(u.spatialReference);u.zmin-=e,u.zmax+=e}return{count:e,extent:u}}catch(u){if(u===T)return{count:0,extent:null};throw u}}async executeQueryForIds(e={},t){return this.executeQueryForIdSet(e,t).then((e=>Array.from(e)))}async executeQueryForIdSet(e={},i){let s,r=t(e);r.returnGeometry=!1,r.returnCentroid=!1,r.outSR=null;try{r=await this._schedule((()=>B(r,this.definitionExpression,this.spatialReference)),i),r=await this._reschedule((()=>this._checkQuerySupport(r)),i),s=await this._reschedule((()=>this._executeGeometryQuery(r,i)),i),s=await this._reschedule((()=>s.executeAggregateIdsQuery(r)),i),s=await this._reschedule((()=>s.executeObjectIdsQuery(r)),i),s=await this._reschedule((()=>s.executeTimeQuery(r)),i),s=await this._reschedule((()=>s.executeAttributesQuery(r)),i);const e=s.items,t=new Set;return await this._reschedule((()=>{for(const i of e)t.add(s.featureAdapter.getObjectId(i))}),i),t}catch(a){if(a===T)return new Set;throw a}}async executeQueryForSnapping(e,t){const{point:s,distance:r,types:a}=e;if(0===a)return{candidates:[]};const n=await this._reschedule((()=>this._checkQuerySupport(e.query)),t),u=!x(s.spatialReference,this.spatialReference);u&&await I(s.spatialReference,this.spatialReference);const o="number"==typeof r?r:r.x,c="number"==typeof r?r:r.y,h={xmin:s.x-o,xmax:s.x+o,ymin:s.y-c,ymax:s.y+c,spatialReference:s.spatialReference},l=u?F(h,this.spatialReference):h;if(!l)return{candidates:[]};const p=(await _(m(s),null,{signal:t}))[0],d=(await _(m(l),null,{signal:t}))[0];if(i(p)||i(d))return{candidates:[]};let y=new b(this._searchFeatures(this._getQueryBBoxes(d.toJSON())),null,this);y=await this._reschedule((()=>y.executeObjectIdsQuery(n)),t),y=await this._reschedule((()=>y.executeTimeQuery(n)),t),y=await this._reschedule((()=>y.executeAttributesQuery(n)),t);const f=p.toJSON(),g=u?F(f,this.spatialReference):f,w=u?Math.max(l.xmax-l.xmin,l.ymax-l.ymin)/2:r;return y.createSnappingResponse({...e,point:g,distance:w},s.spatialReference)}async executeQueryForLatestObservations(i={},s){if(!this.timeInfo||!this.timeInfo.trackIdField)throw new e(G,"Missing timeInfo or timeInfo.trackIdField",{query:i,timeInfo:this.timeInfo});let r,a=t(i);try{a=await this._schedule((()=>B(a,this.definitionExpression,this.spatialReference)),s),a=await this._reschedule((()=>this._checkQuerySupport(a)),s),r=await this._reschedule((()=>this._executeGeometryQuery(a,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(a)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(a)),s),r=await this._reschedule((()=>r.executeTimeQuery(a)),s),r=await this._reschedule((()=>r.executeAttributesQuery(a)),s),r=await this._reschedule((()=>r.filterLatest()),s)}catch(n){if(n!==T)throw n;r=new b([],null,this)}return r.createQueryResponse(a)}async executeQueryForSummaryStatistics(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createSummaryStatisticsResponse(e,t)}async executeQueryForUniqueValues(e={},t,i){const{field:s,valueExpression:r}=t;return(await this._getQueryEngineResultForStats(e,{field:s,valueExpression:r},i)).createUniqueValuesResponse(e,t)}async executeQueryForClassBreaks(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createClassBreaksResponse(e,t)}async _schedule(e,t){return this._frameQueue?this._frameQueue.push(e,t):e()}async _reschedule(e,t){return this._frameQueue?this._frameQueue.unshift(e,t):e()}get running(){return this._frameQueue.length>0}runTask(e){for(this._budget=e;!e.done&&this._frameQueue&&this._frameQueue.process();)e.madeProgress();this._budget=null}_getAll(){if(!this._allItems){const e=[];this.featureStore.forEach((t=>e.push(t))),this._allItems=new b(e,null,this)}return this._allItems}async _executeGeometryQuery(e,t){const{geometry:i,outSR:r,spatialRel:a,returnGeometry:n,returnCentroid:u}=e,o=n||u,c=g(r)&&!x(this.spatialReference,r),h=this._geometryQueryCache?c&&o?JSON.stringify({geometry:i,spatialRelationship:a,outSpatialReference:r}):JSON.stringify({geometry:i,spatialRelationship:a}):null;if(h){const e=this._geometryQueryCache.get(h);if(!s(e))return e}const l=async e=>{if(c&&o){const t=await e.project(r);return h&&this._geometryQueryCache.put(h,t,t.size||1),t}return h&&this._geometryQueryCache.put(h,e,e.size||1),e};if(!i)return l(this._getAll());const p=this.featureAdapter;if("esriSpatialRelDisjoint"===a){const e=this._searchFeatures(this._getQueryBBoxes(i));if(!e.length)return l(this._getAll());let s,r;const n=new Set;for(const t of e)n.add(p.getObjectId(t));await this._reschedule((()=>{let e=0;s=new Array(n.size),this.featureStore.forEach((t=>s[e++]=t)),r=n}),t);const u=await this._reschedule((async()=>{const e=await j(a,i,this.geometryType,this.hasZ,this.hasM),n=t=>!r.has(p.getObjectId(t))||e(p.getGeometry(t));return new b(await this._runSpatialFilter(s,n,t),i,this)}),t);return l(u)}const d=this._searchFeatures(this._getQueryBBoxes(i));if(!d.length){const e=new b([],i,this);return h&&this._geometryQueryCache.put(h,e,e.size||1),e}if(this._canExecuteSoloPass(i,e))return l(new b(d,i,this));const m=await j(a,i,this.geometryType,this.hasZ,this.hasM),y=await this._runSpatialFilter(d,(e=>m(p.getGeometry(e))),t);return l(new b(y,i,this))}async _runSpatialFilter(e,t,i){if(!t)return e;if(!this._budget)return e.filter((e=>t(e)));let s=0;const r=new Array,a=async()=>{for(;s<e.length;){const n=e[s];t(n)&&r.push(n),this._budget.done&&await this._reschedule((()=>a()),i),++s}};return this._reschedule((()=>a()),i).then((()=>r))}_canExecuteSoloPass(e,t){const{geometryType:i}=this,{spatialRel:s}=t;return A(e)&&("esriSpatialRelEnvelopeIntersects"===s||"esriGeometryPoint"===i&&("esriSpatialRelIntersects"===s||"esriSpatialRelContains"===s||"esriSpatialRelWithin"===s))}_getQueryBBoxes(e){if(A(e)){if(y(e))return[l(e.xmin,e.ymin,e.xmax,e.ymax)];if(f(e))return e.rings.map((e=>l(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1]))))}return[d(p(),e)]}_searchFeatures(e){for(const s of e)this.featureStore.forEachInBounds(s,(e=>{U.add(e)}));const t=new Array(U.size);let i=0;return U.forEach((e=>t[i++]=e)),U.clear(),t}async _checkStatisticsSupport(t,i){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(G,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkStatisticsParamsSupport(i),k(t,this.geometryType,this.spatialReference),I(this.spatialReference,t.outSR)]).then((()=>t))}async _checkStatisticsParamsSupport(t){let i=[];if(t.valueExpression){const{arcadeUtils:e}=await P();i=e.extractFieldNames(t.valueExpression)}if(t.field&&i.push(t.field),t.normalizationField&&i.push(t.normalizationField),!i.length)throw new e(G,"params should have at least a field or valueExpression",{params:t});w(this.fieldsIndex,i,"params contains missing fields")}async _checkQuerySupport(t){if(t.distance<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(G,"Unsupported query options",{query:t});return Promise.all([this._checkAttributesQuerySupport(t),this._checkStatisticsQuerySupport(t),k(t,this.geometryType,this.spatialReference),I(this.spatialReference,t.outSR)]).then((()=>t))}_checkAttributesQuerySupport(t){const{outFields:i,orderByFields:s,returnDistinctValues:r,outStatistics:a}=t,n=a?a.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())):[];if(s&&s.length>0){const e=" asc",t=" desc",i=s.map((i=>{const s=i.toLowerCase();return s.indexOf(e)>-1?s.split(e)[0]:s.indexOf(t)>-1?s.split(t)[0]:i})).filter((e=>-1===n.indexOf(e)));w(this.fieldsIndex,i,"orderByFields contains missing fields")}if(i&&i.length>0)w(this.fieldsIndex,i,"outFields contains missing fields");else if(r)throw new e(G,"outFields should be specified for returnDistinctValues",{query:t});Q(this.fieldsIndex,t.where)}async _checkStatisticsQuerySupport(t){const{outStatistics:i,groupByFieldsForStatistics:s,having:r}=t,a=s&&s.length,n=i&&i.length;if(r){if(!a||!n)throw new e(G,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:t});S(this.fieldsIndex,r,i)}if(n){if(!q(i))return;const r=i.map((e=>e.onStatisticField));w(this.fieldsIndex,r,"onStatisticFields contains missing fields"),a&&w(this.fieldsIndex,s,"groupByFieldsForStatistics contains missing fields");for(const s of i){const{onStatisticField:i,statisticType:r}=s;if(("percentile_disc"===r||"percentile_cont"===r)&&"statisticParameters"in s){const{statisticParameters:i}=s;if(!i)throw new e(G,"statisticParamters should be set for percentile type",{definition:s,query:t})}else if("count"!==r&&i&&R(i,this.fieldsIndex))throw new e(G,"outStatistics contains non-numeric fields",{definition:s,query:t})}}}async _getQueryEngineResultForStats(e={},i,s){let r;e=t(e);try{e=await this._schedule((()=>B(e,this.definitionExpression,this.spatialReference)),s),e=await this._reschedule((()=>this._checkStatisticsSupport(e,i)),s),r=await this._reschedule((()=>this._executeGeometryQuery(e,s)),s),r=await this._reschedule((()=>r.executeAggregateIdsQuery(e)),s),r=await this._reschedule((()=>r.executeObjectIdsQuery(e)),s),r=await this._reschedule((()=>r.executeTimeQuery(e)),s),r=await this._reschedule((()=>r.executeAttributesQuery(e)),s)}catch(a){if(a!==T)throw a;r=new b([],null,this)}return r}}const H=u(),J=u();export{M as Feature,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.22/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as t}from"../../../core/maybe.js";import{toQuantizationTransform as s}from"../../../geometry/support/quantizationUtils.js";import{isValid as i,equals as r}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as n}from"../featureConversionUtils.js";import a from"./AttributesBuilder.js";import{getWhereClause as o}from"./attributeSupport.js";import{project as u,projectMany as l}from"./projectionSupport.js";import{getTimeOperator as c}from"./timeSupport.js";import{cleanFromGeometryEngine as d,getGeometry as h,transformCentroid as m}from"./utils.js";import{isStringField as f}from"../../support/fieldUtils.js";import{isNullCountSupported as p,calculateStringStatistics as g,calculateStatistics as y,processStatsResult as I,calculateUniqueValuesCount as x,createUVResult as b}from"../../../statistics/utils.js";import{loadArcade as F}from"../../../support/arcadeOnDemand.js";function T(e){return e.substr(24,12)+e.substr(19,4)+e.substr(16,2)+e.substr(14,2)+e.substr(11,2)+e.substr(9,2)+e.substr(6,2)+e.substr(4,2)+e.substr(2,2)+e.substr(0,2)}function V(e,t,s){return(s?e>t:e<t)?-1:(s?e<t:e>t)?1:0}function A(e,t,s){return s?t-e:e-t}function S(e,t,s,i){if(s&&"esriFieldTypeDate"===s.type){const s=new Date(e).getTime(),r=new Date(t).getTime();if(!isNaN(s)&&!isNaN(r))return A(s,r,i)}if("number"==typeof e&&"number"==typeof t)return A(e,t,i);if("string"==typeof e&&"string"==typeof t){const r=e.toUpperCase(),n=t.toUpperCase();return!s||"esriFieldTypeGUID"!==s.type&&"esriFieldTypeGlobalID"!==s.type?V(r,n,i):V(T(r),T(n),i)}return i?1:-1}class _{constructor(e,t,s){this.items=e,this.queryGeometry=t,this.definitionExpression=s.definitionExpression,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.fieldsIndex=s.fieldsIndex,this.timeInfo=s.timeInfo,this.featureAdapter=s.featureAdapter,this.aggregateAdapter=s.aggregateAdapter}get size(){return this.items.length}createQueryResponseForCount(e){const t=new a(e,this.featureAdapter,this.fieldsIndex);if(!e.outStatistics)return t.countDistinctValues(this.items);const{groupByFieldsForStatistics:s,having:i}=e;if(!!!(null==s?void 0:s.length))return 1;const r=new Map,n=new Map,o=new Set,u=e.outStatistics;for(const a of u){const{statisticType:e}=a,u="exceedslimit"!==e?a.onStatisticField:void 0;if(!n.has(u)){const e=[];for(const i of s){const s=this._getAttributeValues(t,i,r);e.push(s)}n.set(u,this._calculateUniqueValues(e,t.returnDistinctValues))}const l=n.get(u);for(const s in l){const{data:e,items:r}=l[s],n=e.join(",");i&&!t.validateItems(r,i)||o.add(n)}}return o.size}createQueryResponse(e){let t;if(e.outStatistics){t=e.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(e):this._createStatisticsQueryResponse(e)}else t=this._createFeatureQueryResponse(e);return e.returnQueryGeometry&&(i(e.outSR)&&!r(this.queryGeometry.spatialReference,e.outSR)?t.queryGeometry=d({spatialReference:e.outSR,...u(this.queryGeometry,this.queryGeometry.spatialReference,e.outSR)}):t.queryGeometry=d({spatialReference:e.outSR,...this.queryGeometry})),t}createSnappingResponse(t,s){const i=this.featureAdapter,r=v(this.hasZ,this.hasM),{x:n,y:a}=t.point,o="number"==typeof t.distance?t.distance:t.distance.x,u="number"==typeof t.distance?t.distance:t.distance.y,l={candidates:[]},c="esriGeometryPolygon"===this.geometryType,d=this.getPointCreator(t.point,this.spatialReference,s);for(const h of this.items){const s=i.getGeometry(h);if(e(s))continue;const{coords:m,lengths:f}=s;if(1&t.types){let e=0;for(let t=0;t<f.length;t++){const s=f[t];for(let t=0;t<s;t++,e+=r){const c=m[e],f=m[e+1];if(t!==s-1){const t=m[e+r],s=m[e+r+1],{x:p,y:g}=P(n,a,c,f,t,s),y=(n-p)/o,I=(a-g)/u,x=y*y+I*I;x<=1&&l.candidates.push({type:"edge",objectId:i.getObjectId(h),distance:Math.sqrt(x),target:d(p,g),start:d(c,f),end:d(t,s)})}}}}if(2&t.types){const e=c?m.length-r:m.length;for(let t=0;t<e;t+=r){const e=m[t],s=m[t+1],r=(n-e)/o,c=(a-s)/u,f=r*r+c*c;f<=1&&l.candidates.push({type:"vertex",objectId:i.getObjectId(h),distance:Math.sqrt(f),target:d(e,s)})}}}return l.candidates.sort(((e,t)=>e.distance-t.distance)),l}getPointCreator(e,s,i){const n=t(i)&&!r(s,i)?e=>u(e,s,i):e=>e;return null!=e.z&&null!=e.m?(t,s)=>n({x:t,y:s,z:e.z,m:e.m}):null!=e.z?(t,s)=>n({x:t,y:s,z:e.z}):null!=e.m?(t,s)=>n({x:t,y:s,m:e.m}):(e,t)=>n({x:e,y:t})}executeAttributesQuery(e){const t=o(e.where,this.fieldsIndex);if(!t)return Promise.resolve(this);if(t.isStandardized){let s=0;const i=[];for(const e of this.items)t.testFeature(e,this.featureAdapter)&&(i[s++]=e);const r=new _(i,this.queryGeometry,this);return r.definitionExpression=e.where,Promise.resolve(r)}return Promise.reject(new TypeError("Where clause is not standardized"))}executeAggregateIdsQuery(t){if(!t.aggregateIds||!t.aggregateIds.length||e(this.aggregateAdapter))return Promise.resolve(this);const s=new Set;for(const e of t.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(e).forEach((e=>s.add(e)))}const i=this.featureAdapter.getObjectId;return Promise.resolve(new _(this.items.filter((e=>s.has(i(e)))),this.queryGeometry,this))}executeObjectIdsQuery(e){if(!e.objectIds||!e.objectIds.length)return Promise.resolve(this);const t=new Set(e.objectIds),s=this.featureAdapter.getObjectId;return Promise.resolve(new _(this.items.filter((e=>t.has(s(e)))),this.queryGeometry,this))}executeTimeQuery(e){const s=c(this.timeInfo,e.timeExtent,this.featureAdapter);if(!t(s))return Promise.resolve(this);const i=this.items.filter(s);return Promise.resolve(new _(i,this.queryGeometry,this))}filterLatest(){const{trackIdField:e,startTimeField:t,endTimeField:s}=this.timeInfo,i=s||t,r=new Map,n=this.featureAdapter.getAttribute;for(const o of this.items){const t=n(o,e),s=n(o,i),a=r.get(t);(!a||s>n(a,i))&&r.set(t,o)}const a=Array.from(r.values());return Promise.resolve(new _(a,this.queryGeometry,this))}async project(e){if(!e||r(this.spatialReference,e))return this;const t=this.featureAdapter,s=(await l(this.items.map((e=>h(this.geometryType,this.hasZ,this.hasM,t.getGeometry(e)))),this.spatialReference,e)).map(((e,s)=>t.cloneWithGeometry(this.items[s],n(e,this.hasZ,this.hasM))));return new _(s,this.queryGeometry,{definitionExpression:this.definitionExpression,geometryType:this.geometryType,hasM:this.hasM,hasZ:this.hasZ,objectIdField:this.objectIdField,spatialReference:e,fieldsIndex:this.fieldsIndex,timeInfo:this.timeInfo,featureAdapter:this.featureAdapter})}async createSummaryStatisticsResponse(e,t){const{field:s,normalizationField:i,normalizationType:r,normalizationTotal:n,minValue:o,maxValue:u}=t,l=new a(e,this.featureAdapter,this.fieldsIndex),c=this.fieldsIndex.isDateField(s),d=t.valueExpression?await this._getAttributeExpressionValues(l,t.valueExpression,t.viewInfoParams):this._getAttributeNormalizedValues(l,{field:s,normalizationField:i,normalizationType:r,normalizationTotal:n}),h=p({normalizationType:r,normalizationField:i,minValue:o,maxValue:u}),m=f(this.fieldsIndex.get(s))?g({values:d,supportsNullCount:h}):y({values:d,minValue:o,maxValue:u,useSampleStdDev:!r,supportsNullCount:h});return I(m,c)}async createUniqueValuesResponse(e,t){const{field:s,valueExpression:i,domain:r,returnAllCodedValues:n}=t,o=new a(e,this.featureAdapter,this.fieldsIndex),u=i?await this._getAttributeExpressionValues(o,i,t.viewInfoParams):this._getAttributeNormalizedValues(o,{field:s}),l=x(u);return b(l,r,n)}_sortFeatures(e,t,s){if(e.length>1&&t&&t.length)for(const i of t.reverse()){const t=i.split(" "),r=t[0],n=this.fieldsIndex.get(r),a=t[1]&&"desc"===t[1].toLowerCase();e.sort(((e,t)=>S(s(e,r,n),s(t,r,n),n,a)))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:i,hasM:r,hasZ:n,objectIdField:a,spatialReference:o}=this,{outFields:u,outSR:l,quantizationParameters:c,resultRecordCount:h,resultOffset:m,returnZ:f,returnM:p}=e,g=null!=h&&t.length>(m||0)+h,y=u&&(u.indexOf("*")>-1?[...this.fieldsIndex.fields]:u.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:g,features:this._createFeatures(e,t),fields:y,geometryType:i,hasM:r&&p,hasZ:n&&f,objectIdFieldName:a,spatialReference:d(l||o),transform:c&&s(c)||null}}_createFeatures(e,t){const i=new a(e,this.featureAdapter,this.fieldsIndex),{hasM:r,hasZ:n}=this,{orderByFields:o,quantizationParameters:u,returnGeometry:l,returnCentroid:c,maxAllowableOffset:d,resultOffset:f,resultRecordCount:p,returnZ:g=!1,returnM:y=!1}=e,I=n&&g,x=r&&y;let b=[],F=0;const T=[...t];if(this._sortFeatures(T,o,((e,t,s)=>i.getFieldValue(e,t,s))),l||c){const e=s(u);if(l&&!c)for(const t of T)b[F++]={attributes:i.getAttributes(t),geometry:h(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,I,x)};else if(!l&&c)for(const t of T)b[F++]={attributes:i.getAttributes(t),centroid:m(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of T)b[F++]={attributes:i.getAttributes(t),centroid:m(this,this.featureAdapter.getCentroid(t,this),e),geometry:h(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,I,x)}}else for(const s of T){const e=i.getAttributes(s);e&&(b[F++]={attributes:e})}const V=f||0;if(null!=p){const e=V+p;b=b.slice(V,Math.min(b.length,e))}return b}_createExceedsLimitQueryResponse(e){let s=!1,i=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY;for(const t of e.outStatistics)if("exceedslimit"===t.statisticType){i=null!=t.maxPointCount?t.maxPointCount:Number.POSITIVE_INFINITY,r=null!=t.maxRecordCount?t.maxRecordCount:Number.POSITIVE_INFINITY,n=null!=t.maxVertexCount?t.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)s=this.items.length>i;else if(this.items.length>r)s=!0;else{const e=this.hasZ?this.hasM?4:3:this.hasM?3:2,i=this.featureAdapter;s=this.items.reduce(((e,s)=>{const r=i.getGeometry(s);return e+(t(r)&&r.coords.length||0)}),0)/e>n}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(s)}}]}}_createStatisticsQueryResponse(e){const t={attributes:{}},s=[],i=new Map,r=new Map,n=new Map,o=new Map,u=new a(e,this.featureAdapter,this.fieldsIndex),l=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:h}=e,m=c&&c.length,f=!!m,p=f&&c[0],g=f&&!this.fieldsIndex.get(p);for(const a of l){const{outStatisticFieldName:e,statisticType:l}=a,h=a,y="exceedslimit"!==l?a.onStatisticField:void 0,I="percentile_disc"===l||"percentile_cont"===l,x=f&&1===m&&(y===p||g)&&"count"===l;if(f){if(!n.has(y)){const e=[];for(const t of c){const s=this._getAttributeValues(u,t,i);e.push(s)}n.set(y,this._calculateUniqueValues(e,u.returnDistinctValues))}const t=n.get(y);for(const s in t){const{count:r,data:n,items:a,itemPositions:l}=t[s],m=n.join(",");if(!d||u.validateItems(a,d)){const t=o.get(m)||{attributes:{}};let s=null;if(x)s=r;else{const e=this._getAttributeValues(u,y,i),t=l.map((t=>e[t]));s=I&&"statisticParameters"in h?this._getPercentileValue(h,t):this._getStatisticValue(h,t,null,u.returnDistinctValues)}t.attributes[e]=s,c.forEach(((e,s)=>t.attributes[this.fieldsIndex.get(e)?e:`EXPR_${s+1}`]=n[s])),o.set(m,t)}}}else{const s=this._getAttributeValues(u,y,i);t.attributes[e]=I&&"statisticParameters"in h?this._getPercentileValue(h,s):this._getStatisticValue(h,s,r,u.returnDistinctValues)}s.push({name:e,alias:e,type:"esriFieldTypeDouble"})}const y=f?Array.from(o.values()):[t];return this._sortFeatures(y,h,((e,t)=>e.attributes[t])),{fields:s,features:y}}_getStatisticValue(e,t,s,i){const{onStatisticField:r,statisticType:n}=e;let a=null;a=null!=s&&s.has(r)?s.get(r):f(this.fieldsIndex.get(r))?g({values:t,returnDistinct:i}):y({values:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(r,a);return a["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:r}=e,{value:n,orderBy:a}=i,o="desc"===a,u=this.fieldsIndex.get(s),l=[...t].filter((e=>null!=e)).sort(((e,t)=>S(e,t,u,o)));return this._calculatePercentile(l,n,"percentile_disc"===r)}_getAttributeValues(e,t,s){if(s.has(t))return s.get(t);const i=this.fieldsIndex.get(t),r=this.items.map((s=>e.getFieldValue(s,t,i)));return s.set(t,r),r}_getAttributeNormalizedValues(e,t){return this.items.map((s=>e.getNormalizedValue(s,{field:t.field,fieldInfo:this.fieldsIndex.get(t.field),normalizationField:t.normalizationField,normalizationFieldInfo:this.fieldsIndex.get(t.normalizationField),normalizationType:t.normalizationType,normalizationTotal:t.normalizationTotal})))}async _getAttributeExpressionValues(e,t,s){const{arcadeUtils:i}=await F(),r=i.createFunction(t),n=s&&i.getViewInfo(s);return this.items.map((t=>e.getExpressionValue(t,{compiledFunc:r,viewInfo:n},i)))}_calculateUniqueValues(e,t){const s={},i=this.items,r=i.length;for(let n=0;n<r;n++){const r=i[n],a=[];for(const t of e)a.push(t[n]);const o=a.join(",");t?null==s[o]&&(s[o]={count:1,data:a,items:[r],itemPositions:[n]}):null==s[o]?s[o]={count:1,data:a,items:[r],itemPositions:[n]}:(s[o].count++,s[o].items.push(r),s[o].itemPositions.push(n))}return s}_calculatePercentile(e,t,s){if(0===e.length)return null;if(t<=0)return e[0];if(t>=1)return e[e.length-1];const i=(e.length-1)*t,r=Math.floor(i),n=r+1,a=i%1,o=e[r],u=e[n];return n>=e.length||s||"string"==typeof o||"string"==typeof u?o:o*(1-a)+u*a}}function P(e,t,s,i,r,n){const a=r-s,o=n-i,u=a*a+o*o,l=(e-s)*a+(t-i)*o,c=Math.min(1,Math.max(0,l/u));return{x:s+a*c,y:i+o*c}}function v(e,t){return e?t?4:3:t?3:2}export{_ as default};
5
+ import{isNone as e,isSome as t}from"../../../core/maybe.js";import{toQuantizationTransform as s}from"../../../geometry/support/quantizationUtils.js";import{isValid as i,equals as r}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as a}from"../featureConversionUtils.js";import n from"./AttributesBuilder.js";import{getWhereClause as o}from"./attributeSupport.js";import{project as l,projectMany as u}from"./projectionSupport.js";import{getTimeOperator as c}from"./timeSupport.js";import{cleanFromGeometryEngine as d,getGeometry as m,transformCentroid as h}from"./utils.js";import{isStringField as f}from"../../support/fieldUtils.js";import{isNullCountSupported as p,calculateStringStatistics as y,calculateStatistics as g,processStatsResult as I,calculateUniqueValuesCount as x,createUVResult as b,calculateClassBreaks as T,resolveCBResult as F}from"../../../statistics/utils.js";import{loadArcade as V}from"../../../support/arcadeOnDemand.js";function z(e){return e.substr(24,12)+e.substr(19,4)+e.substr(16,2)+e.substr(14,2)+e.substr(11,2)+e.substr(9,2)+e.substr(6,2)+e.substr(4,2)+e.substr(2,2)+e.substr(0,2)}function A(e,t,s){return(s?e>t:e<t)?-1:(s?e<t:e>t)?1:0}function S(e,t,s){return s?t-e:e-t}function _(e,t,s,i){if(s&&"esriFieldTypeDate"===s.type){const s=new Date(e).getTime(),r=new Date(t).getTime();if(!isNaN(s)&&!isNaN(r))return S(s,r,i)}if("number"==typeof e&&"number"==typeof t)return S(e,t,i);if("string"==typeof e&&"string"==typeof t){const r=e.toUpperCase(),a=t.toUpperCase();return!s||"esriFieldTypeGUID"!==s.type&&"esriFieldTypeGlobalID"!==s.type?A(r,a,i):A(z(r),z(a),i)}return i?1:-1}class v{constructor(e,t,s){this.items=e,this.queryGeometry=t,this.definitionExpression=s.definitionExpression,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.fieldsIndex=s.fieldsIndex,this.timeInfo=s.timeInfo,this.featureAdapter=s.featureAdapter,this.aggregateAdapter=s.aggregateAdapter}get size(){return this.items.length}createQueryResponseForCount(e){const t=new n(e,this.featureAdapter,this.fieldsIndex);if(!e.outStatistics)return t.countDistinctValues(this.items);const{groupByFieldsForStatistics:s,having:i}=e;if(!!!(null==s?void 0:s.length))return 1;const r=new Map,a=new Map,o=new Set,l=e.outStatistics;for(const n of l){const{statisticType:e}=n,l="exceedslimit"!==e?n.onStatisticField:void 0;if(!a.has(l)){const e=[];for(const i of s){const s=this._getAttributeValues(t,i,r);e.push(s)}a.set(l,this._calculateUniqueValues(e,t.returnDistinctValues))}const u=a.get(l);for(const s in u){const{data:e,items:r}=u[s],a=e.join(",");i&&!t.validateItems(r,i)||o.add(a)}}return o.size}createQueryResponse(e){let t;if(e.outStatistics){t=e.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(e):this._createStatisticsQueryResponse(e)}else t=this._createFeatureQueryResponse(e);return e.returnQueryGeometry&&(i(e.outSR)&&!r(this.queryGeometry.spatialReference,e.outSR)?t.queryGeometry=d({spatialReference:e.outSR,...l(this.queryGeometry,this.queryGeometry.spatialReference,e.outSR)}):t.queryGeometry=d({spatialReference:e.outSR,...this.queryGeometry})),t}createSnappingResponse(t,s){const i=this.featureAdapter,r=P(this.hasZ,this.hasM),{x:a,y:n}=t.point,o="number"==typeof t.distance?t.distance:t.distance.x,l="number"==typeof t.distance?t.distance:t.distance.y,u={candidates:[]},c="esriGeometryPolygon"===this.geometryType,d=this.getPointCreator(t.point,this.spatialReference,s);for(const m of this.items){const s=i.getGeometry(m);if(e(s))continue;const{coords:h,lengths:f}=s;if(1&t.types){let e=0;for(let t=0;t<f.length;t++){const s=f[t];for(let t=0;t<s;t++,e+=r){const c=h[e],f=h[e+1];if(t!==s-1){const t=h[e+r],s=h[e+r+1],{x:p,y}=R(a,n,c,f,t,s),g=(a-p)/o,I=(n-y)/l,x=g*g+I*I;x<=1&&u.candidates.push({type:"edge",objectId:i.getObjectId(m),distance:Math.sqrt(x),target:d(p,y),start:d(c,f),end:d(t,s)})}}}}if(2&t.types){const e=c?h.length-r:h.length;for(let t=0;t<e;t+=r){const e=h[t],s=h[t+1],r=(a-e)/o,c=(n-s)/l,f=r*r+c*c;f<=1&&u.candidates.push({type:"vertex",objectId:i.getObjectId(m),distance:Math.sqrt(f),target:d(e,s)})}}}return u.candidates.sort(((e,t)=>e.distance-t.distance)),u}getPointCreator(e,s,i){const a=t(i)&&!r(s,i)?e=>l(e,s,i):e=>e;return null!=e.z&&null!=e.m?(t,s)=>a({x:t,y:s,z:e.z,m:e.m}):null!=e.z?(t,s)=>a({x:t,y:s,z:e.z}):null!=e.m?(t,s)=>a({x:t,y:s,m:e.m}):(e,t)=>a({x:e,y:t})}executeAttributesQuery(e){const t=o(e.where,this.fieldsIndex);if(!t)return Promise.resolve(this);if(t.isStandardized){let s=0;const i=[];for(const e of this.items)t.testFeature(e,this.featureAdapter)&&(i[s++]=e);const r=new v(i,this.queryGeometry,this);return r.definitionExpression=e.where,Promise.resolve(r)}return Promise.reject(new TypeError("Where clause is not standardized"))}executeAggregateIdsQuery(t){if(!t.aggregateIds||!t.aggregateIds.length||e(this.aggregateAdapter))return Promise.resolve(this);const s=new Set;for(const e of t.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(e).forEach((e=>s.add(e)))}const i=this.featureAdapter.getObjectId;return Promise.resolve(new v(this.items.filter((e=>s.has(i(e)))),this.queryGeometry,this))}executeObjectIdsQuery(e){if(!e.objectIds||!e.objectIds.length)return Promise.resolve(this);const t=new Set(e.objectIds),s=this.featureAdapter.getObjectId;return Promise.resolve(new v(this.items.filter((e=>t.has(s(e)))),this.queryGeometry,this))}executeTimeQuery(e){const s=c(this.timeInfo,e.timeExtent,this.featureAdapter);if(!t(s))return Promise.resolve(this);const i=this.items.filter(s);return Promise.resolve(new v(i,this.queryGeometry,this))}filterLatest(){const{trackIdField:e,startTimeField:t,endTimeField:s}=this.timeInfo,i=s||t,r=new Map,a=this.featureAdapter.getAttribute;for(const o of this.items){const t=a(o,e),s=a(o,i),n=r.get(t);(!n||s>a(n,i))&&r.set(t,o)}const n=Array.from(r.values());return Promise.resolve(new v(n,this.queryGeometry,this))}async project(e){if(!e||r(this.spatialReference,e))return this;const t=this.featureAdapter,s=(await u(this.items.map((e=>m(this.geometryType,this.hasZ,this.hasM,t.getGeometry(e)))),this.spatialReference,e)).map(((e,s)=>t.cloneWithGeometry(this.items[s],a(e,this.hasZ,this.hasM))));return new v(s,this.queryGeometry,{definitionExpression:this.definitionExpression,geometryType:this.geometryType,hasM:this.hasM,hasZ:this.hasZ,objectIdField:this.objectIdField,spatialReference:e,fieldsIndex:this.fieldsIndex,timeInfo:this.timeInfo,featureAdapter:this.featureAdapter})}async createSummaryStatisticsResponse(e,t){const{field:s,valueExpression:i,normalizationField:r,normalizationType:a,normalizationTotal:n,minValue:o,maxValue:l,scale:u}=t,c=this.fieldsIndex.isDateField(s),d=await this._getDataValues(e,{field:s,valueExpression:i,normalizationField:r,normalizationType:a,normalizationTotal:n,scale:u}),m=p({normalizationType:a,normalizationField:r,minValue:o,maxValue:l}),h=f(this.fieldsIndex.get(s))?y({values:d,supportsNullCount:m}):g({values:d,minValue:o,maxValue:l,useSampleStdDev:!a,supportsNullCount:m});return I(h,c)}async createUniqueValuesResponse(e,t){const{field:s,valueExpression:i,domain:r,returnAllCodedValues:a,scale:n}=t,o=await this._getDataValues(e,{field:s,valueExpression:i,scale:n}),l=x(o);return b(l,r,a)}async createClassBreaksResponse(e,t){const{field:s,valueExpression:i,normalizationField:r,normalizationType:a,normalizationTotal:n,classificationMethod:o,standardDeviationInterval:l,minValue:u,maxValue:c,numClasses:d,scale:m}=t,h=await this._getDataValues(e,{field:s,valueExpression:i,normalizationField:r,normalizationType:a,normalizationTotal:n,scale:m}),f=T(h,{field:s,normalizationField:r,normalizationType:a,normalizationTotal:n,classificationMethod:o,standardDeviationInterval:l,minValue:u,maxValue:c,numClasses:d});return F(f,o)}_sortFeatures(e,t,s){if(e.length>1&&t&&t.length)for(const i of t.reverse()){const t=i.split(" "),r=t[0],a=this.fieldsIndex.get(r),n=t[1]&&"desc"===t[1].toLowerCase();e.sort(((e,t)=>_(s(e,r,a),s(t,r,a),a,n)))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:i,hasM:r,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:h,returnZ:f,returnM:p}=e,y=null!=m&&t.length>(h||0)+m,g=l&&(l.indexOf("*")>-1?[...this.fieldsIndex.fields]:l.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:r&&p,hasZ:a&&f,objectIdFieldName:n,spatialReference:d(u||o),transform:c&&s(c)||null}}_createFeatures(e,t){const i=new n(e,this.featureAdapter,this.fieldsIndex),{hasM:r,hasZ:a}=this,{orderByFields:o,quantizationParameters:l,returnGeometry:u,returnCentroid:c,maxAllowableOffset:d,resultOffset:f,resultRecordCount:p,returnZ:y=!1,returnM:g=!1}=e,I=a&&y,x=r&&g;let b=[],T=0;const F=[...t];if(this._sortFeatures(F,o,((e,t,s)=>i.getFieldValue(e,t,s))),u||c){const e=s(l);if(u&&!c)for(const t of F)b[T++]={attributes:i.getAttributes(t),geometry:m(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,I,x)};else if(!u&&c)for(const t of F)b[T++]={attributes:i.getAttributes(t),centroid:h(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of F)b[T++]={attributes:i.getAttributes(t),centroid:h(this,this.featureAdapter.getCentroid(t,this),e),geometry:m(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,I,x)}}else for(const s of F){const e=i.getAttributes(s);e&&(b[T++]={attributes:e})}const V=f||0;if(null!=p){const e=V+p;b=b.slice(V,Math.min(b.length,e))}return b}_createExceedsLimitQueryResponse(e){let s=!1,i=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY;for(const t of e.outStatistics)if("exceedslimit"===t.statisticType){i=null!=t.maxPointCount?t.maxPointCount:Number.POSITIVE_INFINITY,r=null!=t.maxRecordCount?t.maxRecordCount:Number.POSITIVE_INFINITY,a=null!=t.maxVertexCount?t.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)s=this.items.length>i;else if(this.items.length>r)s=!0;else{const e=this.hasZ?this.hasM?4:3:this.hasM?3:2,i=this.featureAdapter;s=this.items.reduce(((e,s)=>{const r=i.getGeometry(s);return e+(t(r)&&r.coords.length||0)}),0)/e>a}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(s)}}]}}_createStatisticsQueryResponse(e){const t={attributes:{}},s=[],i=new Map,r=new Map,a=new Map,o=new Map,l=new n(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:m}=e,h=c&&c.length,f=!!h,p=f&&c[0],y=f&&!this.fieldsIndex.get(p);for(const n of u){const{outStatisticFieldName:e,statisticType:u}=n,m=n,g="exceedslimit"!==u?n.onStatisticField:void 0,I="percentile_disc"===u||"percentile_cont"===u,x=f&&1===h&&(g===p||y)&&"count"===u;if(f){if(!a.has(g)){const e=[];for(const t of c){const s=this._getAttributeValues(l,t,i);e.push(s)}a.set(g,this._calculateUniqueValues(e,l.returnDistinctValues))}const t=a.get(g);for(const s in t){const{count:r,data:a,items:n,itemPositions:u}=t[s],h=a.join(",");if(!d||l.validateItems(n,d)){const t=o.get(h)||{attributes:{}};let s=null;if(x)s=r;else{const e=this._getAttributeValues(l,g,i),t=u.map((t=>e[t]));s=I&&"statisticParameters"in m?this._getPercentileValue(m,t):this._getStatisticValue(m,t,null,l.returnDistinctValues)}t.attributes[e]=s,c.forEach(((e,s)=>t.attributes[this.fieldsIndex.get(e)?e:`EXPR_${s+1}`]=a[s])),o.set(h,t)}}}else{const s=this._getAttributeValues(l,g,i);t.attributes[e]=I&&"statisticParameters"in m?this._getPercentileValue(m,s):this._getStatisticValue(m,s,r,l.returnDistinctValues)}s.push({name:e,alias:e,type:"esriFieldTypeDouble"})}const g=f?Array.from(o.values()):[t];return this._sortFeatures(g,m,((e,t)=>e.attributes[t])),{fields:s,features:g}}_getStatisticValue(e,t,s,i){const{onStatisticField:r,statisticType:a}=e;let n=null;n=null!=s&&s.has(r)?s.get(r):f(this.fieldsIndex.get(r))?y({values:t,returnDistinct:i}):g({values:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(r,n);return n["var"===a?"variance":a]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:r}=e,{value:a,orderBy:n}=i,o="desc"===n,l=this.fieldsIndex.get(s),u=[...t].filter((e=>null!=e)).sort(((e,t)=>_(e,t,l,o)));return this._calculatePercentile(u,a,"percentile_disc"===r)}_getAttributeValues(e,t,s){if(s.has(t))return s.get(t);const i=this.fieldsIndex.get(t),r=this.items.map((s=>e.getFieldValue(s,t,i)));return s.set(t,r),r}_getAttributeNormalizedValues(e,t){return this.items.map((s=>e.getNormalizedValue(s,{field:t.field,fieldInfo:this.fieldsIndex.get(t.field),normalizationField:t.normalizationField,normalizationFieldInfo:this.fieldsIndex.get(t.normalizationField),normalizationType:t.normalizationType,normalizationTotal:t.normalizationTotal})))}async _getAttributeExpressionValues(e,t,s){const{arcadeUtils:i}=await V(),r=i.createFunction(t),a=s&&i.getViewInfo(s);return this.items.map((t=>e.getExpressionValue(t,{compiledFunc:r,viewInfo:a},i)))}_calculateUniqueValues(e,t){const s={},i=this.items,r=i.length;for(let a=0;a<r;a++){const r=i[a],n=[];for(const t of e)n.push(t[a]);const o=n.join(",");t?null==s[o]&&(s[o]={count:1,data:n,items:[r],itemPositions:[a]}):null==s[o]?s[o]={count:1,data:n,items:[r],itemPositions:[a]}:(s[o].count++,s[o].items.push(r),s[o].itemPositions.push(a))}return s}_calculatePercentile(e,t,s){if(0===e.length)return null;if(t<=0)return e[0];if(t>=1)return e[e.length-1];const i=(e.length-1)*t,r=Math.floor(i),a=r+1,n=i%1,o=e[r],l=e[a];return a>=e.length||s||"string"==typeof o||"string"==typeof l?o:o*(1-n)+l*n}async _getDataValues(e,t){const s=new n(e,this.featureAdapter,this.fieldsIndex),{valueExpression:i,field:r,normalizationField:a,normalizationType:o,normalizationTotal:l,scale:u}=t,c=i?{viewingMode:"map",scale:u,spatialReference:e.outSR||this.spatialReference}:null;return i?this._getAttributeExpressionValues(s,i,c):this._getAttributeNormalizedValues(s,{field:r,normalizationField:a,normalizationType:o,normalizationTotal:l})}}function R(e,t,s,i,r,a){const n=r-s,o=a-i,l=n*n+o*o,u=(e-s)*n+(t-i)*o,c=Math.min(1,Math.max(0,u/l));return{x:s+n*c,y:i+o*c}}function P(e,t){return e?t?4:3:t?3:2}export{v 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.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../request.js";import r from"../../../../core/Error.js";import o from"../../../../core/Logger.js";import{isNone as s,isSome as i,unwrapOr as n,get as a}from"../../../../core/maybe.js";import{createResolver as c}from"../../../../core/promiseUtils.js";import{addQueryParameters as u}from"../../../../core/urlUtils.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{WebSocketConnection as d}from"./WebSocketConnection.js";import{executeQuery as h}from"../../../../rest/query/operations/query.js";import l from"../../../../rest/support/Query.js";import{fromJSON as y}from"../../../../geometry/support/jsonUtils.js";import m from"../../../../geometry/SpatialReference.js";const p=o.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection"),g=1e4,_={maxQueryDepth:5,maxRecordCountFactor:3};let w=class extends d{constructor(e){super({..._,...e})}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||p.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:r,outFields:o}=this._config;this.destroyed||this._setFilter(r,o)}_onMessage(e){let t;try{t=this._enrich(JSON.parse(e.data)),this._featureZScaler&&this._featureZScaler(t.geometry)}catch(o){return void p.error(new r("geoevent-connection","Failed to parse message",o))}this.onFeature(t)}async _fetchServiceDefinition(e){const r={f:"json",...this._config.customParameters},o=t(e.path,{query:r,responseType:"json"}),s=(await o).data;return this._serviceDefinition=s,s}_fetchWebSocketUrl(e,t){const r=e[0],{urls:o,token:s}=r,i=this._inferWebSocketBaseUrl(o);return u(i,{outSR:""+t.wkid,token:s})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(-1!==t.indexOf("wss"))return t;return p.error(new r("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const o=this._websocket;if(s(o)||s(e)&&s(t))return;const i=JSON.stringify({filter:this._serializeFilter(e,t)});let n=!1;const a=c(),u=()=>{n||(this.destroyed||this._websocket!==o||p.error(new r("geoevent-connection","Server timed out when setting filter")),a.reject())},f=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(p.error(new r("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),a.reject(t.error)),o.onmessage=this._onMessage.bind(this),n=!0,a.resolve())};return o.onmessage=f,o.send(i),setTimeout(u,g),a.promise}_serializeFilter(e,t){const o={};if(s(e)&&s(t))return o;if(i(e)&&e.geometry)try{const t=y(e.geometry);if("extent"!==t.type)throw new r(`Expected extent but found type ${t.type}`);o.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(n){p.error(new r("geoevent-connection","Encountered an error when setting connection geometryDefinition",n))}return i(e)&&e.where&&"1 = 1"!==e.where&&(o.where=e.where),i(t)&&(o.outFields=t.join(",")),o}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,o=e.attributes[t];if(!this._relatedFeatures.has(o))return p.warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:s,geometry:i}=this._relatedFeatures.get(o);for(const r in s)e.attributes[r]=s[r];return i&&(e.geometry=i),e.geometry||e.centroid||p.error(new r("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,r=this._queryRelatedFeatures(e),o=this._queryArchive(t);await r;const s=await o;if(!s)return;for(const i of s.features)this.onFeature(this._enrich(i))}catch(e){p.error(new r("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await import("../../../FeatureLayer.js")).default)({url:e}),{capabilities:r}=await t.load(),o=r.query.supportsMaxRecordCountFactor,s=r.query.supportsPagination,i=r.query.supportsCentroid,c=this._config.maxRecordCountFactor,u=t.capabilities.query.maxRecordCount,f=o?u*c:u,d=new l;if(d.outFields=n(this._config.outFields,["*"]),d.where=n(a(this._config.filter,"where"),"1=1"),d.returnGeometry=!0,d.returnExceededLimitFeatures=!0,d.outSpatialReference=m.fromJSON(this._config.spatialReference),i&&(d.returnCentroid=!0),o&&(d.maxRecordCountFactor=c),s)return d.num=f,t.destroy(),this._queryPages(e,d);const y=await h(e,d,this._config.sourceSpatialReference);return t.destroy(),y.data}async _queryPages(e,t,r=[],o=0){t.start=i(t.num)?o*t.num:null;const{data:s}=await h(e,t,this._config.sourceSpatialReference);return s.exceededTransferLimit&&o<this._config.maxQueryDepth?(s.features.forEach((e=>r.push(e))),this._queryPages(e,t,r,o+1)):(r.forEach((e=>s.features.push(e))),s)}_addRelatedFeatures(e){const t=new Map,r=e.features,o=this._serviceDefinition.relatedFeatures.joinField;for(const s of r){const e=s.attributes[o];t.set(e,s)}this._relatedFeatures=t}};w=e([f("esri.layers.graphics.sources.connections.GeoEventConnection")],w);const F=w;export{F as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../request.js";import r from"../../../../core/Error.js";import o from"../../../../core/Logger.js";import{isNone as s,isSome as i,unwrapOr as n,get as a}from"../../../../core/maybe.js";import{createResolver as c}from"../../../../core/promiseUtils.js";import{addQueryParameters as u}from"../../../../core/urlUtils.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/set.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{WebSocketConnection as d}from"./WebSocketConnection.js";import{executeQuery as h}from"../../../../rest/query/operations/query.js";import l from"../../../../rest/support/Query.js";import{fromJSON as y}from"../../../../geometry/support/jsonUtils.js";import m from"../../../../geometry/SpatialReference.js";const p=o.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection"),g=1e4,_={maxQueryDepth:5,maxRecordCountFactor:3};let w=class extends d{constructor(e){super({..._,...e})}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||p.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:r,outFields:o}=this._config;this.destroyed||this._setFilter(r,o)}_onMessage(e){let t;try{t=this._enrich(JSON.parse(e.data)),this._featureZScaler&&this._featureZScaler(t.geometry)}catch(o){return void p.error(new r("geoevent-connection","Failed to parse message",o))}this.onFeature(t)}async _fetchServiceDefinition(e){const r={f:"json",...this._config.customParameters},o=t(e.path,{query:r,responseType:"json"}),s=(await o).data;return this._serviceDefinition=s,s}_fetchWebSocketUrl(e,t){const r=e[0],{urls:o,token:s}=r,i=this._inferWebSocketBaseUrl(o);return u(`${i}/subscribe`,{outSR:""+t.wkid,token:s})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(-1!==t.indexOf("wss"))return t;return p.error(new r("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const o=this._websocket;if(s(o)||s(e)&&s(t))return;const i=JSON.stringify({filter:this._serializeFilter(e,t)});let n=!1;const a=c(),u=()=>{n||(this.destroyed||this._websocket!==o||p.error(new r("geoevent-connection","Server timed out when setting filter")),a.reject())},f=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(p.error(new r("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),a.reject(t.error)),o.onmessage=this._onMessage.bind(this),n=!0,a.resolve())};return o.onmessage=f,o.send(i),setTimeout(u,g),a.promise}_serializeFilter(e,t){const o={};if(s(e)&&s(t))return o;if(i(e)&&e.geometry)try{const t=y(e.geometry);if("extent"!==t.type)throw new r(`Expected extent but found type ${t.type}`);o.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(n){p.error(new r("geoevent-connection","Encountered an error when setting connection geometryDefinition",n))}return i(e)&&e.where&&"1 = 1"!==e.where&&(o.where=e.where),i(t)&&(o.outFields=t.join(",")),o}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,o=e.attributes[t];if(!this._relatedFeatures.has(o))return p.warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:s,geometry:i}=this._relatedFeatures.get(o);for(const r in s)e.attributes[r]=s[r];return i&&(e.geometry=i),e.geometry||e.centroid||p.error(new r("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,r=this._queryRelatedFeatures(e),o=this._queryArchive(t);await r;const s=await o;if(!s)return;for(const i of s.features)this.onFeature(this._enrich(i))}catch(e){p.error(new r("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await import("../../../FeatureLayer.js")).default)({url:e}),{capabilities:r}=await t.load(),o=r.query.supportsMaxRecordCountFactor,s=r.query.supportsPagination,i=r.query.supportsCentroid,c=this._config.maxRecordCountFactor,u=t.capabilities.query.maxRecordCount,f=o?u*c:u,d=new l;if(d.outFields=n(this._config.outFields,["*"]),d.where=n(a(this._config.filter,"where"),"1=1"),d.returnGeometry=!0,d.returnExceededLimitFeatures=!0,d.outSpatialReference=m.fromJSON(this._config.spatialReference),i&&(d.returnCentroid=!0),o&&(d.maxRecordCountFactor=c),s)return d.num=f,t.destroy(),this._queryPages(e,d);const y=await h(e,d,this._config.sourceSpatialReference);return t.destroy(),y.data}async _queryPages(e,t,r=[],o=0){t.start=i(t.num)?o*t.num:null;const{data:s}=await h(e,t,this._config.sourceSpatialReference);return s.exceededTransferLimit&&o<this._config.maxQueryDepth?(s.features.forEach((e=>r.push(e))),this._queryPages(e,t,r,o+1)):(r.forEach((e=>s.features.push(e))),s)}_addRelatedFeatures(e){const t=new Map,r=e.features,o=this._serviceDefinition.relatedFeatures.joinField;for(const s of r){const e=s.attributes[o];t.set(e,s)}this._relatedFeatures=t}};w=e([f("esri.layers.graphics.sources.connections.GeoEventConnection")],w);const F=w;export{F 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.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as t}from"../../rasterRenderers.js";import r from"../../request.js";import i from"../../core/Logger.js";import{isNone as s,isSome as n}from"../../core/maybe.js";import{aliasOf as o}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as d}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as m}from"../support/arcgisLayerUrl.js";import{url as p}from"../support/commonProperties.js";import h from"../support/DimensionalDefinition.js";import u from"../support/RasterJobHandler.js";import c from"../support/TileInfo.js";import{convertVectorFieldData as f}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as y,getDefaultInterpolation as b,getDefaultBandCombination as g,createDefaultRenderer as I}from"../../renderers/support/rasterRendererHelper.js";import _ from"../../renderers/support/RasterSymbolizer.js";import J from"../../geometry/Extent.js";import v from"../../geometry/SpatialReference.js";const S=i.getLogger("esri.layers.mixins.ImageryTileMixin"),x=i=>{let x=class extends i{constructor(){super(...arguments),this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.fullExtent=null,this.interpolation="nearest",this.raster=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.tileInfo=null,this.symbolizer=null}set multidimensionalDefinition(e){this.raster&&(this._sliceId=this.raster.getSliceIndex(e)),this._set("multidimensionalDefinition",e)}set url(e){this._set("url",m(e,S))}set renderer(e){this._set("renderer",e),this.updateRenderer()}async convertVectorFieldData(e,t){if(s(e))return null;const r=this._rasterJobHandler.instance,i=this.rasterInfo.dataType;return r?r.convertVectorFieldData({pixelBlock:e,dataType:i},t):f(e,i)}async updateRenderer(){if(!this.loaded)return;if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(this.renderer))return;const e=this._rasterJobHandler.instance;e&&(this.symbolizer.rendererJSON=y(this.renderer.toJSON()),this.symbolizer.bind(),await e.updateSymbolizer(this.symbolizer),this._cachedRendererJson=this.renderer.toJSON())}async applyRenderer(e,t){const r=e&&e.pixelBlock;if(!(n(r)&&r.pixels&&r.pixels.length>0))return null;let i;await this.updateRenderer();const s=this._rasterJobHandler.instance,{bandIds:o}=this;return i=s?await s.symbolize({...e,simpleStretchParams:t,bandIds:o}):this.symbolizer.symbolize({...e,simpleStretchParams:t,bandIds:o}),i}getTileUrl(e,t,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${r}`:""}getCompatibleTileInfo(e,t,r=!1){if(!this.loaded||s(t))return null;if(r&&e.equals(this.spatialReference))return this.tileInfo;const i=d(e);return c.create({size:256,spatialReference:e,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,t,i,s={}){if(s.requestAsImageElement){const n=this.getTileUrl(e,t,i);return r(n,{responseType:"image",query:{sliceId:this._sliceId,...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:s.signal}).then((e=>e.data))}await this._initJobHandler();const n="raster-shaded-relief"===this.renderer.type?{cols:1,rows:1}:null;if(this.multidimensionalDefinition){const e=this._sliceId;s={multidimensionalDefinition:this.multidimensionalDefinition,sliceId:e,buffer:n,...s}}return this.raster.fetchTile(e,t,i,s)}async fetchPixels(e,t,r,i){if(await this._initJobHandler(),this.multidimensionalDefinition){const e=this._sliceId;i={multidimensionalDefinition:this.multidimensionalDefinition,sliceId:e,...i}}return this.raster.fetchPixels(e,t,r,i)}identify(e,t={}){return this.multidimensionalDefinition&&!t.multidimensionalDefinition&&(t={...t,multidimensionalDefinition:this.multidimensionalDefinition}),this.raster.identify(e,t)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){var e;const t=this.rasterInfo.multidimensionalInfo;if(!n(t)||"standard-time"!==this.rasterInfo.dataType)return!1;const r=null==(e=this.multidimensionalDefinition[0])?void 0:e.variableName;return t.variables.some((e=>e.name===r&&e.dimensions.some((e=>"StdTime"===e.name))))}getStandardTimeValue(e){return new Date(24*(e-25569)*3600*1e3).toString()}_configDefaultSettings(){this._configDefaultInterpolation(),this._configDefaultSlice(),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new u;return this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e,this.raster.rasterJobHandler=e,this.renderer&&this.updateRenderer()})).catch((()=>null)),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this.raster.rasterJobHandler=null}_configDefaultInterpolation(){if(null==this.interpolation){var e;const t=b(this.rasterInfo,this.raster.tileType,null==(e=this.sourceJSON)?void 0:e.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultSlice(){const{multidimensionalInfo:e}=this.raster.rasterInfo;if(n(e)){if(!this.multidimensionalDefinition){const t=e.variables[0],r=[];t.dimensions.forEach((e=>{r.push(new h({variableName:t.name,dimensionName:e.name,values:e.hasRegularIntervals?e.extent[0]:e.values[0],isSlice:!0}))})),this.multidimensionalDefinition=r}this._sliceId=this.raster.getSliceIndex(this.multidimensionalDefinition)}}_configDefaultRenderer(){const e=this.raster.rasterInfo;var t,r;(this.bandIds||(this.bandIds=g(e)),this.renderer)||(this.renderer=I(e,{bandIds:this.bandIds,variableName:null==(t=this.multidimensionalDefinition)||null==(r=t[0])?void 0:r.variableName}));this.symbolizer?(this.symbolizer.rendererJSON=y(this.renderer.toJSON()),this.symbolizer.rasterInfo=e):this.symbolizer=new _({rendererJSON:this.renderer.toJSON(),rasterInfo:e}),this.symbolizer.bind()||S.warn("imagery-tile-mixin","The given renderer is not supported by the layer.")}};return e([a()],x.prototype,"_cachedRendererJson",void 0),e([a()],x.prototype,"_sliceId",void 0),e([a()],x.prototype,"_compatibleFullExtent",void 0),e([a()],x.prototype,"_rasterJobHandler",void 0),e([a()],x.prototype,"bandIds",void 0),e([a()],x.prototype,"copyright",void 0),e([a({type:J}),o("rasterInfo.extent")],x.prototype,"fullExtent",void 0),e([a()],x.prototype,"interpolation",void 0),e([a()],x.prototype,"ioConfig",void 0),e([a({type:[h]})],x.prototype,"multidimensionalDefinition",null),e([a()],x.prototype,"raster",void 0),e([a({readOnly:!0}),o("raster.rasterInfo")],x.prototype,"rasterInfo",void 0),e([a()],x.prototype,"sourceJSON",void 0),e([a({type:v}),o("rasterInfo.spatialReference")],x.prototype,"spatialReference",void 0),e([a({type:c}),o("rasterInfo.storageInfo.tileInfo")],x.prototype,"tileInfo",void 0),e([a(p)],x.prototype,"url",null),e([a({types:t})],x.prototype,"renderer",null),e([a()],x.prototype,"symbolizer",void 0),x=e([l("esri.layers.ImageryTileMixin")],x),x};export{x as ImageryTileMixin};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as t}from"../../rasterRenderers.js";import r from"../../request.js";import i from"../../core/Logger.js";import{isNone as n,isSome as s}from"../../core/maybe.js";import{aliasOf as o}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as m}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as d}from"../support/arcgisLayerUrl.js";import{url as u}from"../support/commonProperties.js";import p from"../support/DimensionalDefinition.js";import h from"../support/RasterJobHandler.js";import c from"../support/TileInfo.js";import{convertVectorFieldData as f}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as y,getDefaultInterpolation as b,getDefaultBandCombination as g,createDefaultRenderer as I}from"../../renderers/support/rasterRendererHelper.js";import v from"../../renderers/support/RasterSymbolizer.js";import J from"../../geometry/Extent.js";import _ from"../../geometry/SpatialReference.js";const x=i.getLogger("esri.layers.mixins.ImageryTileMixin"),S=i=>{let S=class extends i{constructor(){super(...arguments),this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.fullExtent=null,this.interpolation="nearest",this.multidimensionalDefinition=null,this.raster=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.tileInfo=null,this.symbolizer=null}set url(e){this._set("url",d(e,x))}set renderer(e){this._set("renderer",e),this.updateRenderer()}async convertVectorFieldData(e,t){if(n(e))return null;const r=this._rasterJobHandler.instance,i=this.rasterInfo.dataType;return r?r.convertVectorFieldData({pixelBlock:e,dataType:i},t):f(e,i)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.rasterInfo;if(n(t))return e;let r=e.multidimensionalDefinition||this.multidimensionalDefinition;!n(r)&&r.length||(r=this._getDefaultSlice());const i=e.timeExtent||this.timeExtent;if(s(r)&&s(i)&&(s(i.start)||s(i.end))){var o,a;r=r.map((e=>e.clone()));const l=null==(o=t.variables.find((({name:e})=>e===r[0].variableName)))||null==(a=o.dimensions)?void 0:a.find((({name:e})=>"StdTime"===e)),m=r.find((({dimensionName:e})=>"StdTime"===e));if(!l||!m)return{...e,multidimensionalDefinition:null};const{start:d,end:u}=i,p=n(d)?null:d.getTime(),h=n(u)?null:u.getTime(),c=null!=p?p:h,f=null!=h?h:p;if(s(l.values)){const e=l.values.filter((e=>Array.isArray(e)?e[0]<=c&&e[1]>=c||e[0]<=f&&e[1]>=f:c===f?e===c:e>=c&&e<=f));if(e.length){const t=e.sort(((e,t)=>{var r;return(null!=(r=t[1])?r:t)-(e[0]||e)}))[0];m.values=[t]}else r=null}else if(l.hasRegularIntervals&&l.extent){const[e,t]=l.extent;c>t||f<e?r=null:m.values=c===f?[c]:[Math.max(e,c),Math.min(t,f)]}}return{...e,multidimensionalDefinition:r}}async updateRenderer(){if(!this.loaded)return;if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(this.renderer))return;const e=this._rasterJobHandler.instance;e&&(this.symbolizer.rendererJSON=y(this.renderer.toJSON()),this.symbolizer.bind(),await e.updateSymbolizer(this.symbolizer),this._cachedRendererJson=this.renderer.toJSON())}async applyRenderer(e,t){const r=e&&e.pixelBlock;if(!(s(r)&&r.pixels&&r.pixels.length>0))return null;let i;await this.updateRenderer();const n=this._rasterJobHandler.instance,{bandIds:o}=this;return i=n?await n.symbolize({...e,simpleStretchParams:t,bandIds:o}):this.symbolizer.symbolize({...e,simpleStretchParams:t,bandIds:o}),i}getTileUrl(e,t,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${r}`:""}getCompatibleTileInfo(e,t,r=!1){if(!this.loaded||n(t))return null;if(r&&e.equals(this.spatialReference))return this.tileInfo;const i=m(e);return c.create({size:256,spatialReference:e,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,t,i,o={}){if(o.requestAsImageElement){const n=this.getTileUrl(e,t,i);return r(n,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:o.signal}).then((e=>e.data))}if(s(this.rasterInfo.multidimensionalInfo)&&(o=this.normalizeRasterFetchOptions(o),n(o.multidimensionalDefinition))){const r=o.tileInfo||this.rasterInfo.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(e,t,i,r),pixelBlock:null}}return await this._initJobHandler(),"raster-shaded-relief"===this.renderer.type&&(o={...o,buffer:{cols:1,rows:1}}),this.raster.fetchTile(e,t,i,o)}async fetchPixels(e,t,r,i={}){return s(this.rasterInfo.multidimensionalInfo)&&(i=this.normalizeRasterFetchOptions(i),n(i.multidimensionalDefinition))?{extent:e,pixelBlock:null}:(await this._initJobHandler(),this.raster.fetchPixels(e,t,r,i))}async identify(e,t={}){return s(this.rasterInfo.multidimensionalInfo)&&(t=this.normalizeRasterFetchOptions(t),n(t.multidimensionalDefinition))?{location:e,value:null}:this.raster.identify(e,t)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){var e;const t=this.rasterInfo.multidimensionalInfo;if(!s(t)||"standard-time"!==this.rasterInfo.dataType)return!1;const r=null==(e=this.multidimensionalDefinition[0])?void 0:e.variableName;return t.variables.some((e=>e.name===r&&e.dimensions.some((e=>"StdTime"===e.name))))}getStandardTimeValue(e){return new Date(24*(e-25569)*3600*1e3).toString()}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=this._getDefaultSlice()),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new h;return this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e,this.raster.rasterJobHandler=e,this.renderer&&this.updateRenderer()})).catch((()=>null)),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this.raster.rasterJobHandler=null}_configDefaultInterpolation(){if(null==this.interpolation){var e;const t=b(this.rasterInfo,this.raster.tileType,null==(e=this.sourceJSON)?void 0:e.defaultResamplingMethod);this._set("interpolation",t)}}_getDefaultSlice(){const{multidimensionalInfo:e}=this.raster.rasterInfo;if(!s(e))return null;const t=e.variables[0];return t.dimensions.map((e=>new p({variableName:t.name,dimensionName:e.name,values:e.hasRegularIntervals?e.extent[0]:e.values[0],isSlice:!0})))}_configDefaultRenderer(){const e=this.raster.rasterInfo;var t;(this.bandIds||(this.bandIds=g(e)),this.renderer)||(this.renderer=I(e,{bandIds:this.bandIds,variableName:s(this.multidimensionalDefinition)?null==(t=this.multidimensionalDefinition[0])?void 0:t.variableName:null}));this.symbolizer?(this.symbolizer.rendererJSON=y(this.renderer.toJSON()),this.symbolizer.rasterInfo=e):this.symbolizer=new v({rendererJSON:this.renderer.toJSON(),rasterInfo:e}),this.symbolizer.bind()||x.warn("imagery-tile-mixin","The given renderer is not supported by the layer.")}};return e([a()],S.prototype,"_cachedRendererJson",void 0),e([a()],S.prototype,"_compatibleFullExtent",void 0),e([a()],S.prototype,"_rasterJobHandler",void 0),e([a()],S.prototype,"bandIds",void 0),e([a()],S.prototype,"copyright",void 0),e([a({type:J}),o("rasterInfo.extent")],S.prototype,"fullExtent",void 0),e([a()],S.prototype,"interpolation",void 0),e([a()],S.prototype,"ioConfig",void 0),e([a({type:[p]})],S.prototype,"multidimensionalDefinition",void 0),e([a()],S.prototype,"raster",void 0),e([a({readOnly:!0}),o("raster.rasterInfo")],S.prototype,"rasterInfo",void 0),e([a()],S.prototype,"sourceJSON",void 0),e([a({type:_}),o("rasterInfo.spatialReference")],S.prototype,"spatialReference",void 0),e([a({type:c}),o("rasterInfo.storageInfo.tileInfo")],S.prototype,"tileInfo",void 0),e([a(u)],S.prototype,"url",null),e([a({types:t})],S.prototype,"renderer",null),e([a()],S.prototype,"symbolizer",void 0),S=e([l("esri.layers.ImageryTileMixin")],S),S};export{S as ImageryTileMixin};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import"../../geometry.js";import{isSome as e}from"../../core/maybe.js";import r from"./PixelBlock.js";import{decode as o}from"./rasterFormats/RasterCodec.js";import{estimateStatisticsHistograms as t,split as s,mosaic as i,approximateTransform as m}from"./rasterFunctions/pixelUtils.js";import{convertVectorFieldData as l}from"./rasterFunctions/vectorFieldUtils.js";import n from"../../renderers/support/RasterSymbolizer.js";import c from"../../geometry/Extent.js";class a{convertVectorFieldData(o){const t=r.fromJSON(o.pixelBlock),s=l(t,o.type);return Promise.resolve(e(s)&&s.toJSON())}async decode(e){const r=await o(e.data,e.options);return r&&r.toJSON()}symbolize(o){o.pixelBlock=r.fromJSON(o.pixelBlock),o.extent=o.extent?c.fromJSON(o.extent):null;const t=this.symbolizer.symbolize(o);return Promise.resolve(e(t)&&t.toJSON())}async updateSymbolizer(e){var r;this.symbolizer=n.fromJSON(e.symbolizerJSON),e.histograms&&"rasterStretch"===(null==(r=this.symbolizer)?void 0:r.rendererJSON.type)&&(this.symbolizer.rendererJSON.histograms=e.histograms)}stretch(o){const t=this.symbolizer.simpleStretch(r.fromJSON(o.srcPixelBlock),o.stretchParams);return Promise.resolve(e(t)&&t.toJSON())}estimateStatisticsHistograms(e){const o=t(r.fromJSON(e.srcPixelBlock));return Promise.resolve(o)}split(e){const o=s(r.fromJSON(e.srcPixelBlock),e.tileSize,e.maximumPyramidLevel);return o&&o.forEach(((e,r)=>{o.set(r,null==e?void 0:e.toJSON())})),Promise.resolve(o)}async mosaicAndTransform(e){const o=e.srcPixelBlocks.map((e=>e?new r(e):null)),t=i(o,e.srcMosaicSize,null,null,e.alignmentInfo);if(!e.coefs)return t&&t.toJSON();const s=m(t,e.destDimension,e.coefs,e.sampleSpacing,e.interpolation);return s&&s.toJSON()}}export{a as default};
5
+ import"../../geometry.js";import{isSome as e}from"../../core/maybe.js";import r from"./PixelBlock.js";import{decode as o}from"./rasterFormats/RasterCodec.js";import{estimateStatisticsHistograms as t,split as s,mosaic as i,approximateTransform as m}from"./rasterFunctions/pixelUtils.js";import{convertVectorFieldData as l}from"./rasterFunctions/vectorFieldUtils.js";import n from"../../renderers/support/RasterSymbolizer.js";import c from"../../geometry/Extent.js";class a{convertVectorFieldData(o){const t=r.fromJSON(o.pixelBlock),s=l(t,o.type);return Promise.resolve(e(s)&&s.toJSON())}async decode(e){const r=await o(e.data,e.options);return r&&r.toJSON()}symbolize(o){o.pixelBlock=r.fromJSON(o.pixelBlock),o.extent=o.extent?c.fromJSON(o.extent):null;const t=this.symbolizer.symbolize(o);return Promise.resolve(e(t)&&t.toJSON())}async updateSymbolizer(e){var r;this.symbolizer=n.fromJSON(e.symbolizerJSON),e.histograms&&"rasterStretch"===(null==(r=this.symbolizer)?void 0:r.rendererJSON.type)&&(this.symbolizer.rendererJSON.histograms=e.histograms)}stretch(o){const t=this.symbolizer.simpleStretch(r.fromJSON(o.srcPixelBlock),o.stretchParams);return Promise.resolve(e(t)&&t.toJSON())}estimateStatisticsHistograms(e){const o=t(r.fromJSON(e.srcPixelBlock));return Promise.resolve(o)}split(e){const o=s(r.fromJSON(e.srcPixelBlock),e.tileSize,e.maximumPyramidLevel);return o&&o.forEach(((e,r)=>{o.set(r,null==e?void 0:e.toJSON())})),Promise.resolve(o)}async mosaicAndTransform(e){const o=e.srcPixelBlocks.map((e=>e?new r(e):null)),t=i(o,e.srcMosaicSize,{blockWidths:e.blockWidths,alignmentInfo:e.alignmentInfo});if(!e.coefs)return t&&t.toJSON();const s=m(t,e.destDimension,e.coefs,e.sampleSpacing,e.interpolation);return s&&s.toJSON()}}export{a 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.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import i from"../../core/Accessor.js";import l from"../../core/Error.js";import r from"../../core/Handles.js";import s from"../../core/Logger.js";import a from"../../core/LRUCache.js";import o from"../../core/PooledArray.js";import{onAbort as n,createAbortError as c,isAbortError as h,createAbortController as p,isAborted as m}from"../../core/promiseUtils.js";import{waitTicks as u}from"../../core/scheduling.js";import{objectToQuery as f}from"../../core/urlUtils.js";import{init as v}from"../../core/watchUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{tilemapDefinitionId as b,Tilemap as g}from"./Tilemap.js";var w;const T=s.getLogger("esri.layers.support.TilemapCache");let j=w=class extends i{constructor(e){super(e),this._handles=new r,this._pendingTilemapRequests={},this._availableLevels={},this.levels=5,this.cacheByteSize=2097152,this.request=t,this._prefetchingEnabled=!0}initialize(){this._tilemapCache=new a(this.cacheByteSize),this._handles.add([this.watch(["layer.parsedUrl","layer.tileServers?"],(()=>this._initializeTilemapDefinition())),v(this,"layer.tileInfo.lods",(e=>this._initializeAvailableLevels(e)),!0)]),this._initializeTilemapDefinition()}destroy(){this._handles&&(this._handles.destroy(),this._handles=null)}castLevels(e){return e<=2?(T.error("Minimum levels for Tilemap is 3, but got ",e),3):e}get size(){return 1<<this.levels}fetchTilemap(e,t,i,r){if(!this._availableLevels[e])return Promise.reject(new l("tilemap-cache:level-unavailable",`Level ${e} is unavailable in the service`));const s=this._tmpTilemapDefinition,a=this._tilemapFromCache(e,t,i,s);if(a)return Promise.resolve(a);const o=r&&r.signal;return r={...r,signal:null},new Promise(((e,t)=>{n(o,(()=>t(c())));const i=b(s);let l=this._pendingTilemapRequests[i];if(!l){l=g.fromDefinition(s,r).then((e=>(this._tilemapCache.put(i,e,e.byteSize),e)));const e=()=>delete this._pendingTilemapRequests[i];this._pendingTilemapRequests[i]=l,l.then(e,e)}l.then(e,t)}))}getAvailability(e,t,i){if(!this._availableLevels[e])return"unavailable";const l=this._tilemapFromCache(e,t,i,this._tmpTilemapDefinition);return l?l.getAvailability(t,i):"unknown"}getAvailabilityUpsample(e,t,i,l){l.level=e,l.row=t,l.col=i;const r=this.layer.tileInfo;for(r.updateTileInfo(l);;){const e=this.getAvailability(l.level,l.row,l.col);if("unavailable"!==e)return e;if(!r.upsampleTile(l))return"unavailable"}}fetchAvailability(e,t,i,r){return this._availableLevels[e]?this.fetchTilemap(e,t,i,r).catch((e=>e)).then((r=>{if(r instanceof g){const s=r.getAvailability(t,i);return"unavailable"===s?Promise.reject(new l("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i})):s}if(h(r))throw r;return"unknown"})):Promise.reject(new l("tilemap-cache:level-unavailable",`Level ${e} is unavailable in the service`))}fetchAvailabilityUpsample(e,t,i,l,r){l.level=e,l.row=t,l.col=i;const s=this.layer.tileInfo;s.updateTileInfo(l);const a=this.fetchAvailability(e,t,i,r).catch((e=>{if(h(e))throw e;if(s.upsampleTile(l))return this.fetchAvailabilityUpsample(l.level,l.row,l.col,l);throw e}));return this._fetchAvailabilityUpsamplePrefetch(l.id,e,t,i,r,a),a}async _fetchAvailabilityUpsamplePrefetch(e,t,i,l,r,s){if(!this._prefetchingEnabled)return;const a=`prefetch-${e}`;if(this._handles.has(a))return;const o=p();s.then((()=>o.abort()),(()=>o.abort()));let n=!1;const c={remove(){n||(n=!0,o.abort())}};if(this._handles.add(c,a),await u(10,o.signal).catch((()=>{})),n||(n=!0,this._handles.remove(a)),m(o))return;const h={id:e,level:t,row:i,col:l},f={...r,signal:o.signal},v=this.layer.tileInfo;for(let p=0;w._prefetches.length<w._maxPrefetch&&v.upsampleTile(h);++p){const e=this.fetchAvailability(h.level,h.row,h.col,f);w._prefetches.push(e);const t=()=>{w._prefetches.removeUnordered(e)};e.then(t,t)}}_initializeTilemapDefinition(){if(!this.layer.parsedUrl)return;const e=this.layer.parsedUrl,t=e.query;this._tilemapCache.clear(),this._tmpTilemapDefinition={service:{url:e.path,query:t?f(t):null,tileServers:this.layer.tileServers,request:this.request,type:this.layer.type},width:this.size,height:this.size,level:0,row:0,col:0}}_tilemapFromCache(e,t,i,l){l.level=e,l.row=t-t%this.size,l.col=i-i%this.size;const r=b(l);return this._tilemapCache.get(r)}_initializeAvailableLevels(e){this._availableLevels={},e&&e.forEach((e=>this._availableLevels[e.level]=!0))}get test(){const e=this;return{get prefetchingEnabled(){return e._prefetchingEnabled},set prefetchingEnabled(t){e._prefetchingEnabled=t},hasTilemap:(t,i,l)=>!!e._tilemapFromCache(t,i,l,e._tmpTilemapDefinition)}}};j._maxPrefetch=4,j._prefetches=new o({initialSize:w._maxPrefetch}),e([y({constructOnly:!0,type:Number})],j.prototype,"levels",void 0),e([_("levels")],j.prototype,"castLevels",null),e([y({readOnly:!0,type:Number})],j.prototype,"size",null),e([y({constructOnly:!0,type:Number})],j.prototype,"cacheByteSize",void 0),e([y({constructOnly:!0})],j.prototype,"layer",void 0),e([y({constructOnly:!0})],j.prototype,"request",void 0),j=w=e([d("esri.layers.support.TilemapCache")],j);export{j as TilemapCache};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import i from"../../core/Accessor.js";import l from"../../core/Error.js";import r from"../../core/Handles.js";import s from"../../core/Logger.js";import a from"../../core/LRUCache.js";import o from"../../core/PooledArray.js";import{onAbort as n,createAbortError as c,isAbortError as h,isAborted as p}from"../../core/promiseUtils.js";import{waitTicks as m}from"../../core/scheduling.js";import{objectToQuery as u}from"../../core/urlUtils.js";import{init as f}from"../../core/watchUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as y}from"../../core/accessorSupport/decorators/cast.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{tilemapDefinitionId as d,Tilemap as b}from"./Tilemap.js";var g;const w=s.getLogger("esri.layers.support.TilemapCache");let T=g=class extends i{constructor(e){super(e),this._handles=new r,this._pendingTilemapRequests={},this._availableLevels={},this.levels=5,this.cacheByteSize=2097152,this.request=t,this._prefetchingEnabled=!0}initialize(){this._tilemapCache=new a(this.cacheByteSize),this._handles.add([this.watch(["layer.parsedUrl","layer.tileServers?"],(()=>this._initializeTilemapDefinition())),f(this,"layer.tileInfo.lods",(e=>this._initializeAvailableLevels(e)),!0)]),this._initializeTilemapDefinition()}destroy(){this._handles&&(this._handles.destroy(),this._handles=null)}castLevels(e){return e<=2?(w.error("Minimum levels for Tilemap is 3, but got ",e),3):e}get size(){return 1<<this.levels}fetchTilemap(e,t,i,r){if(!this._availableLevels[e])return Promise.reject(new l("tilemap-cache:level-unavailable",`Level ${e} is unavailable in the service`));const s=this._tmpTilemapDefinition,a=this._tilemapFromCache(e,t,i,s);if(a)return Promise.resolve(a);const o=r&&r.signal;return r={...r,signal:null},new Promise(((e,t)=>{n(o,(()=>t(c())));const i=d(s);let l=this._pendingTilemapRequests[i];if(!l){l=b.fromDefinition(s,r).then((e=>(this._tilemapCache.put(i,e,e.byteSize),e)));const e=()=>delete this._pendingTilemapRequests[i];this._pendingTilemapRequests[i]=l,l.then(e,e)}l.then(e,t)}))}getAvailability(e,t,i){if(!this._availableLevels[e])return"unavailable";const l=this._tilemapFromCache(e,t,i,this._tmpTilemapDefinition);return l?l.getAvailability(t,i):"unknown"}getAvailabilityUpsample(e,t,i,l){l.level=e,l.row=t,l.col=i;const r=this.layer.tileInfo;for(r.updateTileInfo(l);;){const e=this.getAvailability(l.level,l.row,l.col);if("unavailable"!==e)return e;if(!r.upsampleTile(l))return"unavailable"}}fetchAvailability(e,t,i,r){return this._availableLevels[e]?this.fetchTilemap(e,t,i,r).catch((e=>e)).then((r=>{if(r instanceof b){const s=r.getAvailability(t,i);return"unavailable"===s?Promise.reject(new l("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i})):s}if(h(r))throw r;return"unknown"})):Promise.reject(new l("tilemap-cache:level-unavailable",`Level ${e} is unavailable in the service`))}fetchAvailabilityUpsample(e,t,i,l,r){l.level=e,l.row=t,l.col=i;const s=this.layer.tileInfo;s.updateTileInfo(l);const a=this.fetchAvailability(e,t,i,r).catch((e=>{if(h(e))throw e;if(s.upsampleTile(l))return this.fetchAvailabilityUpsample(l.level,l.row,l.col,l);throw e}));return this._fetchAvailabilityUpsamplePrefetch(l.id,e,t,i,r,a),a}async _fetchAvailabilityUpsamplePrefetch(e,t,i,l,r,s){if(!this._prefetchingEnabled)return;const a=`prefetch-${e}`;if(this._handles.has(a))return;const o=new AbortController;s.then((()=>o.abort()),(()=>o.abort()));let n=!1;const c={remove(){n||(n=!0,o.abort())}};if(this._handles.add(c,a),await m(10,o.signal).catch((()=>{})),n||(n=!0,this._handles.remove(a)),p(o))return;const h={id:e,level:t,row:i,col:l},u={...r,signal:o.signal},f=this.layer.tileInfo;for(let p=0;g._prefetches.length<g._maxPrefetch&&f.upsampleTile(h);++p){const e=this.fetchAvailability(h.level,h.row,h.col,u);g._prefetches.push(e);const t=()=>{g._prefetches.removeUnordered(e)};e.then(t,t)}}_initializeTilemapDefinition(){if(!this.layer.parsedUrl)return;const e=this.layer.parsedUrl,t=e.query;this._tilemapCache.clear(),this._tmpTilemapDefinition={service:{url:e.path,query:t?u(t):null,tileServers:this.layer.tileServers,request:this.request,type:this.layer.type},width:this.size,height:this.size,level:0,row:0,col:0}}_tilemapFromCache(e,t,i,l){l.level=e,l.row=t-t%this.size,l.col=i-i%this.size;const r=d(l);return this._tilemapCache.get(r)}_initializeAvailableLevels(e){this._availableLevels={},e&&e.forEach((e=>this._availableLevels[e.level]=!0))}get test(){const e=this;return{get prefetchingEnabled(){return e._prefetchingEnabled},set prefetchingEnabled(t){e._prefetchingEnabled=t},hasTilemap:(t,i,l)=>!!e._tilemapFromCache(t,i,l,e._tmpTilemapDefinition)}}};T._maxPrefetch=4,T._prefetches=new o({initialSize:g._maxPrefetch}),e([v({constructOnly:!0,type:Number})],T.prototype,"levels",void 0),e([y("levels")],T.prototype,"castLevels",null),e([v({readOnly:!0,type:Number})],T.prototype,"size",null),e([v({constructOnly:!0,type:Number})],T.prototype,"cacheByteSize",void 0),e([v({constructOnly:!0})],T.prototype,"layer",void 0),e([v({constructOnly:!0})],T.prototype,"request",void 0),T=g=e([_("esri.layers.support.TilemapCache")],T);export{T as TilemapCache};