@arcgis/core 4.34.0-next.52 → 4.34.0-next.54

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 (139) hide show
  1. package/applications/Components/formatUtils.d.ts +3 -0
  2. package/applications/Components/formatUtils.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{35fc8a64674005b1d1d7.js → 0a4357af5b8c0532b439.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{e58336aafe8c95bb6831.js → 0eb728cee6e40cb30c01.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{b87ed14fde381f79bc9f.js → 17776d9d3558d45ea7b5.js} +1 -1
  7. package/assets/esri/core/workers/chunks/23f54b49742098def8ae.js +1 -0
  8. package/assets/esri/core/workers/chunks/2efa4d8fe5454f8b2a05.js +1 -0
  9. package/assets/esri/core/workers/chunks/{a69e885336eb5d2729fd.js → 3505988ce3839cdbbc98.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{46ab551bd19e52e73649.js → 3800764932a1c32cb29f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +1 -0
  12. package/assets/esri/core/workers/chunks/435169b455fd2846799b.js +1 -0
  13. package/assets/esri/core/workers/chunks/{77493aa2118d462612a0.js → 43bd338bb0de375b9bb7.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{5a016dcd3192d42d363e.js → 5fc414fc2cfc68828c5b.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js → 659f7e99b2d524ef53fb.js} +2 -2
  16. package/assets/esri/core/workers/chunks/69e6000044bfb03776ac.js +1 -0
  17. package/assets/esri/core/workers/chunks/{037bc400257bc13b3ec8.js → 772e81e9162e2240a7a6.js} +1 -1
  18. package/assets/esri/core/workers/chunks/813efde41e90e652b7db.js +1 -0
  19. package/assets/esri/core/workers/chunks/82404ff7c298493ff6f4.js +1 -0
  20. package/assets/esri/core/workers/chunks/{f1de768b0a6d345f7e39.js → 8f6ff09e7d2f01b79faf.js} +1 -1
  21. package/assets/esri/core/workers/chunks/9639a6f6fab52a501bf7.js +1 -0
  22. package/assets/esri/core/workers/chunks/{cfa8b17cf1349f6ed355.js → 9e9be7f6ea32957f1088.js} +1 -1
  23. package/assets/esri/core/workers/chunks/9fef330b241f958b55df.js +1 -0
  24. package/assets/esri/core/workers/chunks/aab349d4624b78ef429f.js +1 -0
  25. package/assets/esri/core/workers/chunks/b9f5672093727c6f92c9.js +1 -0
  26. package/assets/esri/core/workers/chunks/bcc233a86e01ff1eac16.js +1 -0
  27. package/assets/esri/core/workers/chunks/cac060a187f3a27a19ba.js +1 -0
  28. package/assets/esri/core/workers/chunks/cda27c0fafd687dfa72e.js +1 -0
  29. package/assets/esri/core/workers/chunks/{82a390be9500b629f6bc.js → d0bf1fc6e3c198bc565d.js} +1 -1
  30. package/assets/esri/core/workers/chunks/dd120d562b63618e71c0.js +1 -0
  31. package/assets/esri/core/workers/chunks/dd2b5f115d156b5b212e.js +1 -0
  32. package/assets/esri/core/workers/chunks/e28d3ed65c3a76a044c8.js +1 -0
  33. package/assets/esri/core/workers/chunks/{fb4950995f6780f6c22a.js → ee0286b5f5475f2d853f.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{c5b2a261d8c216ca4a10.js → f8505bf69795f5293a79.js} +1 -1
  35. package/assets/esri/core/workers/chunks/fae6030a81cb91a91b69.js +1 -0
  36. package/assets/esri/core/workers/chunks/ff7962063d132c1ec814.js +1 -0
  37. package/assets/esri/themes/base/widgets/_FloorFilter.scss +23 -19
  38. package/assets/esri/themes/dark/main.css +1 -1
  39. package/assets/esri/themes/light/main.css +1 -1
  40. package/assets/esri/themes/light/view.css +1 -1
  41. package/config.js +1 -1
  42. package/geometry/operators/json/graphicBufferOperator.js +5 -0
  43. package/geometry/support/coordinateSystem.js +1 -1
  44. package/interfaces.d.ts +93 -185
  45. package/kernel.js +1 -1
  46. package/layers/KMLLayer.js +1 -1
  47. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  48. package/layers/graphics/data/QueryEngine.js +1 -1
  49. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  50. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  51. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  52. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  53. package/layers/support/ElevationQuery.js +1 -1
  54. package/layers/support/ExportImageParameters.js +1 -1
  55. package/networks/UtilityNetwork.js +1 -1
  56. package/networks/support/typeUtils.js +1 -1
  57. package/package.json +3 -3
  58. package/portal/Portal.js +1 -1
  59. package/renderers/support/rasterRendererHelper.js +1 -1
  60. package/renderers/support/utils.js +1 -1
  61. package/rest/featureService/FeatureService.js +1 -1
  62. package/rest/networks/support/Circuit.js +5 -0
  63. package/rest/networks/support/CircuitSection.js +1 -1
  64. package/rest/networks/support/Subcircuit.js +1 -1
  65. package/rest/print.js +1 -1
  66. package/support/revision.js +1 -1
  67. package/symbols/cim/CIMEffects.js +1 -1
  68. package/symbols/cim/effects/EffectOffset.js +1 -1
  69. package/views/2d/analysisViewModuleImportUtils.js +5 -0
  70. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  71. package/views/2d/input/MapViewInputManager.js +1 -1
  72. package/views/2d/layers/LayerView2D.js +1 -1
  73. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  74. package/views/3d/analysis/ElevationProfile/HoveredPointsVisualization.js +1 -1
  75. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  76. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  77. package/views/3d/analysisViewModuleImportUtils.js +5 -0
  78. package/views/3d/input/SceneInputManager.js +1 -1
  79. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  80. package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
  81. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  82. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  83. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  84. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  85. package/views/3d/terrain/TerrainSurface.js +1 -1
  86. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  87. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  88. package/views/SceneView.js +1 -1
  89. package/views/ToolViewManager.js +1 -1
  90. package/views/View.js +1 -1
  91. package/views/View2D.js +1 -1
  92. package/views/draw/Draw.js +1 -1
  93. package/views/draw/DrawGraphicTool.js +1 -1
  94. package/views/draw/DrawOperation.js +1 -1
  95. package/views/draw/LegacyDrawManipulator.js +1 -1
  96. package/views/draw/support/Box.js +1 -1
  97. package/views/draw/support/GraphicMover.js +1 -1
  98. package/views/draw/support/Reshape.js +1 -1
  99. package/views/input/InputManager.js +1 -1
  100. package/views/input/handlers/LatestPointer.js +1 -1
  101. package/views/interactive/InteractiveToolBase.js +1 -1
  102. package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
  103. package/views/interactive/Tooltip.js +1 -1
  104. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  105. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  106. package/views/layers/support/popupUtils.js +1 -1
  107. package/views/support/AnalysisViewManager.js +5 -0
  108. package/views/support/PromiseQueue.js +5 -0
  109. package/views/support/Scheduler.js +1 -1
  110. package/widgets/Feature/FeatureViewModel.js +1 -1
  111. package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
  112. package/widgets/FloorFilter/css.js +1 -1
  113. package/widgets/FloorFilter.js +1 -1
  114. package/widgets/HistogramRangeSlider.js +1 -1
  115. package/widgets/Sketch/SketchViewModel.js +1 -1
  116. package/widgets/support/ItemList.js +1 -1
  117. package/assets/esri/core/workers/chunks/0874b88d5ae7c2b78b3b.js +0 -1
  118. package/assets/esri/core/workers/chunks/0c129b78e5cfe96795e1.js +0 -1
  119. package/assets/esri/core/workers/chunks/1a3a4c2c642899be37a0.js +0 -1
  120. package/assets/esri/core/workers/chunks/2b75212c31145cc07d16.js +0 -1
  121. package/assets/esri/core/workers/chunks/37a97e690786814bf0b3.js +0 -1
  122. package/assets/esri/core/workers/chunks/48e64f99720907017778.js +0 -1
  123. package/assets/esri/core/workers/chunks/4c6862ad3af947c704f7.js +0 -1
  124. package/assets/esri/core/workers/chunks/4d544e3e19ce07c2c195.js +0 -1
  125. package/assets/esri/core/workers/chunks/781b59ba0cabe78bc122.js +0 -1
  126. package/assets/esri/core/workers/chunks/8c1bd9bcfc59497de3b5.js +0 -1
  127. package/assets/esri/core/workers/chunks/8cc700da2ac58849a708.js +0 -1
  128. package/assets/esri/core/workers/chunks/9b7fee0adffeee8d45ae.js +0 -1
  129. package/assets/esri/core/workers/chunks/9d30fed26e0d84ef893b.js +0 -1
  130. package/assets/esri/core/workers/chunks/b29f0b32787edb4e75cf.js +0 -1
  131. package/assets/esri/core/workers/chunks/b877142a275188a16e17.js +0 -1
  132. package/assets/esri/core/workers/chunks/c87bb42f825c39f9cce3.js +0 -1
  133. package/assets/esri/core/workers/chunks/cc0cb4906e4419f7c4a9.js +0 -1
  134. package/assets/esri/core/workers/chunks/f667096ea325f690c4a6.js +0 -1
  135. package/assets/esri/core/workers/chunks/f9f94b5efa9a64cdb407.js +0 -1
  136. package/layers/graphics/data/executeQueryForSnapping.js +0 -5
  137. package/layers/support/PromiseQueue.js +0 -5
  138. package/views/3d/analysis/AnalysisViewManager3D.js +0 -5
  139. /package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js.LICENSE.txt → 659f7e99b2d524ef53fb.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../core/Collection.js";import t from"../core/CollectionFlattener.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{watch as i,sync as l}from"../core/reactiveUtils.js";import{getFilename as a}from"../core/urlUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as p}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{writer as y}from"../core/accessorSupport/decorators/writer.js";import m from"../geometry/Extent.js";import c from"../geometry/SpatialReference.js";import d from"./Layer.js";import{BlendLayer as h}from"./mixins/BlendLayer.js";import{OperationalLayer as f}from"./mixins/OperationalLayer.js";import{PortalLayer as b}from"./mixins/PortalLayer.js";import{RefreshableLayer as v}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as g}from"./mixins/ScaleRangeLayer.js";import{url as j}from"./support/commonProperties.js";import S from"./support/KMLSublayer.js";import{sublayersFromJSON as x,fetchService as L,parseKML as E}from"./support/kmlUtils.js";const w=["kml","xml"];let F=class extends(h(v(g(f(b(o(d))))))){constructor(...e){super(...e),this._visibleFolders=[],this.allSublayers=new t({getCollections:()=>[this.sublayers],getChildrenFunction:e=>e.sublayers}),this.outSpatialReference=c.WGS84,this.path=null,this.legendEnabled=!1,this.operationalLayerType="KML",this.sublayers=null,this.type="kml",this.url=null}initialize(){this.addHandles([i(()=>this.sublayers,(e,r)=>{r&&r.forEach(e=>{e.parent=null,e.layer=null}),e&&e.forEach(e=>{e.parent=this,e.layer=this})},l),this.on("sublayer-update",()=>this.notifyChange("fullExtent"))])}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}readSublayersFromItemOrWebMap(e,r){this._visibleFolders=r.visibleFolders}readSublayers(e,r,t){return x(S,r,t,this._visibleFolders)}writeSublayers(e,r){const t=[],o=e.toArray();for(;o.length;){const e=o[0];e.networkLink||(e.visible&&t.push(e.id),e.sublayers&&o.push(...e.sublayers.toArray())),o.shift()}r.visibleFolders=t}get title(){const e=this._get("title");return e&&"defaults"!==this.originOf("title")?e:this.url?a(this.url,w)||"KML":e}set title(e){this._set("title",e)}get visibleSublayers(){const e=this.sublayers,r=[],t=e=>{e.visible&&(r.push(e),e.sublayers&&e.sublayers.forEach(t))};return e&&e.forEach(t),r}get fullExtent(){return this._recomputeFullExtent()}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["KML"],supportsData:!1},e).catch(s).then(()=>this._fetchService(r))),Promise.resolve(this)}destroy(){super.destroy(),this.allSublayers.destroy()}async _fetchService(e){const r=await Promise.resolve().then(()=>this.resourceInfo?{ssl:!1,data:this.resourceInfo}:L(this.url??"",this.outSpatialReference,this.refreshInterval,e)),t=E(r.data);t&&this.read(t,{origin:"service"})}_recomputeFullExtent(){let e=null;null!=this.extent&&(e=this.extent.clone());const r=t=>{if(t.sublayers)for(const o of t.sublayers.items)r(o),o.visible&&o.fullExtent&&(null!=e?e.union(o.fullExtent):e=o.fullExtent.clone())};return r(this),e}};e([n({readOnly:!0})],F.prototype,"allSublayers",void 0),e([n({type:c})],F.prototype,"outSpatialReference",void 0),e([n({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],F.prototype,"path",void 0),e([n({readOnly:!0,json:{read:!1,write:!1}})],F.prototype,"legendEnabled",void 0),e([n({type:["show","hide","hide-children"]})],F.prototype,"listMode",void 0),e([n({type:["KML"]})],F.prototype,"operationalLayerType",void 0),e([n({})],F.prototype,"resourceInfo",void 0),e([n({type:r.ofType(S),json:{write:{ignoreOrigin:!0}}})],F.prototype,"sublayers",void 0),e([p(["web-map","portal-item"],"sublayers",["visibleFolders"])],F.prototype,"readSublayersFromItemOrWebMap",null),e([p("service","sublayers",["sublayers"])],F.prototype,"readSublayers",null),e([y("sublayers")],F.prototype,"writeSublayers",null),e([n({readOnly:!0,json:{read:!1}})],F.prototype,"type",void 0),e([n({json:{origins:{"web-map":{read:{source:"title"}}},write:{ignoreOrigin:!0}}})],F.prototype,"title",null),e([n(j)],F.prototype,"url",void 0),e([n({readOnly:!0})],F.prototype,"visibleSublayers",null),e([n({type:m})],F.prototype,"extent",void 0),e([n()],F.prototype,"fullExtent",null),F=e([u("esri.layers.KMLLayer")],F);const O=F;export{O as default};
5
+ import{__decorate as e}from"tslib";import r from"../core/Collection.js";import t from"../core/CollectionFlattener.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{watch as i,sync as l}from"../core/reactiveUtils.js";import{getFilename as a}from"../core/urlUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as p}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{writer as y}from"../core/accessorSupport/decorators/writer.js";import m from"../geometry/Extent.js";import c from"../geometry/SpatialReference.js";import d from"./Layer.js";import{BlendLayer as h}from"./mixins/BlendLayer.js";import{OperationalLayer as f}from"./mixins/OperationalLayer.js";import{PortalLayer as b}from"./mixins/PortalLayer.js";import{RefreshableLayer as v}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as g}from"./mixins/ScaleRangeLayer.js";import{url as j}from"./support/commonProperties.js";import S from"./support/KMLSublayer.js";import{sublayersFromJSON as x,fetchService as L,parseKML as E}from"./support/kmlUtils.js";const w=["kml","xml"];let F=class extends(h(v(g(f(b(o(d))))))){constructor(...e){super(...e),this._visibleFolders=[],this.allSublayers=new t({getCollections:()=>[this.sublayers],getChildrenFunction:e=>e.sublayers}),this.outSpatialReference=c.WGS84,this.path=null,this.legendEnabled=!1,this.operationalLayerType="KML",this.sublayers=null,this.type="kml",this.url=null}initialize(){this.addHandles([i(()=>this.sublayers,(e,r)=>{r&&r.forEach(e=>{e.parent=null,e.layer=null}),e&&e.forEach(e=>{e.parent=this,e.layer=this})},l),this.on("sublayer-update",()=>this.notifyChange("fullExtent"))])}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}readSublayersFromItemOrWebMap(e,r){this._visibleFolders=r.visibleFolders}readSublayers(e,r,t){return x(S,r,t,this._visibleFolders)}writeSublayers(e,r){const t=[],o=e.toArray();for(;o.length;){const e=o[0];e.networkLink||(e.visible&&t.push(e.id),e.sublayers&&o.push(...e.sublayers.toArray())),o.shift()}r.visibleFolders=t}get title(){const e=this._get("title");return e&&"defaults"!==this.originOf("title")?e:this.url?a(this.url,w)||"KML":e}set title(e){this._set("title",e)}get visibleSublayers(){const e=this.sublayers,r=[],t=e=>{e.visible&&(r.push(e),e.sublayers&&e.sublayers.forEach(t))};return e?.forEach(t),r}get fullExtent(){return this._recomputeFullExtent()}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["KML"],supportsData:!1},e).catch(s).then(()=>this._fetchService(r))),Promise.resolve(this)}destroy(){super.destroy(),this.allSublayers.destroy()}async _fetchService(e){const r=await Promise.resolve().then(()=>this.resourceInfo?{ssl:!1,data:this.resourceInfo}:L(this.url??"",this.outSpatialReference,this.refreshInterval,e)),t=E(r.data);t&&this.read(t,{origin:"service"})}_recomputeFullExtent(){let e=null;null!=this.extent&&(e=this.extent.clone());const r=t=>{if(t.sublayers)for(const o of t.sublayers.items)r(o),o.visible&&o.fullExtent&&(null!=e?e.union(o.fullExtent):e=o.fullExtent.clone())};return r(this),e}};e([n({readOnly:!0})],F.prototype,"allSublayers",void 0),e([n({type:c})],F.prototype,"outSpatialReference",void 0),e([n({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],F.prototype,"path",void 0),e([n({readOnly:!0,json:{read:!1,write:!1}})],F.prototype,"legendEnabled",void 0),e([n({type:["show","hide","hide-children"]})],F.prototype,"listMode",void 0),e([n({type:["KML"]})],F.prototype,"operationalLayerType",void 0),e([n({})],F.prototype,"resourceInfo",void 0),e([n({type:r.ofType(S),json:{write:{ignoreOrigin:!0}}})],F.prototype,"sublayers",void 0),e([p(["web-map","portal-item"],"sublayers",["visibleFolders"])],F.prototype,"readSublayersFromItemOrWebMap",null),e([p("service","sublayers",["sublayers"])],F.prototype,"readSublayers",null),e([y("sublayers")],F.prototype,"writeSublayers",null),e([n({readOnly:!0,json:{read:!1}})],F.prototype,"type",void 0),e([n({json:{origins:{"web-map":{read:{source:"title"}}},write:{ignoreOrigin:!0}}})],F.prototype,"title",null),e([n(j)],F.prototype,"url",void 0),e([n({readOnly:!0})],F.prototype,"visibleSublayers",null),e([n({type:m})],F.prototype,"extent",void 0),e([n()],F.prototype,"fullExtent",null),F=e([u("esri.layers.KMLLayer")],F);const O=F;export{O as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import has from"../../../core/has.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import r from"../../../core/PooledArray.js";import{EsriPromiseMixin as a}from"../../../core/Promise.js";import{isAbortError as d}from"../../../core/promiseUtils.js";import{watch as o,initial as n,sync as l}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as _}from"../../../geometry/projection/projectBoundingRect.js";import{create as c}from"../../../geometry/support/aaBoundingRect.js";import{PromiseQueue as p}from"../../support/PromiseQueue.js";import{viewingModeFromString as g}from"../../../views/ViewingMode.js";import{I3SClientNodeLoader as m}from"../../../views/3d/layers/i3s/I3SClientNodeLoader.js";import{addCallback as y}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as x}from"../../../views/3d/layers/i3s/I3SIndex.js";import f from"../../../views/3d/layers/i3s/I3SLodHandling.js";import N from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as b}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as w,getIndexCrs as v,findIntersectingNodes as C}from"../../../views/3d/layers/i3s/I3SUtil.js";import L from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{maxDownloadSlots as D}from"../../../views/3d/support/downloadSlots.js";import{toBoundingRect as V}from"../../../views/3d/support/extentUtils.js";import{minQuality as A}from"../../../views/3d/support/MemoryController.js";import{noBudget as I}from"../../../views/support/Scheduler.js";const S=100,M=2,F=1e4,O=1e-4,P=1.2,U=500,q=1.5;let G=class extends(a(t)){get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store?.lodType}get isGraphics3D(){return"points"===this.layer.profile}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(null==this.layer.priority||"High"===this.layer.priority)}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(2);return new b(e,this.layer.customParameters,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(3);return new b(e,this.layer.customParameters,this.layer.apiKey)}get crsVertex(){return w(this.layer)}get crsIndex(){return v(this.layer)}get layer(){return this.layerView.i3slayer}get running(){return this.updating}get rootNodeVisible(){if(this._index){const e=this._index.rootNode;if(e)return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}get requiredAttributes(){return this._requiredAttributes}constructor(e){super(e),this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.worker=null,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._idleStateCallbacks=null,this._newLoadingNodes=new r({deallocator:null}),this._modificationsNodeFilteringArray=new r,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._idleQueue=new p,this._elevationUpdateNodes=new r({deallocator:null}),this._errorCount=0}initialize(){const{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new f(e),this._defaultGeometrySchema=t.store.defaultGeometrySchema,this.disableIDBCache=!!has("disable-feature:idb-cache"),"fields"in t&&(this._fields=t.fields,this._attributeStorageInfo=t.attributeStorageInfo),this.addResolvingPromise(Promise.all([t.indexInfo,t.when(),e.when()]).then(([s])=>{if(this.destroyed||!e||e.destroyed||!s)return;const{view:r,clientGeometry:a}=e,{resourceController:d}=r;if(this._setClippingArea(r.clippingArea),this.addHandles([o(()=>r?.pointsOfInterest?.focus?.renderLocation,e=>this._pointOfInterestChanged(e),n),o(()=>r.quality,()=>this._setCameraDirty(),l),o(()=>e.contentVisible,e=>{const t=e?()=>this._updateIdleState(!0):()=>this._updateViewData(),i=e?()=>this._updateIdleState(!1):()=>{};e&&null!=this._index&&this._index.invalidateAllElevationRanges(),this._idleStateCallbacks?(e||this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=d.scheduler.registerIdleStateCallbacks(t,i)},n),y(e.view.resourceController.scheduler,this),o(()=>[this.featureTarget,this.fixedFeatureTarget],()=>{this._setCameraDirty(),this._stableFeatureLOD=!1}),o(()=>r.state?.contentCamera,()=>this._setCameraDirty()),o(()=>t.elevationInfo,e=>this._elevationInfoChanged(e)),o(()=>e.lodFactor,()=>this._setCameraDirty()),o(()=>e.availableFields,()=>this._requiredFieldsChange()),o(()=>e.holeFilling,e=>null!=this._index&&(this._index.holeFilling=e))]),this._viewportQueries=new L(this.crsIndex,r.renderCoordsHelper,r.state.contentCamera,!r.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?r.basemapTerrain:r.elevationProvider,g(r.viewingMode),this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._clientNodeLoader=new m(this.layer.uid,{indexSR:this.crsIndex,vertexSR:this.crsVertex,renderSR:r.renderCoordsHelper.spatialReference},r.resourceController.memoryController,this.worker),this._index=new x(g(r.viewingMode),t,s,this.indexStreamController,this._clientNodeLoader,this._viewportQueries,i.getLogger(this),e.holeFilling,t=>e.isNodeLoaded(t),t=>e.isNodeReloading(t),e=>this._shouldLoadNode(e),e=>this._enableFromGPUCache(e,1),e=>this._needsUpdate(e),()=>!this.indexStreamController.busy,t=>e.computeVisibilityObb?.(t)??null,e?.computeNodeFiltering?t=>e.computeNodeFiltering(t):void 0),this._index.updateElevationInfo(this.layer.elevationInfo,this.isMeshPyramid||this.isGraphics3D),this._index.imModificationsChanged(!!e.hasModifications),this._index.layerFilterChanged(!!e.hasGeometryFilter),null!=a){for(const e of a)this._addMesh(e.mesh,e.oid);this.addHandles(a.on("change",e=>{for(const t of e.removed)this._removeMesh(t.oid);for(const t of e.added)this._addMesh(t.mesh,t.oid)}))}this._startNodeLoading()}))}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;null!=t&&i?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll(e=>{const i=t.getNode(e);null!=i&&this._modificationsNodeFilteringArray.push(i)}),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._nodeLoader=null,Q.prune(),this._newLoadingNodes.prune(),this._modificationsNodeFilteringArray.prune(),this._elevationUpdateNodes.prune(),this._index=null,this._lodHandling=s(this._lodHandling),this._nodeLoader=null,this._clientNodeLoader=null,this._viewportQueries=null,this._set("worker",null)}get viewportQueries(){return this._viewportQueries}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map(i=>{const s=k(e,i),r=k(t,i);return s>=0&&r>=0?{index:s,name:t[r].name,field:t[r],attributeStorageInfo:e[s]}:null}).filter(e=>null!=e&&e.name!==i)}_requiredFieldsChange(){const e=this._getRequiredAttributes();j(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=c();V(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){null!=this._viewportQueries&&(this._viewportQueries.setPointOfInterest(e),null!=this._index&&(this._index.progressiveLoadPenalty=T.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),null!=this._viewportQueries&&null!=this._index&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}_addMesh(e,t){if(null==this._index)return;const i=this._clientNodeLoader.createMeshNodeInfo(e,t),s=this._index.addClientNodeToIndex(i.id,i.mbs);this._clientNodeLoader.addMeshNode(s,i),this._evaluateUpdating(),this.notifyChange("rootNodeVisible")}_removeMesh(e){const t=this._clientNodeLoader.getMeshNodeIndex(e);if(null!=t){if(null==this._index)throw new Error("delayed removal of client side i3s node geometry not supported yet.");{const e=(e,t)=>{this.layerView.removeNode(t),this._clientNodeLoader.removeNode(e),this.layerView.deleteCachedNodeData&&null!=e&&this.layerView.deleteCachedNodeData(e),this.layerView.deleteCachedGPUData?.(this.layerView.loadCachedGPUData?.(t))},i=(e,t,i)=>{this._clientNodeLoader.updateNodeIndex(e,t,i),this.layerView.updateNodeIndex&&this.layerView.updateNodeIndex(t,i)};this._index.removeClientNodeFromIndex(t,e,i),this.notifyChange("rootNodeVisible")}}}updateElevationChanged(e,t){const i=this._index;if(null==i?.rootNode||null==t)return null;this.crsIndex.equals(t)||(_(e,t,R,this.crsIndex),e=R);const s=this._elevationUpdateNodes;return s.clear(),C(e,i.rootNode,i,e=>s.push(e.index)),s.length&&(s.forAll(e=>i.updateElevationChanged(e)),this._setCameraDirty()),s}removeAllGeometryObbs(){null!=this._index&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return null!=this._viewportQueries?this._viewportQueries.getServiceMbsInRenderSR(e):null}_elevationInfoChanged(e){null!=this._index&&(this._index.updateElevationInfo(e,this.isMeshPyramid||this.isGraphics3D),this._setCameraDirty())}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get unloadedMemoryEstimate(){return null!=this._index&&this.layerView.contentVisible?this._index.unloadedMemoryEstimate*this._lodDropFactor:0}async _loadNodeData(e,t){return e.index<0?this._clientNodeLoader.loadNodeData(e.id,t):this._nodeLoader.loadNodeData(e,t)}async _loadAttributes(e,t,i){return(e.index<0?this._clientNodeLoader:this._nodeLoader).loadAttributes(e,t,i)}get indexDepth(){return null!=this._index?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData?this._disableMemCache=e:this._disableMemCache=!0}runTask(e,t){return this.layerView.contentVisible?this.layerView.visible&&null!=this._index?(this._processWithErrorLogging(e,t),this._index.maxPriority):-1/0:(this._updateViewData(),this._evaluateUpdating(),-1/0)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(s){this._errorCount<50?i.getLogger(this).error(`Error during processing: ${s} at ${s.stack}`):50===this._errorCount&&i.getLogger(this).error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),null!=this._nodeLoader&&null!=this._index&&(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this._isIntegratedMesh&&(e.enabled=!1),e.run(()=>this._processIndex(e)),this._updateFeatureLOD(),e.run(()=>this._processCache(e)),this._isIntegratedMesh&&(e.enabled=!0),e.run(()=>this._processNodes(e,t)),this._idleQueue.runTask(e),e.run(()=>this._prefetchIndex()),t.numIndexLoading+=this._index.indexLoading,t.numNodesLoading+=this._downloadingCount,e.run(()=>this._lodHandling.lodGlobalHandling(e)),this._evaluateUpdating())}_processIndex(e){if(null==this._index)return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update(Array.from(this._loadingNodes.keys()),e,e=>this.updateNodeModificationStatus(e)),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(null==this._index||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||null==this._index||null==this._viewportQueries)return;const e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.indexMissing>U){if(this._featureLOD<=O)return;this._featureLOD/=q,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=F||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this._lod,r=this._index.checkFeatureTarget(t,s);r!==s&&(this._featureLOD=r/this._baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*P||e&&i.estimate>t))return;if(this._featureLOD<=O)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(F,Math.max(O,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(null==t)return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);null!=s&&!this.layerView.isNodeLoaded(s.index);s=t.getParent(s.index))if(this._enableFromGPUCache(s,0)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(null==this._index)return!1;let i=(this._isIdle?S:M)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());null!=t&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const r=this._index.getNode(s.add.back());if(null==r||2!==r.cacheState&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(r),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach(e=>e.abort()),this._loadingNodes.clear(),this._updatingNodes.forEach(e=>e.abort()),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=M)&&(this._downloadingCount<D&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView){if(this.layerView.contentVisible){const i=(this._index?.indexMissing??0)+3*(this._index?.updates.add.length??0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.updating||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||null!=this._index&&this._index.isPrefetching),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}else e=this._cameraDirty,t=e?0:1;this.updating=e,this.updatingProgress=t}}_updateViewData(){if(!this._cameraDirty||null==this._index||null==this._viewportQueries)return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=T.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.quality<1?1:this.layerView.progressiveLoadFactor}get _lod(){return this._featureLOD*this._baseLOD}get _baseLOD(){const e=this.layerView.lodFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*this.layerView.view.quality}get _lodDropFactor(){if(this.fixedFeatureTarget)return 1;return(Math.min(this.layerView.view.quality,.5)-A)/(.5-A)}isGeometryVisible(e){return!!this._index?.isGeometryVisible(e.index)}updateVisibility(e){this._index?.invalidateNodeVisibilityCache(e)}invalidateGeometryVisibility(e){this._index?.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){this._index?.invalidateVisibilityObbs()}modificationsChanged(){this._index?.imModificationsChanged(!!this.layerView.hasModifications),this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e))&&!(null==this._index||!this._index.isGeometryVisible(e.index))}_shouldDropNode(e){if(null==this._viewportQueries)return!1;const t=this._lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||null==e||null==this._viewportQueries)return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new N(this.layer,this.dataStreamController,i.getLogger(this),this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e,t)=>this._removeNodes(e,t,1),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(null==t||null==this._viewportQueries)return!1;Q.clear(),this.layerView.getLoadedNodeIndices(Q);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return Q.filterInPlace(e=>{const i=t.getNode(e);return null==i||!t.isGeometryVisible(e)||s(i)}),Q.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(Q,e,0),!(i&&this._lodDropFactor<1)&&(0===Q.length||(Q.clear(),!1))}markNodeToRemove(e){Q.push(e)}removeMarkedNodes(){this._removeNodes(Q,I,0)}_removeNodes(e,t,i){if(0!==e.length&&!t.done)for(null!=this._index&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),r=this._index;1===i&&this.layerView.nodeFadeoutEnabled&&null!=r&&r.isGeometryVisible(s)?this.layerView.fadeNode(s,1,!0):this.layerView.removeNode(s),t.madeProgress()}}_needsUpdate(e){if(e.resources.isEmpty||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}async _updateLoadedNode(e){const t=new AbortController;this._updatingNodes.set(e.index,t),this._evaluateUpdating();try{const i=this.layerView.getLoadedAttributes(e.index),s=j(i,this._requiredAttributes)?this.layerView.getAttributeData(e.index):await this._loadAttributes(e,this._requiredAttributes,t.signal);await this.schedule(()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:s},t.signal),t.signal)}catch(i){if(!d(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)}this._updatingNodes.delete(e.index),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void i.getLogger(this).error("already loading node "+e.index);const t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).then(i=>{i&&null!=this._index&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())}).catch(e=>{if(!d(e))throw e}).finally(()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()})}_loadAndAddNode(e,t){return 1===e.cacheState?this._loadUncached(e,t).then(()=>!1):this._loadCached(e,t).then(t=>!t&&(e.cacheState=1,!0)).catch(t=>!d(t)&&(e.cacheState=1,!0))}_enableFromGPUCache(e,t){if(this._disableMemCache||null==this._index)return!1;if(0===t&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e.index);return null!=t?.attributeInfo&&j(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){null!=this._index&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateLoadStatus(e,t){const i=this._index;null!=i&&i.updateChildrenLoaded(e,t?1:-1)}async _loadCached(e,t){if(this._enableFromGPUCache(e,1))return!0;const i=this.layerView;if(this.disableIDBCache||!i.loadCachedNodeData||!i.addCachedNodeData)return!1;const s=(t,i)=>this._nodeLoader.loadTextures(e,t,i),r=(t,i)=>this._clientNodeLoader.loadTextures(e,t,i),a=e.index>=0?s:r,d=await this.schedule(()=>i.loadCachedNodeData(e,t,a),t);if(null==d)return!1;const o=this._requiredAttributes,n=await this.reschedule(()=>this._loadAttributes(e,o,t),t);return await this.reschedule(()=>i.addCachedNodeData(e,d,{loadedAttributes:o,attributeData:n},t),t),this._nodeAdded(),!0}_loadUncached(e,t){return this._downloadingCount++,this._loadNodeData(e,t).catch(e=>{throw this._downloadingCount--,e}).then(i=>(this._downloadingCount--,this.schedule(()=>this.layerView.addNode(e,i,t),t))).then(()=>{this._nodeAdded(),e.cacheState=2}).catch(t=>{if(!d(t))throw i.getLogger(this).error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,null!=this._index&&this._index.requestUpdate(),t})}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&null!=this._index&&this._index.resetFailedNodes())}get test(){}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),null!=this._index&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;null!=t&&t.layerFilterChanged(e),this._setCameraDirty()}};e([h({readOnly:!0})],G.prototype,"isMeshPyramid",null),e([h({readOnly:!0})],G.prototype,"isGraphics3D",null),e([h({readOnly:!0})],G.prototype,"useMaximumNumberOfFeatures",null),e([h({readOnly:!0})],G.prototype,"indexStreamController",null),e([h({readOnly:!0})],G.prototype,"dataStreamController",null),e([h({readOnly:!0})],G.prototype,"crsVertex",null),e([h({readOnly:!0})],G.prototype,"crsIndex",null),e([h()],G.prototype,"featureTarget",void 0),e([h()],G.prototype,"fixedFeatureTarget",void 0),e([h()],G.prototype,"layerView",void 0),e([h()],G.prototype,"layer",null),e([h()],G.prototype,"updating",void 0),e([h({readOnly:!0})],G.prototype,"running",null),e([h()],G.prototype,"updatingProgress",void 0),e([h({readOnly:!0})],G.prototype,"leavesReached",void 0),e([h({constructOnly:!0})],G.prototype,"worker",void 0),e([h({readOnly:!0,dependsOn:[]})],G.prototype,"rootNodeVisible",null),G=e([u("esri.layers.graphics.controllers.I3SOnDemandController")],G);const Q=new r({deallocator:null});function j(e,t){return null!=e&&e.length===t.length&&e.every(e=>k(t,e.name)>=0)}function k(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const T={distancePenalty:10},R=c();export{G as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import has from"../../../core/has.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import r from"../../../core/PooledArray.js";import{EsriPromiseMixin as a}from"../../../core/Promise.js";import{isAbortError as d}from"../../../core/promiseUtils.js";import{watch as o,initial as n,sync as l}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as _}from"../../../geometry/projection/projectBoundingRect.js";import{create as c}from"../../../geometry/support/aaBoundingRect.js";import{viewingModeFromString as p}from"../../../views/ViewingMode.js";import{I3SClientNodeLoader as g}from"../../../views/3d/layers/i3s/I3SClientNodeLoader.js";import{addCallback as m}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as y}from"../../../views/3d/layers/i3s/I3SIndex.js";import x from"../../../views/3d/layers/i3s/I3SLodHandling.js";import f from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as N}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as b,getIndexCrs as w,findIntersectingNodes as v}from"../../../views/3d/layers/i3s/I3SUtil.js";import C from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{maxDownloadSlots as L}from"../../../views/3d/support/downloadSlots.js";import{toBoundingRect as D}from"../../../views/3d/support/extentUtils.js";import{minQuality as V}from"../../../views/3d/support/MemoryController.js";import{PromiseQueue as A}from"../../../views/support/PromiseQueue.js";import{noBudget as I}from"../../../views/support/Scheduler.js";const S=100,M=2,F=1e4,O=1e-4,P=1.2,U=500,q=1.5;let G=class extends(a(t)){get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store?.lodType}get isGraphics3D(){return"points"===this.layer.profile}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(null==this.layer.priority||"High"===this.layer.priority)}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(2);return new N(e,this.layer.customParameters,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(3);return new N(e,this.layer.customParameters,this.layer.apiKey)}get crsVertex(){return b(this.layer)}get crsIndex(){return w(this.layer)}get layer(){return this.layerView.i3slayer}get running(){return this.updating}get rootNodeVisible(){if(this._index){const e=this._index.rootNode;if(e)return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}get requiredAttributes(){return this._requiredAttributes}constructor(e){super(e),this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.worker=null,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._idleStateCallbacks=null,this._newLoadingNodes=new r({deallocator:null}),this._modificationsNodeFilteringArray=new r,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._idleQueue=new A,this._elevationUpdateNodes=new r({deallocator:null}),this._errorCount=0}initialize(){const{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new x(e),this._defaultGeometrySchema=t.store.defaultGeometrySchema,this.disableIDBCache=!!has("disable-feature:idb-cache"),"fields"in t&&(this._fields=t.fields,this._attributeStorageInfo=t.attributeStorageInfo),this.addResolvingPromise(Promise.all([t.indexInfo,t.when(),e.when()]).then(([s])=>{if(this.destroyed||!e||e.destroyed||!s)return;const{view:r,clientGeometry:a}=e,{resourceController:d}=r;if(this._setClippingArea(r.clippingArea),this.addHandles([o(()=>r?.pointsOfInterest?.focus?.renderLocation,e=>this._pointOfInterestChanged(e),n),o(()=>r.quality,()=>this._setCameraDirty(),l),o(()=>e.contentVisible,e=>{const t=e?()=>this._updateIdleState(!0):()=>this._updateViewData(),i=e?()=>this._updateIdleState(!1):()=>{};e&&null!=this._index&&this._index.invalidateAllElevationRanges(),this._idleStateCallbacks?(e||this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=d.scheduler.registerIdleStateCallbacks(t,i)},n),m(e.view.resourceController.scheduler,this),o(()=>[this.featureTarget,this.fixedFeatureTarget],()=>{this._setCameraDirty(),this._stableFeatureLOD=!1}),o(()=>r.state?.contentCamera,()=>this._setCameraDirty()),o(()=>t.elevationInfo,e=>this._elevationInfoChanged(e)),o(()=>e.lodFactor,()=>this._setCameraDirty()),o(()=>e.availableFields,()=>this._requiredFieldsChange()),o(()=>e.holeFilling,e=>null!=this._index&&(this._index.holeFilling=e))]),this._viewportQueries=new C(this.crsIndex,r.renderCoordsHelper,r.state.contentCamera,!r.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?r.basemapTerrain:r.elevationProvider,p(r.viewingMode),this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._clientNodeLoader=new g(this.layer.uid,{indexSR:this.crsIndex,vertexSR:this.crsVertex,renderSR:r.renderCoordsHelper.spatialReference},r.resourceController.memoryController,this.worker),this._index=new y(p(r.viewingMode),t,s,this.indexStreamController,this._clientNodeLoader,this._viewportQueries,i.getLogger(this),e.holeFilling,t=>e.isNodeLoaded(t),t=>e.isNodeReloading(t),e=>this._shouldLoadNode(e),e=>this._enableFromGPUCache(e,1),e=>this._needsUpdate(e),()=>!this.indexStreamController.busy,t=>e.computeVisibilityObb?.(t)??null,e?.computeNodeFiltering?t=>e.computeNodeFiltering(t):void 0),this._index.updateElevationInfo(this.layer.elevationInfo,this.isMeshPyramid||this.isGraphics3D),this._index.imModificationsChanged(!!e.hasModifications),this._index.layerFilterChanged(!!e.hasGeometryFilter),null!=a){for(const e of a)this._addMesh(e.mesh,e.oid);this.addHandles(a.on("change",e=>{for(const t of e.removed)this._removeMesh(t.oid);for(const t of e.added)this._addMesh(t.mesh,t.oid)}))}this._startNodeLoading()}))}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;null!=t&&i?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll(e=>{const i=t.getNode(e);null!=i&&this._modificationsNodeFilteringArray.push(i)}),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._nodeLoader=null,Q.prune(),this._newLoadingNodes.prune(),this._modificationsNodeFilteringArray.prune(),this._elevationUpdateNodes.prune(),this._index=null,this._lodHandling=s(this._lodHandling),this._nodeLoader=null,this._clientNodeLoader=null,this._viewportQueries=null,this._set("worker",null)}get viewportQueries(){return this._viewportQueries}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map(i=>{const s=k(e,i),r=k(t,i);return s>=0&&r>=0?{index:s,name:t[r].name,field:t[r],attributeStorageInfo:e[s]}:null}).filter(e=>null!=e&&e.name!==i)}_requiredFieldsChange(){const e=this._getRequiredAttributes();j(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=c();D(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){null!=this._viewportQueries&&(this._viewportQueries.setPointOfInterest(e),null!=this._index&&(this._index.progressiveLoadPenalty=T.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),null!=this._viewportQueries&&null!=this._index&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}_addMesh(e,t){if(null==this._index)return;const i=this._clientNodeLoader.createMeshNodeInfo(e,t),s=this._index.addClientNodeToIndex(i.id,i.mbs);this._clientNodeLoader.addMeshNode(s,i),this._evaluateUpdating(),this.notifyChange("rootNodeVisible")}_removeMesh(e){const t=this._clientNodeLoader.getMeshNodeIndex(e);if(null!=t){if(null==this._index)throw new Error("delayed removal of client side i3s node geometry not supported yet.");{const e=(e,t)=>{this.layerView.removeNode(t),this._clientNodeLoader.removeNode(e),this.layerView.deleteCachedNodeData&&null!=e&&this.layerView.deleteCachedNodeData(e),this.layerView.deleteCachedGPUData?.(this.layerView.loadCachedGPUData?.(t))},i=(e,t,i)=>{this._clientNodeLoader.updateNodeIndex(e,t,i),this.layerView.updateNodeIndex&&this.layerView.updateNodeIndex(t,i)};this._index.removeClientNodeFromIndex(t,e,i),this.notifyChange("rootNodeVisible")}}}updateElevationChanged(e,t){const i=this._index;if(null==i?.rootNode||null==t)return null;this.crsIndex.equals(t)||(_(e,t,R,this.crsIndex),e=R);const s=this._elevationUpdateNodes;return s.clear(),v(e,i.rootNode,i,e=>s.push(e.index)),s.length&&(s.forAll(e=>i.updateElevationChanged(e)),this._setCameraDirty()),s}removeAllGeometryObbs(){null!=this._index&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return null!=this._viewportQueries?this._viewportQueries.getServiceMbsInRenderSR(e):null}_elevationInfoChanged(e){null!=this._index&&(this._index.updateElevationInfo(e,this.isMeshPyramid||this.isGraphics3D),this._setCameraDirty())}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get unloadedMemoryEstimate(){return null!=this._index&&this.layerView.contentVisible?this._index.unloadedMemoryEstimate*this._lodDropFactor:0}async _loadNodeData(e,t){return e.index<0?this._clientNodeLoader.loadNodeData(e.id,t):this._nodeLoader.loadNodeData(e,t)}async _loadAttributes(e,t,i){return(e.index<0?this._clientNodeLoader:this._nodeLoader).loadAttributes(e,t,i)}get indexDepth(){return null!=this._index?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData?this._disableMemCache=e:this._disableMemCache=!0}runTask(e,t){return this.layerView.contentVisible?this.layerView.visible&&null!=this._index?(this._processWithErrorLogging(e,t),this._index.maxPriority):-1/0:(this._updateViewData(),this._evaluateUpdating(),-1/0)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(s){this._errorCount<50?i.getLogger(this).error(`Error during processing: ${s} at ${s.stack}`):50===this._errorCount&&i.getLogger(this).error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),null!=this._nodeLoader&&null!=this._index&&(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this._isIntegratedMesh&&(e.enabled=!1),e.run(()=>this._processIndex(e)),this._updateFeatureLOD(),e.run(()=>this._processCache(e)),this._isIntegratedMesh&&(e.enabled=!0),e.run(()=>this._processNodes(e,t)),this._idleQueue.runTask(e),e.run(()=>this._prefetchIndex()),t.numIndexLoading+=this._index.indexLoading,t.numNodesLoading+=this._downloadingCount,e.run(()=>this._lodHandling.lodGlobalHandling(e)),this._evaluateUpdating())}_processIndex(e){if(null==this._index)return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update(Array.from(this._loadingNodes.keys()),e,e=>this.updateNodeModificationStatus(e)),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(null==this._index||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||null==this._index||null==this._viewportQueries)return;const e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.indexMissing>U){if(this._featureLOD<=O)return;this._featureLOD/=q,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=F||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this._lod,r=this._index.checkFeatureTarget(t,s);r!==s&&(this._featureLOD=r/this._baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*P||e&&i.estimate>t))return;if(this._featureLOD<=O)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(F,Math.max(O,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(null==t)return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);null!=s&&!this.layerView.isNodeLoaded(s.index);s=t.getParent(s.index))if(this._enableFromGPUCache(s,0)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(null==this._index)return!1;let i=(this._isIdle?S:M)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());null!=t&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const r=this._index.getNode(s.add.back());if(null==r||2!==r.cacheState&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(r),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach(e=>e.abort()),this._loadingNodes.clear(),this._updatingNodes.forEach(e=>e.abort()),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=M)&&(this._downloadingCount<L&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView){if(this.layerView.contentVisible){const i=(this._index?.indexMissing??0)+3*(this._index?.updates.add.length??0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.updating||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||null!=this._index&&this._index.isPrefetching),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}else e=this._cameraDirty,t=e?0:1;this.updating=e,this.updatingProgress=t}}_updateViewData(){if(!this._cameraDirty||null==this._index||null==this._viewportQueries)return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=T.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.quality<1?1:this.layerView.progressiveLoadFactor}get _lod(){return this._featureLOD*this._baseLOD}get _baseLOD(){const e=this.layerView.lodFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*this.layerView.view.quality}get _lodDropFactor(){if(this.fixedFeatureTarget)return 1;return(Math.min(this.layerView.view.quality,.5)-V)/(.5-V)}isGeometryVisible(e){return!!this._index?.isGeometryVisible(e.index)}updateVisibility(e){this._index?.invalidateNodeVisibilityCache(e)}invalidateGeometryVisibility(e){this._index?.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){this._index?.invalidateVisibilityObbs()}modificationsChanged(){this._index?.imModificationsChanged(!!this.layerView.hasModifications),this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e))&&!(null==this._index||!this._index.isGeometryVisible(e.index))}_shouldDropNode(e){if(null==this._viewportQueries)return!1;const t=this._lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||null==e||null==this._viewportQueries)return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new f(this.layer,this.dataStreamController,i.getLogger(this),this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e,t)=>this._removeNodes(e,t,1),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(null==t||null==this._viewportQueries)return!1;Q.clear(),this.layerView.getLoadedNodeIndices(Q);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return Q.filterInPlace(e=>{const i=t.getNode(e);return null==i||!t.isGeometryVisible(e)||s(i)}),Q.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(Q,e,0),!(i&&this._lodDropFactor<1)&&(0===Q.length||(Q.clear(),!1))}markNodeToRemove(e){Q.push(e)}removeMarkedNodes(){this._removeNodes(Q,I,0)}_removeNodes(e,t,i){if(0!==e.length&&!t.done)for(null!=this._index&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),r=this._index;1===i&&this.layerView.nodeFadeoutEnabled&&null!=r&&r.isGeometryVisible(s)?this.layerView.fadeNode(s,1,!0):this.layerView.removeNode(s),t.madeProgress()}}_needsUpdate(e){if(e.resources.isEmpty||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}async _updateLoadedNode(e){const t=new AbortController;this._updatingNodes.set(e.index,t),this._evaluateUpdating();try{const i=this.layerView.getLoadedAttributes(e.index),s=j(i,this._requiredAttributes)?this.layerView.getAttributeData(e.index):await this._loadAttributes(e,this._requiredAttributes,t.signal);await this.schedule(()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:s},t.signal),t.signal)}catch(i){if(!d(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)}this._updatingNodes.delete(e.index),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void i.getLogger(this).error("already loading node "+e.index);const t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).then(i=>{i&&null!=this._index&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())}).catch(e=>{if(!d(e))throw e}).finally(()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()})}_loadAndAddNode(e,t){return 1===e.cacheState?this._loadUncached(e,t).then(()=>!1):this._loadCached(e,t).then(t=>!t&&(e.cacheState=1,!0)).catch(t=>!d(t)&&(e.cacheState=1,!0))}_enableFromGPUCache(e,t){if(this._disableMemCache||null==this._index)return!1;if(0===t&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e.index);return null!=t?.attributeInfo&&j(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){null!=this._index&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateLoadStatus(e,t){const i=this._index;null!=i&&i.updateChildrenLoaded(e,t?1:-1)}async _loadCached(e,t){if(this._enableFromGPUCache(e,1))return!0;const i=this.layerView;if(this.disableIDBCache||!i.loadCachedNodeData||!i.addCachedNodeData)return!1;const s=(t,i)=>this._nodeLoader.loadTextures(e,t,i),r=(t,i)=>this._clientNodeLoader.loadTextures(e,t,i),a=e.index>=0?s:r,d=await this.schedule(()=>i.loadCachedNodeData(e,t,a),t);if(null==d)return!1;const o=this._requiredAttributes,n=await this.reschedule(()=>this._loadAttributes(e,o,t),t);return await this.reschedule(()=>i.addCachedNodeData(e,d,{loadedAttributes:o,attributeData:n},t),t),this._nodeAdded(),!0}_loadUncached(e,t){return this._downloadingCount++,this._loadNodeData(e,t).catch(e=>{throw this._downloadingCount--,e}).then(i=>(this._downloadingCount--,this.schedule(()=>this.layerView.addNode(e,i,t),t))).then(()=>{this._nodeAdded(),e.cacheState=2}).catch(t=>{if(!d(t))throw i.getLogger(this).error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,null!=this._index&&this._index.requestUpdate(),t})}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&null!=this._index&&this._index.resetFailedNodes())}get test(){}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),null!=this._index&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;null!=t&&t.layerFilterChanged(e),this._setCameraDirty()}};e([h({readOnly:!0})],G.prototype,"isMeshPyramid",null),e([h({readOnly:!0})],G.prototype,"isGraphics3D",null),e([h({readOnly:!0})],G.prototype,"useMaximumNumberOfFeatures",null),e([h({readOnly:!0})],G.prototype,"indexStreamController",null),e([h({readOnly:!0})],G.prototype,"dataStreamController",null),e([h({readOnly:!0})],G.prototype,"crsVertex",null),e([h({readOnly:!0})],G.prototype,"crsIndex",null),e([h()],G.prototype,"featureTarget",void 0),e([h()],G.prototype,"fixedFeatureTarget",void 0),e([h()],G.prototype,"layerView",void 0),e([h()],G.prototype,"layer",null),e([h()],G.prototype,"updating",void 0),e([h({readOnly:!0})],G.prototype,"running",null),e([h()],G.prototype,"updatingProgress",void 0),e([h({readOnly:!0})],G.prototype,"leavesReached",void 0),e([h({constructOnly:!0})],G.prototype,"worker",void 0),e([h({readOnly:!0,dependsOn:[]})],G.prototype,"rootNodeVisible",null),G=e([u("esri.layers.graphics.controllers.I3SOnDemandController")],G);const Q=new r({deallocator:null});function j(e,t){return null!=e&&e.length===t.length&&e.every(e=>k(t,e.name)>=0)}function k(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const T={distancePenalty:10},R=c();export{G as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{indexOf as e,PositionHint as t}from"../../../core/arrayUtils.js";import{toConst as s}from"../../../core/compilerUtils.js";import i from"../../../core/Error.js";import"../../../core/has.js";import{clone as r}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{signalFromSignalOrOptions as u,throwIfAborted as l}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as o}from"../../../core/unitUtils.js";import{isSerializable as h}from"../../../core/support/jsonUtils.js";import{getTransformation as c}from"../../../geometry/projectionUtils.js";import{set as m,negativeInfinity as f,create as d,expandWithAABB as y}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as p,create as g}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as x}from"../../../geometry/support/boundsUtils.js";import{isExtent as w,isPolygon as F}from"../../../geometry/support/jsonUtils.js";import{equals as _,isValid as S}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as R}from"../featureConversionUtils.js";import{getWhereClause as I}from"./attributeSupport.js";import{cleanFromGeometryEngine as Q,getGeometry as j}from"./geometryUtils.js";import{project as E,projectMany as b}from"./projectionSupport.js";import{QueryEngineCache as A}from"./QueryEngineCache.js";import{queryCapabilities as T}from"./QueryEngineCapabilities.js";import{QueryEngineResult as v}from"./QueryEngineResult.js";import{queryEngineEmptyResult as C,normalizeAttributeBinsQuery as P,normalizeQuery as M}from"./queryUtils.js";import{validateAttributeBinsQuery as z,validateQuery as G,validateStatisticsQuery as O}from"./queryValidationUtils.js";import{getSpatialQueryOperator as U,canQueryWithRBush as q}from"./spatialQuerySupport.js";import{getTimeExtent as k,getTimeOperator as B}from"./timeSupport.js";import Z from"../../support/FieldsIndex.js";import{noBudget as H}from"../../../views/support/Scheduler.js";const N="unsupported-query";class J{constructor(e,t=null,s,i,r){this.attributes=e,this.geometry=s,this.centroid=i,this.filterFlags=r,this.groupId=-1,this.displayId=t}}class L{constructor(e){this._changeHandle=null,this.capabilities={query:T},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._cache=e.cache??new A,this.timeInfo=e.timeInfo,this.featureIdInfo=e.featureIdInfo,"object-id"===e.featureIdInfo.type&&(this.objectIdField=e.featureIdInfo.fieldName),this._changeHandle=this.featureStore.events.on("changed",()=>this._clearCache()),this.fieldsIndex=h(e.fieldsIndex)?e.fieldsIndex:Z.fromJSON(e.fieldsIndex),!e.availableFields||1===e.availableFields.length&&"*"===e.availableFields[0]?this.availableFields=new Set(this.fieldsIndex.fields.map(e=>e.name)):this.availableFields=new Set(e.availableFields.map(e=>this.fieldsIndex.get(e)?.name).filter(e=>null!=e)),e.scheduler&&e.priority&&(this._frameTask=e.scheduler.registerTask(e.priority))}destroy(){this._changeHandle=a(this._changeHandle),this._frameTask=a(this._frameTask),this._clearCache(),n(this._cache)}get featureAdapter(){return this.featureStore.featureAdapter}_clearCache(){this._cache.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async executeQuery(e,t){const s=u(t);try{const t=await this._executeQuery(e,{},s);return await t.createQueryResponse()}catch(i){if(i!==C)throw i;return new v([],e,this).createQueryResponse()}}async executeQueryForCount(e={},t){const s=u(t);try{return(await this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null},s)).createQueryResponseForCount()}catch(i){if(i!==C)throw i;return 0}}async executeQueryForExtent(e,t){const s=u(t),i=e.outSR;try{const t=await this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null},s),r=t.size;if(!r)return{count:0,extent:null};return{count:r,extent:await this._getBounds(t.items,t.spatialReference,i||this.spatialReference)}}catch(r){if(r===C)return{count:0,extent:null};throw r}}async executeQueryForIds(e,t){return this.executeQueryForIdSet(e,t).then(e=>Array.from(e))}async executeQueryForIdSet(e,t){const s=u(t);try{const t=await this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null},s),i=t.items,r=new Set;return await this.reschedule(()=>{for(const e of i)r.add(t.featureAdapter.getObjectId(e))},s),r}catch(i){if(i===C)return new Set;throw i}}async executeQueryForLatestObservations(e,t){const s=u(t);if(!this.timeInfo?.trackIdField)throw new i(N,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});try{const t=await this._executeQuery(e,{},s);return await this.reschedule(()=>this._filterLatest(t),s),await t.createQueryResponse()}catch(r){if(r!==C)throw r;return new v([],e,this).createQueryResponse()}}async executeQueryForOpaqueFeatures(e,t){const s=u(t);return(await this._executeQuery(e,{},s)).items}async executeAttributeBinsQuery(e,t){const s=u(t);let i;e=r(e);try{e=await this.schedule(()=>P(e,this.definitionExpression,this.spatialReference),s),e=await this.reschedule(()=>z(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),s);const t=await this.reschedule(()=>this._executeSceneFilterQuery(e,s),s);i=await this.reschedule(()=>this._executeGeometryQuery(e,t,s),s),await this.reschedule(()=>this._executeAggregateIdsQuery(i),s),await this.reschedule(()=>this.executeObjectIdsQuery(i),s),await this.reschedule(()=>this.executeTimeQuery(i),s),await this.reschedule(()=>this.executeAttributesQuery(i),s)}catch(a){if(a!==C)throw a;i=new v([],e,this)}return i.createQueryBinsResponse(e)}async executeQueryForSummaryStatistics(e={},t,s){const i=u(s),{field:r,normalizationField:a,valueExpression:n}=t;return(await this._executeQueryForStatistics(e,{field:r,normalizationField:a,valueExpression:n},i)).createSummaryStatisticsResponse(t)}async executeQueryForUniqueValues(e={},t,s){const i=u(s),{field:r,field2:a,field3:n,valueExpression:l}=t;return(await this._executeQueryForStatistics(e,{field:r,field2:a,field3:n,valueExpression:l},i)).createUniqueValuesResponse(t)}async executeQueryForClassBreaks(e={},t,s){const i=u(s),{field:r,normalizationField:a,valueExpression:n}=t;return(await this._executeQueryForStatistics(e,{field:r,normalizationField:a,valueExpression:n},i)).createClassBreaksResponse(t)}async executeQueryForHistogram(e={},t,s){const i=u(s),{field:r,normalizationField:a,valueExpression:n}=t;return(await this._executeQueryForStatistics(e,{field:r,normalizationField:a,valueExpression:n},i)).createHistogramResponse(t)}async fetchRecomputedExtents(e){const t=u(e);this._timeExtentPromise||=k(this.timeInfo,this.featureStore);const[s,i]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return l(t),{fullExtent:s,timeExtent:i}}async _getBounds(e,t,s){const i=m(d(),f);return await this.featureStore.forEachBounds(e,e=>y(i,e)),D(i,t,s,this.spatialReference,this.hasZ)}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then(e=>this._getBounds(e,this.spatialReference,this.spatialReference)),this._fullExtentPromise}async schedule(e,t){return this._frameTask?.schedule(e,t)??e(H)}async reschedule(e,t){return this._frameTask?.reschedule(e,t)??e(H)}async _getAllFeaturesQueryEngineResult(e){return new v(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>await this.featureStore.forEach(t=>e.push(t)))().then(()=>s(e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async _executeQuery(e,t,s){e=r(e),e=await this.schedule(()=>M(e,this.definitionExpression,this.spatialReference),s),e=await this.reschedule(()=>G(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),s),e={...e,...t};const i=await this.reschedule(()=>this._executeSceneFilterQuery(e,s),s),a=await this.reschedule(()=>this._executeGeometryQuery(e,i,s),s);return await this.reschedule(()=>this._executeAggregateIdsQuery(a),s),await this.reschedule(()=>this.executeObjectIdsQuery(a),s),await this.reschedule(()=>this.executeTimeQuery(a),s),await this.reschedule(()=>this.executeAttributesQuery(a),s),a}async _executeSceneFilterQuery(e,t){if(null==e.sceneFilter)return null;const{outSR:s,returnGeometry:i,returnCentroid:r}=e,a=this.featureStore.featureSpatialReference,n=e.sceneFilter.geometry,u=null==a||_(a,n.spatialReference)?n:E(n,a);if(!u)return null;const l=i||r,o=S(s)&&!_(this.spatialReference,s)&&l?async e=>this._project(e,s):e=>e,h=this.featureAdapter,c=await this.reschedule(()=>this.searchFeatures(V(u)),t);if("disjoint"===e.sceneFilter.spatialRelationship){if(!c.length)return null;const s=new Set;for(const e of c)s.add(h.getObjectId(e));const i=await this.reschedule(()=>this._getAllFeatures(),t),r=await this.reschedule(async()=>{const r=await U("esriSpatialRelDisjoint",u,this.geometryType,this.hasZ,this.hasM),a=e=>!s.has(h.getObjectId(e))||r(h.getGeometry(e)),n=await this.runSpatialFilter(i,a,t);return new v(n,e,this)},t);return o(r)}if(!c.length)return new v([],e,this);if(this._canExecuteSinglePass(u,e))return o(new v(c,e,this));const m=await U("esriSpatialRelContains",u,this.geometryType,this.hasZ,this.hasM),f=await this.runSpatialFilter(c,e=>m(h.getGeometry(e)),t);return o(new v(f,e,this))}async _executeGeometryQuery(s,i,r){if(null!=i&&0===i.items.length)return i;const{geometry:a,outSR:n,returnGeometry:u,returnCentroid:l}=s,o=i?null:this._getCacheKey(s),h=o?this._cache.get(o):null;if(h)return new v(h,s,this);const c=S(n)&&!_(this.spatialReference,n),m=u||l,f=async e=>(c&&m&&await this._project(e,n),o&&this._cache.put(o,e.items),e),d=this.featureStore.featureSpatialReference,y=!a||null==d||_(d,a.spatialReference)?a:E(a,d);if(!y)return f(null!=i?i:await this._getAllFeaturesQueryEngineResult(s));const p=this.featureAdapter;let g=await this.reschedule(()=>this.searchFeatures(V(a)),r);const x=s.spatialRel??"esriSpatialRelIntersects";if("esriSpatialRelDisjoint"===x){if(!g.length)return f(null!=i?i:await this._getAllFeaturesQueryEngineResult(s));const e=new Set;for(const s of g)e.add(p.getObjectId(s));const t=null!=i?i.items:await this.reschedule(()=>this._getAllFeatures(),r),a=await this.reschedule(async()=>{const i=await U(x,y,this.geometryType,this.hasZ,this.hasM),a=t=>!e.has(p.getObjectId(t))||i(p.getGeometry(t)),n=await this.runSpatialFilter(t,a,r);return new v(n,s,this)},r);return f(a)}if(null!=i){const s=new t;g=g.filter(t=>e(i.items,t,i.items.length,s)>=0)}if(!g.length){const e=new v([],s,this);return o&&this._cache.put(o,e.items),e}if(this._canExecuteSinglePass(y,s))return f(new v(g,s,this));const w=await U(x,y,this.geometryType,this.hasZ,this.hasM),F=await this.runSpatialFilter(g,e=>w(p.getGeometry(e)),r);return f(new v(F,s,this))}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const i of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(i).forEach(e=>t.add(e))}const s=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(s(e)))}executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),s=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(s(e)))}executeTimeQuery(e){if(0===e.items.length)return;const t=B(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}executeAttributesQuery(e){if(0===e.items.length)return;const t=I(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter(e=>t.testFeature(e,this.featureAdapter))}}async runSpatialFilter(e,t,s){if(!t)return e;if(null==this._frameTask)return e.filter(e=>t(e));let i=0;const r=new Array,a=async n=>{for(;i<e.length;){const u=e[i++];t(u)&&(r.push(u),n.madeProgress()),n.done&&await this.reschedule(e=>a(e),s)}};return this.reschedule(e=>a(e),s).then(()=>r)}_filterLatest(e){const{trackIdField:t,startTimeField:s,endTimeField:i}=this.timeInfo,r=i||s,a=new Map,n=this.featureAdapter.getAttribute;for(const u of e.items){const e=n(u,t),s=n(u,r),i=a.get(e);(!i||s>n(i,r))&&a.set(e,u)}e.items=Array.from(a.values())}_getCacheKey(e){const{geometry:t,spatialRel:s,returnGeometry:i,returnCentroid:r,outSR:a,resultType:n,cacheHint:u}=e;if("tile"!==n&&!u)return null;const l=i||r;return S(a)&&!_(this.spatialReference,a)&&l?JSON.stringify([t,s,a]):JSON.stringify([t,s])}_canExecuteSinglePass(e,t){const{spatialRel:s}=t;return q(e)&&("esriSpatialRelEnvelopeIntersects"===s||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===s||"esriSpatialRelContains"===s))}async _project(e,t){if(!t||_(this.spatialReference,t))return e;const i=this.featureAdapter;let r;try{const e=await this._getFullExtent();r=c(this.spatialReference,t,e)}catch{}const a=await b(e.items.map(e=>j(this.geometryType,this.hasZ,this.hasM,i.getGeometry(e))),this.spatialReference,t,r);return e.items=s(a.map((t,s)=>i.cloneWithGeometry(e.items[s],R(t,this.hasZ,this.hasM)))),e}async searchFeatures(e){const t=new Set;await Promise.all(e.map(e=>this.featureStore.forEachInBounds(e,e=>t.add(e))));const s=Array.from(t.values());return t.clear(),s}async _executeQueryForStatistics(e,t,s){e=r(e);try{e=await this.schedule(()=>M(e,this.definitionExpression,this.spatialReference),s),e=await this.reschedule(()=>O(e,t,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),s);const i=await this.reschedule(()=>this._executeSceneFilterQuery(e,s),s),r=await this.reschedule(()=>this._executeGeometryQuery(e,i,s),s);return await this.reschedule(()=>this._executeAggregateIdsQuery(r),s),await this.reschedule(()=>this.executeObjectIdsQuery(r),s),await this.reschedule(()=>this.executeTimeQuery(r),s),await this.reschedule(()=>this.executeAttributesQuery(r),s),r}catch(i){if(i!==C)throw i;return new v([],e,this)}}get test(){}}function V(e){if(q(e)){if(w(e))return[p(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(F(e))return e.rings.map(e=>p(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1])))}return[x(g(),e)]}function D(e,t,s,i,r){const a={xmin:e[0],ymin:e[1],xmax:e[3],ymax:e[4],spatialReference:Q(i)};r&&isFinite(e[2])&&isFinite(e[5])&&(a.zmin=e[2],a.zmax=e[5],a.hasZ=!0);const n=E(a,t,s);if(n.spatialReference=Q(s),n.xmax-n.xmin===0){const e=o(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin===0){const e=o(n.spatialReference);n.ymin-=e,n.ymax+=e}if(r&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin===0){const e=o(n.spatialReference);n.zmin-=e,n.zmax+=e}return n}export{J as Feature,L as QueryEngine,V as getQueryBBoxes,D as getQueryResultExtent};
5
+ import{indexOf as e,PositionHint as t}from"../../../core/arrayUtils.js";import{toConst as i}from"../../../core/compilerUtils.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{clone as s}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{signalFromSignalOrOptions as l,throwIfAborted as o}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as u}from"../../../core/unitUtils.js";import{isSerializable as c}from"../../../core/support/jsonUtils.js";import{getTransformation as h}from"../../../geometry/projectionUtils.js";import{set as y,negativeInfinity as d,create as m,expandWithAABB as f}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as p,create as x}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../../geometry/support/boundsUtils.js";import{fromJSON as _,isExtent as F,isPolygon as w}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as Q}from"../../../geometry/support/normalizeUtils.js";import{equals as S,isValid as R}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as I}from"../featureConversionUtils.js";import{getWhereClause as j}from"./attributeSupport.js";import{cleanFromGeometryEngine as b,getGeometry as E}from"./geometryUtils.js";import{project as T,checkProjectionSupport as A,projectMany as v}from"./projectionSupport.js";import{QueryEngineCache as G}from"./QueryEngineCache.js";import{queryCapabilities as k}from"./QueryEngineCapabilities.js";import{QueryEngineResult as C}from"./QueryEngineResult.js";import{queryEngineEmptyResult as O,normalizeAttributeBinsQuery as M,normalizeQueryLike as P,normalizeQuery as q}from"./queryUtils.js";import{validateAttributeBinsQuery as z,validateQuery as U,validateStatisticsQuery as B}from"./queryValidationUtils.js";import{getSpatialQueryOperator as Z,canQueryWithRBush as H}from"./spatialQuerySupport.js";import{getTimeExtent as N,getTimeOperator as J}from"./timeSupport.js";import L from"../../support/FieldsIndex.js";import{ImmediateTask as V}from"../../../views/support/Scheduler.js";const D="unsupported-query";class K{constructor(e,t=null,i,r,s){this.attributes=e,this.geometry=i,this.centroid=r,this.filterFlags=s,this.groupId=-1,this.displayId=t}}class W{constructor(e){this._changeHandle=null,this.capabilities={query:k},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._cache=e.cache??new G,this.timeInfo=e.timeInfo,this.featureIdInfo=e.featureIdInfo,"object-id"===e.featureIdInfo.type&&(this.objectIdField=e.featureIdInfo.fieldName),this._changeHandle=this.featureStore.events.on("changed",()=>this._clearCache()),this.fieldsIndex=c(e.fieldsIndex)?e.fieldsIndex:L.fromJSON(e.fieldsIndex),!e.availableFields||1===e.availableFields.length&&"*"===e.availableFields[0]?this.availableFields=new Set(this.fieldsIndex.fields.map(e=>e.name)):this.availableFields=new Set(e.availableFields.map(e=>this.fieldsIndex.get(e)?.name).filter(e=>null!=e)),e.scheduler&&e.priority?this._frameTask=e.scheduler.registerTask(e.priority):this._frameTask=V}destroy(){this._changeHandle=a(this._changeHandle),this._frameTask=a(this._frameTask),this._clearCache(),n(this._cache)}get featureAdapter(){return this.featureStore.featureAdapter}async executeQuery(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryFeatureSet(e),i)}async executeQueryForCount(e={},t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForCount(e),i)}async executeQueryForExtent(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForExtent(e),i)}async executeQueryForIds(e,t){return Array.from(await this.executeQueryForIdSet(e,t))}async executeQueryForIdSet(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForIdSet(e),i)}async executeQueryForLatestObservations(e,t){const i=l(t);if(!this.timeInfo?.trackIdField)throw new r(D,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});return await this._frameTask.scheduleGenerator(()=>this._executeQueryForLatestObservations(e),i)}async executeQueryForOpaqueFeatures(e,t){const i=l(t);return(await this._frameTask.scheduleGenerator(()=>this._executeQuery(e,{}),i)).items}async executeAttributeBinsQuery(e,t){const i=l(t);return e=s(e),await this._frameTask.scheduleGenerator(()=>this._executeAttributeBinsQuery(e),i)}async executeQueryForSummaryStatistics(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSummaryStatistics(e,t),r)}async executeQueryForUniqueValues(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForUniqueValues(e,t),r)}async executeQueryForClassBreaks(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForClassBreaks(e,t),r)}async executeQueryForHistogram(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForHistogram(e,t),r)}async executeQueryForSnapping(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSnapping(e,i),i)}async fetchRecomputedExtents(e){const t=l(e);this._timeExtentPromise||=N(this.timeInfo,this.featureStore);const[i,r]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return o(t),{fullExtent:i,timeExtent:r}}_clearCache(){this._cache.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async*_executeQueryFeatureSet(e){try{const t=yield*this._executeQuery(e,{});return yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeQueryForCount(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null});return yield,t.createQueryResponseForCount()}catch(t){if(t!==O)throw t;return 0}}async*_executeQueryForExtent(e){const t=e.outSR;try{const i=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const r=i.size;if(!r)return{count:0,extent:null};const s=await this._getBounds(i.items,i.spatialReference,t??this.spatialReference);return yield,{count:r,extent:s}}catch(i){if(i===O)return{count:0,extent:null};throw i}}async*_executeQueryForIdSet(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const i=t.items,r=new Set;for(const e of i)r.add(t.featureAdapter.getObjectId(e));return r}catch(t){if(t===O)return new Set;throw t}}async*_executeQueryForLatestObservations(e){try{const t=yield*this._executeQuery(e,{});return yield,this._filterLatest(t),yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeAttributeBinsQuery(e){let t;try{e=await M(e,this.definitionExpression,this.spatialReference),yield,e=await z(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield,t=yield*this._executeGeometryQuery(e,i),yield,this._executeAggregateIdsQuery(t),yield,this._executeObjectIdsQuery(t),yield,this._executeTimeQuery(t),yield,this._executeAttributesQuery(t),yield}catch(i){if(i!==O)throw i;t=new C([],e,this)}return await t.createQueryBinsResponse(e)}async*_executeQueryForSummaryStatistics(e={},t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createSummaryStatisticsResponse(t)}async*_executeQueryForUniqueValues(e={},t){const{field:i,field2:r,field3:s,valueExpression:a}=t,n=yield*this._executeQueryForStatistics(e,{field:i,field2:r,field3:s,valueExpression:a});return yield,await n.createUniqueValuesResponse(t)}async*_executeQueryForClassBreaks(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createClassBreaksResponse(t)}async*_executeQueryForHistogram(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createHistogramResponse(t)}async*_executeQueryForSnapping(e,t){const{point:i,distance:r,returnEdge:a,vertexMode:n}=e;if(!a&&"none"===n)return{candidates:[]};let l=s(e.query);l=await P(l,this.definitionExpression,this.spatialReference),yield,l=await U(l,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const o=!S(i.spatialReference,this.spatialReference);o&&(await A(i.spatialReference,this.spatialReference),yield);const u="number"==typeof r?r:r.x,c="number"==typeof r?r:r.y,h={xmin:i.x-u,xmax:i.x+u,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},y=o?T(h,this.spatialReference):h;if(!y)return{candidates:[]};const d=(await Q(_(i),null,{signal:t}))[0];yield;const m=(await Q(_(y),null,{signal:t}))[0];if(yield,null==d||null==m)return{candidates:[]};const f=await this._searchFeatures(X(m.toJSON()));yield;const p=new C(f,l,this);this._executeObjectIdsQuery(p),yield,this._executeTimeQuery(p),yield,this._executeAttributesQuery(p),yield,yield*this._executeGeometryQueryForSnapping(p),yield;const x=d.toJSON(),g=o?T(x,this.spatialReference):x,F=o?Math.max(y.xmax-y.xmin,y.ymax-y.ymin)/2:r;return p.createSnappingResponse({...e,point:g,distance:F},l.returnZ,i.spatialReference)}async _getBounds(e,t,i){const r=y(m(),d);return await this.featureStore.forEachBounds(e,e=>f(r,e)),Y(r,t,i,this.spatialReference,this.hasZ)}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then(e=>this._getBounds(e,this.spatialReference,this.spatialReference)),this._fullExtentPromise}async _getAllFeaturesQueryEngineResult(e){return new C(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>await this.featureStore.forEach(t=>e.push(t)))().then(()=>i(e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async*_executeQuery(e,t){e=s(e),e=await q(e,this.definitionExpression,this.spatialReference),yield,e=await U(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield,e={...e,...t};const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),r}async*_executeSceneFilterQuery(e){if(null==e.sceneFilter)return null;const{outSR:t,returnGeometry:i,returnCentroid:r}=e,s=this.featureStore.featureSpatialReference,a=e.sceneFilter.geometry,n=null==s||S(s,a.spatialReference)?a:T(a,s);if(!n)return null;const l=i||r,o=R(t)&&!S(this.spatialReference,t)&&l?async e=>this._project(e,t):e=>e;yield;const u=this.featureAdapter,c=await this._searchFeatures(X(n));yield;if("disjoint"===e.sceneFilter.spatialRelationship){if(!c.length)return null;const t=new Set;for(const e of c)t.add(u.getObjectId(e));const i=await this._getAllFeatures();yield;const r=await Z("esriSpatialRelDisjoint",n,this.geometryType,this.hasZ,this.hasM);yield;const s=e=>!t.has(u.getObjectId(e))||r(u.getGeometry(e)),a=yield*this._runSpatialFilter(i,s);yield;const l=new C(a,e,this);return await o(l)}if(!c.length)return new C([],e,this);if(this._canExecuteSinglePass(n,e))return await o(new C(c,e,this));const h=await Z("esriSpatialRelContains",n,this.geometryType,this.hasZ,this.hasM);yield;const y=yield*this._runSpatialFilter(c,e=>h(u.getGeometry(e)));return yield,await o(new C(y,e,this))}async*_executeGeometryQuery(i,r){if(null!=r&&0===r.items.length)return r;const{geometry:s,outSR:a,returnGeometry:n,returnCentroid:l}=i,o=r?null:this._getCacheKey(i),u=o?this._cache.get(o):null;if(u)return new C(u,i,this);const c=R(a)&&!S(this.spatialReference,a),h=n||l,y=async e=>(c&&h&&await this._project(e,a),o&&this._cache.put(o,e.items),e),d=this.featureStore.featureSpatialReference,m=!s||null==d||S(d,s.spatialReference)?s:T(s,d);if(!m)return await y(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));yield;const f=this.featureAdapter;let p=await this._searchFeatures(X(s));yield;const x=i.spatialRel??"esriSpatialRelIntersects";if("esriSpatialRelDisjoint"===x){if(!p.length)return await y(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));const e=new Set;for(const i of p)e.add(f.getObjectId(i));let t;null!=r?t=r.items:(yield,t=await this._getAllFeatures(),yield);const s=await Z(x,m,this.geometryType,this.hasZ,this.hasM);yield;const a=t=>!e.has(f.getObjectId(t))||s(f.getGeometry(t)),n=yield*this._runSpatialFilter(t,a);yield;const l=new C(n,i,this);return await y(l)}if(null!=r){const i=new t;p=p.filter(t=>e(r.items,t,r.items.length,i)>=0)}if(!p.length){const e=new C([],i,this);return o&&this._cache.put(o,e.items),e}if(this._canExecuteSinglePass(m,i))return await y(new C(p,i,this));const g=await Z(x,m,this.geometryType,this.hasZ,this.hasM);yield;const _=yield*this._runSpatialFilter(p,e=>g(f.getGeometry(e)));return yield,await y(new C(_,i,this))}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const r of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(r).forEach(e=>t.add(e))}const i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeTimeQuery(e){if(0===e.items.length)return;const t=J(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}_executeAttributesQuery(e){if(0===e.items.length)return;const t=j(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter(e=>t.testFeature(e,this.featureAdapter))}}async*_executeGeometryQueryForSnapping(e){const{query:t}=e,{spatialRel:i}=t;if(!e?.items?.length||!t.geometry||!i)return;const r=await Z(i,t.geometry,this.geometryType,this.hasZ,this.hasM);yield;const s=this.featureAdapter,a=e=>r(s.getGeometry(e)),n=yield*this._runSpatialFilter(e.items,a);e.items=n}*_runSpatialFilter(e,t){if(!t)return e;if(null==this._frameTask)return e.filter(e=>t(e));let i=yield;const r=new Array;for(const s of e)t(s)&&r.push(s),i.madeProgress(),i.done&&(i=yield);return r}_filterLatest(e){const{trackIdField:t,startTimeField:i,endTimeField:r}=this.timeInfo,s=r||i,a=new Map,n=this.featureAdapter.getAttribute;for(const l of e.items){const e=n(l,t),i=n(l,s),r=a.get(e);(!r||i>n(r,s))&&a.set(e,l)}e.items=Array.from(a.values())}_getCacheKey(e){const{geometry:t,spatialRel:i,returnGeometry:r,returnCentroid:s,outSR:a,resultType:n,cacheHint:l}=e;if("tile"!==n&&!l)return null;const o=r||s;return R(a)&&!S(this.spatialReference,a)&&o?JSON.stringify([t,i,a]):JSON.stringify([t,i])}_canExecuteSinglePass(e,t){const{spatialRel:i}=t;return H(e)&&("esriSpatialRelEnvelopeIntersects"===i||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===i||"esriSpatialRelContains"===i))}async _project(e,t){if(!t||S(this.spatialReference,t))return e;const r=this.featureAdapter;let s;try{const e=await this._getFullExtent();s=h(this.spatialReference,t,e)}catch{}const a=await v(e.items.map(e=>E(this.geometryType,this.hasZ,this.hasM,r.getGeometry(e))),this.spatialReference,t,s);return e.items=i(a.map((t,i)=>r.cloneWithGeometry(e.items[i],I(t,this.hasZ,this.hasM)))),e}async _searchFeatures(e){const t=new Set;await Promise.all(e.map(e=>this.featureStore.forEachInBounds(e,e=>t.add(e))));const i=Array.from(t.values());return t.clear(),i}async*_executeQueryForStatistics(e,t){e=s(e);try{e=await q(e,this.definitionExpression,this.spatialReference),yield,e=await B(e,t,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),yield,r}catch(i){if(i!==O)throw i;return new C([],e,this)}}get test(){}}function X(e){if(H(e)){if(F(e))return[p(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(w(e))return e.rings.map(e=>p(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1])))}return[g(x(),e)]}function Y(e,t,i,r,s){const a={xmin:e[0],ymin:e[1],xmax:e[3],ymax:e[4],spatialReference:b(r)};s&&isFinite(e[2])&&isFinite(e[5])&&(a.zmin=e[2],a.zmax=e[5],a.hasZ=!0);const n=T(a,t,i);if(n.spatialReference=b(i),n.xmax-n.xmin===0){const e=u(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin===0){const e=u(n.spatialReference);n.ymin-=e,n.ymax+=e}if(s&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin===0){const e=u(n.spatialReference);n.zmin-=e,n.zmax+=e}return n}export{K as Feature,W as QueryEngine,Y as getQueryResultExtent};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{createTask as e}from"../../../core/asyncUtils.js";import t from"../../../core/Error.js";import r from"../../../core/Logger.js";import{clamp as a}from"../../../core/mathUtils.js";import{throwIfAborted as s,isAbortError as o}from"../../../core/promiseUtils.js";import n from"../../../core/Warning.js";import{equals as i}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as u,convertToGeometry as l}from"../featureConversionUtils.js";import{executeQueryForSnapping as c}from"../data/executeQueryForSnapping.js";import h from"../data/FeatureStore.js";import{checkProjectionSupport as m,project as p}from"../data/projectionSupport.js";import{QueryEngine as d}from"../data/QueryEngine.js";import{validateGeoJSON as f,createOptimizedFeatures as g}from"./geojson/geojson.js";import{mixAttributes as y}from"./support/sourceUtils.js";import{getGetFeatureSpatialReference as _,getFeatureCount as x,getFeature as C}from"../../ogc/wfsUtils.js";import w from"../../support/FieldsIndex.js";import{isNumber as R}from"../../../support/guards.js";import{utc as F}from"../../../time/constants.js";const S="esri.layers.WFSLayer";class j{constructor(){this._customParameters=null,this._queryEngine=null,this._supportsPagination=!0}destroy(){this._queryEngine?.destroy(),this._queryEngine=null}async load(e,r={}){const{getFeatureUrl:a,getFeatureOutputFormat:o,fields:n,geometryType:i,featureType:u,maxRecordCount:l,maxTotalRecordCount:c,maxPageCount:p,objectIdField:f,customParameters:g}=e,{spatialReference:y,getFeatureSpatialReference:x}=_(a,u,e.spatialReference);try{await m(x,y)}catch{throw new t("unsupported-projection","Projection not supported",{inSpatialReference:x,outSpatialReference:y})}s(r),this._customParameters=g,this._featureType=u,this._fieldsIndex=w.fromLayerJSON({fields:n,dateFieldsTimeReference:n.some(e=>"esriFieldTypeDate"===e.type)?{timeZoneIANA:F}:null}),this._geometryType=i,this._getFeatureUrl=a,this._getFeatureOutputFormat=o,this._getFeatureSpatialReference=x,this._maxRecordCount=l,this._maxTotalRecordCount=c,this._maxPageCount=p,this._objectIdField=f,this._spatialReference=y;let C=await this._snapshotFeatures(r);if(C.errors.length>0&&(this._supportsPagination=!1,C=await this._snapshotFeatures(r),C.errors.length>0))throw C.errors[0];const R={type:"object-id",fieldName:f};return this._queryEngine=new d({fieldsIndex:this._fieldsIndex,geometryType:i,hasM:!1,hasZ:!1,featureIdInfo:R,spatialReference:y,timeInfo:null,featureStore:new h({geometryType:i,hasM:!1,hasZ:!1})}),this._queryEngine.featureStore.addMany(C.features),{warnings:q(C),extent:(await this._queryEngine.fetchRecomputedExtents()).fullExtent}}async applyEdits(){throw new t("wfs-source:editing-not-supported","applyEdits() is not supported on WFSLayer")}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(R)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),c(this._queryEngine,e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(t){return this._customParameters=t.customParameters,this._maxRecordCount=t.maxRecordCount,this._maxTotalRecordCount=t.maxTotalRecordCount,this._maxPageCount=t.maxPageCount,this._snapshotTask?.abort(),this._snapshotTask=e(e=>this._snapshotFeatures({signal:e})),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._queryEngine.featureStore.addMany(e.features);for(const t of q(e))r.getLogger(S).warn(new n("wfs-layer:refresh-warning",t.message,t.details));e.errors?.length&&r.getLogger(S).warn(new n("wfs-layer:refresh-error","Refresh completed with errors",{errors:e.errors}))},()=>{this._queryEngine.featureStore.clear()}),await this._waitSnapshotComplete(),{extent:(await this._queryEngine.fetchRecomputedExtents()).fullExtent}}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _snapshotFeatures(e){const t=e?.signal,r=this._maxTotalRecordCount,n=this._maxPageCount,i=this._supportsPagination&&n>1?await x(this._getFeatureUrl,this._featureType.typeName,{customParameters:this._customParameters,signal:t}):void 0;let u=[];const l=[];if(null==i)try{u=await this._singleQuery(t)}catch(c){o(c)||l.push(c)}else{const e=Math.min(i,r),s=T(this,a(Math.ceil(e/this._maxRecordCount),1,n),t);await Promise.allSettled(Array.from({length:10}).map(()=>E(s,u,l)))}return s(t),{features:u,totalRecordCount:i,maxTotalRecordCount:r,maxPageCount:n,errors:l}}async _singleQuery(e){const t=Number.isFinite(this._maxRecordCount)&&this._maxRecordCount>0?this._maxRecordCount:void 0,r=await C(this._getFeatureUrl,this._featureType.typeName,this._getFeatureSpatialReference,this._getFeatureOutputFormat,{customParameters:this._customParameters,count:t,signal:e});return this._processGeoJSON(r,{signal:e})}async _pageQuery(e,t){const r=e*this._maxRecordCount,a=await C(this._getFeatureUrl,this._featureType.typeName,this._getFeatureSpatialReference,this._getFeatureOutputFormat,{customParameters:this._customParameters,startIndex:r,count:this._maxRecordCount,signal:t});return this._processGeoJSON(a,{startIndex:r,signal:t})}_processGeoJSON(e,t){f(e,this._getFeatureSpatialReference.wkid);const{startIndex:r,signal:a}=t;s(a);const o=g(e,{geometryType:this._geometryType,hasZ:!1,objectIdField:this._objectIdField});if(!i(this._spatialReference,this._getFeatureSpatialReference))for(const s of o)null!=s.geometry&&(s.geometry=u(p(l(s.geometry,this._geometryType,!1,!1),this._getFeatureSpatialReference,this._spatialReference)));let n=r??1;for(const s of o){const e={};y(this._fieldsIndex,e,s.attributes,!0),s.attributes=e,null==e[this._objectIdField]&&(s.objectId=e[this._objectIdField]=n++)}return o}}function*T(e,t,r){for(let a=0;a<t;a++)yield e._pageQuery(a,r)}async function E(e,t,r){let a=e.next();for(;!a.done;){try{const e=await a.value;t.push(...e)}catch(s){o(s)||r.push(s)}a=e.next()}}function q(e){const t=[];return null!=e.totalRecordCount&&(e.features.length<e.totalRecordCount&&t.push({name:"wfs-layer:maxRecordCount-too-low",message:`Could only fetch ${e.features.length} of ${e.totalRecordCount} in ${e.maxPageCount} queries. Try increasing the value of WFSLayer.maxRecordCount.`,details:{recordCount:e.features.length,totalRecordCount:e.totalRecordCount}}),e.totalRecordCount>e.maxTotalRecordCount&&t.push({name:"wfs-layer:large-dataset",message:`The number of ${e.totalRecordCount} features exceeds the maximum allowed of ${e.maxTotalRecordCount}.`,details:{recordCount:e.features.length,totalRecordCount:e.totalRecordCount,maxTotalRecordCount:e.maxTotalRecordCount}})),t}export{j as default};
5
+ import{createTask as e}from"../../../core/asyncUtils.js";import t from"../../../core/Error.js";import r from"../../../core/Logger.js";import{clamp as a}from"../../../core/mathUtils.js";import{throwIfAborted as s,isAbortError as o}from"../../../core/promiseUtils.js";import n from"../../../core/Warning.js";import{equals as i}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as u,convertToGeometry as l}from"../featureConversionUtils.js";import c from"../data/FeatureStore.js";import{checkProjectionSupport as h,project as m}from"../data/projectionSupport.js";import{QueryEngine as p}from"../data/QueryEngine.js";import{validateGeoJSON as d,createOptimizedFeatures as g}from"./geojson/geojson.js";import{mixAttributes as f}from"./support/sourceUtils.js";import{getGetFeatureSpatialReference as y,getFeatureCount as _,getFeature as x}from"../../ogc/wfsUtils.js";import C from"../../support/FieldsIndex.js";import{isNumber as w}from"../../../support/guards.js";import{utc as R}from"../../../time/constants.js";const F="esri.layers.WFSLayer";class S{constructor(){this._customParameters=null,this._queryEngine=null,this._supportsPagination=!0}destroy(){this._queryEngine?.destroy(),this._queryEngine=null}async load(e,r={}){const{getFeatureUrl:a,getFeatureOutputFormat:o,fields:n,geometryType:i,featureType:u,maxRecordCount:l,maxTotalRecordCount:m,maxPageCount:d,objectIdField:g,customParameters:f}=e,{spatialReference:_,getFeatureSpatialReference:x}=y(a,u,e.spatialReference);try{await h(x,_)}catch{throw new t("unsupported-projection","Projection not supported",{inSpatialReference:x,outSpatialReference:_})}s(r),this._customParameters=f,this._featureType=u,this._fieldsIndex=C.fromLayerJSON({fields:n,dateFieldsTimeReference:n.some(e=>"esriFieldTypeDate"===e.type)?{timeZoneIANA:R}:null}),this._geometryType=i,this._getFeatureUrl=a,this._getFeatureOutputFormat=o,this._getFeatureSpatialReference=x,this._maxRecordCount=l,this._maxTotalRecordCount=m,this._maxPageCount=d,this._objectIdField=g,this._spatialReference=_;let w=await this._snapshotFeatures(r);if(w.errors.length>0&&(this._supportsPagination=!1,w=await this._snapshotFeatures(r),w.errors.length>0))throw w.errors[0];const F={type:"object-id",fieldName:g};return this._queryEngine=new p({fieldsIndex:this._fieldsIndex,geometryType:i,hasM:!1,hasZ:!1,featureIdInfo:F,spatialReference:_,timeInfo:null,featureStore:new c({geometryType:i,hasM:!1,hasZ:!1})}),this._queryEngine.featureStore.addMany(w.features),{warnings:E(w),extent:(await this._queryEngine.fetchRecomputedExtents()).fullExtent}}async applyEdits(){throw new t("wfs-source:editing-not-supported","applyEdits() is not supported on WFSLayer")}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(w)}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(t){return this._customParameters=t.customParameters,this._maxRecordCount=t.maxRecordCount,this._maxTotalRecordCount=t.maxTotalRecordCount,this._maxPageCount=t.maxPageCount,this._snapshotTask?.abort(),this._snapshotTask=e(e=>this._snapshotFeatures({signal:e})),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._queryEngine.featureStore.addMany(e.features);for(const t of E(e))r.getLogger(F).warn(new n("wfs-layer:refresh-warning",t.message,t.details));e.errors?.length&&r.getLogger(F).warn(new n("wfs-layer:refresh-error","Refresh completed with errors",{errors:e.errors}))},()=>{this._queryEngine.featureStore.clear()}),await this._waitSnapshotComplete(),{extent:(await this._queryEngine.fetchRecomputedExtents()).fullExtent}}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _snapshotFeatures(e){const t=e?.signal,r=this._maxTotalRecordCount,n=this._maxPageCount,i=this._supportsPagination&&n>1?await _(this._getFeatureUrl,this._featureType.typeName,{customParameters:this._customParameters,signal:t}):void 0;let u=[];const l=[];if(null==i)try{u=await this._singleQuery(t)}catch(c){o(c)||l.push(c)}else{const e=Math.min(i,r),s=T(this,a(Math.ceil(e/this._maxRecordCount),1,n),t);await Promise.allSettled(Array.from({length:10}).map(()=>j(s,u,l)))}return s(t),{features:u,totalRecordCount:i,maxTotalRecordCount:r,maxPageCount:n,errors:l}}async _singleQuery(e){const t=Number.isFinite(this._maxRecordCount)&&this._maxRecordCount>0?this._maxRecordCount:void 0,r=await x(this._getFeatureUrl,this._featureType.typeName,this._getFeatureSpatialReference,this._getFeatureOutputFormat,{customParameters:this._customParameters,count:t,signal:e});return this._processGeoJSON(r,{signal:e})}async _pageQuery(e,t){const r=e*this._maxRecordCount,a=await x(this._getFeatureUrl,this._featureType.typeName,this._getFeatureSpatialReference,this._getFeatureOutputFormat,{customParameters:this._customParameters,startIndex:r,count:this._maxRecordCount,signal:t});return this._processGeoJSON(a,{startIndex:r,signal:t})}_processGeoJSON(e,t){d(e,this._getFeatureSpatialReference.wkid);const{startIndex:r,signal:a}=t;s(a);const o=g(e,{geometryType:this._geometryType,hasZ:!1,objectIdField:this._objectIdField});if(!i(this._spatialReference,this._getFeatureSpatialReference))for(const s of o)null!=s.geometry&&(s.geometry=u(m(l(s.geometry,this._geometryType,!1,!1),this._getFeatureSpatialReference,this._spatialReference)));let n=r??1;for(const s of o){const e={};f(this._fieldsIndex,e,s.attributes,!0),s.attributes=e,null==e[this._objectIdField]&&(s.objectId=e[this._objectIdField]=n++)}return o}}function*T(e,t,r){for(let a=0;a<t;a++)yield e._pageQuery(a,r)}async function j(e,t,r){let a=e.next();for(;!a.done;){try{const e=await a.value;t.push(...e)}catch(s){o(s)||r.push(s)}a=e.next()}}function E(e){const t=[];return null!=e.totalRecordCount&&(e.features.length<e.totalRecordCount&&t.push({name:"wfs-layer:maxRecordCount-too-low",message:`Could only fetch ${e.features.length} of ${e.totalRecordCount} in ${e.maxPageCount} queries. Try increasing the value of WFSLayer.maxRecordCount.`,details:{recordCount:e.features.length,totalRecordCount:e.totalRecordCount}}),e.totalRecordCount>e.maxTotalRecordCount&&t.push({name:"wfs-layer:large-dataset",message:`The number of ${e.totalRecordCount} features exceeds the maximum allowed of ${e.maxTotalRecordCount}.`,details:{recordCount:e.features.length,totalRecordCount:e.totalRecordCount,maxTotalRecordCount:e.maxTotalRecordCount}})),t}export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- 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/jsonUtils.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{executeQueryForSnapping as y}from"../../data/executeQueryForSnapping.js";import m from"../../data/FeatureStore.js";import{checkProjectionSupport as h,project as f}from"../../data/projectionSupport.js";import{QueryEngine as g}from"../../data/QueryEngine.js";import{inferLayerProperties as _,createOptimizedFeatures as j,validateGeoJSON as I}from"./geojson.js";import{createDefaultTemplate as F,createDefaultAttributesFunction as E,createDrawingInfo as b}from"../support/clientSideDefaults.js";import{queryBinsCapabilities as T,loadGeometryEngineForSimplify as w,mixAttributes as q,createFeatureEditSuccessResult as x,createFeatureEditErrorResult as S,simplify as R}from"../support/sourceUtils.js";import C from"../../../support/FieldsIndex.js";import{kebabDict as O}from"../../../support/fieldType.js";import{getFieldDefaultValue as k,getFieldDefaultLength as Q}from"../../../support/fieldUtils.js";import{utc as D}from"../../../../time/constants.js";const A={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryBins:!0,supportsQueryWithCacheHint:!0,supportsQueryWithDistance:!0,supportsQueryWithResultType:!0,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 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=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=_(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 y=new C(o);let h=y.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 f={};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(!O.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=k(a);void 0!==e&&(f[a.name]=e)}null==a.length&&(a.length=Q(a))}if(c){if(c.startTimeField){const e=y.get(c.startTimeField);e?(c.startTimeField=e.name,e.type="esriFieldTypeDate"):c.startTimeField=null}if(c.endTimeField){const e=y.get(c.endTimeField);e?(c.endTimeField=e.name,e.type="esriFieldTypeDate"):c.endTimeField=null}if(c.trackIdField){const e=y.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 j=l?b(l):void 0,I=y.dateFields.length?{timeZoneIANA:D}:null,T={warnings:i,featureErrors:[],layerDefinition:{...A,drawingInfo:j??void 0,templates:F(f),extent:void 0,geometryType:l,objectIdField:d,fields:o,hasZ:!!u,timeInfo:c,dateFieldsTimeReference:I}},w={type:"object-id",fieldName:d};this._queryEngine=new g({fieldsIndex:C.fromLayerJSON({fields:o,timeInfo:c,dateFieldsTimeReference:I}),geometryType:l,hasM:!1,hasZ:u,featureIdInfo:w,spatialReference:p,timeInfo:c,featureStore:new m({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(f,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:R,timeExtent:v}=await this._queryEngine.fetchRecomputedExtents();if(T.layerDefinition.extent=R,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([w(t,s),h(e.adds,t),h(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(),y(this._queryEngine,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=j(e,{geometryType:t,hasZ:s,objectIdField:i});if(!o(this._queryEngine.spatialReference,a))for(const n of r)null!=n.geometry&&(n.geometry=u(f(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=q(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(x(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(S("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),r=q(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=f(R(d.geometry,e),e,u)}c.push(d),s.push(x(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,h=t?.[a];if(null==h){e.push(S(`Identifier field ${a} missing`));continue}if(!u.has(h)){e.push(S(`Feature with object id ${h} missing`));continue}const g=p(u.getFeature(h),s,r,i);if(null!=m){if(s!==n(m)){e.push(S("Incorrect geometry type."));continue}const t=m.spatialReference??o;g.geometry=f(R(m,t),t,o)}if(t){const s=q(l,g.attributes,t);if(s){e.push(s);continue}}u.add(c(g,s,r,i,d)),e.push(x(h))}}_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 h(a,e)}catch{throw new s("geojson-layer","Projection not supported")}}}export{v as default};
5
+ 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/jsonUtils.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 F,createDrawingInfo as E}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 O,getFieldDefaultLength as k}from"../../../support/fieldUtils.js";import{utc as Q}from"../../../../time/constants.js";const D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryBins:!0,supportsQueryWithCacheHint:!0,supportsQueryWithDistance:!0,supportsQueryWithResultType:!0,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 A{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=O(a);void 0!==e&&(_[a.name]=e)}null==a.length&&(a.length=k(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?E(l):void 0,b=m.dateFields.length?{timeZoneIANA:Q}:null,T={warnings:i,featureErrors:[],layerDefinition:{...D,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=F(_,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:A,timeExtent:v}=await this._queryEngine.fetchRecomputedExtents();if(T.layerDefinition.extent=A,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{A as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- 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{jsonAdapter as c}from"../../../../geometry/geometryAdapters/json.js";import{equals as d,isWebMercator as u,wgs84 as f}from"../../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as p}from"../../../../geometry/support/webMercatorUtils.js";import{OptimizedFeature as y}from"../../OptimizedFeature.js";import h from"../../OptimizedGeometry.js";import{executeQueryForSnapping as g}from"../../data/executeQueryForSnapping.js";import I from"../../data/FeatureStore.js";import{checkProjectionSupport as _}from"../../data/projectionSupport.js";import{QueryEngine as F}from"../../data/QueryEngine.js";import{parseRows as w,parseNumber as E,severSlicedString as j,readRows as T,inferDelimiterAndLocationInfo as x,extractFieldNamesAndAliasesFromRow as N,inferFields as S}from"../csv/csv.js";import{createDefaultAttributesFunction as q,createDrawingInfo as b}from"./clientSideDefaults.js";import C from"../../../support/FieldsIndex.js";import{getFieldDefaultValue as O}from"../../../support/fieldUtils.js";import{isNumber as v}from"../../../../support/guards.js";import{utc as D}from"../../../../time/constants.js";const k=b("esriGeometryPoint"),P=["csv"],R=[0,0];class V{constructor(e,t){this.x=e,this.y=t}}class A{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=G(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(v)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),g(this._queryEngine,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 I({geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1}),o={type:"object-id",fieldName:t};return new F({fieldsIndex:C.fromLayerJSON({fields:i,dateFieldsTimeReference:{timeZoneIANA:D}}),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 f=[],g=s.fields.filter(e=>e.name!==r).map(e=>e.name);let I=0;const _={};for(const i of s.fields)if("esriFieldTypeOID"!==i.type&&"esriFieldTypeGlobalID"!==i.type){const e=O(i);void 0!==e&&(_[i.name]=e)}const F=w(e,g,this._delimiter,q(_,r));for(const l of F){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=E(l[e]);isNaN(t)?l[e]=null:l[e]=t}else null!=l[e]&&(l[e]=j(l[e]));l[r]=I,I++,a.push(new V(o,e)),f.push(l)}}if(!d({wkid:4326},o))if(u(o))for(const i of a)[i.x,i.y]=p(i.x,i.y,R);else a=l(c,a,m.WGS84,o,null,null);const T=[];for(let i=0;i<a.length;i++){const{x:e,y:t}=a[i],n=f[i];n[r]=i+1,T.push(new y(new h([],[e,t]),n,null,n[r]))}return T}_parseCoordinateValue(e){if(null==e||""===e)return null;let t=E(e);return(isNaN(t)||Math.abs(t)>181)&&(t=parseFloat(e)),t}async _checkProjection(e){try{await _(f,e)}catch{throw new n("csv-layer:projection-not-supported","Projection not supported")}}}function G(e,t){const i=t.parsingOptions||{},r={delimiter:i.delimiter,layerDefinition:null,locationInfo:{latitudeFieldName:i.latitudeField,longitudeFieldName:i.longitudeField}},s=r.layerDefinition={name:a(t.url,P)||"csv",dateFieldsTimeReference:{timeZoneIANA:D},drawingInfo:k,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=T(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}=x(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}=N(l,c),p=S(e,r.delimiter,u,f,r.locationInfo);if(i.fields?.length){const e=new C(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 C(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{A as default};
5
+ 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{jsonAdapter as c}from"../../../../geometry/geometryAdapters/json.js";import{equals as d,isWebMercator as u,wgs84 as f}from"../../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as p}from"../../../../geometry/support/webMercatorUtils.js";import{OptimizedFeature as y}from"../../OptimizedFeature.js";import h from"../../OptimizedGeometry.js";import g from"../../data/FeatureStore.js";import{checkProjectionSupport as I}from"../../data/projectionSupport.js";import{QueryEngine as _}from"../../data/QueryEngine.js";import{parseRows as F,parseNumber as w,severSlicedString as E,readRows as j,inferDelimiterAndLocationInfo as T,extractFieldNamesAndAliasesFromRow as x,inferFields as N}from"../csv/csv.js";import{createDefaultAttributesFunction as S,createDrawingInfo as q}from"./clientSideDefaults.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=q("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=A(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 g({geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1}),o={type:"object-id",fieldName:t};return new _({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 f=[],g=s.fields.filter(e=>e.name!==r).map(e=>e.name);let I=0;const _={};for(const i of s.fields)if("esriFieldTypeOID"!==i.type&&"esriFieldTypeGlobalID"!==i.type){const e=C(i);void 0!==e&&(_[i.name]=e)}const j=F(e,g,this._delimiter,S(_,r));for(const l of j){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=w(l[e]);isNaN(t)?l[e]=null:l[e]=t}else null!=l[e]&&(l[e]=E(l[e]));l[r]=I,I++,a.push(new R(o,e)),f.push(l)}}if(!d({wkid:4326},o))if(u(o))for(const i of a)[i.x,i.y]=p(i.x,i.y,P);else a=l(c,a,m.WGS84,o,null,null);const T=[];for(let i=0;i<a.length;i++){const{x:e,y:t}=a[i],n=f[i];n[r]=i+1,T.push(new y(new h([],[e,t]),n,null,n[r]))}return T}_parseCoordinateValue(e){if(null==e||""===e)return null;let t=w(e);return(isNaN(t)||Math.abs(t)>181)&&(t=parseFloat(e)),t}async _checkProjection(e){try{await I(f,e)}catch{throw new n("csv-layer:projection-not-supported","Projection not supported")}}}function A(e,t){const i=t.parsingOptions||{},r={delimiter:i.delimiter,layerDefinition:null,locationInfo:{latitudeFieldName:i.latitudeField,longitudeFieldName:i.longitudeField}},s=r.layerDefinition={name: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=j(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}=x(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};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{getJsonType as t,isPoint as i}from"../../../../geometry/support/jsonUtils.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{executeQueryForSnapping as u}from"../../data/executeQueryForSnapping.js";import d from"../../data/FeatureStore.js";import{checkProjectionSupport as p,project as f}from"../../data/projectionSupport.js";import{QueryEngine as c}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as y,createDefaultTemplate as m,createDrawingInfo as h}from"./clientSideDefaults.js";import{queryBinsCapabilities as g,loadGeometryEngineForSimplify as I,createFeatureEditErrorResult as b,mixAttributes as F,createFeatureEditSuccessResult as j,simplify as E}from"./sourceUtils.js";import _ from"../../../support/FieldsIndex.js";import{kebabDict as T}from"../../../support/fieldType.js";import{getFieldDefaultLength as x,getFieldDefaultValue as R}from"../../../support/fieldUtils.js";import{utc as q}from"../../../../time/constants.js";const O=s,D={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:s},w={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryBins:!0,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 S(e){return i(e)?null!=e.m:!!e.hasM}class v{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,u=null!=t.hasZ?t.hasZ:!!r.hasZ,f=!t.spatialReference&&!r.spatialReference,g=f?O:t.spatialReference||r.spatialReference,I=f?D:null,b=t.geometryType||r.geometryType,F=!b;let j=t.objectIdField||r.objectIdField,E=t.timeInfo;const Q=new _(n);if(!F&&(f&&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=Q.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=x(o))}const S={};for(const e of n)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=R(e);void 0!==t&&(S[e.name]=t)}if(E){if(E.startTimeField){const e=Q.get(E.startTimeField);e?(E.startTimeField=e.name,e.type="esriFieldTypeDate"):E.startTimeField=null}if(E.endTimeField){const e=Q.get(E.endTimeField);e?(E.endTimeField=e.name,e.type="esriFieldTypeDate"):E.endTimeField=null}if(E.trackIdField){const e=Q.get(E.trackIdField);e?E.trackIdField=e.name:(E.trackIdField=null,i.push({name:"feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:E}}))}E.startTimeField||E.endTimeField||(i.push({name:"feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing or invalid",details:{timeInfo:E}}),E=null)}const v=Q.dateFields.length?{timeZoneIANA:t.dateFieldsTimeZone??q}:null;this._createDefaultAttributes=y(S,j);const M={warnings:i,featureErrors:[],layerDefinition:{...w,drawingInfo:h(b),templates:m(S),extent:I,geometryType:b,objectIdField:j,fields:n,hasZ:u,hasM:a,timeInfo:E,dateFieldsTimeReference:v},assignedObjectIds:{}},A={type:"object-id",fieldName:j};if(this._queryEngine=new c({fieldsIndex:_.fromLayerJSON({fields:n,timeInfo:E,dateFieldsTimeReference:v}),geometryType:b,hasM:a,hasZ:u,featureIdInfo:A,spatialReference:g,featureStore:new d({geometryType:b,hasM:a,hasZ:u}),timeInfo:E}),!s?.length)return this._nextObjectId=o,M;const Z=l(j,s);return this._nextObjectId=Z+1,await p(s,g),this._loadInitialFeatures(M,s)}async applyEdits(e){const{spatialReference:t,geometryType:i}=this._queryEngine;return await Promise.all([I(t,i),p(e.adds,t),p(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 u(this._queryEngine,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=S(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,p=[],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(b("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),n=F(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=f(r.geometry,r.geometry.spatialReference,l)),p.push(r))}u.addMany(r([],p,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(j(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:p,fieldsIndex:c}=this._queryEngine,y=[];for(const r of i){if(r.geometry&&n!==t(r.geometry)){s.push(b("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),a=F(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=f(E(r.geometry,e),e,u)}y.push(r),s.push(j(r.attributes[l]))}}d.addMany(r([],y,n,o,a,p))}_applyUpdateEdits({updateResults:e},i){const{geometryType:s,hasM:r,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d,fieldsIndex:p,featureIdInfo:c}=this._queryEngine;for(const y of i){const{attributes:i,geometry:m}=y,h=i?.[l];if(null==h){e.push(b(`Identifier field ${l} missing`));continue}if(!d.has(h)){e.push(b(`Feature with object id ${h} missing`));continue}const g=n(d.getFeature(h),s,o,r);if(null!=m){if(s!==t(m)){e.push(b("Incorrect geometry type."));continue}const i=m.spatialReference??u;g.geometry=f(E(m,i),i,u)}if(i){const t=F(p,g.attributes,i);if(t){e.push(t);continue}}d.add(a(g,s,o,r,c)),e.push(j(h))}}_assignObjectId(e,t,i=!1){const s=this._queryEngine.objectIdField;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}export{v as default};
5
+ import e from"../../../../core/Error.js";import{getJsonType as t,isPoint as i}from"../../../../geometry/support/jsonUtils.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 h,loadGeometryEngineForSimplify as g,createFeatureEditErrorResult as I,mixAttributes as b,createFeatureEditSuccessResult as F,simplify as j}from"./sourceUtils.js";import E from"../../../support/FieldsIndex.js";import{kebabDict as _}from"../../../support/fieldType.js";import{getFieldDefaultLength as T,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},D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryBins:!0,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 w(e){return i(e)?null!=e.z:!!e.hasZ}function Q(e){return i(e)?null!=e.m:!!e.hasM}class S{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,h=!t.spatialReference&&!r.spatialReference,g=h?q:t.spatialReference||r.spatialReference,I=h?O:null,b=t.geometryType||r.geometryType,F=!b;let j=t.objectIdField||r.objectIdField,w=t.timeInfo;const Q=new E(n);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)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=Q.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"),!_.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=T(o))}const S={};for(const e of n)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=x(e);void 0!==t&&(S[e.name]=t)}if(w){if(w.startTimeField){const e=Q.get(w.startTimeField);e?(w.startTimeField=e.name,e.type="esriFieldTypeDate"):w.startTimeField=null}if(w.endTimeField){const e=Q.get(w.endTimeField);e?(w.endTimeField=e.name,e.type="esriFieldTypeDate"):w.endTimeField=null}if(w.trackIdField){const e=Q.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 v=Q.dateFields.length?{timeZoneIANA:t.dateFieldsTimeZone??R}:null;this._createDefaultAttributes=c(S,j);const M={warnings:i,featureErrors:[],layerDefinition:{...D,drawingInfo:m(b),templates:y(S),extent:I,geometryType:b,objectIdField:j,fields:n,hasZ:p,hasM:a,timeInfo:w,dateFieldsTimeReference:v},assignedObjectIds:{}},A={type:"object-id",fieldName:j};if(this._queryEngine=new f({fieldsIndex:E.fromLayerJSON({fields:n,timeInfo:w,dateFieldsTimeReference:v}),geometryType:b,hasM:a,hasZ:p,featureIdInfo:A,spatialReference:g,featureStore:new u({geometryType:b,hasM:a,hasZ:p}),timeInfo:w}),!s?.length)return this._nextObjectId=o,M;const Z=l(j,s);return this._nextObjectId=Z+1,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,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=w(e)),null==r&&(r=Q(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,h=i?.[l];if(null==h){e.push(I(`Identifier field ${l} missing`));continue}if(!d.has(h)){e.push(I(`Feature with object id ${h} missing`));continue}const g=n(d.getFeature(h),s,o,r);if(null!=m){if(s!==t(m)){e.push(I("Incorrect geometry type."));continue}const i=m.spatialReference??u;g.geometry=p(j(m,i),i,u)}if(i){const t=b(f,g.attributes,i);if(t){e.push(t);continue}}d.add(a(g,s,o,r,c)),e.push(F(h))}}_assignObjectId(e,t,i=!1){const s=this._queryEngine.objectIdField;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{result as e}from"../../core/asyncUtils.js";import t from"../../core/Error.js";import{assertIsSome as i}from"../../core/maybe.js";import{whenOrAbort as n,throwIfAbortError as o}from"../../core/promiseUtils.js";import{getMetersPerUnitForSR as l}from"../../core/unitUtils.js";import s from"../../geometry/Multipoint.js";import a from"../../geometry/Point.js";import r from"../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../geometry/projectionUtils.js";import{fromExtent as h,create as f,contains as m}from"../../geometry/support/aaBoundingRect.js";import{MultiTileElevationSampler as p}from"./ElevationSampler.js";import{ElevationTile as d}from"./ElevationTile.js";import{TileKey as y}from"./TileKey.js";class T{async queryAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");const o=v.fromGeometry(i);let l=!1;n?.returnSampleInfo||(l=!0);const s={...R,...n,returnSampleInfo:!0},a=await this.query(e[e.length-1],o,s),r=await this._queryAllContinue(e,a,s);return r.geometry=r.geometry.export(),l&&delete r.sampleInfo,r}async query(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||!(i instanceof v)&&"point"!==i.type&&"multipoint"!==i.type&&"polyline"!==i.type)throw new t("elevation-query:invalid-geometry","Only point, polyline and multipoint geometries can be used to query elevation");const o={...R,...n},l=new x(e,i.spatialReference,o),s=o.signal;return await e.load({signal:s}),await q(l,i,s),await this._selectTiles(l,s),await F(l,s),b(l),z(l,s)}async createSampler(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n};return this._createSampler(e,i,o)}async createSamplerAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n,returnSampleInfo:!0},l=await this._createSampler(e[e.length-1],i,o);return this._createSamplerAllContinue(e,i,l,o)}async _createSampler(e,t,i,n){const o=i.signal;await e.load({signal:o});const l=t.spatialReference,s=e.tileInfo.spatialReference;l.equals(s)||(await c([{source:l,dest:s}],{signal:o}),t=u(t,s));const a=new _(e,t,i,n);return await this._selectTiles(a,o),await F(a,o),new p(a.elevationTiles,a.layer.tileInfo,a.options.noDataValue)}async _createSamplerAllContinue(e,t,i,n){if(e.pop(),!e.length)return i;const o=i.samplers.filter(e=>!e.tile.hasNoDataValues).map(e=>h(e.extent)),l=await this._createSampler(e[e.length-1],t,n,o);if(0===l.samplers.length)return i;const s=i.samplers.concat(l.samplers),a=new p(s,n.noDataValue);return this._createSamplerAllContinue(e,t,a,n)}async _queryAllContinue(e,t,n){const o=e.pop(),l=t.geometry.coordinates,s=t.sampleInfo;i(s);const a=[],r=[];for(let i=0;i<l.length;i++){const t=s[i];t.demResolution>=0?t.source||(t.source=o):e.length&&(a.push(l[i]),r.push(i))}if(!e.length||0===a.length)return t;const c=t.geometry.clone(a),u=await this.query(e[e.length-1],c,n),h=u.sampleInfo;if(!h)throw new Error("no sampleInfo");return r.forEach((e,t)=>{l[e].z=u.geometry.coordinates[t].z,s[e].demResolution=h[t].demResolution}),this._queryAllContinue(e,t,n)}async _selectTiles(e,i){"geometry"===e.type&&I(e);const n=e.options.demResolution;if("number"==typeof n)C(e,n);else if("finest-contiguous"===n)await this._selectTilesFinestContiguous(e,i);else{if("auto"!==n)throw new t("elevation-query:invalid-dem-resolution",`Invalid dem resolution value '${n}', expected a number, "finest-contiguous" or "auto"`);await this._selectTilesAuto(e,i)}}async _selectTilesFinestContiguous(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=E(i,n,e.options.minDemResolution);await this._selectTilesFinestContiguousAt(e,o,t)}async _selectTilesFinestContiguousAt(e,i,l){const s=e.layer;if(e.selectTilesAtLOD(i),i<0)return;const a=s.tilemapCache,r=e.getTilesToFetch();try{if(a&&!L(a))await n(Promise.all(r.map(e=>a.fetchAvailability(e.level,e.row,e.col,{signal:l}))),l);else if(await F(e,l),!e.allElevationTilesFetched())throw e.clearElevationTiles(),new t("elevation-query:has-unavailable-tiles","Some elevation tiles are unavailable")}catch(c){o(c),await this._selectTilesFinestContiguousAt(e,i-1,l)}}async _selectTilesAuto(t,i){M(t),S(t);const l=t.layer.tilemapCache;if(!l||L(l))return this._selectTilesAutoPrefetchUpsample(t,i);const s=t.getTilesToFetch(),a={},r=s.map(async t=>{const n=new y(null,0,0,0,f()),s=await e(l.fetchAvailabilityUpsample(t.level,t.row,t.col,n,{signal:i}));!1!==s.ok?null!=t.id&&(a[t.id]=n):o(s.error)});await n(Promise.all(r),i),t.remapTiles(a)}async _selectTilesAutoPrefetchUpsample(e,t){const i=e.layer.tileInfo;await F(e,t);let n=!1;e.forEachTileToFetch((e,t)=>{i.upsampleTile(e)?n=!0:t()}),n&&await this._selectTilesAutoPrefetchUpsample(e,t)}}class v{export(){return this._exporter(this.coordinates,this.spatialReference)}clone(e){const t=new v;return t.geometry=this.geometry,t.spatialReference=this.spatialReference,t.coordinates=e||this.coordinates.map(e=>e.clone()),t._exporter=this._exporter,t}async project(e,t){if(this.spatialReference.equals(e))return this.clone();await c([{source:this.spatialReference,dest:e}],{signal:t});const i=new s({spatialReference:this.spatialReference,points:this.coordinates.map(e=>[e.x,e.y])}),n=u(i,e);if(!n)return null;const o=this.coordinates.map((e,t)=>{const i=e.clone(),o=n.points[t];return i.x=o[0],i.y=o[1],i}),l=this.clone(o);return l.spatialReference=e,l}static fromGeometry(e){const t=new v;if(t.geometry=e,t.spatialReference=e.spatialReference,e instanceof v)t.coordinates=e.coordinates.map(e=>e.clone()),t._exporter=(t,i)=>{const n=e.clone(t);return n.spatialReference=i,n};else switch(e.type){case"point":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?[new w(i.x,i.y,i.z,i.m)]:n?[new w(i.x,i.y,i.z)]:o?[new w(i.x,i.y,null,i.m)]:[new w(i.x,i.y)],t._exporter=(t,i)=>e.hasM?new a(t[0].x,t[0].y,t[0].z,t[0].m,i):new a(t[0].x,t[0].y,t[0].z,i);break}case"multipoint":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?i.points.map(e=>new w(e[0],e[1],e[2],e[3])):n?i.points.map(e=>new w(e[0],e[1],e[2])):o?i.points.map(e=>new w(e[0],e[1],null,e[2])):i.points.map(e=>new w(e[0],e[1])),t._exporter=(t,i)=>e.hasM?new s({points:t.map(e=>[e.x,e.y,e.z,e.m]),hasZ:!0,hasM:!0,spatialReference:i}):new s(t.map(e=>[e.x,e.y,e.z]),i);break}case"polyline":{const i=e,n=[],o=[],{hasZ:l,hasM:s}=e;let a=0;for(const e of i.paths)if(o.push([a,a+e.length]),a+=e.length,l&&s)for(const t of e)n.push(new w(t[0],t[1],t[2],t[3]));else if(l)for(const t of e)n.push(new w(t[0],t[1],t[2]));else if(s)for(const t of e)n.push(new w(t[0],t[1],null,t[2]));else for(const t of e)n.push(new w(t[0],t[1]));t.coordinates=n,t._exporter=(t,i)=>{const n=e.hasM?t.map(e=>[e.x,e.y,e.z??0,e.m??0]):t.map(e=>[e.x,e.y,e.z??0]),l=o.map(e=>n.slice(e[0],e[1]));return new r({paths:l,hasM:e.hasM,hasZ:!0,spatialReference:i})};break}}return t}}class w{constructor(e,t,i=null,n=null,o=null,l=null){this.x=e,this.y=t,this.z=i,this.m=n,this.tile=o,this.elevationTile=l}clone(){return new w(this.x,this.y,this.z,this.m)}}class g{constructor(e,t){this.layer=e,this.options=t}}class x extends g{constructor(e,t,i){super(e,i),this.outSpatialReference=t,this.type="geometry"}selectTilesAtLOD(e){if(e<0)this.geometry.coordinates.forEach(e=>e.tile=null);else{const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i)[e].level;this.geometry.coordinates.forEach(e=>e.tile=t.tileAt(n,e.x,e.y))}}allElevationTilesFetched(){return!this.geometry.coordinates.some(e=>!e.elevationTile)}clearElevationTiles(){for(const e of this.geometry.coordinates)e.elevationTile!==this.outsideExtentTile&&(e.elevationTile=null)}populateElevationTiles(e){for(const t of this.geometry.coordinates)!t.elevationTile&&t.tile?.id&&(t.elevationTile=e[t.tile.id])}remapTiles(e){for(const t of this.geometry.coordinates){const i=t.tile?.id;t.tile=i?e[i]:null}}getTilesToFetch(){const e={},t=[];for(const i of this.geometry.coordinates){const n=i.tile;if(!n)continue;const o=i.tile?.id;i.elevationTile||!o||e[o]||(e[o]=n,t.push(n))}return t}forEachTileToFetch(e){for(const t of this.geometry.coordinates)t.tile&&!t.elevationTile&&e(t.tile,()=>{t.tile=null})}}class _ extends g{constructor(e,t,i,n){super(e,i),this.type="extent",this.elevationTiles=[],this._candidateTiles=[],this._fetchedCandidates=new Set,this.extent=t.clone().intersection(e.fullExtent),this.maskExtents=n}selectTilesAtLOD(e,t){const i=this._maximumLodForRequests(t),n=Math.min(i,e);n<0?this._candidateTiles.length=0:this._selectCandidateTilesCoveringExtentAt(n)}_maximumLodForRequests(e){const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i);if(!e)return n.length-1;const o=this.extent;if(null==o)return-1;for(let l=n.length-1;l>=0;l--){const i=n[l],s=i.resolution*t.size[0],a=i.resolution*t.size[1];if(Math.ceil(o.width/s)*Math.ceil(o.height/a)<=e)return l}return-1}allElevationTilesFetched(){return this._candidateTiles.length===this.elevationTiles.length}clearElevationTiles(){this.elevationTiles.length=0,this._fetchedCandidates.clear()}populateElevationTiles(e){for(const t of this._candidateTiles){const i=t.id&&e[t.id];i&&(this._fetchedCandidates.add(t),this.elevationTiles.push(i))}}remapTiles(e){this._candidateTiles=j(this._candidateTiles.map(t=>e[t.id]))}getTilesToFetch(){return this._candidateTiles}forEachTileToFetch(e,t){const i=this._candidateTiles;this._candidateTiles=[],i.forEach(i=>{if(this._fetchedCandidates.has(i))return void(t&&t(i));let n=!1;e(i,()=>n=!0),n?t&&t(i):this._candidateTiles.push(i)}),this._candidateTiles=j(this._candidateTiles,t)}_selectCandidateTilesCoveringExtentAt(e){this._candidateTiles.length=0;const t=this.extent;if(null==t)return;const{tileInfo:i,tilemapCache:n}=this.layer,o=D(i,n)[e],l=i.tileAt(o.level,t.xmin,t.ymin),s=l.extent;if(null==s)return;const a=o.resolution*i.size[0],r=o.resolution*i.size[1],c=Math.ceil((t.xmax-s[0])/a),u=Math.ceil((t.ymax-s[1])/r);for(let h=0;h<u;h++)for(let e=0;e<c;e++){const t=new y(null,l.level,l.row-h,l.col+e);i.updateTileInfo(t),this._tileIsMasked(t)||this._candidateTiles.push(t)}}_tileIsMasked(e){return!!this.maskExtents&&this.maskExtents.some(t=>e.extent&&m(t,e.extent))}}function E(e,t,i=0){const n=D(e,t);let o=n.length-1;if(i>0){const t=i/l(e.spatialReference),s=n.findIndex(e=>e.resolution<t);0===s?o=0:s>0&&(o=s-1)}return o}const R={maximumAutoTileRequests:20,noDataValue:0,returnSampleInfo:!1,demResolution:"auto",minDemResolution:0};async function q(e,i,n){let o;const l=e.layer.tileInfo.spatialReference;if(i instanceof v?o=await i.project(l,n):(await c([{source:i.spatialReference,dest:l}],{signal:n}),o=u(i,l)),!o)throw new t("elevation-query:spatial-reference-mismatch",`Cannot query elevation in '${i.spatialReference.wkid}' on an elevation service in '${l.wkid}'`);e.geometry=v.fromGeometry(o)}function I(e){if(null==e.layer.fullExtent)return;const t=new d(null);t.sample=()=>e.options.noDataValue,e.outsideExtentTile=t;const i=e.layer.fullExtent;e.geometry.coordinates.forEach(e=>{const n=e.x,o=e.y;(n<i.xmin||n>i.xmax||o<i.ymin||o>i.ymax)&&(e.elevationTile=t)})}function A(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=t/l(i.spatialReference),s=D(i,n);let a=s[0],r=0;for(let l=1;l<s.length;l++){const e=s[l];Math.abs(e.resolution-o)<Math.abs(a.resolution-o)&&(a=e,r=l)}return r}function C(e,t){const i=A(e,t);e.selectTilesAtLOD(i)}function M(e){const{tileInfo:t,tilemapCache:i}=e.layer,n=E(t,i,e.options.minDemResolution);e.selectTilesAtLOD(n,e.options.maximumAutoTileRequests)}function D(e,t){const i=e.lods;if(L(t)){const{effectiveMinLOD:e,effectiveMaxLOD:n}=t;return i.filter(t=>t.level>=e&&t.level<=n)}return i}async function F(e,t){const i=e.getTilesToFetch(),o={},l=e.options.cache,s=e.options.noDataValue,a=i.map(async i=>{if(null==i.id)return;const n=`${e.layer.uid}:${i.id}:${s}`,a=null!=l?l.get(n):null,r=null!=a?a:await e.layer.fetchTile(i.level,i.row,i.col,{noDataValue:s,signal:t});null!=l&&l.put(n,r),o[i.id]=new d(i,r)});await n(Promise.allSettled(a),t),e.populateElevationTiles(o)}function S(e){const t=e.layer.tileInfo;let i=0;const n={},o=e=>{null!=e.id&&(e.id in n?n[e.id]++:(n[e.id]=1,i++))},l=e=>{if(null==e.id)return;const t=n[e.id];1===t?(delete n[e.id],i--):n[e.id]=t-1};e.forEachTileToFetch(o,l);let s=!0;for(;s&&(s=!1,e.forEachTileToFetch(n=>{i<=e.options.maximumAutoTileRequests||(l(n),t.upsampleTile(n)&&(s=!0),o(n))},l),s););}function b(e){e.geometry.coordinates.forEach(t=>{const i=t.elevationTile;let n=e.options.noDataValue;if(i){const e=i.sample(t.x,t.y);null!=e?n=e:t.elevationTile=null}t.z=n})}function j(e,t){const i={},n=[];for(const l of e){const e=l.id;e&&!i[e]?(i[e]=l,n.push(l)):t&&t(l)}const o=n.sort((e,t)=>e.level-t.level);return o.filter((e,i)=>{for(let n=0;n<i;n++){const i=o[n].extent;if(i&&e.extent&&m(i,e.extent))return t&&t(e),!1}return!0})}async function z(e,t){const n=await e.geometry.project(e.outSpatialReference,t);i(n);const o={geometry:n.export(),noDataValue:e.options.noDataValue};return e.options.returnSampleInfo&&(o.sampleInfo=k(e)),e.geometry.coordinates.forEach(e=>{e.tile=null,e.elevationTile=null}),o}function k(e){const t=e.layer.tileInfo,i=l(t.spatialReference);return e.geometry.coordinates.map(n=>{let o=-1;if(n.elevationTile&&n.elevationTile!==e.outsideExtentTile){o=t.lodAt(n.elevationTile.tile.level).resolution*i}return{demResolution:o}})}function L(e){return null!=e?.tileInfo}export{T as ElevationQuery,v as GeometryDescriptor,E as getFinestLodIndex};
5
+ import{result as e}from"../../core/asyncUtils.js";import t from"../../core/Error.js";import{assertIsSome as i}from"../../core/maybe.js";import{whenOrAbort as n,throwIfAbortError as o}from"../../core/promiseUtils.js";import{getMetersPerUnitForSR as l}from"../../core/unitUtils.js";import s from"../../geometry/Multipoint.js";import a from"../../geometry/Point.js";import r from"../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../geometry/projectionUtils.js";import{fromExtent as h,create as f,contains as m}from"../../geometry/support/aaBoundingRect.js";import{MultiTileElevationSampler as p}from"./ElevationSampler.js";import{ElevationTile as d}from"./ElevationTile.js";import{TileKey as y}from"./TileKey.js";class T{async queryAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");const o=v.fromGeometry(i);let l=!1;n?.returnSampleInfo||(l=!0);const s={...R,...n,returnSampleInfo:!0},a=await this.query(e[e.length-1],o,s),r=await this._queryAllContinue(e,a,s);return r.geometry=r.geometry.export(),l&&delete r.sampleInfo,r}async query(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||!(i instanceof v)&&"point"!==i.type&&"multipoint"!==i.type&&"polyline"!==i.type)throw new t("elevation-query:invalid-geometry","Only point, polyline and multipoint geometries can be used to query elevation");const o={...R,...n},l=new x(e,i.spatialReference,o),s=o.signal;return await e.load({signal:s}),await q(l,i,s),await this._selectTiles(l,s),await F(l,s),b(l),z(l,s)}async createSampler(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n};return this._createSampler(e,i,o)}async createSamplerAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n,returnSampleInfo:!0},l=await this._createSampler(e[e.length-1],i,o);return this._createSamplerAllContinue(e,i,l,o)}async _createSampler(e,t,i,n){const o=i.signal;await e.load({signal:o});const l=t.spatialReference,s=e.tileInfo.spatialReference;l.equals(s)||(await c([{source:l,dest:s}],{signal:o}),t=u(t,s));const a=new _(e,t,i,n);return await this._selectTiles(a,o),await F(a,o),new p(a.elevationTiles,a.layer.tileInfo,a.options.noDataValue)}async _createSamplerAllContinue(e,t,i,n){if(e.pop(),!e.length)return i;const o=i.samplers.filter(e=>!e.tile.hasNoDataValues).map(e=>h(e.extent)),l=await this._createSampler(e[e.length-1],t,n,o);if(0===l.samplers.length)return i;const s=i.samplers.concat(l.samplers),a=new p(s,n.noDataValue);return this._createSamplerAllContinue(e,t,a,n)}async _queryAllContinue(e,t,n){const o=e.pop(),l=t.geometry.coordinates,s=t.sampleInfo;i(s);const a=[],r=[];for(let i=0;i<l.length;i++){const t=s[i];t.demResolution>=0?t.source||(t.source=o):e.length&&(a.push(l[i]),r.push(i))}if(!e.length||0===a.length)return t;const c=t.geometry.clone(a),u=await this.query(e[e.length-1],c,n),h=u.sampleInfo;if(!h)throw new Error("no sampleInfo");return r.forEach((e,t)=>{l[e].z=u.geometry.coordinates[t].z,s[e].demResolution=h[t].demResolution}),this._queryAllContinue(e,t,n)}async _selectTiles(e,i){"geometry"===e.type&&I(e);const n=e.options.demResolution;if("number"==typeof n)C(e,n);else if("finest-contiguous"===n)await this._selectTilesFinestContiguous(e,i);else{if("auto"!==n)throw new t("elevation-query:invalid-dem-resolution",`Invalid dem resolution value '${n}', expected a number, "finest-contiguous" or "auto"`);await this._selectTilesAuto(e,i)}}async _selectTilesFinestContiguous(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=E(i,n,e.options.minDemResolution);await this._selectTilesFinestContiguousAt(e,o,t)}async _selectTilesFinestContiguousAt(e,i,l){const s=e.layer;if(e.selectTilesAtLOD(i),i<0)return;const a=s.tilemapCache,r=e.getTilesToFetch();try{if(a&&!L(a))await n(Promise.all(r.map(e=>a.fetchAvailability(e.level,e.row,e.col,{signal:l}))),l);else if(await F(e,l),!e.allElevationTilesFetched())throw e.clearElevationTiles(),new t("elevation-query:has-unavailable-tiles","Some elevation tiles are unavailable")}catch(c){o(c),await this._selectTilesFinestContiguousAt(e,i-1,l)}}async _selectTilesAuto(t,i){M(t),S(t);const l=t.layer.tilemapCache;if(!l||L(l))return this._selectTilesAutoPrefetchUpsample(t,i);const s=t.getTilesToFetch(),a={},r=s.map(async t=>{const n=new y(null,0,0,0,f()),s=await e(l.fetchAvailabilityUpsample(t.level,t.row,t.col,n,{signal:i}));!1!==s.ok?null!=t.id&&(a[t.id]=n):o(s.error)});await n(Promise.all(r),i),t.remapTiles(a)}async _selectTilesAutoPrefetchUpsample(e,t){const i=e.layer.tileInfo;await F(e,t);let n=!1;e.forEachTileToFetch((e,t)=>{i.upsampleTile(e)?n=!0:t()}),n&&await this._selectTilesAutoPrefetchUpsample(e,t)}}class v{export(){return this._exporter(this.coordinates,this.spatialReference)}clone(e){const t=new v;return t.geometry=this.geometry,t.spatialReference=this.spatialReference,t.coordinates=e||this.coordinates.map(e=>e.clone()),t._exporter=this._exporter,t}async project(e,t){if(this.spatialReference.equals(e))return this.clone();await c([{source:this.spatialReference,dest:e}],{signal:t});const i=new s({spatialReference:this.spatialReference,points:this.coordinates.map(e=>[e.x,e.y])}),n=u(i,e);if(!n)return null;const o=this.coordinates.map((e,t)=>{const i=e.clone(),o=n.points[t];return i.x=o[0],i.y=o[1],i}),l=this.clone(o);return l.spatialReference=e,l}static fromGeometry(e){const t=new v;if(t.geometry=e,t.spatialReference=e.spatialReference,e instanceof v)t.coordinates=e.coordinates.map(e=>e.clone()),t._exporter=(t,i)=>{const n=e.clone(t);return n.spatialReference=i,n};else switch(e.type){case"point":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?[new w(i.x,i.y,i.z,i.m)]:n?[new w(i.x,i.y,i.z)]:o?[new w(i.x,i.y,null,i.m)]:[new w(i.x,i.y)],t._exporter=(t,i)=>e.hasM?new a(t[0].x,t[0].y,t[0].z,t[0].m,i):new a(t[0].x,t[0].y,t[0].z,i);break}case"multipoint":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?i.points.map(e=>new w(e[0],e[1],e[2],e[3])):n?i.points.map(e=>new w(e[0],e[1],e[2])):o?i.points.map(e=>new w(e[0],e[1],null,e[2])):i.points.map(e=>new w(e[0],e[1])),t._exporter=(t,i)=>e.hasM?new s({points:t.map(e=>[e.x,e.y,e.z,e.m]),hasZ:!0,hasM:!0,spatialReference:i}):new s(t.map(e=>[e.x,e.y,e.z]),i);break}case"polyline":{const i=e,n=[],o=[],{hasZ:l,hasM:s}=e;let a=0;for(const e of i.paths)if(o.push([a,a+e.length]),a+=e.length,l&&s)for(const t of e)n.push(new w(t[0],t[1],t[2],t[3]));else if(l)for(const t of e)n.push(new w(t[0],t[1],t[2]));else if(s)for(const t of e)n.push(new w(t[0],t[1],null,t[2]));else for(const t of e)n.push(new w(t[0],t[1]));t.coordinates=n,t._exporter=(t,i)=>{const n=e.hasM?t.map(e=>[e.x,e.y,e.z??0,e.m??0]):t.map(e=>[e.x,e.y,e.z??0]),l=o.map(e=>n.slice(e[0],e[1]));return new r({paths:l,hasM:e.hasM,hasZ:!0,spatialReference:i})};break}}return t}}class w{constructor(e,t,i=null,n=null,o=null,l=null){this.x=e,this.y=t,this.z=i,this.m=n,this.tile=o,this.elevationTile=l}clone(){return new w(this.x,this.y,this.z,this.m)}}class g{constructor(e,t){this.layer=e,this.options=t}}class x extends g{constructor(e,t,i){super(e,i),this.outSpatialReference=t,this.type="geometry"}selectTilesAtLOD(e){if(e<0)this.geometry.coordinates.forEach(e=>e.tile=null);else{const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i)[e].level;this.geometry.coordinates.forEach(e=>e.tile=t.tileAt(n,e.x,e.y))}}allElevationTilesFetched(){return!this.geometry.coordinates.some(e=>!e.elevationTile)}clearElevationTiles(){for(const e of this.geometry.coordinates)e.elevationTile!==this.outsideExtentTile&&(e.elevationTile=null)}populateElevationTiles(e){for(const t of this.geometry.coordinates)!t.elevationTile&&t.tile?.id&&(t.elevationTile=e[t.tile.id])}remapTiles(e){for(const t of this.geometry.coordinates){const i=t.tile?.id;t.tile=i?e[i]:null}}getTilesToFetch(){const e={},t=[];for(const i of this.geometry.coordinates){const n=i.tile;if(!n)continue;const o=i.tile?.id;i.elevationTile||!o||e[o]||(e[o]=n,t.push(n))}return t}forEachTileToFetch(e){for(const t of this.geometry.coordinates)t.tile&&!t.elevationTile&&e(t.tile,()=>{t.tile=null})}}class _ extends g{constructor(e,t,i,n){super(e,i),this.type="extent",this.elevationTiles=[],this._candidateTiles=[],this._fetchedCandidates=new Set,this.extent=t.clone().intersection(e.fullExtent),this.maskExtents=n}selectTilesAtLOD(e,t){const i=this._maximumLodForRequests(t),n=Math.min(i,e);n<0?this._candidateTiles.length=0:this._selectCandidateTilesCoveringExtentAt(n)}_maximumLodForRequests(e){const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i);if(!e)return n.length-1;const o=this.extent;if(null==o)return-1;for(let l=n.length-1;l>=0;l--){const i=n[l],s=i.resolution*t.size[0],a=i.resolution*t.size[1];if(Math.ceil(o.width/s)*Math.ceil(o.height/a)<=e)return l}return-1}allElevationTilesFetched(){return this._candidateTiles.length===this.elevationTiles.length}clearElevationTiles(){this.elevationTiles.length=0,this._fetchedCandidates.clear()}populateElevationTiles(e){for(const t of this._candidateTiles){const i=t.id&&e[t.id];i&&(this._fetchedCandidates.add(t),this.elevationTiles.push(i))}}remapTiles(e){this._candidateTiles=j(this._candidateTiles.map(t=>e[t.id]))}getTilesToFetch(){return this._candidateTiles}forEachTileToFetch(e,t){const i=this._candidateTiles;this._candidateTiles=[],i.forEach(i=>{if(this._fetchedCandidates.has(i))return void t?.(i);let n=!1;e(i,()=>n=!0),n?t?.(i):this._candidateTiles.push(i)}),this._candidateTiles=j(this._candidateTiles,t)}_selectCandidateTilesCoveringExtentAt(e){this._candidateTiles.length=0;const t=this.extent;if(null==t)return;const{tileInfo:i,tilemapCache:n}=this.layer,o=D(i,n)[e],l=i.tileAt(o.level,t.xmin,t.ymin),s=l.extent;if(null==s)return;const a=o.resolution*i.size[0],r=o.resolution*i.size[1],c=Math.ceil((t.xmax-s[0])/a),u=Math.ceil((t.ymax-s[1])/r);for(let h=0;h<u;h++)for(let e=0;e<c;e++){const t=new y(null,l.level,l.row-h,l.col+e);i.updateTileInfo(t),this._tileIsMasked(t)||this._candidateTiles.push(t)}}_tileIsMasked(e){return!!this.maskExtents&&this.maskExtents.some(t=>e.extent&&m(t,e.extent))}}function E(e,t,i=0){const n=D(e,t);let o=n.length-1;if(i>0){const t=i/l(e.spatialReference),s=n.findIndex(e=>e.resolution<t);0===s?o=0:s>0&&(o=s-1)}return o}const R={maximumAutoTileRequests:20,noDataValue:0,returnSampleInfo:!1,demResolution:"auto",minDemResolution:0};async function q(e,i,n){let o;const l=e.layer.tileInfo.spatialReference;if(i instanceof v?o=await i.project(l,n):(await c([{source:i.spatialReference,dest:l}],{signal:n}),o=u(i,l)),!o)throw new t("elevation-query:spatial-reference-mismatch",`Cannot query elevation in '${i.spatialReference.wkid}' on an elevation service in '${l.wkid}'`);e.geometry=v.fromGeometry(o)}function I(e){if(null==e.layer.fullExtent)return;const t=new d(null);t.sample=()=>e.options.noDataValue,e.outsideExtentTile=t;const i=e.layer.fullExtent;e.geometry.coordinates.forEach(e=>{const n=e.x,o=e.y;(n<i.xmin||n>i.xmax||o<i.ymin||o>i.ymax)&&(e.elevationTile=t)})}function A(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=t/l(i.spatialReference),s=D(i,n);let a=s[0],r=0;for(let l=1;l<s.length;l++){const e=s[l];Math.abs(e.resolution-o)<Math.abs(a.resolution-o)&&(a=e,r=l)}return r}function C(e,t){const i=A(e,t);e.selectTilesAtLOD(i)}function M(e){const{tileInfo:t,tilemapCache:i}=e.layer,n=E(t,i,e.options.minDemResolution);e.selectTilesAtLOD(n,e.options.maximumAutoTileRequests)}function D(e,t){const i=e.lods;if(L(t)){const{effectiveMinLOD:e,effectiveMaxLOD:n}=t;return i.filter(t=>t.level>=e&&t.level<=n)}return i}async function F(e,t){const i=e.getTilesToFetch(),o={},l=e.options.cache,s=e.options.noDataValue,a=i.map(async i=>{if(null==i.id)return;const n=`${e.layer.uid}:${i.id}:${s}`,a=null!=l?l.get(n):null,r=null!=a?a:await e.layer.fetchTile(i.level,i.row,i.col,{noDataValue:s,signal:t});null!=l&&l.put(n,r),o[i.id]=new d(i,r)});await n(Promise.allSettled(a),t),e.populateElevationTiles(o)}function S(e){const t=e.layer.tileInfo;let i=0;const n={},o=e=>{null!=e.id&&(e.id in n?n[e.id]++:(n[e.id]=1,i++))},l=e=>{if(null==e.id)return;const t=n[e.id];1===t?(delete n[e.id],i--):n[e.id]=t-1};e.forEachTileToFetch(o,l);let s=!0;for(;s&&(s=!1,e.forEachTileToFetch(n=>{i<=e.options.maximumAutoTileRequests||(l(n),t.upsampleTile(n)&&(s=!0),o(n))},l),s););}function b(e){e.geometry.coordinates.forEach(t=>{const i=t.elevationTile;let n=e.options.noDataValue;if(i){const e=i.sample(t.x,t.y);null!=e?n=e:t.elevationTile=null}t.z=n})}function j(e,t){const i={},n=[];for(const l of e){const e=l.id;e&&!i[e]?(i[e]=l,n.push(l)):t?.(l)}const o=n.sort((e,t)=>e.level-t.level);return o.filter((e,i)=>{for(let n=0;n<i;n++){const i=o[n].extent;if(i&&e.extent&&m(i,e.extent))return t?.(e),!1}return!0})}async function z(e,t){const n=await e.geometry.project(e.outSpatialReference,t);i(n);const o={geometry:n.export(),noDataValue:e.options.noDataValue};return e.options.returnSampleInfo&&(o.sampleInfo=k(e)),e.geometry.coordinates.forEach(e=>{e.tile=null,e.elevationTile=null}),o}function k(e){const t=e.layer.tileInfo,i=l(t.spatialReference);return e.geometry.coordinates.map(n=>{let o=-1;if(n.elevationTile&&n.elevationTile!==e.outsideExtentTile){o=t.lodAt(n.elevationTile.tile.level).resolution*i}return{demResolution:o}})}function L(e){return null!=e?.tileInfo}export{T as ElevationQuery,v as GeometryDescriptor,E as getFinestLodIndex};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import{sqlAnd as s}from"../../core/sql.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{isInScaleRange as a}from"../../geometry/support/scaleUtils.js";import{getLayerFloorFilterClause as o}from"./floorFilterUtils.js";import{isExportDynamic as l}from"./sublayerUtils.js";const n={visible:"visibleSublayers",definitionExpression:"layerDefs",labelingInfo:"hasDynamicLayers",labelsVisible:"hasDynamicLayers",opacity:"hasDynamicLayers",minScale:"visibleSublayers",maxScale:"visibleSublayers",renderer:"hasDynamicLayers",source:"hasDynamicLayers"};let y=class extends r{constructor(e){super(e),this.floors=null,this.scale=0}destroy(){this.layer=null}get dynamicLayers(){if(!this.hasDynamicLayers)return null;const e=this.visibleSublayers.map(e=>{const r=o(this.floors,e);return e.toExportImageJSON(r)});return e.length?JSON.stringify(e):null}get hasDynamicLayers(){return this.layer&&l(this.visibleSublayers,this.layer.serviceSublayers,this.layer.gdbVersion)}set layer(e){this._get("layer")!==e&&(this._set("layer",e),this.removeHandles("layer"),e&&this.addHandles([e.allSublayers.on("change",()=>this.notifyChange("visibleSublayers")),e.on("sublayer-update",e=>this.notifyChange(n[e.propertyName]))],"layer"))}get layers(){const e=this.visibleSublayers;return e?e.length?"show:"+e.map(e=>e.id).join(","):"show:-1":null}get layerDefs(){const e=!!this.floors?.length,r=this.visibleSublayers.filter(r=>null!=r.definitionExpression||e&&null!=r.floorInfo);return r.length?JSON.stringify(r.reduce((e,r)=>{const t=o(this.floors,r),i=s(t,r.definitionExpression);return null!=i&&(e[r.id]=i),e},{})):null}get version(){this.commitProperty("layers"),this.commitProperty("layerDefs"),this.commitProperty("dynamicLayers");const e=this.layer;return e&&(e.commitProperty("dpi"),e.commitProperty("imageFormat"),e.commitProperty("imageTransparency"),e.commitProperty("gdbVersion")),(this._get("version")||0)+1}get visibleSublayers(){const e=[];if(!this.layer)return e;const r=this.layer.sublayers,s=this.scale,t=r=>{r.visible&&(0===s||a(s,r.minScale,r.maxScale))&&(r.sublayers?r.sublayers.forEach(t):e.unshift(r))};r&&r.forEach(t);const i=this._get("visibleSublayers");return!i||i.length!==e.length||i.some((r,s)=>e[s]!==r)?e:i}toJSON(){const e=this.layer;let r={dpi:e.dpi,format:e.imageFormat,transparent:e.imageTransparency,gdbVersion:e.gdbVersion||null};return this.hasDynamicLayers&&this.dynamicLayers?r.dynamicLayers=this.dynamicLayers:r={...r,layers:this.layers,layerDefs:this.layerDefs},r}};e([t({readOnly:!0})],y.prototype,"dynamicLayers",null),e([t()],y.prototype,"floors",void 0),e([t({readOnly:!0})],y.prototype,"hasDynamicLayers",null),e([t()],y.prototype,"layer",null),e([t({readOnly:!0})],y.prototype,"layers",null),e([t({readOnly:!0})],y.prototype,"layerDefs",null),e([t({type:Number})],y.prototype,"scale",void 0),e([t({readOnly:!0})],y.prototype,"version",null),e([t({readOnly:!0})],y.prototype,"visibleSublayers",null),y=e([i("esri.layers.support.ExportImageParameters")],y);export{y as ExportImageParameters};
5
+ import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import{sqlAnd as s}from"../../core/sql.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{isInScaleRange as a}from"../../geometry/support/scaleUtils.js";import{getLayerFloorFilterClause as o}from"./floorFilterUtils.js";import{isExportDynamic as l}from"./sublayerUtils.js";const n={visible:"visibleSublayers",definitionExpression:"layerDefs",labelingInfo:"hasDynamicLayers",labelsVisible:"hasDynamicLayers",opacity:"hasDynamicLayers",minScale:"visibleSublayers",maxScale:"visibleSublayers",renderer:"hasDynamicLayers",source:"hasDynamicLayers"};let y=class extends r{constructor(e){super(e),this.floors=null,this.scale=0}destroy(){this.layer=null}get dynamicLayers(){if(!this.hasDynamicLayers)return null;const e=this.visibleSublayers.map(e=>{const r=o(this.floors,e);return e.toExportImageJSON(r)});return e.length?JSON.stringify(e):null}get hasDynamicLayers(){return this.layer&&l(this.visibleSublayers,this.layer.serviceSublayers,this.layer.gdbVersion)}set layer(e){this._get("layer")!==e&&(this._set("layer",e),this.removeHandles("layer"),e&&this.addHandles([e.allSublayers.on("change",()=>this.notifyChange("visibleSublayers")),e.on("sublayer-update",e=>this.notifyChange(n[e.propertyName]))],"layer"))}get layers(){const e=this.visibleSublayers;return e?e.length?"show:"+e.map(e=>e.id).join(","):"show:-1":null}get layerDefs(){const e=!!this.floors?.length,r=this.visibleSublayers.filter(r=>null!=r.definitionExpression||e&&null!=r.floorInfo);return r.length?JSON.stringify(r.reduce((e,r)=>{const t=o(this.floors,r),i=s(t,r.definitionExpression);return null!=i&&(e[r.id]=i),e},{})):null}get version(){this.commitProperty("layers"),this.commitProperty("layerDefs"),this.commitProperty("dynamicLayers");const e=this.layer;return e&&(e.commitProperty("dpi"),e.commitProperty("imageFormat"),e.commitProperty("imageTransparency"),e.commitProperty("gdbVersion")),(this._get("version")||0)+1}get visibleSublayers(){const e=[];if(!this.layer)return e;const r=this.layer.sublayers,s=this.scale,t=r=>{r.visible&&(0===s||a(s,r.minScale,r.maxScale))&&(r.sublayers?r.sublayers.forEach(t):e.unshift(r))};r?.forEach(t);const i=this._get("visibleSublayers");return!i||i.length!==e.length||i.some((r,s)=>e[s]!==r)?e:i}toJSON(){const e=this.layer;let r={dpi:e.dpi,format:e.imageFormat,transparent:e.imageTransparency,gdbVersion:e.gdbVersion||null};return this.hasDynamicLayers&&this.dynamicLayers?r.dynamicLayers=this.dynamicLayers:r={...r,layers:this.layers,layerDefs:this.layerDefs},r}};e([t({readOnly:!0})],y.prototype,"dynamicLayers",null),e([t()],y.prototype,"floors",void 0),e([t({readOnly:!0})],y.prototype,"hasDynamicLayers",null),e([t()],y.prototype,"layer",null),e([t({readOnly:!0})],y.prototype,"layers",null),e([t({readOnly:!0})],y.prototype,"layerDefs",null),e([t({type:Number})],y.prototype,"scale",void 0),e([t({readOnly:!0})],y.prototype,"version",null),e([t({readOnly:!0})],y.prototype,"visibleSublayers",null),y=e([i("esri.layers.support.ExportImageParameters")],y);export{y as ExportImageParameters};