@arcgis/core 5.1.0-next.80 → 5.1.0-next.82

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 (277) hide show
  1. package/analysis/ShadowCast/DiscreteOptions.d.ts +12 -0
  2. package/analysis/ShadowCast/TotalDurationOptions.d.ts +12 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/040884cec4b84dd1bb17.js +1 -0
  5. package/assets/esri/core/workers/chunks/05c5f68e117fc58ae801.js +1 -0
  6. package/assets/esri/core/workers/chunks/074f5e6aaeafca13bf72.js +1 -0
  7. package/assets/esri/core/workers/chunks/{7bd1d624f4f4a11a31e8.js → 086d7cdfa92a649c9f7b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{0eed2b1b06355ab89013.js → 0c074c46d106ca4d3bad.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{d7324a00ed576e7a37b1.js → 1768f1a7e3caa6074d91.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{85d3475667c503ec4fc6.js → 186bfde8c552e3b42302.js} +1 -1
  11. package/assets/esri/core/workers/chunks/1a35121a0c2595a41fdb.js +1 -0
  12. package/assets/esri/core/workers/chunks/1ab66600579fa4232d7b.js +1 -0
  13. package/assets/esri/core/workers/chunks/{d5fd99ee40bba9b48a54.js → 1e2c0c6d724f7639d4c1.js} +27 -27
  14. package/assets/esri/core/workers/chunks/1e3fe89970c57a883fe5.js +1 -0
  15. package/assets/esri/core/workers/chunks/{824051af00e7a1f05ed0.js → 230e0e43f8e771950397.js} +1 -1
  16. package/assets/esri/core/workers/chunks/26f804c92077c11c626d.js +1 -0
  17. package/assets/esri/core/workers/chunks/28a45bd26eb5c9b3ec7c.js +1 -0
  18. package/assets/esri/core/workers/chunks/38f1a86b8dd9ee684ee5.js +596 -0
  19. package/assets/esri/core/workers/chunks/{c1d4110aa494a1dba3c4.js → 455d08294e0f5c5509ff.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{71fe127734f33d020a44.js → 475394218caaa4cd3e86.js} +1 -1
  21. package/assets/esri/core/workers/chunks/475409026288f0981ce2.js +1 -0
  22. package/assets/esri/core/workers/chunks/4e206957b28253ddc1a3.js +1 -0
  23. package/assets/esri/core/workers/chunks/{87d2021e91d025a2a142.js → 5c7ba4b8a9ec2e2e02b5.js} +1 -1
  24. package/assets/esri/core/workers/chunks/5cc38ac051d3d0557920.js +1 -0
  25. package/assets/esri/core/workers/chunks/{992cd87ba0ab6346f692.js → 64e268ebac0b62076f81.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{003fd7745966fe03510c.js → 65ac73de5bb133c6bf89.js} +1 -1
  27. package/assets/esri/core/workers/chunks/6675d56f49d07a97dc40.js +1 -0
  28. package/assets/esri/core/workers/chunks/{1f82a0f134ea912fc686.js → 66fe1634c6e8f72fc653.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{96b13b6042cdf5833d39.js → 67abbe81c16de26f61d8.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{484d6c1b0fe1633515b7.js → 72f8f4cfa0842d325fb0.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{283d39dfb1625b5a74db.js → 747e258f57f0543c836e.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{dd4f431511edd975a53b.js → 7acf82763aeba44049d0.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{5d8e944b192aad4cf986.js → 7b505112c7e6d9b7a239.js} +1 -1
  34. package/assets/esri/core/workers/chunks/7b8466f892a38a53c600.js +1 -0
  35. package/assets/esri/core/workers/chunks/{6a0352d20596ca3f4b64.js → 88eb1e4320c4ada01711.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{77dd719516138afb1a2a.js → 8af9a78cf316581ea482.js} +1 -1
  37. package/assets/esri/core/workers/chunks/97719271a3e4c9f2b2c9.js +1 -0
  38. package/assets/esri/core/workers/chunks/988e91cc6cf88c34c2de.js +1 -0
  39. package/assets/esri/core/workers/chunks/9c402657f63a4d5668d0.js +1 -0
  40. package/assets/esri/core/workers/chunks/9cac70164d8528c283af.js +1 -0
  41. package/assets/esri/core/workers/chunks/9ea23cd4b2664c08b670.js +1 -0
  42. package/assets/esri/core/workers/chunks/9f51a69b8f1937a8794a.js +1 -0
  43. package/assets/esri/core/workers/chunks/a28124bba6b43efd74cc.js +1 -0
  44. package/assets/esri/core/workers/chunks/ac5999c88c27b49cd760.js +1 -0
  45. package/assets/esri/core/workers/chunks/af762422a65c551dcd54.js +1 -0
  46. package/assets/esri/core/workers/chunks/{056fd7847caaff2c9514.js → af8bc56cf1404afc3028.js} +1 -1
  47. package/assets/esri/core/workers/chunks/b811d62284be95f4beb6.js +1 -0
  48. package/assets/esri/core/workers/chunks/b9e163f4a898e50cc854.js +1 -0
  49. package/assets/esri/core/workers/chunks/{444f0f51b3ee0b9845a5.js → bb2f6b0fcdfb8b158e26.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{3b9100c59a8050f4834e.js → bbc27d9285162696d089.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{5da2051f548c2942e01a.js → bc8a74da48b08309875f.js} +1 -1
  52. package/assets/esri/core/workers/chunks/bd8cb64b6e08839398f3.js +1 -0
  53. package/assets/esri/core/workers/chunks/{026d3fa331caec1ea3d2.js → bf4dd8e50704e4040966.js} +1 -1
  54. package/assets/esri/core/workers/chunks/c19e3f6027b6526de359.js +1 -0
  55. package/assets/esri/core/workers/chunks/c8ef80a7c46d7d2c5172.js +1 -0
  56. package/assets/esri/core/workers/chunks/cbf1a03f54bd8d2a2b47.js +1 -0
  57. package/assets/esri/core/workers/chunks/ce4dfc3a470230ddc9e4.js +1 -0
  58. package/assets/esri/core/workers/chunks/{8ea4584e07ccc85caabd.js → d11de13537b623739e14.js} +1 -1
  59. package/assets/esri/core/workers/chunks/d897412b99b9fba44bb4.js +1 -0
  60. package/assets/esri/core/workers/chunks/d9c3f14eee4db7a7137b.js +1 -0
  61. package/assets/esri/core/workers/chunks/{035dbb0217f83108fa89.js → db86a1119e4e58ecfbda.js} +1 -1
  62. package/assets/esri/core/workers/chunks/dcb7a3ff59677b1cf0f1.js +1 -0
  63. package/assets/esri/core/workers/chunks/{5fe97253f80c797fad7f.js → df8a3d3cac454d42e14d.js} +1 -1
  64. package/assets/esri/core/workers/chunks/dfe1139124fda0d6c059.js +1 -0
  65. package/assets/esri/core/workers/chunks/{8b8f391f27774aec6db9.js → e0b27bceb397482bd0e8.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{fb9e3e7cd532ac4353f1.js → e89dc473f46a5584d2ef.js} +32 -32
  67. package/assets/esri/core/workers/chunks/{01ee18782a50279f907e.js → f4220b6eab0865318033.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{42336e0d1ef88737b078.js → f468c6ea2818a1f97e19.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{3f242f8d092f601c3abf.js → f77d23ee60c876b01e4b.js} +1 -1
  70. package/assets/esri/core/workers/chunks/fce2306a1b31c6680f90.js +1 -0
  71. package/assets/esri/core/workers/chunks/fcf51697c361e0075cc2.js +1 -0
  72. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  73. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  74. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +15 -0
  75. package/assets/esri/themes/dark/main.css +1 -1
  76. package/assets/esri/themes/light/main.css +1 -1
  77. package/assets/esri/themes/light/view.css +1 -1
  78. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
  79. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
  80. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  81. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  82. package/chunks/ShadowCastVisualize.glsl.js +33 -15
  83. package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
  84. package/chunks/arcgis-knowledge-client-core.js +1 -1
  85. package/config.js +1 -1
  86. package/core/workers/registry.js +1 -1
  87. package/form/elements/inputs/MultipleChoiceInput.d.ts +6 -6
  88. package/form/elements/inputs/MultipleChoiceInput.js +1 -1
  89. package/form/elements/inputs.js +1 -1
  90. package/geometry/SpatialReference.js +1 -1
  91. package/geometry/support/coordsUtils.js +1 -1
  92. package/kernel.js +1 -1
  93. package/layers/BaseDynamicLayer.js +1 -1
  94. package/layers/BaseTileLayer.js +1 -1
  95. package/layers/ElevationLayer.js +1 -1
  96. package/layers/FeatureLayer.d.ts +2 -2
  97. package/layers/FeatureLayer.js +1 -1
  98. package/layers/MapImageLayer.js +1 -1
  99. package/layers/TileLayer.js +1 -1
  100. package/layers/WMSLayer.js +1 -1
  101. package/layers/WMTSLayer.js +1 -1
  102. package/layers/WebTileLayer.js +1 -1
  103. package/layers/graphics/data/QueryEngine.js +1 -1
  104. package/layers/graphics/data/QueryEngineResult.js +1 -1
  105. package/layers/graphics/sources/MemorySource.js +1 -1
  106. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  107. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  108. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  109. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  110. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  111. package/layers/mixins/ArcGISImageService.js +1 -1
  112. package/layers/mixins/FeatureLayerBase.js +1 -1
  113. package/layers/mixins/TiledImagery.js +1 -1
  114. package/layers/support/imageBitmapUtils.js +1 -1
  115. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  116. package/package.json +1 -1
  117. package/request/process.js +1 -1
  118. package/rest/knowledgeGraph/CreateReplicaResponse.d.ts +37 -0
  119. package/rest/knowledgeGraph/CreateReplicaResponse.js +2 -0
  120. package/rest/knowledgeGraph/ReplicaDefinition.d.ts +91 -0
  121. package/rest/knowledgeGraph/ReplicaDefinition.js +2 -0
  122. package/rest/knowledgeGraph/ReplicasInformationResponse.d.ts +24 -0
  123. package/rest/knowledgeGraph/ReplicasInformationResponse.js +2 -0
  124. package/rest/knowledgeGraph/UnregisterReplicaResponse.d.ts +44 -0
  125. package/rest/knowledgeGraph/UnregisterReplicaResponse.js +2 -0
  126. package/rest/knowledgeGraph/wasmInterface/replicaToWasmEncodedFactories.js +2 -0
  127. package/rest/knowledgeGraph/wasmInterface/wasmToReplicaFactories.js +2 -0
  128. package/rest/knowledgeGraphService.d.ts +50 -1
  129. package/rest/knowledgeGraphService.js +1 -1
  130. package/support/revision.js +1 -1
  131. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  132. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  133. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  134. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  135. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  136. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
  137. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/FillShader.js +1 -1
  138. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  139. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OutlineFillShader.js +1 -1
  140. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  141. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  142. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueCircle.js +1 -1
  143. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
  144. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueLine.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueSymbol.js +1 -1
  146. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  147. package/views/2d/input/MapViewInputManager.js +1 -1
  148. package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
  149. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  150. package/views/2d/layers/MediaLayerView2D.js +1 -1
  151. package/views/2d/layers/TileLayerView2D.js +1 -1
  152. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  153. package/views/2d/layers/WMSLayerView2D.js +1 -1
  154. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  155. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  156. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  157. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  158. package/views/3d/input/SceneInputManager.js +1 -1
  159. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  160. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  161. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  162. package/views/3d/layers/IntegratedMesh3DTilesLayerWorker.js +2 -0
  163. package/views/3d/layers/IntegratedMesh3DTilesLayerWorkerHandle.js +2 -0
  164. package/views/3d/layers/TileLayerView3D.js +1 -1
  165. package/views/3d/layers/WMTSLayerView3D.js +1 -1
  166. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  167. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  168. package/views/3d/layers/support/IntegratedMesh3DTilesVertexProcessing.js +2 -0
  169. package/views/3d/layers/support/makeScheduleFunction.js +1 -1
  170. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  171. package/views/3d/terrain/TerrainData.js +1 -1
  172. package/views/3d/terrain/TerrainSurface.js +1 -1
  173. package/views/3d/terrain/Tile.js +1 -1
  174. package/views/3d/terrain/TileRenderer.js +1 -1
  175. package/views/3d/terrain/terrainUtils.js +1 -1
  176. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  177. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  178. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  179. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialInitParameters.js +2 -0
  180. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
  181. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +1 -1
  182. package/views/3d/webgl-engine/effects/atmosphere/LocalAtmosphere.js +1 -1
  183. package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
  184. package/views/3d/webgl-engine/effects/clouds/CloudsComposition.js +1 -1
  185. package/views/3d/webgl-engine/effects/clouds/CloudsRenderer.js +1 -1
  186. package/views/3d/webgl-engine/effects/clouds/NoiseTextureAtlas.js +1 -1
  187. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  188. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  189. package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
  190. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  191. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  192. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  193. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  194. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  195. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightBuffer.js +1 -1
  196. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  197. package/views/3d/webgl-engine/effects/precipitation/Precipitation.js +1 -1
  198. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  199. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  200. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  201. package/views/3d/webgl-engine/lib/CutFillComputationRenderNode.js +1 -1
  202. package/views/3d/webgl-engine/lib/CutFillVisualizationRenderNode.js +1 -1
  203. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  204. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  205. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  206. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  207. package/views/3d/webgl-engine/lib/StencilUtils.js +1 -1
  208. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  209. package/views/3d/webgl-engine/materials/VisualVariablePassParameters.js +1 -1
  210. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  211. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +1 -1
  212. package/views/3d/webgl-engine/shaders/ShadowCastMaskTechnique.js +2 -0
  213. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
  214. package/views/3d/webgl-engine/shaders/colorRampParameters.js +2 -0
  215. package/views/VideoView.js +1 -1
  216. package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +1 -1
  217. package/views/draw/support/createUtils.js +1 -1
  218. package/views/input/BrowserEventSource.js +1 -1
  219. package/views/input/InputManager.js +1 -1
  220. package/views/input/handlers/LatestPen.js +2 -0
  221. package/views/input/handlers/LatestPointer.js +1 -1
  222. package/views/input/types.d.ts +1 -1
  223. package/views/interactive/Tooltip.js +1 -1
  224. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  225. package/views/support/TextureCompressionWorker.js +1 -1
  226. package/views/support/TextureCompressionWorkerHandle.js +1 -1
  227. package/views/support/unnormalizationUtils.js +2 -0
  228. package/views/webgl/RenderingContext.js +1 -1
  229. package/views/webgl/Texture.js +1 -1
  230. package/views/webgl/renderState.js +1 -1
  231. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  232. package/widgets/ElevationProfile/support/profileUtils.js +1 -1
  233. package/widgets/FeatureTable.js +1 -1
  234. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  235. package/widgets/OrientedImageryViewer/css.js +1 -1
  236. package/widgets/OrientedImageryViewer.js +1 -1
  237. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  238. package/assets/esri/core/workers/chunks/05c3146d87d917606193.js +0 -1
  239. package/assets/esri/core/workers/chunks/0b77c124b743067e4155.js +0 -1
  240. package/assets/esri/core/workers/chunks/11241781baaed346af52.js +0 -1
  241. package/assets/esri/core/workers/chunks/1d9560eb8b21b9e76616.js +0 -1
  242. package/assets/esri/core/workers/chunks/2c87c3112a43db8624f6.js +0 -1
  243. package/assets/esri/core/workers/chunks/2da62687ff678b690839.js +0 -1
  244. package/assets/esri/core/workers/chunks/3a58708217a9c11836ab.js +0 -1
  245. package/assets/esri/core/workers/chunks/3bbf684ee2484eb44c9f.js +0 -1
  246. package/assets/esri/core/workers/chunks/49fb9c47070641bce9a9.js +0 -1
  247. package/assets/esri/core/workers/chunks/4eed175277eb0df3c821.js +0 -1
  248. package/assets/esri/core/workers/chunks/4f9d027055f3a616173c.js +0 -1
  249. package/assets/esri/core/workers/chunks/5417308eba30e668b1ee.js +0 -1
  250. package/assets/esri/core/workers/chunks/62b3e933f548ce354b99.js +0 -1
  251. package/assets/esri/core/workers/chunks/63381d81adce0a0d2089.js +0 -1
  252. package/assets/esri/core/workers/chunks/6dbddf5ab1867ac2ac80.js +0 -1
  253. package/assets/esri/core/workers/chunks/6e70e922331704b92a08.js +0 -1
  254. package/assets/esri/core/workers/chunks/7c7c11c0fde8b63e330b.js +0 -1
  255. package/assets/esri/core/workers/chunks/7f55eef696e9ed717bfc.js +0 -1
  256. package/assets/esri/core/workers/chunks/89dbea6f436d45a3b185.js +0 -1
  257. package/assets/esri/core/workers/chunks/8f6f5dad52747d252aac.js +0 -596
  258. package/assets/esri/core/workers/chunks/99c189e1de2b1f14799b.js +0 -1
  259. package/assets/esri/core/workers/chunks/9aa6b32cb65fbaa93218.js +0 -1
  260. package/assets/esri/core/workers/chunks/9d216e30d04ea21fc8a2.js +0 -1
  261. package/assets/esri/core/workers/chunks/9d434360dfce1e49b7b9.js +0 -1
  262. package/assets/esri/core/workers/chunks/a5d8d6f3c0c8de474efd.js +0 -1
  263. package/assets/esri/core/workers/chunks/a809b811121099a87a98.js +0 -1
  264. package/assets/esri/core/workers/chunks/c02ba921c0a32d2021e3.js +0 -1
  265. package/assets/esri/core/workers/chunks/c3c19b62d948d53118a8.js +0 -1
  266. package/assets/esri/core/workers/chunks/c46a4adea39636a96d03.js +0 -1
  267. package/assets/esri/core/workers/chunks/c5507480344176fad241.js +0 -1
  268. package/assets/esri/core/workers/chunks/c6030271bd6d39b6e1db.js +0 -1
  269. package/assets/esri/core/workers/chunks/d1a7d13e1d48abcd7bf1.js +0 -1
  270. package/assets/esri/core/workers/chunks/dcbc4072c18278c2b67d.js +0 -1
  271. package/assets/esri/core/workers/chunks/e610d24539a675fb054b.js +0 -1
  272. package/assets/esri/core/workers/chunks/ecb7ede6a8e6c05e4c6c.js +0 -1
  273. package/assets/esri/core/workers/chunks/f227b34cce6843df0fb6.js +0 -1
  274. package/assets/esri/core/workers/chunks/fb5a2205f05afc396119.js +0 -1
  275. package/request/ImageWithType.js +0 -2
  276. package/views/3d/layers/support/fetchTile.js +0 -2
  277. package/views/interactive/editGeometry/unnormalizationHelper.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{insertSortedStableTopN as e}from"../../../core/arrayUtils.js";import{clone as t}from"../../../core/lang.js";import i from"../../../geometry/SpatialReference.js";import{polygonCentroid as s,extentCentroid as a}from"../../../geometry/support/centroid.js";import{getPolygonExtent as r,getGeometryExtent as n}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as o}from"../../../geometry/support/quantizationUtils.js";import{isValid as l,equals as u}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as c}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as m,isCoordinate as d,cloneCurve as p}from"../../../geometry/support/curves/curveUtils.js";import f from"./AttributesBuilder.js";import{cleanFromGeometryEngine as h,getGeometry as y,transformCentroid as g}from"./geometryUtils.js";import{project as x}from"./projectionSupport.js";import{getDateInNumber as F}from"./queryUtils.js";import{SnappingCandidateEdge as T,SnappingCandidateVertex as I}from"./SnappingCandidate.js";import{isDateField as _,isDateOnlyField as v,isTimestampOffsetField as V,isStringField as S,isTimeOnlyField as b}from"../../support/fieldUtils.js";import R from"../../../rest/support/AutoIntervalBinParameters.js";import z from"../../../rest/support/DateBinParameters.js";import{unitsDict as B}from"../../../rest/support/DateBinUtils.js";import M from"../../../rest/support/FixedBoundariesBinParameters.js";import A from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as w,calculateStatistics as N,processSummaryStatisticsResult as D,calculateUniqueValuesCount as P,createUVResult as q,calculateClassBreaks as O,resolveCBResult as j,calculateHistogram as C,calculatePercentile as G,binIndex as Z,getBinParams as E,isNullCountSupported as H,getAttributeComparator as U}from"../../../statistics/utils.js";import{utc as k}from"../../../time/constants.js";import{DateTime as J}from"luxon";const Q="bin";class Y{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasZ=!!t.returnZ&&i.hasZ,this.hasM=!!t.returnM&&i.hasM,this.fieldsIndex=i.fieldsIndex,this.objectIdField=i.objectIdField,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new f(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;l(this.query.outSR)&&!u(t.spatialReference,this.query.outSR)?e.queryGeometry=h({spatialReference:this.query.outSR,...x(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=h({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,i){const s=this.featureAdapter,{point:a}=e,r="number"==typeof e.distance?e.distance:e.distance.x,n="number"==typeof e.distance?e.distance:e.distance.y;function o(e,t){const i=(e-a.x)/r,s=(t-a.y)/n;return i*i+s*s}const l={candidates:[]},u="esriGeometryPolygon"===this.geometryType,f="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,h=this._getPointCreator(t,this.spatialReference,i),y=new L(null,0),g=new L(null,0),x={x:0,y:0,z:0};for(const c of this.items){const e=s.getObjectId(c),t=s.getGeometryWithCurves?.(c);if(null!=t){_(t,e);continue}const i=s.getGeometry(c);null==i||F(i,e)}return l.candidates.sort((e,t)=>e.distance-t.distance),l;function F(t,i){const{coords:s,stride:r}=t,n=t.isPoint?W:t.lengths;if(y.coords=s,g.coords=s,e.returnEdge){let e=0;for(let t=0;t<n.length;t++){const s=n[t],c=e;for(let t=0;t<s;t++,e+=r){if(!u&&t===s-1)continue;if(y.coordsIndex=e,g.coordsIndex=t===s-1?c:e+r,!X(x,a,y,g))continue;const n=o(x.x,x.y);n<=1&&l.candidates.push(new T(i,h(x),Math.sqrt(n),h(y),h(g)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<n.length;t++){const s=n[t],a=e,c=g;c.coordsIndex=a;for(let t=0;t<s;t++,e+=r){if(y.coordsIndex=e,u&&t===s-1&&y.x===c.x&&y.y===c.y)continue;const a=o(y.x,y.y);a<=1&&l.candidates.push(new I(i,h(y),Math.sqrt(a)))}}}else if(f&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<n.length;i++){t.push(e);const s=n[i];e+=s*r,s>1&&t.push(e-r)}for(const s of t){y.coordsIndex=s;const e=o(y.x,y.y);e<=1&&l.candidates.push(new I(i,h(y),Math.sqrt(e)))}}}function _(t,i){const{candidates:s}=l,r={x:0,y:0,z:0};if(e.returnEdge){const e=[a.x,a.y],n=new L(e,0),l=new L(e,0);for(const{segments:a}of t.parts)for(const{start:t,curve:u}of a){const{curvePoint:a}=c(t,u,e),f=o(...a);if(f>1)continue;[r.x,r.y]=a,n.coords=t,l.coords=m(u);const y=d(u)?null:p(u);s.push(new T(i,h(r),Math.sqrt(f),h(n),h(l),!1,y))}}function n(e){r.x=t.vertexXY[2*e],r.y=t.vertexXY[2*e+1];const a=o(r.x,r.y);a>1||(r.z=t.vertexZ?.[e]??0,s.push(new I(i,h(r),Math.sqrt(a))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)n(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":n(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const i=t.partOffsets[e],s=t.partOffsets[e+1]-1;n(i),s!==i&&n(s)}}}}_getPointCreator(e,t,i){const s=null==i||u(t,i)?e=>e:e=>x(e,t,i),{hasZ:a}=this,r=0;return a&&e?({x:e,y:t,z:i})=>s({x:e,y:t,z:i}):({x:e,y:t})=>s({x:e,y:t,z:r})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=_(m)||v(m)||V(m),p=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u},this.items),f=H({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),h={value:.5,fieldType:m?.type},y=S(m)?w({values:p,supportsNullCount:f,percentileParams:h,outStatisticTypes:c}):N({values:p,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:h,outStatisticTypes:c});return D(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n},this.items,!1),l=P(o);return q(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items),f=O(p,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return j(f,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items);return C(p,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.slice().reverse()){const{compare:t,fieldOrExpression:a,fieldInfo:r}=K(s,this.fieldsIndex);e.sort((e,s)=>t(i(e,a,r),i(s,a,r)))}}_topNFeatures(t,i,s,a){if(t.length>1&&i?.length){const r=i.map(e=>{const{compare:t,fieldOrExpression:i,fieldInfo:s}=K(e,this.fieldsIndex);return(e,r)=>t(a(e,i,s),a(r,i,s))}).reduceRight((e,t)=>(i,s)=>{const a=t(i,s);return 0===a||Number.isNaN(a)?e(i,s):a}),n=[];for(const i of t)e(n,i,s,r);return n}return t.slice(0,s)}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:r,spatialReference:n}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:d,returnZ:p,returnM:f}=e,y=null!=m&&t.length>(d||0)+m,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:s&&f,hasZ:a&&p,objectIdFieldName:r,spatialReference:h(u||n),transform:c&&o(c)||null}}_createFeatures(e,t){const i=new f(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:r,quantizationParameters:n,returnGeometry:l,returnCentroid:u,maxAllowableOffset:c,resultOffset:m,resultRecordCount:d,returnZ:p=!1,returnM:h=!1}=e,x=a&&p,F=s&&h;let T;const I=m||0,_=null!=d?I+d:null;null!=_&&_<=5e3&&_<t.length?T=this._topNFeatures(t,r,_,(e,t,s)=>i.getFieldValue(e,t,s)):(T=[...t],this._sortFeatures(T,r,(e,t,s)=>i.getFieldValue(e,t,s))),(I>0||null!=_)&&(T=T.slice(I,_??void 0));const v=[];let V=0;if(this.geometryType&&(l||u)){const e=o(n)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const s of T){const a=this.featureAdapter.getGeometry(s),r=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:y(this.geometryType,a,c,e,x,F)});t&&a&&!r.geometry&&(r.centroid=g(this,this.featureAdapter.getCentroid(s,this),e)),v[V++]=r}else if(!l&&u)for(const s of T)v[V++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:g(this,this.featureAdapter.getCentroid(s,this),e)});else for(const s of T)v[V++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:g(this,this.featureAdapter.getCentroid(s,this),e),geometry:y(this.geometryType,this.featureAdapter.getGeometry(s),c,e,x,F)})}else for(const o of T){const e=i.getAttributes(o);e&&(v[V++]=this._addFeatureJSONMetadata(o,{attributes:e}))}return v}_addFeatureJSONMetadata(e,t){const i=this.featureAdapter.getMetadata?.(e);return void 0!==i&&(t.metadata=i),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,i=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,s=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>i)e=!0;else{e=this.items.reduce((e,t)=>{const i=this.featureAdapter.getGeometry(t);return e+(i?.size??0)},0)>s}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,i={attributes:{}}){const s=[],a=new Map,r=new Map,n=new Map,o=new Map,l=new f(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:m,orderByFields:d,resultRecordCount:p}=e,h=c?.length,y=!!h,g=y?c[0]:null,x=y&&!this.fieldsIndex.get(g);for(const f of u??[]){const{outStatisticFieldName:e,statisticType:u}=f,d=f,p="exceedslimit"!==u?f.onStatisticField:void 0,F="percentile_disc"===u||"percentile_cont"===u,T="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,I=y&&1===h&&(p===g||x)&&"count"===u;if(y){if(!n.has(p)){const e=[];for(const i of c){const s=this._getAttributeValues(l,i,t,a);e.push(s)}n.set(p,this._calculateUniqueValues(e,t,!T&&l.returnDistinctValues))}const i=n.get(p);if(!i)continue;const s=Object.keys(i);for(const r of s){const{count:s,data:n,items:u,itemPositions:f}=i[r],h=n.join(",");if(!m||l.validateItems(u,m)){const i=o.get(h)||{attributes:{}};if(T){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(d,u);i.aggregateGeometries[t]=e}else{let r=null;if(I)r=s;else{const e=this._getAttributeValues(l,p,t,a),i=f.map(t=>e[t]);r=F&&"statisticParameters"in d?this._getPercentileValue(d,i):this._getStatisticValue(d,i,null,l.returnDistinctValues)}i.attributes[e]=r}let r=0;c.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++r]=n[t]),o.set(h,i)}}}else if(T){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(d,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(l,p,t,a);i.attributes[e]=F&&"statisticParameters"in d?this._getPercentileValue(d,s):this._getStatisticValue(d,s,r,l.returnDistinctValues)}const _="min"!==u&&"max"!==u||!S(this.fieldsIndex.get(p))&&!this._isAnyDateField(p)?null:this.fieldsIndex.get(p)?.type;s.push({name:e,alias:e,type:_||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[i];return this._sortFeatures(F,d,(e,t)=>e.attributes[t]),p&&(F.length=Math.min(p,F.length)),{fields:s,features:F}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return _(t)||v(t)||V(t)||b(t)}async _getAggregateGeometry(e,t){const{convexHull:i,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:d}=this,p=t.map(e=>y(d,c.getGeometry(e))),f=i(m,p,!0)[0],h={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=f?r(f):n(o(m,p));h.aggregateGeometries={...e,spatialReference:m},h.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=f?s(f):a(n(o(m,p)));h.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},h.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(h.aggregateGeometries=f,h.outStatisticFieldName=u||"convexHull");return h}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):S(this.fieldsIndex.get(a))||this._isAnyDateField(a)?w({values:t,returnDistinct:s}):N({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return G(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i,s){if(s.has(t))return s.get(t);const a=this.fieldsIndex.get(t),r=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,r),r}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let r=0;r<a;r++){const a=t[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(e,s,a=!0){const r=new f(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:o,timeZone:l}=e,u=i.fromJSON(this.query.outSR||this.spatialReference);return n?r.getExpressionValues(s,n,{viewingMode:"map",scale:o,spatialReference:u},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},l):r.getDataValues(s,t(e),a)}_calculateHistogramBins(e,t,i){if(null==t.min&&null==t.max)return[];const s=t.intervals,a=t.min??0,r=t.max??0,n=s.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=i[o];if(null!=t&&t>=a&&t<=r){const e=Z(s,t);e>-1&&(n[e].count++,n[e].items.push(l))}}return n}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,r=[],n=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:Q,alias:Q,type:"esriFieldTypeInteger"}],o=new f(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[i],(e,t,i)=>o.getFieldValue(e,t,i));const c=this._getAttributeValues(o,i,u,l),m=this._calculateUniqueValues([c],u,o.returnDistinctValues);for(const d in m){const{items:t}=m[d],a=await this._createBinsResponse(e,t);if(r.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:d}}))),a.fields)for(const e of a.fields)n.some(t=>t.name===e.name)||n.push(e)}return{fields:n,features:r}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(R.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(z.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(M.fromJSON(i),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(A.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:r,normalizationType:n,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),m=E(c,{field:s,normalizationField:a,normalizationType:n,normalizationTotal:o,numBins:r,minValue:F(n?e.normalizationMinValue:l,!1),maxValue:F(n?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:s||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},i),p=b(this.fieldsIndex.get(s)),f=B.toJSON(m),h=d.filter(Boolean).sort((e,t)=>e-t),y=null!=r?F(r,p):h[0],g=null!=n?F(n,p):h[h.length-1],x=[];if(null!=y&&null!=g){const e={zone:t.outTimeReference?.ianaTimeZone??k},i=u?.unit?B.toJSON(u.unit):"milliseconds",s={[i]:u?.value||0},r=J.fromMillis(y,e).minus(s),n=J.fromMillis(g,e).minus(s),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const i=(e.weekday-t+7)%7;return e.minus({days:i}).startOf("day")};if("last"===o){let e="week"===f?((e,t)=>d(e,t).plus({days:7}))(n,m):n;for(;e>r;){const t=e.minus({[f]:a.value});if(t<r){x.unshift([l?t.plus(s).toMillis():r.plus(s).toMillis(),e.plus(s).toMillis()]);break}x.unshift([t.plus(s).toMillis(),e.plus(s).toMillis()]),e=t}}else{let e="first"===o?r:"week"===f?d(r,m):r.startOf(f);for(;e<=n;){const t=e.plus({[f]:a.value});if(t>n){x.push([e.plus(s).toMillis(),l?t.plus(s).toMillis():n.plus(s).toMillis()]);break}x.push([e.plus(s).toMillis(),t.plus(s).toMillis()]),e=t}}}const T=this._calculateHistogramBins(d,{intervals:x,min:y,max:g},i);return this._createFeaturesFromHistogramBins(T,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},i),r=b(this.fieldsIndex.get(s)),n=e.boundaries.map(e=>F(e,r)).sort((e,t)=>e-t),o=[];for(let c=0;c<n.length-1;c++)o.push([n[c],n[c+1]]);const l={intervals:o,min:n.at(0),max:n.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,normalizationType:r,start:n,end:o}=e,l=await this._getDataValues({field:s||e.expression,normalizationField:e.normalizationField,normalizationType:r,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),u=b(this.fieldsIndex.get(s)),c=E(l,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:F(r?e.normalizationMinValue:n,u),maxValue:F(r?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,i);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:i,lowerBoundaryAlias:s}=t,a=s||"lowerBoundary",r=i||"upperBoundary",n=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:r,alias:r,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:Q,alias:Q,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const p of e){const{minValue:e,maxValue:i,items:s}=p,f={attributes:{}};let h;if(f.attributes[a]=m&&d&&null!=e?J.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(f.attributes[r]=m&&d&&null!=i?J.fromMillis(i,{zone:d}).toISO():i),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),f.attributes[Q]=++c,"flat"===t.bin.jsonStyle?n.push(...h.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),n.push(f))):(t.bin?.splitBy&&(f.attributes[Q]=++c),h=await this._createStatisticsQueryResponse(t,s,f),n.push(f)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&n.reverse(),{fields:o,features:n}}}function X(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=t.x-i.x,o=t.y-i.y,l=a*a+r*r;if(0===l)return!1;const u=n*a+o*r,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+r*c,!0}class L{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const W=[1];function K(e,t){const i=e.split(" "),s=i[0],a=t.get(s),r=!!i[1]&&"desc"===i[1].toLowerCase();return{compare:U(a?.type,r,"case-insensitive"),fieldOrExpression:s,fieldInfo:a}}export{Y as QueryEngineResult};
2
+ import{insertSortedStableTopN as e}from"../../../core/arrayUtils.js";import{clone as t}from"../../../core/lang.js";import i from"../../../geometry/SpatialReference.js";import{polygonCentroid as s,extentCentroid as a}from"../../../geometry/support/centroid.js";import{getPolygonExtent as r,getGeometryExtent as n}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as o}from"../../../geometry/support/quantizationUtils.js";import{isValid as l,equals as u}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as c}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as m,isCoordinate as d,cloneCurve as f}from"../../../geometry/support/curves/curveUtils.js";import p from"./AttributesBuilder.js";import{cleanFromGeometryEngine as h,getGeometry as y,transformCentroid as g}from"./geometryUtils.js";import{project as x}from"./projectionSupport.js";import{getDateInNumber as I}from"./queryUtils.js";import{SnappingCandidateEdge as T,SnappingCandidateVertex as F}from"./SnappingCandidate.js";import{isDateField as _,isDateOnlyField as v,isTimestampOffsetField as V,isStringField as S,isTimeOnlyField as b}from"../../support/fieldUtils.js";import R from"../../../rest/support/AutoIntervalBinParameters.js";import z from"../../../rest/support/DateBinParameters.js";import{unitsDict as B}from"../../../rest/support/DateBinUtils.js";import M from"../../../rest/support/FixedBoundariesBinParameters.js";import A from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as N,calculateStatistics as w,processSummaryStatisticsResult as D,calculateUniqueValuesCount as P,createUVResult as q,calculateClassBreaks as O,resolveCBResult as j,calculateHistogram as C,calculatePercentile as G,binIndex as Z,getBinParams as E,isNullCountSupported as H,getAttributeComparator as U}from"../../../statistics/utils.js";import{utc as k}from"../../../time/constants.js";import{DateTime as J}from"luxon";const Q="bin";class Y{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasZ=!!t.returnZ&&i.hasZ,this.hasM=!!t.returnM&&i.hasM,this.fieldsIndex=i.fieldsIndex,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter,this.featureIdInfo=i.featureIdInfo}get size(){return this.items.length}createQueryResponseForCount(){const e=new p(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;l(this.query.outSR)&&!u(t.spatialReference,this.query.outSR)?e.queryGeometry=h({spatialReference:this.query.outSR,...x(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=h({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,i){const s=this.featureAdapter,{point:a}=e,r="number"==typeof e.distance?e.distance:e.distance.x,n="number"==typeof e.distance?e.distance:e.distance.y;function o(e,t){const i=(e-a.x)/r,s=(t-a.y)/n;return i*i+s*s}const l={candidates:[]},u="esriGeometryPolygon"===this.geometryType,p="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,h=this._getPointCreator(t,this.spatialReference,i),y=new L(null,0),g=new L(null,0),x={x:0,y:0,z:0};for(const c of this.items){const e=s.getObjectId(c),t=s.getGeometryWithCurves?.(c);if(null!=t){_(t,e);continue}const i=s.getGeometry(c);null==i||I(i,e)}return l.candidates.sort((e,t)=>e.distance-t.distance),l;function I(t,i){const{coords:s,stride:r}=t,n=t.isPoint?W:t.lengths;if(y.coords=s,g.coords=s,e.returnEdge){let e=0;for(let t=0;t<n.length;t++){const s=n[t],c=e;for(let t=0;t<s;t++,e+=r){if(!u&&t===s-1)continue;if(y.coordsIndex=e,g.coordsIndex=t===s-1?c:e+r,!X(x,a,y,g))continue;const n=o(x.x,x.y);n<=1&&l.candidates.push(new T(i,h(x),Math.sqrt(n),h(y),h(g)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<n.length;t++){const s=n[t],a=e,c=g;c.coordsIndex=a;for(let t=0;t<s;t++,e+=r){if(y.coordsIndex=e,u&&t===s-1&&y.x===c.x&&y.y===c.y)continue;const a=o(y.x,y.y);a<=1&&l.candidates.push(new F(i,h(y),Math.sqrt(a)))}}}else if(p&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<n.length;i++){t.push(e);const s=n[i];e+=s*r,s>1&&t.push(e-r)}for(const s of t){y.coordsIndex=s;const e=o(y.x,y.y);e<=1&&l.candidates.push(new F(i,h(y),Math.sqrt(e)))}}}function _(t,i){const{candidates:s}=l,r={x:0,y:0,z:0};if(e.returnEdge){const e=[a.x,a.y],n=new L(e,0),l=new L(e,0);for(const{segments:a}of t.parts)for(const{start:t,curve:u}of a){const{curvePoint:a}=c(t,u,e),p=o(...a);if(p>1)continue;[r.x,r.y]=a,n.coords=t,l.coords=m(u);const y=d(u)?null:f(u);s.push(new T(i,h(r),Math.sqrt(p),h(n),h(l),!1,y))}}function n(e){r.x=t.vertexXY[2*e],r.y=t.vertexXY[2*e+1];const a=o(r.x,r.y);a>1||(r.z=t.vertexZ?.[e]??0,s.push(new F(i,h(r),Math.sqrt(a))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)n(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":n(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const i=t.partOffsets[e],s=t.partOffsets[e+1]-1;n(i),s!==i&&n(s)}}}}_getPointCreator(e,t,i){const s=null==i||u(t,i)?e=>e:e=>x(e,t,i),{hasZ:a}=this,r=0;return a&&e?({x:e,y:t,z:i})=>s({x:e,y:t,z:i}):({x:e,y:t})=>s({x:e,y:t,z:r})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=_(m)||v(m)||V(m),f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u},this.items),p=H({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),h={value:.5,fieldType:m?.type},y=S(m)?N({values:f,supportsNullCount:p,percentileParams:h,outStatisticTypes:c}):w({values:f,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:p,percentileParams:h,outStatisticTypes:c});return D(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n},this.items,!1),l=P(o);return q(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items),p=O(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return j(p,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items);return C(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.slice().reverse()){const{compare:t,fieldOrExpression:a,fieldInfo:r}=K(s,this.fieldsIndex);e.sort((e,s)=>t(i(e,a,r),i(s,a,r)))}}_topNFeatures(t,i,s,a){if(t.length>1&&i?.length){const r=i.map(e=>{const{compare:t,fieldOrExpression:i,fieldInfo:s}=K(e,this.fieldsIndex);return(e,r)=>t(a(e,i,s),a(r,i,s))}).reduceRight((e,t)=>(i,s)=>{const a=t(i,s);return 0===a||Number.isNaN(a)?e(i,s):a}),n=[];for(const i of t)e(n,i,s,r);return n}return t.slice(0,s)}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,featureIdInfo:r,spatialReference:n}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:d,returnZ:f,returnM:p}=e,y=null!=m&&t.length>(d||0)+m,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:s&&p,hasZ:a&&f,objectIdFieldName:"object-id"===r.type?r.fieldName:null,spatialReference:h(u||n),transform:c&&o(c)||null}}_createFeatures(e,t){const i=new p(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:r,quantizationParameters:n,returnGeometry:l,returnCentroid:u,maxAllowableOffset:c,resultOffset:m,resultRecordCount:d,returnZ:f=!1,returnM:h=!1}=e,x=a&&f,I=s&&h;let T;const F=m||0,_=null!=d?F+d:null;null!=_&&_<=5e3&&_<t.length?T=this._topNFeatures(t,r,_,(e,t,s)=>i.getFieldValue(e,t,s)):(T=[...t],this._sortFeatures(T,r,(e,t,s)=>i.getFieldValue(e,t,s))),(F>0||null!=_)&&(T=T.slice(F,_??void 0));const v=[];let V=0;if(this.geometryType&&(l||u)){const e=o(n)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const s of T){const a=this.featureAdapter.getGeometry(s),r=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:y(this.geometryType,a,c,e,x,I)});t&&a&&!r.geometry&&(r.centroid=g(this,this.featureAdapter.getCentroid(s,this),e)),v[V++]=r}else if(!l&&u)for(const s of T)v[V++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:g(this,this.featureAdapter.getCentroid(s,this),e)});else for(const s of T)v[V++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:g(this,this.featureAdapter.getCentroid(s,this),e),geometry:y(this.geometryType,this.featureAdapter.getGeometry(s),c,e,x,I)})}else for(const o of T){const e=i.getAttributes(o);e&&(v[V++]=this._addFeatureJSONMetadata(o,{attributes:e}))}return v}_addFeatureJSONMetadata(e,t){const i=this.featureAdapter.getMetadata?.(e);return void 0!==i&&(t.metadata=i),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,i=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,s=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>i)e=!0;else{e=this.items.reduce((e,t)=>{const i=this.featureAdapter.getGeometry(t);return e+(i?.size??0)},0)>s}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,i={attributes:{}}){const s=[],a=new Map,r=new Map,n=new Map,o=new Map,l=new p(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:m,orderByFields:d,resultRecordCount:f}=e,h=c?.length,y=!!h,g=y?c[0]:null,x=y&&!this.fieldsIndex.get(g);for(const p of u??[]){const{outStatisticFieldName:e,statisticType:u}=p,d=p,f="exceedslimit"!==u?p.onStatisticField:void 0,I="percentile_disc"===u||"percentile_cont"===u,T="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,F=y&&1===h&&(f===g||x)&&"count"===u;if(y){if(!n.has(f)){const e=[];for(const i of c){const s=this._getAttributeValues(l,i,t,a);e.push(s)}n.set(f,this._calculateUniqueValues(e,t,!T&&l.returnDistinctValues))}const i=n.get(f);if(!i)continue;const s=Object.keys(i);for(const r of s){const{count:s,data:n,items:u,itemPositions:p}=i[r],h=n.join(",");if(!m||l.validateItems(u,m)){const i=o.get(h)||{attributes:{}};if(T){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(d,u);i.aggregateGeometries[t]=e}else{let r=null;if(F)r=s;else{const e=this._getAttributeValues(l,f,t,a),i=p.map(t=>e[t]);r=I&&"statisticParameters"in d?this._getPercentileValue(d,i):this._getStatisticValue(d,i,null,l.returnDistinctValues)}i.attributes[e]=r}let r=0;c.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++r]=n[t]),o.set(h,i)}}}else if(T){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(d,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(l,f,t,a);i.attributes[e]=I&&"statisticParameters"in d?this._getPercentileValue(d,s):this._getStatisticValue(d,s,r,l.returnDistinctValues)}const _="min"!==u&&"max"!==u||!S(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;s.push({name:e,alias:e,type:_||"esriFieldTypeDouble"})}const I=y?Array.from(o.values()):[i];return this._sortFeatures(I,d,(e,t)=>e.attributes[t]),f&&(I.length=Math.min(f,I.length)),{fields:s,features:I}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return _(t)||v(t)||V(t)||b(t)}async _getAggregateGeometry(e,t){const{convexHull:i,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:d}=this,f=t.map(e=>y(d,c.getGeometry(e))),p=i(m,f,!0)[0],h={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=p?r(p):n(o(m,f));h.aggregateGeometries={...e,spatialReference:m},h.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=p?s(p):a(n(o(m,f)));h.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},h.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(h.aggregateGeometries=p,h.outStatisticFieldName=u||"convexHull");return h}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):S(this.fieldsIndex.get(a))||this._isAnyDateField(a)?N({values:t,returnDistinct:s}):w({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return G(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i,s){if(s.has(t))return s.get(t);const a=this.fieldsIndex.get(t),r=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,r),r}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let r=0;r<a;r++){const a=t[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(e,s,a=!0){const r=new p(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:o,timeZone:l}=e,u=i.fromJSON(this.query.outSR||this.spatialReference);return n?r.getExpressionValues(s,n,{viewingMode:"map",scale:o,spatialReference:u},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},l):r.getDataValues(s,t(e),a)}_calculateHistogramBins(e,t,i){if(null==t.min&&null==t.max)return[];const s=t.intervals,a=t.min??0,r=t.max??0,n=s.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=i[o];if(null!=t&&t>=a&&t<=r){const e=Z(s,t);e>-1&&(n[e].count++,n[e].items.push(l))}}return n}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,r=[],n=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:Q,alias:Q,type:"esriFieldTypeInteger"}],o=new p(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[i],(e,t,i)=>o.getFieldValue(e,t,i));const c=this._getAttributeValues(o,i,u,l),m=this._calculateUniqueValues([c],u,o.returnDistinctValues);for(const d in m){const{items:t}=m[d],a=await this._createBinsResponse(e,t);if(r.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:d}}))),a.fields)for(const e of a.fields)n.some(t=>t.name===e.name)||n.push(e)}return{fields:n,features:r}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(R.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(z.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(M.fromJSON(i),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(A.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:r,normalizationType:n,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),m=E(c,{field:s,normalizationField:a,normalizationType:n,normalizationTotal:o,numBins:r,minValue:I(n?e.normalizationMinValue:l,!1),maxValue:I(n?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:s||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},i),f=b(this.fieldsIndex.get(s)),p=B.toJSON(m),h=d.filter(Boolean).sort((e,t)=>e-t),y=null!=r?I(r,f):h[0],g=null!=n?I(n,f):h[h.length-1],x=[];if(null!=y&&null!=g){const e={zone:t.outTimeReference?.ianaTimeZone??k},i=u?.unit?B.toJSON(u.unit):"milliseconds",s={[i]:u?.value||0},r=J.fromMillis(y,e).minus(s),n=J.fromMillis(g,e).minus(s),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const i=(e.weekday-t+7)%7;return e.minus({days:i}).startOf("day")};if("last"===o){let e="week"===p?((e,t)=>d(e,t).plus({days:7}))(n,m):n;for(;e>r;){const t=e.minus({[p]:a.value});if(t<r){x.unshift([l?t.plus(s).toMillis():r.plus(s).toMillis(),e.plus(s).toMillis()]);break}x.unshift([t.plus(s).toMillis(),e.plus(s).toMillis()]),e=t}}else{let e="first"===o?r:"week"===p?d(r,m):r.startOf(p);for(;e<=n;){const t=e.plus({[p]:a.value});if(t>n){x.push([e.plus(s).toMillis(),l?t.plus(s).toMillis():n.plus(s).toMillis()]);break}x.push([e.plus(s).toMillis(),t.plus(s).toMillis()]),e=t}}}const T=this._calculateHistogramBins(d,{intervals:x,min:y,max:g},i);return this._createFeaturesFromHistogramBins(T,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},i),r=b(this.fieldsIndex.get(s)),n=e.boundaries.map(e=>I(e,r)).sort((e,t)=>e-t),o=[];for(let c=0;c<n.length-1;c++)o.push([n[c],n[c+1]]);const l={intervals:o,min:n.at(0),max:n.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,normalizationType:r,start:n,end:o}=e,l=await this._getDataValues({field:s||e.expression,normalizationField:e.normalizationField,normalizationType:r,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),u=b(this.fieldsIndex.get(s)),c=E(l,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:I(r?e.normalizationMinValue:n,u),maxValue:I(r?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,i);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:i,lowerBoundaryAlias:s}=t,a=s||"lowerBoundary",r=i||"upperBoundary",n=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:r,alias:r,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:Q,alias:Q,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const f of e){const{minValue:e,maxValue:i,items:s}=f,p={attributes:{}};let h;if(p.attributes[a]=m&&d&&null!=e?J.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(p.attributes[r]=m&&d&&null!=i?J.fromMillis(i,{zone:d}).toISO():i),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),p.attributes[Q]=++c,"flat"===t.bin.jsonStyle?n.push(...h.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...p.attributes}:{...t,...p.attributes}}))):(p.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),n.push(p))):(t.bin?.splitBy&&(p.attributes[Q]=++c),h=await this._createStatisticsQueryResponse(t,s,p),n.push(p)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&n.reverse(),{fields:o,features:n}}}function X(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=t.x-i.x,o=t.y-i.y,l=a*a+r*r;if(0===l)return!1;const u=n*a+o*r,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+r*c,!0}class L{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const W=[1];function K(e,t){const i=e.split(" "),s=i[0],a=t.get(s),r=!!i[1]&&"desc"===i[1].toLowerCase();return{compare:U(a?.type,r,"case-insensitive"),fieldOrExpression:s,fieldInfo:a}}export{Y as QueryEngineResult};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import r from"../../../core/Collection.js";import o from"../../../core/Error.js";import has from"../../../core/has.js";import{LoadableMixin as i}from"../../../core/Loadable.js";import s from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{open as a}from"../../../core/workers.js";import{property as l,subclass as u}from"../../../core/accessorSupport/decorators.js";import{ensureType as p}from"../../../core/accessorSupport/ensureType.js";import c from"../../../geometry/Extent.js";import d from"../../../geometry/Polygon.js";import{typeKebabDictionary as y}from"../../../geometry/support/typeUtils.js";import{unapplyEditsZUnitScaling as h}from"../../../rest/query/operations/editsZScale.js";import{applyFeatureSetZUnitScaling as m}from"../../../rest/query/operations/queryZScale.js";import f from"../../../rest/support/FeatureSet.js";import{shared as g}from"../../../core/accessorSupport/decorators/shared.js";let _=0,T=class extends(i(n(r))){constructor(e){super(e),this._idToClientGeometry=null,this.type="memory"}load(e){const t=null!=e?e.signal:null;return this.addResolvingPromise(this._startWorker(t)),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null}get _workerGeometryType(){const e=this.layer?.geometryType;return e?this._geometryTypeRequiresClientGraphicMapping(e)?"polygon":e:null}applyEdits(e){return this.load().then(()=>this._applyEdits(e))}openPorts(){return this.load().then(()=>this._connection.openPorts())}async queryFeatures(e,t={}){await this.load(t);const r=await this._connection.invoke("queryFeatures",e?e.toJSON():null,t);m(e,this.layer.spatialReference,r);const o=f.fromJSON(r);if(!this._requiresClientGraphicMapping()||!this._idToClientGeometry)return o;const i=this.layer.objectIdField;for(const s of o.features){const e=s.attributes[i],t=this._idToClientGeometry.get(e);void 0!==t&&(s.geometry=t)}return o.geometryType=this.layer.geometryType,o}async queryFeaturesJSON(e,t={}){if(this._requiresClientGraphicMapping())throw new o("query-features-json:unsupported","Cannot query in JSON format for client only geometry types (mesh and extent)");await this.load(t);const r=await this._connection.invoke("queryFeatures",e?e.toJSON():null,t);return m(e,this.layer.spatialReference,r),r}queryFeatureCount(e,t={}){return this.load(t).then(()=>this._connection.invoke("queryFeatureCount",e?e.toJSON():null,t))}queryObjectIds(e,t={}){return this.load(t).then(()=>this._connection.invoke("queryObjectIds",e?e.toJSON():null,t))}queryExtent(e,t={}){return this.load(t).then(()=>this._connection.invoke("queryExtent",e?e.toJSON():null,t)).then(e=>({count:e.count,extent:c.fromJSON(e.extent)}))}querySnapping(e,t={}){return this.load(t).then(()=>this._connection.invoke("querySnapping",e,t))}async queryAttributeBins(e,t={}){return await this.load(),this._connection.invoke("queryAttributeBins",e?.toJSON(),t)}async _applyEdits(e){if(!this._connection)throw new o("feature-layer-source:edit-failure","Memory source not loaded");const t=this.layer.objectIdField;let r=null;const i=[],s=[];await Promise.all([this._prepareClientMapping(e.addFeatures,null),this._prepareClientMapping(e.updateFeatures,null)]);const n=e=>"objectId"in e&&null!=e.objectId?e.objectId:"attributes"in e&&null!=e.attributes[t]?e.attributes[t]:null;if(e.addFeatures&&(r=this._prepareAddFeatures(e.addFeatures)),e.deleteFeatures)for(const o of e.deleteFeatures){const e=n(o);null!=e&&i.push(e)}const a=e.updateFeatures&&this._idToClientGeometry?new Map:null;if(e.updateFeatures)for(const o of e.updateFeatures)if(s.push(this._serializeFeature(o)),a&&null!=o.geometry){const e=n(o);null!=e&&a.set(e,o)}h(r?r.features:null,s,this.layer.spatialReference);const{fullExtent:l,featureEditResults:u}=await this._connection.invoke("applyEdits",{adds:r?r.features:[],updates:s,deletes:i});return this.fullExtent=l,r&&r.finish(u.uidToObjectId),this._updateIdToClientGeometries(a,u),this._createEditsResult(u)}async _prepareClientMapping(e,t){if("mesh"!==this._layerOrSourceGeometryType||null==e)return;const r=[];for(const{geometry:o}of e)null==o||"mesh"!==o.type||o.hasExtent||o.loaded||r.push(o.load({signal:t}));r.length&&await Promise.all(r)}_updateIdToClientGeometries(e,t){if(this._idToClientGeometry){if(e)for(const r of t.updateResults){if(!r.success)continue;const t=e.get(r.objectId);null!=t&&this._addIdToClientGeometry(t)}for(const e of t.deleteResults)e.success&&this._idToClientGeometry.delete(e.objectId)}}_createEditsResult(e){return{addFeatureResults:e.addResults?e.addResults.map(this._createFeatureEditResult,this):[],updateFeatureResults:e.updateResults?e.updateResults.map(this._createFeatureEditResult,this):[],deleteFeatureResults:e.deleteResults?e.deleteResults.map(this._createFeatureEditResult,this):[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}_createFeatureEditResult(e){const t=!0===e.success?null:e.error||{code:void 0,description:""};return{objectId:e.objectId,globalId:e.globalId,error:t?new o("feature-layer-source:edit-failure",t.description,{code:t.code}):null}}_prepareAddFeatures(e){const t=new Map,r=new Array(e.length);let o=null;for(let s=0;s<e.length;s++){const i=e[s],n=this._serializeFeature(i);o||null==i.geometry||(o=i.geometry.type),r[s]=n,t.set(`${n.uid}`,i)}const i=this;return{features:r,inferredGeometryType:o,finish(e){const r=i.sourceJSON.objectIdField;for(const o in e){const s=e[o],n=t.get(o);n&&(n.attributes||(n.attributes={}),-1===s?delete n.attributes[r]:n.attributes[r]=s,i._addIdToClientGeometry(n))}}}}_addIdToClientGeometry(e){if(!this._idToClientGeometry)return;const t=this.sourceJSON.objectIdField,r=e.attributes?.[t];null!=r&&this._idToClientGeometry.set(r,e.geometry??null)}get _layerOrSourceGeometryType(){return this.layer?.geometryType??this.sourceJSON?.geometryType}_requiresClientGraphicMapping(){return this._geometryTypeRequiresClientGraphicMapping(this._layerOrSourceGeometryType)}_geometryRequiresClientGraphicMapping(e){return this._geometryTypeRequiresClientGraphicMapping(e.type)}_geometryTypeRequiresClientGraphicMapping(e){return"mesh"===e||"multipatch"===e||"extent"===e}_serializeFeature(e){const{attributes:t}=e,r=this._geometryForSerialization(e),o=(_++).toString();return r?{uid:o,geometry:r.toJSON(),attributes:t}:{uid:o,attributes:t}}_geometryForSerialization(e){const{geometry:t}=e;if(null==t)return null;if(this._geometryRequiresClientGraphicMapping(t)){return t.extent?d.fromExtent(t.extent):null}return t}async _startWorker(e){this._connection=await a("MemorySourceWorker",{strategy:has("feature-layers-workers")?"dedicated":"local",signal:e,registryTarget:this});const{fields:t,spatialReference:r,objectIdField:o,hasM:i,hasZ:n,timeInfo:l,dateFieldsTimeZone:u}=this.layer,p="defaults"===this.layer.originOf("spatialReference");await this._prepareClientMapping(this.items,e);const c=this._prepareAddFeatures(this.items);this.addHandles(this.on("before-changes",e=>{s.getLogger(this).error("Source modifications will not propagate after layer has been loaded. Please use .applyEdits() instead"),e.preventDefault()}));const d={features:c.features,fields:t?.map(e=>e.toJSON()),geometryType:y.toJSON(this._workerGeometryType),hasM:"mesh"!==this._layerOrSourceGeometryType&&i,hasZ:"mesh"===this._layerOrSourceGeometryType||n,objectIdField:o,spatialReference:p?null:r&&r.toJSON(),timeInfo:l?.toJSON()??null,dateFieldsTimeZone:u},h=await this._connection.invoke("load",d,{signal:e});for(const a of h.warnings)s.getLogger(this.layer).warn("#load()",`${a.message} (title: '${this.layer.title||"no title"}', id: '${this.layer.id??"no id"}')`,{warning:a});h.featureErrors.length&&s.getLogger(this.layer).error("#load()",`Failed to load ${h.featureErrors.length} features due to errors. (title: '${this.layer.title||"no title"}', id: '${this.layer.id??"no id"}').`,h.featureErrors.map(e=>"\n\n- "+e.error.description).join(""));const m=h.layerDefinition;this._geometryTypeRequiresClientGraphicMapping(c.inferredGeometryType)&&(m.geometryType=y.toJSON(c.inferredGeometryType)),this.sourceJSON=m,this._requiresClientGraphicMapping()&&(this._idToClientGeometry=new Map),c.finish(h.assignedObjectIds)}};e([g({Type:t,ensureType:p(t)})],T.prototype,"itemType",void 0),e([l()],T.prototype,"type",void 0),e([l({constructOnly:!0})],T.prototype,"layer",void 0),e([l({readOnly:!0})],T.prototype,"_workerGeometryType",null),e([l()],T.prototype,"sourceJSON",void 0),T=e([u("esri.layers.graphics.sources.MemorySource")],T);export{T as MemorySource};
2
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import r from"../../../core/Collection.js";import i from"../../../core/Error.js";import has from"../../../core/has.js";import{LoadableMixin as o}from"../../../core/Loadable.js";import s from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{open as a}from"../../../core/workers.js";import{property as l,subclass as u}from"../../../core/accessorSupport/decorators.js";import{ensureType as p}from"../../../core/accessorSupport/ensureType.js";import d from"../../../geometry/Extent.js";import c from"../../../geometry/Polygon.js";import{typeKebabDictionary as y}from"../../../geometry/support/typeUtils.js";import{createFeatureIdFromLayer as h}from"../data/createFeatureId.js";import{unapplyEditsZUnitScaling as m}from"../../../rest/query/operations/editsZScale.js";import{applyFeatureSetZUnitScaling as f}from"../../../rest/query/operations/queryZScale.js";import g from"../../../rest/support/FeatureSet.js";import{shared as _}from"../../../core/accessorSupport/decorators/shared.js";let F=0,T=class extends(o(n(r))){constructor(e){super(e),this._idToClientGeometry=null,this.type="memory"}load(e){const t=null!=e?e.signal:null;return this.addResolvingPromise(this._startWorker(t)),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null}get _workerGeometryType(){const e=this.layer?.geometryType;return e?this._geometryTypeRequiresClientGraphicMapping(e)?"polygon":e:null}applyEdits(e){return this.load().then(()=>this._applyEdits(e))}openPorts(){return this.load().then(()=>this._connection.openPorts())}async queryFeatures(e,t={}){await this.load(t);const r=await this._connection.invoke("queryFeatures",e?e.toJSON():null,t);f(e,this.layer.spatialReference,r);const i=g.fromJSON(r);if(!this._requiresClientGraphicMapping()||!this._idToClientGeometry)return i;const o=this.layer.objectIdField;for(const s of i.features){const e=s.attributes[o],t=this._idToClientGeometry.get(e);void 0!==t&&(s.geometry=t)}return i.geometryType=this.layer.geometryType,i}async queryFeaturesJSON(e,t={}){if(this._requiresClientGraphicMapping())throw new i("query-features-json:unsupported","Cannot query in JSON format for client only geometry types (mesh and extent)");await this.load(t);const r=await this._connection.invoke("queryFeatures",e?e.toJSON():null,t);return f(e,this.layer.spatialReference,r),r}queryFeatureCount(e,t={}){return this.load(t).then(()=>this._connection.invoke("queryFeatureCount",e?e.toJSON():null,t))}queryObjectIds(e,t={}){return this.load(t).then(()=>this._connection.invoke("queryObjectIds",e?e.toJSON():null,t))}queryExtent(e,t={}){return this.load(t).then(()=>this._connection.invoke("queryExtent",e?e.toJSON():null,t)).then(e=>({count:e.count,extent:d.fromJSON(e.extent)}))}querySnapping(e,t={}){return this.load(t).then(()=>this._connection.invoke("querySnapping",e,t))}async queryAttributeBins(e,t={}){return await this.load(),this._connection.invoke("queryAttributeBins",e?.toJSON(),t)}async _applyEdits(e){if(!this._connection)throw new i("feature-layer-source:edit-failure","Memory source not loaded");const t=this.layer.objectIdField,r=this.layer.uniqueIdFields;let o=null;const s=[],n=[];await Promise.all([this._prepareClientMapping(e.addFeatures,null),this._prepareClientMapping(e.updateFeatures,null)]);const a=e=>r?.length&&"attributes"in e?h(e.attributes,this.layer):"objectId"in e&&null!=e.objectId?e.objectId:"attributes"in e&&null!=e.attributes[t]?e.attributes[t]:null;if(e.addFeatures&&(o=this._prepareAddFeatures(e.addFeatures)),e.deleteFeatures)for(const i of e.deleteFeatures){const e=a(i);null!=e&&s.push(e)}const l=e.updateFeatures&&this._idToClientGeometry?new Map:null;if(e.updateFeatures)for(const i of e.updateFeatures)if(n.push(this._serializeFeature(i)),l&&null!=i.geometry){const e=a(i);null!=e&&l.set(e,i)}m(o?o.features:null,n,this.layer.spatialReference);const{fullExtent:u,featureEditResults:p}=await this._connection.invoke("applyEdits",{adds:o?o.features:[],updates:n,deletes:s});return this.fullExtent=u,o&&o.finish(p.uidToObjectId),this._updateIdToClientGeometries(l,p),this._createEditsResult(p)}async _prepareClientMapping(e,t){if("mesh"!==this._layerOrSourceGeometryType||null==e)return;const r=[];for(const{geometry:i}of e)null==i||"mesh"!==i.type||i.hasExtent||i.loaded||r.push(i.load({signal:t}));r.length&&await Promise.all(r)}_updateIdToClientGeometries(e,t){if(this._idToClientGeometry){if(e)for(const r of t.updateResults){if(!r.success)continue;const t=e.get(r.objectId);null!=t&&this._addIdToClientGeometry(t)}for(const e of t.deleteResults)e.success&&this._idToClientGeometry.delete(e.objectId)}}_createEditsResult(e){return{addFeatureResults:e.addResults?e.addResults.map(this._createFeatureEditResult,this):[],updateFeatureResults:e.updateResults?e.updateResults.map(this._createFeatureEditResult,this):[],deleteFeatureResults:e.deleteResults?e.deleteResults.map(this._createFeatureEditResult,this):[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}_createFeatureEditResult(e){const t=!0===e.success?null:e.error||{code:void 0,description:""};return{objectId:e.objectId,globalId:e.globalId,error:t?new i("feature-layer-source:edit-failure",t.description,{code:t.code}):null}}_prepareAddFeatures(e){const t=new Map,r=new Array(e.length);let i=null;for(let s=0;s<e.length;s++){const o=e[s],n=this._serializeFeature(o);i||null==o.geometry||(i=o.geometry.type),r[s]=n,t.set(`${n.uid}`,o)}const o=this;return{features:r,inferredGeometryType:i,finish(e){const r=o.sourceJSON.objectIdField;for(const i in e){const s=e[i],n=t.get(i);n&&(n.attributes||(n.attributes={}),-1===s?delete n.attributes[r]:n.attributes[r]=s,o._addIdToClientGeometry(n))}}}}_addIdToClientGeometry(e){if(!this._idToClientGeometry)return;const t=this.sourceJSON.objectIdField,r=e.attributes?.[t];null!=r&&this._idToClientGeometry.set(r,e.geometry??null)}get _layerOrSourceGeometryType(){return this.layer?.geometryType??this.sourceJSON?.geometryType}_requiresClientGraphicMapping(){return this._geometryTypeRequiresClientGraphicMapping(this._layerOrSourceGeometryType)}_geometryRequiresClientGraphicMapping(e){return this._geometryTypeRequiresClientGraphicMapping(e.type)}_geometryTypeRequiresClientGraphicMapping(e){return"mesh"===e||"multipatch"===e||"extent"===e}_serializeFeature(e){const{attributes:t}=e,r=this._geometryForSerialization(e),i=(F++).toString();return r?{uid:i,geometry:r.toJSON(),attributes:t}:{uid:i,attributes:t}}_geometryForSerialization(e){const{geometry:t}=e;if(null==t)return null;if(this._geometryRequiresClientGraphicMapping(t)){return t.extent?c.fromExtent(t.extent):null}return t}async _startWorker(e){this._connection=await a("MemorySourceWorker",{strategy:has("feature-layers-workers")?"dedicated":"local",signal:e,registryTarget:this});const{fields:t,spatialReference:r,objectIdField:i,hasM:o,hasZ:n,timeInfo:l,dateFieldsTimeZone:u}=this.layer,p="defaults"===this.layer.originOf("spatialReference");await this._prepareClientMapping(this.items,e);const d=this._prepareAddFeatures(this.items);this.addHandles(this.on("before-changes",e=>{s.getLogger(this).error("Source modifications will not propagate after layer has been loaded. Please use .applyEdits() instead"),e.preventDefault()}));const{uniqueIdFields:c}=this.layer,h=c?.length?{type:c.length>1?"composite":"simple",fields:c.slice(),OIDFieldContainsHashValue:!(1===c?.length&&c.at(0)===this.layer.objectIdField)}:void 0,m={features:d.features,fields:t?.map(e=>e.toJSON()),geometryType:y.toJSON(this._workerGeometryType),hasM:"mesh"!==this._layerOrSourceGeometryType&&o,hasZ:"mesh"===this._layerOrSourceGeometryType||n,objectIdField:i,spatialReference:p?null:r&&r.toJSON(),timeInfo:l?.toJSON()??null,dateFieldsTimeZone:u,uniqueIdInfo:h},f=await this._connection.invoke("load",m,{signal:e});for(const a of f.warnings)s.getLogger(this.layer).warn("#load()",`${a.message} (title: '${this.layer.title||"no title"}', id: '${this.layer.id??"no id"}')`,{warning:a});f.featureErrors.length&&s.getLogger(this.layer).error("#load()",`Failed to load ${f.featureErrors.length} features due to errors. (title: '${this.layer.title||"no title"}', id: '${this.layer.id??"no id"}').`,f.featureErrors.map(e=>"\n\n- "+e.error.description).join(""));const g=f.layerDefinition;this._geometryTypeRequiresClientGraphicMapping(d.inferredGeometryType)&&(g.geometryType=y.toJSON(d.inferredGeometryType)),this.sourceJSON=g,this._requiresClientGraphicMapping()&&(this._idToClientGeometry=new Map),d.finish(f.assignedObjectIds)}};e([_({Type:t,ensureType:p(t)})],T.prototype,"itemType",void 0),e([l()],T.prototype,"type",void 0),e([l({constructOnly:!0})],T.prototype,"layer",void 0),e([l({readOnly:!0})],T.prototype,"_workerGeometryType",null),e([l()],T.prototype,"sourceJSON",void 0),T=e([u("esri.layers.graphics.sources.MemorySource")],T);export{T as MemorySource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import s from"../../../../core/Error.js";import i from"../../../../core/Logger.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{getJsonType as n}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as a,equals as o}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as u,convertToGeometry as l,convertFromFeatures as d,convertToFeature as p,convertFromFeature as c}from"../../featureConversionUtils.js";import y from"../../data/FeatureStore.js";import{checkProjectionSupport as m,project as h}from"../../data/projectionSupport.js";import{QueryEngine as f}from"../../data/QueryEngine.js";import{inferLayerProperties as g,createOptimizedFeatures as _,validateGeoJSON as I}from"./geojson.js";import{createDefaultTemplate as j,createDefaultAttributesFunction as E,createDrawingInfo as F}from"../support/clientSideDefaults.js";import{queryBinsCapabilities as b,loadGeometryEngineForSimplify as T,mixAttributes as w,createFeatureEditSuccessResult as q,createFeatureEditErrorResult as x,simplify as S}from"../support/sourceUtils.js";import R from"../../../support/FieldsIndex.js";import{kebabDict as C}from"../../../support/fieldType.js";import{getFieldDefaultValue as A,getFieldDefaultLength as O}from"../../../support/fieldUtils.js";import{utc as Q}from"../../../../time/constants.js";const k={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentsCountOnly:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryWithCacheHint:!0,supportsQueryWithDistance:!0,supportsQueryWithResultType:!0,supportsSpatialAggregationStatistics:!0,supportedSpatialAggregationStatistics:["EnvelopeAggregate","CentroidAggregate","ConvexHullAggregate"],supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0},queryBinsCapabilities:b};class D{constructor(){this._queryEngine=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e,t={}){this._loadOptions={url:e.url,customParameters:e.customParameters};const i=[],[r]=await Promise.all([e.url?this._fetch(t?.signal):null,this._checkProjection(e.spatialReference)]),n=g(r,{geometryType:e.geometryType}),o=e.fields||n.fields||[],u=null!=e.hasZ?e.hasZ:n.hasZ,l=n.geometryType;let d=e.objectIdField||n.objectIdFieldName||"__OBJECTID";const p=e.spatialReference||a;let c=e.timeInfo;o===n.fields&&n.unknownFields.length>0&&i.push({name:"geojson-layer:unknown-field-types",message:"Some fields types couldn't be inferred from the features and were dropped",details:{unknownFields:n.unknownFields}});const m=new R(o);let h=m.get(d);h?("esriFieldTypeString"!==h.type&&(h.type="esriFieldTypeOID"),h.editable=!1,h.nullable=!1,d=h.name):(h={alias:d,name:d,type:"string"===n.objectIdFieldType?"esriFieldTypeString":"esriFieldTypeOID",editable:!1,nullable:!1},o.unshift(h));const _={};for(const a of o){if(null==a.name&&(a.name=a.alias),null==a.alias&&(a.alias=a.name),!a.name)throw new s("geojson-layer:invalid-field-name","field name is missing",{field:a});if(!C.jsonValues.includes(a.type))throw new s("geojson-layer:invalid-field-type",`invalid type for field "${a.name}"`,{field:a});if(a.name!==h.name){const e=A(a);void 0!==e&&(_[a.name]=e)}null==a.length&&(a.length=O(a))}if(c){if(c.startTimeField){const e=m.get(c.startTimeField);e?(c.startTimeField=e.name,e.type="esriFieldTypeDate"):c.startTimeField=null}if(c.endTimeField){const e=m.get(c.endTimeField);e?(c.endTimeField=e.name,e.type="esriFieldTypeDate"):c.endTimeField=null}if(c.trackIdField){const e=m.get(c.trackIdField);e?c.trackIdField=e.name:(c.trackIdField=null,i.push({name:"geojson-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:c}}))}c.startTimeField||c.endTimeField||(i.push({name:"geojson-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing",details:{timeInfo:c}}),c=null)}const I=l?F(l):void 0,b=m.dateFields.length?{timeZoneIANA:Q}:null,T={warnings:i,featureErrors:[],layerDefinition:{...k,drawingInfo:I??void 0,templates:j(_),extent:void 0,geometryType:l,objectIdField:d,fields:o,hasZ:!!u,timeInfo:c,dateFieldsTimeReference:b}},w={type:"object-id",fieldName:d};this._queryEngine=new f({fieldsIndex:R.fromLayerJSON({fields:o,timeInfo:c,dateFieldsTimeReference:b}),geometryType:l,hasM:!1,hasZ:u,featureIdInfo:w,spatialReference:p,timeInfo:c,featureStore:new y({geometryType:l,hasM:!1,hasZ:u})});const q=this._queryEngine.fieldsIndex.requiredFields.indexOf(h);q>-1&&this._queryEngine.fieldsIndex.requiredFields.splice(q,1),this._createDefaultAttributes=E(_,d);const x=this._createFeatures(r);this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,x);const S=this._normalizeFeatures(x,T.featureErrors);this._queryEngine.featureStore.addMany(S);const{fullExtent:D,timeExtent:v}=await this._queryEngine.fetchRecomputedExtents();if(T.layerDefinition.extent=D,v){const{start:e,end:t}=v;T.layerDefinition.timeInfo.timeExtent=[e,t]}return T}async applyEdits(e){const{spatialReference:t,geometryType:s}=this._queryEngine;return await Promise.all([T(t,s),m(e.adds,t),m(e.updates,t)]),await this._waitSnapshotComplete(),this._applyEdits(e)}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForIds(e,t.signal)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,e);const t=this._normalizeFeatures(e);t&&this._queryEngine.featureStore.addMany(t)},e=>{this._queryEngine.featureStore.clear(),r(e)||i.getLogger("esri.layers.GeoJSONLayer").error(new s("geojson-layer:refresh","An error occurred during refresh",{error:e}))}),await this._waitSnapshotComplete();const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a}}_createFeatures(e){if(null==e)return[];const{geometryType:t,hasZ:s,objectIdField:i}=this._queryEngine,r=_(e,{geometryType:t,hasZ:s,objectIdField:i});if(!o(this._queryEngine.spatialReference,a))for(const n of r)null!=n.geometry&&(n.geometry=u(h(l(n.geometry,this._queryEngine.geometryType,this._queryEngine.hasZ,!1),a,this._queryEngine.spatialReference)));return r}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:s,customParameters:i}=this._loadOptions,r=(await e(s??"",{responseType:"json",query:{...i},signal:t})).data;return I(r),r}_normalizeFeatures(e,t){const{objectIdField:s,fieldsIndex:i}=this._queryEngine,r=[];for(const n of e){const e=this._createDefaultAttributes(),a=w(i,e,n.attributes,!0);a?t?.push(a):(this._assignObjectId(e,n.attributes,!0),n.attributes=e,n.objectId=e[s],r.push(n))}return r}async _applyEdits(e){const{adds:t,updates:s,deletes:i}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(r,t),s?.length&&this._applyUpdateEdits(r,s),i?.length){for(const e of i)r.deleteResults.push(q(e));this._queryEngine.featureStore.removeManyById(i)}const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a,featureEditResults:r}}_applyAddEdits(e,t){const{addResults:s}=e,{geometryType:i,hasM:r,hasZ:a,objectIdField:o,spatialReference:u,featureStore:l,fieldsIndex:p}=this._queryEngine,c=[],y={type:"object-id",fieldName:o};for(const d of t){if(d.geometry&&i!==n(d.geometry)){s.push(x("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),r=w(p,t,d.attributes);if(r)s.push(r);else{if(this._assignObjectId(t,d.attributes),d.attributes=t,null!=d.uid){const t=d.attributes[o];e.uidToObjectId[d.uid]=t}if(null!=d.geometry){const e=d.geometry.spatialReference??u;d.geometry=h(S(d.geometry,e),e,u)}c.push(d),s.push(q(d.attributes[o]))}}l.addMany(d([],c,i,a,r,y))}_applyUpdateEdits({updateResults:e},t){const{geometryType:s,hasM:i,hasZ:r,objectIdField:a,spatialReference:o,featureStore:u,fieldsIndex:l}=this._queryEngine,d={type:"object-id",fieldName:a};for(const y of t){const{attributes:t,geometry:m}=y,f=t?.[a];if(null==f){e.push(x(`Identifier field ${a} missing`));continue}if(!u.has(f)){e.push(x(`Feature with object id ${f} missing`));continue}const g=p(u.getFeature(f),s,r,i);if(null!=m){if(s!==n(m)){e.push(x("Incorrect geometry type."));continue}const t=m.spatialReference??o;g.geometry=h(S(m,t),t,o)}if(t){const s=w(l,g.attributes,t);if(s){e.push(s);continue}}u.add(c(g,s,r,i,d)),e.push(q(f))}}_createObjectIdGenerator(e,t){const s=e.fieldsIndex.get(e.objectIdField);if("esriFieldTypeString"===s.type)return()=>s.name+"-"+Date.now().toString(16);let i=Number.NEGATIVE_INFINITY;for(const r of t)r.objectId&&(i=Math.max(i,r.objectId));return i=Math.max(0,i)+1,()=>i++}_assignObjectId(e,t,s=!1){const i=this._queryEngine.objectIdField;e[i]=s&&i in t?t[i]:this._objectIdGenerator()}async _checkProjection(e){try{await m(a,e)}catch{throw new s("geojson-layer","Projection not supported")}}}export{D as default};
2
+ import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import s from"../../../../core/Error.js";import i from"../../../../core/Logger.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{getJsonType as n}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as a,equals as o}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as u,convertToGeometry as l,convertFromFeatures as d,convertToFeature as p,convertFromFeature as c}from"../../featureConversionUtils.js";import y from"../../data/FeatureStore.js";import{checkProjectionSupport as f,project as m}from"../../data/projectionSupport.js";import{QueryEngine as h}from"../../data/QueryEngine.js";import{inferLayerProperties as g,createOptimizedFeatures as _,validateGeoJSON as I}from"./geojson.js";import{createDefaultTemplate as E,createDefaultAttributesFunction as F,createDrawingInfo as j}from"../support/clientSideDefaults.js";import{queryBinsCapabilities as T,loadGeometryEngineForSimplify as b,mixAttributes as w,createFeatureEditSuccessResult as q,createFeatureEditErrorResult as x,simplify as S}from"../support/sourceUtils.js";import R from"../../../support/FieldsIndex.js";import{kebabDict as C}from"../../../support/fieldType.js";import{getFieldDefaultValue as A,getFieldDefaultLength as O}from"../../../support/fieldUtils.js";import{utc as Q}from"../../../../time/constants.js";const k={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentsCountOnly:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryWithCacheHint:!0,supportsQueryWithDistance:!0,supportsQueryWithResultType:!0,supportsSpatialAggregationStatistics:!0,supportedSpatialAggregationStatistics:["EnvelopeAggregate","CentroidAggregate","ConvexHullAggregate"],supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0},queryBinsCapabilities:T};class D{constructor(){this._featureIdInfo=null,this._queryEngine=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e,t={}){this._loadOptions={url:e.url,customParameters:e.customParameters};const i=[],[r]=await Promise.all([e.url?this._fetch(t?.signal):null,this._checkProjection(e.spatialReference)]),n=g(r,{geometryType:e.geometryType}),o=e.fields||n.fields||[],u=null!=e.hasZ?e.hasZ:n.hasZ,l=n.geometryType;let d=e.objectIdField||n.objectIdFieldName||"__OBJECTID";const p=e.spatialReference||a;let c=e.timeInfo;o===n.fields&&n.unknownFields.length>0&&i.push({name:"geojson-layer:unknown-field-types",message:"Some fields types couldn't be inferred from the features and were dropped",details:{unknownFields:n.unknownFields}});const f=new R(o);let m=f.get(d);m?("esriFieldTypeString"!==m.type&&(m.type="esriFieldTypeOID"),m.editable=!1,m.nullable=!1,d=m.name):(m={alias:d,name:d,type:"string"===n.objectIdFieldType?"esriFieldTypeString":"esriFieldTypeOID",editable:!1,nullable:!1},o.unshift(m));const _={};for(const a of o){if(null==a.name&&(a.name=a.alias),null==a.alias&&(a.alias=a.name),!a.name)throw new s("geojson-layer:invalid-field-name","field name is missing",{field:a});if(!C.jsonValues.includes(a.type))throw new s("geojson-layer:invalid-field-type",`invalid type for field "${a.name}"`,{field:a});if(a.name!==m.name){const e=A(a);void 0!==e&&(_[a.name]=e)}null==a.length&&(a.length=O(a))}if(c){if(c.startTimeField){const e=f.get(c.startTimeField);e?(c.startTimeField=e.name,e.type="esriFieldTypeDate"):c.startTimeField=null}if(c.endTimeField){const e=f.get(c.endTimeField);e?(c.endTimeField=e.name,e.type="esriFieldTypeDate"):c.endTimeField=null}if(c.trackIdField){const e=f.get(c.trackIdField);e?c.trackIdField=e.name:(c.trackIdField=null,i.push({name:"geojson-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:c}}))}c.startTimeField||c.endTimeField||(i.push({name:"geojson-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing",details:{timeInfo:c}}),c=null)}const I=l?j(l):void 0,T=f.dateFields.length?{timeZoneIANA:Q}:null,b={warnings:i,featureErrors:[],layerDefinition:{...k,drawingInfo:I??void 0,templates:E(_),extent:void 0,geometryType:l,objectIdField:d,fields:o,hasZ:!!u,timeInfo:c,dateFieldsTimeReference:T}};this._featureIdInfo={type:"object-id",fieldName:d},this._queryEngine=new h({fieldsIndex:R.fromLayerJSON({fields:o,timeInfo:c,dateFieldsTimeReference:T}),geometryType:l,hasM:!1,hasZ:u,featureIdInfo:this._featureIdInfo,spatialReference:p,timeInfo:c,featureStore:new y({geometryType:l,hasM:!1,hasZ:u})});const w=this._queryEngine.fieldsIndex.requiredFields.indexOf(m);w>-1&&this._queryEngine.fieldsIndex.requiredFields.splice(w,1),this._createDefaultAttributes=F(_,d);const q=this._createFeatures(r);this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,q);const x=this._normalizeFeatures(q,b.featureErrors);this._queryEngine.featureStore.addMany(x);const{fullExtent:S,timeExtent:D}=await this._queryEngine.fetchRecomputedExtents();if(b.layerDefinition.extent=S,D){const{start:e,end:t}=D;b.layerDefinition.timeInfo.timeExtent=[e,t]}return b}async applyEdits(e){const{spatialReference:t,geometryType:s}=this._queryEngine;return await Promise.all([b(t,s),f(e.adds,t),f(e.updates,t)]),await this._waitSnapshotComplete(),this._applyEdits(e)}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForIds(e,t.signal)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,e);const t=this._normalizeFeatures(e);t&&this._queryEngine.featureStore.addMany(t)},e=>{this._queryEngine.featureStore.clear(),r(e)||i.getLogger("esri.layers.GeoJSONLayer").error(new s("geojson-layer:refresh","An error occurred during refresh",{error:e}))}),await this._waitSnapshotComplete();const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a}}_createFeatures(e){if(null==e)return[];const{geometryType:t,hasZ:s}=this._queryEngine,i=this._featureIdInfo.fieldName,r=_(e,{geometryType:t,hasZ:s,objectIdField:i});if(!o(this._queryEngine.spatialReference,a))for(const n of r)null!=n.geometry&&(n.geometry=u(m(l(n.geometry,this._queryEngine.geometryType,this._queryEngine.hasZ,!1),a,this._queryEngine.spatialReference)));return r}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:s,customParameters:i}=this._loadOptions,r=(await e(s??"",{responseType:"json",query:{...i},signal:t})).data;return I(r),r}_normalizeFeatures(e,t){const{fieldsIndex:s}=this._queryEngine,i=[],r=this._featureIdInfo.fieldName;for(const n of e){const e=this._createDefaultAttributes(),a=w(s,e,n.attributes,!0);a?t?.push(a):(this._assignObjectId(e,n.attributes,!0),n.attributes=e,n.objectId=e[r],i.push(n))}return i}async _applyEdits(e){const{adds:t,updates:s,deletes:i}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(r,t),s?.length&&this._applyUpdateEdits(r,s),i?.length){for(const e of i)r.deleteResults.push(q(e));this._queryEngine.featureStore.removeManyById(i)}const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a,featureEditResults:r}}_applyAddEdits(e,t){const{addResults:s}=e,{geometryType:i,hasM:r,hasZ:a,spatialReference:o,featureStore:u,fieldsIndex:l}=this._queryEngine,p=this._featureIdInfo.fieldName,c=[];for(const d of t){if(d.geometry&&i!==n(d.geometry)){s.push(x("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),r=w(l,t,d.attributes);if(r)s.push(r);else{if(this._assignObjectId(t,d.attributes),d.attributes=t,null!=d.uid){const t=d.attributes[p];e.uidToObjectId[d.uid]=t}if(null!=d.geometry){const e=d.geometry.spatialReference??o;d.geometry=m(S(d.geometry,e),e,o)}c.push(d),s.push(q(d.attributes[p]))}}u.addMany(d([],c,i,a,r,this._featureIdInfo))}_applyUpdateEdits({updateResults:e},t){const{geometryType:s,hasM:i,hasZ:r,spatialReference:a,featureStore:o,fieldsIndex:u}=this._queryEngine,l=this._featureIdInfo.fieldName;for(const d of t){const{attributes:t,geometry:y}=d,f=t?.[l];if(null==f){e.push(x(`Identifier field ${l} missing`));continue}if(!o.has(f)){e.push(x(`Feature with object id ${f} missing`));continue}const h=p(o.getFeature(f),s,r,i);if(null!=y){if(s!==n(y)){e.push(x("Incorrect geometry type."));continue}const t=y.spatialReference??a;h.geometry=m(S(y,t),t,a)}if(t){const s=w(u,h.attributes,t);if(s){e.push(s);continue}}o.add(c(h,s,r,i,this._featureIdInfo)),e.push(q(f))}}_createObjectIdGenerator(e,t){const s=this._featureIdInfo.fieldName,i=e.fieldsIndex.get(s);if("esriFieldTypeString"===i.type)return()=>i.name+"-"+Date.now().toString(16);let r=Number.NEGATIVE_INFINITY;for(const n of t)n.objectId&&(r=Math.max(r,n.objectId));return r=Math.max(0,r)+1,()=>r++}_assignObjectId(e,t,s=!1){const i=this._featureIdInfo.fieldName;e[i]=s&&i in t?t[i]:this._objectIdGenerator()}async _checkProjection(e){try{await f(a,e)}catch{throw new s("geojson-layer","Projection not supported")}}}export{D as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import{parseDate as i}from"../../../../core/date.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{urlToObject as o,getFilename as a}from"../../../../core/urlUtils.js";import{projectMany as l}from"../../../../geometry/projectionUtils.js";import m from"../../../../geometry/SpatialReference.js";import{equals as c,isWebMercator as d,wgs84 as u}from"../../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as p}from"../../../../geometry/support/webMercatorUtils.js";import{OptimizedFeature as f}from"../../OptimizedFeature.js";import y from"../../OptimizedGeometry.js";import h from"../../data/FeatureStore.js";import{checkProjectionSupport as g}from"../../data/projectionSupport.js";import{QueryEngine as I}from"../../data/QueryEngine.js";import{parseRows as _,parseNumber as F,severSlicedString as w,readRows as E,inferDelimiterAndLocationInfo as T,extractFieldNamesAndAliasesFromRow as j,inferFields as x}from"../csv/csv.js";import{createDefaultAttributesFunction as N,createDrawingInfo as S}from"./clientSideDefaults.js";import{cleanTitle as q}from"../../../support/arcgisLayerUrl.js";import b from"../../../support/FieldsIndex.js";import{getFieldDefaultValue as C}from"../../../support/fieldUtils.js";import{isNumber as O}from"../../../../support/guards.js";import{utc as v}from"../../../../time/constants.js";const D=S("esriGeometryPoint"),k=["csv"],P=[0,0];class R{constructor(e,t){this.x=e,this.y=t}}class V{constructor(){this._queryEngine=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=null}async load(e,t={}){this._loadOptions=e;const[i]=await Promise.all([this._fetch(t.signal),this._checkProjection(e?.parsingOptions?.spatialReference)]),n=L(i,e);this._locationInfo=n.locationInfo,this._delimiter=n.delimiter,this._queryEngine=this._createQueryEngine(n);const r=this._createFeatures(i);this._queryEngine.featureStore.addMany(r);const{fullExtent:s,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();if(n.layerDefinition.extent=s,o){const{start:e,end:t}=o;n.layerDefinition.timeInfo.timeExtent=[e,t]}return n}async applyEdits(){throw new n("csv-layer:editing-not-supported","applyEdits() is not supported on CSVLayer")}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){await this._waitSnapshotComplete();return(await this._queryEngine.executeQueryForIds(e,t.signal)).filter(O)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),e&&this._queryEngine.featureStore.addMany(e)},e=>{this._queryEngine.featureStore.clear(),s(e)||r.getLogger("esri.layers.CSVLayer").error(new n("csv-layer:refresh","An error occurred during refresh",{error:e}))}),await this._waitSnapshotComplete();const{fullExtent:i,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:i,timeExtent:o}}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:i,customParameters:r}=this._loadOptions;if(!i)throw new n("csv-layer:invalid-source","url not defined");const s=o(i);return(await e(s.path,{query:{...s.query,...r},responseType:"text",signal:t})).data}_createQueryEngine(e){const{objectIdField:t,fields:i,extent:n,timeInfo:r}=e.layerDefinition,s=new h({geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1}),o={type:"object-id",fieldName:t};return new I({fieldsIndex:b.fromLayerJSON({fields:i,dateFieldsTimeReference:{timeZoneIANA:v}}),geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1,timeInfo:r,featureIdInfo:o,spatialReference:n.spatialReference||{wkid:4326},featureStore:s})}_createFeatures(e){const{latitudeFieldName:t,longitudeFieldName:n}=this._locationInfo,{objectIdField:r,fieldsIndex:s,spatialReference:o}=this._queryEngine;let a=[];const u=[],h=s.fields.filter(e=>e.name!==r).map(e=>e.name);let g=0;const I={};for(const i of s.fields)if("esriFieldTypeOID"!==i.type&&"esriFieldTypeGlobalID"!==i.type){const e=C(i);void 0!==e&&(I[i.name]=e)}const E=_(e,h,this._delimiter,N(I,r));for(const l of E){const e=this._parseCoordinateValue(l[t]),o=this._parseCoordinateValue(l[n]);if(null!=o&&null!=e&&!isNaN(e)&&!isNaN(o)){l[t]=e,l[n]=o;for(const e in l)if(e!==t&&e!==n)if(s.isDateField(e))l[e]=i(l[e]);else if(s.isNumericField(e)){const t=F(l[e]);isNaN(t)?l[e]=null:l[e]=t}else null!=l[e]&&(l[e]=w(l[e]));l[r]=g,g++,a.push(new R(o,e)),u.push(l)}}if(!c({wkid:4326},o))if(d(o))for(const i of a)[i.x,i.y]=p(i.x,i.y,P);else a=l(a,m.WGS84,o);const T=[];for(let i=0;i<a.length;i++){const{x:e,y:t}=a[i],n=u[i];n[r]=i+1,T.push(new f(new y([],[e,t]),n,null,n[r]))}return T}_parseCoordinateValue(e){if(null==e||""===e)return null;let t=F(e);return(isNaN(t)||Math.abs(t)>181)&&(t=parseFloat(e)),t}async _checkProjection(e){try{await g(u,e)}catch{throw new n("csv-layer:projection-not-supported","Projection not supported")}}}function L(e,t){const i=t.parsingOptions||{},r={delimiter:i.delimiter,layerDefinition:null,locationInfo:{latitudeFieldName:i.latitudeField,longitudeFieldName:i.longitudeField}},s=r.layerDefinition={name:q(a(t.url,k)||"csv"),dateFieldsTimeReference:{timeZoneIANA:v},drawingInfo:D,geometryType:"esriGeometryPoint",objectIdField:null,fields:[],timeInfo:i.timeInfo,extent:{xmin:Number.POSITIVE_INFINITY,ymin:Number.POSITIVE_INFINITY,xmax:Number.NEGATIVE_INFINITY,ymax:Number.NEGATIVE_INFINITY,spatialReference:i.spatialReference||{wkid:4326}}},o=E(e),l=o.next().value?.trim(),m=o.next().value?.trim();if(!l)throw new n("csv-layer:empty-csv","CSV is empty",{csv:e});const{delimiter:c,locationInfo:d}=T(l,m,i);if(!c)throw new n("csv-layer:invalid-delimiter","Unable to detect the delimiter from CSV",{firstLine:l,secondLine:m,parsingOptions:i});if(!d)throw new n("csv-layer:location-fields-not-found","Unable to identify latitude and longitude fields from the CSV file",{firstLine:l,secondLine:m,parsingOptions:i});r.locationInfo=d,r.delimiter=c;const{names:u,aliases:p}=j(l,c),f=x(e,r.delimiter,u,p,r.locationInfo);if(i.fields?.length){const e=new b(i.fields);for(const t of f){const i=e.get(t.name);i&&Object.assign(t,i)}}if(!f.some(e=>"esriFieldTypeOID"===e.type&&(s.objectIdField=e.name,!0))){const e={name:"__OBJECTID",alias:"__OBJECTID",type:"esriFieldTypeOID",editable:!1,nullable:!1};s.objectIdField=e.name,f.unshift(e)}s.fields=f;const y=new b(s.fields);if(r.locationInfo&&(r.locationInfo.latitudeFieldName=y.get(r.locationInfo.latitudeFieldName).name,r.locationInfo.longitudeFieldName=y.get(r.locationInfo.longitudeFieldName).name),s.timeInfo){const e=s.timeInfo;if(e.startTimeField){const t=y.get(e.startTimeField);t?(e.startTimeField=t.name,t.type="esriFieldTypeDate"):e.startTimeField=null}if(e.endTimeField){const t=y.get(e.endTimeField);t?(e.endTimeField=t.name,t.type="esriFieldTypeDate"):e.endTimeField=null}if(e.trackIdField){const t=y.get(e.trackIdField);e.trackIdField=t?t.name:null}e.startTimeField||e.endTimeField||(s.timeInfo=null)}return r}export{V as default};
2
+ import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import{parseDate as i}from"../../../../core/date.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{urlToObject as o,getFilename as a}from"../../../../core/urlUtils.js";import{projectMany as l}from"../../../../geometry/projectionUtils.js";import m from"../../../../geometry/SpatialReference.js";import{equals as c,isWebMercator as d,wgs84 as u}from"../../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as f}from"../../../../geometry/support/webMercatorUtils.js";import{OptimizedFeature as p}from"../../OptimizedFeature.js";import y from"../../OptimizedGeometry.js";import h from"../../data/FeatureStore.js";import{checkProjectionSupport as I}from"../../data/projectionSupport.js";import{QueryEngine as g}from"../../data/QueryEngine.js";import{parseRows as _,parseNumber as F,severSlicedString as w,readRows as E,inferDelimiterAndLocationInfo as T,extractFieldNamesAndAliasesFromRow as j,inferFields as N}from"../csv/csv.js";import{createDefaultAttributesFunction as x,createDrawingInfo as S}from"./clientSideDefaults.js";import{cleanTitle as q}from"../../../support/arcgisLayerUrl.js";import b from"../../../support/FieldsIndex.js";import{getFieldDefaultValue as C}from"../../../support/fieldUtils.js";import{isNumber as O}from"../../../../support/guards.js";import{utc as v}from"../../../../time/constants.js";const D=S("esriGeometryPoint"),k=["csv"],P=[0,0];class R{constructor(e,t){this.x=e,this.y=t}}class V{constructor(){this._queryEngine=null,this._featureIdInfo=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=null}async load(e,t={}){this._loadOptions=e;const[i]=await Promise.all([this._fetch(t.signal),this._checkProjection(e?.parsingOptions?.spatialReference)]),n=L(i,e);this._locationInfo=n.locationInfo,this._delimiter=n.delimiter;const{objectIdField:r,fields:s,extent:{spatialReference:o},timeInfo:a}=n.layerDefinition,l=new h({geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1});this._featureIdInfo={type:"object-id",fieldName:r},this._queryEngine=new g({fieldsIndex:b.fromLayerJSON({fields:s,dateFieldsTimeReference:{timeZoneIANA:v}}),geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1,timeInfo:a,featureIdInfo:this._featureIdInfo,spatialReference:o||{wkid:4326},featureStore:l});const m=this._createFeatures(i);this._queryEngine.featureStore.addMany(m);const{fullExtent:c,timeExtent:d}=await this._queryEngine.fetchRecomputedExtents();if(n.layerDefinition.extent=c,d){const{start:e,end:t}=d;n.layerDefinition.timeInfo.timeExtent=[e,t]}return n}async applyEdits(){throw new n("csv-layer:editing-not-supported","applyEdits() is not supported on CSVLayer")}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){await this._waitSnapshotComplete();return(await this._queryEngine.executeQueryForIds(e,t.signal)).filter(O)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),e&&this._queryEngine.featureStore.addMany(e)},e=>{this._queryEngine.featureStore.clear(),s(e)||r.getLogger("esri.layers.CSVLayer").error(new n("csv-layer:refresh","An error occurred during refresh",{error:e}))}),await this._waitSnapshotComplete();const{fullExtent:i,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:i,timeExtent:o}}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:i,customParameters:r}=this._loadOptions;if(!i)throw new n("csv-layer:invalid-source","url not defined");const s=o(i);return(await e(s.path,{query:{...s.query,...r},responseType:"text",signal:t})).data}_createFeatures(e){const{latitudeFieldName:t,longitudeFieldName:n}=this._locationInfo,{fieldsIndex:r,spatialReference:s}=this._queryEngine,o=this._featureIdInfo.fieldName;let a=[];const u=[],h=r.fields.filter(e=>e.name!==o).map(e=>e.name);let I=0;const g={};for(const i of r.fields)if("esriFieldTypeOID"!==i.type&&"esriFieldTypeGlobalID"!==i.type){const e=C(i);void 0!==e&&(g[i.name]=e)}const E=_(e,h,this._delimiter,x(g,o));for(const l of E){const e=this._parseCoordinateValue(l[t]),s=this._parseCoordinateValue(l[n]);if(null!=s&&null!=e&&!isNaN(e)&&!isNaN(s)){l[t]=e,l[n]=s;for(const e in l)if(e!==t&&e!==n)if(r.isDateField(e))l[e]=i(l[e]);else if(r.isNumericField(e)){const t=F(l[e]);isNaN(t)?l[e]=null:l[e]=t}else null!=l[e]&&(l[e]=w(l[e]));l[o]=I,I++,a.push(new R(s,e)),u.push(l)}}if(!c({wkid:4326},s))if(d(s))for(const i of a)[i.x,i.y]=f(i.x,i.y,P);else a=l(a,m.WGS84,s);const T=[];for(let i=0;i<a.length;i++){const{x:e,y:t}=a[i],n=u[i];n[o]=i+1,T.push(new p(new y([],[e,t]),n,null,n[o]))}return T}_parseCoordinateValue(e){if(null==e||""===e)return null;let t=F(e);return(isNaN(t)||Math.abs(t)>181)&&(t=parseFloat(e)),t}async _checkProjection(e){try{await I(u,e)}catch{throw new n("csv-layer:projection-not-supported","Projection not supported")}}}function L(e,t){const i=t.parsingOptions||{},r={delimiter:i.delimiter,layerDefinition:null,locationInfo:{latitudeFieldName:i.latitudeField,longitudeFieldName:i.longitudeField}},s=r.layerDefinition={name:q(a(t.url,k)||"csv"),dateFieldsTimeReference:{timeZoneIANA:v},drawingInfo:D,geometryType:"esriGeometryPoint",objectIdField:null,fields:[],timeInfo:i.timeInfo,extent:{xmin:Number.POSITIVE_INFINITY,ymin:Number.POSITIVE_INFINITY,xmax:Number.NEGATIVE_INFINITY,ymax:Number.NEGATIVE_INFINITY,spatialReference:i.spatialReference||{wkid:4326}}},o=E(e),l=o.next().value?.trim(),m=o.next().value?.trim();if(!l)throw new n("csv-layer:empty-csv","CSV is empty",{csv:e});const{delimiter:c,locationInfo:d}=T(l,m,i);if(!c)throw new n("csv-layer:invalid-delimiter","Unable to detect the delimiter from CSV",{firstLine:l,secondLine:m,parsingOptions:i});if(!d)throw new n("csv-layer:location-fields-not-found","Unable to identify latitude and longitude fields from the CSV file",{firstLine:l,secondLine:m,parsingOptions:i});r.locationInfo=d,r.delimiter=c;const{names:u,aliases:f}=j(l,c),p=N(e,r.delimiter,u,f,r.locationInfo);if(i.fields?.length){const e=new b(i.fields);for(const t of p){const i=e.get(t.name);i&&Object.assign(t,i)}}if(!p.some(e=>"esriFieldTypeOID"===e.type&&(s.objectIdField=e.name,!0))){const e={name:"__OBJECTID",alias:"__OBJECTID",type:"esriFieldTypeOID",editable:!1,nullable:!1};s.objectIdField=e.name,p.unshift(e)}s.fields=p;const y=new b(s.fields);if(r.locationInfo&&(r.locationInfo.latitudeFieldName=y.get(r.locationInfo.latitudeFieldName).name,r.locationInfo.longitudeFieldName=y.get(r.locationInfo.longitudeFieldName).name),s.timeInfo){const e=s.timeInfo;if(e.startTimeField){const t=y.get(e.startTimeField);t?(e.startTimeField=t.name,t.type="esriFieldTypeDate"):e.startTimeField=null}if(e.endTimeField){const t=y.get(e.endTimeField);t?(e.endTimeField=t.name,t.type="esriFieldTypeDate"):e.endTimeField=null}if(e.trackIdField){const t=y.get(e.trackIdField);e.trackIdField=t?t.name:null}e.startTimeField||e.endTimeField||(s.timeInfo=null)}return r}export{V as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../core/Error.js";import{getJsonType as t,isPoint as i}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as r,convertToFeature as n,convertFromFeature as a}from"../../featureConversionUtils.js";import{initialObjectId as o,findLastObjectIdFromFeatures as l}from"../../objectIdUtils.js";import u from"../../data/FeatureStore.js";import{checkProjectionSupport as d,project as p}from"../../data/projectionSupport.js";import{QueryEngine as f}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as c,createDefaultTemplate as y,createDrawingInfo as m}from"./clientSideDefaults.js";import{queryBinsCapabilities as g,loadGeometryEngineForSimplify as h,createFeatureEditErrorResult as I,mixAttributes as b,createFeatureEditSuccessResult as F,simplify as j}from"./sourceUtils.js";import E from"../../../support/FieldsIndex.js";import{kebabDict as T}from"../../../support/fieldType.js";import{getFieldDefaultLength as _,getFieldDefaultValue as x}from"../../../support/fieldUtils.js";import{utc as R}from"../../../../time/constants.js";const q=s,O={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:s},S={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentsCountOnly:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsSpatialAggregationStatistics:!0,supportedSpatialAggregationStatistics:["EnvelopeAggregate","CentroidAggregate","ConvexHullAggregate"],supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0,supportsQueryWithCacheHint:!0},queryBinsCapabilities:g};function Q(e){return i(e)?null!=e.z:!!e.hasZ}function A(e){return i(e)?null!=e.m:!!e.hasM}class D{constructor(){this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(t){const i=[],{features:s}=t,r=this._inferLayerProperties(s,t.fields),n=t.fields||[],a=null!=t.hasM?t.hasM:!!r.hasM,p=null!=t.hasZ?t.hasZ:!!r.hasZ,g=!t.spatialReference&&!r.spatialReference,h=g?q:t.spatialReference||r.spatialReference,I=g?O:null,b=t.geometryType||r.geometryType,F=!b;let j=t.objectIdField||r.objectIdField,Q=t.timeInfo;const A=new E(n);if(!F&&(g&&i.push({name:"feature-layer:spatial-reference-not-found",message:"Spatial reference not provided or found in features. Defaults to WGS84"}),!b))throw new e("feature-layer:missing-property","geometryType not set and couldn't be inferred from the provided features");if(!j)throw new e("feature-layer:missing-property","objectIdField not set and couldn't be found in the provided fields");if(r.objectIdField&&j!==r.objectIdField&&(i.push({name:"feature-layer:duplicated-oid-field",message:`Provided objectIdField "${j}" doesn't match the field name "${r.objectIdField}", found in the provided fields`}),j=r.objectIdField),j&&!r.objectIdField){const e=A.get(j);e?(j=e.name,e.type="esriFieldTypeOID",e.editable=!1,e.nullable=!1):n.unshift({alias:j,name:j,type:"esriFieldTypeOID",editable:!1,nullable:!1})}for(const o of n){if(null==o.name&&(o.name=o.alias),null==o.alias&&(o.alias=o.name),!o.name)throw new e("feature-layer:invalid-field-name","field name is missing",{field:o});if(o.name===j&&(o.type="esriFieldTypeOID"),!T.jsonValues.includes(o.type))throw new e("feature-layer:invalid-field-type",`invalid type for field "${o.name}"`,{field:o});null==o.length&&(o.length=_(o))}const D={};for(const e of n)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=x(e);void 0!==t&&(D[e.name]=t)}if(Q){if(Q.startTimeField){const e=A.get(Q.startTimeField);e?(Q.startTimeField=e.name,e.type="esriFieldTypeDate"):Q.startTimeField=null}if(Q.endTimeField){const e=A.get(Q.endTimeField);e?(Q.endTimeField=e.name,e.type="esriFieldTypeDate"):Q.endTimeField=null}if(Q.trackIdField){const e=A.get(Q.trackIdField);e?Q.trackIdField=e.name:(Q.trackIdField=null,i.push({name:"feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:Q}}))}Q.startTimeField||Q.endTimeField||(i.push({name:"feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing or invalid",details:{timeInfo:Q}}),Q=null)}const v=A.dateFields.length?{timeZoneIANA:t.dateFieldsTimeZone??R}:null;this._createDefaultAttributes=c(D,j);const w={warnings:i,featureErrors:[],layerDefinition:{...S,drawingInfo:m(b),templates:y(D),extent:I,geometryType:b,objectIdField:j,fields:n,hasZ:p,hasM:a,timeInfo:Q,dateFieldsTimeReference:v},assignedObjectIds:{}},M={type:"object-id",fieldName:j};if(this._queryEngine=new f({fieldsIndex:E.fromLayerJSON({fields:n,timeInfo:Q,dateFieldsTimeReference:v}),geometryType:b,hasM:a,hasZ:p,featureIdInfo:M,spatialReference:h,featureStore:new u({geometryType:b,hasM:a,hasZ:p}),timeInfo:Q}),!s?.length)return this._nextObjectId=o,w;const C=l(j,s);return this._nextObjectId=C+1,await d(s,h),this._loadInitialFeatures(w,s)}async applyEdits(e){const{spatialReference:t,geometryType:i}=this._queryEngine;return await Promise.all([h(t,i),d(e.adds,t),d(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}queryAttributeBins(e,t={}){return this._queryEngine.executeAttributeBinsQuery(e,t.signal)}_inferLayerProperties(e,i){let s,r,n=null,a=null,o=null;for(const l of e){const e=l.geometry;if(null!=e&&(n||(n=t(e)),a||(a=e.spatialReference),null==s&&(s=Q(e)),null==r&&(r=A(e)),n&&a&&null!=s&&null!=r))break}if(i&&i.length){let e=null;i.some(t=>{const i="esriFieldTypeOID"===t.type,s=!t.type&&t.name&&"objectid"===t.name.toLowerCase();return e=t,i||s})&&(o=e.name)}return{geometryType:n,spatialReference:a,objectIdField:o,hasM:r,hasZ:s}}async _loadInitialFeatures(e,i){const{geometryType:s,hasM:n,hasZ:a,objectIdField:o,spatialReference:l,featureStore:u,fieldsIndex:d}=this._queryEngine,f=[],c={type:"object-id",fieldName:o};for(const r of i){if(null!=r.uid&&(e.assignedObjectIds[r.uid]=-1),r.geometry&&s!==t(r.geometry)){e.featureErrors.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),n=b(d,i,r.attributes,!0);n?e.featureErrors.push(n):(this._assignObjectId(i,r.attributes,!0),r.attributes=i,null!=r.uid&&(e.assignedObjectIds[r.uid]=r.attributes[o]),null!=r.geometry&&(r.geometry=p(r.geometry,r.geometry.spatialReference,l)),f.push(r))}u.addMany(r([],f,s,a,n,c));const{fullExtent:y,timeExtent:m}=await this._queryEngine.fetchRecomputedExtents();if(e.layerDefinition.extent=y,m){const{start:t,end:i}=m;e.layerDefinition.timeInfo.timeExtent=[t,i]}return e}async _applyEdits(e){const{adds:t,updates:i,deletes:s}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(r,t),i?.length&&this._applyUpdateEdits(r,i),s?.length){for(const e of s)r.deleteResults.push(F(e));this._queryEngine.featureStore.removeManyById(s)}const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a,featureEditResults:r}}_applyAddEdits(e,i){const{addResults:s}=e,{geometryType:n,hasM:a,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d,featureIdInfo:f,fieldsIndex:c}=this._queryEngine,y=[];for(const r of i){if(r.geometry&&n!==t(r.geometry)){s.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),a=b(c,i,r.attributes);if(a)s.push(a);else{if(this._assignObjectId(i,r.attributes),r.attributes=i,null!=r.uid){const t=r.attributes[l];e.uidToObjectId[r.uid]=t}if(null!=r.geometry){const e=r.geometry.spatialReference??u;r.geometry=p(j(r.geometry,e),e,u)}y.push(r),s.push(F(r.attributes[l]))}}d.addMany(r([],y,n,o,a,f))}_applyUpdateEdits({updateResults:e},i){const{geometryType:s,hasM:r,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d,fieldsIndex:f,featureIdInfo:c}=this._queryEngine;for(const y of i){const{attributes:i,geometry:m}=y,g=i?.[l];if(null==g){e.push(I(`Identifier field ${l} missing`));continue}if(!d.has(g)){e.push(I(`Feature with object id ${g} missing`));continue}const h=n(d.getFeature(g),s,o,r);if(null!=m){if(s!==t(m)){e.push(I("Incorrect geometry type."));continue}const i=m.spatialReference??u;h.geometry=p(j(m,i),i,u)}if(i){const t=b(f,h.attributes,i);if(t){e.push(t);continue}}d.add(a(h,s,o,r,c)),e.push(F(g))}}_assignObjectId(e,t,i=!1){const s=this._queryEngine.objectIdField;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}export{D as default};
2
+ import e from"../../../../core/Error.js";import{getJsonType as t,isPoint as i}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as n,convertToFeature as r,convertFromFeature as a}from"../../featureConversionUtils.js";import{initialObjectId as o,findLastObjectIdFromFeatures as u}from"../../objectIdUtils.js";import l from"../../data/FeatureStore.js";import{checkProjectionSupport as d,project as p}from"../../data/projectionSupport.js";import{QueryEngine as f}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as c,createDefaultTemplate as y,createDrawingInfo as m}from"./clientSideDefaults.js";import{queryBinsCapabilities as h,loadGeometryEngineForSimplify as g,createFeatureEditErrorResult as I,mixAttributes as b,createFeatureEditSuccessResult as F,simplify as j}from"./sourceUtils.js";import _ from"../../../support/FieldsIndex.js";import{kebabDict as q}from"../../../support/fieldType.js";import{getFieldDefaultLength as E,getFieldDefaultValue as T}from"../../../support/fieldUtils.js";import{utc as x}from"../../../../time/constants.js";const R=s,v={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:s},O={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentsCountOnly:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsSpatialAggregationStatistics:!0,supportedSpatialAggregationStatistics:["EnvelopeAggregate","CentroidAggregate","ConvexHullAggregate"],supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0,supportsQueryWithCacheHint:!0},queryBinsCapabilities:h};function S(e){return i(e)?null!=e.z:!!e.hasZ}function w(e){return i(e)?null!=e.m:!!e.hasM}function D(e,t){let i;const s=[];if("unique-id-composite"===t.type){const n=[];for(const i of t.fieldNames)e.attributes[i]?n.push(e.attributes[i]):s.push(i);i=0===s.length?JSON.stringify(n):null}else i=e.attributes[t.fieldName],i||s.push(t.fieldName);return{objectId:i,missingFields:s}}class Q{constructor(){this._uniqueIdInfo=null,this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(t){const i=[],{features:s}=t,n=this._inferLayerProperties(s,t.fields),r=t.fields||[],a=null!=t.hasM?t.hasM:!!n.hasM,p=null!=t.hasZ?t.hasZ:!!n.hasZ,h=!t.spatialReference&&!n.spatialReference,g=h?R:t.spatialReference||n.spatialReference,I=h?v:null,b=t.geometryType||n.geometryType,F=!b,j=t.uniqueIdInfo;let S=t.objectIdField??n.objectIdField,w=t.timeInfo;const D=new _(r);if(!F&&(h&&i.push({name:"feature-layer:spatial-reference-not-found",message:"Spatial reference not provided or found in features. Defaults to WGS84"}),!b))throw new e("feature-layer:missing-property","geometryType not set and couldn't be inferred from the provided features");if(j){const t=new Set(r.map(({name:e})=>e));if(!j.fields.every(e=>t.has(e))){const i=j.fields.filter(e=>!t.has(e));throw new e("feature-layer:missing-property","UniqueIdFields not set and couldn't be found in the provided fields. Fields: "+i+" are mssing.")}S=null}else if(!S)throw new e("feature-layer:missing-property","objectIdField not set and uniqueIdInfo not provided.");if(n.objectIdField&&S!==n.objectIdField&&(i.push({name:"feature-layer:duplicated-oid-field",message:`Provided objectIdField "${S}" doesn't match the field name "${n.objectIdField}", found in the provided fields`}),S=n.objectIdField),S&&!n.objectIdField){const e=D.get(S);e?(S=e.name,e.type="esriFieldTypeOID",e.editable=!1,e.nullable=!1):r.unshift({alias:S,name:S,type:"esriFieldTypeOID",editable:!1,nullable:!1})}for(const o of r){if(null==o.name&&(o.name=o.alias),null==o.alias&&(o.alias=o.name),!o.name)throw new e("feature-layer:invalid-field-name","field name is missing",{field:o});if(o.name===S&&(o.type="esriFieldTypeOID"),!q.jsonValues.includes(o.type))throw new e("feature-layer:invalid-field-type",`invalid type for field "${o.name}"`,{field:o});null==o.length&&(o.length=E(o))}const Q={};for(const e of r)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=T(e);void 0!==t&&(Q[e.name]=t)}if(w){if(w.startTimeField){const e=D.get(w.startTimeField);e?(w.startTimeField=e.name,e.type="esriFieldTypeDate"):w.startTimeField=null}if(w.endTimeField){const e=D.get(w.endTimeField);e?(w.endTimeField=e.name,e.type="esriFieldTypeDate"):w.endTimeField=null}if(w.trackIdField){const e=D.get(w.trackIdField);e?w.trackIdField=e.name:(w.trackIdField=null,i.push({name:"feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:w}}))}w.startTimeField||w.endTimeField||(i.push({name:"feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing or invalid",details:{timeInfo:w}}),w=null)}const A=D.dateFields.length?{timeZoneIANA:t.dateFieldsTimeZone??x}:null;this._createDefaultAttributes=c(Q,S),this._uniqueIdInfo=t.uniqueIdInfo??void 0;const M={warnings:i,featureErrors:[],layerDefinition:{...O,drawingInfo:m(b),templates:y(Q),extent:I,geometryType:b,objectIdField:S,fields:r,hasZ:p,hasM:a,timeInfo:w,dateFieldsTimeReference:A,uniqueIdInfo:this._uniqueIdInfo??void 0},assignedObjectIds:{}},C=this._uniqueIdInfo?.OIDFieldContainsHashValue?"simple"===this._uniqueIdInfo.type?{type:"unique-id-simple",fieldName:this._uniqueIdInfo.fields[0]}:{type:"unique-id-composite",fieldNames:this._uniqueIdInfo.fields}:{type:"object-id",fieldName:S};if(this._queryEngine=new f({fieldsIndex:_.fromLayerJSON({fields:r,timeInfo:w,dateFieldsTimeReference:A}),geometryType:b,hasM:a,hasZ:p,featureIdInfo:C,spatialReference:g,featureStore:new l({geometryType:b,hasM:a,hasZ:p}),timeInfo:w}),!s?.length)return this._nextObjectId=o,M;if(S){const e=u(S,s);this._nextObjectId=e+1}return await d(s,g),this._loadInitialFeatures(M,s)}async applyEdits(e){const{spatialReference:t,geometryType:i}=this._queryEngine;return await Promise.all([g(t,i),d(e.adds,t),d(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}queryAttributeBins(e,t={}){return this._queryEngine.executeAttributeBinsQuery(e,t.signal)}_inferLayerProperties(e,i){let s,n,r=null,a=null,o=null;for(const u of e){const e=u.geometry;if(null!=e&&(r||(r=t(e)),a||(a=e.spatialReference),null==s&&(s=S(e)),null==n&&(n=w(e)),r&&a&&null!=s&&null!=n))break}if(i&&i.length){let e=null;i.some(t=>{const i="esriFieldTypeOID"===t.type,s=!t.type&&t.name&&"objectid"===t.name.toLowerCase();return e=t,i||s})&&(o=e.name)}return{geometryType:r,spatialReference:a,objectIdField:o,hasM:n,hasZ:s}}async _loadInitialFeatures(e,i){const{geometryType:s,hasM:r,hasZ:a,spatialReference:o,featureStore:u,fieldsIndex:l,featureIdInfo:d}=this._queryEngine,f=[];for(const n of i){if(null!=n.uid&&(e.assignedObjectIds[n.uid]=-1),n.geometry&&s!==t(n.geometry)){e.featureErrors.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),r=b(l,i,n.attributes,!0);r?e.featureErrors.push(r):(this._assignObjectId(i,n.attributes,!0),n.attributes=i,n.uid&&(e.assignedObjectIds[n.uid]=D(n,d).objectId),null!=n.geometry&&(n.geometry=p(n.geometry,n.geometry.spatialReference,o)),f.push(n))}u.addMany(n([],f,s,a,r,d));const{fullExtent:c,timeExtent:y}=await this._queryEngine.fetchRecomputedExtents();if(e.layerDefinition.extent=c,y){const{start:t,end:i}=y;e.layerDefinition.timeInfo.timeExtent=[t,i]}return e}async _applyEdits(e){const{adds:t,updates:i,deletes:s}=e,n={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(n,t),i?.length&&this._applyUpdateEdits(n,i),s?.length){for(const e of s)n.deleteResults.push(F(e));this._queryEngine.featureStore.removeManyById(s)}const{fullExtent:r,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:r,timeExtent:a,featureEditResults:n}}_applyAddEdits(e,i){const{addResults:s,updateResults:r}=e,{geometryType:a,hasM:o,hasZ:u,spatialReference:l,featureStore:d,featureIdInfo:f,fieldsIndex:c}=this._queryEngine,y=[];for(const m of i){if(m.geometry&&a!==t(m.geometry)){s.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),h=b(c,i,m.attributes);if(h){s.push(h);continue}this._assignObjectId(i,m.attributes),m.attributes=i;const{objectId:g,missingFields:_}=D(m,f);if(g){if(null!=m.uid&&(e.uidToObjectId[m.uid]=g),null!=m.geometry){const e=m.geometry.spatialReference??l;m.geometry=p(j(m.geometry,e),e,l)}y.push(m);const t=F(g);d.has(g)?r.push(t):s.push(t),d.addMany(n([],y,a,u,o,f))}else s.push(I(`Missing unique id field value for fields: ${_.join()}`))}}_applyUpdateEdits({updateResults:e},i){const{geometryType:s,hasM:n,hasZ:o,spatialReference:u,featureStore:l,fieldsIndex:d,featureIdInfo:f}=this._queryEngine;for(const c of i){const{attributes:i,geometry:y}=c,{objectId:m,missingFields:h}=D(c,f);if(null==m){const t="unique-id-composite"===f.type?h:f.fieldName;e.push(I(`Identifier fields: ${t} missing`));continue}if(!l.has(m)){e.push(I(`Feature with object id ${m} missing`));continue}const g=r(l.getFeature(m),s,o,n);if(null!=y){if(s!==t(y)){e.push(I("Incorrect geometry type."));continue}const i=y.spatialReference??u;g.geometry=p(j(y,i),i,u)}if(i){const t=b(d,g.attributes,i);if(t){e.push(t);continue}}l.add(a(g,s,o,n,f)),e.push(F(m))}}_assignObjectId(e,t,i=!1){if("object-id"===this._queryEngine.featureIdInfo.type){const s=this._queryEngine.featureIdInfo.fieldName;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}}export{Q as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../../../core/Collection.js";import{toConst as s}from"../../../../core/compilerUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import o from"../../../../core/Logger.js";import{onAbortOrThrow as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import{QueueProcessor as u}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import p from"../../../../geometry/SpatialReference.js";import{set as c,create as d,expandWithRect as f,expandWithAABB as m,negativeInfinity as y,fromRect as h}from"../../../../geometry/support/aaBoundingBox.js";import{getQueryResultExtent as g,QueryEngine as w}from"../../data/QueryEngine.js";import{QueryEngineResult as _}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as F}from"../../data/queryUtils.js";import{createDrawingInfo as x}from"./clientSideDefaults.js";import{getParquetFileId as I,getParquetRowId as R}from"./parquetIdUtils.js";import S from"../../../support/Field.js";import C from"../../../support/FieldsIndex.js";import{fromParquetGeometryEncodingJSON as q}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as v,fromParquetJSONGeometryType as b,toParquetJSONGeometryType as E}from"../../../support/parquetUtils.js";import{loadParquetModule as O}from"../../../../libs/parquet/loadParquetModule.js";import{createParquetFile as Q,readGeoMetadata as j}from"../../../../libs/parquet/parquet.js";import{FeatureStoreQueryAdapter as T}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as M}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as P}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as A}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as G}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const B=new T,D=4,z="__OBJECTID",W=new TextDecoder;class U{constructor(){this._fileInfos=new Map,this._queue=new u({concurrency:D,process:(e,t)=>this._executeQuery(e,t)}),this._indexMap={}}async load(s){const a=s.spatialReference?p.fromJSON(s.spatialReference):void 0;if(a&&!a.isWGS84&&!a.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");const n=await v({urls:new r(s.urls),fields:s.fields?.map(e=>S.fromJSON(e)),geometryEncoding:s.geometryEncoding?q(s.geometryEncoding):null,geometryType:s.geometryType?b(s.geometryType):null,displayOptimization:s.displayOptimization,spatialReference:a},{customParameters:s.customParameters});if(!n.fields)throw new i("parquet:unsupported","Fields must be defined");let u;if(n.spatialReference&&n.geometryType){if(!n.spatialReference)throw new i("parquet:unsupported","SpatialReference must be defined");if(!n.spatialReference.isGeographic&&!n.spatialReference.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");n.spatialReference.isGeographic&&!n.spatialReference.isWGS84&&(o.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:n.spatialReference}),n.spatialReference=p.WGS84),u={geometry:n.geometryEncoding?{geometryType:E(n.geometryType),spatialReference:n.spatialReference.toJSON(),encoding:n.geometryEncoding.toJSON()}:null,displayOptimization:n.displayOptimization}}this.setCustomParameters(s.customParameters),this._geometryInfo=u;const l=s.urls;for(const e of l)this._addFile(e);this._capabilities=H(await this.getFileStatistics());const m=this._fileInfos.values().next().value;if(!m)return{layerDefinition:{},capabilities:H(null)};const h=await m,{fields:g}=n;if(null==g)throw new i("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",g);g.push(new S({name:z,type:"oid",alias:z}));for(const e of g){const t=h.file.columnForFieldName(e.name);null!=t&&(this._indexMap[e.name]=t)}const w=new C(g.map(e=>e.toJSON()));this._fieldsIndex=w;const _=E(n.geometryType??"point");if(this._metadata=A.createFeature({fieldsIndex:w.toJSON(),geometryType:_,hasZ:!1,hasM:!1,featureIdInfo:{type:"object-id",fieldName:"rowId"},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:n.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:_,featureIdInfo:{type:"object-id",fieldName:"rowId"},hasM:!1,hasZ:!1,spatialReference:n.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},n.spatialReference){const e=await this.getFileInfos();this._fullExtent=V(e,n.spatialReference.toJSON())}if(null==this._fullExtent&&"location"===n.geometryEncoding?.type){const{xField:r,yField:s}=n.geometryEncoding,i=c(d(),y);for(const o of await this.getFileInfos())for(const a of o.file.rowGroups()){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,a.columnDescriptorForAttribute(r),!1),n=e(o,a.columnDescriptorForAttribute(s),!1),u=[t.minValue(),n.minValue(),t.maxValue(),n.maxValue()];f(i,u),a.free()}catch(F){o.error=F,o.hasError=!0}finally{t(o)}}this._fullExtent={xmin:i[0],ymin:i[1],xmax:i[3],ymax:i[4],spatialReference:n.spatialReference?.toJSON()}}return{capabilities:this._capabilities,layerDefinition:{fields:n.fields?.map(e=>e.toJSON()),drawingInfo:x(_),extent:this._fullExtent??void 0,geometryType:_,geometryEncoding:n.geometryEncoding?.toJSON(),displayOptimization:n.displayOptimization}}}destroy(){for(const e of this._fileInfos.values())e.then(e=>e.file.free);this._fileInfos.clear(),this._queue.destroy()}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async getFileId(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return(await t).id}async getFileInfo(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return t}async getFileInfos(){return Promise.all(Array.from(this._fileInfos.values()))}async getFileStatistics(){if(!this._fileInfos.size)return null;const e=(await this.getFileInfos()).reduce((e,t)=>e+t.file.byteLength(),0);return{featureCount:await this._getFeatureCount(),byteLength:e}}async updateFiles(e){const t=new Set(e);for(const[r,s]of this._fileInfos.entries())t.has(r)?t.delete(r):(s.then(e=>e.file.free()),this._fileInfos.delete(r));await Promise.all(Array.from(t.values()).map(e=>this._addFile(e)))}async queryFeatures(e,t){this._validateQuery(e),Z(e)||(e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0),(e.outStatistics||e.returnDistinctValues)&&(e.returnGeometry=void 0);return(await this._enqueueQuery(e,t)).createQueryResponse()}async queryFeatureCount(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return this._getFeatureCount();r.outFields=void 0,r.returnGeometry=void 0;return(await this._enqueueQuery(r,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,8e3):8e3,r.resultOffset=r.resultOffset??0,r.returnGeometry=void 0,r.outFields=void 0;return(await this._enqueueQuery(r,t)).items.map(e=>e.getObjectId())}async queryExtent(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!N(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const o=c(d(),y),a=d(),n=await this._enqueueQuery(r,t);let u=0;for(const s of n.items)s.getBounds(a)&&(m(o,a),u+=1);return{count:u,extent:g(o,i,r.outSR?s(r.outSR):i,i,!1)}}async queryStream(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=(await O()).Query.new();"tile"===t.type&&(i.setExtent(t.extent),i.setQuantizationTransform(t.transform),i.setScale(t.scale)),i.setOutFields(t.outFields.filter(e=>null!=this._indexMap[e])),i.setOutSpatialReference(t.outSpatialReference.wkid),i.setReturnGeometry(!0),t.where&&await this._setWhereClause(i,s.file,t.where);const o=await s.file.executeQuery(i,r.signal),n=s.streamIdCounter++,u=a(r.signal,e=>{const t=s.streams.get(n);null!=t&&(t.handle.remove(),s.streams.delete(n))});return s.streams.set(n,{stream:o,handle:u}),n}async getStreamNext(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=s.streams.get(t);if(!i)return null;const o=await i.stream.next(r.signal);return null==o&&(i.handle.remove(),s.streams.delete(t)),o?.serialize().buffer}async createPatch(e,t,r,s,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const o=await this.getFileInfo(e);return(await o.file.createChunkPatch(t,r,s,i.signal)).serialize().buffer}async _getFile(e){for(const t of await this.getFileInfos())if(t.id===e)return t.file;throw new Error(`InternalError: File ${e} does not exist`)}_addFile(e){const t=this._fileInfos.size;this._fileInfos.set(e,this._createFileInfo(e,t))}async _createFileInfo(e,t){return{id:t,file:await Q(e,{geometryInfo:this._geometryInfo,getCustomParameters:()=>this._customParameters}),streamIdCounter:0,streams:new Map}}async _getFeatureCount(){return(await this.getFileInfos()).reduce((e,t)=>e+t.file.numRows(),0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new i("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new i("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new i("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,r){const s=this._indexMap,o=this._fieldsIndex,a={getAttribute(e,r){const i=t.readAttribute(e.rowGroup,e.row,s[r]);if(null==i)return null;const a=o.get(r);return"esriFieldTypeString"===a.type||"esriFieldTypeDateOnly"===a.type||"esriFieldTypeTimeOnly"===a.type||"esriFieldTypeTimestampOffset"===a.type?W.decode(i):i}},n=await l(r,this._fieldsIndex);if(!n.isStandardized)throw new i("sql-parse-error","expression is not standardized");const u=(e,t)=>n.testFeatureCompiled({rowGroup:e,row:t},a,null);e.setWhere(r),e.setWhereEvaluator(u),e.setWhereFields(n.fieldNames)}async*_fetchChunks(e,t){const r=await O();for(const s of await this.getFileInfos()){const i=r.Query.new();i.setOutFields(e.fields),i.setReturnGeometry(e.returnGeometry),e.where&&await this._setWhereClause(i,s.file,e.where);const o=await s.file.executeQuery(i),a=[],u=o.next(t);for(let e=0;e<D;e++)a.push(o.next(t));let l=await u;for(;null!=l;){n(t);const e=new G(this._metadata,this._indexMap,l,s.id),r=k([new M(e,null,0,!1)],this._queryEngineParams),i=a.shift();a.push(o.next(t)),yield r,l=await i}}}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){const r=await this._getReadParams(e);if(e.where=void 0,e.objectIds?.length){const r=new Map;for(const t of e.objectIds){const e=I(t),s=R(t);let i=r.get(e);i||(i=[],r.set(e,i)),i.push(s)}const s=[];for(const[i,o]of r.entries()){const r=await this._executeFileIdQuery(e,i,o,t);for(const e of r)s.push(e)}return new _(s,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}let s=e.resultRecordCount??await this._getFeatureCount(),i=e.resultOffset??0;e.resultRecordCount=void 0,e.resultOffset=void 0;const o=[];for await(const a of this._fetchChunks(r,t)){const r=await a.executeQueryForOpaqueFeatures(e,t);if(r.length>i){const t=r.slice(i,Math.min(i+s,r.length));for(const e of t)o.push(e);if(i=0,s-=t.length,0===s)return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}else i-=r.length}return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}async _executeFileIdQuery(e,t,r,s){const i=await this._getReadParams(e),o=(await O()).Query.new();o.setOutFields(i.fields),o.setReturnGeometry(i.returnGeometry),o.setIds(new Uint32Array(r));const a=await this._getFile(t),n=await a.executeQuery(o,s);let u=await n.next(s),l=0;const p=[];for(;null!=u;){const e=new G(this._metadata,this._indexMap,u,t),r=new M(e,null,l++,!1);p.push(r),u=await n.next(s)}return k(p,this._queryEngineParams).executeQueryForOpaqueFeatures(e,s)}async _getReadParams(e){const t=new Set;if(e.outStatistics)for(const r of e.outStatistics)null!=r.onStatisticField&&t.add(r.onStatisticField);if(e.outFields)for(const r of e.outFields)t.add(r);return{fields:(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e]),returnGeometry:!!e.returnGeometry||!!e.geometry,where:e.where}}}function N(e){for(const t in e){const r=t;switch(r){case"resultOffset":case"resultRecordCount":case"aggregateIds":case"distance":case"gdbVersion":case"geometry":case"having":case"timeExtent":case"objectIds":case"historicMoment":case"where":return null!=e[r]}}return!1}function k(e,t){const r=new P;for(const s of e)r.insert(s);return new w({...t,featureStore:r})}function J(e){switch(e.length){case 4:return h(d(),e);case 6:return e;default:throw new i("parquet:protocol-violation","Invalid Geoparquet file. BoundingBox size must be 4 or 6.",{bbox:e})}}function V(e,t){const r=c(d(),y);for(const s of e){const e=j(s.file);if(!e)return null;const t=e.columns[e.primary_column];if(!t.bbox)return null;const i=J(t.bbox);m(r,i)}return{xmin:r[0],ymin:r[1],xmax:r[3],ymax:r[4],spatialReference:t}}function H(e){const t=e?.featureCount;let r=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(r=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:8e3,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,supportsCacheHint:!1,supportsCentroid:!0,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:r,supportsExtent:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:r,supportsPagination:!0,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!0,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:r,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function Z(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{U as default};
2
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../../../core/Collection.js";import{toConst as s}from"../../../../core/compilerUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import o from"../../../../core/Logger.js";import{onAbortOrThrow as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import{QueueProcessor as u}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import p from"../../../../geometry/SpatialReference.js";import{set as c,create as d,expandWithRect as f,expandWithAABB as m,negativeInfinity as y,fromRect as h}from"../../../../geometry/support/aaBoundingBox.js";import{getQueryResultExtent as g,QueryEngine as w}from"../../data/QueryEngine.js";import{QueryEngineResult as _}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as I}from"../../data/queryUtils.js";import{createDrawingInfo as F}from"./clientSideDefaults.js";import{getParquetFileId as x,getParquetRowId as R}from"./parquetIdUtils.js";import S from"../../../support/Field.js";import q from"../../../support/FieldsIndex.js";import{fromParquetGeometryEncodingJSON as C}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as v,fromParquetJSONGeometryType as E,toParquetJSONGeometryType as b}from"../../../support/parquetUtils.js";import{loadParquetModule as O}from"../../../../libs/parquet/loadParquetModule.js";import{createParquetFile as Q,readGeoMetadata as T}from"../../../../libs/parquet/parquet.js";import{FeatureStoreQueryAdapter as j}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as P}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as M}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as A}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as G}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const B=new j,D=4,z="__OBJECTID",W=new TextDecoder;class U{constructor(){this._fileInfos=new Map,this._queue=new u({concurrency:D,process:(e,t)=>this._executeQuery(e,t)}),this._indexMap={}}async load(s){const a=s.spatialReference?p.fromJSON(s.spatialReference):void 0;if(a&&!a.isWGS84&&!a.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");const n=await v({urls:new r(s.urls),fields:s.fields?.map(e=>S.fromJSON(e)),geometryEncoding:s.geometryEncoding?C(s.geometryEncoding):null,geometryType:s.geometryType?E(s.geometryType):null,displayOptimization:s.displayOptimization,spatialReference:a},{customParameters:s.customParameters});if(!n.fields)throw new i("parquet:unsupported","Fields must be defined");let u;if(n.spatialReference&&n.geometryType){if(!n.spatialReference)throw new i("parquet:unsupported","SpatialReference must be defined");if(!n.spatialReference.isGeographic&&!n.spatialReference.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");n.spatialReference.isGeographic&&!n.spatialReference.isWGS84&&(o.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:n.spatialReference}),n.spatialReference=p.WGS84),u={geometry:n.geometryEncoding?{geometryType:b(n.geometryType),spatialReference:n.spatialReference.toJSON(),encoding:n.geometryEncoding.toJSON()}:null,displayOptimization:n.displayOptimization}}this.setCustomParameters(s.customParameters),this._geometryInfo=u;const l=s.urls;for(const e of l)this._addFile(e);this._capabilities=H(await this.getFileStatistics());const m=this._fileInfos.values().next().value;if(!m)return{layerDefinition:{},capabilities:H(null)};const h=await m,{fields:g}=n;if(null==g)throw new i("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",g);g.push(new S({name:z,type:"oid",alias:z}));for(const e of g){const t=h.file.columnForFieldName(e.name);null!=t&&(this._indexMap[e.name]=t)}const w=new q(g.map(e=>e.toJSON()));this._fieldsIndex=w;const _=b(n.geometryType??"point");if(this._metadata=A.createFeature({fieldsIndex:w.toJSON(),geometryType:_,hasZ:!1,hasM:!1,featureIdInfo:{type:"object-id",fieldName:"rowId"},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:n.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:_,featureIdInfo:{type:"object-id",fieldName:"rowId"},hasM:!1,hasZ:!1,spatialReference:n.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},n.spatialReference){const e=await this.getFileInfos();this._fullExtent=V(e,n.spatialReference.toJSON())}if(null==this._fullExtent&&"location"===n.geometryEncoding?.type){const{xField:r,yField:s}=n.geometryEncoding,i=c(d(),y);for(const o of await this.getFileInfos())for(const a of o.file.rowGroups()){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,a.columnDescriptorForAttribute(r),!1),n=e(o,a.columnDescriptorForAttribute(s),!1),u=[t.minValue(),n.minValue(),t.maxValue(),n.maxValue()];f(i,u),a.free()}catch(I){o.error=I,o.hasError=!0}finally{t(o)}}this._fullExtent={xmin:i[0],ymin:i[1],xmax:i[3],ymax:i[4],spatialReference:n.spatialReference?.toJSON()}}return{capabilities:this._capabilities,layerDefinition:{fields:n.fields?.map(e=>e.toJSON()),drawingInfo:F(_),extent:this._fullExtent??void 0,geometryType:_,geometryEncoding:n.geometryEncoding?.toJSON(),displayOptimization:n.displayOptimization}}}destroy(){for(const e of this._fileInfos.values())e.then(e=>e.file.free);this._fileInfos.clear(),this._queue.destroy()}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async getFileId(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return(await t).id}async getFileInfo(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return t}async getFileInfos(){return Promise.all(Array.from(this._fileInfos.values()))}async getFileStatistics(){if(!this._fileInfos.size)return null;const e=(await this.getFileInfos()).reduce((e,t)=>e+t.file.byteLength(),0);return{featureCount:await this._getFeatureCount(),byteLength:e}}async updateFiles(e){const t=new Set(e);for(const[r,s]of this._fileInfos.entries())t.has(r)?t.delete(r):(s.then(e=>e.file.free()),this._fileInfos.delete(r));await Promise.all(Array.from(t.values()).map(e=>this._addFile(e)))}async queryFeatures(e,t){this._validateQuery(e),Z(e)||(e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0),(e.outStatistics||e.returnDistinctValues)&&(e.returnGeometry=void 0);return(await this._enqueueQuery(e,t)).createQueryResponse()}async queryFeatureCount(e,t){const r=await I(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return this._getFeatureCount();r.outFields=void 0,r.returnGeometry=void 0;return(await this._enqueueQuery(r,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const r=await I(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,8e3):8e3,r.resultOffset=r.resultOffset??0,r.returnGeometry=void 0,r.outFields=void 0;return(await this._enqueueQuery(r,t)).items.map(e=>e.getObjectId())}async queryExtent(e,t){const r=await I(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!N(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const o=c(d(),y),a=d(),n=await this._enqueueQuery(r,t);let u=0;for(const s of n.items)s.getBounds(a)&&(m(o,a),u+=1);return{count:u,extent:g(o,i,r.outSR?s(r.outSR):i,i,!1)}}async queryStream(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=(await O()).Query.new();"tile"===t.type&&(i.setExtent(t.extent),i.setQuantizationTransform(t.transform),i.setScale(t.scale)),i.setOutFields(t.outFields.filter(e=>null!=this._indexMap[e])),i.setOutSpatialReference(t.outSpatialReference.wkid),i.setReturnGeometry(!0),t.where&&await this._setWhereClause(i,s.file,t.where);const o=await s.file.executeQuery(i,r.signal),n=s.streamIdCounter++,u=a(r.signal,e=>{const t=s.streams.get(n);null!=t&&(t.handle.remove(),s.streams.delete(n))});return s.streams.set(n,{stream:o,handle:u}),n}async getStreamNext(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=s.streams.get(t);if(!i)return null;const o=await i.stream.next(r.signal);return null==o&&(i.handle.remove(),s.streams.delete(t)),o?.serialize().buffer}async createPatch(e,t,r,s,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const o=await this.getFileInfo(e);return(await o.file.createChunkPatch(t,r,s,i.signal)).serialize().buffer}async _getFile(e){for(const t of await this.getFileInfos())if(t.id===e)return t.file;throw new Error(`InternalError: File ${e} does not exist`)}_addFile(e){const t=this._fileInfos.size;this._fileInfos.set(e,this._createFileInfo(e,t))}async _createFileInfo(e,t){return{id:t,file:await Q(e,{geometryInfo:this._geometryInfo,getCustomParameters:()=>this._customParameters}),streamIdCounter:0,streams:new Map}}async _getFeatureCount(){return(await this.getFileInfos()).reduce((e,t)=>e+t.file.numRows(),0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new i("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new i("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new i("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,r){const s=this._indexMap,o=this._fieldsIndex,a={getAttribute(e,r){const i=t.readAttribute(e.rowGroup,e.row,s[r]);if(null==i)return null;const a=o.get(r);return"esriFieldTypeString"===a.type||"esriFieldTypeDateOnly"===a.type||"esriFieldTypeTimeOnly"===a.type||"esriFieldTypeTimestampOffset"===a.type?W.decode(i):i}},n=await l(r,this._fieldsIndex);if(!n.isStandardized)throw new i("sql-parse-error","expression is not standardized");const u=(e,t)=>n.testFeatureCompiled({rowGroup:e,row:t},a,null);e.setWhere(r),e.setWhereEvaluator(u),e.setWhereFields(n.fieldNames)}async*_fetchChunks(e,t){const r=await O();for(const s of await this.getFileInfos()){const i=r.Query.new();i.setOutFields(e.fields),i.setReturnGeometry(e.returnGeometry),e.where&&await this._setWhereClause(i,s.file,e.where);const o=await s.file.executeQuery(i),a=[],u=o.next(t);for(let e=0;e<D;e++)a.push(o.next(t));let l=await u;for(;null!=l;){n(t);const e=new G(this._metadata,this._indexMap,l,s.id),r=k([new P(e,null,0,!1)],this._queryEngineParams),i=a.shift();a.push(o.next(t)),yield r,l=await i}}}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){const r=await this._getReadParams(e);if(e.where=void 0,e.objectIds?.length){const r=new Map;for(const t of e.objectIds){const e=x(t),s=R(t);let i=r.get(e);i||(i=[],r.set(e,i)),i.push(s)}const s=[];for(const[i,o]of r.entries()){const r=await this._executeFileIdQuery(e,i,o,t);for(const e of r)s.push(e)}return new _(s,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:B,featureIdInfo:this._queryEngineParams.featureIdInfo})}let s=e.resultRecordCount??await this._getFeatureCount(),i=e.resultOffset??0;e.resultRecordCount=void 0,e.resultOffset=void 0;const o=[];for await(const a of this._fetchChunks(r,t)){const r=await a.executeQueryForOpaqueFeatures(e,t);if(r.length>i){const t=r.slice(i,Math.min(i+s,r.length));for(const e of t)o.push(e);if(i=0,s-=t.length,0===s)return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:B,featureIdInfo:this._queryEngineParams.featureIdInfo})}else i-=r.length}return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:B,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,r,s){const i=await this._getReadParams(e),o=(await O()).Query.new();o.setOutFields(i.fields),o.setReturnGeometry(i.returnGeometry),o.setIds(new Uint32Array(r));const a=await this._getFile(t),n=await a.executeQuery(o,s);let u=await n.next(s),l=0;const p=[];for(;null!=u;){const e=new G(this._metadata,this._indexMap,u,t),r=new P(e,null,l++,!1);p.push(r),u=await n.next(s)}return k(p,this._queryEngineParams).executeQueryForOpaqueFeatures(e,s)}async _getReadParams(e){const t=new Set;if(e.outStatistics)for(const r of e.outStatistics)null!=r.onStatisticField&&t.add(r.onStatisticField);if(e.outFields)for(const r of e.outFields)t.add(r);return{fields:(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e]),returnGeometry:!!e.returnGeometry||!!e.geometry,where:e.where}}}function N(e){for(const t in e){const r=t;switch(r){case"resultOffset":case"resultRecordCount":case"aggregateIds":case"distance":case"gdbVersion":case"geometry":case"having":case"timeExtent":case"objectIds":case"historicMoment":case"where":return null!=e[r]}}return!1}function k(e,t){const r=new M;for(const s of e)r.insert(s);return new w({...t,featureStore:r})}function J(e){switch(e.length){case 4:return h(d(),e);case 6:return e;default:throw new i("parquet:protocol-violation","Invalid Geoparquet file. BoundingBox size must be 4 or 6.",{bbox:e})}}function V(e,t){const r=c(d(),y);for(const s of e){const e=T(s.file);if(!e)return null;const t=e.columns[e.primary_column];if(!t.bbox)return null;const i=J(t.bbox);m(r,i)}return{xmin:r[0],ymin:r[1],xmax:r[3],ymax:r[4],spatialReference:t}}function H(e){const t=e?.featureCount;let r=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(r=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:8e3,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,supportsCacheHint:!1,supportsCentroid:!0,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:r,supportsExtent:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:r,supportsPagination:!0,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!0,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:r,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function Z(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{U as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{queryBinsCapabilities as s,queryCapabilities as r}from"../../data/QueryEngineCapabilities.js";import{defaultPointSymbolJSON as e,defaultPolylineSymbolJSON as p,defaultPolygonSymbolJSON as o}from"../../../../symbols/support/defaultsJSON.js";function u(t){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===t||"esriGeometryMultipoint"===t?e:"esriGeometryPolyline"===t?p:o}}}const n=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let i=1;function a(t,s){if(has("esri-csp-restrictions"))return()=>({[s]:null,...t});try{let r=`this${l(s)} = null;`;for(const s in t){r+=`this${l(s)} = ${JSON.stringify(t[s])};`}const e=new Function(`\n return class AttributesClass$${i++} {\n constructor() {\n ${r};\n }\n }\n `)();return()=>new e}catch(r){return()=>({[s]:null,...t})}}function l(t){return n.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}function c(s={}){return[{name:"New Feature",description:"",prototype:{attributes:t(s)}}]}function y(t,e){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:e,supportsDelete:e,supportsEditing:e,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:e,supportsExceedsLimitStatistics:!0,supportsAsyncConvert3D:!1},query:r,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:s,editing:{supportsGeometryUpdate:e,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsTrueCurveUpdate:e,supportsTrueCurveUpdateByTrueCurveClientsOnly:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}export{y as createCapabilities,a as createDefaultAttributesFunction,c as createDefaultTemplate,u as createDrawingInfo};
2
+ import has from"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{queryBinsCapabilities as s,queryCapabilities as r}from"../../data/QueryEngineCapabilities.js";import{defaultPointSymbolJSON as e,defaultPolylineSymbolJSON as p,defaultPolygonSymbolJSON as o}from"../../../../symbols/support/defaultsJSON.js";function u(t){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===t||"esriGeometryMultipoint"===t?e:"esriGeometryPolyline"===t?p:o}}}const n=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let i=1;function a(t,s){if(has("esri-csp-restrictions"))return()=>s?{[s]:null,...t}:{...t};try{let r="";s&&(r+=`this${l(s)} = null;`);for(const s in t){r+=`this${l(s)} = ${JSON.stringify(t[s])};`}const e=new Function(`\n return class AttributesClass$${i++} {\n constructor() {\n ${r};\n }\n }\n `)();return()=>new e}catch(r){return()=>s?{[s]:null,...t}:{...t}}}function l(t){return n.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}function c(s={}){return[{name:"New Feature",description:"",prototype:{attributes:t(s)}}]}function y(t,e){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:e,supportsDelete:e,supportsEditing:e,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:e,supportsExceedsLimitStatistics:!0,supportsAsyncConvert3D:!1},query:r,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:s,editing:{supportsGeometryUpdate:e,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsTrueCurveUpdate:e,supportsTrueCurveUpdateByTrueCurveClientsOnly:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}export{y as createCapabilities,a as createDefaultAttributesFunction,c as createDefaultTemplate,u as createDrawingInfo};